public DLG_AuraModifier(Aura.Modifier mod, Dictionary <int, Spell> spells) { InitializeComponent(); cmb_SpellID.BeginUpdate(); cmb_SpellID.Items.Add(-1); foreach (Spell spell in spells.Values) { cmb_SpellID.Items.Add(spell.id); } cmb_SpellID.EndUpdate(); cmb_SpellID.Text = mod.spellID.ToString(); cmb_Mod.Text = mod.mod.ToString(); num_Value.Value = (Decimal)mod.value; }
void LoadAuraData() { loadedAuras = new Dictionary <int, Aura>(); string fileName = Application.dataPath + "/Data/Auras.dat"; if (File.Exists(fileName)) { Debug.Log("Loading auras from .dat file"); BinaryFormatter format = new BinaryFormatter(); FileStream load = File.Open(fileName, FileMode.Open); loadedAuras = (Dictionary <int, Aura>)format.Deserialize(load); load.Close(); LoadLocalizedText("enUS"); } else { fileName = Application.dataPath + "/Development/Auras.xml"; XmlReader fileReader = XmlReader.Create(fileName); fileReader.MoveToContent(); while (fileReader.ReadToFollowing("aura")) { Aura newAura = new Aura(); newAura.id = int.Parse(fileReader.GetAttribute("id")); fileReader.ReadToDescendant("duration"); newAura.duration = float.Parse(fileReader.ReadString()); fileReader.ReadToNextSibling("oneUse"); newAura.consumedOnUse = bool.Parse(fileReader.ReadString()); fileReader.ReadToNextSibling("isDebuff"); newAura.isDebuff = bool.Parse(fileReader.ReadString()); fileReader.ReadToNextSibling("mods"); string[] mods = fileReader.ReadString().Split('/'); foreach (string mod in mods) { Aura.Modifier newMod = new Aura.Modifier(); string[] innerMod = mod.Split(':'); newMod.spellID = int.Parse(innerMod[0]); newMod.mod = (AuraMods)System.Enum.Parse(typeof(AuraMods), innerMod[1]); newMod.value = float.Parse(innerMod[2]); newAura.mods.Add(newMod); } fileReader.ReadToNextSibling("texture"); newAura.texture = fileReader.ReadString(); loadedAuras.Add(newAura.id, newAura); } fileReader.Close(); LoadLocalizedText("enUS"); // TODO: Store locale to be loaded via UserPref settings SaveAuraData(); } }
private void AUR_Modifiers_DoubleClick(object sender, EventArgs e) { DLG_AuraModifier dialog = new DLG_AuraModifier(auras[lst_Auras.SelectedIndex].mods[AUR_Mods.SelectedIndex], spells); if (dialog.ShowDialog() == DialogResult.OK) { AuraMods modifier; if (Enum.TryParse(dialog.Modifier, out modifier)) { Aura.Modifier newMod = auras[lst_Auras.SelectedIndex].mods[AUR_Mods.SelectedIndex]; newMod.mod = modifier; newMod.spellID = dialog.SpellID; newMod.value = (float)dialog.Value; auras[lst_Auras.SelectedIndex].mods[AUR_Mods.SelectedIndex] = newMod; AUR_Mods.Items[AUR_Mods.SelectedIndex] = newMod.spellID + ":" + newMod.mod.ToString() + ":" + newMod.value; dialog.Close(); AUR_Mods.Update(); } else { MessageBox.Show("Invalid modifier type.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }