public void SaveToTemp(bool savePersistentTemplate) { MapManager.Items.Save(); HorizonSave.Main.SetTerrainTiles(MapManager.Terrain.Tiles); HorizonSave.Main.SetAcreBytes(MapManager.Terrain.BaseAcres); // save.OutsideFieldTemplateUniqueId = (ushort)NUD_MapAcreTemplateOutside.Value; // save.MainFieldParamUniqueID = (ushort)NUD_MapAcreTemplateField.Value; HorizonSave.Main.Buildings = MapManager.Buildings; HorizonSave.Main.EventPlazaLeftUpX = MapManager.PlazaX; HorizonSave.Main.EventPlazaLeftUpZ = MapManager.PlazaY; HorizonSave.Save((uint)DateTime.Now.Ticks); if (savePersistentTemplate) { string persistentTemplateJson = JsonConvert.SerializeObject(PersistentTemplate); File.WriteAllText(PersistentTemplatePath, persistentTemplateJson); } else { File.Delete(PersistentTemplatePath); } }
private static void OpenSaveFile(string path) { var file = new HorizonSave(path); Open(file); var settings = Settings.Default; settings.LastFilePath = path; if (!settings.BackupPrompted) { settings.BackupPrompted = true; var line1 = string.Format(MessageStrings.MsgBackupCreateLocation, BackupFolderName); var line2 = MessageStrings.MsgBackupCreateQuestion; var prompt = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, line1, line2); settings.AutomaticBackup = prompt == DialogResult.Yes; } if (settings.AutomaticBackup) { BackupSaveFile(file, path, BackupPath); } settings.Save(); }
private static void LoadSpecialForms() { // For forms that require more complete initialization (dynamically added user controls) var path = Settings.Default.LastFilePath; var sav = new HorizonSave(path); using var editor = new Editor(sav); }
public Editor(HorizonSave file) { InitializeComponent(); SAV = file; LoadPlayers(); LoadMain(); Villagers = LoadVillagers(); }
private static void LoadSpecialForms() { // For forms that require more complete initialization (dynamically added user controls) var path = Settings.Default.LastFilePath; var sav = new HorizonSave(path); using var editor = new Editor(sav); using var items = new PlayerItemEditor<Item>(new[] {new Item()}, 1, 1); using var so = new SingleObjectEditor<object>(new object(), PropertySort.NoSort, false); }
private static void BackupSaveFile(HorizonSave file, string path, string bak) { Directory.CreateDirectory(bak); var dest = Path.Combine(bak, file.GetBackupFolderTitle()); if (!Directory.Exists(dest)) { FileUtil.CopyFolder(path, dest); } }
private static void OpenSaveFile(string path) { var file = new HorizonSave(path); Open(file); var settings = Settings.Default; settings.LastFilePath = path; settings.Save(); }
private static void Open(HorizonSave file) { bool sized = file.ValidateSizes(); if (!sized) { var prompt = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MessageStrings.MsgSaveDataSizeMismatch, MessageStrings.MsgAskContinue); if (prompt != DialogResult.Yes) { return; } } new Editor(file).Show(); }
public Editor(HorizonSave file) { InitializeComponent(); Menu_Language.SelectedIndex = 0; // en -- triggers translation // this.TranslateInterface(GameInfo.CurrentLanguage); SAV = file; LoadPlayers(); LoadMain(); Villagers = LoadVillagers(); Text = SAV.GetSaveTitle("NHSE"); }
private static void Open(HorizonSave file) { bool sized = file.ValidateSizes(); if (!sized) { const string sizeBad = "Save file sizes appear to be incorrect."; if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, sizeBad, "Continue?") != DialogResult.Yes) { return; } } new Editor(file).Show(); }
public Document(string originalFileName, string tempFolderPath, string title) { Title = title; OriginalFileName = originalFileName; this.TempFolderPath = tempFolderPath; HorizonSave = new HorizonSave(tempFolderPath); this.MapManager = new MapManager(HorizonSave.Main); if (File.Exists(PersistentTemplatePath)) { string persistentTemplateJson = File.ReadAllText(PersistentTemplatePath); PersistentTemplate = JsonConvert.DeserializeObject <PersistentTemplate>(persistentTemplateJson); } else { PersistentTemplate = new PersistentTemplate(); } }
public Editor(HorizonSave file) { InitializeComponent(); SAV = file; LoadPlayers(); Villagers = LoadVillagers(); var lang = Settings.Default.Language; var index = GameLanguage.GetLanguageIndex(lang); Menu_Language.SelectedIndex = index; // triggers translation // this.TranslateInterface(GameInfo.CurrentLanguage); Text = SAV.GetSaveTitle("NHSE"); }
private static void Open(string path) { try { var file = new HorizonSave(path); Open(file); var settings = Settings.Default; settings.LastFilePath = path; settings.Save(); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) #pragma warning restore CA1031 // Do not catch general exception types { WinFormsUtil.Error(ex.Message); } }
public void LoadSave(string folder) { try { _loaded = new HorizonSave(folder); _villagers = _loaded.Main.GetVillagers(); _designs = _loaded.Main.GetDesigns(); _designsTailor = _loaded.Main.GetDesignsTailor(); _pro = _loaded.Main.GetDesignsPRO(); StatusLabel.Text = folder; CopyFolder(folder, $"bak-{(uint)DateTime.Now.Ticks}"); PopulateSave(true); } catch (Exception e) { MessageBox.Show($"Could not open save: ${e.ToString()}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool OpenSaveFromFolder(string saveDirectory, out MainSave mainSave) { mainSave = null; var result = false; var mainDatPath = Path.Combine(saveDirectory, MainDat); var mainHeaderDatPath = Path.Combine(saveDirectory, MainHeaderDat); if (!File.Exists(mainDatPath)) { MessageBox.Show($"{mainDatPath} doesn't exist!", "Failed to open save file", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!File.Exists(mainHeaderDatPath)) { MessageBox.Show($"{mainHeaderDatPath} doesn't exist!", "Failed to open save file header", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { var mainSaveFile = new HorizonSave(saveDirectory); if (mainSaveFile.ValidateSizes()) { result = true; mainSave = mainSaveFile.Main; } else { MessageBox.Show("Save file sizes appear to be incorrect.", "Version doesn't match", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception e) { Logger.Error(e); MessageBox.Show(e.Message, "Failed to load save file", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return(result); }
public Editor(HorizonSave file) { InitializeComponent(); SAV = file; LoadAll(); }
private static void Open(HorizonSave file) => new Editor(file).Show();