Save() public method

public Save ( ) : void
return void
Example #1
0
        public static void Main(string[] args)
        {
            settings = new Settings(Platform.SupportDir + "settings.yaml", new Arguments());

            var form = new Form
            {
                Size = new Size(315, 140),
                Text = "Fatal Error",
                MinimizeBox = false,
                MaximizeBox = false,
                FormBorderStyle = FormBorderStyle.FixedDialog,
                StartPosition = FormStartPosition.CenterScreen,
                Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location)
            };

            var notice = new Label
            {
                Location = new Point(10, 10),
                AutoSize = true,
                Text = "OpenRA has encountered a fatal error and must close.{0}Refer to the crash logs and FAQ for more information.".F(Environment.NewLine),
                TextAlign = ContentAlignment.TopCenter
            };
            form.Controls.Add(notice);

            var dontShowAgain = new CheckBox
            {
                Location = new Point(25, 50),
                AutoSize = true,
                Text = "Don't show this message again",
            };
            form.Controls.Add(dontShowAgain);

            var viewLogs = new Button
            {
                Location = new Point(10, 80),
                Size = new Size(75, 23),
                Text = "View Logs"
            };
            viewLogs.Click += ViewLogsClicked;
            form.Controls.Add(viewLogs);

            var viewFaq = new Button
            {
                Location = new Point(90, 80),
                Size = new Size(75, 23),
                Text = "View FAQ"
            };
            viewFaq.Click += ViewFaqClicked;
            form.Controls.Add(viewFaq);

            var quit = new Button
            {
                Location = new Point(225, 80),
                Size = new Size(75, 23),
                Text = "Quit"
            };
            quit.DialogResult = DialogResult.Cancel;
            form.Controls.Add(quit);

            form.FormClosed += (sender, e) =>
            {
                settings.Debug.ShowFatalErrorDialog = !dontShowAgain.Checked;
                settings.Save();
            };

            SystemSounds.Exclamation.Play();
            form.ShowDialog();
        }
Example #2
0
        public static void InitializeWithMod(string mod, string replay)
        {
            // Clear static state if we have switched mods
            LobbyInfoChanged       = () => { };
            AddChatLine            = (a, b, c) => { };
            ConnectionStateChanged = om => { };
            BeforeGameStart        = () => { };
            Ui.ResetAll();

            worldRenderer = null;
            if (server != null)
            {
                server.Shutdown();
            }
            if (orderManager != null)
            {
                orderManager.Dispose();
            }

            // Fall back to default if the mod doesn't exist
            if (!ModMetadata.AllMods.ContainsKey(mod))
            {
                mod = new GameSettings().Mod;
            }

            Console.WriteLine("Loading mod: {0}", mod);
            Settings.Game.Mod = mod;

            Sound.StopMusic();
            Sound.StopVideo();
            Sound.Initialize();

            modData = new ModData(mod);
            Renderer.InitializeFonts(modData.Manifest);
            modData.InitializeLoaders();
            using (new PerfTimer("LoadMaps"))
                modData.MapCache.LoadMaps();

            PerfHistory.items["render"].hasNormalTick         = false;
            PerfHistory.items["batches"].hasNormalTick        = false;
            PerfHistory.items["render_widgets"].hasNormalTick = false;
            PerfHistory.items["render_flip"].hasNormalTick    = false;

            JoinLocal();

            if (Settings.Server.Dedicated)
            {
                while (true)
                {
                    Settings.Server.Map = WidgetUtils.ChooseInitialMap(Settings.Server.Map);
                    Settings.Save();
                    CreateServer(new ServerSettings(Settings.Server));
                    while (true)
                    {
                        System.Threading.Thread.Sleep(100);

                        if (server.State == Server.ServerState.GameStarted && server.Conns.Count < 1)
                        {
                            Console.WriteLine("No one is playing, shutting down...");
                            server.Shutdown();
                            break;
                        }
                    }

                    if (Settings.Server.DedicatedLoop)
                    {
                        Console.WriteLine("Starting a new server instance...");
                        modData.MapCache.LoadMaps();
                        continue;
                    }

                    break;
                }

                Environment.Exit(0);
            }
            else
            {
                modData.LoadScreen.StartGame();
                Settings.Save();
                if (!string.IsNullOrEmpty(replay))
                {
                    Game.JoinReplay(replay);
                }
            }
        }
