public string GetSelectedRecentGamePath() { int index = lstRecentGames.SelectedItems[0].Index; RecentGame game = Factory.AGSEditor.Settings.RecentGames[index]; return(game.Path); }
public bool LoadGameFromDisk(string gameToLoad, bool interactive) { bool needToSave = false; string gameDirectory = Path.GetDirectoryName(gameToLoad); if (Path.GetFileName(gameDirectory).Length > MAX_GAME_FOLDER_NAME_LENGTH) { throw new AGSEditorException("This game cannot be loaded because it is in a folder that has a name longer than 40 characters."); } List <string> errors = new List <string>(); Directory.SetCurrentDirectory(gameDirectory); Factory.NativeProxy.NewWorkingDirSet(gameDirectory); AddFontIfNotAlreadyThere(0); AddFontIfNotAlreadyThere(1); AddFontIfNotAlreadyThere(2); Game game = null; if (gameToLoad.ToLower().EndsWith(".dta")) { game = new OldGameImporter().ImportGameFromAGS272(gameToLoad, interactive); needToSave = true; } else { Factory.AGSEditor.LoadGameFile(gameToLoad); Factory.NativeProxy.LoadNewSpriteFile(); game = Factory.AGSEditor.CurrentGame; } if (game != null) { game.DirectoryPath = gameDirectory; SetDefaultValuesForNewFeatures(game); Utilities.EnsureStandardSubFoldersExist(); RecentGame recentGame = new RecentGame(game.Settings.GameName, gameDirectory); if (Factory.AGSEditor.Settings.RecentGames.Contains(recentGame)) { Factory.AGSEditor.Settings.RecentGames.Remove(recentGame); } Factory.AGSEditor.Settings.RecentGames.Insert(0, recentGame); Factory.Events.OnGamePostLoad(); Factory.AGSEditor.RefreshEditorAfterGameLoad(game, errors); if (needToSave) { Factory.AGSEditor.SaveGameFiles(); } Factory.AGSEditor.ReportGameLoad(errors); return(true); } return(false); }
public bool LoadGameFromDisk(string gameToLoad, bool interactive) { bool needToSave = false; string gameDirectory = Path.GetDirectoryName(gameToLoad); if (Path.GetFileName(gameDirectory).Length > MAX_GAME_FOLDER_NAME_LENGTH) { throw new AGSEditorException("This game cannot be loaded because it is in a folder that has a name longer than 40 characters."); } List <string> errors = new List <string>(); Directory.SetCurrentDirectory(gameDirectory); Factory.NativeProxy.NewWorkingDirSet(gameDirectory); AddFontIfNotAlreadyThere(0); AddFontIfNotAlreadyThere(1); AddFontIfNotAlreadyThere(2); Game game = null; // Load or import the game itself if (gameToLoad.ToLower().EndsWith(".dta")) { game = new OldGameImporter().ImportGameFromAGS272(gameToLoad, interactive); needToSave = true; } else { Factory.AGSEditor.LoadGameFile(gameToLoad); game = Factory.AGSEditor.CurrentGame; } if (game == null) { return(false); } game.DirectoryPath = gameDirectory; SetDefaultValuesForNewFeatures(game); Utilities.EnsureStandardSubFoldersExist(); // Load the sprite file bool isNewSpriteFile = false; if (!File.Exists(Path.Combine(game.DirectoryPath, AGSEditor.SPRITE_FILE_NAME))) { if (Factory.GUIController.ShowQuestion(string.Format("Spriteset file ({0}) was not found. Would you like to try reimport sprites from their sources? Otherwise, we'll generate an empty spritefile.\nNOTE: you may always try reimporting sprites later using respective menu commands.", AGSEditor.SPRITE_FILE_NAME), MessageBoxIcon.Warning) == DialogResult.Yes) { RecreateSpriteFileFromSources(); } else { CreateNewSpriteFile(); isNewSpriteFile = true; } } try { Factory.NativeProxy.LoadNewSpriteFile(); } catch (Exception e) { errors.Add(e.Message); if (!isNewSpriteFile) { CreateNewSpriteFile(); } } // Process after game load operations RecentGame recentGame = new RecentGame(game.Settings.GameName, gameDirectory); if (Factory.AGSEditor.Settings.RecentGames.Contains(recentGame)) { Factory.AGSEditor.Settings.RecentGames.Remove(recentGame); } Factory.AGSEditor.Settings.RecentGames.Insert(0, recentGame); Factory.Events.OnGamePostLoad(); Factory.AGSEditor.RefreshEditorAfterGameLoad(game, errors); if (needToSave) { Factory.AGSEditor.SaveGameFiles(); } Factory.AGSEditor.ReportGameLoad(errors); return(true); }