[gnome-klotski] Fix scores import
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-klotski] Fix scores import
- Date: Sun, 14 Feb 2016 22:57:54 +0000 (UTC)
commit 8c363bbac7d0a11335470248f9124f86eebf94dd
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Sun Feb 14 16:57:24 2016 -0600
Fix scores import
Broke this when switching away from integer category names
src/klotski-window.vala | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/src/klotski-window.vala b/src/klotski-window.vala
index 4013dc5..ebfc514 100644
--- a/src/klotski-window.vala
+++ b/src/klotski-window.vala
@@ -451,25 +451,29 @@ public class KlotskiWindow : ApplicationWindow
{"start-game", start_puzzle_cb}
};
+ private static string normalize_map_name (string name)
+ {
+ return name.down ().replace (" ", "-");
+ }
+
class construct
{
score_categories = new Gee.ArrayList<Games.Scores.Category> ();
for (var i = 0; i < levels.length; i++)
{
- score_categories.add (new Games.Scores.Category (levels[i].name.down ().replace (" ", "-"),
+ score_categories.add (new Games.Scores.Category (normalize_map_name (levels[i].name),
_(levels[i].name)));
}
}
private Games.Scores.Category? category_request (string key)
{
- var i = int.parse (key);
- // i will be 0 if parsing fails, but 0 is also a valid map key.
- if (i == 0 && key != "0")
- return null;
- if (i < 0 || i > score_categories.size)
- return null;
- return score_categories[i];
+ for (int i = 0; i < levels.length; i++)
+ {
+ if (key == normalize_map_name (levels[i].name))
+ return score_categories[i];
+ }
+ return null;
}
private void parse_old_score (string line, out Games.Scores.Score? score, out Games.Scores.Category?
category)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]