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);
        }
    void Load(string iFilename)
    {
        if (iFilename.EndsWith("json"))
        {
        }
        //using (FileStream fileStream = new FileStream(iFilename, FileMode.Open, FileAccess.Read))
        {
            using (BinaryReader reader = new BinaryReader(File.Open(iFilename, FileMode.Open, FileAccess.Read)))
            {
                float num1;
                switch (reader.ReadString())
                {
                // legacy string, refers to something specific in files, do not change
                case "Mids' Hero Designer Config":
                    num1 = 0.9f;
                    break;

                // legacy string, refers to something specific in files, do not change
                // here's something F# doesn't do easily(fallthrough where one branch has a when variable declared)
                case "Mids' Hero Designer Config V2":
                case string x when x == header:
                    num1 = reader.ReadSingle();
                    break;

                default:
                    MessageBox.Show("Config file was missing a header! Using defaults.");
                    reader.Close();
                    //fileStream.Close();
                    return;
                }

                /* Commenting out for now - will remove later
                 * this.DNickName = reader.ReadString();
                 * this.DSelServer = reader.ReadString();
                 * this.DChannel = reader.ReadString();*/
                this.NoToolTips = reader.ReadBoolean();
                this.BaseAcc    = reader.ReadSingle();
                double num3 = (double)reader.ReadSingle();
                double num4 = (double)reader.ReadSingle();
                double num5 = (double)reader.ReadSingle();
                double num6 = (double)reader.ReadSingle();
                double num7 = (double)reader.ReadSingle();
                this.CalcEnhLevel  = (Enums.eEnhRelative)reader.ReadInt32();
                this.CalcEnhOrigin = (Enums.eEnhGrade)reader.ReadInt32();
                this.ExempHigh     = reader.ReadInt32();
                this.ExempLow      = reader.ReadInt32();
                this.Inc.PvE       = reader.ReadBoolean();
                reader.ReadBoolean();
                this.DamageMath.Calculate = (ConfigData.EDamageMath)reader.ReadInt32();
                reader.ReadSingle();
                if ((double)num1 < 1.24000000953674)
                {
                    reader.ReadBoolean();
                }
                else
                {
                    reader.ReadInt32();
                }
                this.DamageMath.ReturnValue        = (ConfigData.EDamageReturn)reader.ReadInt32();
                this.DataDamageGraph               = reader.ReadBoolean();
                this.DataDamageGraphPercentageOnly = reader.ReadBoolean();
                this.DataGraphType = (Enums.eDDGraph)reader.ReadInt32();
                this.ExportScheme  = reader.ReadInt32();
                this.ExportTarget  = reader.ReadInt32();
                if ((double)num1 >= 1.24000000953674)
                {
                    this.ExportBonusTotals = reader.ReadBoolean();
                    this.ExportBonusList   = reader.ReadBoolean();
                }
                this._hideOriginEnhancements = reader.ReadBoolean();
                this.ShowVillainColours      = reader.ReadBoolean();
                this.CheckForUpdates         = reader.ReadBoolean();
                this.Columns         = reader.ReadInt32();
                this.LastSize.Width  = reader.ReadInt32();
                this.LastSize.Height = reader.ReadInt32();
                this.DvState         = (Enums.eVisibleSize)reader.ReadInt32();
                this.StatGraphStyle  = (Enums.GraphStyle)reader.ReadInt32();
                if ((double)num1 >= 1.0)
                {
                    this.FreshInstall = reader.ReadBoolean();
                }
                if ((double)num1 >= 1.10000002384186)
                {
                    this.ForceLevel = reader.ReadInt32();
                }
                if ((double)num1 >= 1.20000004768372)
                {
                    this.I9.DefaultIOLevel = reader.ReadInt32();
                    if (this.I9.DefaultIOLevel > 49)
                    {
                        this.I9.DefaultIOLevel = 49;
                    }
                    this.I9.DisplayIOLevels        = reader.ReadBoolean();
                    this.I9.CalculateEnahncementFX = reader.ReadBoolean();
                    this.I9.CalculateSetBonusFX    = reader.ReadBoolean();
                    this.I9.ExportIOLevels         = reader.ReadBoolean();
                    this.I9.PrintIOLevels          = reader.ReadBoolean();
                    this.I9.ExportCompress         = reader.ReadBoolean();
                    this.I9.ExportDataChunk        = reader.ReadBoolean();
                    this.I9.ExportStripEnh         = reader.ReadBoolean();
                    this.I9.ExportStripSetNames    = reader.ReadBoolean();
                    this.I9.ExportExtraSep         = reader.ReadBoolean();
                    this.PrintInColour             = reader.ReadBoolean();
                    this._printScheme = reader.ReadInt32();
                }
                if ((double)num1 >= 1.21000003814697)
                {
                    this.RtFont.PairedBase             = reader.ReadSingle();
                    this.RtFont.PairedBold             = reader.ReadBoolean();
                    this.RtFont.RTFBase                = reader.ReadInt32();
                    this.RtFont.RTFBold                = reader.ReadBoolean();
                    this.RtFont.ColorBackgroundHero    = ConfigData.ReadRGB(reader);
                    this.RtFont.ColorBackgroundVillain = ConfigData.ReadRGB(reader);
                    this.RtFont.ColorEnhancement       = ConfigData.ReadRGB(reader);
                    this.RtFont.ColorFaded             = ConfigData.ReadRGB(reader);
                    this.RtFont.ColorInvention         = ConfigData.ReadRGB(reader);
                    this.RtFont.ColorInventionInv      = ConfigData.ReadRGB(reader);
                    this.RtFont.ColorText              = ConfigData.ReadRGB(reader);
                    this.RtFont.ColorWarning           = ConfigData.ReadRGB(reader);
                    this.RtFont.ColorPlName            = ConfigData.ReadRGB(reader);
                    this.RtFont.ColorPlSpecial         = ConfigData.ReadRGB(reader);
                }
                if ((double)num1 >= 1.22000002861023)
                {
                    this.ShowSlotLevels             = reader.ReadBoolean();
                    this.LoadLastFileOnStart        = reader.ReadBoolean();
                    this.LastFileName               = reader.ReadString();
                    this.RtFont.ColorPowerAvailable = ConfigData.ReadRGB(reader);
                    this.RtFont.ColorPowerTaken     = ConfigData.ReadRGB(reader);
                    this.RtFont.ColorPowerTakenDark = ConfigData.ReadRGB(reader);
                    this.RtFont.ColorPowerDisabled  = ConfigData.ReadRGB(reader);
                    this.RtFont.ColorPowerHighlight = ConfigData.ReadRGB(reader);
                }
                if ((double)num1 >= 1.23000001907349)
                {
                    this.Tips = new Tips(reader);
                    this.DefaultSaveFolderOverride = reader.ReadString();
                }
                if ((double)num1 >= 1.24000000953674)
                {
                    this.EnhanceVisibility = reader.ReadBoolean();
                    reader.ReadBoolean();
                    this.BuildMode   = (Enums.dmModes)reader.ReadInt32();
                    this.BuildOption = (Enums.dmItem)reader.ReadInt32();
                    this.UpdatePath  = reader.ReadString();
                    if (string.IsNullOrEmpty(this.UpdatePath))
                    {
                        this.UpdatePath = "";
                    }
                }
                if ((double)num1 >= 1.25)
                {
                    this.ShowEnhRel     = reader.ReadBoolean();
                    this.ShowRelSymbols = reader.ReadBoolean();
                    this.ShowPopup      = reader.ReadBoolean();
                    if ((double)num1 >= 1.32000005245209)
                    {
                        this.ShowAlphaPopup = reader.ReadBoolean();
                    }
                    this.PopupRecipes = reader.ReadBoolean();
                    this.ShoppingListIncludesRecipes = reader.ReadBoolean();
                    this.PrintProfile         = (ConfigData.PrintOptionProfile)reader.ReadInt32();
                    this.PrintHistory         = reader.ReadBoolean();
                    this.LastPrinter          = reader.ReadString();
                    this.PrintProfileEnh      = reader.ReadBoolean();
                    this.DesaturateInherent   = reader.ReadBoolean();
                    this.ReapeatOnMiddleClick = reader.ReadBoolean();
                }
                if ((double)num1 >= 1.25999999046326)
                {
                    this.ExportHex = reader.ReadBoolean();
                }
                if ((double)num1 >= 1.26999998092651)
                {
                    this.SpeedFormat = (Enums.eSpeedMeasure)reader.ReadInt32();
                }
                if ((double)num1 >= 1.27999997138977)
                {
                    this.SaveFolderChecked = reader.ReadBoolean();
                }
                if ((double)num1 >= 1.28999996185303)
                {
                    this.UseArcanaTime = reader.ReadBoolean(); //this is correct
                }

                /*Commented out to expidite release.... Will not load forum Export settings  or supression settings
                 * if ((double)num1 >= 1.29999995231628)
                 * {  // numbers seem really off which is screwing up the rest of the read
                 *  tempNum = reader.ReadInt16();
                 *  this.Suppression = (Enums.eSuppress)tempNum;
                 * }
                 * if ((double)num1 >= 1.30999994277954)
                 * {
                 *  for (int index = 0; index < 19; ++index) {
                 *      this.DragDropScenarioAction[index] = reader.ReadInt16();
                 * }
                 * }//589825 or 2305
                 * tempNum = reader.ReadInt16();
                 * this.Export.ColorSchemes = new ExportConfig.ColorScheme[(int)tempNum];
                 * for (int index = 0; index < this.Export.ColorSchemes.Length; ++index)
                 * { //crashes at index 14
                 *  this.Export.ColorSchemes[index].SchemeName = reader.ReadString();
                 *  this.Export.ColorSchemes[index].Heading = ConfigData.ReadRGB(reader);
                 *  this.Export.ColorSchemes[index].Level = ConfigData.ReadRGB(reader);
                 *  this.Export.ColorSchemes[index].Slots = ConfigData.ReadRGB(reader);
                 *  this.Export.ColorSchemes[index].Title = ConfigData.ReadRGB(reader);
                 *  if ((double)num1 >= 1.20000004768372)
                 *  {
                 *      this.Export.ColorSchemes[index].IOColor = ConfigData.ReadRGB(reader);
                 *      this.Export.ColorSchemes[index].SetColor = ConfigData.ReadRGB(reader);
                 *      this.Export.ColorSchemes[index].HOColor = ConfigData.ReadRGB(reader);
                 *      this.Export.ColorSchemes[index].Power = ConfigData.ReadRGB(reader);
                 *  }
                 * }
                 * this.Export.FormatCode = new ExportConfig.FormatCodes[reader.ReadInt32() + 1];
                 * for (int index = 0; index < this.Export.FormatCode.Length; ++index)
                 * {
                 *  this.Export.FormatCode[index].Name = reader.ReadString();
                 *  this.Export.FormatCode[index].Notes = reader.ReadString();
                 *  this.Export.FormatCode[index].BoldOff = reader.ReadString();
                 *  this.Export.FormatCode[index].BoldOn = reader.ReadString();
                 *  this.Export.FormatCode[index].ColourOff = reader.ReadString();
                 *  this.Export.FormatCode[index].ColourOn = reader.ReadString();
                 *  this.Export.FormatCode[index].ItalicOff = reader.ReadString();
                 *  this.Export.FormatCode[index].ItalicOn = reader.ReadString();
                 *  this.Export.FormatCode[index].SizeOff = reader.ReadString();
                 *  this.Export.FormatCode[index].SizeOn = reader.ReadString();
                 *  this.Export.FormatCode[index].UnderlineOff = reader.ReadString();
                 *  this.Export.FormatCode[index].UnderlineOn = reader.ReadString();
                 *  this.Export.FormatCode[index].Space = (ExportConfig.WhiteSpace)reader.ReadInt32();
                 * } */
                this.CreateDefaultSaveFolder();
            }
        }
    }
