OpenRA.Settings.Save C# (CSharp) Method

Save() public method

public Save ( ) : void
return void
        public void Save()
        {
            var root = new List<MiniYamlNode>();
            foreach (var kv in Sections)
                root.Add(new MiniYamlNode(kv.Key, FieldSaver.SaveDifferences(kv.Value, Activator.CreateInstance(kv.Value.GetType()))));

            root.WriteToFile(settingsFile);
        }

Usage Example

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();
        }
All Usage Examples Of OpenRA.Settings::Save