private void SaveHouseButton_OnButtonClick(UIElement button)
        {
            if (vm == null)
            {
                return;
            }

            var exporter = new VMWorldExporter();

            exporter.SaveHouse(vm, lotName);
            var marshal = vm.Save();

            if (!Directory.Exists(Path.Combine(FSOEnvironment.UserDir, "Houses/")))
            {
                Directory.CreateDirectory(Path.Combine(FSOEnvironment.UserDir, "Houses/"));
            }


            using (var output = new FileStream(Path.Combine(FSOEnvironment.UserDir, "Houses/house_00.fsov"), FileMode.Create))
            {
                marshal.SerializeInto(new BinaryWriter(output));
            }
            if (vm.GlobalLink != null)
            {
                ((VMTSOGlobalLinkStub)vm.GlobalLink).Database.Save();
            }
        }
Beispiel #2
0
        private void SaveHouseButton_OnButtonClick(UIElement button)
        {
            int houses = 0;


            DirectoryInfo HousesDir;

            if (vm == null)
            {
                return;
            }

            if (!Directory.Exists(Path.Combine(FSOEnvironment.UserDir, "Houses/")))
            {
                HousesDir = Directory.CreateDirectory(Path.Combine(FSOEnvironment.UserDir, "Houses/"));
            }

            HousesDir = new DirectoryInfo(Path.Combine(FSOEnvironment.UserDir, "Houses/"));

            foreach (FileInfo file in HousesDir.GetFiles())
            {
                if (file.Extension == ".xml")
                {
                    houses += 1;
                }
            }

            var exporter = new VMWorldExporter();

            if (lotName == "empty_lot")
            {
                lotName = "house0" + houses;
            }

            string housePath = Path.Combine(FSOEnvironment.UserDir, "Houses/", lotName);

            exporter.SaveHouse(vm, housePath + ".xml");
            var marshal = vm.Save();

            // if (marshal != null)
            //using (var output = new FileStream(Path.Combine(FSOEnvironment.UserDir, "Houses/" + lotName + ".fsov"), FileMode.Create))
            //  {
            //    marshal.SerializeInto(new BinaryWriter(output));
            //}

            Texture2D lotThumb = World.GetLotThumb(GameFacade.GraphicsDevice);

            if (lotThumb != null)
            {
                using (var output = File.Open(housePath + ".png", FileMode.OpenOrCreate))
                {
                    lotThumb.SaveAsPng(output, lotThumb.Width, lotThumb.Height);
                }
            }


            //if (vm.GlobalLink != null) ((VMTSOGlobalLinkStub)vm.GlobalLink).Database.Save();
        }
Beispiel #3
0
        private void SaveHouseButton_OnButtonClick(UIElement button)
        {
            if (vm == null)
            {
                return;
            }


            var exporter = new VMWorldExporter();

            exporter.SaveHouse(vm, GameFacade.GameFilePath("housedata/blueprints/house_00.xml"));
        }
Beispiel #4
0
        private void SaveHouseButton_OnButtonClick(UIElement button)
        {
            if (vm == null)
            {
                return;
            }

            var exporter = new VMWorldExporter();

            Directory.CreateDirectory(Path.Combine(FSOEnvironment.UserDir, "Blueprints/cas.xml"));
            exporter.SaveHouse(vm, Path.Combine(FSOEnvironment.UserDir, "Blueprints/cas.xml"));
            var marshal = vm.Save();

            Directory.CreateDirectory(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/"));
            using (var output = new FileStream(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/cas.fsov"), FileMode.Create))
            {
                marshal.SerializeInto(new BinaryWriter(output));
            }
        }
Beispiel #5
0
        private void SaveLot()
        {
            LotSaveDialog = new UIAlert(new UIAlertOptions
            {
                Title     = "Save Lot",
                Message   = "Enter a filename to save this lot with. It will save locally to Content/LocalHouse, where it can be used in sandbox mode.",
                TextEntry = true,
                Width     = 500,
                Buttons   = new UIAlertButton[]
                {
                    new UIAlertButton(UIAlertButtonType.Cancel, (b) => { UIScreen.RemoveDialog(LotSaveDialog); LotSaveDialog = null; }),
                    new UIAlertButton(UIAlertButtonType.OK, (b) =>
                    {
                        try {
                            var exporter = new VMWorldExporter();
                            exporter.SaveHouse(vm, Path.Combine(FSOEnvironment.UserDir, ("Blueprints/" + LotSaveDialog.ResponseText + ".xml")));
                            var marshal = vm.Save();
                            Directory.CreateDirectory(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/"));
                            using (var output = new FileStream(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/" + LotSaveDialog.ResponseText + ".fsov"), FileMode.Create))
                            {
                                marshal.SerializeInto(new BinaryWriter(output));
                            }
                            if (vm.GlobalLink != null)
                            {
                                ((VMTSOGlobalLinkStub)vm.GlobalLink).Database.Save();
                            }

                            UIScreen.GlobalShowAlert(new UIAlertOptions {
                                Message = "Save successful!"
                            }, true);
                        } catch
                        {
                            UIScreen.GlobalShowAlert(new UIAlertOptions {
                                Message = "Lot failed to save. You may need to run the game as administrator."
                            }, true);
                        }
                        UIScreen.RemoveDialog(LotSaveDialog); LotSaveDialog = null;
                    })
                }
            });
            LotSaveDialog.ResponseText = "house_00";
            UIScreen.GlobalShowDialog(LotSaveDialog, true);
        }
Beispiel #6
0
        private void SaveHouseButton_OnButtonClick(UIElement button)
        {
            if (vm == null)
            {
                return;
            }

            var exporter = new VMWorldExporter();

            exporter.SaveHouse(vm, GameFacade.GameFilePath("housedata/blueprints/house_00.xml"));
            var marshal = vm.Save();

            Directory.CreateDirectory(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/"));
            using (var output = new FileStream(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/house_00.fsov"), FileMode.Create))
            {
                marshal.SerializeInto(new BinaryWriter(output));
            }
            if (vm.GlobalLink != null)
            {
                ((VMTSOGlobalLinkStub)vm.GlobalLink).Database.Save();
            }
        }
Beispiel #7
0
        public void SaveLot()
        {
            string filename = Path.GetFileName(Settings.Default.DebugLot);
            var    exporter = new VMWorldExporter();

            exporter.SaveHouse(state, Path.Combine(Settings.Default.GamePath + "housedata/blueprints/" + filename));

            var marshal = state.Save();

            Directory.CreateDirectory("Content/LocalHouse/");
            var extensionless = filename.Substring(0, filename.Length - 4);

            //backup old state
            try { File.Copy("Content/LocalHouse/" + extensionless + ".fsov", "Content/LocalHouse/" + extensionless + "_backup.fsov", true); }
            catch (Exception) { }

            using (var output = new FileStream("Content/LocalHouse/" + extensionless + ".fsov", FileMode.Create))
            {
                marshal.SerializeInto(new BinaryWriter(output));
            }

            ((VMTSOGlobalLinkStub)state.GlobalLink).Database.Save();
        }