AGS.Editor.Tasks.LoadGameFromDisk C# (CSharp) Метод

LoadGameFromDisk() публичный Метод

public LoadGameFromDisk ( string gameToLoad, bool interactive ) : bool
gameToLoad string
interactive bool
Результат bool
        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.");
            }

            Directory.SetCurrentDirectory(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)
            {
                SetDefaultValuesForNewFeatures(game);

                game.DirectoryPath = gameDirectory;
                Utilities.EnsureStandardSubFoldersExist();
                Factory.AGSEditor.RecentGames.AddRecentGame(gameDirectory, game.Settings.GameName);
                Factory.Events.OnGamePostLoad();

                Factory.AGSEditor.RefreshEditorAfterGameLoad(game);
                if (needToSave)
                {
                    Factory.AGSEditor.SaveGameFiles();
                }
                return true;
            }

            return false;
        }

Usage Example

Пример #1
0
        public bool LoadGameFromDisk(string gameToLoad)
        {
            try
            {
                bool success = _tasks.LoadGameFromDisk(gameToLoad, true);

                AGS.Types.Game game = Factory.AGSEditor.CurrentGame;
                if (((game.SavedXmlVersion != null) &&
                     (game.SavedXmlVersion != AGSEditor.LATEST_XML_VERSION))
                    ||
                    ((game.SavedXmlVersionIndex != null) &&
                     (game.SavedXmlVersionIndex != AGSEditor.LATEST_XML_VERSION_INDEX)))
                {
                    Factory.GUIController.ShowMessage("This game was last saved with " +
                                                      ((game.SavedXmlEditorVersion == null) ? "an older version" : ("version " + game.SavedXmlEditorVersion))
                                                      + " of AGS. If you save it now, the game will be upgraded and previous versions of AGS will be unable to open it.", MessageBoxIcon.Information);
                    game.WorkspaceState.RequiresRebuild = true;
                }

                return(success);
            }
            catch (Exception ex)
            {
                ReportTaskException("An error occurred whilst trying to load your game.", ex);
                return(false);
            }
        }
All Usage Examples Of AGS.Editor.Tasks::LoadGameFromDisk