Beispiel #3
0
        public static bool InterpretForumPost(string iPost)
        {
            Enums.dmModes buildMode = MidsContext.Config.BuildMode;
            MidsContext.Config.BuildMode = Enums.dmModes.Dynamic;
            try
            {
                iPost = PowerNameFix(iPost);
                char[] chArray =
                {
                    '`'
                };
                iPost = iPost.Replace("\r\n", "`");
                iPost = iPost.Replace("\n", "`");
                iPost = iPost.Replace("\r", "`");
                string[] haystack = iPost.Split(chArray);
                int      num1     = 0;
                string   dest     = "";
                MidsContext.Character.Reset();
                Character character = MidsContext.Character;
                string    name      = character.Name;
                character.Name = name;
                if (FindValue("Name", haystack, ref name) < 0)
                {
                    MidsContext.Character.Name = "Unknown";
                }
                if (SmartFind("Archetype", haystack, ref dest) < 0)
                {
                    int index1 = -1;
                    int num2   = DatabaseAPI.Database.Classes.Length - 1;
                    for (int 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);
                }

                int 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];
                int 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.");
                }
                int firstPower = FindFirstPower(haystack, MidsContext.Character.Archetype.Idx);
                if (firstPower < 0)
                {
                    throw new Exception("First power entry couldn't be located.");
                }
                sPowerLine[] sPowerLineArray = new sPowerLine[0];
                sPowerLine   iPL             = new sPowerLine();
                int          num3            = haystack.Length - 1;
                for (int 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]);
                    sPowerLineArray[sPowerLineArray.Length - 1].Assign(iPL);
                }

                for (int index1 = 0; index1 <= sPowerLineArray.Length - 1; ++index1)
                {
                    if (sPowerLineArray[index1].Level > num1)
                    {
                        num1 = sPowerLineArray[index1].Level;
                    }
                    int num2 = sPowerLineArray[index1].Slots.Length - 1;
                    for (int 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);
                }
                int num5 = sPowerLineArray.Length - 1;
                for (int index1 = 0; index1 <= num5; ++index1)
                {
                    sPowerLineArray[index1].HistoryID = -1;
                    bool    flag2 = false;
                    SetPair 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:
                    {
                        int num2 = MainModule.MidsController.Toon.PoolLocked.Length - 2;
                        for (int 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;
                    }
                }

                int num6 = sPowerLineArray.Length - 1;
                for (int 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];
                    }
                    int num2 = sPowerLineArray[index1].Slots.Length - 1;
                    for (int index2 = 0; index2 <= num2; ++index2)
                    {
                        if (index2 >= MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index1].HistoryID].Slots.Length)
                        {
                            continue;
                        }
                        SlotEntry[] slots  = MidsContext.Character.CurrentBuild.Powers[sPowerLineArray[index1].HistoryID].Slots;
                        int         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(Conversion.Val(sPowerLineArray[index1].Slots[index2].Enh
                                                           .Substring(sPowerLineArray[index1].Slots[index2].Enh
                                                                      .IndexOf(":", StringComparison.Ordinal) + 1)) - 1.0)
                                : (int)Math.Round(Conversion.Val(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;
                Interaction.MsgBox(("Unable to import from forum post:\r\n" + ex.Message + "\r\n\r\nCheck the build was copied correctly."),
                                   MsgBoxStyle.Information, "Forum Import Filter");
                return(false);
            }
        }