public void CompleteBestiary() { if (MessageBox.Show( "This will completely replace your currently loaded world Bestiary and Kill Tally with a completed bestiary. Continue?", "Complete Bestiary?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) != MessageBoxResult.Yes) { return; } var world = CurrentWorld; // make a backup var bestiary = world.Bestiary.Copy(CurrentWorld.Version); var killTally = world.KilledMobs.ToArray(); try { ErrorLogging.TelemetryClient?.TrackEvent(nameof(CompleteBestiary)); World.CompleteBestiary(world); TallyCount = KillTally.LoadTally(CurrentWorld); } catch (Exception ex) { world.Bestiary = bestiary; world.KilledMobs.Clear(); world.KilledMobs.AddRange(killTally); MessageBox.Show($"Error completing Bestiary data. Your current bestiary has been restored.\r\n{ex.Message}"); } }
private void ImportKillsAndBestiary() { if (MessageBox.Show( "This will completely replace your currently loaded world Bestiary and Kill Tally with selected file's bestiary. Continue?", "Load Bestiary?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) != MessageBoxResult.Yes) { return; } var ofd = new OpenFileDialog(); ofd.Filter = "Terraria World File|*.wld"; ofd.DefaultExt = "Terraria World File| *.wld"; ofd.Title = "Import Bestiary and Kills from World File"; ofd.InitialDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"My Games\Terraria\Schematics"); if (!Directory.Exists(ofd.InitialDirectory)) { Directory.CreateDirectory(ofd.InitialDirectory); } ofd.Multiselect = false; if ((bool)ofd.ShowDialog()) { var world = CurrentWorld; // make a backup var bestiary = world.Bestiary.Copy(CurrentWorld.Version); var killTally = world.KilledMobs.ToArray(); try { ErrorLogging.TelemetryClient?.TrackEvent(nameof(ImportKillsAndBestiary)); World.ImportKillsAndBestiary(world, ofd.FileName); TallyCount = KillTally.LoadTally(CurrentWorld); } catch (Exception ex) { world.Bestiary = bestiary; world.KilledMobs.Clear(); world.KilledMobs.AddRange(killTally); MessageBox.Show($"Error importing Bestiary data from {ofd.FileName}. Your current bestiary has been restored.\r\n{ex.Message}"); } } }
private void TallyCountSave() { if (CurrentWorld == null) { return; } var sfd = new SaveFileDialog(); sfd.DefaultExt = "Text File|*.txt"; sfd.Filter = "Text Files|*.txt"; sfd.FileName = CurrentWorld.Title + " Tally.txt"; sfd.Title = "Save world analysis."; sfd.OverwritePrompt = true; if (sfd.ShowDialog() == true) { KillTally.SaveTally(CurrentWorld, sfd.FileName); } }
private void GetTallyCount() { TallyCount = KillTally.LoadTally(CurrentWorld); }