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);
}