[gbrainy/refactoring] Use Depedency Injection for translation service
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy/refactoring] Use Depedency Injection for translation service
- Date: Sun, 28 Aug 2011 15:01:35 +0000 (UTC)
commit 766541b2e7cb8a0421d7453cac1d9e5f718f88b9
Author: Jordi Mas <jmas softcatala org>
Date: Sun Aug 28 17:01:15 2011 +0200
Use Depedency Injection for translation service
src/Clients/Classical/CommandLine.cs | 9 ++-
src/Clients/Classical/Dialogs/BuilderDialog.cs | 8 ++-
src/Clients/Classical/Dialogs/CustomGameDialog.cs | 5 +-
src/Clients/Classical/Dialogs/PdfExportDialog.cs | 7 +-
.../Classical/Dialogs/PlayerHistoryDialog.cs | 17 ++--
src/Clients/Classical/Dialogs/PreferencesDialog.cs | 3 +-
src/Clients/Classical/gbrainy.cs | 39 +++++----
src/Clients/WebForms/Game.aspx.cs | 39 +++++----
src/Clients/WebForms/LanguageSupport.cs | 3 +
src/Clients/WebForms/Status.aspx.cs | 6 +-
src/Clients/WebForms/TranslationsWeb.cs | 23 ++---
src/Clients/WebForms/web.config | 2 +-
src/Core/Core.csproj | 1 +
src/Core/Libraries/TranslationsCatalog.cs | 2 +
src/Core/Main/ColorPalette.cs | 52 ++++++-----
src/Core/Main/Game.cs | 15 +++-
src/Core/Main/GameAnswer.cs | 29 +++---
src/Core/Main/GameManager.cs | 6 +-
src/Core/Main/GameSession.cs | 22 +++--
src/Core/Main/GameSessionHistory.cs | 39 ++++----
src/Core/Main/GameTips.cs | 48 ++++++-----
src/Core/Main/GameTypes.cs | 10 +-
src/Core/Main/Memory.cs | 6 +-
src/Core/Main/Verbal/Analogies.cs | 14 ++--
src/Core/Main/Verbal/AnalogiesMultipleOptions.cs | 8 +-
.../Main/Verbal/AnalogiesPairOfWordsCompare.cs | 6 +-
.../Main/Verbal/AnalogiesPairOfWordsOptions.cs | 12 ++--
src/Core/Main/Verbal/AnalogiesQuestionAnswer.cs | 2 +-
src/Core/Main/Xml/GameXml.cs | 16 ++--
src/Core/Main/Xml/GameXmlDrawing.cs | 6 +-
src/Core/Services/ITranslations.cs | 1 +
src/Core/Views/CountDownView.cs | 6 +-
src/Core/Views/FinishView.cs | 44 +++++----
src/Core/Views/PlayerHistoryView.cs | 18 ++--
src/Core/Views/ViewsControler.cs | 7 +-
src/Core/Views/WelcomeView.cs | 18 ++--
src/Games/Calculation/CalculationArithmetical.cs | 4 +-
src/Games/Calculation/CalculationAverage.cs | 10 +-
src/Games/Calculation/CalculationCloserFraction.cs | 10 +-
src/Games/Calculation/CalculationFractions.cs | 4 +-
.../Calculation/CalculationGreatestDivisor.cs | 10 +-
src/Games/Calculation/CalculationOperator.cs | 8 +-
src/Games/Calculation/CalculationPrimes.cs | 10 +-
src/Games/Calculation/CalculationProportions.cs | 6 +-
src/Games/Calculation/CalculationRatio.cs | 14 ++--
src/Games/Calculation/CalculationTwoNumbers.cs | 14 ++--
src/Games/Logic/Puzzle3DCube.cs | 6 +-
src/Games/Logic/PuzzleBalance.cs | 8 +-
src/Games/Logic/PuzzleBuildTriangle.cs | 8 +-
src/Games/Logic/PuzzleCirclesSquare.cs | 16 ++--
src/Games/Logic/PuzzleClocks.cs | 8 +-
src/Games/Logic/PuzzleCountCircles.cs | 6 +-
src/Games/Logic/PuzzleCountSeries.cs | 16 ++--
src/Games/Logic/PuzzleCounting.cs | 16 ++--
src/Games/Logic/PuzzleCoverPercentage.cs | 4 +-
src/Games/Logic/PuzzleCube.cs | 4 +-
src/Games/Logic/PuzzleDice.cs | 18 ++--
src/Games/Logic/PuzzleDivideCircle.cs | 8 +-
src/Games/Logic/PuzzleEquation.cs | 6 +-
src/Games/Logic/PuzzleExtraCircle.cs | 10 +-
src/Games/Logic/PuzzleFigureLetter.cs | 8 +-
src/Games/Logic/PuzzleFigurePattern.cs | 10 +-
src/Games/Logic/PuzzleFigures.cs | 8 +-
src/Games/Logic/PuzzleFourSided.cs | 8 +-
src/Games/Logic/PuzzleGridCircles.cs | 8 +-
src/Games/Logic/PuzzleGridDots.cs | 10 +-
src/Games/Logic/PuzzleGridNumbers.cs | 20 ++--
src/Games/Logic/PuzzleHandshakes.cs | 6 +-
src/Games/Logic/PuzzleLargerShape.cs | 8 +-
src/Games/Logic/PuzzleLines.cs | 8 +-
src/Games/Logic/PuzzleMissingPiece.cs | 10 +-
src/Games/Logic/PuzzleMissingSlice.cs | 10 +-
src/Games/Logic/PuzzleMostInCommon.cs | 12 ++--
src/Games/Logic/PuzzleMoveFigure.cs | 8 +-
src/Games/Logic/PuzzleNextFigure.cs | 8 +-
src/Games/Logic/PuzzleNumericRelation.cs | 12 ++--
src/Games/Logic/PuzzleNumericSequence.cs | 12 ++--
src/Games/Logic/PuzzleOstracism.cs | 16 ++--
src/Games/Logic/PuzzlePencil.cs | 4 +-
src/Games/Logic/PuzzlePeopleTable.cs | 20 ++--
src/Games/Logic/PuzzlePercentage.cs | 10 +-
src/Games/Logic/PuzzlePredicateLogic.cs | 96 ++++++++++----------
src/Games/Logic/PuzzleQuadrilaterals.cs | 6 +-
src/Games/Logic/PuzzleRelatedNumbers.cs | 12 ++--
src/Games/Logic/PuzzleSquareSheets.cs | 8 +-
src/Games/Logic/PuzzleSquares.cs | 10 +-
src/Games/Logic/PuzzleSquaresAndLetters.cs | 6 +-
src/Games/Logic/PuzzleTetris.cs | 8 +-
src/Games/Logic/PuzzleTimeNow.cs | 10 +-
src/Games/Logic/PuzzleTrains.cs | 16 ++--
src/Games/Logic/PuzzleTriangles.cs | 8 +-
src/Games/Logic/PuzzleTrianglesWithNumbers.cs | 8 +-
src/Games/Memory/MemoryColouredFigures.cs | 6 +-
src/Games/Memory/MemoryColouredText.cs | 6 +-
src/Games/Memory/MemoryCountDots.cs | 6 +-
src/Games/Memory/MemoryFacts.cs | 24 +++---
src/Games/Memory/MemoryFigures.cs | 4 +-
src/Games/Memory/MemoryFiguresAndText.cs | 16 ++--
src/Games/Memory/MemoryFiguresNumbers.cs | 4 +-
src/Games/Memory/MemoryIndications.cs | 56 ++++++------
src/Games/Memory/MemoryNumbers.cs | 35 ++++++--
src/Games/Memory/MemoryWords.cs | 74 ++++++++--------
tests/Clients/Classical/CommandLineTest.cs | 10 ++-
tests/Clients/Classical/gbrainyTest.cs | 7 +-
tests/Core/GameAnswerTest.cs | 24 +++---
tests/Core/GameSessionTest.cs | 2 +-
106 files changed, 776 insertions(+), 675 deletions(-)
---
diff --git a/src/Clients/Classical/CommandLine.cs b/src/Clients/Classical/CommandLine.cs
index 6056c0b..abe44c6 100644
--- a/src/Clients/Classical/CommandLine.cs
+++ b/src/Clients/Classical/CommandLine.cs
@@ -24,6 +24,7 @@ using System.Collections.Generic;
using System.Reflection;
using gbrainy.Core.Main;
+using gbrainy.Core.Services;
namespace gbrainy.Clients.Classical
{
@@ -32,11 +33,13 @@ namespace gbrainy.Clients.Classical
string [] args;
int [] play_list;
bool cont_execution;
+ ITranslations translations;
public static readonly char GAME_SEPARATOR = ',';
- public CommandLine (string [] args)
+ public CommandLine (ITranslations translations, string [] args)
{
+ this.translations = translations;
this.args = args;
RandomOrder = true;
play_list = new int [0];
@@ -106,7 +109,7 @@ namespace gbrainy.Clients.Classical
String.Format (Catalog.GetString ("(built on {0})"), Defines.BUILD_TIME));
}
- static void GameList ()
+ void GameList ()
{
GameLocator [] games;
GameManager gm = new GameManager ();
@@ -122,6 +125,7 @@ namespace gbrainy.Clients.Classical
continue;
Game game = (Game) Activator.CreateInstance (games[i].TypeOf, true);
+ game.translations = translations;
game.Variant = games[i].Variant;
Console.WriteLine (" {0}", game.Name);
}
@@ -143,6 +147,7 @@ namespace gbrainy.Clients.Classical
continue;
Game game = (Game) Activator.CreateInstance (games[i].TypeOf, true);
+ game.translations = translations;
game.Variant = games[i].Variant;
try
diff --git a/src/Clients/Classical/Dialogs/BuilderDialog.cs b/src/Clients/Classical/Dialogs/BuilderDialog.cs
index 5e56fbe..44ce288 100644
--- a/src/Clients/Classical/Dialogs/BuilderDialog.cs
+++ b/src/Clients/Classical/Dialogs/BuilderDialog.cs
@@ -17,12 +17,18 @@
* Boston, MA 02111-1307, USA.
*/
+using gbrainy.Core.Services;
+
namespace gbrainy.Clients.Classical.Dialogs
{
public class BuilderDialog : Gtk.Dialog
{
- public BuilderDialog (string resourceName, string dialogName) : this (null, resourceName, dialogName)
+ ITranslations translations;
+
+ public BuilderDialog (ITranslations translations, string resourceName, string dialogName) :
+ this ((System.Reflection.Assembly) null, resourceName, dialogName)
{
+ this.translations = translations;
}
public BuilderDialog (System.Reflection.Assembly assembly, string resourceName, string dialogName) :
diff --git a/src/Clients/Classical/Dialogs/CustomGameDialog.cs b/src/Clients/Classical/Dialogs/CustomGameDialog.cs
index 0b2627f..3449a58 100644
--- a/src/Clients/Classical/Dialogs/CustomGameDialog.cs
+++ b/src/Clients/Classical/Dialogs/CustomGameDialog.cs
@@ -23,6 +23,7 @@ using Mono.Unix;
using System.Collections.Generic;
using gbrainy.Core.Main;
+using gbrainy.Core.Services;
using gbrainy.Clients.Classical.Widgets;
namespace gbrainy.Clients.Classical.Dialogs
@@ -44,7 +45,7 @@ namespace gbrainy.Clients.Classical.Dialogs
const int COL_OBJECT = 3;
const int COL_INDEX = 4;
- public CustomGameDialog (GameSession session) : base ("CustomGameDialog.ui", "customgame")
+ public CustomGameDialog (ITranslations translations, GameSession session) : base (translations, "CustomGameDialog.ui", "customgame")
{
Game game;
@@ -126,7 +127,7 @@ namespace gbrainy.Clients.Classical.Dialogs
game = (Game) Activator.CreateInstance (games [i].TypeOf, true);
game.Variant = games [i].Variant;
- type = GameTypesDescription.GetLocalized (game.Type);
+ type = GameTypesDescription.GetLocalized (translations, game.Type);
games_store.AppendValues (game.Name, type, true, game, i);
}
}
diff --git a/src/Clients/Classical/Dialogs/PdfExportDialog.cs b/src/Clients/Classical/Dialogs/PdfExportDialog.cs
index a76025c..3b3ba32 100644
--- a/src/Clients/Classical/Dialogs/PdfExportDialog.cs
+++ b/src/Clients/Classical/Dialogs/PdfExportDialog.cs
@@ -23,6 +23,7 @@ using Gtk;
using Mono.Unix;
using gbrainy.Core.Main;
+using gbrainy.Core.Services;
using gbrainy.Clients.Classical.Widgets;
namespace gbrainy.Clients.Classical.Dialogs
@@ -42,12 +43,14 @@ namespace gbrainy.Clients.Classical.Dialogs
BrowseFile file;
GameManager manager;
+ ITranslations translations;
const int COLUMN_VALUE = 1;
const int DEF_SIDEVALUE = 4;
- public PdfExportDialog (GameManager manager) : base ("PdfExportDialog.ui", "pdfexportbox")
+ public PdfExportDialog (GameManager manager, ITranslations translations) : base (translations, "PdfExportDialog.ui", "pdfexportbox")
{
this.manager = manager;
+ this.translations = translations;
games_spinbutton.Value = 10;
checkbox_logic.Active = checkbox_calculation.Active = checkbox_verbal.Active = true;
@@ -154,7 +157,7 @@ namespace gbrainy.Clients.Classical.Dialogs
MessageType msg_type;
games = new Game [num_games];
- session = new GameSession ();
+ session = new GameSession (translations);
session.GameManager = manager;
session.PlayList.ColorBlind = colorblind;
session.PlayList.Difficulty = difficulty;
diff --git a/src/Clients/Classical/Dialogs/PlayerHistoryDialog.cs b/src/Clients/Classical/Dialogs/PlayerHistoryDialog.cs
index e01cb10..8018edc 100644
--- a/src/Clients/Classical/Dialogs/PlayerHistoryDialog.cs
+++ b/src/Clients/Classical/Dialogs/PlayerHistoryDialog.cs
@@ -23,6 +23,7 @@ using Mono.Unix;
using gbrainy.Core.Main;
using gbrainy.Core.Views;
+using gbrainy.Core.Services;
namespace gbrainy.Clients.Classical.Dialogs
{
@@ -38,7 +39,7 @@ namespace gbrainy.Clients.Classical.Dialogs
CairoPreview drawing_area;
- public PlayerHistoryDialog (PlayerHistory history) : base ("PlayerHistoryDialog.ui", "playerhistory")
+ public PlayerHistoryDialog (ITranslations translations, PlayerHistory history) : base (translations, "PlayerHistoryDialog.ui", "playerhistory")
{
string intro, built;
@@ -59,15 +60,15 @@ namespace gbrainy.Clients.Classical.Dialogs
// Translators: "The graph below" + "It is built using" sentences
label_playerhistory.Text = String.Format (Catalog.GetString ("{0} {1}"), intro, built);
- drawing_area = new CairoPreview (history);
+ drawing_area = new CairoPreview (translations, history);
history_preview.Add (drawing_area);
drawing_area.Visible = true;
checkbutton_total.Label = Catalog.GetString ("Total");
- checkbutton_logic.Label = GameTypesDescription.GetLocalized (GameTypes.LogicPuzzle);
- checkbutton_calculation.Label = GameTypesDescription.GetLocalized (GameTypes.Calculation);
- checkbutton_memory.Label = GameTypesDescription.GetLocalized (GameTypes.Memory);
- checkbutton_verbal.Label = GameTypesDescription.GetLocalized (GameTypes.VerbalAnalogy);
+ checkbutton_logic.Label = GameTypesDescription.GetLocalized (translations, GameTypes.LogicPuzzle);
+ checkbutton_calculation.Label = GameTypesDescription.GetLocalized (translations, GameTypes.Calculation);
+ checkbutton_memory.Label = GameTypesDescription.GetLocalized (translations, GameTypes.Memory);
+ checkbutton_verbal.Label = GameTypesDescription.GetLocalized (translations, GameTypes.VerbalAnalogy);
checkbutton_total.Active = checkbutton_memory.Active = checkbutton_logic.Active = checkbutton_calculation.Active = checkbutton_verbal.Active = true;
}
@@ -106,9 +107,9 @@ namespace gbrainy.Clients.Classical.Dialogs
{
PlayerHistoryView view;
- public CairoPreview (PlayerHistory history)
+ public CairoPreview (ITranslations translations, PlayerHistory history)
{
- view = new PlayerHistoryView (history);
+ view = new PlayerHistoryView (translations, history);
}
public PlayerHistoryView View {
diff --git a/src/Clients/Classical/Dialogs/PreferencesDialog.cs b/src/Clients/Classical/Dialogs/PreferencesDialog.cs
index 9d85f55..42a54c1 100644
--- a/src/Clients/Classical/Dialogs/PreferencesDialog.cs
+++ b/src/Clients/Classical/Dialogs/PreferencesDialog.cs
@@ -22,6 +22,7 @@ using Gtk;
using Mono.Unix;
using gbrainy.Core.Main;
+using gbrainy.Core.Services;
namespace gbrainy.Clients.Classical.Dialogs
{
@@ -41,7 +42,7 @@ namespace gbrainy.Clients.Classical.Dialogs
const int COLUMN_VALUE = 1;
PlayerHistory history;
- public PreferencesDialog (PlayerHistory history) : base ("PreferencesDialog.ui", "preferences")
+ public PreferencesDialog (ITranslations translations, PlayerHistory history) : base (translations, "PreferencesDialog.ui", "preferences")
{
this.history = history;
prefspinbutton.Value = Preferences.Get <int> (Preferences.MemQuestionTimeKey);
diff --git a/src/Clients/Classical/gbrainy.cs b/src/Clients/Classical/gbrainy.cs
index 8128214..d10f2a6 100644
--- a/src/Clients/Classical/gbrainy.cs
+++ b/src/Clients/Classical/gbrainy.cs
@@ -27,6 +27,7 @@ using System.Reflection;
using gbrainy.Core.Main;
using gbrainy.Core.Platform;
using gbrainy.Core.Services;
+using gbrainy.Core.Libraries;
using gbrainy.Clients.Classical.Dialogs;
using gbrainy.Clients.Classical.Widgets;
@@ -71,14 +72,16 @@ namespace gbrainy.Clients.Classical
bool low_res;
bool full_screen;
GameSession.Types initial_session;
+ ITranslations translations;
public readonly int MIN_TRANSLATION = 80;
- public GtkClient ()
+ public GtkClient (ITranslations translations)
{
+ this.translations = translations;
if (Preferences.Get <bool> (Preferences.EnglishKey) == false)
{
- Catalog.Init ("gbrainy", Defines.GNOME_LOCALE_DIR);
+ translations.Init ("gbrainy", Defines.GNOME_LOCALE_DIR);
}
Unix.FixLocaleInfo ();
@@ -95,9 +98,10 @@ namespace gbrainy.Clients.Classical
public void Initialize ()
{
- session = new GameSession ();
+ session = new GameSession (translations);
+
GameManagerPreload (session.GameManager);
- Console.WriteLine (session.GameManager.GetGamesSummary ());
+ Console.WriteLine (session.GameManager.GetGamesSummary (translations));
session.PlayList.ColorBlind = Preferences.Get <bool> (Preferences.ColorBlindKey);
session.DrawRequest += SessionDrawRequest;
@@ -419,9 +423,9 @@ namespace gbrainy.Clients.Classical
correct = session.ScoreGame (answer_entry.Text);
if (correct)
- answer = Catalog.GetString ("Congratulations.");
+ answer = translations.GetString ("Congratulations.");
else
- answer = Catalog.GetString ("Incorrect answer.");
+ answer = translations.GetString ("Incorrect answer.");
session.EnableTimer = false;
answer_entry.Text = String.Empty;
@@ -476,7 +480,7 @@ namespace gbrainy.Clients.Classical
session.New ();
GetNextGame ();
GameSensitiveUI ();
- UpdateSolution (Catalog.GetString ("Once you have an answer type it in the \"Answer:\" entry box and press the \"OK\" button."),
+ UpdateSolution (translations.GetString ("Once you have an answer type it in the \"Answer:\" entry box and press the \"OK\" button."),
GameDrawingArea.SolutionType.Tip);
UpdateStatusBar ();
}
@@ -506,8 +510,8 @@ namespace gbrainy.Clients.Classical
Gtk.DialogFlags.DestroyWithParent,
Gtk.MessageType.Warning,
Gtk.ButtonsType.Ok,
- Catalog.GetString ("The level of translation of gbrainy for your language is low."),
- Catalog.GetString ("You may be exposed to partially translated games making it more difficult to play. If you prefer to play in English, there is an option for doing so in gbrainy's Preferences."));
+ translations.GetString ("The level of translation of gbrainy for your language is low."),
+ translations.GetString ("You may be exposed to partially translated games making it more difficult to play. If you prefer to play in English, there is an option for doing so in gbrainy's Preferences."));
try {
dlg.Run ();
@@ -535,7 +539,7 @@ namespace gbrainy.Clients.Classical
{
PdfExportDialog pdf;
- pdf = new PdfExportDialog (session.GameManager);
+ pdf = new PdfExportDialog (session.GameManager, translations);
pdf.Run ();
pdf.Destroy ();
}
@@ -544,7 +548,7 @@ namespace gbrainy.Clients.Classical
{
PreferencesDialog dialog;
- dialog = new PreferencesDialog (session.PlayerHistory);
+ dialog = new PreferencesDialog (translations, session.PlayerHistory);
if ((Gtk.ResponseType) dialog.Run () == ResponseType.Ok) {
session.Difficulty = (GameDifficulty) Preferences.Get <int> (Preferences.DifficultyKey);
session.PlayList.ColorBlind = Preferences.Get <bool> (Preferences.ColorBlindKey);
@@ -559,7 +563,7 @@ namespace gbrainy.Clients.Classical
{
CustomGameDialog dialog;
- dialog = new CustomGameDialog (session);
+ dialog = new CustomGameDialog (translations, session);
dialog.Run ();
dialog.Destroy ();
@@ -603,12 +607,12 @@ namespace gbrainy.Clients.Classical
if (pause) {
drawing_area.Paused = false;
toolbar.PauseButton.StockId = "pause";
- toolbar.PauseButton.Label = Catalog.GetString ("Pause");
+ toolbar.PauseButton.Label = translations.GetString ("Pause");
ActiveInputControls (true);
} else {
drawing_area.Paused = true;
toolbar.PauseButton.StockId = "resume";
- toolbar.PauseButton.Label = Catalog.GetString ("Resume");
+ toolbar.PauseButton.Label = translations.GetString ("Resume");
ActiveInputControls (false);
}
UpdateStatusBar ();
@@ -685,7 +689,7 @@ namespace gbrainy.Clients.Classical
{
PlayerHistoryDialog dialog;
- dialog = new PlayerHistoryDialog (session.PlayerHistory);
+ dialog = new PlayerHistoryDialog (translations, session.PlayerHistory);
dialog.Run ();
dialog.Destroy ();
}
@@ -732,13 +736,14 @@ namespace gbrainy.Clients.Classical
}
DateTime start_time = DateTime.Now;
+ ITranslations translations = new TranslationsCatalog ();
InitCoreLibraries ();
- GtkClient app = new GtkClient ();
+ GtkClient app = new GtkClient (translations);
CommandLine.Version ();
- CommandLine line = new CommandLine (args);
+ CommandLine line = new CommandLine (translations, args);
line.Parse ();
if (line.Continue == false)
diff --git a/src/Clients/WebForms/Game.aspx.cs b/src/Clients/WebForms/Game.aspx.cs
index ac1a7b2..31b46cd 100644
--- a/src/Clients/WebForms/Game.aspx.cs
+++ b/src/Clients/WebForms/Game.aspx.cs
@@ -36,6 +36,7 @@ namespace gbrainy.Clients.WebForms
gbrainy.Core.Main.GameSession session;
WebSession web_session;
GameImage image;
+ TranslationsWeb translations;
static public GameManager CreateManager ()
{
@@ -59,11 +60,6 @@ namespace gbrainy.Clients.WebForms
}
}
- string GetLanguageFromSessionHandler ()
- {
- return WebSession.LanguageCode;
- }
-
// Page Life-Cycle Events
//
// - Page_Load
@@ -102,6 +98,9 @@ namespace gbrainy.Clients.WebForms
HtmlForm form = (HtmlForm) Master.FindControl ("main_form");
form.DefaultButton = answer_button.UniqueID;
+ translations = new TranslationsWeb ();
+ translations.Language = WebSession.LanguageCode;
+
string answer = Request.QueryString ["answer"];
if (IsPostBack == false && string.IsNullOrEmpty (answer) == false)
{
@@ -109,9 +108,9 @@ namespace gbrainy.Clients.WebForms
}
if (WebSession.GameState == null)
- {
+ {
Logger.Debug ("Game.Page_Load creating new session");
- session = new gbrainy.Core.Main.GameSession ();
+ session = new gbrainy.Core.Main.GameSession (translations);
session.GameManager = CreateManager ();
session.PlayList.Difficulty = gbrainy.Core.Main.GameDifficulty.Medium;
session.PlayList.GameType = gbrainy.Core.Main.GameSession.Types.LogicPuzzles |
@@ -150,6 +149,9 @@ namespace gbrainy.Clients.WebForms
UpdateGame ();
}
+
+ if (IsPostBack == false)
+ SetText ();
if (IsPostBack == true) {
Logger.Debug ("Game.Page_Load. Ignoring postback");
@@ -161,24 +163,27 @@ namespace gbrainy.Clients.WebForms
void InitPage ()
{
- TranslationsWeb service = (TranslationsWeb) ServiceLocator.Instance.GetService <ITranslations> ();
- service.OnGetLanguageFromSession = GetLanguageFromSessionHandler;
-
game_image.Width = GameImage.IMAGE_WIDTH;
game_image.Height = GameImage.IMAGE_HEIGHT;
-
+ }
+
+ void SetText ()
+ {
nextgame_link.Text = "Next Game";
+
+ if (translations == null)
+ return;
// Toolbar
- allgames_label.Text = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All");
- endgames_label.Text = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("End");
- }
+ allgames_label.Text = translations.GetString ("All");
+ endgames_label.Text = translations.GetString ("End");
+ }
void UpdateGame ()
{
if (_game == null)
return;
-
+
status.Text = session.StatusText;
question.Text = _game.Question;
@@ -236,11 +241,11 @@ namespace gbrainy.Clients.WebForms
return;
if (web_session.GameState.ScoreGame (answer) == true) {
- result_label.Text = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Congratulations.");
+ result_label.Text = translations.GetString ("Congratulations.");
result_label.CssClass = "CorrectAnswer";
}
else {
- result_label.Text = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Incorrect answer.");
+ result_label.Text = translations.GetString ("Incorrect answer.");
result_label.CssClass = null;
}
diff --git a/src/Clients/WebForms/LanguageSupport.cs b/src/Clients/WebForms/LanguageSupport.cs
index de3dbee..1e0eef6 100644
--- a/src/Clients/WebForms/LanguageSupport.cs
+++ b/src/Clients/WebForms/LanguageSupport.cs
@@ -87,6 +87,9 @@ namespace gbrainy.Clients.WebForms
static public Language GetFromCode (string code)
{
+ if (String.IsNullOrEmpty (code))
+ return languages [0];
+
if (langmap.ContainsKey (code) == false)
return languages [0];
diff --git a/src/Clients/WebForms/Status.aspx.cs b/src/Clients/WebForms/Status.aspx.cs
index 470dcf5..bc2da07 100644
--- a/src/Clients/WebForms/Status.aspx.cs
+++ b/src/Clients/WebForms/Status.aspx.cs
@@ -116,9 +116,9 @@ namespace gbrainy.Clients.WebForms
total_label.Text = "Total active sessions: " + Global.Sessions.Count;
// Games
- string text = Game.CreateManager ().GetGamesSummary ();
- text = text.Replace (Environment.NewLine, "<br/>");
- games_label.Text = text;
+ //string text = Game.CreateManager ().GetGamesSummary ();
+ //text = text.Replace (Environment.NewLine, "<br/>");
+ //games_label.Text = text;
// Assemblies
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
diff --git a/src/Clients/WebForms/TranslationsWeb.cs b/src/Clients/WebForms/TranslationsWeb.cs
index 3679076..6ac928d 100644
--- a/src/Clients/WebForms/TranslationsWeb.cs
+++ b/src/Clients/WebForms/TranslationsWeb.cs
@@ -26,27 +26,24 @@ namespace gbrainy.Clients.WebForms
{
public class TranslationsWeb : ITranslations
{
- public delegate string GetLanguageFromSessionHandler ();
static readonly object sync = new object ();
public int TranslationPercentage {
get { return 100;}
}
-
- public GetLanguageFromSessionHandler OnGetLanguageFromSession;
+
+ string language;
+ public string Language {
+ get { return language;}
+ set {
+ language = value;
+ }
+ }
public void Init (string package, string localedir)
{
Catalog.Init (package, localedir);
}
-
- string GetLanguageFromSession ()
- {
- if (OnGetLanguageFromSession == null)
- return LanguageSupport.Languages [0].LangCode;
-
- return OnGetLanguageFromSession ();
- }
public string GetString (string s)
{
@@ -54,7 +51,7 @@ namespace gbrainy.Clients.WebForms
lock (sync)
{
- string code = GetLanguageFromSession ();
+ string code = Language;
SetContext (code);
str = Catalog.GetString (s);
}
@@ -67,7 +64,7 @@ namespace gbrainy.Clients.WebForms
lock (sync)
{
- string code = GetLanguageFromSession ();
+ string code = Language;
SetContext (code);
str = Catalog.GetPluralString (s, p, n);
}
diff --git a/src/Clients/WebForms/web.config b/src/Clients/WebForms/web.config
index 7065a94..e2691f2 100644
--- a/src/Clients/WebForms/web.config
+++ b/src/Clients/WebForms/web.config
@@ -33,7 +33,7 @@ http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx
<!-- Used to decide if Google Analytics is shown -->
<appSettings>
- <add key="Production" value="1" />
+ <add key="Production" value="0" />
</appSettings>
</configuration>
diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj
index 81fc733..ba6a28a 100644
--- a/src/Core/Core.csproj
+++ b/src/Core/Core.csproj
@@ -118,6 +118,7 @@
<Compile Include="Main\PreferencesStorage.cs" />
<Compile Include="Main\GameSessionPlayList.cs" />
<Compile Include="Main\GameLocator.cs" />
+ <Compile Include="Main\Xml\GameXmlDrawing.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
diff --git a/src/Core/Libraries/TranslationsCatalog.cs b/src/Core/Libraries/TranslationsCatalog.cs
index 0f1c37c..1f36da0 100644
--- a/src/Core/Libraries/TranslationsCatalog.cs
+++ b/src/Core/Libraries/TranslationsCatalog.cs
@@ -28,6 +28,8 @@ namespace gbrainy.Core.Libraries
{
double strings, translated;
const int max_sample = 250;
+
+ public string Language { set; get; }
public int TranslationPercentage {
get {
diff --git a/src/Core/Main/ColorPalette.cs b/src/Core/Main/ColorPalette.cs
index 23a3c72..646d2e3 100644
--- a/src/Core/Main/ColorPalette.cs
+++ b/src/Core/Main/ColorPalette.cs
@@ -27,6 +27,7 @@ namespace gbrainy.Core.Main
public class ColorPalette
{
double alpha;
+ ITranslations translations;
public enum Id
{
@@ -44,33 +45,40 @@ namespace gbrainy.Core.Main
White=Last
};
- private static readonly string[] ColorName= new string[] {
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("red"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("green"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("blue"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("yellow"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("magenta"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("orange"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("black"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("white")
- };
-
- private static Cairo.Color[] CairoColor = new Cairo.Color[] {
- new Cairo.Color (0.81, 0.1, 0.13),
- new Cairo.Color (0.54, 0.71, 0.24),
- new Cairo.Color (0.17, 0.23 ,0.56),
- new Cairo.Color (0.86, 0.85, 0.25),
- new Cairo.Color (0.82, 0.25, 0.59),
- new Cairo.Color (1, 0.54, 0),
- new Cairo.Color (0, 0, 0),
- new Cairo.Color (.9, .9, .9)
- };
+ private string[] ColorName;
+ private Cairo.Color[] CairoColor;
- public ColorPalette ()
+ public ColorPalette (ITranslations translations)
{
+ this.translations = translations;
alpha = 1;
}
+ void LoadColorArrays ()
+ {
+ CairoColor = new Cairo.Color[] {
+ new Cairo.Color (0.81, 0.1, 0.13),
+ new Cairo.Color (0.54, 0.71, 0.24),
+ new Cairo.Color (0.17, 0.23 ,0.56),
+ new Cairo.Color (0.86, 0.85, 0.25),
+ new Cairo.Color (0.82, 0.25, 0.59),
+ new Cairo.Color (1, 0.54, 0),
+ new Cairo.Color (0, 0, 0),
+ new Cairo.Color (.9, .9, .9)
+ };
+
+ ColorName = new string[] {
+ translations.GetString ("red"),
+ translations.GetString ("green"),
+ translations.GetString ("blue"),
+ translations.GetString ("yellow"),
+ translations.GetString ("magenta"),
+ translations.GetString ("orange"),
+ translations.GetString ("black"),
+ translations.GetString ("white")
+ };
+ }
+
public double Alpha {
set { alpha = value; }
get { return alpha; }
diff --git a/src/Core/Main/Game.cs b/src/Core/Main/Game.cs
index 3b84f69..12152f5 100644
--- a/src/Core/Main/Game.cs
+++ b/src/Core/Main/Game.cs
@@ -47,7 +47,6 @@ namespace gbrainy.Core.Main
{
containers = new List <Toolkit.Container> ();
difficulty = GameDifficulty.Medium;
- answer = new GameAnswer ();
}
public GameAnswer Answer {
@@ -55,6 +54,16 @@ namespace gbrainy.Core.Main
set {answer = value; }
}
+ // At some point, we may move this to constructor injection
+ ITranslations _translations;
+ public ITranslations translations {
+ set {
+ _translations = value;
+ answer = new GameAnswer (translations);
+ }
+ get { return _translations; }
+ }
+
#region Methods to override in your own games
public abstract string Name {
@@ -125,14 +134,14 @@ namespace gbrainy.Core.Main
get {
string str;
- str = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The correct answer is {0}."),
+ str = String.Format (translations.GetString ("The correct answer is {0}."),
Answer.CorrectShow);
if (String.IsNullOrEmpty (Rationale))
return str;
// Translators: answer + rationale of the answer
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} {1}"), str, Rationale);
+ return String.Format (translations.GetString ("{0} {1}"), str, Rationale);
}
}
diff --git a/src/Core/Main/GameAnswer.cs b/src/Core/Main/GameAnswer.cs
index 828048e..f2a504c 100644
--- a/src/Core/Main/GameAnswer.cs
+++ b/src/Core/Main/GameAnswer.cs
@@ -30,9 +30,11 @@ namespace gbrainy.Core.Main
static char separator = '|';
const int MAX_POSSIBLE_ANSWER = 7;
string correct;
+ ITranslations translations;
- public GameAnswer ()
+ public GameAnswer (ITranslations translations)
{
+ this.translations = translations;
CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase;
CheckExpression = ".+";
}
@@ -105,21 +107,21 @@ namespace gbrainy.Core.Main
// For languages represented with the Latin alphabet use
// the same than English
case 0: // First possible answer for a series (e.g.: Figure A)
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("A");
+ return translations.GetString ("A");
case 1: // Second possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("B");
+ return translations.GetString ("B");
case 2: // Third possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("C");
+ return translations.GetString ("C");
case 3: // Fourth possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("D");
+ return translations.GetString ("D");
case 4: // Fifth possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("E");
+ return translations.GetString ("E");
case 5: // Sixth possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("F");
+ return translations.GetString ("F");
case 6: // Seventh possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("G");
+ return translations.GetString ("G");
case 7: // Eighth possible answer for a series
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("H");
+ return translations.GetString ("H");
default:
throw new ArgumentOutOfRangeException ("Do not have an option for this answer");
}
@@ -134,15 +136,15 @@ namespace gbrainy.Core.Main
throw new InvalidOperationException ("You need more than 1 answer to select from");
case 2:
// Translators. This is the list of valid answers, like A or B.
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} or {1}"),
+ return String.Format (translations.GetString ("{0} or {1}"),
GetMultiOption (0), GetMultiOption (1));
case 3:
// Translators. This is the list of valid answers, like A, B or C.
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}, {1} or {2}"),
+ return String.Format (translations.GetString ("{0}, {1} or {2}"),
GetMultiOption (0), GetMultiOption (1), GetMultiOption (2));
case 4:
// Translators. This is the list of valid answers, like A, B, C or D.
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}, {1}, {2} or {3}"),
+ return String.Format (translations.GetString ("{0}, {1}, {2} or {3}"),
GetMultiOption (0), GetMultiOption (1), GetMultiOption (2), GetMultiOption (3));
default:
throw new InvalidOperationException ("Number of multiple options not supported");
@@ -151,8 +153,7 @@ namespace gbrainy.Core.Main
public string GetFigureName (int answer)
{
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ()
- .GetString ("Figure {0}"), GetMultiOptionInternal (answer));
+ return String.Format (translations.GetString ("Figure {0}"), GetMultiOptionInternal (answer));
}
public bool CheckAnswer (string answer)
diff --git a/src/Core/Main/GameManager.cs b/src/Core/Main/GameManager.cs
index 02cc152..bb3d758 100644
--- a/src/Core/Main/GameManager.cs
+++ b/src/Core/Main/GameManager.cs
@@ -244,17 +244,17 @@ namespace gbrainy.Core.Main
available_games.Clear ();
}
- public string GetGamesSummary ()
+ public string GetGamesSummary (ITranslations translations)
{
String s = string.Empty;
#if MONO_ADDINS
- s += ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Extensions database:") + " " +
+ s += translations.GetString ("Extensions database:") + " " +
System.IO.Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "gbrainy");
s += Environment.NewLine;
#endif
// Translators: 'Games registered' is the games know to gbrainy (build-in and load from addins-in and external files)
- s += String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} games registered: {1} logic puzzles, {2} calculation trainers, {3} memory trainers, {4} verbal analogies"),
+ s += String.Format (translations.GetString ("{0} games registered: {1} logic puzzles, {2} calculation trainers, {3} memory trainers, {4} verbal analogies"),
cnt_logic + cnt_memory + cnt_calculation + cnt_verbal,
cnt_logic, cnt_calculation, cnt_memory, cnt_verbal);
diff --git a/src/Core/Main/GameSession.cs b/src/Core/Main/GameSession.cs
index 70b17bf..4b5d568 100644
--- a/src/Core/Main/GameSession.cs
+++ b/src/Core/Main/GameSession.cs
@@ -61,12 +61,15 @@ namespace gbrainy.Core.Main
private int id;
private GameSessionHistoryExtended history;
private GameSessionPlayList play_list;
-
+ private ITranslations translations;
+
public event EventHandler DrawRequest;
public event EventHandler <UpdateUIStateEventArgs> UpdateUIElement;
+
- public GameSession ()
+ public GameSession (ITranslations translations)
{
+ this.translations = translations;
id = 0;
game_manager = new GameManager ();
play_list = new GameSessionPlayList (game_manager);
@@ -76,7 +79,7 @@ namespace gbrainy.Core.Main
timer.Elapsed += TimerUpdater;
timer.Interval = (1 * 1000); // 1 second
- controler = new ViewsControler (this);
+ controler = new ViewsControler (translations, this);
Status = SessionStatus.NotPlaying;
player_history = new PlayerHistory ();
history = new GameSessionHistoryExtended ();
@@ -176,18 +179,18 @@ namespace gbrainy.Core.Main
string played, time, game;
- played = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Games played: {0} (Score: {1})"), history.GamesPlayed, history.TotalScore);
- time = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Time: {0}"),
- paused == false ? GameTime : ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Paused"));
+ played = String.Format (translations.GetString ("Games played: {0} (Score: {1})"), history.GamesPlayed, history.TotalScore);
+ time = String.Format (translations.GetString ("Time: {0}"),
+ paused == false ? GameTime : translations.GetString ("Paused"));
if (CurrentGame != null) {
// Translators: {0} is the name of the game
- game = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Game: {0}"), CurrentGame.Name);
+ game = String.Format (translations.GetString ("Game: {0}"), CurrentGame.Name);
// Translators: text in the status bar: games played - time - game name
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} - {1} - {2}"), played, time, game);
+ return String.Format (translations.GetString ("{0} - {1} - {2}"), played, time, game);
} else {
// Translators: text in the status bar: games played - time
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} - {1}"), played, time);
+ return String.Format (translations.GetString ("{0} - {1}"), played, time);
}
}
}
@@ -238,6 +241,7 @@ namespace gbrainy.Core.Main
history.GamesPlayed++;
CurrentGame = play_list.GetPuzzle ();
+ CurrentGame.translations = translations;
CurrentGame.SynchronizingObject = SynchronizingObject;
CurrentGame.DrawRequest += GameDrawRequest;
CurrentGame.UpdateUIElement += GameUpdateUIElement;
diff --git a/src/Core/Main/GameSessionHistory.cs b/src/Core/Main/GameSessionHistory.cs
index ad39b51..87b0348 100644
--- a/src/Core/Main/GameSessionHistory.cs
+++ b/src/Core/Main/GameSessionHistory.cs
@@ -70,26 +70,25 @@ namespace gbrainy.Core.Main
return history;
}
- public string Result {
- get {
- string s;
-
- if (GamesPlayed >= 10) {
- int percentage_won = (int) (100 * GamesWon / GamesPlayed);
- if (percentage_won >= 90)
- s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Outstanding results");
- else if (percentage_won >= 70)
- s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Excellent results");
- else if (percentage_won >= 50)
- s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Good results");
- else if (percentage_won >= 30)
- s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Poor results");
- else s = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Disappointing results");
- } else
- s = string.Empty;
-
- return s;
- }
+ public string GetResult (ITranslations translations)
+ {
+ string s;
+
+ if (GamesPlayed >= 10) {
+ int percentage_won = (int) (100 * GamesWon / GamesPlayed);
+ if (percentage_won >= 90)
+ s = translations.GetString ("Outstanding results");
+ else if (percentage_won >= 70)
+ s = translations.GetString ("Excellent results");
+ else if (percentage_won >= 50)
+ s = translations.GetString ("Good results");
+ else if (percentage_won >= 30)
+ s = translations.GetString ("Poor results");
+ else s = translations.GetString ("Disappointing results");
+ } else
+ s = string.Empty;
+
+ return s;
}
}
}
diff --git a/src/Core/Main/GameTips.cs b/src/Core/Main/GameTips.cs
index 502fc2a..501f9f0 100644
--- a/src/Core/Main/GameTips.cs
+++ b/src/Core/Main/GameTips.cs
@@ -24,17 +24,23 @@ using gbrainy.Core.Services;
namespace gbrainy.Core.Main
{
- static public class GameTips
+ public class GameTips
{
- static ArrayListIndicesRandom random_indices;
- static int idx = 0;
+ ITranslations translations;
+ ArrayListIndicesRandom random_indices;
+ int idx = 0;
+
+ public GameTips (ITranslations translations)
+ {
+ this.translations = translations;
+ }
- static public int Count {
+ public int Count {
get { return 15; }
}
// Gets a random tip from the list
- static public string Tip {
+ public string Tip {
get {
if (idx + 1 >= Count || random_indices == null) {
random_indices = new ArrayListIndicesRandom (Count);
@@ -45,39 +51,39 @@ namespace gbrainy.Core.Main
}
}
- static public string GetTip (int tip)
+ public string GetTip (int tip)
{
switch (tip) {
case 0:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Read the instructions carefully and identify the data and given clues.");
+ return translations.GetString ("Read the instructions carefully and identify the data and given clues.");
case 1:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("To score the player gbrainy uses the time and tips needed to complete each game.");
+ return translations.GetString ("To score the player gbrainy uses the time and tips needed to complete each game.");
case 2:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("In logic games, elements that may seem irrelevant can be very important.");
+ return translations.GetString ("In logic games, elements that may seem irrelevant can be very important.");
case 3:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Try to approach a problem from different angles.");
+ return translations.GetString ("Try to approach a problem from different angles.");
case 4:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Do not be afraid of making mistakes, they are part of the learning process.");
+ return translations.GetString ("Do not be afraid of making mistakes, they are part of the learning process.");
case 5:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Do all the problems, even the difficult ones. Improvement comes from challeging yourself.");
+ return translations.GetString ("Do all the problems, even the difficult ones. Improvement comes from challeging yourself.");
case 6:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Play on a daily basis, you will notice progress soon.");
+ return translations.GetString ("Play on a daily basis, you will notice progress soon.");
case 7: // Translators: Custom Game Selection is a menu option
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Use the 'Custom Game Selection' to choose exactly which games you want to play.");
+ return translations.GetString ("Use the 'Custom Game Selection' to choose exactly which games you want to play.");
case 8:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Use the Settings to adjust the difficulty level of the game.");
+ return translations.GetString ("Use the Settings to adjust the difficulty level of the game.");
case 9:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Association of elements is a common technique for remembering things.");
+ return translations.GetString ("Association of elements is a common technique for remembering things.");
case 10:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Grouping elements into categories is a common technique for remembering things.");
+ return translations.GetString ("Grouping elements into categories is a common technique for remembering things.");
case 11:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Build acronyms using the first letter of each fact to be remembered.");
+ return translations.GetString ("Build acronyms using the first letter of each fact to be remembered.");
case 12:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The enjoyment obtained from a puzzle is proportional to the time spent on it.");
+ return translations.GetString ("The enjoyment obtained from a puzzle is proportional to the time spent on it.");
case 13:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Think of breaking down every problem into simpler components.");
+ return translations.GetString ("Think of breaking down every problem into simpler components.");
case 14:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("When answering verbal analogies pay attention to the verb tense.");
+ return translations.GetString ("When answering verbal analogies pay attention to the verb tense.");
default:
throw new InvalidOperationException ();
}
diff --git a/src/Core/Main/GameTypes.cs b/src/Core/Main/GameTypes.cs
index 8c0d4c4..3b2c291 100644
--- a/src/Core/Main/GameTypes.cs
+++ b/src/Core/Main/GameTypes.cs
@@ -37,18 +37,18 @@ namespace gbrainy.Core.Main
public static class GameTypesDescription
{
// Type enum to string representation (locale sensitive)
- static public string GetLocalized (GameTypes type)
+ static public string GetLocalized (ITranslations translations, GameTypes type)
{
switch (type)
{
case GameTypes.LogicPuzzle:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Logic");
+ return translations.GetString ("Logic");
case GameTypes.Memory:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Memory");
+ return translations.GetString ("Memory");
case GameTypes.Calculation:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Calculation");
+ return translations.GetString ("Calculation");
case GameTypes.VerbalAnalogy:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Verbal");
+ return translations.GetString ("Verbal");
default:
throw new InvalidOperationException ("Unknown game type");
}
diff --git a/src/Core/Main/Memory.cs b/src/Core/Main/Memory.cs
index 8dd7335..79f0a6c 100644
--- a/src/Core/Main/Memory.cs
+++ b/src/Core/Main/Memory.cs
@@ -50,7 +50,7 @@ namespace gbrainy.Core.Main
public override string Question {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Memorize the objects below in the given time");
+ return translations.GetString ("Memorize the objects below in the given time");
}
}
@@ -74,7 +74,7 @@ namespace gbrainy.Core.Main
return;
}
- downview = new CountDownView (OnCountDownFinish);
+ downview = new CountDownView (translations, OnCountDownFinish);
downview.SynchronizingObject = SynchronizingObject;
downview.DrawRequest += OnCountDownRedraw;
downview.Start ();
@@ -217,7 +217,7 @@ namespace gbrainy.Core.Main
double width = 0.04, height = 0.6;
const double w = 0.003, h = 0.003;
- gr.DrawTextCentered (x + (width / 2), y + height + 0.05, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Time left"));
+ gr.DrawTextCentered (x + (width / 2), y + height + 0.05, translations.GetString ("Time left"));
gr.Stroke ();
gr.Save ();
diff --git a/src/Core/Main/Verbal/Analogies.cs b/src/Core/Main/Verbal/Analogies.cs
index 7ea5994..93cc4a8 100644
--- a/src/Core/Main/Verbal/Analogies.cs
+++ b/src/Core/Main/Verbal/Analogies.cs
@@ -56,12 +56,12 @@ namespace gbrainy.Core.Main.Verbal
return Current.rationale;
string str;
- str = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Possible correct answers are: {0}."),
+ str = String.Format (translations.GetString ("Possible correct answers are: {0}."),
Answer.CorrectShow);
// For multiple answer build a rationale
// Translators: answer + rationale of the answer
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} {1}"), str,
+ return String.Format (translations.GetString ("{0} {1}"), str,
Current.rationale);
}
}
@@ -84,7 +84,7 @@ namespace gbrainy.Core.Main.Verbal
if (i + 1 < items.Length) {
// Translators: this the separator used when concatenating multiple possible answers for verbal analogies
// For example: "Possible correct answers are: sleep, rest."
- str += ServiceLocator.Instance.GetService <ITranslations> ().GetString (", ");
+ str += translations.GetString (", ");
}
}
Answer.CorrectShow = str;
@@ -126,7 +126,7 @@ namespace gbrainy.Core.Main.Verbal
if (GetText.StringExists (analogy.answers [indices[i]]) == false)
localized = false;
- answers [i] = ServiceLocator.Instance.GetService <ITranslations> ().GetString (analogy.answers [indices[i]]);
+ answers [i] = translations.GetString (analogy.answers [indices[i]]);
if (indices[i] == analogy.right)
new_right = i;
}
@@ -140,13 +140,13 @@ namespace gbrainy.Core.Main.Verbal
localized = false;
if (localized == true) {
- analogy.question = ServiceLocator.Instance.GetService <ITranslations> ().GetString (analogy.question);
+ analogy.question = translations.GetString (analogy.question);
if (String.IsNullOrEmpty (analogy.tip) == false)
- analogy.tip = ServiceLocator.Instance.GetService <ITranslations> ().GetString (analogy.tip);
+ analogy.tip = translations.GetString (analogy.tip);
if (String.IsNullOrEmpty (analogy.rationale) == false)
- analogy.rationale = ServiceLocator.Instance.GetService <ITranslations> ().GetString (analogy.rationale);
+ analogy.rationale = translations.GetString (analogy.rationale);
} else {
// Get analogy again
diff --git a/src/Core/Main/Verbal/AnalogiesMultipleOptions.cs b/src/Core/Main/Verbal/AnalogiesMultipleOptions.cs
index 5a020bc..129645f 100644
--- a/src/Core/Main/Verbal/AnalogiesMultipleOptions.cs
+++ b/src/Core/Main/Verbal/AnalogiesMultipleOptions.cs
@@ -40,7 +40,7 @@ namespace gbrainy.Core.Main.Verbal
}
public override string Name {
- get { return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Multiple options #{0}"), Variant);}
+ get { return String.Format (translations.GetString ("Multiple options #{0}"), Variant);}
}
public override string Question {
@@ -53,7 +53,7 @@ namespace gbrainy.Core.Main.Verbal
// Translators: {0} is replaced by a question and {1} by the possible valid answers
// E.g.: What is the correct option? Answer A, B, C or D.
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} Answer {1}."),
+ return String.Format (translations.GetString ("{0} Answer {1}."),
Current.question, Answer.GetMultiOptionsPossibleAnswers (Current.answers.Length));
}
}
@@ -89,7 +89,7 @@ namespace gbrainy.Core.Main.Verbal
int n = (int) e.Data;
e.Context.MoveTo (0.05, 0.02);
- e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), Answer.GetMultiOption (n), Current.answers[n].ToString ()));
+ e.Context.ShowPangoText (String.Format (translations.GetString ("{0}) {1}"), Answer.GetMultiOption (n), Current.answers[n].ToString ()));
};
}
SetAnswerCorrectShow ();
@@ -104,7 +104,7 @@ namespace gbrainy.Core.Main.Verbal
gr.SetPangoLargeFontSize ();
gr.MoveTo (0.1, DrawAreaY + 0.05);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
}
}
}
diff --git a/src/Core/Main/Verbal/AnalogiesPairOfWordsCompare.cs b/src/Core/Main/Verbal/AnalogiesPairOfWordsCompare.cs
index 5962b23..aea32c4 100644
--- a/src/Core/Main/Verbal/AnalogiesPairOfWordsCompare.cs
+++ b/src/Core/Main/Verbal/AnalogiesPairOfWordsCompare.cs
@@ -38,7 +38,7 @@ namespace gbrainy.Core.Main.Verbal
}
public override string Name {
- get { return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Pair of words compare #{0}"), Variant);}
+ get { return String.Format (translations.GetString ("Pair of words compare #{0}"), Variant);}
}
public override Dictionary <int, Analogy> List {
@@ -53,7 +53,7 @@ namespace gbrainy.Core.Main.Verbal
if (Current.answers == null)
return Current.question;
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString (
+ return String.Format (translations.GetString (
"Given the relationship between the two words below, which word has the same relationship to '{0}'?"),
sample);
}
@@ -91,7 +91,7 @@ namespace gbrainy.Core.Main.Verbal
gr.SetPangoLargeFontSize ();
gr.DrawTextCentered (0.5, y + 0.25,
- String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Words: {0}"), samples));
+ String.Format (translations.GetString ("Words: {0}"), samples));
}
}
}
diff --git a/src/Core/Main/Verbal/AnalogiesPairOfWordsOptions.cs b/src/Core/Main/Verbal/AnalogiesPairOfWordsOptions.cs
index cc0f4b2..c73f1f6 100644
--- a/src/Core/Main/Verbal/AnalogiesPairOfWordsOptions.cs
+++ b/src/Core/Main/Verbal/AnalogiesPairOfWordsOptions.cs
@@ -37,7 +37,7 @@ namespace gbrainy.Core.Main.Verbal
}
public override string Name {
- get { return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Pair of words #{0}"), Variant);}
+ get { return String.Format (translations.GetString ("Pair of words #{0}"), Variant);}
}
public override Dictionary <int, Analogy> List {
@@ -52,13 +52,13 @@ namespace gbrainy.Core.Main.Verbal
if (Current.answers == null)
return Current.question;
- string ques = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString (
+ string ques = String.Format (translations.GetString (
"Given the relationship between the two words below, which word has the same relationship to '{0}'?"),
sample);
// Translators: {0} is replaced by a question and {1} by the possible valid answers
// E.g.: What is the correct option? Answer A, B, C or D.
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} Answer {1}."),
+ return String.Format (translations.GetString ("{0} Answer {1}."),
ques, Answer.GetMultiOptionsPossibleAnswers (Current.answers.Length));
}
}
@@ -101,7 +101,7 @@ namespace gbrainy.Core.Main.Verbal
int n = (int) e.Data;
e.Context.MoveTo (0.05, 0.02);
- e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), Answer.GetMultiOption (n), Current.answers[n].ToString ()));
+ e.Context.ShowPangoText (String.Format (translations.GetString ("{0}) {1}"), Answer.GetMultiOption (n), Current.answers[n].ToString ()));
};
}
SetAnswerCorrectShow ();
@@ -119,11 +119,11 @@ namespace gbrainy.Core.Main.Verbal
gr.SetPangoLargeFontSize ();
gr.MoveTo (0.1, y + 0.12);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
gr.Stroke ();
gr.DrawTextCentered (0.5, y,
- String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Words: {0}"), samples));
+ String.Format (translations.GetString ("Words: {0}"), samples));
}
}
diff --git a/src/Core/Main/Verbal/AnalogiesQuestionAnswer.cs b/src/Core/Main/Verbal/AnalogiesQuestionAnswer.cs
index 57ef914..915c32a 100644
--- a/src/Core/Main/Verbal/AnalogiesQuestionAnswer.cs
+++ b/src/Core/Main/Verbal/AnalogiesQuestionAnswer.cs
@@ -35,7 +35,7 @@ namespace gbrainy.Core.Main.Verbal
}
public override string Name {
- get { return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Question and answer #{0}"), Variant);}
+ get { return String.Format (translations.GetString ("Question and answer #{0}"), Variant);}
}
public override Dictionary <int, Analogy> List {
diff --git a/src/Core/Main/Xml/GameXml.cs b/src/Core/Main/Xml/GameXml.cs
index af6b0ea..df36fbf 100644
--- a/src/Core/Main/Xml/GameXml.cs
+++ b/src/Core/Main/Xml/GameXml.cs
@@ -72,7 +72,7 @@ namespace gbrainy.Core.Main.Xml
}
public override string Name {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString (game.Name); }
+ get { return translations.GetString (game.Name); }
}
public override string Question {
@@ -86,10 +86,10 @@ namespace gbrainy.Core.Main.Xml
public override string Tip {
get {
if (game.Variants.Count > 0 && game.Variants[current.Variant].Tip != null)
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString (game.Variants[current.Variant].Tip);
+ return translations.GetString (game.Variants[current.Variant].Tip);
else
if (String.IsNullOrEmpty (game.Tip) == false)
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString (game.Tip);
+ return translations.GetString (game.Tip);
else
return null;
}
@@ -211,7 +211,7 @@ namespace gbrainy.Core.Main.Xml
Answer.SetMultiOptionAnswer (option_answer, answer);
// Translators {0}: list of options (A, B, C)
- string answers = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Answer {0}."),
+ string answers = String.Format (translations.GetString ("Answer {0}."),
Answer.GetMultiOptionsPossibleAnswers (xml_drawing.Options.Count));
question = question.Replace (option_answers, answers);
}
@@ -278,16 +278,16 @@ namespace gbrainy.Core.Main.Xml
}
// Protect from calling with null (exception)
- internal static string CatalogGetString (string str)
+ internal string CatalogGetString (string str)
{
if (String.IsNullOrEmpty (str))
return str;
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString (str);
+ return translations.GetString (str);
}
// Protect from calling with null + resolve plurals
- internal static string CatalogGetString (LocalizableString localizable)
+ internal string CatalogGetString (LocalizableString localizable)
{
if (localizable == null)
return string.Empty;
@@ -295,7 +295,7 @@ namespace gbrainy.Core.Main.Xml
if (localizable.IsPlural () == false)
return CatalogGetString (localizable.String);
- return ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString (localizable.String, localizable.PluralString, localizable.ValueComputed);
+ return translations.GetPluralString (localizable.String, localizable.PluralString, localizable.ValueComputed);
}
// Replace compiler service variables
diff --git a/src/Core/Main/Xml/GameXmlDrawing.cs b/src/Core/Main/Xml/GameXmlDrawing.cs
index 77b8ef3..69904c5 100644
--- a/src/Core/Main/Xml/GameXmlDrawing.cs
+++ b/src/Core/Main/Xml/GameXmlDrawing.cs
@@ -46,7 +46,7 @@ namespace gbrainy.Core.Main.Xml
public int GetOptionCorrectAnswerIndex ()
{
- if (options == null || options.Count > 0)
+ if (options == null || options.Count < 0)
return -1;
for (int i = 0; i < options.Count; i++)
@@ -195,7 +195,7 @@ namespace gbrainy.Core.Main.Xml
string text;
TextDrawingObject draw_string = draw_object as TextDrawingObject;
- text = GameXml.CatalogGetString (draw_string.Text);
+ text = game_xml.CatalogGetString (draw_string.Text);
text = game_xml.ReplaceVariables (text);
switch (draw_string.Size) {
@@ -266,7 +266,7 @@ namespace gbrainy.Core.Main.Xml
{
string answer;
- answer = String.Format (GameXml.CatalogGetString ("{0}) "), game_xml.Answer.GetMultiOption (option));
+ answer = String.Format (game_xml.CatalogGetString ("{0}) "), game_xml.Answer.GetMultiOption (option));
return str.Replace (option_prefix, answer);
}
}
diff --git a/src/Core/Services/ITranslations.cs b/src/Core/Services/ITranslations.cs
index 7ad859a..1321efe 100644
--- a/src/Core/Services/ITranslations.cs
+++ b/src/Core/Services/ITranslations.cs
@@ -22,6 +22,7 @@ namespace gbrainy.Core.Services
public interface ITranslations : IService
{
int TranslationPercentage { get;}
+ string Language { get; set; }
void Init (string package, string localedir);
string GetString (string s);
diff --git a/src/Core/Views/CountDownView.cs b/src/Core/Views/CountDownView.cs
index bd1ed28..21af4de 100644
--- a/src/Core/Views/CountDownView.cs
+++ b/src/Core/Views/CountDownView.cs
@@ -33,11 +33,13 @@ namespace gbrainy.Core.Views
System.Timers.Timer timer;
EventHandler finish;
ISynchronizeInvoke synchronize;
+ ITranslations translations;
public event EventHandler DrawRequest; // Not used in this view
- public CountDownView (EventHandler OnFinish)
+ public CountDownView (ITranslations translations, EventHandler OnFinish)
{
+ this.translations = translations;
timer = new System.Timers.Timer ();
timer.Elapsed += TimerUpdater;
timer.Interval = (1 * 1000); // 1 second
@@ -74,7 +76,7 @@ namespace gbrainy.Core.Views
gr.Color = new Cairo.Color (0, 0, 0, 1);
gr.SetPangoLargeFontSize ();
- gr.DrawTextCentered (0.5, 0.1, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Get ready to memorize the next objects..."));
+ gr.DrawTextCentered (0.5, 0.1, translations.GetString ("Get ready to memorize the next objects..."));
gr.Stroke ();
gr.SetPangoFontSize (0.35);
diff --git a/src/Core/Views/FinishView.cs b/src/Core/Views/FinishView.cs
index 6d24e1f..1dd63a4 100644
--- a/src/Core/Views/FinishView.cs
+++ b/src/Core/Views/FinishView.cs
@@ -29,18 +29,22 @@ namespace gbrainy.Core.Views
public class FinishView : IDrawable
{
GameSession session;
+ ITranslations translations;
const int tips_shown = 4;
const double smaller_font = 0.018;
// Caching mechanism to use always the same tips during different redraws of the same view
int cached_sessionid;
List <string> tips;
+ GameTips game_tips;
- public FinishView (GameSession session)
+ public FinishView (ITranslations translations, GameSession session)
{
+ this.translations = translations;
this.session = session;
tips = new List <string> ();
cached_sessionid = -1;
+ game_tips = new GameTips (translations);
}
static void DrawBand (CairoContextEx gr, double x, double y)
@@ -94,35 +98,35 @@ namespace gbrainy.Core.Views
x = x + space_x;
DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.TotalScore);
- gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Total"));
+ gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, translations.GetString ("Total"));
x = x + space_x * 2;
if (session.History.LogicPlayed > 0)
DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.LogicScore);
- gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Logic"));
+ gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, translations.GetString ("Logic"));
x = x + space_x * 2;
if (session.History.MathPlayed > 0)
DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.MathScore);
- gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Calculation"));
+ gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, translations.GetString ("Calculation"));
x = x + space_x * 2;
if (session.History.MemoryPlayed > 0)
DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.MemoryScore);
- gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Memory"));
+ gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, translations.GetString ("Memory"));
x = x + space_x * 2;
if (session.History.VerbalPlayed > 0)
DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.VerbalScore);
- gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Verbal"));
+ gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, translations.GetString ("Verbal"));
}
public void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
@@ -137,21 +141,21 @@ namespace gbrainy.Core.Views
gr.Color = new Cairo.Color (0, 0, 0, 1);
gr.MoveTo (x, y);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Score"), false, -1, 0);
+ gr.ShowPangoText (translations.GetString ("Score"), false, -1, 0);
DrawBand (gr, 0.03, y - 0.01);
y += 0.08;
gr.MoveTo (x, y);
- s = session.History.Result;
+ s = session.History.GetResult (translations);
if (s == string.Empty)
- gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Games won: {0} ({1} played)"), session.History.GamesWon, session.History.GamesPlayed));
+ gr.ShowPangoText (String.Format (translations.GetString ("Games won: {0} ({1} played)"), session.History.GamesWon, session.History.GamesPlayed));
else
- gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}. Games won: {1} ({2} played)"), s, session.History.GamesWon, session.History.GamesPlayed));
+ gr.ShowPangoText (String.Format (translations.GetString ("{0}. Games won: {1} ({2} played)"), s, session.History.GamesWon, session.History.GamesPlayed));
y += 0.06;
gr.MoveTo (x, y);
- gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Time played {0} (average per game {1})"), session.GameTime, session.TimePerGame));
+ gr.ShowPangoText (String.Format (translations.GetString ("Time played {0} (average per game {1})"), session.GameTime, session.TimePerGame));
y += 0.09;
DrawColumnBarGraphic (gr, x, y);
@@ -160,17 +164,19 @@ namespace gbrainy.Core.Views
gr.MoveTo (x, y);
gr.SetPangoFontSize (smaller_font);
// Translators: translated string should not be longer that the English original (space restriction on the UI)
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("For details on how gbrainy's scoring works refer to the help."));
+ gr.ShowPangoText (translations.GetString ("For details on how gbrainy's scoring works refer to the help."));
y += 0.07;
gr.SetPangoNormalFontSize ();
records = session.PlayerHistory.GetLastGameRecords ();
gr.MoveTo (x, y);
+
+
if (records.Count == 0) {
bool caching = cached_sessionid != session.ID;
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Tips for your next games"), false, -1, 0);
+ gr.ShowPangoText (translations.GetString ("Tips for your next games"), false, -1, 0);
DrawBand (gr, 0.03, y - 0.01);
y += 0.08;
@@ -181,7 +187,7 @@ namespace gbrainy.Core.Views
for (int i = 0; i < tips_shown; i++)
{
if (caching)
- tips.Add (GameTips.Tip);
+ tips.Add (game_tips.Tip);
tip = "- " + tips [i];
@@ -198,7 +204,7 @@ namespace gbrainy.Core.Views
cached_sessionid = session.ID;
}
else {
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Congratulations! New personal record"), false, -1, 0);
+ gr.ShowPangoText (translations.GetString ("Congratulations! New personal record"), false, -1, 0);
DrawBand (gr, 0.03, y - 0.01);
y += 0.08;
@@ -207,25 +213,25 @@ namespace gbrainy.Core.Views
{
switch (records[i].GameType) {
case GameTypes.LogicPuzzle:
- s = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().
+ s = String.Format (translations.
GetString ("By scoring {0} in logic puzzle games you have established a new personal record. Your previous record was {1}."),
records[i].NewScore,
records[i].PreviousScore);
break;
case GameTypes.Calculation:
- s = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().
+ s = String.Format (translations.
GetString ("By scoring {0} in calculation games you have established a new personal record. Your previous record was {1}."),
records[i].NewScore,
records[i].PreviousScore);
break;
case GameTypes.Memory:
- s = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().
+ s = String.Format (translations.
GetString ("By scoring {0} in memory games you have established a new personal record. Your previous record was {1}."),
records[i].NewScore,
records[i].PreviousScore);
break;
case GameTypes.VerbalAnalogy:
- s = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().
+ s = String.Format (translations.
GetString ("By scoring {0} in verbal analogies you have established a new personal record. Your previous record was {1}."),
records[i].NewScore,
records[i].PreviousScore);
diff --git a/src/Core/Views/PlayerHistoryView.cs b/src/Core/Views/PlayerHistoryView.cs
index 53b322b..bbfab9f 100644
--- a/src/Core/Views/PlayerHistoryView.cs
+++ b/src/Core/Views/PlayerHistoryView.cs
@@ -43,9 +43,11 @@ namespace gbrainy.Core.Views
readonly Cairo.Color axis_color = new Cairo.Color (0.8, 0.8, 0.8);
readonly Cairo.Color desc_color = new Color (0.3, 0.3, 0.3);
PlayerHistory history;
+ ITranslations translations;
- public PlayerHistoryView (PlayerHistory history)
+ public PlayerHistoryView (ITranslations translations, PlayerHistory history)
{
+ this.translations = translations;
this.history = history;
ShowLogic = ShowMemory = ShowCalculation = ShowVerbal = true;
}
@@ -80,7 +82,7 @@ namespace gbrainy.Core.Views
cr.Stroke ();
cr.Color = text_color;
cr.MoveTo (x + line_size + offset_x, y - 0.01);
- cr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Total"));
+ cr.ShowPangoText (translations.GetString ("Total"));
cr.Stroke ();
cr.Color = logic_color;
@@ -89,7 +91,7 @@ namespace gbrainy.Core.Views
cr.Stroke ();
cr.Color = text_color;
cr.MoveTo (x + line_size + offset_x, y - 0.01 + second_row);
- cr.ShowPangoText (GameTypesDescription.GetLocalized (GameTypes.LogicPuzzle));
+ cr.ShowPangoText (GameTypesDescription.GetLocalized (translations, GameTypes.LogicPuzzle));
cr.Stroke ();
x += space_hor;
@@ -99,7 +101,7 @@ namespace gbrainy.Core.Views
cr.Stroke ();
cr.Color = text_color;
cr.MoveTo (x + line_size + offset_x, y - 0.01);
- cr.ShowPangoText (GameTypesDescription.GetLocalized (GameTypes.Memory));
+ cr.ShowPangoText (GameTypesDescription.GetLocalized (translations, GameTypes.Memory));
cr.Stroke ();
cr.Color = math_color;
@@ -108,7 +110,7 @@ namespace gbrainy.Core.Views
cr.Stroke ();
cr.Color = text_color;
cr.MoveTo (x + line_size + offset_x, y - 0.01 + second_row);
- cr.ShowPangoText (GameTypesDescription.GetLocalized (GameTypes.Calculation));
+ cr.ShowPangoText (GameTypesDescription.GetLocalized (translations, GameTypes.Calculation));
cr.Stroke ();
x += space_hor;
@@ -118,7 +120,7 @@ namespace gbrainy.Core.Views
cr.Stroke ();
cr.Color = text_color;
cr.MoveTo (x + line_size + offset_x, y - 0.01);
- cr.ShowPangoText (GameTypesDescription.GetLocalized (GameTypes.VerbalAnalogy));
+ cr.ShowPangoText (GameTypesDescription.GetLocalized (translations, GameTypes.VerbalAnalogy));
cr.Stroke ();
cr.LineWidth = old_width;
@@ -271,8 +273,8 @@ namespace gbrainy.Core.Views
DrawLegend (cr, x + grid_offsetx, y + area_h + 0.06);
DrawGrid (cr, grid_x, grid_y);
- DrawAxisDescription (cr, x + area_w + 0.01, 0.78, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Time"));
- DrawAxisDescription (cr, 0, 0.03, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Score"));
+ DrawAxisDescription (cr, x + area_w + 0.01, 0.78, translations.GetString ("Time"));
+ DrawAxisDescription (cr, 0, 0.03, translations.GetString ("Score"));
}
}
}
diff --git a/src/Core/Views/ViewsControler.cs b/src/Core/Views/ViewsControler.cs
index 205b575..606ffbc 100644
--- a/src/Core/Views/ViewsControler.cs
+++ b/src/Core/Views/ViewsControler.cs
@@ -20,6 +20,7 @@
using System;
using gbrainy.Core.Main;
+using gbrainy.Core.Services;
namespace gbrainy.Core.Views
{
@@ -30,10 +31,10 @@ namespace gbrainy.Core.Views
FinishView finish;
Game game;
- public ViewsControler (GameSession session)
+ public ViewsControler (ITranslations translations, GameSession session)
{
- welcome = new WelcomeView ();
- finish = new FinishView (session);
+ welcome = new WelcomeView (translations);
+ finish = new FinishView (translations, session);
}
public GameSession.SessionStatus Status {
diff --git a/src/Core/Views/WelcomeView.cs b/src/Core/Views/WelcomeView.cs
index f205987..f8a35e8 100644
--- a/src/Core/Views/WelcomeView.cs
+++ b/src/Core/Views/WelcomeView.cs
@@ -31,15 +31,17 @@ namespace gbrainy.Core.Views
public class WelcomeView : IDrawable
{
List <Toolkit.Container> containers;
+ ITranslations translations;
const double space = 0.17;
const double image_size = 0.14;
- public WelcomeView ()
+ public WelcomeView (ITranslations translations)
{
Container container;
DrawableArea drawable_area;
double y = 0.22;
+ this.translations = translations;
containers = new List <Toolkit.Container> ();
/* Logic */
@@ -58,7 +60,7 @@ namespace gbrainy.Core.Views
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
e.Context.DrawStringWithWrapping (0, 0,
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Logic puzzles. Challenge your reasoning and thinking skills."),
+ translations.GetString ("Logic puzzles. Challenge your reasoning and thinking skills."),
e.Width);
};
@@ -79,7 +81,7 @@ namespace gbrainy.Core.Views
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
e.Context.DrawStringWithWrapping (0, 0,
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Mental calculation. Arithmetical operations that test your mental calculation abilities."),
+ translations.GetString ("Mental calculation. Arithmetical operations that test your mental calculation abilities."),
e.Width);
};
@@ -100,7 +102,7 @@ namespace gbrainy.Core.Views
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
e.Context.DrawStringWithWrapping (0, 0,
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Memory trainers. To prove your short term memory."),
+ translations.GetString ("Memory trainers. To prove your short term memory."),
e.Width);
};
@@ -121,7 +123,7 @@ namespace gbrainy.Core.Views
drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
{
e.Context.DrawStringWithWrapping (0, 0,
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Verbal analogies. Challenge your verbal aptitude."),
+ translations.GetString ("Verbal analogies. Challenge your verbal aptitude."),
e.Width);
};
}
@@ -137,15 +139,15 @@ namespace gbrainy.Core.Views
gr.MoveTo (0.05, y);
// Translators: {0} is the version number of the program
- gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Welcome to gbrainy {0}"), Defines.VERSION), true, -1, 0);
+ gr.ShowPangoText (String.Format (translations.GetString ("Welcome to gbrainy {0}"), Defines.VERSION), true, -1, 0);
gr.Stroke ();
gr.DrawStringWithWrapping (0.05, y + 0.07,
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("gbrainy is a brain teaser game and trainer to have fun and to keep your brain trained. It includes:"),
+ translations.GetString ("gbrainy is a brain teaser game and trainer to have fun and to keep your brain trained. It includes:"),
1 - 0.05);
y = 0.22 + space * 3;
- gr.DrawStringWithWrapping (0.05, y + 0.17, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Use the Settings to adjust the difficulty level of the game."),
+ gr.DrawStringWithWrapping (0.05, y + 0.17, translations.GetString ("Use the Settings to adjust the difficulty level of the game."),
1 - 0.05);
gr.Stroke ();
diff --git a/src/Games/Calculation/CalculationArithmetical.cs b/src/Games/Calculation/CalculationArithmetical.cs
index afc8731..6a67192 100644
--- a/src/Games/Calculation/CalculationArithmetical.cs
+++ b/src/Games/Calculation/CalculationArithmetical.cs
@@ -38,7 +38,7 @@ namespace gbrainy.Games.Calculation
private int max_operations;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Arithmetical operations");}
+ get {return translations.GetString ("Arithmetical operations");}
}
public override GameTypes Type {
@@ -46,7 +46,7 @@ namespace gbrainy.Games.Calculation
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What is the result of the following operation?");}
+ get {return translations.GetString ("What is the result of the following operation?");}
}
protected override void Initialize ()
diff --git a/src/Games/Calculation/CalculationAverage.cs b/src/Games/Calculation/CalculationAverage.cs
index 1bbcdbf..e9da3ba 100644
--- a/src/Games/Calculation/CalculationAverage.cs
+++ b/src/Games/Calculation/CalculationAverage.cs
@@ -35,7 +35,7 @@ namespace gbrainy.Games.Calculation
double correct;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Average");}
+ get {return translations.GetString ("Average");}
}
public override GameTypes Type {
@@ -52,17 +52,17 @@ namespace gbrainy.Games.Calculation
nums += numbers [numbers.Length - 1];
return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Given the numbers: {0}. Which of the following numbers is closest to the average? Answer {1}, {2}, {3} or {4}."), nums,
+ translations.GetString ("Given the numbers: {0}. Which of the following numbers is closest to the average? Answer {1}, {2}, {3} or {4}."), nums,
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3));}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The average of a list of numbers is their sum divided by the number of numbers in the list.");}
+ get { return translations.GetString ("The average of a list of numbers is their sum divided by the number of numbers in the list.");}
}
public override string Rationale {
get {
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The result of the operation is {0}."),
+ return String.Format (translations.GetString ("The result of the operation is {0}."),
correct);
}
}
@@ -182,7 +182,7 @@ namespace gbrainy.Games.Calculation
gr.SetPangoLargeFontSize ();
gr.MoveTo (0.1, 0.15);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
}
}
}
diff --git a/src/Games/Calculation/CalculationCloserFraction.cs b/src/Games/Calculation/CalculationCloserFraction.cs
index 4f49de9..8f6cd78 100644
--- a/src/Games/Calculation/CalculationCloserFraction.cs
+++ b/src/Games/Calculation/CalculationCloserFraction.cs
@@ -34,7 +34,7 @@ namespace gbrainy.Games.Calculation
private int which;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Closer fraction");}
+ get {return translations.GetString ("Closer fraction");}
}
public override GameTypes Type {
@@ -43,7 +43,7 @@ namespace gbrainy.Games.Calculation
public override string Question {
get {return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which of the following numbers is closer to {0}? Answer {1}, {2}, {3} or {4}."),
+ translations.GetString ("Which of the following numbers is closer to {0}? Answer {1}, {2}, {3} or {4}."),
String.Format ("{0:##0.###}", question_num),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3));}
}
@@ -52,7 +52,7 @@ namespace gbrainy.Games.Calculation
get {
int ans_idx = random_indices[which];
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The result of the operation {0} / {1} is {2}"),
+ return String.Format (translations.GetString ("The result of the operation {0} / {1} is {2}"),
options[ans_idx * 2], options[(ans_idx * 2) + 1], String.Format ("{0:##0.###}", question_num));
}
}
@@ -161,7 +161,7 @@ namespace gbrainy.Games.Calculation
e.Context.SetPangoLargeFontSize ();
e.Context.MoveTo (0.02, 0.02);
- e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), Answer.GetMultiOption (n) ,
+ e.Context.ShowPangoText (String.Format (translations.GetString ("{0}) {1}"), Answer.GetMultiOption (n) ,
options [indx * 2] + " / " + options [(indx * 2) +1]));
};
}
@@ -174,7 +174,7 @@ namespace gbrainy.Games.Calculation
gr.SetPangoLargeFontSize ();
gr.MoveTo (0.1, 0.15);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
}
}
}
diff --git a/src/Games/Calculation/CalculationFractions.cs b/src/Games/Calculation/CalculationFractions.cs
index c0343b8..efa8b00 100644
--- a/src/Games/Calculation/CalculationFractions.cs
+++ b/src/Games/Calculation/CalculationFractions.cs
@@ -59,7 +59,7 @@ namespace gbrainy.Games.Calculation
const string format_string = "{0:##0.###}";
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Fractions");}
+ get {return translations.GetString ("Fractions");}
}
public override GameTypes Type {
@@ -67,7 +67,7 @@ namespace gbrainy.Games.Calculation
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What is the result of the given operation? Answer using either a fraction or a number.");}
+ get {return translations.GetString ("What is the result of the given operation? Answer using either a fraction or a number.");}
}
private int Factor {
diff --git a/src/Games/Calculation/CalculationGreatestDivisor.cs b/src/Games/Calculation/CalculationGreatestDivisor.cs
index aa2e6d2..ded81cb 100644
--- a/src/Games/Calculation/CalculationGreatestDivisor.cs
+++ b/src/Games/Calculation/CalculationGreatestDivisor.cs
@@ -34,7 +34,7 @@ namespace gbrainy.Games.Calculation
private int answer_idx;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Greatest divisor");}
+ get {return translations.GetString ("Greatest divisor");}
}
public override GameTypes Type {
@@ -42,7 +42,7 @@ namespace gbrainy.Games.Calculation
}
public override string Question {
- get { return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString (
+ get { return String.Format (translations.GetString (
"Which of the possible divisors is the greatest that divides all numbers? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3));
}
@@ -150,7 +150,7 @@ namespace gbrainy.Games.Calculation
int d = (int) e.Data;
e.Context.SetPangoLargeFontSize ();
e.Context.MoveTo (0.07, 0.02);
- e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), Answer.GetMultiOption (d),
+ e.Context.ShowPangoText (String.Format (translations.GetString ("{0}) {1}"), Answer.GetMultiOption (d),
answers[d].ToString ()));
};
}
@@ -241,7 +241,7 @@ namespace gbrainy.Games.Calculation
gr.MoveTo (0.05, y);
gr.SetPangoLargeFontSize ();
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Numbers"));
+ gr.ShowPangoText (translations.GetString ("Numbers"));
y += 0.08;
for (int n = 0; n < numbers.Length; n++)
@@ -255,7 +255,7 @@ namespace gbrainy.Games.Calculation
y += 0.16;
gr.MoveTo (0.05, y);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Possible divisors"));
+ gr.ShowPangoText (translations.GetString ("Possible divisors"));
}
}
}
diff --git a/src/Games/Calculation/CalculationOperator.cs b/src/Games/Calculation/CalculationOperator.cs
index c3bb737..b8bf736 100644
--- a/src/Games/Calculation/CalculationOperator.cs
+++ b/src/Games/Calculation/CalculationOperator.cs
@@ -32,11 +32,11 @@ namespace gbrainy.Games.Calculation
private char oper1, oper2;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Operators");}
+ get {return translations.GetString ("Operators");}
}
public override string Tip {
- get {return String.Format( ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The first operator is {0}."), oper1);}
+ get {return String.Format( translations.GetString ("The first operator is {0}."), oper1);}
}
public override GameTypes Type {
@@ -44,7 +44,7 @@ namespace gbrainy.Games.Calculation
}
public override string Question {
- get {return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which operators make {0}, {1}, and {2} equal {3}? Answer using '+-/*'."), number_a, number_b, number_c, total);}
+ get {return String.Format (translations.GetString ("Which operators make {0}, {1}, and {2} equal {3}? Answer using '+-/*'."), number_a, number_b, number_c, total);}
}
static private double ProcessOperation (double total, double number, char op)
@@ -107,7 +107,7 @@ namespace gbrainy.Games.Calculation
Answer.Correct = String.Format ("{0} | {1}", oper1, oper2);
Answer.CheckExpression = "[+*-/]";
Answer.CheckAttributes |= GameAnswerCheckAttributes.MatchAll;
- Answer.CorrectShow = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} and {1}"), oper1, oper2);
+ Answer.CorrectShow = String.Format (translations.GetString ("{0} and {1}"), oper1, oper2);
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
diff --git a/src/Games/Calculation/CalculationPrimes.cs b/src/Games/Calculation/CalculationPrimes.cs
index 3228b11..1c8fbfb 100644
--- a/src/Games/Calculation/CalculationPrimes.cs
+++ b/src/Games/Calculation/CalculationPrimes.cs
@@ -65,7 +65,7 @@ namespace gbrainy.Games.Calculation
};
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Primes");}
+ get {return translations.GetString ("Primes");}
}
public override GameTypes Type {
@@ -74,17 +74,17 @@ namespace gbrainy.Games.Calculation
public override string Question {
get { return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which of the following numbers is a prime? A prime number is a positive integer that has exactly two different positive divisors, 1 and itself. Answer {0}, {1}, {2} or {3}."),
+ translations.GetString ("Which of the following numbers is a prime? A prime number is a positive integer that has exactly two different positive divisors, 1 and itself. Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3));}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If the sum of all digits in a given number is divisible by 3, then so is the number. For example 15 = 1 + 5 = 6, which is divisible by 3.");}
+ get { return translations.GetString ("If the sum of all digits in a given number is divisible by 3, then so is the number. For example 15 = 1 + 5 = 6, which is divisible by 3.");}
}
public override string Rationale {
get {
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The number {0} is a primer number."), answer);
+ return String.Format (translations.GetString ("The number {0} is a primer number."), answer);
}
}
@@ -149,7 +149,7 @@ namespace gbrainy.Games.Calculation
gr.SetPangoLargeFontSize ();
gr.MoveTo (0.1, 0.15);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
}
short GenerateNonPrime ()
diff --git a/src/Games/Calculation/CalculationProportions.cs b/src/Games/Calculation/CalculationProportions.cs
index 60deca3..3088c7a 100644
--- a/src/Games/Calculation/CalculationProportions.cs
+++ b/src/Games/Calculation/CalculationProportions.cs
@@ -34,7 +34,7 @@ namespace gbrainy.Games.Calculation
double num, den, percentage, correct;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Proportions");}
+ get {return translations.GetString ("Proportions");}
}
public override GameTypes Type {
@@ -44,7 +44,7 @@ namespace gbrainy.Games.Calculation
public override string Question {
get {
return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What is {0}% of {1}/{2}? Answer {3}, {4}, {5} or {6}."),
+ translations.GetString ("What is {0}% of {1}/{2}? Answer {3}, {4}, {5} or {6}."),
percentage, num, den, Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3));}
}
@@ -128,7 +128,7 @@ namespace gbrainy.Games.Calculation
gr.SetPangoLargeFontSize ();
gr.MoveTo (0.1, 0.15);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
}
}
}
diff --git a/src/Games/Calculation/CalculationRatio.cs b/src/Games/Calculation/CalculationRatio.cs
index 7b15961..22b2f3e 100644
--- a/src/Games/Calculation/CalculationRatio.cs
+++ b/src/Games/Calculation/CalculationRatio.cs
@@ -29,7 +29,7 @@ namespace gbrainy.Games.Calculation
int number_a, number_b, ratio_a, ratio_b;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Ratio");}
+ get {return translations.GetString ("Ratio");}
}
public override GameTypes Type {
@@ -39,20 +39,20 @@ namespace gbrainy.Games.Calculation
public override string Question {
get {
return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which two numbers have a sum of {0} and have a ratio of {1} to {2}. Answer using two numbers (e.g.: 1 and 2)."),
+ translations.GetString ("Which two numbers have a sum of {0} and have a ratio of {1} to {2}. Answer using two numbers (e.g.: 1 and 2)."),
number_a + number_b, ratio_a, ratio_b);
}
}
public override string Rationale {
get {
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The second number can be calculated by multiplying the first number by {0} and dividing it by {1}."),
+ return String.Format (translations.GetString ("The second number can be calculated by multiplying the first number by {0} and dividing it by {1}."),
ratio_b, ratio_a);
}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("A ratio specifies a proportion between two numbers. A ratio of a:b means that for every 'a' parts you have 'b' parts.");}
+ get { return translations.GetString ("A ratio specifies a proportion between two numbers. A ratio of a:b means that for every 'a' parts you have 'b' parts.");}
}
protected override void Initialize ()
@@ -84,7 +84,7 @@ namespace gbrainy.Games.Calculation
Answer.Correct = String.Format ("{0} | {1}", number_a, number_b);
Answer.CheckExpression = "[0-9]+";
Answer.CheckAttributes |= GameAnswerCheckAttributes.MatchAll;
- Answer.CorrectShow = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} and {1}"), number_a, number_b);
+ Answer.CorrectShow = String.Format (translations.GetString ("{0} and {1}"), number_a, number_b);
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
@@ -96,10 +96,10 @@ namespace gbrainy.Games.Calculation
gr.SetPangoLargeFontSize ();
gr.MoveTo (x, DrawAreaY + 0.22);
- gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("x + y = {0}"), number_a + number_b));
+ gr.ShowPangoText (String.Format (translations.GetString ("x + y = {0}"), number_a + number_b));
gr.MoveTo (x, DrawAreaY + 0.44);
- gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("have a ratio of {0}:{1}"), ratio_a, ratio_b));
+ gr.ShowPangoText (String.Format (translations.GetString ("have a ratio of {0}:{1}"), ratio_a, ratio_b));
}
}
}
diff --git a/src/Games/Calculation/CalculationTwoNumbers.cs b/src/Games/Calculation/CalculationTwoNumbers.cs
index 99db9e4..44f7a79 100644
--- a/src/Games/Calculation/CalculationTwoNumbers.cs
+++ b/src/Games/Calculation/CalculationTwoNumbers.cs
@@ -38,7 +38,7 @@ namespace gbrainy.Games.Calculation
};
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Two numbers");}
+ get {return translations.GetString ("Two numbers");}
}
public override GameTypes Type {
@@ -49,9 +49,9 @@ namespace gbrainy.Games.Calculation
get {
switch (type) {
case SubGameTypes.Addition:
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which two numbers when added are {0} and when multiplied are {1}? Answer using two numbers (e.g.: 1 and 2)."), op1, op2);
+ return String.Format (translations.GetString ("Which two numbers when added are {0} and when multiplied are {1}? Answer using two numbers (e.g.: 1 and 2)."), op1, op2);
case SubGameTypes.Subtraction:
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which two numbers when subtracted are {0} and when multiplied are {1}? Answer using two numbers (e.g.: 1 and 2)."), op1, op2);
+ return String.Format (translations.GetString ("Which two numbers when subtracted are {0} and when multiplied are {1}? Answer using two numbers (e.g.: 1 and 2)."), op1, op2);
default:
throw new InvalidOperationException ();
}
@@ -98,7 +98,7 @@ namespace gbrainy.Games.Calculation
op2 = number_a * number_b;
Answer.Correct = String.Format ("{0} | {1}", number_a, number_b);
Answer.CheckExpression = "[-0-9]+";
- Answer.CorrectShow = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} and {1}"), number_a, number_b);
+ Answer.CorrectShow = String.Format (translations.GetString ("{0} and {1}"), number_a, number_b);
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
@@ -112,17 +112,17 @@ namespace gbrainy.Games.Calculation
switch (type) {
case SubGameTypes.Addition:
- gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("x + y = {0}"), op1));
+ gr.ShowPangoText (String.Format (translations.GetString ("x + y = {0}"), op1));
break;
case SubGameTypes.Subtraction:
- gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("x - y = {0}"), op1));
+ gr.ShowPangoText (String.Format (translations.GetString ("x - y = {0}"), op1));
break;
default:
throw new InvalidOperationException ();
}
gr.MoveTo (x, DrawAreaY + 0.44);
- gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("x * y = {0}"), op2));
+ gr.ShowPangoText (String.Format (translations.GetString ("x * y = {0}"), op2));
}
public override bool CheckAnswer (string answer)
diff --git a/src/Games/Logic/Puzzle3DCube.cs b/src/Games/Logic/Puzzle3DCube.cs
index 1d0fefa..b981286 100644
--- a/src/Games/Logic/Puzzle3DCube.cs
+++ b/src/Games/Logic/Puzzle3DCube.cs
@@ -29,15 +29,15 @@ namespace gbrainy.Games.Logic
int rows, columns, depth;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("3D Cube");}
+ get {return translations.GetString ("3D Cube");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many small cubes does it take to build the large cube below? Answer using a number.");}
+ get {return translations.GetString ("How many small cubes does it take to build the large cube below? Answer using a number.");}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("A cube is a regular solid object having six congruent square faces.");}
+ get { return translations.GetString ("A cube is a regular solid object having six congruent square faces.");}
}
protected override void Initialize ()
diff --git a/src/Games/Logic/PuzzleBalance.cs b/src/Games/Logic/PuzzleBalance.cs
index 12d4aeb..4be831b 100644
--- a/src/Games/Logic/PuzzleBalance.cs
+++ b/src/Games/Logic/PuzzleBalance.cs
@@ -46,21 +46,21 @@ namespace gbrainy.Games.Logic
private const double figure_width = 0.1, figure_height = 0.1, space_width = 0.05, space_height = 0;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Balance");}
+ get {return translations.GetString ("Balance");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Using triangles only, how many triangles are needed in the right part of the last figure to keep it balanced?");}
+ get {return translations.GetString ("Using triangles only, how many triangles are needed in the right part of the last figure to keep it balanced?");}
}
public override string Rationale {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Every circle is equivalent to two triangles and every square to three triangles.");
+ return translations.GetString ("Every circle is equivalent to two triangles and every square to three triangles.");
}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Every circle is equivalent two triangles.");}
+ get { return translations.GetString ("Every circle is equivalent two triangles.");}
}
protected override void Initialize ()
diff --git a/src/Games/Logic/PuzzleBuildTriangle.cs b/src/Games/Logic/PuzzleBuildTriangle.cs
index 5b007dc..8660641 100644
--- a/src/Games/Logic/PuzzleBuildTriangle.cs
+++ b/src/Games/Logic/PuzzleBuildTriangle.cs
@@ -48,17 +48,17 @@ namespace gbrainy.Games.Logic
private double radian = Math.PI / 180;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Build a triangle");}
+ get {return translations.GetString ("Build a triangle");}
}
public override string Question {
get {return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which three pieces can you use together to build a triangle? Answer using the three figure names, e.g.: {0}{1}{2}."),
+ translations.GetString ("Which three pieces can you use together to build a triangle? Answer using the three figure names, e.g.: {0}{1}{2}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2));}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The resulting triangle is isosceles.");}
+ get { return translations.GetString ("The resulting triangle is isosceles.");}
}
protected override void Initialize ()
@@ -171,7 +171,7 @@ namespace gbrainy.Games.Logic
return;
gr.MoveTo (DrawAreaX, y + 0.28);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The triangle is:"));
+ gr.ShowPangoText (translations.GetString ("The triangle is:"));
gr.Stroke ();
x = DrawAreaX + 0.35;
diff --git a/src/Games/Logic/PuzzleCirclesSquare.cs b/src/Games/Logic/PuzzleCirclesSquare.cs
index 4ec8186..749b4c2 100644
--- a/src/Games/Logic/PuzzleCirclesSquare.cs
+++ b/src/Games/Logic/PuzzleCirclesSquare.cs
@@ -27,21 +27,21 @@ namespace gbrainy.Games.Logic
public class PuzzleCirclesSquare : Game
{
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Circles in a square");}
+ get {return translations.GetString ("Circles in a square");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What is the maximum number of circles (as shown) that fit in the square below?");}
+ get {return translations.GetString ("What is the maximum number of circles (as shown) that fit in the square below?");}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You can fit more than 64 circles.");}
+ get { return translations.GetString ("You can fit more than 64 circles.");}
}
public override string Rationale {
get {
// Translators: {0} is replaced always by 0.1340
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Using the above layout {0} units of height are gained per row leaving enough space for an additional row."), 0.1340);
+ return String.Format (translations.GetString ("Using the above layout {0} units of height are gained per row leaving enough space for an additional row."), 0.1340);
}
}
@@ -75,7 +75,7 @@ namespace gbrainy.Games.Logic
gr.Stroke ();
gr.MoveTo (first_x + 0.2, first_y - 0.06 - space_fromrect);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("8 units"));
+ gr.ShowPangoText (translations.GetString ("8 units"));
gr.Stroke ();
@@ -96,7 +96,7 @@ namespace gbrainy.Games.Logic
gr.Stroke ();
gr.MoveTo (first_x - space_fromrect - 0.07, first_y + 0.3);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("8 units"), false, -1, 270 * Math.PI/180);
+ gr.ShowPangoText (translations.GetString ("8 units"), false, -1, 270 * Math.PI/180);
gr.Stroke ();
// Sample circle
@@ -115,7 +115,7 @@ namespace gbrainy.Games.Logic
gr.Stroke ();
gr.MoveTo (first_x + 0.65, first_y - 0.04 - space_fromcircle);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("1 unit"));
+ gr.ShowPangoText (translations.GetString ("1 unit"));
gr.Stroke ();
// ---
@@ -134,7 +134,7 @@ namespace gbrainy.Games.Logic
gr.Stroke ();
gr.MoveTo (first_x + 0.65 - space_fromcircle - 0.08, first_y + 0.15);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("1 unit"), false, -1, 270 * Math.PI/180);
+ gr.ShowPangoText (translations.GetString ("1 unit"), false, -1, 270 * Math.PI/180);
gr.Stroke ();
if (Answer.Draw == false)
diff --git a/src/Games/Logic/PuzzleClocks.cs b/src/Games/Logic/PuzzleClocks.cs
index 603819d..c1d1bfe 100644
--- a/src/Games/Logic/PuzzleClocks.cs
+++ b/src/Games/Logic/PuzzleClocks.cs
@@ -35,27 +35,27 @@ namespace gbrainy.Games.Logic
private const int handle_num = 2;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Clocks");}
+ get {return translations.GetString ("Clocks");}
}
public override string Question {
get {return (String.Format (
// Translators: {0} is replaced by 'Figure X'
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("To what number should the large handle of the '{0}' clock point? Answer using numbers."),
+ translations.GetString ("To what number should the large handle of the '{0}' clock point? Answer using numbers."),
Answer.GetFigureName (3)));}
}
public override string Rationale {
get {
// Translators: {0} is replaced by 'Figure X'
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString (
+ return String.Format (translations.GetString (
"Starting from the first clock, add {1} to the number obtained by appending the values to which the hands point. For example, the values of the hands for '{0}' are {3} ({2} + {1})."),
Answer.GetFigureName (3), addition, handles [4].ToString () + handles [5].ToString (), handles [6].ToString () + handles [7].ToString ());
}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The clocks do not follow the time logic.");}
+ get { return translations.GetString ("The clocks do not follow the time logic.");}
}
protected override void Initialize ()
diff --git a/src/Games/Logic/PuzzleCountCircles.cs b/src/Games/Logic/PuzzleCountCircles.cs
index 78a83ff..ae6169a 100644
--- a/src/Games/Logic/PuzzleCountCircles.cs
+++ b/src/Games/Logic/PuzzleCountCircles.cs
@@ -45,15 +45,15 @@ namespace gbrainy.Games.Logic
ItemCircle[] circles;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Count circles");}
+ get {return translations.GetString ("Count circles");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many circles do you count?");}
+ get {return translations.GetString ("How many circles do you count?");}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("It is an easy exercise if you systematically count the circles.");}
+ get { return translations.GetString ("It is an easy exercise if you systematically count the circles.");}
}
protected override void Initialize ()
diff --git a/src/Games/Logic/PuzzleCountSeries.cs b/src/Games/Logic/PuzzleCountSeries.cs
index db45aca..c60359f 100644
--- a/src/Games/Logic/PuzzleCountSeries.cs
+++ b/src/Games/Logic/PuzzleCountSeries.cs
@@ -37,7 +37,7 @@ namespace gbrainy.Games.Logic
private string question, rationale;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Count series");}
+ get {return translations.GetString ("Count series");}
}
public override string Question {
@@ -59,19 +59,19 @@ namespace gbrainy.Games.Logic
switch (game_type)
{
case GameType.HowManyNines:
- question = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many numbers '9' are required to represent the numbers between 10 to 100?");
+ question = translations.GetString ("How many numbers '9' are required to represent the numbers between 10 to 100?");
Answer.Correct = "19";
numbers = new short [] {19, 29, 39, 49, 59, 69, 79, 89, 90, 91, 92 , 93, 94, 95, 96, 97, 98, 99};
break;
case GameType.HowManyBiggerDigits:
- question = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many two digit numbers occur where the first digit is larger than the second (e.g.: 20 and 21)?");
+ question = translations.GetString ("How many two digit numbers occur where the first digit is larger than the second (e.g.: 20 and 21)?");
Answer.Correct = "45";
numbers = new short [] {10, 20, 21, 30, 31, 32, 40, 41, 42, 43, 50, 51, 52, 53, 54, 60, 61, 62, 63, 64, 65, 70, 71, 72, 73, 74, 75, 76, 80, 81, 82, 83, 84, 85, 86, 87, 90, 91, 92, 93, 94, 95, 96, 97, 98};
break;
case GameType.HowManySmallerDigits:
- question = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many two digit numbers occur where the first digit is smaller than the second (e.g.: 12 and 13)?");
+ question = translations.GetString ("How many two digit numbers occur where the first digit is smaller than the second (e.g.: 12 and 13)?");
Answer.Correct = "36";
numbers = new short [] {12, 13, 14, 15, 16, 17, 18, 19, 23, 24, 25, 26, 27, 28, 29, 34, 35, 36, 37, 38, 39, 45, 46, 47, 48, 49, 56, 57, 58, 59, 67, 68, 69, 78, 79, 89};
break;
@@ -83,15 +83,15 @@ namespace gbrainy.Games.Logic
for (int i = 1; i < numbers.Length; i++)
{
// Translators: A sequence of numbers 1, 2, 3, etc.
- rationale = string.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}, {1}"), rationale, numbers[i].ToString ());
+ rationale = string.Format (translations.GetString ("{0}, {1}"), rationale, numbers[i].ToString ());
}
- rationale = string.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The numbers are: {0}."), rationale);
+ rationale = string.Format (translations.GetString ("The numbers are: {0}."), rationale);
if (game_type == GameType.HowManyNines) {
// Translators: Concatenating two strings (rationale of answer + extra information).
- rationale = string.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} {1}"), rationale,
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Notice that 99 contains two numbers '9'."));
+ rationale = string.Format (translations.GetString ("{0} {1}"), rationale,
+ translations.GetString ("Notice that 99 contains two numbers '9'."));
}
}
}
diff --git a/src/Games/Logic/PuzzleCounting.cs b/src/Games/Logic/PuzzleCounting.cs
index e3c2935..a0ac189 100644
--- a/src/Games/Logic/PuzzleCounting.cs
+++ b/src/Games/Logic/PuzzleCounting.cs
@@ -38,7 +38,7 @@ namespace gbrainy.Games.Logic
GameType gametype;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Counting");}
+ get {return translations.GetString ("Counting");}
}
public override string Question {
@@ -61,16 +61,16 @@ namespace gbrainy.Games.Logic
var = 2 + random.Next (5);
total = 50 + random.Next (100);
question = String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString ("We have a {0} meter piece of fabric.", "We have a {0} meters piece of fabric.", total),
+ translations.GetPluralString ("We have a {0} meter piece of fabric.", "We have a {0} meters piece of fabric.", total),
total);
question += " ";
question += String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString ("Machine A takes {0} second to cut 1 meter of this fabric. How many seconds does Machine A take to cut the entire piece of fabric into 1 meter pieces?",
+ translations.GetPluralString ("Machine A takes {0} second to cut 1 meter of this fabric. How many seconds does Machine A take to cut the entire piece of fabric into 1 meter pieces?",
"Machine A takes {0} seconds to cut 1 meter of this fabric. How many seconds does Machine A take to cut the entire piece of fabric into 1 meter pieces?"
, var), var);
answer = String.Format (
// Translators: {0} is always a number greater than 1
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("With the {0} cut, Machine A creates two 1 meter pieces."), (total - 1));
+ translations.GetString ("With the {0} cut, Machine A creates two 1 meter pieces."), (total - 1));
ans = (total - 1) * var;
break;
@@ -80,14 +80,14 @@ namespace gbrainy.Games.Logic
ans = 4 * total - 4;
question = String.Format (
// Translators: {0} is a number
- ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString (
+ translations.GetPluralString (
"A fence is built to enclose a square shaped region. {0} fence pole is used in each side of the square. How many fence poles are used in total?",
"A fence is built to enclose a square shaped region. {0} fence poles are used in each side of the square. How many fence poles are used in total?",
total),
total);
// Translators: {0} is a number
answer = String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString (
+ translations.GetPluralString (
"There is {0} fence pole since the poles on the corners of the square are shared.",
"There are {0} fence poles since the poles on the corners of the square are shared.",
ans)
@@ -100,14 +100,14 @@ namespace gbrainy.Games.Logic
ans = total;
question = String.Format (
// Translators: {0} is a number
- ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString (
+ translations.GetPluralString (
"Wrapping an anniversary present costs one monetary unit. The anniversary present costs {0} monetary unit more than the cost to wrap it. How much does it cost to both purchase and wrap the present?",
"Wrapping an anniversary present costs one monetary unit. The anniversary present costs {0} monetary units more than the cost to wrap it. How much does it cost to both purchase and wrap the present?",
present),
present);
answer = String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString (
+ translations.GetPluralString (
"It is the cost of the present, {0} monetary unit, plus one monetary unit of the wrapping.",
"It is the cost of the present, {0} monetary units, plus one monetary unit of the wrapping.",
present + 1), present + 1);
diff --git a/src/Games/Logic/PuzzleCoverPercentage.cs b/src/Games/Logic/PuzzleCoverPercentage.cs
index 4f155c5..58052ea 100644
--- a/src/Games/Logic/PuzzleCoverPercentage.cs
+++ b/src/Games/Logic/PuzzleCoverPercentage.cs
@@ -32,11 +32,11 @@ namespace gbrainy.Games.Logic
private const double line_width = 0.001;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Cover percentage");}
+ get {return translations.GetString ("Cover percentage");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What percentage of the figure is colored?");}
+ get {return translations.GetString ("What percentage of the figure is colored?");}
}
protected override void Initialize ()
diff --git a/src/Games/Logic/PuzzleCube.cs b/src/Games/Logic/PuzzleCube.cs
index 633a1b6..bde0730 100755
--- a/src/Games/Logic/PuzzleCube.cs
+++ b/src/Games/Logic/PuzzleCube.cs
@@ -42,11 +42,11 @@ namespace gbrainy.Games.Logic
};
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Cube");}
+ get {return translations.GetString ("Cube");}
}
public override string Question {
- get {return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("When you fold the figure below as a cube, which face on the figure is opposite the face with a {0} drawn on it? Answer the number written on the face."), question);}
+ get {return String.Format (translations.GetString ("When you fold the figure below as a cube, which face on the figure is opposite the face with a {0} drawn on it? Answer the number written on the face."), question);}
}
protected override void Initialize ()
diff --git a/src/Games/Logic/PuzzleDice.cs b/src/Games/Logic/PuzzleDice.cs
index f92ab04..0e89cb8 100644
--- a/src/Games/Logic/PuzzleDice.cs
+++ b/src/Games/Logic/PuzzleDice.cs
@@ -51,26 +51,26 @@ namespace gbrainy.Games.Logic
{
problems = new Problem []
{
- new Problem (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What is the probability of getting a '2' or a '6' in a single throw of an unmodified 6 sided die? Answer using a fraction (e.g.: 1/2)."),
+ new Problem (translations.GetString ("What is the probability of getting a '2' or a '6' in a single throw of an unmodified 6 sided die? Answer using a fraction (e.g.: 1/2)."),
"1/3",
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("There are 2 of 6 possibilities."), true),
+ translations.GetString ("There are 2 of 6 possibilities."), true),
- new Problem (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What is the probability of not getting a '5' in a single throw of an unmodified 6 sided die? Answer using a fraction (e.g.: 1/2)."),
+ new Problem (translations.GetString ("What is the probability of not getting a '5' in a single throw of an unmodified 6 sided die? Answer using a fraction (e.g.: 1/2)."),
"5/6",
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("There are 5 of 6 possibilities."), true),
+ translations.GetString ("There are 5 of 6 possibilities."), true),
- new Problem (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Two unmodified 6 sided dice are thrown simultaneously. What is the probability of getting two even numbers? Answer using a fraction (e.g.: 1/2)."),
+ new Problem (translations.GetString ("Two unmodified 6 sided dice are thrown simultaneously. What is the probability of getting two even numbers? Answer using a fraction (e.g.: 1/2)."),
"9/36",
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("There are 9 of 36 possibilities of getting two even numbers."), false),
+ translations.GetString ("There are 9 of 36 possibilities of getting two even numbers."), false),
- new Problem (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Two unmodified 6 sided dice are thrown simultaneously. What is the probability of getting two '6'? Answer using a fraction (e.g.: 1/2)."),
+ new Problem (translations.GetString ("Two unmodified 6 sided dice are thrown simultaneously. What is the probability of getting two '6'? Answer using a fraction (e.g.: 1/2)."),
"1/36",
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("There is 1 of 6 possibilities of getting a '6' on the first die and the same for the second die."), false),
+ translations.GetString ("There is 1 of 6 possibilities of getting a '6' on the first die and the same for the second die."), false),
};
}
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Dice");}
+ get {return translations.GetString ("Dice");}
}
public override string Question {
diff --git a/src/Games/Logic/PuzzleDivideCircle.cs b/src/Games/Logic/PuzzleDivideCircle.cs
index 4290e01..091264c 100644
--- a/src/Games/Logic/PuzzleDivideCircle.cs
+++ b/src/Games/Logic/PuzzleDivideCircle.cs
@@ -42,11 +42,11 @@ namespace gbrainy.Games.Logic
}
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Divide circles");}
+ get {return translations.GetString ("Divide circles");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("In the last figure, in how many regions is the circle divided into when all dots are connected?");}
+ get {return translations.GetString ("In the last figure, in how many regions is the circle divided into when all dots are connected?");}
}
protected override void Initialize ()
@@ -174,9 +174,9 @@ namespace gbrainy.Games.Logic
DrawAndConnectPoints (gr, pos_x, pos_y, circles, Answer.Draw);
}
- static string HasNRegionString (int regions)
+ string HasNRegionString (int regions)
{
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString ("Has {0} region",
+ return String.Format (translations.GetPluralString ("Has {0} region",
"Has {0} regions", regions), regions);
}
diff --git a/src/Games/Logic/PuzzleEquation.cs b/src/Games/Logic/PuzzleEquation.cs
index 6e676e3..d36b516 100644
--- a/src/Games/Logic/PuzzleEquation.cs
+++ b/src/Games/Logic/PuzzleEquation.cs
@@ -30,16 +30,16 @@ namespace gbrainy.Games.Logic
private string formula;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Equation");}
+ get {return translations.GetString ("Equation");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What is the result of the equation below?");}
+ get {return translations.GetString ("What is the result of the equation below?");}
}
public override string Rationale {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The order of arithmetical operations is always as follows: exponents and roots, multiplication and division, addition and subtraction.");
+ return translations.GetString ("The order of arithmetical operations is always as follows: exponents and roots, multiplication and division, addition and subtraction.");
}
}
diff --git a/src/Games/Logic/PuzzleExtraCircle.cs b/src/Games/Logic/PuzzleExtraCircle.cs
index 2c27e45..fbd03b6 100644
--- a/src/Games/Logic/PuzzleExtraCircle.cs
+++ b/src/Games/Logic/PuzzleExtraCircle.cs
@@ -50,7 +50,7 @@ namespace gbrainy.Games.Logic
};
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Extra circle");}
+ get {return translations.GetString ("Extra circle");}
}
public override bool UsesColors {
@@ -59,17 +59,17 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which circle does not belong to the group? It is not a sequence of elements. Answer {0}, {1}, {2} or {3}."),
+ translations.GetString ("Which circle does not belong to the group? It is not a sequence of elements. Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3));}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All circles share a common property except for one.");}
+ get { return translations.GetString ("All circles share a common property except for one.");}
}
public override string Rationale {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("In all circles the color slices follow the same order except for this one.");
+ return translations.GetString ("In all circles the color slices follow the same order except for this one.");
}
}
@@ -78,7 +78,7 @@ namespace gbrainy.Games.Logic
ArrayListIndicesRandom random_indices = new ArrayListIndicesRandom (total_slices);
Color clr;
- cp = new ColorPalette ();
+ cp = new ColorPalette (translations);
Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
diff --git a/src/Games/Logic/PuzzleFigureLetter.cs b/src/Games/Logic/PuzzleFigureLetter.cs
index f3a7042..f3da0d1 100644
--- a/src/Games/Logic/PuzzleFigureLetter.cs
+++ b/src/Games/Logic/PuzzleFigureLetter.cs
@@ -37,20 +37,20 @@ namespace gbrainy.Games.Logic
}
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Figures and text");}
+ get {return translations.GetString ("Figures and text");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The figures and the text are related. What text should go under the last figure?");}
+ get {return translations.GetString ("The figures and the text are related. What text should go under the last figure?");}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Every character of the text represents a property of the figure.");}
+ get { return translations.GetString ("Every character of the text represents a property of the figure.");}
}
public override string Rationale {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("'A' indicates that the figures overlap, 'B' that are squares, 'C' that are circles, 'D' that the figures are separated, 'E' that there are three figures and 'F' that there are two figures.");
+ return translations.GetString ("'A' indicates that the figures overlap, 'B' that are squares, 'C' that are circles, 'D' that the figures are separated, 'E' that there are three figures and 'F' that there are two figures.");
}
}
diff --git a/src/Games/Logic/PuzzleFigurePattern.cs b/src/Games/Logic/PuzzleFigurePattern.cs
index cbf3faf..9829e72 100644
--- a/src/Games/Logic/PuzzleFigurePattern.cs
+++ b/src/Games/Logic/PuzzleFigurePattern.cs
@@ -37,22 +37,22 @@ namespace gbrainy.Games.Logic
};
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Figure pattern");}
+ get {return translations.GetString ("Figure pattern");}
}
public override string Question {
get {return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What figure should replace the question mark? Answer {0}, {1} or {2}."),
+ translations.GetString ("What figure should replace the question mark? Answer {0}, {1} or {2}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2));}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The third figure of every row involves somehow combining the first two figures.");}
+ get { return translations.GetString ("The third figure of every row involves somehow combining the first two figures.");}
}
public override string Rationale {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Superpose the first and second figures and remove the lines that they have in common, then rotate the resulting figure 45 degrees.");
+ return translations.GetString ("Superpose the first and second figures and remove the lines that they have in common, then rotate the resulting figure 45 degrees.");
}
}
@@ -188,7 +188,7 @@ namespace gbrainy.Games.Logic
gr.Stroke ();
gr.MoveTo (0.05, y - 0.01 + space_y);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
// Answers
x = org_x;
diff --git a/src/Games/Logic/PuzzleFigures.cs b/src/Games/Logic/PuzzleFigures.cs
index 2399293..3fe0455 100644
--- a/src/Games/Logic/PuzzleFigures.cs
+++ b/src/Games/Logic/PuzzleFigures.cs
@@ -55,17 +55,17 @@ namespace gbrainy.Games.Logic
Figure [] figure_answers;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Figures");}
+ get {return translations.GetString ("Figures");}
}
public override string Question {
- get {return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What is the next logical sequence of objects in the last column? Answer {0}, {1} or {2}."),
+ get {return String.Format (translations.GetString ("What is the next logical sequence of objects in the last column? Answer {0}, {1} or {2}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2));}
}
public override string Rationale {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("It is the only combination that you can build with the given elements without repeating them.");
+ return translations.GetString ("It is the only combination that you can build with the given elements without repeating them.");
}
}
@@ -192,7 +192,7 @@ namespace gbrainy.Games.Logic
}
gr.MoveTo (0.08, 0.45);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
gr.Stroke ();
}
}
diff --git a/src/Games/Logic/PuzzleFourSided.cs b/src/Games/Logic/PuzzleFourSided.cs
index 1f4ca49..3796c8b 100644
--- a/src/Games/Logic/PuzzleFourSided.cs
+++ b/src/Games/Logic/PuzzleFourSided.cs
@@ -29,20 +29,20 @@ namespace gbrainy.Games.Logic
{
int type;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Four sided");}
+ get {return translations.GetString ("Four sided");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many four sided figures do you count in the figure below?");}
+ get {return translations.GetString ("How many four sided figures do you count in the figure below?");}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("A four sided figure can be embedded inside another figure.");}
+ get { return translations.GetString ("A four sided figure can be embedded inside another figure.");}
}
public override string Rationale {
get {
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The four sided figures are made by connecting the following points: {0}"),
+ return String.Format (translations.GetString ("The four sided figures are made by connecting the following points: {0}"),
(type == 0) ? "abde, degh, bcef, efhi, acdf, dfgi, abhg, bcih, acig, aghe, aefc, deig, bcie." :
"abde, degh, bcef, efhi, acdf, dfgi, abhg, bcih, acig, aghe, aefc, deig, bcie, acde, cehi, abeg, egif.");
}
diff --git a/src/Games/Logic/PuzzleGridCircles.cs b/src/Games/Logic/PuzzleGridCircles.cs
index 6ec8c15..3d6b55f 100644
--- a/src/Games/Logic/PuzzleGridCircles.cs
+++ b/src/Games/Logic/PuzzleGridCircles.cs
@@ -32,20 +32,20 @@ namespace gbrainy.Games.Logic
private int divisor;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Circles in a grid");}
+ get {return translations.GetString ("Circles in a grid");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("One of the numbers in the grid must be circled. Which one?");}
+ get {return translations.GetString ("One of the numbers in the grid must be circled. Which one?");}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All circled numbers share an arithmetical property.");}
+ get { return translations.GetString ("All circled numbers share an arithmetical property.");}
}
public override string Rationale {
get {
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Every circled number can be divided by {0}."), divisor);
+ return String.Format (translations.GetString ("Every circled number can be divided by {0}."), divisor);
}
}
diff --git a/src/Games/Logic/PuzzleGridDots.cs b/src/Games/Logic/PuzzleGridDots.cs
index 1b99555..1ea8b96 100644
--- a/src/Games/Logic/PuzzleGridDots.cs
+++ b/src/Games/Logic/PuzzleGridDots.cs
@@ -202,12 +202,12 @@ namespace gbrainy.Games.Logic
};
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Square with dots");}
+ get {return translations.GetString ("Square with dots");}
}
public override string Question {
get {return (String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which is the next logical figure in the sequence? Answer {0}, {1} or {2}."),
+ translations.GetString ("Which is the next logical figure in the sequence? Answer {0}, {1} or {2}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2)));}
}
@@ -217,9 +217,9 @@ namespace gbrainy.Games.Logic
switch (puzzle_index) {
case 0:
// Translators: Please, do not make the translated string longer than the original English one. It will not fit in screen.
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("From the top-left figure, the top-left circle moves down, the bottom-left circle moves up, the bottom-right moves diagonally up-left and the top-right moves diagonally down-left.");
+ return translations.GetString ("From the top-left figure, the top-left circle moves down, the bottom-left circle moves up, the bottom-right moves diagonally up-left and the top-right moves diagonally down-left.");
case 2:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString
+ return translations.GetString
("From the top-left figure, the figure is rotated counterclockwise 90 degrees.");
case 1: // TODO
default:
@@ -338,7 +338,7 @@ namespace gbrainy.Games.Logic
y += figure_size + 0.10;
gr.MoveTo (x, y - 0.02);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
}
}
}
diff --git a/src/Games/Logic/PuzzleGridNumbers.cs b/src/Games/Logic/PuzzleGridNumbers.cs
index 82f1495..3ef574c 100644
--- a/src/Games/Logic/PuzzleGridNumbers.cs
+++ b/src/Games/Logic/PuzzleGridNumbers.cs
@@ -41,19 +41,19 @@ namespace gbrainy.Games.Logic
private const int rows = 4, columns = 4;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Numbers in a grid");}
+ get {return translations.GetString ("Numbers in a grid");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The numbers in the grid below follow a pattern. Which number should replace the question mark?");}
+ get {return translations.GetString ("The numbers in the grid below follow a pattern. Which number should replace the question mark?");}
}
public override string Tip {
get {
if (orientation)
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The pattern is arithmetical and works vertically.");
+ return translations.GetString ("The pattern is arithmetical and works vertically.");
else
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The pattern is arithmetical and works horizontally.");
+ return translations.GetString ("The pattern is arithmetical and works horizontally.");
}
}
@@ -62,21 +62,21 @@ namespace gbrainy.Games.Logic
switch (operation) {
case Operation.MultiplyAndAdd:
if (orientation) {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The fourth row is calculated by multiplying the first two rows and adding the third.");
+ return translations.GetString ("The fourth row is calculated by multiplying the first two rows and adding the third.");
} else {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The fourth column is calculated by multiplying the first two columns and adding the third.");
+ return translations.GetString ("The fourth column is calculated by multiplying the first two columns and adding the third.");
}
case Operation.MutilplyAndSubs:
if (orientation) {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The fourth row is calculated by multiplying the first two rows and subtracting the third.");
+ return translations.GetString ("The fourth row is calculated by multiplying the first two rows and subtracting the third.");
} else {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The fourth column is calculated by multiplying the first two columns and subtracting the third.");
+ return translations.GetString ("The fourth column is calculated by multiplying the first two columns and subtracting the third.");
}
case Operation.AddAndSubs:
if (orientation) {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The fourth row is calculated by adding the first two rows and subtracting the third.");
+ return translations.GetString ("The fourth row is calculated by adding the first two rows and subtracting the third.");
} else {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The fourth column is calculated by adding the first two columns and subtracting the third.");
+ return translations.GetString ("The fourth column is calculated by adding the first two columns and subtracting the third.");
}
default:
return string.Empty;
diff --git a/src/Games/Logic/PuzzleHandshakes.cs b/src/Games/Logic/PuzzleHandshakes.cs
index f203f49..b20292a 100644
--- a/src/Games/Logic/PuzzleHandshakes.cs
+++ b/src/Games/Logic/PuzzleHandshakes.cs
@@ -29,17 +29,17 @@ namespace gbrainy.Games.Logic
int people, handshakes;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Handshakes");}
+ get {return translations.GetString ("Handshakes");}
}
public override string Question {
get {return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All attendees to a party are introduced to one another. {0} handshakes are made in total. How many people are attending the party?"), handshakes);
+ translations.GetString ("All attendees to a party are introduced to one another. {0} handshakes are made in total. How many people are attending the party?"), handshakes);
}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Try to imagine a situation in which you are meeting a small number of people.");}
+ get { return translations.GetString ("Try to imagine a situation in which you are meeting a small number of people.");}
}
protected override void Initialize ()
diff --git a/src/Games/Logic/PuzzleLargerShape.cs b/src/Games/Logic/PuzzleLargerShape.cs
index d9a1a50..ac0c492 100644
--- a/src/Games/Logic/PuzzleLargerShape.cs
+++ b/src/Games/Logic/PuzzleLargerShape.cs
@@ -110,7 +110,7 @@ namespace gbrainy.Games.Logic
};
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Larger shape");}
+ get {return translations.GetString ("Larger shape");}
}
public override bool UsesColors {
@@ -119,14 +119,14 @@ namespace gbrainy.Games.Logic
public override string Question {
get {return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which larger shape can you make combining the first two figures? Answer {0}, {1}, {2} or {3}."),
+ translations.GetString ("Which larger shape can you make combining the first two figures? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3));}
}
protected override void Initialize ()
{
Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
- palette = new ColorPalette ();
+ palette = new ColorPalette (translations);
switch (random.Next (2)) {
case 0:
@@ -300,7 +300,7 @@ namespace gbrainy.Games.Logic
base.Draw (gr, area_width, area_height, rtl);
gr.MoveTo (0.1, 0.3);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
gr.Stroke ();
}
}
diff --git a/src/Games/Logic/PuzzleLines.cs b/src/Games/Logic/PuzzleLines.cs
index 1fdfcd7..cd951df 100644
--- a/src/Games/Logic/PuzzleLines.cs
+++ b/src/Games/Logic/PuzzleLines.cs
@@ -31,16 +31,16 @@ namespace gbrainy.Games.Logic
private int fig1, fig2;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Lines");}
+ get {return translations.GetString ("Lines");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many line segments in total are in the figures below? A line segment is a line between two points with no crossing lines.");}
+ get {return translations.GetString ("How many line segments in total are in the figures below? A line segment is a line between two points with no crossing lines.");}
}
public override string Rationale {
get {
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString (
+ return String.Format (translations.GetPluralString (
"There is {0} line in the figure to the left and {1} in the figure to the right.",
"There are {0} lines in the figure to the left and {1} in the figure to the right.",
fig1),
@@ -49,7 +49,7 @@ namespace gbrainy.Games.Logic
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("It is an easy exercise if you systematically count the lines.");}
+ get { return translations.GetString ("It is an easy exercise if you systematically count the lines.");}
}
protected override void Initialize ()
diff --git a/src/Games/Logic/PuzzleMissingPiece.cs b/src/Games/Logic/PuzzleMissingPiece.cs
index 8b05d1d..3f36436 100644
--- a/src/Games/Logic/PuzzleMissingPiece.cs
+++ b/src/Games/Logic/PuzzleMissingPiece.cs
@@ -32,22 +32,22 @@ namespace gbrainy.Games.Logic
private const double sub_figure = 0.15;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Missing piece");}
+ get {return translations.GetString ("Missing piece");}
}
public override string Question {
get {return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which square completes the figure below? Answer {0}, {1} or {2}."),
+ translations.GetString ("Which square completes the figure below? Answer {0}, {1} or {2}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2));}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The logic works at row level.");}
+ get { return translations.GetString ("The logic works at row level.");}
}
public override string Rationale {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("In every row the third square is made by flipping the first square and superimposing it on the second square, followed by removing the matching lines.");
+ return translations.GetString ("In every row the third square is made by flipping the first square and superimposing it on the second square, followed by removing the matching lines.");
}
}
@@ -170,7 +170,7 @@ namespace gbrainy.Games.Logic
DrawFigureSequence (gr, x, DrawAreaY + sub_figure * 2 , 2, false);
gr.MoveTo (0.1, 0.62);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
}
}
}
diff --git a/src/Games/Logic/PuzzleMissingSlice.cs b/src/Games/Logic/PuzzleMissingSlice.cs
index ad5321c..ec13319 100644
--- a/src/Games/Logic/PuzzleMissingSlice.cs
+++ b/src/Games/Logic/PuzzleMissingSlice.cs
@@ -59,22 +59,22 @@ namespace gbrainy.Games.Logic
};
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Missing slice");}
+ get {return translations.GetString ("Missing slice");}
}
public override string Question {
get {return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The slices below have some kind of relation. Which is the missing slice in the circle below? Answer {0}, {1} or {2}."),
+ translations.GetString ("The slices below have some kind of relation. Which is the missing slice in the circle below? Answer {0}, {1} or {2}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2));}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Each slice is related to the opposite one.");}
+ get { return translations.GetString ("Each slice is related to the opposite one.");}
}
public override string Rationale {
get {
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All numbers of each slice, when added to the ones of the opposite slice, add always {0}."), sum_offset + 8);
+ return String.Format (translations.GetString ("All numbers of each slice, when added to the ones of the opposite slice, add always {0}."), sum_offset + 8);
}
}
@@ -215,7 +215,7 @@ namespace gbrainy.Games.Logic
}
gr.MoveTo (0.1, 0.55);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
gr.Stroke ();
}
}
diff --git a/src/Games/Logic/PuzzleMostInCommon.cs b/src/Games/Logic/PuzzleMostInCommon.cs
index 132f07a..6011e52 100644
--- a/src/Games/Logic/PuzzleMostInCommon.cs
+++ b/src/Games/Logic/PuzzleMostInCommon.cs
@@ -73,25 +73,25 @@ namespace gbrainy.Games.Logic
private const double pos7_y = 0.11;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Most in common");}
+ get {return translations.GetString ("Most in common");}
}
public override string Question {
get {return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which of the possible answers have the most in common with the four given figures? Answer {0}, {1}, {2} or {3}."),
+ translations.GetString ("Which of the possible answers have the most in common with the four given figures? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3));}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Think of the common elements that the given figures have inside them.");}
+ get { return translations.GetString ("Think of the common elements that the given figures have inside them.");}
}
public override string Rationale {
get {
if (CurrentDifficulty == GameDifficulty.Easy)
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("It has the same number of elements inside the figure as the given figures.");
+ return translations.GetString ("It has the same number of elements inside the figure as the given figures.");
else
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("It is the figure with the most elements in common compared to the given figures.");
+ return translations.GetString ("It is the figure with the most elements in common compared to the given figures.");
}
}
@@ -311,7 +311,7 @@ namespace gbrainy.Games.Logic
y += 0.28;
x = DrawAreaX;
gr.MoveTo (x - 0.06, y);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
gr.Stroke ();
}
}
diff --git a/src/Games/Logic/PuzzleMoveFigure.cs b/src/Games/Logic/PuzzleMoveFigure.cs
index 3790a3f..8a037a4 100644
--- a/src/Games/Logic/PuzzleMoveFigure.cs
+++ b/src/Games/Logic/PuzzleMoveFigure.cs
@@ -30,20 +30,20 @@ namespace gbrainy.Games.Logic
private int type;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Move figure");}
+ get {return translations.GetString ("Move figure");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What is the minimum number of circles to be moved in order to convert the left figure into the right figure?");}
+ get {return translations.GetString ("What is the minimum number of circles to be moved in order to convert the left figure into the right figure?");}
}
public override string Rationale {
get {
switch (type) {
case 0:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Move the circle from the first line to the second and move two circles from the fourth line to the second and the fifth lines.");
+ return translations.GetString ("Move the circle from the first line to the second and move two circles from the fourth line to the second and the fifth lines.");
case 1:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Move the first line to the seventh; move the two circles of the second line to third; and move first and last circles of the fifth line to the sixth.");
+ return translations.GetString ("Move the first line to the seventh; move the two circles of the second line to third; and move first and last circles of the fifth line to the sixth.");
default:
return string.Empty;
}
diff --git a/src/Games/Logic/PuzzleNextFigure.cs b/src/Games/Logic/PuzzleNextFigure.cs
index 4b278ff..29a25b9 100644
--- a/src/Games/Logic/PuzzleNextFigure.cs
+++ b/src/Games/Logic/PuzzleNextFigure.cs
@@ -50,19 +50,19 @@ namespace gbrainy.Games.Logic
};
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Next figure");}
+ get {return translations.GetString ("Next figure");}
}
public override string Question {
get {return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which is the next logical figure in the sequence? Answer {0}, {1} or {2}."),
+ translations.GetString ("Which is the next logical figure in the sequence? Answer {0}, {1} or {2}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2));}
}
public override string Rationale {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("From first figure, the top circle advances by two positions clockwise, while the left circle goes backwards one position.");
+ return translations.GetString ("From first figure, the top circle advances by two positions clockwise, while the left circle goes backwards one position.");
}
}
@@ -163,7 +163,7 @@ namespace gbrainy.Games.Logic
y += figure_size + 0.06;
gr.MoveTo (x, y);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
gr.Stroke ();
}
}
diff --git a/src/Games/Logic/PuzzleNumericRelation.cs b/src/Games/Logic/PuzzleNumericRelation.cs
index f021693..e720e61 100644
--- a/src/Games/Logic/PuzzleNumericRelation.cs
+++ b/src/Games/Logic/PuzzleNumericRelation.cs
@@ -43,26 +43,26 @@ namespace gbrainy.Games.Logic
};
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Numeric relation");}
+ get {return translations.GetString ("Numeric relation");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What number should replace the question mark?");}
+ get {return translations.GetString ("What number should replace the question mark?");}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The numbers are related arithmetically.");}
+ get { return translations.GetString ("The numbers are related arithmetically.");}
}
public override string Rationale {
get {
switch (formula) {
case Formula.AllAdding:
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Every group of {0} numbers sums exactly {1}."), group_size, sum_value);
+ return String.Format (translations.GetString ("Every group of {0} numbers sums exactly {1}."), group_size, sum_value);
case Formula.ThirdMultiply:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Divide the sequence in groups of three numbers. Every third number is calculated by multiplying by the two previous ones.");
+ return translations.GetString ("Divide the sequence in groups of three numbers. Every third number is calculated by multiplying by the two previous ones.");
case Formula.ThirdSubstracting:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Divide the sequence in groups of three numbers. Every third number is calculated by subtracting the second number from the first.");
+ return translations.GetString ("Divide the sequence in groups of three numbers. Every third number is calculated by subtracting the second number from the first.");
default:
throw new InvalidOperationException ("Invalid Value");
}
diff --git a/src/Games/Logic/PuzzleNumericSequence.cs b/src/Games/Logic/PuzzleNumericSequence.cs
index 2bb32ea..885901e 100644
--- a/src/Games/Logic/PuzzleNumericSequence.cs
+++ b/src/Games/Logic/PuzzleNumericSequence.cs
@@ -39,26 +39,26 @@ namespace gbrainy.Games.Logic
private Formula formula;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Numeric sequence");}
+ get {return translations.GetString ("Numeric sequence");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The next sequence follows a logic. What number should replace the question mark?");}
+ get {return translations.GetString ("The next sequence follows a logic. What number should replace the question mark?");}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Every number in the sequence is related to the previous one.");}
+ get { return translations.GetString ("Every number in the sequence is related to the previous one.");}
}
public override string Rationale {
get {
switch (formula) {
case Formula.SubstractingOne:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Every number in the sequence is the result of subtracting 1 from the previous number and multiplying it by 2.");
+ return translations.GetString ("Every number in the sequence is the result of subtracting 1 from the previous number and multiplying it by 2.");
case Formula.Adding:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Every number in the sequence is the result of adding 1 to the previous number and multiplying it by 3.");
+ return translations.GetString ("Every number in the sequence is the result of adding 1 to the previous number and multiplying it by 3.");
case Formula.SubstractingTwo:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Every number in the sequence is the result of subtracting 2 from the previous number and multiplying it by -2.");
+ return translations.GetString ("Every number in the sequence is the result of subtracting 2 from the previous number and multiplying it by -2.");
default:
return string.Empty;
}
diff --git a/src/Games/Logic/PuzzleOstracism.cs b/src/Games/Logic/PuzzleOstracism.cs
index f332ded..cf99aa0 100644
--- a/src/Games/Logic/PuzzleOstracism.cs
+++ b/src/Games/Logic/PuzzleOstracism.cs
@@ -50,12 +50,12 @@ namespace gbrainy.Games.Logic
string [] equations;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Ostracism");}
+ get {return translations.GetString ("Ostracism");}
}
public override string Question {
get {return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which element does not belong to the group? It is not related to any arithmetical of the numbers. Answer {0}, {1}, {2}, {3} or {4}."),
+ translations.GetString ("Which element does not belong to the group? It is not related to any arithmetical of the numbers. Answer {0}, {1}, {2}, {3} or {4}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3), Answer.GetMultiOption (4));}
}
@@ -63,9 +63,9 @@ namespace gbrainy.Games.Logic
get {
switch (gametype) {
case GameType.Equations:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The criteria for deciding if an equation belongs to the group is not arithmetical.");
+ return translations.GetString ("The criteria for deciding if an equation belongs to the group is not arithmetical.");
case GameType.Numbers:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Consider that every number that belongs to the group has two parts that are related.");
+ return translations.GetString ("Consider that every number that belongs to the group has two parts that are related.");
default:
throw new InvalidOperationException ();
}
@@ -76,9 +76,9 @@ namespace gbrainy.Games.Logic
get {
switch (gametype) {
case GameType.Equations:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("In all the other equations the digits from the left side also appear on the right side.");
+ return translations.GetString ("In all the other equations the digits from the left side also appear on the right side.");
case GameType.Numbers:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("In all the other numbers the last three digits are the square of the first two digits.");
+ return translations.GetString ("In all the other numbers the last three digits are the square of the first two digits.");
default:
throw new InvalidOperationException ();
}
@@ -161,7 +161,7 @@ namespace gbrainy.Games.Logic
e.Context.SetPangoLargeFontSize ();
e.Context.MoveTo (0.05, 0.02);
// Translators: this "option) answer" for example "a) "21 x 60 = 1260". This should not be changed for most of the languages
- e.Context.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), Answer.GetMultiOption (n), equations [random_indices[n]]));
+ e.Context.ShowPangoText (String.Format (translations.GetString ("{0}) {1}"), Answer.GetMultiOption (n), equations [random_indices[n]]));
};
}
}
@@ -173,7 +173,7 @@ namespace gbrainy.Games.Logic
gr.SetPangoLargeFontSize ();
gr.MoveTo (0.1, 0.15);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
}
}
}
diff --git a/src/Games/Logic/PuzzlePencil.cs b/src/Games/Logic/PuzzlePencil.cs
index 72054b3..aa74448 100644
--- a/src/Games/Logic/PuzzlePencil.cs
+++ b/src/Games/Logic/PuzzlePencil.cs
@@ -35,11 +35,11 @@ namespace gbrainy.Games.Logic
private const int answer_index = 4;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Pencil");}
+ get {return translations.GetString ("Pencil");}
}
public override string Question {
- get {return String.Format ( ServiceLocator.Instance.GetService <ITranslations> ().GetString
+ get {return String.Format ( translations.GetString
("Which of the following figures cannot be drawn without crossing any previous lines nor lifting the pencil? Answer {0}, {1}, {2}, {3} or {4}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3), Answer.GetMultiOption (4));}
}
diff --git a/src/Games/Logic/PuzzlePeopleTable.cs b/src/Games/Logic/PuzzlePeopleTable.cs
index 510edaf..8035f27 100644
--- a/src/Games/Logic/PuzzlePeopleTable.cs
+++ b/src/Games/Logic/PuzzlePeopleTable.cs
@@ -42,16 +42,16 @@ namespace gbrainy.Games.Logic
}
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("People at a table");}
+ get {return translations.GetString ("People at a table");}
}
public override string Question {
- get {return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("A group of people are sitting at a round table spaced out evenly. How many people are there if the {0} person is across from the {1}?"), ques1, ques2);}
+ get {return String.Format (translations.GetString ("A group of people are sitting at a round table spaced out evenly. How many people are there if the {0} person is across from the {1}?"), ques1, ques2);}
}
public override string Rationale {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Subtracting the two positions you find out how many people are seated half way around the table. Doubling this number leaves you with the total amount of people.");
+ return translations.GetString ("Subtracting the two positions you find out how many people are seated half way around the table. Doubling this number leaves you with the total amount of people.");
}
}
@@ -59,18 +59,18 @@ namespace gbrainy.Games.Logic
{
switch (random.Next (3)) {
case 0:
- ques1 = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("5th");
- ques2 = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("19th");
+ ques1 = translations.GetString ("5th");
+ ques2 = translations.GetString ("19th");
Answer.Correct = "28";
break;
case 1:
- ques1 = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("4th");
- ques2 = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("12th");
+ ques1 = translations.GetString ("4th");
+ ques2 = translations.GetString ("12th");
Answer.Correct = "16";
break;
case 2:
- ques1 = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("9th");
- ques2 = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("22nd");
+ ques1 = translations.GetString ("9th");
+ ques2 = translations.GetString ("22nd");
Answer.Correct = "26";
break;
}
@@ -110,7 +110,7 @@ namespace gbrainy.Games.Logic
gr.Stroke ();
gr.DrawTextCentered (pos_x + figure_size, pos_y + 0.08 + figure_size * 2,
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Two people in the table sitting across each other"));
+ translations.GetString ("Two people in the table sitting across each other"));
}
}
}
diff --git a/src/Games/Logic/PuzzlePercentage.cs b/src/Games/Logic/PuzzlePercentage.cs
index e1b3dfd..315e383 100644
--- a/src/Games/Logic/PuzzlePercentage.cs
+++ b/src/Games/Logic/PuzzlePercentage.cs
@@ -38,7 +38,7 @@ namespace gbrainy.Games.Logic
GameType gametype;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Percentage");}
+ get {return translations.GetString ("Percentage");}
}
public override string Question {
@@ -71,7 +71,7 @@ namespace gbrainy.Games.Logic
} while (paid != Math.Truncate (paid));
question = String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("After getting {0}% discount you have paid {1} monetary units for a TV set. What was the original price of the TV set?"),
+ translations.GetString ("After getting {0}% discount you have paid {1} monetary units for a TV set. What was the original price of the TV set?"),
discount, paid);
ans = (int)price;
svg_image = "tv_set.svg";
@@ -89,7 +89,7 @@ namespace gbrainy.Games.Logic
question = String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("John's shop had sales of {0} monetary units. This was an increase of {1}% over last month. What were last month sales?"),
+ translations.GetString ("John's shop had sales of {0} monetary units. This was an increase of {1}% over last month. What were last month sales?"),
sales, increase);
ans = (int) previous;
svg_image = "shop.svg";
@@ -105,10 +105,10 @@ namespace gbrainy.Games.Logic
} while (percentage != Math.Truncate (percentage));
question = String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The amount of water in a bucket decreases by {0}%. By what percentage must the amount of water increase to reach its original value?"),
+ translations.GetString ("The amount of water in a bucket decreases by {0}%. By what percentage must the amount of water increase to reach its original value?"),
decrease);
- answer = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The objective is to obtain the same total amount.");
+ answer = translations.GetString ("The objective is to obtain the same total amount.");
ans = (int) percentage;
svg_image = "bucket.svg";
break;
diff --git a/src/Games/Logic/PuzzlePredicateLogic.cs b/src/Games/Logic/PuzzlePredicateLogic.cs
index 16719ba..8404dc7 100644
--- a/src/Games/Logic/PuzzlePredicateLogic.cs
+++ b/src/Games/Logic/PuzzlePredicateLogic.cs
@@ -58,82 +58,82 @@ namespace gbrainy.Games.Logic
Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption;
predicates = new Predicate []
{
- new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If all painters are artists and some citizens of Barcelona are artists. Which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
+ new Predicate (String.Format (translations.GetString ("If all painters are artists and some citizens of Barcelona are artists. Which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3)),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some citizens of Barcelona are painters"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All citizens of Barcelona are painters"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("No citizen of Barcelona is a painter"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("None of the other options"),
+ translations.GetString ("Some citizens of Barcelona are painters"),
+ translations.GetString ("All citizens of Barcelona are painters"),
+ translations.GetString ("No citizen of Barcelona is a painter"),
+ translations.GetString ("None of the other options"),
3),
- new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If no ill artist is happy and some artists are happy. Which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
+ new Predicate (String.Format (translations.GetString ("If no ill artist is happy and some artists are happy. Which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3)),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some artist are not ill"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some painters are not artists"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All artists are happy"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("None of the other options"),
+ translations.GetString ("Some artist are not ill"),
+ translations.GetString ("Some painters are not artists"),
+ translations.GetString ("All artists are happy"),
+ translations.GetString ("None of the other options"),
0),
- new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("People that travel always buy a map. You are not going to travel. Which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
+ new Predicate (String.Format (translations.GetString ("People that travel always buy a map. You are not going to travel. Which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3)),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You do not have any map"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You do not buy a map"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All people have a map"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("None of the other options"),
+ translations.GetString ("You do not have any map"),
+ translations.GetString ("You do not buy a map"),
+ translations.GetString ("All people have a map"),
+ translations.GetString ("None of the other options"),
3),
- new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If you whistle if you are happy and you always smile when you whistle, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
+ new Predicate (String.Format (translations.GetString ("If you whistle if you are happy and you always smile when you whistle, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3)),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You smile if you are happy"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You are only happy if you whistle"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You whistle if you are not happy"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("None of the other options"),
+ translations.GetString ("You smile if you are happy"),
+ translations.GetString ("You are only happy if you whistle"),
+ translations.GetString ("You whistle if you are not happy"),
+ translations.GetString ("None of the other options"),
0),
- new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If your course is always honest and your course is always the best policy, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
+ new Predicate (String.Format (translations.GetString ("If your course is always honest and your course is always the best policy, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3)),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Honesty is sometimes the best policy"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Honesty is always the best policy"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Honesty is not always the best policy"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some of the best policies are dishonest"),
+ translations.GetString ("Honesty is sometimes the best policy"),
+ translations.GetString ("Honesty is always the best policy"),
+ translations.GetString ("Honesty is not always the best policy"),
+ translations.GetString ("Some of the best policies are dishonest"),
0),
- new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If no old misers are cheerful and some old misers are thin, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
+ new Predicate (String.Format (translations.GetString ("If no old misers are cheerful and some old misers are thin, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3)),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some thin people are not cheerful"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Thin people are not cheerful"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Cheerful people are not thin"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some cheerful people are not thin"),
+ translations.GetString ("Some thin people are not cheerful"),
+ translations.GetString ("Thin people are not cheerful"),
+ translations.GetString ("Cheerful people are not thin"),
+ translations.GetString ("Some cheerful people are not thin"),
0),
- new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If all pigs are fat and nothing that is fed on barley-water is fat, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
+ new Predicate (String.Format (translations.GetString ("If all pigs are fat and nothing that is fed on barley-water is fat, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3)),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All animals fed on barley-water are non pigs"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("No pigs are fed on barley-water"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Pigs are not fed on barley-water"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All the other options"),
+ translations.GetString ("All animals fed on barley-water are non pigs"),
+ translations.GetString ("No pigs are fed on barley-water"),
+ translations.GetString ("Pigs are not fed on barley-water"),
+ translations.GetString ("All the other options"),
3),
- new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If some pictures are first attempts and no first attempts are really good, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
+ new Predicate (String.Format (translations.GetString ("If some pictures are first attempts and no first attempts are really good, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3)),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some bad pictures are not first attempts"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some pictures are not really good"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All bad pictures are first attempts"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All the others"),
+ translations.GetString ("Some bad pictures are not first attempts"),
+ translations.GetString ("Some pictures are not really good"),
+ translations.GetString ("All bad pictures are first attempts"),
+ translations.GetString ("All the others"),
1),
- new Predicate (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If you have been out for a walk and you are feeling better, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
+ new Predicate (String.Format (translations.GetString ("If you have been out for a walk and you are feeling better, which of the following conclusions is correct? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3)),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("To feel better, you must go out for a walk"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("If you go out for a walk, you will feel better"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Some who go out for a walk feel better"),
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("No one feels better who does not go out for a walk"),
+ translations.GetString ("To feel better, you must go out for a walk"),
+ translations.GetString ("If you go out for a walk, you will feel better"),
+ translations.GetString ("Some who go out for a walk feel better"),
+ translations.GetString ("No one feels better who does not go out for a walk"),
2),
};
}
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Predicate Logic");}
+ get {return translations.GetString ("Predicate Logic");}
}
public override string Question {
@@ -182,7 +182,7 @@ namespace gbrainy.Games.Logic
int option = random_indices [data];
e.Context.SetPangoNormalFontSize ();
- e.Context.DrawStringWithWrapping (0.05, 0.02, String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}) {1}"), Answer.GetMultiOption (data),
+ e.Context.DrawStringWithWrapping (0.05, 0.02, String.Format (translations.GetString ("{0}) {1}"), Answer.GetMultiOption (data),
predicates[question].options[option].ToString ()), 0.8 - DrawAreaX);
e.Context.Stroke ();
};
@@ -195,7 +195,7 @@ namespace gbrainy.Games.Logic
gr.SetPangoLargeFontSize ();
gr.MoveTo (0.1, DrawAreaY);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
}
}
}
diff --git a/src/Games/Logic/PuzzleQuadrilaterals.cs b/src/Games/Logic/PuzzleQuadrilaterals.cs
index 20ccbf3..4637203 100644
--- a/src/Games/Logic/PuzzleQuadrilaterals.cs
+++ b/src/Games/Logic/PuzzleQuadrilaterals.cs
@@ -41,19 +41,19 @@ namespace gbrainy.Games.Logic
private const double figure_size = 0.15;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Quadrilaterals");}
+ get {return translations.GetString ("Quadrilaterals");}
}
public override string Question {
get {return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which of the following figures does not belong to the group? Answer {0}, {1}, {2}, {3}, {4} or {5}."),
+ translations.GetString ("Which of the following figures does not belong to the group? Answer {0}, {1}, {2}, {3}, {4} or {5}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3), Answer.GetMultiOption (4),
Answer.GetMultiOption (5));}
}
public override string Rationale {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("It is the only figure with all lines of equal length.");
+ return translations.GetString ("It is the only figure with all lines of equal length.");
}
}
diff --git a/src/Games/Logic/PuzzleRelatedNumbers.cs b/src/Games/Logic/PuzzleRelatedNumbers.cs
index 8aa5a79..c92e1a6 100644
--- a/src/Games/Logic/PuzzleRelatedNumbers.cs
+++ b/src/Games/Logic/PuzzleRelatedNumbers.cs
@@ -156,26 +156,26 @@ namespace gbrainy.Games.Logic
}
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Related numbers");}
+ get {return translations.GetString ("Related numbers");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("In the grid below, which number should replace the question mark?");}
+ get {return translations.GetString ("In the grid below, which number should replace the question mark?");}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The pattern is arithmetical and works horizontally."); }
+ get { return translations.GetString ("The pattern is arithmetical and works horizontally."); }
}
public override string Rationale {
get {
switch (operation) {
case Operation.AddHalf:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The number in the middle of every row is half of the sum of the other numbers in the row.");
+ return translations.GetString ("The number in the middle of every row is half of the sum of the other numbers in the row.");
case Operation.Add:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The number in the middle of every row is the sum of the other numbers in the row.");
+ return translations.GetString ("The number in the middle of every row is the sum of the other numbers in the row.");
case Operation.AddDouble:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The number in the middle of every row is the double of the sum of the other numbers in the row.");
+ return translations.GetString ("The number in the middle of every row is the double of the sum of the other numbers in the row.");
default:
throw new InvalidOperationException ("Invalid value");
}
diff --git a/src/Games/Logic/PuzzleSquareSheets.cs b/src/Games/Logic/PuzzleSquareSheets.cs
index 3c51f94..a7e7ec4 100644
--- a/src/Games/Logic/PuzzleSquareSheets.cs
+++ b/src/Games/Logic/PuzzleSquareSheets.cs
@@ -25,21 +25,21 @@ namespace gbrainy.Games.Logic
public class PuzzleSquareSheets : Game
{
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Square sheets");}
+ get {return translations.GetString ("Square sheets");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What is the minimum number of square sheets of paper of any size required to create the figure? Lines indicate frontiers between different sheets.");}
+ get {return translations.GetString ("What is the minimum number of square sheets of paper of any size required to create the figure? Lines indicate frontiers between different sheets.");}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The sheets should overlap.");}
+ get { return translations.GetString ("The sheets should overlap.");}
}
public override string Rationale {
get {
// Translators: the translated version should not take more characters that the English original
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("A full sized square of paper, a 3/4 of the whole size square of paper in the bottom right corner, another 3/4 square of paper in the top left corner and a 1/4 square of paper in the top left corner.");
+ return translations.GetString ("A full sized square of paper, a 3/4 of the whole size square of paper in the bottom right corner, another 3/4 square of paper in the top left corner and a 1/4 square of paper in the top left corner.");
}
}
diff --git a/src/Games/Logic/PuzzleSquares.cs b/src/Games/Logic/PuzzleSquares.cs
index c8bfe4d..ca8586e 100644
--- a/src/Games/Logic/PuzzleSquares.cs
+++ b/src/Games/Logic/PuzzleSquares.cs
@@ -28,24 +28,24 @@ namespace gbrainy.Games.Logic
private int type;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Squares");}
+ get {return translations.GetString ("Squares");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many squares of any size do you count in the figure below?");}
+ get {return translations.GetString ("How many squares of any size do you count in the figure below?");}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("A square is a rectangle with sides of equal length. A square can also be built from other squares.");}
+ get { return translations.GetString ("A square is a rectangle with sides of equal length. A square can also be built from other squares.");}
}
public override string Rationale {
get {
switch (type) {
case 0:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("There are 16 single squares, 9 squares made by 4 single squares, 4 squares made by 9 single squares and 1 square made by 16 single squares.");
+ return translations.GetString ("There are 16 single squares, 9 squares made by 4 single squares, 4 squares made by 9 single squares and 1 square made by 16 single squares.");
case 1:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("There are 9 single squares, 4 squares made by 4 single squares and 1 square made by 9 single squares.");
+ return translations.GetString ("There are 9 single squares, 4 squares made by 4 single squares and 1 square made by 9 single squares.");
default:
return string.Empty;
}
diff --git a/src/Games/Logic/PuzzleSquaresAndLetters.cs b/src/Games/Logic/PuzzleSquaresAndLetters.cs
index 97c5650..5fafcfa 100644
--- a/src/Games/Logic/PuzzleSquaresAndLetters.cs
+++ b/src/Games/Logic/PuzzleSquaresAndLetters.cs
@@ -32,16 +32,16 @@ namespace gbrainy.Games.Logic
private const int figures = 3;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Squares and letters");}
+ get {return translations.GetString ("Squares and letters");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The letters around the squares follow a pattern. Which letter should replace the question mark in the last square?");}
+ get {return translations.GetString ("The letters around the squares follow a pattern. Which letter should replace the question mark in the last square?");}
}
public override string Rationale {
get {
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Every letter is calculated by taking the alphabetical position of the previous character and adding {0} to it in order to get the position of the next letter."), step);
+ return String.Format (translations.GetString ("Every letter is calculated by taking the alphabetical position of the previous character and adding {0} to it in order to get the position of the next letter."), step);
}
}
diff --git a/src/Games/Logic/PuzzleTetris.cs b/src/Games/Logic/PuzzleTetris.cs
index 3822f28..969efac 100644
--- a/src/Games/Logic/PuzzleTetris.cs
+++ b/src/Games/Logic/PuzzleTetris.cs
@@ -32,18 +32,18 @@ namespace gbrainy.Games.Logic
private const double rect_witdh = 0.04, rect_height = 0.04, space_figures = 0.22;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Tetris");}
+ get {return translations.GetString ("Tetris");}
}
public override string Question {
get {return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What figure completes the set below? Answer {0}, {1} or {2}."),
+ translations.GetString ("What figure completes the set below? Answer {0}, {1} or {2}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2));}
}
public override string Rationale {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("It is the figure that completes all possible combinations with four blocks without taking into account rotations.");
+ return translations.GetString ("It is the figure that completes all possible combinations with four blocks without taking into account rotations.");
}
}
@@ -169,7 +169,7 @@ namespace gbrainy.Games.Logic
}
gr.MoveTo (0.1, 0.4 - 0.02);
- gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
+ gr.ShowPangoText (translations.GetString ("Choose one of the following:"));
}
}
}
diff --git a/src/Games/Logic/PuzzleTimeNow.cs b/src/Games/Logic/PuzzleTimeNow.cs
index 55594ec..ea4dbf3 100644
--- a/src/Games/Logic/PuzzleTimeNow.cs
+++ b/src/Games/Logic/PuzzleTimeNow.cs
@@ -31,7 +31,7 @@ namespace gbrainy.Games.Logic
DateTime position_a, position_b, ans, sample;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Time now");}
+ get {return translations.GetString ("Time now");}
}
public override string Question {
@@ -41,7 +41,7 @@ namespace gbrainy.Games.Logic
// http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.aspx
// For 12-hour clock format use {0:%h} and for 24-hour clock format use {0:%H}. The date formats {0:h} and {0:H} are invalid.
//
- ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString (
+ translations.GetPluralString (
"{0} hour ago it was as long after {1:h tt} as it was before {2:h tt} on the same day. What is the time now? Answer using the hour (e.g.: {3:h tt})",
"{0} hours ago it was as long after {1:h tt} as it was before {2:h tt} on the same day. What is the time now? Answer using the hour (e.g.: {3:h tt})",
after),
@@ -50,7 +50,7 @@ namespace gbrainy.Games.Logic
public override string Rationale {
get {
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString (
+ return String.Format (translations.GetPluralString (
"Determine the hour half way between the given times, and then add {0} hour to convert it to the present time.",
"Determine the hour half way between the given times, and then add {0} hours to convert it to the present time.",
after),
@@ -82,7 +82,7 @@ namespace gbrainy.Games.Logic
// Explanation of the date and time format specifications can be found here:
// http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.aspx
// For 12-hour clock format use {0:%h} and for 24-hour clock format use {0:%H}. The date formats {0:h} and {0:H} are invalid.
- Answer.Correct = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0:h tt}"), ans);
+ Answer.Correct = String.Format (translations.GetString ("{0:h tt}"), ans);
Answer.CheckAttributes = GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.IgnoreSpaces;
}
@@ -92,7 +92,7 @@ namespace gbrainy.Games.Logic
gr.DrawClock (DrawAreaX + 0.4, DrawAreaY + 0.4, figure_size,
0, 0 /* No hands */);
- gr.DrawTextCentered (0.5, DrawAreaY + 0.3 + figure_size, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Sample clock"));
+ gr.DrawTextCentered (0.5, DrawAreaY + 0.3 + figure_size, translations.GetString ("Sample clock"));
}
}
}
diff --git a/src/Games/Logic/PuzzleTrains.cs b/src/Games/Logic/PuzzleTrains.cs
index a8c5722..44dd154 100644
--- a/src/Games/Logic/PuzzleTrains.cs
+++ b/src/Games/Logic/PuzzleTrains.cs
@@ -38,7 +38,7 @@ namespace gbrainy.Games.Logic
GameType gametype;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Trains");}
+ get {return translations.GetString ("Trains");}
}
public override string Question {
@@ -50,7 +50,7 @@ namespace gbrainy.Games.Logic
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The distance formula is 'distance = rate x time'.");}
+ get { return translations.GetString ("The distance formula is 'distance = rate x time'.");}
}
protected override void Initialize ()
@@ -79,11 +79,11 @@ namespace gbrainy.Games.Logic
// Translators:
// - mph (miles per hour). You must localize this using the right unit of speed for your locale
/// - The translated string should not use more characters than the original sentence
- ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString ("A train leaves the station traveling at {0} mph. {1} hour later a second train leaves the station traveling in the same direction at {2} mph. How many hours since the first train left does it take the second train to overtake the first train?",
+ translations.GetPluralString ("A train leaves the station traveling at {0} mph. {1} hour later a second train leaves the station traveling in the same direction at {2} mph. How many hours since the first train left does it take the second train to overtake the first train?",
"A train leaves the station traveling at {0} mph. {1} hours later a second train leaves the station traveling in the same direction at {2} mph. How many hours since the first train left does it take the second train to overtake the first train?", (int) hours),
speed_a, hours, speed_b);
- answer = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You can calculate the answer by multiplying the speed of the first train by the time and dividing it by the difference of speeds.");
+ answer = translations.GetString ("You can calculate the answer by multiplying the speed of the first train by the time and dividing it by the difference of speeds.");
break;
}
case GameType.Meet:
@@ -99,12 +99,12 @@ namespace gbrainy.Games.Logic
question = String.Format (
// Translators:
// - mph (miles per hour) and miles must be localized this using the right unit of speed for your locale
- ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString ("Two trains separated by {0} mile are heading towards each other on straight parallel tracks. One travels at {1} mph and the other at {2} mph. In how many hours will they meet?",
+ translations.GetPluralString ("Two trains separated by {0} mile are heading towards each other on straight parallel tracks. One travels at {1} mph and the other at {2} mph. In how many hours will they meet?",
"Two trains separated by {0} miles are heading towards each other on straight parallel tracks. One travels at {1} mph and the other at {2} mph. In how many hours will they meet?",
(int) distance),
distance, speed_a, speed_b);
- answer = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You can calculate the answer by dividing the distance by the sum of both speeds.");
+ answer = translations.GetString ("You can calculate the answer by dividing the distance by the sum of both speeds.");
break;
}
case GameType.Apart:
@@ -121,12 +121,12 @@ namespace gbrainy.Games.Logic
question = String.Format (
// Translators:
// - mph (miles per hour) and miles must be localized this using the right unit of speed for your locale
- ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString ("Two trains on straight parallel tracks leave from the same point and time traveling in opposite directions at {0} and {1} mph respectively. In how many hours will they be {2} mile apart?",
+ translations.GetPluralString ("Two trains on straight parallel tracks leave from the same point and time traveling in opposite directions at {0} and {1} mph respectively. In how many hours will they be {2} mile apart?",
"Two trains on straight parallel tracks leave from the same point and time traveling in opposite directions at {0} and {1} mph respectively. In how many hours will they be {2} miles apart?",
(int) distance),
speed_a, speed_b, distance);
- answer = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("You can calculate the answer by dividing the distance by the sum of both speeds.");
+ answer = translations.GetString ("You can calculate the answer by dividing the distance by the sum of both speeds.");
break;
}
default:
diff --git a/src/Games/Logic/PuzzleTriangles.cs b/src/Games/Logic/PuzzleTriangles.cs
index 59bf08d..ffcf423 100644
--- a/src/Games/Logic/PuzzleTriangles.cs
+++ b/src/Games/Logic/PuzzleTriangles.cs
@@ -29,20 +29,20 @@ namespace gbrainy.Games.Logic
{
int type;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Triangles");}
+ get {return translations.GetString ("Triangles");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many triangles of any size do you count in the figure below?");}
+ get {return translations.GetString ("How many triangles of any size do you count in the figure below?");}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("A triangle can be embedded inside another triangle.");}
+ get { return translations.GetString ("A triangle can be embedded inside another triangle.");}
}
public override string Rationale {
get {
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The triangles are made by connecting the following points: {0}"),
+ return String.Format (translations.GetString ("The triangles are made by connecting the following points: {0}"),
(type == 0) ? "bdc, dcf, dfg, abd, ade, edg, acg, abg, bcg, afg, ecg, acd, acf, ace, adg, cdg." :
"dcf, ade, acg, afg, ecg, acd, acf, ace.");
}
diff --git a/src/Games/Logic/PuzzleTrianglesWithNumbers.cs b/src/Games/Logic/PuzzleTrianglesWithNumbers.cs
index a443940..09bf767 100644
--- a/src/Games/Logic/PuzzleTrianglesWithNumbers.cs
+++ b/src/Games/Logic/PuzzleTrianglesWithNumbers.cs
@@ -55,21 +55,21 @@ namespace gbrainy.Games.Logic
};
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Triangles with numbers");}
+ get {return translations.GetString ("Triangles with numbers");}
}
public override string Question {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which number should replace the question mark below?");}
+ get {return translations.GetString ("Which number should replace the question mark below?");}
}
public override string Tip {
- get { return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("All the triangles share a property and are independent of the rest.");}
+ get { return translations.GetString ("All the triangles share a property and are independent of the rest.");}
}
public override string Rationale {
get {
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The result of multiplying the two numbers inside every triangle is {0}."), answer_number);
+ return String.Format (translations.GetString ("The result of multiplying the two numbers inside every triangle is {0}."), answer_number);
}
}
diff --git a/src/Games/Memory/MemoryColouredFigures.cs b/src/Games/Memory/MemoryColouredFigures.cs
index dcfe6c5..6579396 100644
--- a/src/Games/Memory/MemoryColouredFigures.cs
+++ b/src/Games/Memory/MemoryColouredFigures.cs
@@ -48,7 +48,7 @@ namespace gbrainy.Games.Memory
private const double block_space = 0.35;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Colored figures");}
+ get {return translations.GetString ("Colored figures");}
}
public override bool UsesColors {
@@ -57,7 +57,7 @@ namespace gbrainy.Games.Memory
public override string MemoryQuestion {
get { return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which of these figures was previously shown? Answer {0}, {1}, {2} or {3}."),
+ translations.GetString ("Which of these figures was previously shown? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3));}
}
@@ -82,7 +82,7 @@ namespace gbrainy.Games.Memory
rect_h = 0.3 / columns;
squares_colours = new SquareColor [squares * answers];
color_sheme = random.Next (2);
- palette = new ColorPalette ();
+ palette = new ColorPalette (translations);
for (int i = 0; i < squares; i++)
squares_colours[i] = (SquareColor) random.Next ((int) SquareColor.Length);
diff --git a/src/Games/Memory/MemoryColouredText.cs b/src/Games/Memory/MemoryColouredText.cs
index b7d4a7c..b4b5dc0 100644
--- a/src/Games/Memory/MemoryColouredText.cs
+++ b/src/Games/Memory/MemoryColouredText.cs
@@ -33,7 +33,7 @@ namespace gbrainy.Games.Memory
private ArrayListIndicesRandom color_order;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Colored text");}
+ get {return translations.GetString ("Colored text");}
}
public override bool UsesColors {
@@ -42,7 +42,7 @@ namespace gbrainy.Games.Memory
public override string MemoryQuestion {
get {
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What was the color of the text that said '{0}'?"), question_colorname);}
+ return String.Format (translations.GetString ("What was the color of the text that said '{0}'?"), question_colorname);}
}
protected override void Initialize ()
@@ -61,7 +61,7 @@ namespace gbrainy.Games.Memory
break;
}
- palette = new ColorPalette ();
+ palette = new ColorPalette (translations);
// It is not acceptable that all the random colors names match the right colors
while (done == false) {
diff --git a/src/Games/Memory/MemoryCountDots.cs b/src/Games/Memory/MemoryCountDots.cs
index 465595d..bb45b24 100644
--- a/src/Games/Memory/MemoryCountDots.cs
+++ b/src/Games/Memory/MemoryCountDots.cs
@@ -38,7 +38,7 @@ namespace gbrainy.Games.Memory
private int [] dotsPerColor;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Counting dots");}
+ get {return translations.GetString ("Counting dots");}
}
public override bool UsesColors {
@@ -49,7 +49,7 @@ namespace gbrainy.Games.Memory
get {
return String.Format (
// Translators: {0} is the name of the color. The color name is always singular
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many dots of {0} color were in the previous image? Answer using numbers."),
+ translations.GetString ("How many dots of {0} color were in the previous image? Answer using numbers."),
palette.Name (0));
}
}
@@ -71,7 +71,7 @@ namespace gbrainy.Games.Memory
location_order = new ArrayListIndicesRandom (NUMCOLUMNS*NUMCOLUMNS);
location_order.Initialize();
- palette = new ColorPalette ();
+ palette = new ColorPalette (translations);
// dotsPerColor is compared with iterator of dots. (this iterator is 0 based, so I
// have to substract 1 to make dotsPerColor contents 0 based.
diff --git a/src/Games/Memory/MemoryFacts.cs b/src/Games/Memory/MemoryFacts.cs
index 5916ac7..67af4ad 100644
--- a/src/Games/Memory/MemoryFacts.cs
+++ b/src/Games/Memory/MemoryFacts.cs
@@ -46,7 +46,7 @@ namespace gbrainy.Games.Memory
}
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Memorize facts");}
+ get {return translations.GetString ("Memorize facts");}
}
public override string MemoryQuestion {
@@ -104,12 +104,12 @@ namespace gbrainy.Games.Memory
fact.fact = String.Format (
// Translators: {0} is replaced by a number, {1} by a year (like 1940)
// Day in English does not need to be plural
- ServiceLocator.Instance.GetService <ITranslations> ().GetPluralString ("Shiny Cars had already announced a {0} day production halt next month, but before then it had not halted production since {1}.",
+ translations.GetPluralString ("Shiny Cars had already announced a {0} day production halt next month, but before then it had not halted production since {1}.",
"Shiny Cars had already announced a {0} day production halt next month, but before then it had not halted production since {1}.",
fact.answers [0]),
fact.answers [0], fact.answers [1]);
- fact.questions [0] = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many days did Shiny Cars halt its production for?");
- fact.questions [1] = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("In what year did Shiny Cars last halt its production?");
+ fact.questions [0] = translations.GetString ("How many days did Shiny Cars halt its production for?");
+ fact.questions [1] = translations.GetString ("In what year did Shiny Cars last halt its production?");
break;
case 1:
fact.Initialize (2);
@@ -117,26 +117,26 @@ namespace gbrainy.Games.Memory
fact.answers [1] = 1914 + random.Next (50);
fact.fact = String.Format (
// Translators: {0} is replaced by a number, {1} by a year (like 1940)
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Shiny Cars sales fell {0}% this past December, the worst decline since {1}."),
+ translations.GetString ("Shiny Cars sales fell {0}% this past December, the worst decline since {1}."),
fact.answers [0], fact.answers [1]);
- fact.questions [0] = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("By how much did company sales fall last December?");
- fact.questions [1] = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("In what year was Shiny Cars sales total lower than that of last December?");
+ fact.questions [0] = translations.GetString ("By how much did company sales fall last December?");
+ fact.questions [1] = translations.GetString ("In what year was Shiny Cars sales total lower than that of last December?");
break;
case 2:
fact.Initialize (1);
fact.answers [0] = 10 + random.Next (30);
- fact.fact = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("About {0}% of Shiny Cars produced worldwide are sold in Europe."),
+ fact.fact = String.Format (translations.GetString ("About {0}% of Shiny Cars produced worldwide are sold in Europe."),
fact.answers [0]);
- fact.questions [0] = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What percentage of all Shiny Cars produced worldwide are sold in Europe?");
+ fact.questions [0] = translations.GetString ("What percentage of all Shiny Cars produced worldwide are sold in Europe?");
break;
case 3:
fact.Initialize (2);
fact.answers [0] = 10 + random.Next (30);
fact.answers [1] = 100 - (1 + random.Next (10)) - fact.answers [0];
- fact.fact = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("About {0}% of Shiny Cars use diesel, {1}% use gasoline and the remainder use electricity."),
+ fact.fact = String.Format (translations.GetString ("About {0}% of Shiny Cars use diesel, {1}% use gasoline and the remainder use electricity."),
fact.answers [0], fact.answers [1]);
- fact.questions [0] = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What percentage of Shiny Cars use diesel?");
- fact.questions [1] = ServiceLocator.Instance.GetService <ITranslations> ().GetString ("What percentage of Shiny Cars use gasoline?");
+ fact.questions [0] = translations.GetString ("What percentage of Shiny Cars use diesel?");
+ fact.questions [1] = translations.GetString ("What percentage of Shiny Cars use gasoline?");
break;
default:
throw new Exception ("Invalid index value");
diff --git a/src/Games/Memory/MemoryFigures.cs b/src/Games/Memory/MemoryFigures.cs
index 8c4bc1a..c146e52 100644
--- a/src/Games/Memory/MemoryFigures.cs
+++ b/src/Games/Memory/MemoryFigures.cs
@@ -52,12 +52,12 @@ namespace gbrainy.Games.Memory
}
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Memorize figures");}
+ get {return translations.GetString ("Memorize figures");}
}
public override string MemoryQuestion {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("In which cell is the other figure like the one shown below? Answer the cell number." );}
+ return translations.GetString ("In which cell is the other figure like the one shown below? Answer the cell number." );}
}
protected override void Initialize ()
diff --git a/src/Games/Memory/MemoryFiguresAndText.cs b/src/Games/Memory/MemoryFiguresAndText.cs
index 26f360d..badd381 100644
--- a/src/Games/Memory/MemoryFiguresAndText.cs
+++ b/src/Games/Memory/MemoryFiguresAndText.cs
@@ -45,28 +45,30 @@ namespace gbrainy.Games.Memory
internal const int Total = Circle + 1;
static internal string ToString (int type)
- {
+ {/*
switch (type) {
case Triangle:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Triangle");
+ return translations.GetString ("Triangle");
case Square:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Square");
+ return translations.GetString ("Square");
case Pentagon:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Pentagon");
+ return translations.GetString ("Pentagon");
case Circle:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Circle");
+ return translations.GetString ("Circle");
default:
throw new InvalidOperationException ();
}
+ */
+ return string.Empty;
}
}
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Memorize figures and text");}
+ get {return translations.GetString ("Memorize figures and text");}
}
public override string MemoryQuestion {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The list below enumerates the figures shown in the previous image except for one. Which is the missing figure? Possible answers are triangle, square, pentagon and circle." );}
+ get {return translations.GetString ("The list below enumerates the figures shown in the previous image except for one. Which is the missing figure? Possible answers are triangle, square, pentagon and circle." );}
}
protected override void Initialize ()
diff --git a/src/Games/Memory/MemoryFiguresNumbers.cs b/src/Games/Memory/MemoryFiguresNumbers.cs
index 8b2b264..0962b56 100644
--- a/src/Games/Memory/MemoryFiguresNumbers.cs
+++ b/src/Games/Memory/MemoryFiguresNumbers.cs
@@ -36,12 +36,12 @@ namespace gbrainy.Games.Memory
private const double block_space = 0.35;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Figures with numbers");}
+ get {return translations.GetString ("Figures with numbers");}
}
public override string MemoryQuestion {
get { return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which one of these squares was previously shown? Answer {0}, {1}, {2} or {3}."),
+ translations.GetString ("Which one of these squares was previously shown? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3));}
}
diff --git a/src/Games/Memory/MemoryIndications.cs b/src/Games/Memory/MemoryIndications.cs
index 6c79ae9..4d067f4 100644
--- a/src/Games/Memory/MemoryIndications.cs
+++ b/src/Games/Memory/MemoryIndications.cs
@@ -32,11 +32,13 @@ namespace gbrainy.Games.Memory
{
public Type type;
public object obj;
+ ITranslations translations;
- public Indication (Type type, object obj)
+ public Indication (ITranslations translations, Type type, object obj)
{
this.type = type;
this.obj = obj;
+ this.translations = translations;
}
public enum Type
@@ -127,22 +129,22 @@ namespace gbrainy.Games.Memory
{
switch (type) {
case Indication.Type.Start:
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Start at point number {0}"), (int) obj);
+ return String.Format (translations.GetString ("Start at point number {0}"), (int) obj);
case Indication.Type.Turn: {
switch ((TurnDirection) obj) {
case TurnDirection.Right:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Move right");
+ return translations.GetString ("Move right");
case TurnDirection.Left:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Move left");
+ return translations.GetString ("Move left");
case TurnDirection.Up:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Move up");
+ return translations.GetString ("Move up");
case TurnDirection.Down:
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Move down");
+ return translations.GetString ("Move down");
}
break;
}
case Indication.Type.End:
- return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("End at point {0}"), obj);
+ return String.Format (translations.GetString ("End at point {0}"), obj);
}
return null;
}
@@ -156,13 +158,13 @@ namespace gbrainy.Games.Memory
private int ans;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Memorize indications");}
+ get {return translations.GetString ("Memorize indications");}
}
public override string MemoryQuestion {
get {
return String.Format (
- ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Which of the following graphics represents the indications previously given? Answer {0}, {1}, {2} or {3}."),
+ translations.GetString ("Which of the following graphics represents the indications previously given? Answer {0}, {1}, {2} or {3}."),
Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3));}
}
@@ -171,23 +173,23 @@ namespace gbrainy.Games.Memory
indications = new Indication [CurrentDifficulty == GameDifficulty.Easy ? 5 : 7];
Indication.TurnDirection second_turn = (Indication.TurnDirection) 2 + random.Next (2);
- indications[0] = new Indication (Indication.Type.Start, 0);
- indications[1] = new Indication (Indication.Type.Turn, random.Next (2)); // right or left
- indications[2] = new Indication (Indication.Type.Turn, second_turn); // up or down
- indications[3] = new Indication (Indication.Type.Turn, random.Next (2)); // right or left
+ indications[0] = new Indication (translations, Indication.Type.Start, 0);
+ indications[1] = new Indication (translations, Indication.Type.Turn, random.Next (2)); // right or left
+ indications[2] = new Indication (translations, Indication.Type.Turn, second_turn); // up or down
+ indications[3] = new Indication (translations, Indication.Type.Turn, random.Next (2)); // right or left
Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;
if (CurrentDifficulty==GameDifficulty.Easy) {
- indications[4] = new Indication (Indication.Type.End, 1);
+ indications[4] = new Indication (translations, Indication.Type.End, 1);
} else {
if (second_turn == Indication.TurnDirection.Up)
- indications[4] = new Indication (Indication.Type.Turn, Indication.TurnDirection.Up);
+ indications[4] = new Indication (translations, Indication.Type.Turn, Indication.TurnDirection.Up);
else
- indications[4] = new Indication (Indication.Type.Turn, Indication.TurnDirection.Down);
+ indications[4] = new Indication (translations, Indication.Type.Turn, Indication.TurnDirection.Down);
- indications[5] = new Indication (Indication.Type.Turn, random.Next (2)); // right or left
- indications[6] = new Indication (Indication.Type.End, 1);
+ indications[5] = new Indication (translations, Indication.Type.Turn, random.Next (2)); // right or left
+ indications[6] = new Indication (translations, Indication.Type.End, 1);
}
indications_wrongA = CopyAnswer ();
@@ -195,33 +197,33 @@ namespace gbrainy.Games.Memory
indications_wrongC = CopyAnswer ();
if ((Indication.TurnDirection) indications[3].obj == Indication.TurnDirection.Right) {
- indications_wrongA[3] = new Indication (Indication.Type.Turn, Indication.TurnDirection.Left);
+ indications_wrongA[3] = new Indication (translations, Indication.Type.Turn, Indication.TurnDirection.Left);
}
else {
- indications_wrongA[3] = new Indication (Indication.Type.Turn, Indication.TurnDirection.Right);
+ indications_wrongA[3] = new Indication (translations, Indication.Type.Turn, Indication.TurnDirection.Right);
}
if (CurrentDifficulty == GameDifficulty.Easy) {
if ((Indication.TurnDirection) indications[2].obj == Indication.TurnDirection.Up) {
- indications_wrongB[2] = new Indication (Indication.Type.Turn, Indication.TurnDirection.Down);
+ indications_wrongB[2] = new Indication (translations, Indication.Type.Turn, Indication.TurnDirection.Down);
}
else {
- indications_wrongB[2] = new Indication (Indication.Type.Turn, Indication.TurnDirection.Up);
+ indications_wrongB[2] = new Indication (translations, Indication.Type.Turn, Indication.TurnDirection.Up);
}
} else {
if ((Indication.TurnDirection) indications[5].obj == Indication.TurnDirection.Right) {
- indications_wrongB[5] = new Indication (Indication.Type.Turn, Indication.TurnDirection.Left);
+ indications_wrongB[5] = new Indication (translations, Indication.Type.Turn, Indication.TurnDirection.Left);
}
else {
- indications_wrongB[5] = new Indication (Indication.Type.Turn, Indication.TurnDirection.Right);
+ indications_wrongB[5] = new Indication (translations, Indication.Type.Turn, Indication.TurnDirection.Right);
}
}
if ((Indication.TurnDirection) indications[1].obj == Indication.TurnDirection.Right) {
- indications_wrongC[1] = new Indication (Indication.Type.Turn, Indication.TurnDirection.Left);
+ indications_wrongC[1] = new Indication (translations, Indication.Type.Turn, Indication.TurnDirection.Left);
}
else {
- indications_wrongC[1] = new Indication (Indication.Type.Turn, Indication.TurnDirection.Right);
+ indications_wrongC[1] = new Indication (translations, Indication.Type.Turn, Indication.TurnDirection.Right);
}
base.Initialize ();
@@ -284,7 +286,7 @@ namespace gbrainy.Games.Memory
{
Indication[] answer = new Indication [indications.Length];
for (int i = 0; i < indications.Length; i++)
- answer[i] = new Indication (indications[i].type, indications[i].obj);
+ answer[i] = new Indication (translations, indications[i].type, indications[i].obj);
return answer;
}
diff --git a/src/Games/Memory/MemoryNumbers.cs b/src/Games/Memory/MemoryNumbers.cs
index 0eaa4dc..9f22be2 100644
--- a/src/Games/Memory/MemoryNumbers.cs
+++ b/src/Games/Memory/MemoryNumbers.cs
@@ -32,8 +32,12 @@ namespace gbrainy.Games.Memory
class Challenge
{
protected static int [] numbers;
+ protected ITranslations translations;
- public Challenge () {}
+ public Challenge (ITranslations translations)
+ {
+ this.translations = translations;
+ }
public static int[] Numbers {
set { numbers = value;}
@@ -51,9 +55,14 @@ namespace gbrainy.Games.Memory
class ChallengeOdds : Challenge
{
+ public ChallengeOdds (ITranslations translations) : base (translations)
+ {
+
+ }
+
public override string Question {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many odd numbers were in the previous image? Answer using numbers.");
+ return translations.GetString ("How many odd numbers were in the previous image? Answer using numbers.");
}
}
@@ -71,9 +80,14 @@ namespace gbrainy.Games.Memory
class ChallengeEvens : Challenge
{
+ public ChallengeEvens (ITranslations translations) : base (translations)
+ {
+
+ }
+
public override string Question {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many even numbers were in the previous image? Answer using numbers.");
+ return translations.GetString ("How many even numbers were in the previous image? Answer using numbers.");
}
}
@@ -91,9 +105,14 @@ namespace gbrainy.Games.Memory
class ChallengeTwoDigits : Challenge
{
+ public ChallengeTwoDigits (ITranslations translations) : base (translations)
+ {
+
+ }
+
public override string Question {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("How many numbers with more than one digit were in the previous image? Answer using numbers.");
+ return translations.GetString ("How many numbers with more than one digit were in the previous image? Answer using numbers.");
}
}
@@ -110,7 +129,7 @@ namespace gbrainy.Games.Memory
}
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Memorize numbers");}
+ get {return translations.GetString ("Memorize numbers");}
}
public override string MemoryQuestion {
@@ -144,13 +163,13 @@ namespace gbrainy.Games.Memory
switch (random.Next (num_games)) {
case 0:
- current_game = new ChallengeOdds ();
+ current_game = new ChallengeOdds (translations);
break;
case 1:
- current_game = new ChallengeEvens ();
+ current_game = new ChallengeEvens (translations);
break;
case 2:
- current_game = new ChallengeTwoDigits ();
+ current_game = new ChallengeTwoDigits (translations);
break;
}
diff --git a/src/Games/Memory/MemoryWords.cs b/src/Games/Memory/MemoryWords.cs
index 179f73f..254a7fb 100644
--- a/src/Games/Memory/MemoryWords.cs
+++ b/src/Games/Memory/MemoryWords.cs
@@ -34,12 +34,12 @@ namespace gbrainy.Games.Memory
private int answer;
public override string Name {
- get {return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Memorize words");}
+ get {return translations.GetString ("Memorize words");}
}
public override string MemoryQuestion {
get {
- return ServiceLocator.Instance.GetService <ITranslations> ().GetString ("There is a missing word from the previous list. Which one is the missing word?");}
+ return translations.GetString ("There is a missing word from the previous list. Which one is the missing word?");}
}
protected override void Initialize ()
@@ -48,53 +48,53 @@ namespace gbrainy.Games.Memory
words = new List <string> (total_words);
// Body parts
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("wrist"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("elbow"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("armpit"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("hand"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("chest"));
+ words.Add (translations.GetString ("wrist"));
+ words.Add (translations.GetString ("elbow"));
+ words.Add (translations.GetString ("armpit"));
+ words.Add (translations.GetString ("hand"));
+ words.Add (translations.GetString ("chest"));
//Fishes
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("sardine"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("trout"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("monkfish"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("cod"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("salmon"));
+ words.Add (translations.GetString ("sardine"));
+ words.Add (translations.GetString ("trout"));
+ words.Add (translations.GetString ("monkfish"));
+ words.Add (translations.GetString ("cod"));
+ words.Add (translations.GetString ("salmon"));
// Vegetables
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("potato"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("ginger"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("pepper"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("garlic"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("pumpkin"));
+ words.Add (translations.GetString ("potato"));
+ words.Add (translations.GetString ("ginger"));
+ words.Add (translations.GetString ("pepper"));
+ words.Add (translations.GetString ("garlic"));
+ words.Add (translations.GetString ("pumpkin"));
// Bicycle
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("brake"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("pedal"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("chain"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("wheel"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("handlebar"));
+ words.Add (translations.GetString ("brake"));
+ words.Add (translations.GetString ("pedal"));
+ words.Add (translations.GetString ("chain"));
+ words.Add (translations.GetString ("wheel"));
+ words.Add (translations.GetString ("handlebar"));
// Music
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("drummer"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("speaker"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("lyrics"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("beat"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("song"));
+ words.Add (translations.GetString ("drummer"));
+ words.Add (translations.GetString ("speaker"));
+ words.Add (translations.GetString ("lyrics"));
+ words.Add (translations.GetString ("beat"));
+ words.Add (translations.GetString ("song"));
// Weather
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("cloud"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("rain"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("storm"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("fog"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("rainbow"));
+ words.Add (translations.GetString ("cloud"));
+ words.Add (translations.GetString ("rain"));
+ words.Add (translations.GetString ("storm"));
+ words.Add (translations.GetString ("fog"));
+ words.Add (translations.GetString ("rainbow"));
// Animals
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("rabbit"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("mouse"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("monkey"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("bear"));
- words.Add (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("wolf"));
+ words.Add (translations.GetString ("rabbit"));
+ words.Add (translations.GetString ("mouse"));
+ words.Add (translations.GetString ("monkey"));
+ words.Add (translations.GetString ("bear"));
+ words.Add (translations.GetString ("wolf"));
switch (CurrentDifficulty) {
case GameDifficulty.Easy:
diff --git a/tests/Clients/Classical/CommandLineTest.cs b/tests/Clients/Classical/CommandLineTest.cs
index 39593aa..aad4576 100644
--- a/tests/Clients/Classical/CommandLineTest.cs
+++ b/tests/Clients/Classical/CommandLineTest.cs
@@ -23,16 +23,21 @@ using NUnit.Framework;
using gbrainy.Clients.Classical;
using gbrainy.Core.Main;
+using gbrainy.Core.Services;
+using gbrainy.Core.Libraries;
namespace gbrainy.Test.Clients.Classical
{
[TestFixture]
public class CommandLineTest : UnitTestSupport
{
+ ITranslations translations;
+
[TestFixtureSetUp]
public void Construct ()
{
RegisterDefaultServices ();
+ translations = new TranslationsCatalog ();
}
[Test]
@@ -44,7 +49,7 @@ namespace gbrainy.Test.Clients.Classical
args = new string [1];
args [0] = "--norandom";
- line = new CommandLine (args);
+ line = new CommandLine (translations, args);
Assert.AreEqual (true, line.RandomOrder);
line.Parse ();
@@ -72,6 +77,7 @@ namespace gbrainy.Test.Clients.Classical
continue;
Game game = (Game) Activator.CreateInstance (games[i].TypeOf, true);
+ game.translations = translations;
game.Variant = games[i].Variant;
if (cand_idx > 0)
@@ -88,7 +94,7 @@ namespace gbrainy.Test.Clients.Classical
args [0] = "--customgame";
args [1] = game_list.ToString ();
- line = new CommandLine (args);
+ line = new CommandLine (translations, args);
line.Parse ();
Assert.AreEqual (cand_idx, line.PlayList.Length);
diff --git a/tests/Clients/Classical/gbrainyTest.cs b/tests/Clients/Classical/gbrainyTest.cs
index ce93279..703ec89 100644
--- a/tests/Clients/Classical/gbrainyTest.cs
+++ b/tests/Clients/Classical/gbrainyTest.cs
@@ -34,6 +34,7 @@ namespace gbrainy.Test.Clients.Classical
public class TranslationsTest : ITranslations
{
+ public string Language { set; get; }
public int Percentage { set; get; }
public int TranslationPercentage {
get { return Percentage; }
@@ -55,7 +56,7 @@ namespace gbrainy.Test.Clients.Classical
[Test]
public void ShowTranslationMessageHonorPercentage ()
{
- GtkClient client = new GtkClient ();
+ GtkClient client = new GtkClient (translations);
Preferences.ConfigPath = ".";
Preferences.Clear ();
@@ -66,7 +67,7 @@ namespace gbrainy.Test.Clients.Classical
[Test]
public void ShowTranslationMessageOnlyOnce ()
{
- GtkClient client = new GtkClient ();
+ GtkClient client = new GtkClient (translations);
Preferences.ConfigPath = ".";
Preferences.Clear ();
@@ -78,7 +79,7 @@ namespace gbrainy.Test.Clients.Classical
[Test]
public void ShowTranslationMessageWhenChangingVersion ()
{
- GtkClient client = new GtkClient ();
+ GtkClient client = new GtkClient (translations);
Preferences.ConfigPath = ".";
Preferences.Clear ();
diff --git a/tests/Core/GameAnswerTest.cs b/tests/Core/GameAnswerTest.cs
index 6a6874b..94274d2 100644
--- a/tests/Core/GameAnswerTest.cs
+++ b/tests/Core/GameAnswerTest.cs
@@ -37,7 +37,7 @@ namespace gbrainy.Test.Core
[Test]
public void Trim ()
{
- GameAnswer answer = new GameAnswer ();
+ GameAnswer answer = new GameAnswer (null);
answer.CheckAttributes = GameAnswerCheckAttributes.None;
answer.Correct = "icon";
@@ -60,7 +60,7 @@ namespace gbrainy.Test.Core
[Test]
public void IgnoreCase ()
{
- GameAnswer answer = new GameAnswer ();
+ GameAnswer answer = new GameAnswer (null);
answer.CheckAttributes = GameAnswerCheckAttributes.None;
answer.Correct = "icon";
@@ -83,7 +83,7 @@ namespace gbrainy.Test.Core
[Test]
public void IgnoreSpaces ()
{
- GameAnswer answer = new GameAnswer ();
+ GameAnswer answer = new GameAnswer (null);
answer.CheckAttributes = GameAnswerCheckAttributes.None;
answer.Correct = "10 pm";
@@ -106,7 +106,7 @@ namespace gbrainy.Test.Core
[Test]
public void MatchAllInOder ()
{
- GameAnswer answer = new GameAnswer ();
+ GameAnswer answer = new GameAnswer (null);
answer.CheckAttributes = GameAnswerCheckAttributes.MatchAllInOrder;
answer.CheckExpression = "[0-9]+";
@@ -119,7 +119,7 @@ namespace gbrainy.Test.Core
[Test]
public void MatchAll ()
{
- GameAnswer answer = new GameAnswer ();
+ GameAnswer answer = new GameAnswer (null);
answer.CheckAttributes = GameAnswerCheckAttributes.MatchAll;
answer.CheckExpression = "[0-9]+";
@@ -133,7 +133,7 @@ namespace gbrainy.Test.Core
[Test]
public void DefaultAnswer ()
{
- GameAnswer answer = new GameAnswer ();
+ GameAnswer answer = new GameAnswer (null);
answer.Correct = "icon";
Assert.AreEqual (true, answer.CheckAnswer ("icon"));
@@ -145,7 +145,7 @@ namespace gbrainy.Test.Core
[Test]
public void DefaultAnswerOptions ()
{
- GameAnswer answer = new GameAnswer ();
+ GameAnswer answer = new GameAnswer (null);
answer.Correct = "option1 | option2";
Assert.AreEqual (true, answer.CheckAnswer ("option1"));
@@ -158,7 +158,7 @@ namespace gbrainy.Test.Core
[Test]
public void CheckPuzzleTimeNowAnswer ()
{
- GameAnswer answer = new GameAnswer ();
+ GameAnswer answer = new GameAnswer (null);
answer.Correct = "10 PM";
answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.IgnoreCase | GameAnswerCheckAttributes.IgnoreSpaces;
@@ -175,7 +175,7 @@ namespace gbrainy.Test.Core
[Test]
public void CheckCalculationOperator ()
{
- GameAnswer answer = new GameAnswer ();
+ GameAnswer answer = new GameAnswer (null);
answer.Correct = "+ | -";
answer.CheckExpression = "[+*-/]";
answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAllInOrder;
@@ -191,7 +191,7 @@ namespace gbrainy.Test.Core
[Test]
public void CheckPuzzleBuildTriangle ()
{
- GameAnswer answer = new GameAnswer ();
+ GameAnswer answer = new GameAnswer (null);
answer.Correct = "A | B | C";
answer.CheckExpression = "[ABCDF]";
@@ -213,7 +213,7 @@ namespace gbrainy.Test.Core
[Test]
public void CheckPuzzlePercentage ()
{
- GameAnswer answer = new GameAnswer ();
+ GameAnswer answer = new GameAnswer (null);
answer.Correct = "10";
answer.CheckExpression = "[0-9]+";
@@ -231,7 +231,7 @@ namespace gbrainy.Test.Core
[Test]
public void TwoNumbersAnswer ()
{
- GameAnswer answer = new GameAnswer ();
+ GameAnswer answer = new GameAnswer (null);
answer.Correct = "10 | 20";
answer.CheckExpression = "[0-9]+";
answer.CheckAttributes = GameAnswerCheckAttributes.Trim | GameAnswerCheckAttributes.MatchAll;
diff --git a/tests/Core/GameSessionTest.cs b/tests/Core/GameSessionTest.cs
index e1fe8a7..5c7cc81 100644
--- a/tests/Core/GameSessionTest.cs
+++ b/tests/Core/GameSessionTest.cs
@@ -36,7 +36,7 @@ namespace gbrainy.Test.Core
GameSession PrepareSession ()
{
- GameSession session = new GameSession ();
+ GameSession session = new GameSession (null);
session.GameManager.LoadAssemblyGames ("gbrainy.Games.dll");
session.GameManager.LoadPlugins ();
session.GameManager.LoadGamesFromXml (System.IO.Path.Combine (gbrainy.Core.Main.Defines.DATA_DIR, "games.xml"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]