public void TestSave() { GameSaver saver = new GameSaver(); GameImpl myGame = new GameImpl(); saver.Save(myGame); Assert.IsTrue(saver.IsSavingPresent()); Assert.AreNotEqual(saver.Load(), new GameImpl()); Assert.AreEqual(myGame, saver.Load()); }
protected override void OnStartup(StartupEventArgs e) { SettingsSaver.Load(); // Load the settings Global.ChangeLanguage(); // Change the language Definitions.GameInfoPage = new(); // Create the page Definitions.GameInfoPage2 = new(); // Create the page ProfileManager.LoadProfiles(); // Load profiles GameSaver.Load(); // Load the .gav file in the Definitions class Definitions.StatGameInfoControl = new(); // New control Definitions.Statistics = new(); // New page Definitions.HomePage = new(); RecentGamesPage recentGamesPage = new(); // RecentGamesPage Definitions.RecentGamesPage = recentGamesPage; // Define the RecentGamesPage Definitions.RecentGamesPage.LoadGames(); // Load the games GamesListPage gamesListPage = new(); // GamesListPage Definitions.GamesListPage = gamesListPage; // Define the GamesListPage Definitions.GamesListPage.LoadGames(); // Load the games Definitions.LibraryPage = new(); Definitions.ProfilePage = new(); if (Definitions.Settings.DefaultGavilyaHomePage is null) { Definitions.Settings.DefaultGavilyaHomePage = Enums.GavilyaWindowPages.Home; // Set default value SettingsSaver.Save(); // Save changes } if (Definitions.Settings.IsFirstRun) // If it is the app first run { new FirstRun().Show(); // Show the first run experience } else { int?pageID = (e.Args.Length >= 2 && e.Args[0] == "/page") ? int.Parse(e.Args[1]) : null; new MainWindow(pageID == null ? null : (Enums.GavilyaWindowPages)pageID).Show(); // Show the regular main window Global.CreateJumpLists(); } }
public void OnGet() { // Get action param if (!Request.Query.TryGetValue("action", out var action)) { return; } // Get id param if (!Request.Query.TryGetValue("id", out var id)) { return; } Action = action.ToString().ToLower().Trim(); Id = id.ToString().ToLower().Trim(); // Check params if (string.IsNullOrEmpty(Action) || string.IsNullOrEmpty(id) || !int.TryParse(id, out _)) { return; } if (Action.Equals("delete")) { GameSaver.Delete(int.Parse(Id)); IsStatus = true; StatusMsg = "Game deleted!"; BackBtnHref = "List"; } else if (Action.Equals("load")) { // Load game from database into active static context GameSaver.Load(int.Parse(Id)); ActiveGame.CyclePlayers(); IsStatus = true; StatusMsg = "Game loaded!"; OkBtnText = "Start game"; BackBtnHref = "Play"; } }
public override void Init() { GameObjects.Add( new ButtonObject(new Text("Перейти к сцене", Cache.GetFont("fonts/arial"), 15), new Style()) { LeftClickHandler = () => { Game.Scene = Find("Test"); }, Position = new Vector2f(500, 500) }); GameObjects.Add( new ButtonObject(new Text("Загрузить сцену", Cache.GetFont("fonts/arial"), 15), new Style()) { LeftClickHandler = () => { GameSaver.Load("test.save"); }, Position = new Vector2f(500, 800) }); }
void Continue() { gameSaver.Load(); SceneManager.LoadScene("Lab"); }