[gnome-nibbles] Use new scores import API of libgames-support
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles] Use new scores import API of libgames-support
- Date: Sat, 13 Feb 2016 21:12:01 +0000 (UTC)
commit 3581fbf4388bfe9e860eda2d58630cf77c35a357
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Sat Feb 13 14:49:33 2016 -0600
Use new scores import API of libgames-support
This replaces the hardcoded list of Nibbles categories I added to
libgames-support last night. It also corrects the order of the
difficulty levels, so scores actually get added to the right categories.
src/gnome-nibbles.vala | 40 ++++++++++++++++++++++++++++++++++------
1 files changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/src/gnome-nibbles.vala b/src/gnome-nibbles.vala
index 6eb63aa..820940c 100644
--- a/src/gnome-nibbles.vala
+++ b/src/gnome-nibbles.vala
@@ -606,6 +606,30 @@ public class Nibbles : Gtk.Application
return null;
}
+ private string? get_new_scores_key (string old_key)
+ {
+ switch (old_key)
+ {
+ case "1.0":
+ return "fast";
+ case "2.0":
+ return "medium";
+ case "3.0":
+ return "slow";
+ case "4.0":
+ return "beginner";
+ case "1.1":
+ return "fast-fakes";
+ case "2.1":
+ return "medium-fakes";
+ case "3.1":
+ return "slow-fakes";
+ case "4.1":
+ return "beginner-fakes";
+ }
+ return null;
+ }
+
private void create_scores ()
{
scorecats = new Gee.LinkedList<Games.Scores.Category> ();
@@ -626,12 +650,16 @@ public class Nibbles : Gtk.Application
/* Translators: Difficulty level with fake bonuses, displayed on the scores dialog */
scorecats.add (new Games.Scores.Category ("fast-fakes", _("Fast with Fakes")));
- scores_context = new Games.Scores.Context ("gnome-nibbles",
- /* Displayed on the scores dialog, preceeding a
difficulty. */
- _("Difficulty Level:"),
- window,
- category_request,
- Games.Scores.Style.PLAIN_DESCENDING);
+ var importer = new Games.Scores.Importer (Games.Scores.Importer.OldFormat.C_GAMES_MULTI_FILE_FORMAT,
+ get_new_scores_key);
+ scores_context = new Games.Scores.Context.with_importer (
+ "gnome-nibbles",
+ /* Displayed on the scores dialog, preceeding a difficulty. */
+ _("Difficulty Level:"),
+ window,
+ category_request,
+ Games.Scores.Style.PLAIN_DESCENDING,
+ importer);
}
private Games.Scores.Category get_scores_category (int speed, bool fakes)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]