public CustomGameDialog(ITranslations translations, GameSession session) : base(translations, "CustomGameDialog.ui", "customgame") { Game game; selection_done = false; this.session = session; games = session.GameManager.AvailableGames; drawing_area = new GameDrawingArea (); drawing_area.UseSolutionArea = false; drawing_area.SetSizeRequest (preview_vbox.WidthRequest, preview_vbox.HeightRequest); preview_vbox.Add (drawing_area); drawing_area.Visible = true; treeview.HeadersClickable = true; CreateColumnName (); CreateColumnType (); CreateColumnSelected (); LoadGames (); treeview.Model = games_store; game = (Game) Activator.CreateInstance (games [0].TypeOf, true); game.Translations = Translations; game.Variant = 0; game.Begin (); drawing_area.Drawable = game; drawing_area.Question = game.Question; treeview.ColumnsAutosize (); }
public FinishView(ITranslations translations, GameSession session) { Translations = translations; this.session = session; tips = new List <string> (); cached_sessionid = -1; game_tips = new GameTips (translations); }
public FinishView(GameSession session) { this.session = session; tips = new List <string> (); cached_sessionid = -1; }
private void Page_Load(Object sender, EventArgs e) { // If the Language has not been set the user has a expired // session or does not come from the main page if (String.IsNullOrEmpty (WebSession.LanguageCode)) { Response.Redirect ("/"); return; } if (IsPostBack == false) InitPage (); Logger.Debug ("Game.Page_Load. Page load starts. Session ID {0}, IsPostBack {1}", Session.SessionID, IsPostBack); 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) { ProcessAnswer (answer); } if (WebSession.GameState == null) { Logger.Debug ("Game.Page_Load creating new session"); 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 | gbrainy.Core.Main.GameSession.Types.Calculation | gbrainy.Core.Main.GameSession.Types.VerbalAnalogies; session.New (); WebSession.GameState = session; Global.TotalGamesSessions++; _game = GetNextGame (); UpdateGame (); // If the first time that loads this does not have a session // send the user to the home page //Logger.Debug ("New Session, redirecting to Default.aspx"); //Response.Redirect ("Default.aspx"); } else if (WebSession.GameState != null && WebSession.GameState.Status == GameSession.SessionStatus.Finished) { // Finished game image = new GameImage (null); game_image.ImageUrl = CreateImage (WebSession); answer_button.Enabled = false; answer_textbox.Text = string.Empty; answer_textbox.Enabled = false; nextgame_link.Enabled = false; endgames_button.Enabled = false; UpdateGame (); } else { session = WebSession.GameState; if (_game == null) _game = WebSession.GameState.CurrentGame; UpdateGame (); } if (IsPostBack == false) SetText (); if (IsPostBack == true) { Logger.Debug ("Game.Page_Load. Ignoring postback"); return; } Logger.Debug ("Game.Page_Load. Page load completed"); }
void OnNewGame(GameSession.Types type) { // If the translation is lower than MIN_TRANSLATION explain that running the English version is an option if (ShowTranslationWarning ()) Translations (); session.Type = type; session.New (); GetNextGame (); GameSensitiveUI (); UpdateSolution (Catalog.GetString ("Once you have an answer type it in the \"Answer:\" entry box and press the \"OK\" button."), GameDrawingArea.SolutionType.Tip); UpdateStatusBar (); }
public void Initialize() { session = new GameSession (); GameManagerPreload (session.GameManager); Console.WriteLine (session.GameManager.GetGamesSummary ()); session.GameManager.ColorBlind = Preferences.Get <bool> (Preferences.ColorBlindKey); session.DrawRequest += SessionDrawRequest; session.UpdateUIElement += SessionUpdateUIElement; session.SynchronizingObject = new GtkSynchronize (); session.Difficulty = (GameDifficulty) Preferences.Get <int> (Preferences.DifficultyKey); BuildUI (); }
private void Page_Load(Object sender, EventArgs e) { // If the Language has not been set the user has a expired // session or does not come from the main page if (String.IsNullOrEmpty(WebSession.LanguageCode)) { Response.Redirect("/"); return; } if (IsPostBack == false) { InitPage(); } Logger.Debug("Game.Page_Load. Page load starts. Session ID {0}, IsPostBack {1}", Session.SessionID, IsPostBack); 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) { ProcessAnswer(answer); } if (WebSession.GameState == null) { Logger.Debug("Game.Page_Load creating new session"); 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 | gbrainy.Core.Main.GameSession.Types.Calculation | gbrainy.Core.Main.GameSession.Types.VerbalAnalogies; session.New(); WebSession.GameState = session; Global.TotalGamesSessions++; _game = GetNextGame(); UpdateGame(); // If the first time that loads this does not have a session // send the user to the home page //Logger.Debug ("New Session, redirecting to Default.aspx"); //Response.Redirect ("Default.aspx"); } else if (WebSession.GameState != null && WebSession.GameState.Status == GameSession.SessionStatus.Finished) { // Finished game image = new GameImage(null); game_image.ImageUrl = CreateImage(WebSession); answer_button.Enabled = false; answer_textbox.Text = string.Empty; answer_textbox.Enabled = false; nextgame_link.Enabled = false; endgames_button.Enabled = false; UpdateGame(); } else { session = WebSession.GameState; if (_game == null) { _game = WebSession.GameState.CurrentGame; } UpdateGame(); } if (IsPostBack == false) { SetText(); } if (IsPostBack == true) { Logger.Debug("Game.Page_Load. Ignoring postback"); return; } Logger.Debug("Game.Page_Load. Page load completed"); }
void GeneratePdf(GameSession.Types types, int num_games, int gamespage, GameDifficulty difficulty, bool colorblind, string filename) { Game [] games; GameSession session; string msg; MessageType msg_type; games = new Game [num_games]; session = new GameSession (Translations); session.GameManager = manager; session.PlayList.ColorBlind = colorblind; session.PlayList.Difficulty = difficulty; session.PlayList.GameType = types; for (int n = 0; n < num_games; n++) { games [n] = session.PlayList.GetPuzzle (); games [n].Translations = Translations; } if (pdfExporter.GeneratePdf (games, gamespage, filename) == true) { msg = Catalog.GetString ("The PDF file has been exported correctly."); msg_type = MessageType.Info; } else { msg = Catalog.GetString ("There was a problem generating the PDF file. The file has not been created."); msg_type = MessageType.Error; } // Notify operation result MessageDialog md = new MessageDialog (this, DialogFlags.Modal, msg_type, ButtonsType.Ok, msg); md.Run (); md.Destroy (); }
GameSession PrepareSession() { ITranslations translations = new TranslationsCatalog (); GameSession session = new GameSession (translations); session.GameManager.LoadAssemblyGames ("gbrainy.Games.dll"); return session; }
public ViewsControler(GameSession session) { welcome = new WelcomeView (); finish = new FinishView (session); }