public void SaveGame(string filename) { GameData.Guid = string.Empty; string gameXml = GetGameXml(); if (gameXml != "") { Ap.LoadDatabase(filename); Ap.Database.AppendGame(gameXml); Ap.Database.Save(); } }
public bool LoadGame(string guid) { if (!Ap.LoadDatabase(Ap.Options.CurrentGameDatabaseFilePath)) { return(false); } GameItem gameItem = Ap.Database.GameItems.GetGameByGuid(guid); if (gameItem == null) { return(false); } if (BeforeLoadGame != null) { BeforeLoadGame(this, EventArgs.Empty); } NewGame(GameData.InitialBoardFen, MapGameMode(GameData.GameMode), GameData.GameType, new OptionsBlitzClock(GameData.OptionsBlitzClock), new OptionsLongClock(GameData.OptionsLongClock)); GameData = gameItem.GameData; Ap.Options.CurrentGameGuid = guid; Ap.Options.CurrentGameDatabaseFilePath = Ap.Options.CurrentDatabaseFilePath; Ap.Options.Save(); Flags.Flags = gameItem.GameData.Flags; Flags.IsDatabaseGame = true; Paste(gameItem.Moves); if (GameData.Result != string.Empty) { Finish(gameItem.GameData.GameResult); } if (AfterLoadGame != null) { AfterLoadGame(this, EventArgs.Empty); } Flags.IsDatabaseGame = false; return(true); }
private void DoAutoSaveGame() { try { string storeCurrentGameGuid = string.Empty; string path = ""; path = AutoSaveFilePath; Ap.LoadDatabase(path); storeCurrentGameGuid = GameData.Guid; if (Ap.Options.CurrentGameGuid != string.Empty && GameMode != GameMode.Kibitzer) { GameItem gameItem = Ap.Database.GameItems.GetGameByGuid(Ap.Options.CurrentGameGuid); int currentGameIndex = Ap.Database.GameItems.GetCurrentGameIndex(); GameData.Guid = Ap.Options.CurrentGameGuid; string updatedGameXml = GetGameXml(); Ap.Database.UpdateGame(updatedGameXml, currentGameIndex); Ap.Database.Save(); } else { GameData.Guid = string.Empty; string gameXml = GetGameXml(); Ap.Database.AppendGame(gameXml); Ap.Options.CurrentGameGuid = GameData.Guid; Ap.Options.CurrentGameDatabaseFilePath = path; Ap.Options.Save(); } GameData.Guid = storeCurrentGameGuid; } catch { } }
public void SaveEmptyGame(string filename) { Ap.LoadDatabase(filename); }