Beispiel #1
0
 public static void Save(string file)
 {
     try
     {
         FileUtils.SaveBasicJson(Default, file);
     }
     catch (Exception exception)
     {
         Console.Error.WriteLine("Failed to save settings: {0}", exception.ToString());
         if (exception.InnerException != null)
         {
             Console.Error.WriteLine("Inner exception: {0}", exception.InnerException.ToString());
         }
     }
 }
Beispiel #2
0
 public static void Save(string file)
 {
     FileUtils.SaveBasicJson(Default, file);
 }
Beispiel #3
0
 public static void Save(string file)
 {
     FileUtils.SaveBasicJson(Mappings, file);
 }
Beispiel #4
0
        public override void Construct()
        {
            var bottomBar = AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.DockBottom,
                MinimumSize = new Point(Rect.Width - 128, 24)
            })
            ;

            bottomBar.AddChild(new Button()
            {
                Text        = "Back",
                OnClick     = (sender, args) => this.Close(),
                AutoLayout  = AutoLayout.DockLeft,
                MinimumSize = new Point(64, 24)
            });


            if (SoundManager.Mixer == null)
            {
                Text = "Error. Failed to load audio mixer :(";
                return;
            }

            bottomBar.AddChild(new Button()
            {
                Text    = "Save",
                OnClick = (sender, args) => {
                    try
                    {
                        FileUtils.SaveBasicJson(SoundManager.Mixer, AssetManager.ResolveContentPath(ContentPaths.mixer));
                    }
                    catch (Exception exception)
                    {
                        Console.Out.WriteLine(exception.ToString());
                        Root.ShowModalPopup(new Popup()
                        {
                            Text = "Failed to save audio mixer. This is a debug tool. Are you a dev?",
                        });
                    }
                },
                AutoLayout  = AutoLayout.DockRight,
                MinimumSize = new Point(64, 24)
            });


            var listView = AddChild(new WidgetListView()
            {
                AutoLayout  = AutoLayout.DockBottom,
                MinimumSize = new Point(Rect.Width - 128, 512),
                ItemHeight  = 24
            });

            foreach (var level in SoundManager.Mixer.Gains)
            {
                var row = listView.AddChild(new Widget()
                {
                    AutoLayout  = AutoLayout.DockTop,
                    MinimumSize = new Point(512, 24)
                });

                row.AddChild(new Widget()
                {
                    Text                = level.Key,
                    TextColor           = Color.Black.ToVector4(),
                    AutoLayout          = AutoLayout.DockLeft,
                    TextVerticalAlign   = VerticalAlign.Center,
                    TextHorizontalAlign = HorizontalAlign.Right,
                    MinimumSize         = new Point(256, 24)
                });

                KeyValuePair <string, SFXMixer.Levels> level1 = level;
                row.AddChild(new HorizontalFloatSlider()
                {
                    ScrollArea      = 1.0f,
                    ScrollPosition  = level.Value.Volume,
                    MinimumSize     = new Point(256, 24),
                    AutoLayout      = AutoLayout.DockLeft,
                    OnSliderChanged = (sender) =>
                    {
                        SFXMixer.Levels levels = SoundManager.Mixer.GetOrCreateLevels(level1.Key);
                        SoundManager.Mixer.SetLevels(level1.Key,
                                                     new SFXMixer.Levels()
                        {
                            RandomPitch = level1.Value.RandomPitch,
                            Volume      = (sender as HorizontalFloatSlider).ScrollPosition
                        });
                        if (MathFunctions.RandEvent(0.15f))
                        {
                            SoundManager.PlaySound(level1.Key);
                        }
                    }
                });
            }
            Layout();

            base.Construct();
        }
Beispiel #5
0
        public void Save()
        {
            var metaDataPath = Directory + ProgramData.DirChar + "meta.json";

            FileUtils.SaveBasicJson(this, metaDataPath);
        }
Beispiel #6
0
        public void Save()
        {
            var metaDataPath = Directory + System.IO.Path.DirectorySeparatorChar + "meta.json";

            FileUtils.SaveBasicJson(this, metaDataPath);
        }