public static void Main() { Logger.Initialize(); // Log all unhandled exceptions. AppDomain.CurrentDomain.UnhandledException += (sender, args) => { var exception = args.ExceptionObject as Exception; Logger.Error(exception, LogType.Runtime); }; // Change the working directory to where the executable is. Directory.SetCurrentDirectory(WorkingDirectory); Environment.CurrentDirectory = WorkingDirectory; try { using (var p = Process.GetCurrentProcess()) p.PriorityClass = ProcessPriorityClass.High; } catch (Win32Exception) { /* do nothing */ } CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; NativeAssemblies.Copy(); ConfigManager.Initialize(); SteamManager.Initialize(); using (var game = new QuaverGame()) game.Run(); }
static void Main(string[] args) { GameMain game = null; string executableDir = ""; #if !DEBUG try { #endif executableDir = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); SteamManager.Initialize(); game = new GameMain(args); game.Run(); game.Dispose(); #if !DEBUG } catch (Exception e) { try { CrashDump(game, Path.Combine(executableDir, "crashreport.log"), e); } catch (Exception e2) { CrashMessageBox("Barotrauma seems to have crashed, and failed to generate a crash report: " + e2.Message + "\n" + e2.StackTrace.ToString(), null); } game?.Dispose(); return; } #endif }
public GameMain() { Instance = this; World = new World(new Vector2(0, -9.82f)); FarseerPhysics.Settings.AllowSleep = true; FarseerPhysics.Settings.ContinuousPhysics = false; FarseerPhysics.Settings.VelocityIterations = 1; FarseerPhysics.Settings.PositionIterations = 1; Config = new GameSettings("config.xml"); if (Config.WasGameUpdated) { UpdaterUtil.CleanOldFiles(); Config.WasGameUpdated = false; Config.Save(); } TextManager.LoadTextPacks(Path.Combine("Content", "Texts")); SteamManager.Initialize(); if (GameSettings.SendUserStatistics) { GameAnalyticsManager.Init(); } GameScreen = new GameScreen(); }
public GameMain(string[] args) { Instance = this; CommandLineArgs = args; World = new World(new Vector2(0, -9.82f)); FarseerPhysics.Settings.AllowSleep = true; FarseerPhysics.Settings.ContinuousPhysics = false; FarseerPhysics.Settings.VelocityIterations = 1; FarseerPhysics.Settings.PositionIterations = 1; Console.WriteLine("Loading game settings"); Config = new GameSettings(); Console.WriteLine("Loading MD5 hash cache"); Md5Hash.LoadCache(); Console.WriteLine("Initializing SteamManager"); SteamManager.Initialize(); Console.WriteLine("Initializing GameAnalytics"); if (GameSettings.SendUserStatistics) { GameAnalyticsManager.Init(); } Console.WriteLine("Initializing GameScreen"); GameScreen = new GameScreen(); MainThread = Thread.CurrentThread; }
static void Main(string[] args) { string executableDir = ""; #if !DEBUG AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += new UnhandledExceptionEventHandler(CrashHandler); #endif #if LINUX setLinuxEnv(); #endif Game = null; executableDir = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); Directory.SetCurrentDirectory(executableDir); SteamManager.Initialize(); EnableNvOptimus(); Game = new GameMain(args); Game.Run(); Game.Dispose(); FreeNvOptimus(); CrossThread.ProcessTasks(); }
static void Main(string[] args) { GameMain game = null; #if !DEBUG try { #endif SteamManager.Initialize(); game = new GameMain(args); game.Run(); game.Dispose(); #if !DEBUG } catch (Exception e) { try { CrashDump(game, "crashreport.log", e); } catch (Exception e2) { CrashMessageBox("Barotrauma seems to have crashed, and failed to generate a crash report: " + e2.Message + "\n" + e2.StackTrace.ToString(), null); } game?.Dispose(); return; } #endif }
/// <summary> /// Starts the game /// </summary> private static void Run() { Logger.Initialize(); // Log all unhandled exceptions. AppDomain.CurrentDomain.UnhandledException += (sender, args) => { var exception = args.ExceptionObject as Exception; Logger.Error(exception, LogType.Runtime); }; StartIpcServer(); // Change the working directory to where the executable is. Directory.SetCurrentDirectory(WorkingDirectory); Environment.CurrentDirectory = WorkingDirectory; try { using (var p = Process.GetCurrentProcess()) p.PriorityClass = ProcessPriorityClass.High; } catch (Win32Exception) { /* do nothing */ } CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; NativeAssemblies.Copy(); ConfigManager.Initialize(); SteamManager.Initialize(); try { Utils.NativeUtils.RegisterURIScheme("quaver", "Quaver"); } catch (Exception e) { Logger.Error(e, LogType.Runtime); } #if VISUAL_TESTS using (var game = new QuaverGame(new HotLoader("../../../../Quaver.Shared/"))) #else using (var game = new QuaverGame()) #endif game.Run(); }
public GameMain(string[] args) { Instance = this; CommandLineArgs = args; World = new World(new Vector2(0, -9.82f)); FarseerPhysics.Settings.AllowSleep = true; FarseerPhysics.Settings.ContinuousPhysics = false; FarseerPhysics.Settings.VelocityIterations = 1; FarseerPhysics.Settings.PositionIterations = 1; Config = new GameSettings(); SteamManager.Initialize(); if (GameSettings.SendUserStatistics) { GameAnalyticsManager.Init(); } GameScreen = new GameScreen(); }
public static void Main() { // Log all unhandled exceptions. AppDomain.CurrentDomain.UnhandledException += (sender, args) => { var exception = args.ExceptionObject as Exception; Logger.Error(exception, LogType.Runtime); }; // Change the working directory to where the executable is. Directory.SetCurrentDirectory(WorkingDirectory); Environment.CurrentDirectory = WorkingDirectory; CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; ConfigManager.Initialize(); SteamManager.Initialize(); using (var game = new QuaverGame()) game.Run(); }
static void Main() { SteamManager.Initialize(); GameMain game = null; #if !DEBUG try { #endif game = new GameMain(); #if !DEBUG } catch (Exception e) { if (game != null) { game.Dispose(); } CrashDump(null, "crashreport.log", e); return; } #endif #if DEBUG game.Run(); #else bool attemptRestart = false; do { try { game.Run(); attemptRestart = false; } catch (Exception e) { if (restartAttempts < 5 && CheckException(game, e)) { attemptRestart = true; restartAttempts++; } else { CrashDump(game, "crashreport.log", e); attemptRestart = false; } } } while (attemptRestart); #endif #if !DEBUG try { #endif game.Dispose(); #if !DEBUG } catch (Exception e) { CrashDump(null, "crashreport.log", e); } #endif }
private IEnumerable <object> Load() { if (GameSettings.VerboseLogging) { DebugConsole.NewMessage("LOADING COROUTINE", Color.Lime); } SoundManager = new Sounds.SoundManager(); SoundManager.SetCategoryGainMultiplier("default", Config.SoundVolume); SoundManager.SetCategoryGainMultiplier("ui", Config.SoundVolume); SoundManager.SetCategoryGainMultiplier("waterambience", Config.SoundVolume); SoundManager.SetCategoryGainMultiplier("music", Config.MusicVolume); SoundManager.SetCategoryGainMultiplier("voip", Config.VoiceChatVolume); if (Config.EnableSplashScreen) { try { (TitleScreen as LoadingScreen).SplashScreen = new Video(base.GraphicsDevice, SoundManager, "Content/splashscreen.mp4", 1280, 720); } catch (Exception e) { Config.EnableSplashScreen = false; DebugConsole.ThrowError("Playing the splash screen failed.", e); } } GUI.Init(Window, Config.SelectedContentPackages, GraphicsDevice); DebugConsole.Init(); SteamManager.Initialize(); if (Config.AutoUpdateWorkshopItems) { if (SteamManager.AutoUpdateWorkshopItems()) { ContentPackage.LoadAll(ContentPackage.Folder); Config.ReloadContentPackages(); } } if (SelectedPackages.Count == 0) { DebugConsole.Log("No content packages selected"); } else { DebugConsole.Log("Selected content packages: " + string.Join(", ", SelectedPackages.Select(cp => cp.Name))); } #if DEBUG GameSettings.ShowUserStatisticsPrompt = false; GameSettings.SendUserStatistics = false; #endif InitUserStats(); yield return(CoroutineStatus.Running); LightManager = new Lights.LightManager(base.GraphicsDevice, Content); WaterRenderer.Instance = new WaterRenderer(base.GraphicsDevice, Content); TitleScreen.LoadState = 1.0f; yield return(CoroutineStatus.Running); GUI.LoadContent(); TitleScreen.LoadState = 2.0f; yield return(CoroutineStatus.Running); MissionPrefab.Init(); MapEntityPrefab.Init(); Tutorials.Tutorial.Init(); MapGenerationParams.Init(); LevelGenerationParams.LoadPresets(); ScriptedEventSet.LoadPrefabs(); AfflictionPrefab.LoadAll(GetFilesOfType(ContentType.Afflictions)); TitleScreen.LoadState = 10.0f; yield return(CoroutineStatus.Running); StructurePrefab.LoadAll(GetFilesOfType(ContentType.Structure)); TitleScreen.LoadState = 15.0f; yield return(CoroutineStatus.Running); ItemPrefab.LoadAll(GetFilesOfType(ContentType.Item)); TitleScreen.LoadState = 25.0f; yield return(CoroutineStatus.Running); JobPrefab.LoadAll(GetFilesOfType(ContentType.Jobs)); // Add any missing jobs from the prefab into Config.JobNamePreferences. foreach (JobPrefab job in JobPrefab.List) { if (!Config.JobPreferences.Contains(job.Identifier)) { Config.JobPreferences.Add(job.Identifier); } } NPCConversation.LoadAll(GetFilesOfType(ContentType.NPCConversations)); ItemAssemblyPrefab.LoadAll(); TitleScreen.LoadState = 30.0f; yield return(CoroutineStatus.Running); Debug.WriteLine("sounds"); int i = 0; foreach (object crObj in SoundPlayer.Init()) { CoroutineStatus status = (CoroutineStatus)crObj; if (status == CoroutineStatus.Success) { break; } i++; TitleScreen.LoadState = SoundPlayer.SoundCount == 0 ? 30.0f : Math.Min(30.0f + 40.0f * i / Math.Max(SoundPlayer.SoundCount, 1), 70.0f); yield return(CoroutineStatus.Running); } TitleScreen.LoadState = 70.0f; yield return(CoroutineStatus.Running); GameModePreset.Init(); Submarine.RefreshSavedSubs(); TitleScreen.LoadState = 80.0f; yield return(CoroutineStatus.Running); GameScreen = new GameScreen(GraphicsDeviceManager.GraphicsDevice, Content); TitleScreen.LoadState = 90.0f; yield return(CoroutineStatus.Running); MainMenuScreen = new MainMenuScreen(this); LobbyScreen = new LobbyScreen(); ServerListScreen = new ServerListScreen(); if (SteamManager.USE_STEAM) { SteamWorkshopScreen = new SteamWorkshopScreen(); } SubEditorScreen = new SubEditorScreen(); ParticleEditorScreen = new ParticleEditorScreen(); LevelEditorScreen = new LevelEditorScreen(); SpriteEditorScreen = new SpriteEditorScreen(); CharacterEditorScreen = new CharacterEditorScreen(); yield return(CoroutineStatus.Running); TitleScreen.LoadState = 95.0f; ParticleManager = new ParticleManager(GameScreen.Cam); ParticleManager.LoadPrefabs(); TitleScreen.LoadState = 97.0f; LevelObjectPrefab.LoadAll(); DecalManager = new DecalManager(); TitleScreen.LoadState = 99.0f; yield return(CoroutineStatus.Running); LocationType.Init(); MainMenuScreen.Select(); CheckContentPackage(); TitleScreen.LoadState = 100.0f; hasLoaded = true; if (GameSettings.VerboseLogging) { DebugConsole.NewMessage("LOADING COROUTINE FINISHED", Color.Lime); } yield return(CoroutineStatus.Success); }
private IEnumerable <object> Load() { if (GameSettings.VerboseLogging) { DebugConsole.NewMessage("LOADING COROUTINE", Color.Lime); } SoundManager = new Sounds.SoundManager(); SoundManager.SetCategoryGainMultiplier("default", Config.SoundVolume); SoundManager.SetCategoryGainMultiplier("ui", Config.SoundVolume); SoundManager.SetCategoryGainMultiplier("waterambience", Config.SoundVolume); SoundManager.SetCategoryGainMultiplier("music", Config.MusicVolume); GUI.Init(Window, Config.SelectedContentPackages, GraphicsDevice); DebugConsole.Init(); SteamManager.Initialize(); if (SelectedPackages.Count == 0) { DebugConsole.Log("No content packages selected"); } else { DebugConsole.Log("Selected content packages: " + string.Join(", ", SelectedPackages.Select(cp => cp.Name))); } InitUserStats(); yield return(CoroutineStatus.Running); LightManager = new Lights.LightManager(base.GraphicsDevice, Content); WaterRenderer.Instance = new WaterRenderer(base.GraphicsDevice, Content); TitleScreen.LoadState = 1.0f; yield return(CoroutineStatus.Running); GUI.LoadContent(); TitleScreen.LoadState = 2.0f; yield return(CoroutineStatus.Running); MissionPrefab.Init(); MapEntityPrefab.Init(); Tutorials.Tutorial.Init(); MapGenerationParams.Init(); LevelGenerationParams.LoadPresets(); ScriptedEventSet.LoadPrefabs(); AfflictionPrefab.LoadAll(GetFilesOfType(ContentType.Afflictions)); TitleScreen.LoadState = 10.0f; yield return(CoroutineStatus.Running); StructurePrefab.LoadAll(GetFilesOfType(ContentType.Structure)); TitleScreen.LoadState = 15.0f; yield return(CoroutineStatus.Running); ItemPrefab.LoadAll(GetFilesOfType(ContentType.Item)); TitleScreen.LoadState = 30.0f; yield return(CoroutineStatus.Running); JobPrefab.LoadAll(GetFilesOfType(ContentType.Jobs)); // Add any missing jobs from the prefab into Config.JobNamePreferences. foreach (JobPrefab job in JobPrefab.List) { if (!Config.JobPreferences.Contains(job.Identifier)) { Config.JobPreferences.Add(job.Identifier); } } NPCConversation.LoadAll(GetFilesOfType(ContentType.NPCConversations)); ItemAssemblyPrefab.LoadAll(); TitleScreen.LoadState = 35.0f; yield return(CoroutineStatus.Running); Debug.WriteLine("sounds"); CoroutineManager.StartCoroutine(SoundPlayer.Init()); int i = 0; while (!SoundPlayer.Initialized) { i++; TitleScreen.LoadState = SoundPlayer.SoundCount == 0 ? 30.0f : Math.Min(30.0f + 40.0f * i / Math.Max(SoundPlayer.SoundCount, 1), 70.0f); yield return(CoroutineStatus.Running); } TitleScreen.LoadState = 70.0f; yield return(CoroutineStatus.Running); GameModePreset.Init(); Submarine.RefreshSavedSubs(); TitleScreen.LoadState = 80.0f; yield return(CoroutineStatus.Running); GameScreen = new GameScreen(GraphicsDeviceManager.GraphicsDevice, Content); TitleScreen.LoadState = 90.0f; yield return(CoroutineStatus.Running); MainMenuScreen = new MainMenuScreen(this); LobbyScreen = new LobbyScreen(); ServerListScreen = new ServerListScreen(); if (SteamManager.USE_STEAM) { SteamWorkshopScreen = new SteamWorkshopScreen(); } SubEditorScreen = new SubEditorScreen(); ParticleEditorScreen = new ParticleEditorScreen(); LevelEditorScreen = new LevelEditorScreen(); SpriteEditorScreen = new SpriteEditorScreen(); CharacterEditorScreen = new CharacterEditorScreen(); yield return(CoroutineStatus.Running); ParticleManager = new ParticleManager(GameScreen.Cam); ParticleManager.LoadPrefabs(); LevelObjectPrefab.LoadAll(); DecalManager = new DecalManager(); yield return(CoroutineStatus.Running); LocationType.Init(); MainMenuScreen.Select(); TitleScreen.LoadState = 100.0f; hasLoaded = true; if (GameSettings.VerboseLogging) { DebugConsole.NewMessage("LOADING COROUTINE FINISHED", Color.Lime); } yield return(CoroutineStatus.Success); }