/// <summary>Deinitializes the program.</summary> private static void Deinitialize() { Plugins.UnloadPlugins(); Sounds.Deinitialize(); Joysticks.Deinitialize(); Screen.Deinitialize(); Sdl.SDL_Quit(); }
/// <summary>Deinitializes the program.</summary> private static void Deinitialize() { Plugins.UnloadPlugins(); Sounds.Deinitialize(); if (currentGameWindow != null) { currentGameWindow.Dispose(); } }
/// <summary>Deinitializes the program.</summary> private static void Deinitialize() { string error; Program.CurrentHost.UnloadPlugins(out error); Sounds.Deinitialize(); if (currentGameWindow != null) { currentGameWindow.Dispose(); } }
private void StartSimulator() { if (Result.RouteFile != null & Result.TrainFolder != null) { if (System.IO.File.Exists(Result.RouteFile) & System.IO.Directory.Exists(Result.TrainFolder)) { Result.Start = true; formCloseTrig = true; Sounds.Deinitialize(); if (routeWorkerThread != null) { routeWorkerThread.Dispose(); } //HACK: Call Application.DoEvents() to force the message pump to process all pending messages when the form closes //This fixes the main form failing to close on Linux Application.DoEvents(); this.Close(); } } else { System.Media.SystemSounds.Exclamation.Play(); } }
internal static void Main(string[] args) { CurrentHost = new Host(); commandLineArguments = args; // platform and mono CurrentlyRunOnMono = Type.GetType("Mono.Runtime") != null; // file system FileSystem = FileSystem.FromCommandLineArgs(args); FileSystem.CreateFileSystem(); Renderer = new NewRenderer(); CurrentRoute = new CurrentRoute(Renderer); Sounds = new Sounds(); // command line arguments SkipArgs = new bool[args.Length]; if (args.Length != 0) { string File = System.IO.Path.Combine(Application.StartupPath, "ObjectViewer.exe"); if (System.IO.File.Exists(File)) { int Skips = 0; System.Text.StringBuilder NewArgs = new System.Text.StringBuilder(); for (int i = 0; i < args.Length; i++) { if (args[i] != null && System.IO.File.Exists(args[i])) { if (System.IO.Path.GetExtension(args[i]).Equals(".csv", StringComparison.OrdinalIgnoreCase)) { string Text = System.IO.File.ReadAllText(args[i], System.Text.Encoding.UTF8); if (Text.Length == 0 || Text.IndexOf("CreateMeshBuilder", StringComparison.OrdinalIgnoreCase) >= 0) { if (NewArgs.Length != 0) { NewArgs.Append(" "); } NewArgs.Append("\"" + args[i] + "\""); SkipArgs[i] = true; Skips++; } } } else { SkipArgs[i] = true; Skips++; } } if (NewArgs.Length != 0) { System.Diagnostics.Process.Start(File, NewArgs.ToString()); } if (Skips == args.Length) { return; } } } Options.LoadOptions(); var options = new ToolkitOptions(); Plugins.LoadPlugins(); options.Backend = PlatformBackend.PreferX11; Toolkit.Init(options); string folder = Program.FileSystem.GetDataFolder("Languages"); Translations.LoadLanguageFiles(folder); Interface.CurrentOptions.ObjectOptimizationBasicThreshold = 1000; Interface.CurrentOptions.ObjectOptimizationFullThreshold = 250; // application currentGraphicsMode = new GraphicsMode(new ColorFormat(8, 8, 8, 8), 24, 8, Interface.CurrentOptions.AntiAliasingLevel); if (Renderer.Screen.Width == 0 || Renderer.Screen.Height == 0) { //Duff values saved, so reset to something sensible else we crash Renderer.Screen.Width = 1024; Renderer.Screen.Height = 768; } Renderer.CameraTrackFollower = new TrackFollower(Program.CurrentHost); currentGameWindow = new RouteViewer(Renderer.Screen.Width, Renderer.Screen.Height, currentGraphicsMode, "Route Viewer", GameWindowFlags.Default); currentGameWindow.Visible = true; currentGameWindow.TargetUpdateFrequency = 0; currentGameWindow.TargetRenderFrequency = 0; currentGameWindow.Title = "Route Viewer"; processCommandLineArgs = true; currentGameWindow.Run(); //Unload Sounds.Deinitialize(); }
internal static void Main(string[] args) { CurrentHost = new Host(); commandLineArguments = args; Options.LoadOptions(); Interface.CurrentOptions.UseSound = true; Interface.CurrentOptions.ObjectOptimizationBasicThreshold = 1000; Interface.CurrentOptions.ObjectOptimizationFullThreshold = 250; // platform and mono int p = (int)Environment.OSVersion.Platform; if (p == 4 | p == 128) { // general Unix CurrentPlatform = Platform.Linux; } else if (p == 6) { // Mac CurrentPlatform = Platform.Mac; } else { // non-Unix CurrentPlatform = Platform.Windows; } CurrentlyRunOnMono = Type.GetType("Mono.Runtime") != null; // file system FileSystem = FileSystem.FromCommandLineArgs(args); FileSystem.CreateFileSystem(); Plugins.LoadPlugins(); // command line arguments SkipArgs = new bool[args.Length]; if (args.Length != 0) { string File = System.IO.Path.Combine(Application.StartupPath, "ObjectViewer.exe"); if (System.IO.File.Exists(File)) { int Skips = 0; System.Text.StringBuilder NewArgs = new System.Text.StringBuilder(); for (int i = 0; i < args.Length; i++) { if (args[i] != null && System.IO.File.Exists(args[i])) { if (System.IO.Path.GetExtension(args[i]).Equals(".csv", StringComparison.OrdinalIgnoreCase)) { string Text = System.IO.File.ReadAllText(args[i], System.Text.Encoding.UTF8); if (Text.Length == 0 || Text.IndexOf("CreateMeshBuilder", StringComparison.OrdinalIgnoreCase) >= 0) { if (NewArgs.Length != 0) { NewArgs.Append(" "); } NewArgs.Append("\"" + args[i] + "\""); SkipArgs[i] = true; Skips++; } } } else { SkipArgs[i] = true; Skips++; } } if (NewArgs.Length != 0) { System.Diagnostics.Process.Start(File, NewArgs.ToString()); } if (Skips == args.Length) { return; } } } // application currentGraphicsMode = new GraphicsMode(new ColorFormat(8, 8, 8, 8), 24, 8, Interface.CurrentOptions.AntialiasingLevel); currentGameWindow = new RouteViewer(Renderer.ScreenWidth, Renderer.ScreenHeight, currentGraphicsMode, "Route Viewer", GameWindowFlags.Default); currentGameWindow.Visible = true; currentGameWindow.TargetUpdateFrequency = 0; currentGameWindow.TargetRenderFrequency = 0; currentGameWindow.Title = "Route Viewer"; processCommandLineArgs = true; currentGameWindow.Run(); //Unload TextureManager.UnuseAllTextures(); Sounds.Deinitialize(); }
internal static void Main(string[] args) { CurrentHost = new Host(); // file system FileSystem = FileSystem.FromCommandLineArgs(args, CurrentHost); FileSystem.CreateFileSystem(); Renderer = new NewRenderer(); CurrentRoute = new CurrentRoute(Renderer); Sounds = new Sounds(); Options.LoadOptions(); Plugins.LoadPlugins(); // command line arguments StringBuilder objectsToLoad = new StringBuilder(); if (args.Length != 0) { for (int i = 0; i < args.Length; i++) { if (args[i] != null) { if (System.IO.File.Exists(args[i])) { for (int j = 0; j < CurrentHost.Plugins.Length; j++) { if (CurrentHost.Plugins[j].Object != null && CurrentHost.Plugins[j].Object.CanLoadObject(args[i])) { objectsToLoad.Append(args[i] + " "); continue; } if (CurrentHost.Plugins[j].Route != null && CurrentHost.Plugins[j].Route.CanLoadRoute(args[i])) { if (string.IsNullOrEmpty(CurrentRouteFile)) { CurrentRouteFile = args[i]; processCommandLineArgs = true; } } } } else if (args[i].ToLowerInvariant() == "/enablehacks") { //Deliberately undocumented option for debugging use Interface.CurrentOptions.EnableBveTsHacks = true; for (int j = 0; j < CurrentHost.Plugins.Length; j++) { if (CurrentHost.Plugins[j].Object != null) { CompatabilityHacks enabledHacks = new CompatabilityHacks { BveTsHacks = true, CylinderHack = false, BlackTransparency = true }; CurrentHost.Plugins[j].Object.SetCompatibilityHacks(enabledHacks); } } } } } } if (objectsToLoad.Length != 0) { string File = System.IO.Path.Combine(Application.StartupPath, "ObjectViewer.exe"); if (System.IO.File.Exists(File)) { System.Diagnostics.Process.Start(File, objectsToLoad.ToString()); if (string.IsNullOrEmpty(CurrentRouteFile)) { //We only supplied objects, so launch Object Viewer instead Environment.Exit(0); } } } var options = new ToolkitOptions(); Plugins.LoadPlugins(); options.Backend = PlatformBackend.PreferX11; Toolkit.Init(options); string folder = Program.FileSystem.GetDataFolder("Languages"); Translations.LoadLanguageFiles(folder); Interface.CurrentOptions.ObjectOptimizationBasicThreshold = 1000; Interface.CurrentOptions.ObjectOptimizationFullThreshold = 250; // application currentGraphicsMode = new GraphicsMode(new ColorFormat(8, 8, 8, 8), 24, 8, Interface.CurrentOptions.AntiAliasingLevel); if (Renderer.Screen.Width == 0 || Renderer.Screen.Height == 0) { //Duff values saved, so reset to something sensible else we crash Renderer.Screen.Width = 1024; Renderer.Screen.Height = 768; } Renderer.CameraTrackFollower = new TrackFollower(Program.CurrentHost); currentGameWindow = new RouteViewer(Renderer.Screen.Width, Renderer.Screen.Height, currentGraphicsMode, "Route Viewer", GameWindowFlags.Default); currentGameWindow.Visible = true; currentGameWindow.TargetUpdateFrequency = 0; currentGameWindow.TargetRenderFrequency = 0; currentGameWindow.Title = "Route Viewer"; processCommandLineArgs = true; currentGameWindow.Run(); //Unload Sounds.Deinitialize(); }