Beispiel #1
0
        public void WriteFile(string directory)
        {
            global::System.IO.Directory.CreateDirectory(directory);
            global::System.IO.Directory.CreateDirectory(directory + System.IO.Path.DirectorySeparatorChar + "Chunks");

            foreach (ChunkFile chunk in ChunkData)
            {
                var filename = directory + System.IO.Path.DirectorySeparatorChar + "Chunks" + System.IO.Path.DirectorySeparatorChar + chunk.ID.X + "_" + chunk.ID.Y + "_" + chunk.ID.Z + ".";
                FileUtils.SaveJSON(chunk, filename + ChunkFile.Extension);
            }

            FileUtils.SaveJSON(this.Metadata, directory + System.IO.Path.DirectorySeparatorChar + "Metadata." + MetaData.Extension);
            FileUtils.SaveJSON(this.PlayData, directory + System.IO.Path.DirectorySeparatorChar + "World." + PlayData.Extension);
        }
 public static void Save(string file)
 {
     try
     {
         FileUtils.SaveJSON(Default, file);
         Console.Out.WriteLine("Saving settings to {0} : {1}", file, GameSettings.Default.ToString());
     }
     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 #3
0
        public bool WriteFile(string filePath)
        {
            var worldFilePath = filePath + global::System.IO.Path.DirectorySeparatorChar + "world.png";
            var metaFilePath  = filePath + global::System.IO.Path.DirectorySeparatorChar + "meta.txt";

            // Write meta info
            MetaData.Version = Program.Version;
            FileUtils.SaveJSON(MetaData, metaFilePath);

            using (var texture = CreateSaveTexture())
                using (var stream = new System.IO.FileStream(worldFilePath, System.IO.FileMode.Create))
                    texture.SaveAsPng(stream, Settings.Width, Settings.Height);

            using (var texture = CreateScreenshot())
                using (var stream = new System.IO.FileStream(filePath + Path.DirectorySeparatorChar + "screenshot.png", System.IO.FileMode.Create))
                    texture.SaveAsPng(stream, Settings.Width, Settings.Height);

            return(true);
        }
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.SaveJSON(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 static void Save(string file)
 {
     FileUtils.SaveJSON(Mappings, file);
 }
Beispiel #6
0
        public void Save()
        {
            var metaDataPath = Directory + global::System.IO.Path.DirectorySeparatorChar + "meta.json";

            FileUtils.SaveJSON(this, metaDataPath);
        }