void LoadInBackground() { try { LuaEngine.InitInstance(); GraphicsManager.InitStatic(); SoundManager.InitStatic(); DiagManager.Instance.LoadMsg = "Loading Content"; Data.DataManager.InitInstance(); Data.DataManager.Instance.InitData(); Network.NetworkManager.InitInstance(); Menu.MenuManager.InitInstance(); GameManager.InitInstance(); Dungeon.ZoneManager.InitInstance(); Dungeon.DungeonScene.InitInstance(); Ground.GroundScene.InitInstance(); //Dungeon.DungeonEditScene.InitInstance(); Dev.GroundEditScene.InitInstance(); //Notify script engine LuaEngine.Instance.OnDataLoad(); LuaEngine.Instance.UpdateExposedInstances(); GameManager.Instance.Begin(); } catch (Exception ex) { DiagManager.Instance.LogError(ex); } backgroundLoaded = true; DiagManager.Instance.LoadMsg = "Press any key to continue"; }
static void Main() { if (OperatingSystem.IsWindows()) { enlargeConsole(); } string[] args = Environment.GetCommandLineArgs(); PathMod.InitExePath(args[0]); DiagManager.InitInstance(); for (int ii = 1; ii < args.Length; ii++) { if (args[ii] == "-asset") { PathMod.ASSET_PATH = System.IO.Path.GetFullPath(PathMod.ExePath + args[ii + 1]); ii++; } else if (args[ii] == "-raw") { PathMod.DEV_PATH = System.IO.Path.GetFullPath(PathMod.ExePath + args[ii + 1]); ii++; } } GraphicsManager.InitParams(); Text.Init(); Text.SetCultureCode("en"); LuaEngine.InitInstance(); DataManager.InitInstance(); DataManager.Instance.InitData(); #if DEBUG GenContextDebug.OnInit += ExampleDebug.Init; GenContextDebug.OnStep += ExampleDebug.OnStep; GenContextDebug.OnStepIn += ExampleDebug.StepIn; GenContextDebug.OnStepOut += ExampleDebug.StepOut; #endif Example.Run(); Console.Clear(); Console.WriteLine("Bye."); Console.ReadKey(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { DiagManager.Instance.LoadMsg = "Loading System"; GraphicsManager.InitSystem(GraphicsDevice); CurrentPhase = LoadPhase.Content; LuaEngine.InitInstance(); GraphicsManager.InitStatic(); Thread thread = new Thread(LoadInBackground); thread.IsBackground = true; //thread.CurrentCulture = Thread.CurrentThread.CurrentCulture; //thread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture; thread.Start(); base.Initialize(); }
static void Main() { InitDllMap(); //SetProcessDPIAware(); //TODO: figure out how to set this switch in appconfig AppContext.SetSwitch("Switch.System.Runtime.Serialization.SerializationGuard.AllowFileWrites", true); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; string[] args = Environment.GetCommandLineArgs(); PathMod.InitExePath(args[0]); DiagManager.InitInstance(); DiagManager.Instance.CurSettings = DiagManager.Instance.LoadSettings(); DiagManager.Instance.LoadModSettings(); DiagManager.Instance.UpgradeBinder = new UpgradeBinder(); try { DiagManager.Instance.LogInfo("========================================="); DiagManager.Instance.LogInfo(String.Format("SESSION STARTED: {0}", String.Format("{0:yyyy/MM/dd HH:mm:ss}", DateTime.Now))); DiagManager.Instance.LogInfo("Version: " + Versioning.GetVersion().ToString()); DiagManager.Instance.LogInfo(Versioning.GetDotNetInfo()); DiagManager.Instance.LogInfo("========================================="); bool logInput = true; bool guideBook = false; bool guideCsv = false; GraphicsManager.AssetType convertAssets = GraphicsManager.AssetType.None; DataManager.DataType convertIndices = DataManager.DataType.None; DataManager.DataType reserializeIndices = DataManager.DataType.None; string langArgs = ""; bool dev = false; string quest = ""; List <string> mod = new List <string>(); bool buildQuest = false; string playInputs = null; for (int ii = 1; ii < args.Length; ii++) { if (args[ii] == "-dev") { dev = true; } else if (args[ii] == "-play" && args.Length > ii + 1) { playInputs = args[ii + 1]; ii++; } else if (args[ii] == "-lang" && args.Length > ii + 1) { langArgs = args[ii + 1]; ii++; } else if (args[ii] == "-nolog") { logInput = false; } else if (args[ii] == "-guide") { guideBook = true; } else if (args[ii] == "-csv") { guideCsv = true; } else if (args[ii] == "-asset") { PathMod.ASSET_PATH = Path.GetFullPath(args[ii + 1]); ii++; } else if (args[ii] == "-raw") { PathMod.DEV_PATH = Path.GetFullPath(args[ii + 1]); ii++; } else if (args[ii] == "-quest") { quest = args[ii + 1]; ii++; } else if (args[ii] == "-mod") { int jj = 1; while (args.Length > ii + jj) { if (args[ii + jj].StartsWith("-")) { break; } else { mod.Add(args[ii + jj]); } jj++; } ii += jj - 1; } else if (args[ii] == "-build") { buildQuest = true; ii++; } else if (args[ii] == "-convert") { int jj = 1; while (args.Length > ii + jj) { GraphicsManager.AssetType conv = GraphicsManager.AssetType.None; foreach (GraphicsManager.AssetType type in Enum.GetValues(typeof(GraphicsManager.AssetType))) { if (args[ii + jj].ToLower() == type.ToString().ToLower()) { conv = type; break; } } if (conv != GraphicsManager.AssetType.None) { convertAssets |= conv; } else { break; } jj++; } ii += jj - 1; } else if (args[ii] == "-index") { int jj = 1; while (args.Length > ii + jj) { DataManager.DataType conv = DataManager.DataType.None; foreach (DataManager.DataType type in Enum.GetValues(typeof(DataManager.DataType))) { if (args[ii + jj].ToLower() == type.ToString().ToLower()) { conv = type; break; } } if (conv != DataManager.DataType.None) { convertIndices |= conv; } else { break; } jj++; } ii += jj - 1; } else if (args[ii] == "-reserialize") { int jj = 1; while (args.Length > ii + jj) { DataManager.DataType conv = DataManager.DataType.None; foreach (DataManager.DataType type in Enum.GetValues(typeof(DataManager.DataType))) { if (args[ii + jj].ToLower() == type.ToString().ToLower()) { conv = type; break; } } if (conv != DataManager.DataType.None) { reserializeIndices |= conv; } else { break; } jj++; } ii += jj - 1; } } DiagManager.Instance.SetupGamepad(); GraphicsManager.InitParams(); DiagManager.Instance.DevMode = dev; if (quest != "") { ModHeader header = PathMod.GetModDetails(Path.Combine(PathMod.MODS_PATH, quest)); if (header.IsValid()) { PathMod.Quest = header; DiagManager.Instance.LogInfo(String.Format("Loaded quest \"{0}\".", quest)); } else { DiagManager.Instance.LogInfo(String.Format("Cannot find quest \"{0}\" in {1}. Falling back to base game.", quest, PathMod.MODS_PATH)); } } if (mod.Count > 0) { List <ModHeader> workingMods = new List <ModHeader>(); for (int ii = 0; ii < mod.Count; ii++) { ModHeader header = PathMod.GetModDetails(Path.Combine(PathMod.MODS_PATH, mod[ii])); if (header.IsValid()) { workingMods.Add(header); DiagManager.Instance.LogInfo(String.Format("Loaded mod \"{0}\".", String.Join(", ", mod[ii]))); } else { DiagManager.Instance.LogInfo(String.Format("Cannot find mod \"{0}\" in {1}. It will be ignored.", mod, PathMod.MODS_PATH)); mod.RemoveAt(ii); ii--; } } PathMod.Mods = workingMods.ToArray(); } if (playInputs != null) { DiagManager.Instance.LoadInputs(playInputs); } Text.Init(); if (langArgs != "" && DiagManager.Instance.CurSettings.Language == "") { if (langArgs.Length > 0) { DiagManager.Instance.CurSettings.Language = langArgs.ToLower(); Text.SetCultureCode(langArgs.ToLower()); } else { DiagManager.Instance.CurSettings.Language = "en"; } } Text.SetCultureCode(DiagManager.Instance.CurSettings.Language == "" ? "" : DiagManager.Instance.CurSettings.Language.ToString()); if (buildQuest) { if (!PathMod.Quest.IsValid()) { DiagManager.Instance.LogInfo("No quest specified to build."); return; } RogueEssence.Dev.DevHelper.MergeQuest(quest); return; } if (convertAssets != GraphicsManager.AssetType.None) { //run conversions using (GameBase game = new GameBase()) { GraphicsManager.InitSystem(game.GraphicsDevice); GraphicsManager.RunConversions(convertAssets); } return; } if (reserializeIndices != DataManager.DataType.None) { DiagManager.Instance.LogInfo("Beginning Reserialization"); using (GameBase game = new GameBase()) { GraphicsManager.InitSystem(game.GraphicsDevice); GraphicsManager.RebuildIndices(GraphicsManager.AssetType.All); } //we need the datamanager for this, but only while data is hardcoded //TODO: remove when data is no longer hardcoded LuaEngine.InitInstance(); DataManager.InitInstance(); DataManager.InitDataDirs(PathMod.ModPath("")); RogueEssence.Dev.DevHelper.ReserializeBase(); DiagManager.Instance.LogInfo("Reserializing main data"); RogueEssence.Dev.DevHelper.Reserialize(reserializeIndices); DiagManager.Instance.LogInfo("Reserializing map data"); if ((reserializeIndices & DataManager.DataType.Zone) != DataManager.DataType.None) { RogueEssence.Dev.DevHelper.ReserializeData <Map>(DataManager.DATA_PATH + "Map/", DataManager.MAP_EXT); RogueEssence.Dev.DevHelper.ReserializeData <GroundMap>(DataManager.DATA_PATH + "Ground/", DataManager.GROUND_EXT); } DiagManager.Instance.LogInfo("Reserializing indices"); RogueEssence.Dev.DevHelper.RunIndexing(reserializeIndices); DataManager.Instance.UniversalData = (TypeDict <BaseData>)RogueEssence.Dev.DevHelper.LoadWithLegacySupport(PathMod.ModPath(DataManager.MISC_PATH + "Index.bin"), typeof(TypeDict <BaseData>)); RogueEssence.Dev.DevHelper.RunExtraIndexing(reserializeIndices); return; } if (convertIndices != DataManager.DataType.None) { //we need the datamanager for this, but only while data is hardcoded //TODO: remove when data is no longer hardcoded LuaEngine.InitInstance(); DataManager.InitInstance(); DiagManager.Instance.LogInfo("Reserializing indices"); DataManager.InitDataDirs(PathMod.ModPath("")); RogueEssence.Dev.DevHelper.RunIndexing(convertIndices); DataManager.Instance.UniversalData = (TypeDict <BaseData>)RogueEssence.Dev.DevHelper.LoadWithLegacySupport(PathMod.ModPath(DataManager.MISC_PATH + "Index.bin"), typeof(TypeDict <BaseData>)); RogueEssence.Dev.DevHelper.RunExtraIndexing(convertIndices); return; } if (guideBook || guideCsv) { //print the guidebook in the chosen language //we need the datamanager for this LuaEngine.InitInstance(); DataManager.InitInstance(); DataManager.Instance.InitData(); //just print a guidebook and exit StrategyGuide.PrintMoveGuide(guideCsv); StrategyGuide.PrintItemGuide(guideCsv); StrategyGuide.PrintAbilityGuide(guideCsv); StrategyGuide.PrintEncounterGuide(guideCsv); return; } //Dev.ImportManager.PrintMoveUsers(PathMod.DEV_PATH+"moves.txt"); //Dev.ImportManager.PrintAbilityUsers(PathMod.DEV_PATH+"abilities.txt"); logInput = false; //this feature is disabled for now... if (DiagManager.Instance.ActiveDebugReplay == null && logInput) { DiagManager.Instance.BeginInput(); } if (DiagManager.Instance.DevMode) { InitDataEditor(); AppBuilder builder = RogueEssence.Dev.Program.BuildAvaloniaApp(); builder.StartWithClassicDesktopLifetime(args); } else { DiagManager.Instance.DevEditor = new EmptyEditor(); using (GameBase game = new GameBase()) game.Run(); } } catch (Exception ex) { DiagManager.Instance.LogError(ex); throw; } }