private void RenameSave_Click(object sender, EventArgs e) { if (listSaveStates.SelectedIndex < 0) { return; } var newSaveState = new NewSaveState(DialogAction.Rename, GetSaveNames(_categories[listCategories.SelectedIndex])); newSaveState.SaveStateName = _saveStates[listSaveStates.SelectedIndex].SaveStateName; newSaveState.ShowDialog(); if (newSaveState.DialogResult == DialogResult.OK) { var config = BlossomConfig.GetBlossomConfig(); var categoryName = _categories[listCategories.SelectedIndex].CategoryName; var originalSaveState = _categories[listCategories.SelectedIndex].SaveStates[listSaveStates.SelectedIndex]; _categories[listCategories.SelectedIndex].SaveStates[listSaveStates.SelectedIndex] = Helper.RenameSave(originalSaveState, categoryName, newSaveState.SaveStateName); _saveStates = new BindingList <SaveState>(_categories[listCategories.SelectedIndex].SaveStates); BindSaves(); } Helper.WriteSaveInfo(_categories); }
public ConfigForm() { InitializeComponent(); BlossomConfig.LoadConfig(); _config = BlossomConfig.GetBlossomConfig(); UpdateTextBoxes(); }
public static SaveState CreateSaveState(string categoryName, string saveStateName, string origAFilePath, string origBFilePath, string origCFilePath) { var config = BlossomConfig.GetBlossomConfig(); var shortenedCategory = new string(categoryName.Where(char.IsLetterOrDigit).ToArray()); var shortenedState = new string(saveStateName.Where(char.IsLetterOrDigit).ToArray()); var save = new SaveState() { SaveStateName = saveStateName, CategoryName = categoryName, FileAName = $@"{shortenedCategory}-{shortenedState}-A-{Guid.NewGuid()}.txt", FileBName = $@"{shortenedCategory}-{shortenedState}-B-{Guid.NewGuid()}.txt", FileCName = $@"{shortenedCategory}-{shortenedState}-C-{Guid.NewGuid()}.txt" }; try { File.Copy(origAFilePath, GetFullManagedSavePath(save.FileAName)); File.Copy(origBFilePath, GetFullManagedSavePath(save.FileBName)); File.Copy(origCFilePath, GetFullManagedSavePath(save.FileCName)); } catch (Exception) { } return(save); }
public static BlossomConfig GetBlossomConfig() { if (_blossomConfig == null) { _blossomConfig = new BlossomConfig(); LoadConfig(); } return(_blossomConfig); }
public static void DeleteSave(SaveState saveState) { var config = BlossomConfig.GetBlossomConfig(); try { File.Delete(GetFullManagedSavePath(saveState.FileAName)); File.Delete(GetFullManagedSavePath(saveState.FileBName)); File.Delete(GetFullManagedSavePath(saveState.FileCName)); } catch (Exception) { } }
public static void SaveConfig(BlossomConfig config) { if (config == null) { return; } var configText = JsonConvert.SerializeObject(config); try { File.WriteAllText(_configFile, configText); } catch (Exception) { } }
private void LoadSelectedSave_Click(object sender, EventArgs e) { var config = BlossomConfig.GetBlossomConfig(); var targetAPath = Path.Combine(config.OriginalSaveDirectory, $"{Helper.SaveFileBaseName}{_loadSlot}{Helper.AFileEnding}"); var targetBPath = Path.Combine(config.OriginalSaveDirectory, $"{Helper.SaveFileBaseName}{_loadSlot}{Helper.BFileEnding}"); var targetCPath = Path.Combine(config.OriginalSaveDirectory, $"{Helper.SaveFileBaseName}{_loadSlot}{Helper.CFileEnding}"); var selectedSave = _saveStates[listSaveStates.SelectedIndex]; try { File.Copy(Path.Combine(config.ManagedSaveDirectory, selectedSave.FileAName), targetAPath, true); File.Copy(Path.Combine(config.ManagedSaveDirectory, selectedSave.FileBName), targetBPath, true); File.Copy(Path.Combine(config.ManagedSaveDirectory, selectedSave.FileCName), targetCPath, true); } catch (Exception) { } }
private void BlossomSaves_Load(object sender, EventArgs e) { if (!Directory.Exists(Path.Combine(_basePath, "SaveData"))) { Directory.CreateDirectory(Path.Combine(_basePath, "SaveData")); } while (!BlossomConfig.BlossomConfigExists()) { var configForm = new ConfigForm(); configForm.ShowDialog(); } if (listCategories.Items.Count > 0) { listCategories.SelectedIndex = 0; } }
public static void LoadConfig() { if (File.Exists(_configFile)) { string configText = string.Empty; try { configText = File.ReadAllText(_configFile); } catch { } _blossomConfig = JsonConvert.DeserializeObject <BlossomConfig>(configText); } else { _blossomConfig = new BlossomConfig() { OriginalSaveDirectory = Path.Combine(_appDataPath, "Blossom Tales"), ManagedSaveDirectory = _saveDirectory }; } }
public static string GetOriginalSavePath(int saveSlotNumber, string fileLetter) { string ending; if (fileLetter.Equals("A", StringComparison.InvariantCultureIgnoreCase)) { ending = AFileEnding; } else if (fileLetter.Equals("B", StringComparison.InvariantCultureIgnoreCase)) { ending = BFileEnding; } else { ending = CFileEnding; } var config = BlossomConfig.GetBlossomConfig(); return(Path.Combine(config.OriginalSaveDirectory, $"{SaveFileBaseName}{saveSlotNumber}{ending}")); }
private void Save_Click(object sender, EventArgs e) { UpdateConifgObject(); BlossomConfig.SaveConfig(_config); Close(); }
public static string GetFullManagedSavePath(string managedSaveFileName) { var config = BlossomConfig.GetBlossomConfig(); return(Path.Combine(config.ManagedSaveDirectory, managedSaveFileName)); }