public PowerData(string iString) { if (string.IsNullOrEmpty(iString)) { this.IsValid = false; } else { this.Data = (IPower) new Power(); this.IsValid = this.Data.UpdateFromCSV(iString); this._csvString = iString; if (DatabaseAPI.GetPowersetByName(this.Data.GroupName + "." + this.Data.SetName) == null) { this.IsValid = false; } else { this.IsNew = true; for (int index = 0; index < DatabaseAPI.Database.Power.Length; ++index) { if (!string.IsNullOrEmpty(DatabaseAPI.Database.Power[index].FullName) && string.Equals(DatabaseAPI.Database.Power[index].FullName, this.Data.FullName, StringComparison.OrdinalIgnoreCase)) { this.IsNew = false; this.Index = index; break; } } } } }
public PowerData(string iString) { if (string.IsNullOrEmpty(iString)) { IsValid = false; } else { Data = new Power(); IsValid = Data.UpdateFromCSV(iString); _csvString = iString; if (DatabaseAPI.GetPowersetByName(Data.GroupName + "." + Data.SetName) == null) { IsValid = false; } else { IsNew = true; for (var index = 0; index < DatabaseAPI.Database.Power.Length; ++index) { if (string.IsNullOrEmpty(DatabaseAPI.Database.Power[index].FullName) || !string.Equals( DatabaseAPI.Database.Power[index].FullName, Data.FullName, StringComparison.OrdinalIgnoreCase)) { continue; } IsNew = false; Index = index; break; } } } }
public frmIncarnates(ref frmMain iParent) { Load += frmIncarnate_Load; myPowers = Array.Empty <IPower>(); Locked = false; buttonArray = new ImageButton[10]; InitializeComponent(); GenesisButton.ButtonClicked += GenesisButton_ButtonClicked; OmegaButton.ButtonClicked += OmegaButton_ButtonClicked; // PopInfo events PopInfo.MouseWheel += PopInfo_MouseWheel; PopInfo.MouseEnter += PopInfo_MouseEnter; StanceButton.ButtonClicked += StanceButton_ButtonClicked; VScrollBar1.Scroll += VScrollBar1_Scroll; VitaeButton.ButtonClicked += VitaeButton_ButtonClicked; alphaBtn.ButtonClicked += alphaBtn_ButtonClicked; destinyBtn.ButtonClicked += destinyBtn_ButtonClicked; hybridBtn.ButtonClicked += hybridBtn_ButtonClicked; ibClose.ButtonClicked += ibClose_ButtonClicked; interfaceBtn.ButtonClicked += interfaceBtn_ButtonClicked; judgementBtn.ButtonClicked += judgementBtn_ButtonClicked; lblLock.Click += lblLock_Click; loreBtn.ButtonClicked += loreBtn_ButtonClicked; Icon = Resources.reborn; myParent = iParent; myPowers = DatabaseAPI.GetPowersetByName("Alpha", Enums.ePowerSetType.Incarnate).Powers; FormClosing += FrmIncarnate_FormClosing; }
public frmIncarnate(ref frmMain iParent) { base.Load += this.frmIncarnate_Load; this.myPowers = new IPower[0]; this.Locked = false; this.buttonArray = new ImageButton[10]; this.InitializeComponent(); this.myParent = iParent; this.myPowers = DatabaseAPI.GetPowersetByName("Alpha", Enums.ePowerSetType.Incarnate).Powers; }
public frmIncarnate(ref frmMain iParent) { Load += frmIncarnate_Load; myPowers = new IPower[0]; Locked = false; buttonArray = new ImageButton[10]; InitializeComponent(); GenesisButton.ButtonClicked += GenesisButton_ButtonClicked; OmegaButton.ButtonClicked += OmegaButton_ButtonClicked; // PopInfo events PopInfo.MouseWheel += PopInfo_MouseWheel; PopInfo.MouseEnter += PopInfo_MouseEnter; StanceButton.ButtonClicked += StanceButton_ButtonClicked; VScrollBar1.Scroll += VScrollBar1_Scroll; VitaeButton.ButtonClicked += VitaeButton_ButtonClicked; alphaBtn.ButtonClicked += alphaBtn_ButtonClicked; destinyBtn.ButtonClicked += destinyBtn_ButtonClicked; hybridBtn.ButtonClicked += hybridBtn_ButtonClicked; ibClose.ButtonClicked += ibClose_ButtonClicked; interfaceBtn.ButtonClicked += interfaceBtn_ButtonClicked; judgementBtn.ButtonClicked += judgementBtn_ButtonClicked; lblLock.Click += lblLock_Click; // llLeft events LLLeft.ItemClick += llLeft_ItemClick; LLLeft.MouseEnter += llLeft_MouseEnter; LLLeft.ItemHover += llLeft_ItemHover; // llRight events LLRight.MouseEnter += llRight_MouseEnter; LLRight.ItemHover += llRight_ItemHover; LLRight.ItemClick += llRight_ItemClick; loreBtn.ButtonClicked += loreBtn_ButtonClicked; Name = nameof(frmIncarnate); ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(frmIncarnate)); Icon = (Icon)componentResourceManager.GetObject("$this.Icon"); myParent = iParent; myPowers = DatabaseAPI.GetPowersetByName("Alpha", Enums.ePowerSetType.Incarnate).Powers; FormClosing += FrmIncarnate_FormClosing; }
public static bool InterpretForumPost(string iPost) { var buildMode = MidsContext.Config.BuildMode; MidsContext.Config.BuildMode = Enums.dmModes.Normal; try { iPost = PowerNameFix(iPost); char[] chArray = { '`' }; iPost = iPost.Replace("\r\n", "`"); iPost = iPost.Replace("\n", "`"); iPost = iPost.Replace("\r", "`"); var haystack = iPost.Split(chArray); var num1 = 0; var dest = ""; MidsContext.Character.Reset(); var character = MidsContext.Character; var name = character.Name; character.Name = name; if (FindValue("Name", haystack, ref name) < 0) { MidsContext.Character.Name = "Unknown"; } if (SmartFind("Archetype", haystack, ref dest) < 0) { var index1 = -1; var num2 = DatabaseAPI.Database.Classes.Length - 1; for (var index2 = 0; index2 <= num2; ++index2) { if (FindString(DatabaseAPI.Database.Classes[index2].DisplayName, haystack) <= -1) { continue; } index1 = index2; break; } if (index1 <= -1) { throw new Exception("Archetype value not found."); } MidsContext.Character.Archetype = DatabaseAPI.Database.Classes[index1]; } else { MidsContext.Character.Archetype = DatabaseAPI.GetArchetypeByName(dest); } var index3 = -1; if (FindValue("Primary", haystack, ref dest) > -1) { index3 = DatabaseAPI.GetPowersetByName(dest, MidsContext.Character.Archetype.DisplayName).nID; } if (index3 < 0) { index3 = FindPowerSetAdvanced("Primary", Enums.ePowerSetType.Primary, MidsContext.Character.Archetype.Idx, haystack); if (index3 < 0) { throw new Exception("Primary Powerset value not found."); } } MidsContext.Character.Powersets[0] = DatabaseAPI.Database.Powersets[index3]; var index4 = -1; if (FindValue("Secondary", haystack, ref dest) > -1) { index4 = DatabaseAPI.GetPowersetByName(dest, MidsContext.Character.Archetype.DisplayName).nID; } if (index4 < 0) { index4 = FindPowerSetAdvanced("Secondary", Enums.ePowerSetType.Secondary, MidsContext.Character.Archetype.Idx, haystack); if (index4 < 0) { throw new Exception("Secondary Powerset value not found."); } } MidsContext.Character.Powersets[1] = DatabaseAPI.Database.Powersets[index4]; if ((MidsContext.Character.Powersets[0] == null) | (MidsContext.Character.Powersets[1] == null)) { throw new Exception("Powerset Name value couldn't be interpreted."); } var firstPower = FindFirstPower(haystack, MidsContext.Character.Archetype.Idx); if (firstPower < 0) { throw new Exception("First power entry couldn't be located."); } var sPowerLineArray = new sPowerLine[0]; var iPL = new sPowerLine(); var num3 = haystack.Length - 1; for (var index1 = firstPower; index1 <= num3; ++index1) { iPL.Assign(BreakLine(haystack[index1], MidsContext.Character.Archetype.Idx)); if (!((iPL.Level > 0) & (iPL.Power != ""))) { continue; } //sPowerLineArray = (sPowerLine[]) Utils.CopyArray(sPowerLineArray, new sPowerLine[sPowerLineArray.Length + 1]); Array.Copy(sPowerLineArray, new sPowerLine[sPowerLineArray.Length + 1], sPowerLineArray.Length + 1); sPowerLineArray[sPowerLineArray.Length - 1].Assign(iPL); } for (var index1 = 0; index1 <= sPowerLineArray.Length - 1; ++index1) { if (sPowerLineArray[index1].Level > num1) { num1 = sPowerLineArray[index1].Level; } var num2 = sPowerLineArray[index1].Slots.Length - 1; for (var index2 = 0; index2 <= num2; ++index2) { if (sPowerLineArray[index1].Slots[index2].Level > num1) { num1 = sPowerLineArray[index1].Slots[index2].Level; } } } MainModule.MidsController.Toon.Locked = true; if (sPowerLineArray.Length < 1) { return(false); } var num5 = sPowerLineArray.Length - 1; for (var index1 = 0; index1 <= num5; ++index1) { sPowerLineArray[index1].HistoryID = -1; var flag2 = false; var power = FindPower(sPowerLineArray[index1].Power, MidsContext.Character.Archetype.Idx); if (power.Powerset > -1 && DatabaseAPI.Database.Powersets[power.Powerset].SetType == Enums.ePowerSetType.Inherent) { flag2 = true; } if (power.Powerset < 0) { flag2 = true; } else if ((power.Powerset == MidsContext.Character.Powersets[1].nID) & (power.Power == 0)) { flag2 = true; } if (flag2) { continue; } MainModule.MidsController.Toon.RequestedLevel = sPowerLineArray[index1].Level - 1; MainModule.MidsController.Toon.BuildPower(power.Powerset, power.Power); switch (DatabaseAPI.Database.Powersets[power.Powerset].SetType) { case Enums.ePowerSetType.Pool: { var num2 = MainModule.MidsController.Toon.PoolLocked.Length - 2; for (var index2 = 0; index2 <= num2 && !(MainModule.MidsController.Toon.PoolLocked[index2] & (MidsContext.Character.Powersets[3 + index2].nID == power.Powerset)); ++index2) { if (MainModule.MidsController.Toon.PoolLocked[index2]) { continue; } MidsContext.Character.Powersets[3 + index2].nID = power.Powerset; MainModule.MidsController.Toon.PoolLocked[index2] = true; break; } break; } case Enums.ePowerSetType.Ancillary when !MainModule.MidsController.Toon.PoolLocked[ MainModule.MidsController.Toon.PoolLocked.Length - 1]: MidsContext.Character.Powersets[7].nID = power.Powerset; MainModule.MidsController.Toon.PoolLocked[ MainModule.MidsController.Toon.PoolLocked.Length - 1] = true; break; } } var num6 = sPowerLineArray.Length - 1; for (var index1 = 0; index1 <= num6; ++index1) { sPowerLineArray[index1].HistoryID = MidsContext.Character.CurrentBuild.FindInToonHistory( DatabaseAPI.NidFromUidPower(sPowerLineArray[index1].Power)); if (sPowerLineArray[index1].HistoryID == -1 && (index1 > -1) & (index1 < MidsContext.Character.CurrentBuild.Powers.Count)) { sPowerLineArray[index1].HistoryID = index1; } if (!((sPowerLineArray[index1].HistoryID > -1) & (sPowerLineArray[index1].Slots.Length > 0))) { continue; } if (sPowerLineArray[index1].Slots.Length > 1) { MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index1].HistoryID].Slots = new SlotEntry[sPowerLineArray[index1].Slots.Length - 1 + 1]; } var num2 = sPowerLineArray[index1].Slots.Length - 1; for (var index2 = 0; index2 <= num2; ++index2) { if (index2 >= MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index1].HistoryID].Slots .Length) { continue; } var slots = MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index1].HistoryID].Slots; var index5 = index2; slots[index5].Enhancement = new I9Slot(); slots[index5].FlippedEnhancement = new I9Slot(); slots[index5].Enhancement.Enh = MatchEnhancement(sPowerLineArray[index1].Slots[index2].Enh); slots[index5].Enhancement.Grade = Enums.eEnhGrade.SingleO; slots[index5].Enhancement.IOLevel = sPowerLineArray[index1].Slots[index2].Enh.IndexOf("-I:", StringComparison.Ordinal) <= -1 ? sPowerLineArray[index1].Slots[index2].Enh.IndexOf(":", StringComparison.Ordinal) <= -1 ? MidsContext.Config.I9.DefaultIOLevel : (int)Math.Round(Convert.ToInt32(sPowerLineArray[index1].Slots[index2].Enh .Substring(sPowerLineArray[index1].Slots[index2].Enh .IndexOf(":", StringComparison.Ordinal) + 1)) - 1.0) : (int)Math.Round(Convert.ToInt32(sPowerLineArray[index1].Slots[index2].Enh .Substring(sPowerLineArray[index1].Slots[index2].Enh .IndexOf(":", StringComparison.Ordinal) + 1)) - 1.0); slots[index5].Level = index2 != 0 ? sPowerLineArray[index1].Slots[index2].Level - 1 : MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index1].HistoryID].Level; if (slots[index5].Level < 0) { slots[index5].Level = 0; } } } MidsContext.Character.Validate(); MidsContext.Config.BuildMode = buildMode; return(true); } catch (Exception ex) { MidsContext.Config.BuildMode = buildMode; MessageBox.Show($"Unable to import from forum post:\r\n{ex.Message}\r\n\r\nCheck that the build was copied correctly.", @"Forum Import", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } }
public static bool InterpretForumPost(string iPost) { Enums.dmModes buildMode = MidsContext.Config.BuildMode; MidsContext.Config.BuildMode = Enums.dmModes.Dynamic; bool flag3; try { iPost = clsUniversalImport.PowerNameFix(iPost); char[] chArray = new char[] { '`' }; iPost = iPost.Replace("\r\n", "`"); iPost = iPost.Replace("\n", "`"); iPost = iPost.Replace("\r", "`"); string[] haystack = iPost.Split(chArray); int num = 0; string dest = ""; MidsContext.Character.Reset(null, 0); Character character = MidsContext.Character; string name = character.Name; character.Name = name; if (clsUniversalImport.FindValue("Name", haystack, ref name) < 0) { MidsContext.Character.Name = "Unknown"; } if (clsUniversalImport.SmartFind("Archetype", haystack, ref dest) < 0) { int index = -1; int num2 = DatabaseAPI.Database.Classes.Length - 1; for (int index2 = 0; index2 <= num2; index2++) { if (clsUniversalImport.FindString(DatabaseAPI.Database.Classes[index2].DisplayName, haystack) > -1) { index = index2; break; } } if (index <= -1) { throw new Exception("Archetype value not found."); } MidsContext.Character.Archetype = DatabaseAPI.Database.Classes[index]; } else { MidsContext.Character.Archetype = DatabaseAPI.GetArchetypeByName(dest); } int index3 = -1; if (clsUniversalImport.FindValue("Primary", haystack, ref dest) > -1) { index3 = DatabaseAPI.GetPowersetByName(dest, MidsContext.Character.Archetype.DisplayName).nID; } if (index3 < 0) { index3 = clsUniversalImport.FindPowerSetAdvanced("Primary", Enums.ePowerSetType.Primary, MidsContext.Character.Archetype.Idx, haystack); if (index3 < 0) { throw new Exception("Primary Powerset value not found."); } } MidsContext.Character.Powersets[0] = DatabaseAPI.Database.Powersets[index3]; index3 = -1; if (clsUniversalImport.FindValue("Secondary", haystack, ref dest) > -1) { index3 = DatabaseAPI.GetPowersetByName(dest, MidsContext.Character.Archetype.DisplayName).nID; } if (index3 < 0) { index3 = clsUniversalImport.FindPowerSetAdvanced("Secondary", Enums.ePowerSetType.Secondary, MidsContext.Character.Archetype.Idx, haystack); if (index3 < 0) { throw new Exception("Secondary Powerset value not found."); } } MidsContext.Character.Powersets[1] = DatabaseAPI.Database.Powersets[index3]; if (MidsContext.Character.Powersets[0] == null | MidsContext.Character.Powersets[1] == null) { throw new Exception("Powerset Name value couldn't be interpreted."); } int firstPower = clsUniversalImport.FindFirstPower(haystack, MidsContext.Character.Archetype.Idx); if (firstPower < 0) { throw new Exception("First power entry couldn't be located."); } clsUniversalImport.sPowerLine[] sPowerLineArray = new clsUniversalImport.sPowerLine[0]; clsUniversalImport.sPowerLine iPL = default(clsUniversalImport.sPowerLine); int num3 = haystack.Length - 1; for (int index4 = firstPower; index4 <= num3; index4++) { iPL.Assign(clsUniversalImport.BreakLine(haystack[index4], MidsContext.Character.Archetype.Idx)); if (iPL.Level > 0 & iPL.Power != "") { sPowerLineArray = (clsUniversalImport.sPowerLine[])Utils.CopyArray(sPowerLineArray, new clsUniversalImport.sPowerLine[sPowerLineArray.Length + 1]); sPowerLineArray[sPowerLineArray.Length - 1].Assign(iPL); } } int num4 = sPowerLineArray.Length - 1; for (int index4 = 0; index4 <= num4; index4++) { if (sPowerLineArray[index4].Level > num) { num = sPowerLineArray[index4].Level; } int num5 = sPowerLineArray[index4].Slots.Length - 1; for (int index5 = 0; index5 <= num5; index5++) { if (sPowerLineArray[index4].Slots[index5].Level > num) { num = sPowerLineArray[index4].Slots[index5].Level; } } } MainModule.MidsController.Toon.Locked = true; if (sPowerLineArray.Length < 1) { return(false); } int num6 = sPowerLineArray.Length - 1; for (int index4 = 0; index4 <= num6; index4++) { sPowerLineArray[index4].HistoryID = -1; bool flag2 = false; clsUniversalImport.SetPair power = clsUniversalImport.FindPower(sPowerLineArray[index4].Power, MidsContext.Character.Archetype.Idx); if (power.Powerset > -1 && DatabaseAPI.Database.Powersets[power.Powerset].SetType == Enums.ePowerSetType.Inherent) { flag2 = true; } if (power.Powerset < 0) { flag2 = true; } else if (power.Powerset == MidsContext.Character.Powersets[1].nID & power.Power == 0) { flag2 = true; } if (!flag2) { MainModule.MidsController.Toon.RequestedLevel = sPowerLineArray[index4].Level - 1; MainModule.MidsController.Toon.BuildPower(power.Powerset, power.Power, false); if (DatabaseAPI.Database.Powersets[power.Powerset].SetType == Enums.ePowerSetType.Pool) { int num7 = MainModule.MidsController.Toon.PoolLocked.Length - 2; for (int index6 = 0; index6 <= num7; index6++) { if (MainModule.MidsController.Toon.PoolLocked[index6] & MidsContext.Character.Powersets[3 + index6].nID == power.Powerset) { break; } if (!MainModule.MidsController.Toon.PoolLocked[index6]) { MidsContext.Character.Powersets[3 + index6].nID = power.Powerset; MainModule.MidsController.Toon.PoolLocked[index6] = true; break; } } } else if (DatabaseAPI.Database.Powersets[power.Powerset].SetType == Enums.ePowerSetType.Ancillary && !MainModule.MidsController.Toon.PoolLocked[MainModule.MidsController.Toon.PoolLocked.Length - 1]) { MidsContext.Character.Powersets[7].nID = power.Powerset; MainModule.MidsController.Toon.PoolLocked[MainModule.MidsController.Toon.PoolLocked.Length - 1] = true; } } } int num8 = sPowerLineArray.Length - 1; for (int index4 = 0; index4 <= num8; index4++) { sPowerLineArray[index4].HistoryID = MidsContext.Character.CurrentBuild.FindInToonHistory(DatabaseAPI.NidFromUidPower(sPowerLineArray[index4].Power)); if (sPowerLineArray[index4].HistoryID == -1 && (index4 > -1 & index4 < MidsContext.Character.CurrentBuild.Powers.Count)) { sPowerLineArray[index4].HistoryID = index4; } if (sPowerLineArray[index4].HistoryID > -1 & sPowerLineArray[index4].Slots.Length > 0) { if (sPowerLineArray[index4].Slots.Length > 1) { MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index4].HistoryID].Slots = new SlotEntry[sPowerLineArray[index4].Slots.Length - 1 + 1]; } int num9 = sPowerLineArray[index4].Slots.Length - 1; for (int index5 = 0; index5 <= num9; index5++) { if (index5 < MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index4].HistoryID].Slots.Length) { SlotEntry[] slots = MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index4].HistoryID].Slots; int index7 = index5; slots[index7].Enhancement = new I9Slot(); slots[index7].FlippedEnhancement = new I9Slot(); slots[index7].Enhancement.Enh = clsUniversalImport.MatchEnhancement(sPowerLineArray[index4].Slots[index5].Enh); slots[index7].Enhancement.Grade = Enums.eEnhGrade.SingleO; if (sPowerLineArray[index4].Slots[index5].Enh.IndexOf("-I:") > -1) { slots[index7].Enhancement.IOLevel = (int)Math.Round(Conversion.Val(sPowerLineArray[index4].Slots[index5].Enh.Substring(sPowerLineArray[index4].Slots[index5].Enh.IndexOf(":") + 1)) - 1.0); } else if (sPowerLineArray[index4].Slots[index5].Enh.IndexOf(":") > -1) { slots[index7].Enhancement.IOLevel = (int)Math.Round(Conversion.Val(sPowerLineArray[index4].Slots[index5].Enh.Substring(sPowerLineArray[index4].Slots[index5].Enh.IndexOf(":") + 1)) - 1.0); } else { slots[index7].Enhancement.IOLevel = MidsContext.Config.I9.DefaultIOLevel; } if (index5 == 0) { slots[index7].Level = MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index4].HistoryID].Level; } else { slots[index7].Level = sPowerLineArray[index4].Slots[index5].Level - 1; } if (slots[index7].Level < 0) { slots[index7].Level = 0; } } } } } MidsContext.Character.Validate(); MidsContext.Config.BuildMode = buildMode; flag3 = true; } catch (Exception ex) { Exception exception = ex; MidsContext.Config.BuildMode = buildMode; Interaction.MsgBox("Unable to import from forum post:\r\n" + exception.Message + "\r\n\r\nCheck the build was copied correctly.", MsgBoxStyle.Information, "Forum Import Filter"); flag3 = false; } return(flag3); }
static bool MxDReadSaveData(ref byte[] buffer, bool silent) { if (buffer.Length < 1) { MessageBox.Show("Unable to read data - Empty Buffer.", "ReadSaveData Failed"); return(false); } else { MemoryStream memoryStream; BinaryReader reader; try { memoryStream = new MemoryStream(buffer, writable: false); reader = new BinaryReader(memoryStream); reader.BaseStream.Seek(0L, SeekOrigin.Begin); } catch (Exception ex) { MessageBox.Show("Unable to read data - " + ex.Message, "ReadSaveData Failed"); return(false); } try { int streamIndex = 0; bool magicFound; // try to find magic number, reading 4 bytes at a time, offset by 1 on each failure do { reader.BaseStream.Seek(streamIndex, SeekOrigin.Begin); var numArray = reader.ReadBytes(4); if (numArray.Length >= 4) { magicFound = true; for (int index = 0; index < MagicNumber.Length; ++index) { if (MagicNumber[index] != numArray[index]) { magicFound = false; } } if (!magicFound) { ++streamIndex; } } else { if (!silent) { MessageBox.Show("Unable to read data - Magic Number not found.", "ReadSaveData Failed"); } reader.Close(); memoryStream.Close(); return(false); } }while (!magicFound); float fVersion = reader.ReadSingle(); if (fVersion > 2.0) { MessageBox.Show("File was saved by a newer version of the application. Please obtain the most recent release in order to open this file.", "Unable to Load"); reader.Close(); memoryStream.Close(); return(false); } else { bool qualifiedNames = reader.ReadBoolean(); bool hasSubPower = reader.ReadBoolean(); int nIDClass = DatabaseAPI.NidFromUidClass(reader.ReadString()); if (nIDClass < 0) { if (!silent) { MessageBox.Show("Unable to read data - Invalid Class UID.", "ReadSaveData Failed"); } reader.Close(); memoryStream.Close(); return(false); } else { int iOrigin = DatabaseAPI.NidFromUidOrigin(reader.ReadString(), nIDClass); MidsContext.Character.Reset(DatabaseAPI.Database.Classes[nIDClass], iOrigin); if (fVersion > 1.0) { int align = reader.ReadInt32(); MidsContext.Character.Alignment = (Enums.Alignment)align; } MidsContext.Character.Name = reader.ReadString(); int num4 = reader.ReadInt32(); if (MidsContext.Character.Powersets.Length - 1 != num4) { MidsContext.Character.Powersets = new IPowerset[num4 + 1]; } for (int index = 0; index < MidsContext.Character.Powersets.Length; ++index) { string iName = reader.ReadString(); MidsContext.Character.Powersets[index] = !string.IsNullOrEmpty(iName) ? DatabaseAPI.GetPowersetByName(iName) : null; } MidsContext.Character.CurrentBuild.LastPower = reader.ReadInt32() - 1; int powerCount = reader.ReadInt32(); try { for (int powerIndex = 0; powerIndex <= powerCount; ++powerIndex) { int nId = -1; string name1 = ""; int sidPower1 = -1; if (qualifiedNames) { name1 = reader.ReadString(); if (!string.IsNullOrEmpty(name1)) { nId = DatabaseAPI.NidFromUidPower(name1); } } else { sidPower1 = reader.ReadInt32(); nId = DatabaseAPI.NidFromStaticIndexPower(sidPower1); } bool flag5 = false; PowerEntry powerEntry1; if (powerIndex < MidsContext.Character.CurrentBuild.Powers.Count) { powerEntry1 = MidsContext.Character.CurrentBuild.Powers[powerIndex]; } else { powerEntry1 = new PowerEntry(-1, null, false); flag5 = true; } if (sidPower1 > -1 | !string.IsNullOrEmpty(name1)) { powerEntry1.Level = reader.ReadSByte(); powerEntry1.StatInclude = reader.ReadBoolean(); powerEntry1.VariableValue = reader.ReadInt32(); if (hasSubPower) { powerEntry1.SubPowers = new PowerSubEntry[reader.ReadSByte() + 1]; for (int subPowerIndex = 0; subPowerIndex < powerEntry1.SubPowers.Length; ++subPowerIndex) { var powerSub = new PowerSubEntry(); powerEntry1.SubPowers[subPowerIndex] = powerSub; if (qualifiedNames) { string name2 = reader.ReadString(); if (!string.IsNullOrEmpty(name2)) { powerSub.nIDPower = DatabaseAPI.NidFromUidPower(name2); } } else { int sidPower2 = reader.ReadInt32(); powerSub.nIDPower = DatabaseAPI.NidFromStaticIndexPower(sidPower2); } if (powerSub.nIDPower > -1) { powerSub.Powerset = DatabaseAPI.Database.Power[powerSub.nIDPower].PowerSetID; powerSub.Power = DatabaseAPI.Database.Power[powerSub.nIDPower].PowerSetIndex; } powerSub.StatInclude = reader.ReadBoolean(); if (powerSub.nIDPower > -1 & powerSub.StatInclude) { PowerEntry powerEntry2 = new PowerEntry(DatabaseAPI.Database.Power[powerSub.nIDPower]) { StatInclude = true }; MidsContext.Character.CurrentBuild.Powers.Add(powerEntry2); } } } } if (nId < 0 && powerIndex < DatabaseAPI.Database.Levels_MainPowers.Length) { powerEntry1.Level = DatabaseAPI.Database.Levels_MainPowers[powerIndex]; } powerEntry1.Slots = new SlotEntry[reader.ReadSByte() + 1]; for (var index3 = 0; index3 < powerEntry1.Slots.Length; ++index3) { powerEntry1.Slots[index3] = new SlotEntry() { Level = reader.ReadSByte(), Enhancement = new I9Slot(), FlippedEnhancement = new I9Slot() }; ReadSlotData(reader, ref powerEntry1.Slots[index3].Enhancement, qualifiedNames, fVersion); if (reader.ReadBoolean()) { ReadSlotData(reader, ref powerEntry1.Slots[index3].FlippedEnhancement, qualifiedNames, fVersion); } } if (powerEntry1.SubPowers.Length > 0) { nId = -1; } if (nId > -1) { powerEntry1.NIDPower = nId; powerEntry1.NIDPowerset = DatabaseAPI.Database.Power[nId].PowerSetID; powerEntry1.IDXPower = DatabaseAPI.Database.Power[nId].PowerSetIndex; if (powerEntry1.Level == 0 && powerEntry1.Power.FullSetName == "Pool.Fitness") { if (powerEntry1.NIDPower == 2553) { powerEntry1.NIDPower = 1521; } if (powerEntry1.NIDPower == 2554) { powerEntry1.NIDPower = 1523; } if (powerEntry1.NIDPower == 2555) { powerEntry1.NIDPower = 1522; } if (powerEntry1.NIDPower == 2556) { powerEntry1.NIDPower = 1524; } powerEntry1.NIDPowerset = DatabaseAPI.Database.Power[nId].PowerSetID; powerEntry1.IDXPower = DatabaseAPI.Database.Power[nId].PowerSetIndex; } var ps = powerEntry1.Power?.GetPowerSet(); if (powerIndex < MidsContext.Character.CurrentBuild.Powers.Count) { if (!(!MidsContext.Character.CurrentBuild.Powers[powerIndex].Chosen & ((ps != null && ps.nArchetype > -1) || powerEntry1.Power.GroupName == "Pool"))) { flag5 = !MidsContext.Character.CurrentBuild.Powers[powerIndex].Chosen; } else { continue; } } if (flag5) { MidsContext.Character.CurrentBuild.Powers.Add(powerEntry1); } else if ((ps != null && ps.nArchetype > -1) || powerEntry1.Power.GroupName == "Pool") { MidsContext.Character.CurrentBuild.Powers[powerIndex] = powerEntry1; } } } } catch (Exception ex) { if (!silent) { MessageBox.Show("Error reading some power data, will attempt to build character with known data - " + ex.Message, "ReadSaveData Failed"); } return(false); } MidsContext.Archetype = MidsContext.Character.Archetype; MidsContext.Character.Validate(); MidsContext.Character.Lock(); return(true); } } } catch (Exception ex) { if (!silent) { MessageBox.Show("Unable to read data - " + ex.Message, "ReadSaveData Failed"); } return(false); } } }
public List <PowerEntry>?Parse() { Regex r; Match m; Regex r1; Regex r2; Regex r3; Match m1; Match m2; Match m3; string rawPowerset; var p = new RawPowerData { Valid = false }; var powerSlots = new List <RawEnhData>(); RawEnhData e; var listPowers = new List <PowerEntry>(); string[] powerIDChunks; r1 = new Regex(@"^Level ([0-9]+)\: (.+)$"); // Picked power r2 = new Regex(@"^[\t\s]*EMPTY$"); // Empty enhancement slot r3 = new Regex(@"^[\t\s]*([0-9a-zA-Z\+\:\-_]+) \(([0-9]+)(\+([1-5]))?\)$"); // Filled enhancement slot var line = -1; string lineText; using var streamReader = new StreamReader(BuildString); while ((lineText = streamReader.ReadLine()) != null) { line++; if (line == 0) { // Name, Level, Origin, ClassID r = new Regex(@"^([^\:]+)\: Level ([0-9]+) ([a-zA-Z]+) ([a-zA-Z_]+)$"); m = r.Match(lineText); if (!m.Success) { MessageBox.Show("This build cannot be imported because it doesn't match the expected format.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } CharacterInfo.Name = m.Groups[1].Value; CharacterInfo.Archetype = m.Groups[4].Value.Replace("Class_", string.Empty); CharacterInfo.Origin = m.Groups[3].Value; CharacterInfo.Level = Convert.ToInt32(m.Groups[2].Value, null); SetCharacterInfo(); } else if (line < HeaderSize) { continue; } m1 = r1.Match(lineText); m2 = r2.Match(lineText); m3 = r3.Match(lineText); if (m1.Success) { if (p.Valid) { AddPowerToBuildSheet(p, ref listPowers); } powerIDChunks = m1.Groups[2].Value.Split(' '); rawPowerset = (powerIDChunks[0] + "." + powerIDChunks[1]).Trim(); p.FullName = m1.Groups[2].Value.Replace(" ", "."); p.Powerset = DatabaseAPI.GetPowersetByName(rawPowerset); p.pData = DatabaseAPI.GetPowerByFullName(p.FullName); if (p.pData == null) { p.FullName = FixKheldPowerNames(p.FullName); powerIDChunks = p.FullName.Split('.'); rawPowerset = (powerIDChunks[0] + "." + powerIDChunks[1]).Trim(); p.Powerset = DatabaseAPI.GetPowersetByName(rawPowerset); p.pData = DatabaseAPI.GetPowerByFullName(p.FullName); } p.Valid = CheckValid(p.pData); p.Level = Convert.ToInt32(m1.Groups[1].Value, null); p.Slots = new List <RawEnhData>(); if (CheckValid(p.Powerset)) { PowerSets.Add(p.Powerset.FullName); } } else if (m2.Success) { // Empty slot e = new RawEnhData { InternalName = "Empty", Level = 0, Boosters = 0, HasCatalyst = false, eData = -1 }; p.Slots.Add(e); } else if (m3.Success) { // Enhancement: internal name, level, (dummy), boosters e = new RawEnhData(); e.InternalName = DatabaseAPI.GetEnhancementBaseUIDName(m3.Groups[1].Value); e.Level = Convert.ToInt32(m3.Groups[2].Value, null); e.Boosters = (m3.Groups.Count > 3) & !string.IsNullOrWhiteSpace(m3.Groups[4].Value) ? Convert.ToInt32(m3.Groups[4].Value, null) : 0; e.HasCatalyst = DatabaseAPI.EnhHasCatalyst(m3.Groups[1].Value); e.eData = DatabaseAPI.GetEnhancementByUIDName(e.InternalName); p.Slots.Add(e); } } streamReader.Close(); if (p.Valid) { AddPowerToBuildSheet(p, ref listPowers); } return(listPowers); }
private void cbSecondary_SelectedIndexChanged(object sender, EventArgs e) { if (cbSecondary.SelectedIndex < 0) { return; } IPowerset selectedSec; var secondaryList = new BindingList <IPower>(); var selectedPowerset = (Powerset)cbSecondary.Items[cbSecondary.SelectedIndex]; switch (selectedPowerset.DisplayName) { case "Bane Spider Training": selectedSec = DatabaseAPI.GetPowersetByName("Training and Gadgets", Enums.ePowerSetType.Secondary); foreach (var power in selectedSec.Powers) { secondaryList.Add(power); } foreach (var power in selectedPowerset.Powers) { secondaryList.Add(power); } break; case "Crab Spider Training": selectedSec = DatabaseAPI.GetPowersetByName("Training and Gadgets", Enums.ePowerSetType.Secondary); foreach (var power in selectedSec.Powers) { secondaryList.Add(power); } foreach (var power in selectedPowerset.Powers) { secondaryList.Add(power); } break; case "Fortunata Teamwork": selectedSec = DatabaseAPI.GetPowersetByName("Teamwork", Enums.ePowerSetType.Secondary); foreach (var power in selectedSec.Powers) { secondaryList.Add(power); } foreach (var power in selectedPowerset.Powers) { secondaryList.Add(power); } break; case "Widow Teamwork": selectedSec = DatabaseAPI.GetPowersetByName("Teamwork", Enums.ePowerSetType.Secondary); foreach (var power in selectedSec.Powers) { secondaryList.Add(power); } foreach (var power in selectedPowerset.Powers) { secondaryList.Add(power); } break; default: secondaryList = new BindingList <IPower>(selectedPowerset.Powers); break; } FillSecondaryPowers(secondaryList); }
private void cbPrimary_SelectedIndexChanged(object sender, EventArgs e) { if (cbPrimary.SelectedIndex < 0) { return; } IPowerset selectedPri; var primaryList = new BindingList <IPower>(); var selectedPowerset = (Powerset)cbPrimary.Items[cbPrimary.SelectedIndex]; switch (selectedPowerset.DisplayName) { case "Arachnos Soldier": primaryList = new BindingList <IPower>(selectedPowerset.Powers); cbSecondary.SelectedIndex = 2; break; case "Bane Spider Soldier": selectedPri = DatabaseAPI.GetPowersetByName("Arachnos Soldier", Enums.ePowerSetType.Primary); foreach (var power in selectedPri.Powers) { primaryList.Add(power); } foreach (var power in selectedPowerset.Powers) { primaryList.Add(power); } cbSecondary.SelectedIndex = 0; break; case "Crab Spider Soldier": selectedPri = DatabaseAPI.GetPowersetByName("Arachnos Soldier", Enums.ePowerSetType.Primary); foreach (var power in selectedPri.Powers) { primaryList.Add(power); } foreach (var power in selectedPowerset.Powers) { primaryList.Add(power); } cbSecondary.SelectedIndex = 1; break; case "Fortunata Training": selectedPri = DatabaseAPI.GetPowersetByName("Widow Training", Enums.ePowerSetType.Primary); foreach (var power in selectedPri.Powers) { primaryList.Add(power); } foreach (var power in selectedPowerset.Powers) { primaryList.Add(power); } cbSecondary.SelectedIndex = 0; break; case "Night Widow Training": selectedPri = DatabaseAPI.GetPowersetByName("Widow Training", Enums.ePowerSetType.Primary); foreach (var power in selectedPri.Powers) { primaryList.Add(power); } foreach (var power in selectedPowerset.Powers) { primaryList.Add(power); } cbSecondary.SelectedIndex = 2; break; case "Widow Training": primaryList = new BindingList <IPower>(selectedPowerset.Powers); cbSecondary.SelectedIndex = 1; break; default: primaryList = new BindingList <IPower>(selectedPowerset.Powers); break; } FillPrimaryPowers(primaryList); }
static bool MxDReadSaveData(ref byte[] buffer, bool silent) { bool flag; if (buffer.Length < 1) { MessageBox.Show("Unable to read data - Empty Buffer.", "ReadSaveData Failed"); flag = false; } else { MemoryStream memoryStream; BinaryReader reader; bool flag2; try { memoryStream = new MemoryStream(buffer, false); reader = new BinaryReader(memoryStream); reader.BaseStream.Seek(0L, SeekOrigin.Begin); } catch (Exception ex) { MessageBox.Show("Unable to read data - " + ex.Message, "ReadSaveData Failed"); flag2 = false; return(flag2); } try { int num = 0; for (; ;) { reader.BaseStream.Seek((long)num, SeekOrigin.Begin); byte[] numArray = reader.ReadBytes(4); if (numArray.Length < 4) { break; } bool flag3 = true; for (int index = 0; index < MidsCharacterFileFormat.MagicNumber.Length; index++) { if (MidsCharacterFileFormat.MagicNumber[index] != numArray[index]) { flag3 = false; } } if (!flag3) { num++; } if (flag3) { goto Block_11; } } if (!silent) { MessageBox.Show("Unable to read data - Magic Number not found.", "ReadSaveData Failed"); } reader.Close(); memoryStream.Close(); flag2 = false; return(flag2); Block_11: float fVersion = reader.ReadSingle(); if ((double)fVersion > 2.0) { MessageBox.Show("File was saved by a newer version of the application. Please obtain the most recent release in order to open this file.", "Unable to Load"); reader.Close(); memoryStream.Close(); flag2 = false; } else { bool qualifiedNames = reader.ReadBoolean(); bool flag4 = reader.ReadBoolean(); int nIDClass = DatabaseAPI.NidFromUidClass(reader.ReadString()); if (nIDClass < 0) { if (!silent) { MessageBox.Show("Unable to read data - Invalid Class UID.", "ReadSaveData Failed"); } reader.Close(); memoryStream.Close(); flag2 = false; } else { int iOrigin = DatabaseAPI.NidFromUidOrigin(reader.ReadString(), nIDClass); MidsContext.Character.Reset(DatabaseAPI.Database.Classes[nIDClass], iOrigin); if ((double)fVersion > 1.0) { int num2 = reader.ReadInt32(); MidsContext.Character.Alignment = (Enums.Alignment)num2; } MidsContext.Character.Name = reader.ReadString(); int num3 = reader.ReadInt32(); if (MidsContext.Character.Powersets.Length - 1 != num3) { MidsContext.Character.Powersets = new IPowerset[num3 + 1]; } for (int index2 = 0; index2 < MidsContext.Character.Powersets.Length; index2++) { string iName = reader.ReadString(); if (string.IsNullOrEmpty(iName)) { MidsContext.Character.Powersets[index2] = null; } else { MidsContext.Character.Powersets[index2] = DatabaseAPI.GetPowersetByName(iName); } } MidsContext.Character.CurrentBuild.LastPower = reader.ReadInt32() - 1; int num4 = reader.ReadInt32(); try { for (int index3 = 0; index3 <= num4; index3++) { int index4 = -1; string name2 = string.Empty; int sidPower2 = -1; if (qualifiedNames) { name2 = reader.ReadString(); if (!string.IsNullOrEmpty(name2)) { index4 = DatabaseAPI.NidFromUidPower(name2); } } else { sidPower2 = reader.ReadInt32(); index4 = DatabaseAPI.NidFromStaticIndexPower(sidPower2); } bool flag5 = false; PowerEntry powerEntry; if (index3 < MidsContext.Character.CurrentBuild.Powers.Count) { powerEntry = MidsContext.Character.CurrentBuild.Powers[index3]; } else { powerEntry = new PowerEntry(-1, null, false); flag5 = true; } if (sidPower2 > -1 | !string.IsNullOrEmpty(name2)) { powerEntry.Level = (int)reader.ReadSByte(); powerEntry.StatInclude = reader.ReadBoolean(); powerEntry.VariableValue = reader.ReadInt32(); if (flag4) { powerEntry.SubPowers = new PowerSubEntry[(int)(reader.ReadSByte() + 1)]; for (int index5 = 0; index5 < powerEntry.SubPowers.Length; index5++) { powerEntry.SubPowers[index5] = new PowerSubEntry(); if (qualifiedNames) { name2 = reader.ReadString(); if (!string.IsNullOrEmpty(name2)) { powerEntry.SubPowers[index5].nIDPower = DatabaseAPI.NidFromUidPower(name2); } } else { sidPower2 = reader.ReadInt32(); powerEntry.SubPowers[index5].nIDPower = DatabaseAPI.NidFromStaticIndexPower(sidPower2); } if (powerEntry.SubPowers[index5].nIDPower > -1) { powerEntry.SubPowers[index5].Powerset = DatabaseAPI.Database.Power[powerEntry.SubPowers[index5].nIDPower].PowerSetID; powerEntry.SubPowers[index5].Power = DatabaseAPI.Database.Power[powerEntry.SubPowers[index5].nIDPower].PowerSetIndex; } powerEntry.SubPowers[index5].StatInclude = reader.ReadBoolean(); if (powerEntry.SubPowers[index5].nIDPower > -1 & powerEntry.SubPowers[index5].StatInclude) { PowerEntry powerEntry2 = new PowerEntry(DatabaseAPI.Database.Power[powerEntry.SubPowers[index5].nIDPower]) { StatInclude = true }; MidsContext.Character.CurrentBuild.Powers.Add(powerEntry2); } } } } if (index4 < 0 && index3 < DatabaseAPI.Database.Levels_MainPowers.Length) { powerEntry.Level = DatabaseAPI.Database.Levels_MainPowers[index3]; } powerEntry.Slots = new SlotEntry[(int)(reader.ReadSByte() + 1)]; for (int index6 = 0; index6 < powerEntry.Slots.Length; index6++) { powerEntry.Slots[index6] = new SlotEntry { Level = (int)reader.ReadSByte(), Enhancement = new I9Slot(), FlippedEnhancement = new I9Slot() }; MidsCharacterFileFormat.ReadSlotData(ref reader, ref powerEntry.Slots[index6].Enhancement, qualifiedNames, fVersion); if (reader.ReadBoolean()) { MidsCharacterFileFormat.ReadSlotData(ref reader, ref powerEntry.Slots[index6].FlippedEnhancement, qualifiedNames, fVersion); } } if (powerEntry.SubPowers.Length > 0) { index4 = -1; } if (index4 > -1) { powerEntry.NIDPower = index4; powerEntry.NIDPowerset = DatabaseAPI.Database.Power[index4].PowerSetID; powerEntry.IDXPower = DatabaseAPI.Database.Power[index4].PowerSetIndex; if (powerEntry.Level == 0 && powerEntry.Power.FullSetName == "Pool.Fitness") { if (powerEntry.NIDPower == 2553) { powerEntry.NIDPower = 1521; } if (powerEntry.NIDPower == 2554) { powerEntry.NIDPower = 1523; } if (powerEntry.NIDPower == 2555) { powerEntry.NIDPower = 1522; } if (powerEntry.NIDPower == 2556) { powerEntry.NIDPower = 1524; } powerEntry.NIDPowerset = DatabaseAPI.Database.Power[index4].PowerSetID; powerEntry.IDXPower = DatabaseAPI.Database.Power[index4].PowerSetIndex; } if (index3 < MidsContext.Character.CurrentBuild.Powers.Count) { if (!MidsContext.Character.CurrentBuild.Powers[index3].Chosen & (powerEntry.Power.PowerSet.nArchetype > -1 | powerEntry.Power.GroupName == "Pool")) { goto IL_91F; } flag5 = !MidsContext.Character.CurrentBuild.Powers[index3].Chosen; } if (flag5) { MidsContext.Character.CurrentBuild.Powers.Add(powerEntry); } else if (powerEntry.Power.PowerSet.nArchetype > -1 || powerEntry.Power.GroupName == "Pool") { MidsContext.Character.CurrentBuild.Powers[index3] = powerEntry; } } IL_91F :; } } catch (Exception ex2) { if (!silent) { MessageBox.Show("Error reading some power data, will attempt to build character with known data - " + ex2.Message, "ReadSaveData Failed"); } flag2 = false; return(flag2); } MidsContext.Archetype = MidsContext.Character.Archetype; MidsContext.Character.Validate(); MidsContext.Character.Lock(); flag2 = true; } } } catch (Exception ex3) { if (!silent) { MessageBox.Show("Unable to read data - " + ex3.Message, "ReadSaveData Failed"); } flag2 = false; } flag = flag2; } return(flag); }