Example #3
0
        public static void InitializeWithMods(string[] mods)
        {
            // Clear static state if we have switched mods
            LobbyInfoChanged       = () => {};
            AddChatLine            = (a, b, c) => {};
            ConnectionStateChanged = om => {};
            BeforeGameStart        = () => {};
            Ui.ResetAll();

            worldRenderer = null;
            if (server != null)
            {
                server.Shutdown();
            }
            if (orderManager != null)
            {
                orderManager.Dispose();
            }

            // Discard any invalid mods, set RA as default
            var mm = mods.Where(m => Mod.AllMods.ContainsKey(m)).ToArray();

            if (mm.Length == 0)
            {
                mm = new[] { "ra" }
            }
            ;
            Console.WriteLine("Loading mods: {0}", mm.JoinWith(","));
            Settings.Game.Mods = mm;

            Sound.StopMusic();
            Sound.StopVideo();
            Sound.Initialize();

            modData = new ModData(mm);
            Renderer.InitializeFonts(modData.Manifest);
            modData.InitializeLoaders();

            PerfHistory.items["render"].hasNormalTick         = false;
            PerfHistory.items["batches"].hasNormalTick        = false;
            PerfHistory.items["render_widgets"].hasNormalTick = false;
            PerfHistory.items["render_flip"].hasNormalTick    = false;

            JoinLocal();
            viewport = new Viewport(new int2(Renderer.Resolution), Rectangle.Empty, Renderer);

            if (Game.Settings.Server.Dedicated)
            {
                while (true)
                {
                    Game.Settings.Server.Map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);
                    Game.Settings.Save();
                    Game.CreateServer(new ServerSettings(Game.Settings.Server));
                    while (true)
                    {
                        System.Threading.Thread.Sleep(100);

                        if ((server.State == Server.ServerState.GameStarted) &&
                            (server.conns.Count <= 1))
                        {
                            Console.WriteLine("No one is playing, shutting down...");
                            server.Shutdown();
                            break;
                        }
                    }
                    if (Game.Settings.Server.DedicatedLoop)
                    {
                        Console.WriteLine("Starting a new server instance...");
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
                System.Environment.Exit(0);
            }
            else
            {
                modData.LoadScreen.StartGame();
                Settings.Save();
            }
        }
Example #4
0
        public static void InitializeMod(string mod, Arguments args)
        {
            // Clear static state if we have switched mods
            LobbyInfoChanged       = () => { };
            ConnectionStateChanged = om => { };
            BeforeGameStart        = () => { };
            OnRemoteDirectConnect  = (a, b) => { };
            delayedActions         = new ActionQueue();

            Ui.ResetAll();

            if (worldRenderer != null)
            {
                worldRenderer.Dispose();
            }
            worldRenderer = null;
            if (server != null)
            {
                server.Shutdown();
            }
            if (OrderManager != null)
            {
                OrderManager.Dispose();
            }

            if (ModData != null)
            {
                ModData.Dispose();
            }
            ModData = null;

            // Fall back to default if the mod doesn't exist
            if (!ModMetadata.AllMods.ContainsKey(mod))
            {
                mod = new GameSettings().Mod;
            }

            Console.WriteLine("Loading mod: {0}", mod);
            Settings.Game.Mod = mod;

            Sound.StopVideo();
            Sound.Initialize();

            ModData = new ModData(mod, !Settings.Server.Dedicated);
            ModData.InitializeLoaders();
            if (!Settings.Server.Dedicated)
            {
                Renderer.InitializeFonts(ModData.Manifest);
            }

            using (new PerfTimer("LoadMaps"))
                ModData.MapCache.LoadMaps();

            if (Cursor != null)
            {
                Cursor.Dispose();
            }

            if (Settings.Graphics.HardwareCursors)
            {
                try
                {
                    Cursor = new HardwareCursor(ModData.CursorProvider);
                }
                catch (Exception e)
                {
                    Log.Write("debug", "Failed to initialize hardware cursors. Falling back to software cursors.");
                    Log.Write("debug", "Error was: " + e.Message);

                    Console.WriteLine("Failed to initialize hardware cursors. Falling back to software cursors.");
                    Console.WriteLine("Error was: " + e.Message);

                    Cursor = new SoftwareCursor(ModData.CursorProvider);
                    Settings.Graphics.HardwareCursors = false;
                }
            }
            else
            {
                Cursor = new SoftwareCursor(ModData.CursorProvider);
            }

            PerfHistory.Items["render"].HasNormalTick         = false;
            PerfHistory.Items["batches"].HasNormalTick        = false;
            PerfHistory.Items["render_widgets"].HasNormalTick = false;
            PerfHistory.Items["render_flip"].HasNormalTick    = false;

            JoinLocal();

            if (Settings.Server.Dedicated)
            {
                while (true)
                {
                    Settings.Server.Map = WidgetUtils.ChooseInitialMap(Settings.Server.Map);
                    Settings.Save();
                    CreateServer(new ServerSettings(Settings.Server));
                    while (true)
                    {
                        Thread.Sleep(100);

                        if (server.State == Server.ServerState.GameStarted && server.Conns.Count < 1)
                        {
                            Console.WriteLine("No one is playing, shutting down...");
                            server.Shutdown();
                            break;
                        }
                    }

                    if (Settings.Server.DedicatedLoop)
                    {
                        Console.WriteLine("Starting a new server instance...");
                        ModData.MapCache.LoadMaps();
                        continue;
                    }

                    break;
                }

                Environment.Exit(0);
            }
            else
            {
                ModData.LoadScreen.StartGame(args);
            }
        }