public void OnGameLoaded(object sender, PluginEventArgs e) { this.CurrentWSG = e.WTM.SaveData; }
public void OnGameLoaded(object sender, PluginEventArgs e) { CurrentWSG = e.WTM.SaveData; DoEchoTree(); this.Enabled = true; }
public void ReleasePlugin() { CurrentWSG = null; }
public void OnGameLoaded(object sender, PluginEventArgs e) { // Warning: Setting numeric up/down controls to values that are outside their min/max // range will cause an exception and crash the program. It is safest to use // Util.SetNumericUpDown() to set them since it will adjust the value to a valid value // if it is too high or low. CurrentWSG = e.WTM.SaveData; CharacterName.Text = CurrentWSG.CharacterName; Util.SetNumericUpDown(Level, CurrentWSG.Level); if (Level.Value != CurrentWSG.Level) { MessageBox.Show("The character's level was outside the acceptable range. It has been adjusted.\n\nOld: " + CurrentWSG.Level + "\nNew: " + (int)Level.Value); } Util.SetNumericUpDown(Experience, CurrentWSG.Experience); if (Experience.Value != CurrentWSG.Experience) { MessageBox.Show("The character's experience was outside the acceptable range. It has been adjusted.\n\nOld: " + CurrentWSG.Experience + "\nNew: " + (int)Experience.Value); } Util.SetNumericUpDown(SkillPoints, CurrentWSG.SkillPoints); if (SkillPoints.Value != CurrentWSG.SkillPoints) { MessageBox.Show("The character's skill point count was outside the acceptable range. It has been adjusted.\n\nOld: " + CurrentWSG.SkillPoints + "\nNew: " + (int)SkillPoints.Value); } if (CurrentWSG.FinishedPlaythrough1 == 0) { PT2Unlocked.SelectedIndex = 0; } else { PT2Unlocked.SelectedIndex = 1; } // No message when cash is adjusted because it will likely have to be changed on // every load for people who exceed the limit. The spam would be annoying. if (CurrentWSG.Cash < 0) { Util.SetNumericUpDown(Cash, int.MaxValue); } else { Util.SetNumericUpDown(Cash, CurrentWSG.Cash); } Util.SetNumericUpDown(BackpackSpace, CurrentWSG.BackpackSize); if (BackpackSpace.Value != CurrentWSG.BackpackSize) { MessageBox.Show("The character's backpack capacity was outside the acceptable range. It has been adjusted.\n\nOld: " + CurrentWSG.BackpackSize + "\nNew: " + (int)BackpackSpace.Value); } Util.SetNumericUpDown(EquipSlots, CurrentWSG.EquipSlots); Util.SetNumericUpDown(SaveNumber, CurrentWSG.SaveNumber); UI_UpdateCurrentLocationComboBox(CurrentWSG.CurrentLocation); if (!GlobalSettings.customCharacters.ContainsValue("gd_Roland.Character.CharacterClass_Roland")) { foreach (var character in defaultCharacters) { GlobalSettings.customCharacters.Add(character.Key, character.Value); } } string possibleCharacter = "Unknown"; // Some fun string handling to detect a [hopefully] properly formatted character name. // Only do this string handling if it's not a default class. if (!defaultCharacters.ContainsValue(CurrentWSG.Class)) { try { possibleCharacter = Regex.Split(CurrentWSG.Class, "gd_", RegexOptions.IgnoreCase)[1].Split('.')[0]; } catch (IndexOutOfRangeException) { possibleCharacter = CurrentWSG.Class.Split(new string[] { "." }, StringSplitOptions.None)[0]; } if (possibleCharacter == "Unknown") { Class.Text = "Unknown"; } else { if (!GlobalSettings.customCharacters.Keys.Contains(possibleCharacter) && !GlobalSettings.customCharacters.Values.Contains(CurrentWSG.Class)) { GlobalSettings.customCharacters.Add(possibleCharacter, CurrentWSG.Class); } } } // This'll select our current class now that it's been added. foreach (var character in GlobalSettings.customCharacters) { // No duplicates. if (!Class.Items.Contains(character.Key)) { Class.Items.Add(character.Key); } // This'll select our current class now that it's been added. if (character.Value == CurrentWSG.Class) { Class.SelectedIndex = Class.Items.IndexOf(character.Key); } } // If DLC section 1 is not present then the bank does not exist, so disable the // control to prevent the user from editing its size. labelGeneralBankSpace.Enabled = CurrentWSG.DLC.HasSection1; BankSpace.Enabled = CurrentWSG.DLC.HasSection1; if (CurrentWSG.DLC.HasSection1) { Util.SetNumericUpDown(BankSpace, CurrentWSG.DLC.BankSize); if (BankSpace.Value != CurrentWSG.DLC.BankSize) { MessageBox.Show("The character's bank capacity was outside the acceptable range. It has been adjusted.\n\nOld: " + CurrentWSG.BackpackSize + "\nNew: " + (int)BackpackSpace.Value); } } else { Util.SetNumericUpDown(BankSpace, 0); } DoWindowTitle(); Application.DoEvents(); DoLocationTree(); GlobalSettings.Save(); this.Enabled = true; }
public void ReleasePlugin() { CurrentWSG = null; EchoesXml = null; }
public void ReleasePlugin() { CurrentWSG = null; LocationsXml = null; }
public void ReleasePlugin() { CurrentWSG = null; QuestsXml = null; }
public void MergeFromSaveQuests(string filename, int index) { WillowSaveGame OtherSave = new WillowSaveGame(); OtherSave.LoadWsg(filename); if (OtherSave.NumberOfQuestLists - 1 < index) { return; } WillowSaveGame.QuestTable qtOther = OtherSave.QuestLists[index]; WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[index]; QuestTree.BeginUpdate(); foreach (WillowSaveGame.QuestEntry qe in OtherSave.QuestLists[index].Quests) { string name = qe.Name; int progress = qe.Progress; // Check to see if the quest is already in the list QuestSearchKey = name; int prevIndex = qt.Quests.FindIndex(QuestSearchByName); if (prevIndex != -1) { // This quest entry exists in both lists. If the progress is // not greater then don't do anything with it. WillowSaveGame.QuestEntry old = qt.Quests[prevIndex]; if (progress < old.Progress) { continue; } if (progress == old.Progress) { // If the progress of the quest is the same, there may be // individual objectives that don't have the same progress // so check and update them. int objectiveCount = qe.NumberOfObjectives; // The number of objectives should be the same with the same // level of progress. If they aren't then there's something // wrong so just ignore the new quest and keep the old. if (objectiveCount != old.NumberOfObjectives) { continue; } for (int i = 0; i < objectiveCount; i++) { int objectiveProgress = old.Objectives[i].Progress; if (qe.Objectives[i].Progress < objectiveProgress) { qe.Objectives[i].Progress = objectiveProgress; } } } // This quest progress is further advanced than the existing one // so replace the existing one in the list. qt.Quests[prevIndex] = qe; // The quest doesn't need to be added to the quest list since we // modified an existing entry. The tree view doesn't need to be // changed because the name and text should still be the same. continue; } // Add the quest entry to the quest list qt.Quests.Add(qe); qt.TotalQuests++; // Add the quest to the tree view ColoredTextNode treeNode = new ColoredTextNode(); treeNode.Tag = qe.Name; treeNode.Text = QuestsXml.XmlReadValue(qe.Name, "MissionName"); if (treeNode.Text == "") { treeNode.Text = "(" + treeNode.Tag as string + ")"; } QuestTree.Root.Children[index].AddNode(treeNode); } QuestTree.EndUpdate(); // In case the operation modified the currently selected quest, refresh // the quest group panel by signalizing the selection changed event. QuestTree_SelectionChanged(null, null); }
private void ImportFromSaveQuests_Click(object sender, EventArgs e) { int index = GetSelectedQuestList(); if (index == -1) { MessageBox.Show("Select a playthrough to import to first."); return; } Util.WTOpenFileDialog tempOpen = new Util.WTOpenFileDialog("sav", ""); if (tempOpen.ShowDialog() == DialogResult.OK) { WillowSaveGame OtherSave = new WillowSaveGame(); try { OtherSave.LoadWsg(tempOpen.FileName()); } catch { return; } if (OtherSave.NumberOfQuestLists - 1 < index) { MessageBox.Show("This quest list does not exist in the other savegame file."); return; } // Note that when you set lists equal to one another like this it doesn't copy // the elements, only the pointer to the list. This is only safe here because // OtherSave will be disposed of right away and not modify the values. If OtherSave // was being used actively then a new copy of all the elements in the quest list // would have to be made or else changes to one would affect the quest // list of the other. // Replace the old entries in the quest table with the new ones CurrentWSG.QuestLists[index] = OtherSave.QuestLists[index]; WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[index]; QuestTree.BeginUpdate(); TreeNodeAdv parent = QuestTree.Root.Children[index]; // Remove the old entries from the tree view TreeNodeAdv[] children = parent.Children.ToArray(); foreach (TreeNodeAdv child in children) { child.Remove(); } // Add the new entries to the tree view foreach (WillowSaveGame.QuestEntry qe in qt.Quests) { string nodeName = qe.Name; ColoredTextNode node = new ColoredTextNode(); node.Tag = nodeName; node.Text = QuestsXml.XmlReadValue(nodeName, "MissionName"); if (node.Text == "") { node.Text = "(" + node.Tag as string + ")"; } parent.AddNode(node); } QuestTree.EndUpdate(); } }
public void OnGameLoaded(object sender, PluginEventArgs e) { // Warning: Setting numeric up/down controls to values that are outside their min/max // range will cause an exception and crash the program. It is safest to use // Util.SetNumericUpDown() to set them since it will adjust the value to a valid value // if it is too high or low. CurrentWSG = e.WTM.SaveData; CharacterName.Text = CurrentWSG.CharacterName; Util.SetNumericUpDown(Level, CurrentWSG.Level); if (Level.Value != CurrentWSG.Level) { MessageBox.Show("The character's level was outside the acceptable range. It has been adjusted.\n\nOld: " + CurrentWSG.Level + "\nNew: " + (int)Level.Value); } Util.SetNumericUpDown(Experience, CurrentWSG.Experience); if (Experience.Value != CurrentWSG.Experience) { MessageBox.Show("The character's experience was outside the acceptable range. It has been adjusted.\n\nOld: " + CurrentWSG.Experience + "\nNew: " + (int)Experience.Value); } Util.SetNumericUpDown(SkillPoints, CurrentWSG.SkillPoints); if (SkillPoints.Value != CurrentWSG.SkillPoints) { MessageBox.Show("The character's skill point count was outside the acceptable range. It has been adjusted.\n\nOld: " + CurrentWSG.SkillPoints + "\nNew: " + (int)SkillPoints.Value); } if (CurrentWSG.FinishedPlaythrough1 == 0) { PT2Unlocked.SelectedIndex = 0; } else { PT2Unlocked.SelectedIndex = 1; } // No message when cash is adjusted because it will likely have to be changed on // every load for people who exceed the limit. The spam would be annoying. if (CurrentWSG.Cash < 0) { Util.SetNumericUpDown(Cash, int.MaxValue); } else { Util.SetNumericUpDown(Cash, CurrentWSG.Cash); } Util.SetNumericUpDown(BackpackSpace, CurrentWSG.BackpackSize); if (BackpackSpace.Value != CurrentWSG.BackpackSize) { MessageBox.Show("The character's backpack capacity was outside the acceptable range. It has been adjusted.\n\nOld: " + CurrentWSG.BackpackSize + "\nNew: " + (int)BackpackSpace.Value); } Util.SetNumericUpDown(EquipSlots, CurrentWSG.EquipSlots); Util.SetNumericUpDown(SaveNumber, CurrentWSG.SaveNumber); UI_UpdateCurrentLocationComboBox(CurrentWSG.CurrentLocation); if (CurrentWSG.Class == "gd_Roland.Character.CharacterClass_Roland") { Class.SelectedIndex = 0; } else if (CurrentWSG.Class == "gd_lilith.Character.CharacterClass_Lilith") { Class.SelectedIndex = 1; } else if (CurrentWSG.Class == "gd_mordecai.Character.CharacterClass_Mordecai") { Class.SelectedIndex = 2; } else if (CurrentWSG.Class == "gd_Brick.Character.CharacterClass_Brick") { Class.SelectedIndex = 3; } // If DLC section 1 is not present then the bank does not exist, so disable the // control to prevent the user from editing its size. labelGeneralBankSpace.Enabled = CurrentWSG.Dlc.HasSection1; BankSpace.Enabled = CurrentWSG.Dlc.HasSection1; if (CurrentWSG.Dlc.HasSection1) { Util.SetNumericUpDown(BankSpace, CurrentWSG.Dlc.BankSize); if (BankSpace.Value != CurrentWSG.Dlc.BankSize) { MessageBox.Show("The character's bank capacity was outside the acceptable range. It has been adjusted.\n\nOld: " + CurrentWSG.BackpackSize + "\nNew: " + (int)BackpackSpace.Value); } } else { Util.SetNumericUpDown(BankSpace, 0); } DoWindowTitle(); Application.DoEvents(); DoLocationTree(); this.Enabled = true; }