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(); } }
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(); }
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); }
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("Content/LocalHouse/"); using (var output = new FileStream("Content/LocalHouse/house_00.fsov", FileMode.Create)) { marshal.SerializeInto(new BinaryWriter(output)); } if (vm.GlobalLink != null) { ((VMTSOGlobalLinkStub)vm.GlobalLink).Database.Save(); } }