private void Window_Loaded(object sender, RoutedEventArgs e) { txtLog.IsReadOnly = true; logMessage("Current save date: " + File.GetLastWriteTime(saveDirPath + "\\profile.sav").ToString()); //logMessage("Backups folder: " + backupDirPath); //logMessage("Save folder: " + saveDirPath); loadBackups(); bool autoBackup = Properties.Settings.Default.AutoBackup; chkAutoBackup.IsChecked = autoBackup; txtBackupMins.Text = Properties.Settings.Default.BackupMinutes.ToString(); txtBackupLimit.Text = Properties.Settings.Default.BackupLimit.ToString(); chkShowPossibleItems.IsChecked = Properties.Settings.Default.ShowPossibleItems; cmbMissingItemColor.Items.Add("Red"); cmbMissingItemColor.Items.Add("White"); if (Properties.Settings.Default.MissingItemColor.ToString().Equals("Red")) { cmbMissingItemColor.SelectedIndex = 0; } else { cmbMissingItemColor.SelectedIndex = 1; } cmbMissingItemColor.SelectionChanged += cmbMissingItemColorSelectionChanged; saveWatcher.EnableRaisingEvents = true; activeSave = new RemnantSave(saveDirPath); updateCurrentWorldAnalyzer(); checkForUpdate(); }
public RestoreDialog(MainWindow @mw, SaveBackup @sb, RemnantSave @as) { InitializeComponent(); this.txtSave.Content = $"Save Name:\t{sb.Name}\nSave Date:\t{sb.SaveDate.ToString(CultureInfo.CurrentCulture)}"; this._saveBackup = sb; this._activeSave = @as; }
//public SaveBackup(DateTime saveDate) public SaveBackup(string savePath) { this.save = new RemnantSave(savePath); this.saveData = new SaveData(); this.saveData.name = this.SaveDateTime.Ticks.ToString(); this.saveData.date = this.SaveDateTime; this.saveData.keep = false; }
public RemnantCharacter() { this.Archetype = ""; this.Inventory = new List <string>(); this.CampaignEvents = new List <RemnantWorldEvent>(); this.AdventureEvents = new List <RemnantWorldEvent>(); this.missingItems = new List <RemnantItem>(); this.save = null; }
private void loadBackups() { if (!Directory.Exists(backupDirPath)) { logMessage("Backups folder not found, creating..."); Directory.CreateDirectory(backupDirPath); } dataBackups.ItemsSource = null; listBackups.Clear(); Dictionary <long, string> backupNames = getSavedBackupNames(); Dictionary <long, bool> backupKeeps = getSavedBackupKeeps(); string[] files = Directory.GetDirectories(backupDirPath); SaveBackup activeBackup = null; for (int i = 0; i < files.Length; i++) { if (RemnantSave.ValidSaveFolder(files[i])) { SaveBackup backup = new SaveBackup(files[i]); if (backupNames.ContainsKey(backup.SaveDate.Ticks)) { backup.Name = backupNames[backup.SaveDate.Ticks]; } if (backupKeeps.ContainsKey(backup.SaveDate.Ticks)) { backup.Keep = backupKeeps[backup.SaveDate.Ticks]; } if (backupActive(backup)) { backup.Active = true; activeBackup = backup; } backup.Updated += saveUpdated; listBackups.Add(backup); } } dataBackups.ItemsSource = listBackups; logMessage("Backups found: " + listBackups.Count); if (listBackups.Count > 0) { logMessage("Last backup save date: " + listBackups[listBackups.Count - 1].SaveDate.ToString()); } if (activeBackup != null) { dataBackups.SelectedItem = activeBackup; } ActiveSaveIsBackedUp = (activeBackup != null); }
private void Window_Loaded(object sender, RoutedEventArgs e) { txtLog.IsReadOnly = true; logMessage("Current save date: " + File.GetLastWriteTime(saveDirPath + "\\profile.sav").ToString()); //logMessage("Backups folder: " + backupDirPath); //logMessage("Save folder: " + saveDirPath); loadBackups(); bool autoBackup = Properties.Settings.Default.AutoBackup; chkAutoBackup.IsChecked = autoBackup; txtBackupMins.Text = Properties.Settings.Default.BackupMinutes.ToString(); txtBackupLimit.Text = Properties.Settings.Default.BackupLimit.ToString(); saveWatcher.EnableRaisingEvents = true; activeSave = new RemnantSave(saveDirPath); updateCurrentWorldAnalyzer(); checkForUpdate(); }
public static List <RemnantCharacter> GetCharactersFromSave(RemnantSave remnantSave, CharacterProcessingMode mode) { List <RemnantCharacter> charData = new List <RemnantCharacter>(); try { string profileData = File.ReadAllText(remnantSave.SaveProfilePath); string[] characters = profileData.Split(new string[] { "/Game/Characters/Player/Base/Character_Master_Player.Character_Master_Player_C" }, StringSplitOptions.None); for (var i = 1; i < characters.Length; i++) { RemnantCharacter cd = new RemnantCharacter(); cd.Archetype = GameInfo.Archetypes["Undefined"]; Match archetypeMatch = new Regex(@"/Game/_Core/Archetypes/[a-zA-Z_]+").Match(characters[i - 1]); if (archetypeMatch.Success) { string archetype = archetypeMatch.Value.Replace("/Game/_Core/Archetypes/", "").Split('_')[1]; if (GameInfo.Archetypes.ContainsKey(archetype)) { cd.Archetype = GameInfo.Archetypes[archetype]; } else { cd.Archetype = archetype; } } cd.save = remnantSave; List <string> saveItems = new List <string>(); string charEnd = "Character_Master_Player_C"; string inventory = characters[i].Substring(0, characters[i].IndexOf(charEnd)); Regex rx = new Regex(@"/Items/Weapons(/[a-zA-Z0-9_]+)+/[a-zA-Z0-9_]+"); MatchCollection matches = rx.Matches(inventory); foreach (Match match in matches) { saveItems.Add(match.Value); } rx = new Regex(@"/Items/Armor/([a-zA-Z0-9_]+/)?[a-zA-Z0-9_]+"); matches = rx.Matches(inventory); foreach (Match match in matches) { saveItems.Add(match.Value); } rx = new Regex(@"/Items/Trinkets/(BandsOfCastorAndPollux/)?[a-zA-Z0-9_]+"); matches = rx.Matches(inventory); foreach (Match match in matches) { saveItems.Add(match.Value); } rx = new Regex(@"/Items/Mods/[a-zA-Z0-9_]+"); matches = rx.Matches(inventory); foreach (Match match in matches) { saveItems.Add(match.Value); } rx = new Regex(@"/Items/Traits/[a-zA-Z0-9_]+"); matches = rx.Matches(inventory); foreach (Match match in matches) { saveItems.Add(match.Value); } rx = new Regex(@"/Items/QuestItems(/[a-zA-Z0-9_]+)+/[a-zA-Z0-9_]+"); matches = rx.Matches(inventory); foreach (Match match in matches) { saveItems.Add(match.Value); } rx = new Regex(@"/Quests/[a-zA-Z0-9_]+/[a-zA-Z0-9_]+"); matches = rx.Matches(inventory); foreach (Match match in matches) { saveItems.Add(match.Value); } rx = new Regex(@"/Player/Emotes/Emote_[a-zA-Z0-9]+"); matches = rx.Matches(inventory); foreach (Match match in matches) { saveItems.Add(match.Value); } cd.Inventory = saveItems; charData.Add(cd); } if (mode == CharacterProcessingMode.All) { string[] saves = remnantSave.WorldSaves; for (int i = 0; i < saves.Length && i < charData.Count; i++) { charData[i].processSaveData(File.ReadAllText(saves[i])); } } } catch (IOException ex) { if (ex.Message.Contains("being used by another process")) { Console.WriteLine("Save file in use; waiting 0.5 seconds and retrying."); System.Threading.Thread.Sleep(500); charData = GetCharactersFromSave(remnantSave, mode); } } return(charData); }
public static List <RemnantCharacter> GetCharactersFromSave(RemnantSave remnantSave) { return(GetCharactersFromSave(remnantSave, CharacterProcessingMode.All)); }
private void doBackup() { try { int existingSaveIndex = -1; DateTime saveDate = File.GetLastWriteTime(saveDirPath + "\\profile.sav"); string backupFolder = backupDirPath + "\\" + saveDate.Ticks; if (!Directory.Exists(backupFolder)) { Directory.CreateDirectory(backupFolder); } else if (RemnantSave.ValidSaveFolder(backupFolder)) { for (int i = listBackups.Count - 1; i >= 0; i--) { if (listBackups[i].SaveDate.Ticks == saveDate.Ticks) { existingSaveIndex = i; break; } } } foreach (string file in Directory.GetFiles(saveDirPath)) { File.Copy(file, backupFolder + "\\" + System.IO.Path.GetFileName(file), true); } if (RemnantSave.ValidSaveFolder(backupFolder)) { Dictionary <long, string> backupNames = getSavedBackupNames(); Dictionary <long, bool> backupKeeps = getSavedBackupKeeps(); SaveBackup backup = new SaveBackup(backupFolder); if (backupNames.ContainsKey(backup.SaveDate.Ticks)) { backup.Name = backupNames[backup.SaveDate.Ticks]; } if (backupKeeps.ContainsKey(backup.SaveDate.Ticks)) { backup.Keep = backupKeeps[backup.SaveDate.Ticks]; } foreach (SaveBackup saveBackup in listBackups) { saveBackup.Active = false; } backup.Active = true; backup.Updated += saveUpdated; if (existingSaveIndex > -1) { listBackups[existingSaveIndex] = backup; } else { listBackups.Add(backup); } } checkBackupLimit(); dataBackups.Items.Refresh(); this.ActiveSaveIsBackedUp = true; logMessage($"Backup completed ({saveDate.ToString()})!"); } catch (IOException ex) { if (ex.Message.Contains("being used by another process")) { logMessage("Save file in use; waiting 0.5 seconds and retrying."); System.Threading.Thread.Sleep(500); doBackup(); } } }
private void loadBackups() { if (!Directory.Exists(backupDirPath)) { logMessage("Backups folder not found, creating..."); Directory.CreateDirectory(backupDirPath); } dataBackups.ItemsSource = null; listBackups.Clear(); Dictionary <long, string> backupNames = getSavedBackupNames(); Dictionary <long, bool> backupKeeps = getSavedBackupKeeps(); string[] files = Directory.GetDirectories(backupDirPath); SaveBackup activeBackup = null; /*DataGridTextColumn col1 = new DataGridTextColumn(); * col1.Header = "Name"; * col1.Binding = new Binding("Name"); * dataBackups.Columns.Add(col1); * DataGridTextColumn col2 = new DataGridTextColumn(); * col2.Header = "Date"; * col2.Binding = new Binding("SaveDate"); * dataBackups.Columns.Add(col2); * DataGridCheckBoxColumn col3 = new DataGridCheckBoxColumn(); * col3.Header = "Keep"; * col3.Binding = new Binding("Keep"); * dataBackups.Columns.Add(col3);*/ for (int i = 0; i < files.Length; i++) { if (RemnantSave.ValidSaveFolder(files[i])) { SaveBackup backup = new SaveBackup(files[i]); if (backupNames.ContainsKey(backup.SaveDate.Ticks)) { backup.Name = backupNames[backup.SaveDate.Ticks]; } if (backupKeeps.ContainsKey(backup.SaveDate.Ticks)) { backup.Keep = backupKeeps[backup.SaveDate.Ticks]; } if (backupActive(backup)) { backup.Active = true; activeBackup = backup; } backup.Updated += saveUpdated; listBackups.Add(backup); } } dataBackups.ItemsSource = listBackups; logMessage("Backups found: " + listBackups.Count); if (listBackups.Count > 0) { logMessage("Last backup save date: " + listBackups[listBackups.Count - 1].SaveDate.ToString()); } if (activeBackup != null) { dataBackups.SelectedItem = activeBackup; } SetActiveSaveIsBackedup(activeBackup != null); }