void btnSave_Click(object sender, EventArgs e)
 {
     I9Gfx.LoadEnhancements();
     DatabaseAPI.AssignStaticIndexValues();
     DatabaseAPI.AssignRecipeIDs();
     DatabaseAPI.SaveEnhancementDb();
     base.Hide();
 }
Example #2
0
        void btnSave_Click(object sender, EventArgs e)
        {
            I9Gfx.LoadEnhancements();
            var serializer = MyApplication.GetSerializer();

            DatabaseAPI.AssignStaticIndexValues(serializer, false);
            DatabaseAPI.AssignRecipeIDs();
            DatabaseAPI.SaveEnhancementDb(serializer);
            Hide();
        }
 void btnOK_Click(object sender, EventArgs e) => this.EventHandlerWithCatch(() =>
 {
     frmRecipeEdit.AssignNewRecipes();
     DatabaseAPI.AssignRecipeSalvageIDs();
     DatabaseAPI.AssignRecipeIDs();
     var serializer = My.MyApplication.GetSerializer();
     DatabaseAPI.SaveRecipes(serializer);
     DatabaseAPI.SaveEnhancementDb(serializer);
     this.Close();
 });
Example #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            BusyMsg("Saving, please wait...");
            I9Gfx.LoadEnhancements();
            foreach (var power in DatabaseAPI.Database.Power)
            {
                power.BaseRechargeTime = power.RechargeTime;
            }
            Array.Sort(DatabaseAPI.Database.Power);
            var serializer = MyApplication.GetSerializer();

            DatabaseAPI.AssignStaticIndexValues(serializer, false);
            DatabaseAPI.AssignRecipeIDs();
            DatabaseAPI.SaveEnhancementDb(serializer);
            DatabaseAPI.MatchAllIDs();
            Task.Delay(1000).Wait();
            DatabaseAPI.SaveMainDatabase(serializer);
            BusyHide();
            DialogResult = DialogResult.OK;
            Hide();
        }
        bool ImportRecipeCSV(string iFName1, string iFName2)
        {
            StreamReader iStream1;
            StreamReader iStream2;

            try
            {
                iStream1 = new StreamReader(iFName1);
                iStream2 = new StreamReader(iFName2);
            }
            catch (Exception ex)
            {
                Interaction.MsgBox(ex.Message, MsgBoxStyle.Critical, "Recipe CSVs Not Opened");
                return(false);
            }
            int num1 = 0;
            int num2 = 0;
            int num3 = 0;
            int num4 = 0;

            DatabaseAPI.Database.Recipes = new Recipe[0];
            int num5;

            try
            {
                string iLine1;
                do
                {
                    iLine1 = FileIO.ReadLineUnlimited(iStream1, char.MinValue);
                    if (iLine1 != null && !iLine1.StartsWith("#"))
                    {
                        ++num4;
                        if (num4 >= 18)
                        {
                            this.BusyMsg(Strings.Format(num1, "###,##0") + " Recipes Created.");
                            num4 = 0;
                        }
                        string[] array = CSV.ToArray(iLine1);
                        if (array.Length >= 18)
                        {
                            bool   flag  = false;
                            string iName = array[0];
                            if (iName.Contains("_Memorized"))
                            {
                                iName = iName.Replace("_Memorized", "");
                                flag  = true;
                            }
                            if (iName.LastIndexOf("_", StringComparison.Ordinal) > 0)
                            {
                                iName = iName.Substring(0, iName.LastIndexOf("_", StringComparison.Ordinal));
                            }
                            int    num6    = (int)Math.Round(Conversion.Val(array[10]));
                            Recipe recipe1 = DatabaseAPI.GetRecipeByName(iName);
                            if (recipe1 == null)
                            {
                                recipe1 = new Recipe
                                {
                                    InternalName = iName,
                                    ExternalName = !(array[1] != "") ? iName : array[1],
                                    Rarity       = (Recipe.RecipeRarity)Math.Round(Conversion.Val(array[9]) - 1.0)
                                };
                                DatabaseAPI.Database.Recipes = DatabaseAPI.Database.Recipes.Append(recipe1).ToArray();
                            }
                            int index1 = -1;
                            int num7   = recipe1.Item.Length - 1;
                            for (int index2 = 0; index2 <= num7; ++index2)
                            {
                                if (recipe1.Item[index2].Level == num6 - 1)
                                {
                                    index1 = index2;
                                }
                            }
                            if (index1 < 0)
                            {
                                recipe1.Item = recipe1.Item.Append(new Recipe.RecipeEntry()).ToArray();
                            }
                            recipe1.Item[index1].Level = num6 - 1;
                            if (flag)
                            {
                                recipe1.Item[index1].BuyCostM   = (int)Math.Round(Conversion.Val(array[15]));
                                recipe1.Item[index1].CraftCostM = (int)Math.Round(Conversion.Val(array[11]));
                            }
                            else
                            {
                                recipe1.Item[index1].BuyCost   = (int)Math.Round(Conversion.Val(array[15]));
                                recipe1.Item[index1].CraftCost = (int)Math.Round(Conversion.Val(array[11]));
                            }
                            if (array[7].Length > 0)
                            {
                                int index2 = DatabaseAPI.NidFromUidEnhExtended(array[7]);
                                if (index2 > -1)
                                {
                                    recipe1.Enhancement = DatabaseAPI.Database.Enhancements[index2].UID;
                                    DatabaseAPI.Database.Enhancements[index2].RecipeName = recipe1.InternalName;
                                }
                            }
                            ++num1;
                        }
                    }
                }while (iLine1 != null);
                iStream1.Close();
                num5 = 0;
                string iLine2;
                do
                {
                    iLine2 = FileIO.ReadLineUnlimited(iStream2, char.MinValue);
                    if (iLine2 != null && !iLine2.StartsWith("#"))
                    {
                        ++num4;
                        if (num4 >= 18)
                        {
                            this.BusyMsg(Strings.Format(num5, "###,##0") + " Recipes Created.");
                            num4 = 0;
                        }
                        string[] array = CSV.ToArray(iLine2);
                        if (array.Length >= 3)
                        {
                            int    num6  = -1;
                            bool   flag  = false;
                            string iName = array[0];
                            if (iName.Contains("_Memorized"))
                            {
                                iName = iName.Replace("_Memorized", "");
                                flag  = true;
                            }
                            if (iName.LastIndexOf("_", StringComparison.Ordinal) > 0)
                            {
                                num6  = (int)Math.Round(Conversion.Val(iName.Substring(iName.LastIndexOf("_", StringComparison.Ordinal) + 1)));
                                iName = iName.Substring(0, iName.LastIndexOf("_", StringComparison.Ordinal));
                            }
                            if (num6 > -1 & !flag)
                            {
                                Recipe recipeByName = DatabaseAPI.GetRecipeByName(iName);
                                if (recipeByName != null)
                                {
                                    int index1 = -1;
                                    ++num5;
                                    Recipe recipe = recipeByName;
                                    int    num7   = recipe.Item.Length - 1;
                                    for (int index2 = 0; index2 <= num7; ++index2)
                                    {
                                        if (recipe.Item[index2].Level == num6 - 1)
                                        {
                                            index1 = index2;
                                        }
                                    }
                                    if (index1 > -1)
                                    {
                                        int index2 = -1;
                                        int num8   = recipe.Item[index1].Salvage.Length - 1;
                                        for (int index3 = 0; index3 <= num8; ++index3)
                                        {
                                            if (recipe.Item[index1].Salvage[index3] == "")
                                            {
                                                index2 = index3;
                                                break;
                                            }
                                        }
                                        if (index2 > -1)
                                        {
                                            recipe.Item[index1].Salvage[index2]    = array[2];
                                            recipe.Item[index1].Count[index2]      = (int)Math.Round(Conversion.Val(array[1]));
                                            recipe.Item[index1].SalvageIdx[index2] = -1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }while (iLine2 != null);
                DatabaseAPI.AssignRecipeSalvageIDs();
                DatabaseAPI.GuessRecipes();
                DatabaseAPI.AssignRecipeIDs();
                Interaction.MsgBox("Done. Recipe-Enhancement links have been guessed.", MsgBoxStyle.Information, "Import");
            }
            catch (Exception ex)
            {
                Exception exception = ex;
                iStream1.Close();
                iStream2.Close();
                this.BusyHide();
                Interaction.MsgBox(exception.Message, MsgBoxStyle.Critical, "CSV Parse Error");
                return(false);
            }
            this.BusyHide();
            iStream2.Close();
            Interaction.MsgBox(("Parse Completed!\r\nTotal Records: " + num5.ToString() + "\r\nGood: " + num2.ToString() + "\r\nRejected: " + num3.ToString()), MsgBoxStyle.Information, "File Parsed");
            var serializer = My.MyApplication.GetSerializer();

            DatabaseAPI.SaveRecipes(serializer);
            DatabaseAPI.SaveEnhancementDb(serializer);
            return(true);
        }
            public static void LoadData(ref frmLoading iFrm)
            {
                DatabaseAPI.LoadDatabaseVersion();
                IsAppInitialized = true;
                iFrm?.SetMessage("Loading Data...");
                iFrm?.SetMessage("Loading Attribute Modifiers...");
                DatabaseAPI.Database.AttribMods = new Modifiers();
                if (!DatabaseAPI.Database.AttribMods.Load())
                {
                }

                iFrm?.SetMessage("Loading Powerset Database...");
                if (!DatabaseAPI.LoadLevelsDatabase())
                {
                    Interaction.MsgBox(
                        "Failed to load Leveling data file! The program is unable to proceed.\r\n" +
                        "We suggest you redownload the application from https://github.com/Crytilis/mids-reborn-hero-designer/releases",
                        MsgBoxStyle.Critical, "Error");
                    ProjectData.EndApp();
                }

                if (!DatabaseAPI.LoadMainDatabase())
                {
                    Interaction.MsgBox("There was an error reading the database. Aborting.", MsgBoxStyle.Critical, "Dang");
                    ProjectData.EndApp();
                }

                if (!DatabaseAPI.LoadMaths())
                {
                    ProjectData.EndApp();
                }
                iFrm?.SetMessage("Loading Enhancement Database...");
                if (!DatabaseAPI.LoadEnhancementClasses())
                {
                    ProjectData.EndApp();
                }
                I9Gfx.LoadClasses();
                DatabaseAPI.LoadEnhancementDb();
                I9Gfx.LoadEnhancements();
                I9Gfx.LoadSets();
                DatabaseAPI.LoadOrigins();
                I9Gfx.LoadBorders();
                DatabaseAPI.LoadSetTypeStrings();
                iFrm?.SetMessage("Loading Recipe Database...");
                DatabaseAPI.LoadSalvage();
                DatabaseAPI.LoadRecipes();
                iFrm?.SetMessage("Loading Graphics...");
                I9Gfx.LoadSetTypes();
                I9Gfx.LoadEnhTypes();
                I9Gfx.LoadOriginImages();
                I9Gfx.LoadArchetypeImages();
                I9Gfx.LoadPowersetImages();
                MidsContext.Config.Export.LoadCodes(Files.SelectDataFileLoad(Files.MxdbFileBbCodeUpdate));
                if (iFrm != null)
                {
                    iFrm.Opacity = 1.0;
                    DatabaseAPI.MatchAllIDs(iFrm);
                    iFrm?.SetMessage("Matching Set Bonus IDs...");
                    DatabaseAPI.AssignSetBonusIndexes();
                    iFrm?.SetMessage("Matching Recipe IDs...");
                }

                DatabaseAPI.AssignRecipeIDs();
                GC.Collect();
            }
Example #7
0
            public static void LoadData(ref frmInitializing iFrm)
            {
                DatabaseAPI.LoadDatabaseVersion();
                IsAppInitialized = true;
                iFrm?.SetMessage("Loading Data...");
                iFrm?.SetMessage("Loading Attribute Modifiers...");
                DatabaseAPI.Database.AttribMods = new Modifiers();
                if (!DatabaseAPI.Database.AttribMods.Load())
                {
                }

                iFrm?.SetMessage("Loading Powerset Database...");
                if (!DatabaseAPI.LoadLevelsDatabase())
                {
                    MessageBox.Show("Unable to proceed, failed to load leveling data! We suggest you re-download the application from https://github.com/Reborn-Team/Hero-Designer/releases.", @"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }

                if (!DatabaseAPI.LoadMainDatabase())
                {
                    MessageBox.Show(@"There was an error reading the database. Aborting!", @"Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }

                if (!DatabaseAPI.LoadMaths())
                {
                    Application.Exit();
                }

                iFrm?.SetMessage("Loading Global Chance Modifiers...");
                if (!DatabaseAPI.LoadEffectIdsDatabase())
                {
                    Application.Exit();
                }

                iFrm?.SetMessage("Loading Enhancement Database...");
                if (!DatabaseAPI.LoadEnhancementClasses())
                {
                    Application.Exit();
                }

                DatabaseAPI.LoadEnhancementDb();
                DatabaseAPI.LoadOrigins();
                DatabaseAPI.LoadSetTypeStrings();

                iFrm?.SetMessage("Loading Recipe Database...");
                DatabaseAPI.LoadSalvage();
                DatabaseAPI.LoadRecipes();

                iFrm?.SetMessage("Loading Graphics...");
                var taskArray = new Task[9];

                taskArray[0] = Task.Run(I9Gfx.LoadOriginImages);
                taskArray[1] = Task.Run(I9Gfx.LoadArchetypeImages);
                taskArray[2] = Task.Run(I9Gfx.LoadPowersetImages);
                taskArray[3] = Task.Run(I9Gfx.LoadEnhancements);
                taskArray[4] = Task.Run(I9Gfx.LoadSets);
                taskArray[5] = Task.Run(I9Gfx.LoadBorders);
                taskArray[6] = Task.Run(I9Gfx.LoadSetTypes);
                taskArray[7] = Task.Run(I9Gfx.LoadEnhTypes);
                taskArray[8] = Task.Run(I9Gfx.LoadClasses);
                Task.WaitAll(taskArray);

                MidsContext.Config.Export.LoadCodes(Files.SelectDataFileLoad(Files.MxdbFileBbCodeUpdate));
                if (iFrm != null)
                {
                    //iFrm.Opacity = 1.0;
                    DatabaseAPI.MatchAllIDs(iFrm);
                    iFrm?.SetMessage("Matching Set Bonus IDs...");
                    DatabaseAPI.AssignSetBonusIndexes();
                    iFrm?.SetMessage("Matching Recipe IDs...");
                }

                DatabaseAPI.AssignRecipeIDs();
                GC.Collect();
            }
 void Button1_Click(object sender, EventArgs e)
 {
     DatabaseAPI.GuessRecipes();
     DatabaseAPI.AssignRecipeIDs();
 }
        void btnImport_Click(object sender, EventArgs e)
        {
            if (Interaction.MsgBox("Really erase all stored recipes and attempt import?", MsgBoxStyle.YesNo | MsgBoxStyle.Question, "Careful...") != MsgBoxResult.Yes)
            {
                return;
            }
            char[] chArray = new char[1] {
                '\r'
            };
            string[] strArray1 = Clipboard.GetDataObject().GetData("System.String", true).ToString().Split(chArray);
            chArray[0] = '\t';
            DatabaseAPI.Database.Recipes = new Recipe[0];
            int num1 = strArray1.Length - 1;

            for (int index1 = 0; index1 <= num1; ++index1)
            {
                string[] strArray2 = strArray1[index1].Split(chArray);
                if (strArray2.Length > 7)
                {
                    string iName = strArray2[0].Replace("_Memorized", "").LastIndexOf("_", StringComparison.Ordinal) <= 0 ? strArray2[0] : strArray2[0].Substring(0, strArray2[0].Replace("_Memorized", "").LastIndexOf("_", StringComparison.Ordinal));
                    if (!char.IsLetterOrDigit(iName[0]))
                    {
                        iName = iName.Substring(1);
                    }
                    Recipe recipe1 = DatabaseAPI.GetRecipeByName(iName);
                    if (recipe1 == null)
                    {
                        IDatabase database    = DatabaseAPI.Database;
                        Recipe[]  recipeArray = (Recipe[])Utils.CopyArray(database.Recipes, (Array) new Recipe[DatabaseAPI.Database.Recipes.Length + 1]);
                        database.Recipes = recipeArray;
                        DatabaseAPI.Database.Recipes[DatabaseAPI.Database.Recipes.Length - 1] = new Recipe();
                        recipe1 = DatabaseAPI.Database.Recipes[DatabaseAPI.Database.Recipes.Length - 1];
                        Recipe recipe2 = recipe1;
                        recipe2.InternalName = iName;
                        recipe2.ExternalName = !(strArray2[14] == "") ? "" : strArray2[1];
                        recipe2.Rarity       = (Recipe.RecipeRarity)Math.Round(Conversion.Val(strArray2[15]) - 1.0);
                    }
                    int    index2  = -1;
                    Recipe recipe3 = recipe1;
                    int    num2    = recipe3.Item.Length - 1;
                    for (int index3 = 0; index3 <= num2; ++index3)
                    {
                        if ((double)recipe3.Item[index3].Level == Conversion.Val(strArray2[16]) - 1.0)
                        {
                            index2 = index3;
                        }
                    }
                    if (index2 < 0)
                    {
                        recipe3.Item = (Recipe.RecipeEntry[])Utils.CopyArray(recipe3.Item, (Array) new Recipe.RecipeEntry[recipe3.Item.Length + 1]);
                        recipe3.Item[recipe3.Item.Length - 1] = new Recipe.RecipeEntry();
                        index2 = recipe3.Item.Length - 1;
                    }
                    recipe3.Item[index2].Level = (int)Math.Round(Conversion.Val(strArray2[16]) - 1.0);
                    if (strArray2[0].IndexOf("Memorized") > -1)
                    {
                        recipe3.Item[index2].BuyCostM   = (int)Math.Round(Conversion.Val(strArray2[19]) - 1.0);
                        recipe3.Item[index2].CraftCostM = (int)Math.Round(Conversion.Val(strArray2[17]) - 1.0);
                    }
                    else
                    {
                        recipe3.Item[index2].BuyCost   = (int)Math.Round(Conversion.Val(strArray2[19]) - 1.0);
                        recipe3.Item[index2].CraftCost = (int)Math.Round(Conversion.Val(strArray2[17]) - 1.0);
                    }
                    int index4 = 0;
                    do
                    {
                        if (Conversion.Val(strArray2[4 + index4 * 2]) > 0.0)
                        {
                            recipe3.Item[index2].Count[index4]      = (int)Math.Round(Conversion.Val(strArray2[4 + index4 * 2]));
                            recipe3.Item[index2].Salvage[index4]    = strArray2[5 + index4 * 2];
                            recipe3.Item[index2].SalvageIdx[index4] = -1;
                        }
                        ++index4;
                    }while (index4 <= 4);
                }
            }
            DatabaseAPI.AssignRecipeSalvageIDs();
            DatabaseAPI.GuessRecipes();
            DatabaseAPI.AssignRecipeIDs();
            this.FillList();
            int num3 = (int)Interaction.MsgBox("Done. Recipe-Enhancement links have been guessed.", MsgBoxStyle.Information, "Import");
        }
 void Button1_Click(object sender, EventArgs e) => this.EventHandlerWithCatch(() =>
 {
     DatabaseAPI.GuessRecipes();
     DatabaseAPI.AssignRecipeIDs();
 });
Example #11
0
 public static void LoadData(ref frmLoading iFrm)
 {
     DatabaseAPI.LoadDatabaseVersion();
     MainModule.MidsController._appInitialized = true;
     if (iFrm != null)
     {
         iFrm.SetMessage("Loading Data...");
     }
     if (iFrm != null)
     {
         iFrm.SetMessage("Loading Attribute Modifiers...");
     }
     DatabaseAPI.Database.AttribMods = new Modifiers();
     DatabaseAPI.Database.AttribMods.Load();
     if (iFrm != null)
     {
         iFrm.SetMessage("Loading Powerset Database...");
     }
     if (!DatabaseAPI.LoadLevelsDatabase())
     {
         Interaction.MsgBox("Failed to load Levelling data file! The program is unable to proceed.\r\nSuggest you redownload the application from http://www.cohplanner.com/", MsgBoxStyle.Critical, "Error");
         ProjectData.EndApp();
     }
     if (!DatabaseAPI.LoadMainDatabase())
     {
         if (Interaction.MsgBox("There was an error reading the database. Attempt to download replacement?", MsgBoxStyle.YesNo | MsgBoxStyle.Information, "Dang") == MsgBoxResult.Yes)
         {
             DateTime date = new DateTime(1, 1, 1);
             DatabaseAPI.Database.Date = date;
             clsXMLUpdate clsXmlUpdate = new clsXMLUpdate("http://repo.cohtitan.com/mids_updates/");
             IMessager    iLoadFrm     = null;
             clsXmlUpdate.UpdateCheck(false, ref iLoadFrm);
         }
         else
         {
             ProjectData.EndApp();
         }
     }
     if (!DatabaseAPI.LoadMaths())
     {
         ProjectData.EndApp();
     }
     if (iFrm != null)
     {
         iFrm.SetMessage("Loading Enhancement Database...");
     }
     if (!DatabaseAPI.LoadEnhancementClasses())
     {
         ProjectData.EndApp();
     }
     I9Gfx.LoadClasses();
     DatabaseAPI.LoadEnhancementDb();
     I9Gfx.LoadEnhancements();
     I9Gfx.LoadSets();
     DatabaseAPI.LoadOrigins();
     I9Gfx.LoadBorders();
     DatabaseAPI.LoadSetTypeStrings();
     if (iFrm != null)
     {
         iFrm.SetMessage("Loading Recipe Database...");
     }
     DatabaseAPI.LoadSalvage();
     DatabaseAPI.LoadRecipes();
     if (iFrm != null)
     {
         iFrm.SetMessage("Loading Graphics...");
     }
     I9Gfx.LoadSetTypes();
     I9Gfx.LoadEnhTypes();
     I9Gfx.LoadOriginImages();
     I9Gfx.LoadArchetypeImages();
     I9Gfx.LoadPowersetImages();
     MidsContext.Config.Export.LoadCodes(Files.SelectDataFileLoad("BBCode.mhd"));
     iFrm.Opacity = 1.0;
     DatabaseAPI.MatchAllIDs(iFrm);
     if (iFrm != null)
     {
         iFrm.SetMessage("Matching Set Bonus IDs...");
     }
     DatabaseAPI.AssignSetBonusIndexes();
     if (iFrm != null)
     {
         iFrm.SetMessage("Matching Recipe IDs...");
     }
     DatabaseAPI.AssignRecipeIDs();
     GC.Collect();
 }
Example #12
0
        void btnImport_Click(object sender, EventArgs e) => this.EventHandlerWithCatch(() =>
        {
            if (Interaction.MsgBox("Really erase all stored recipes and attempt import?", MsgBoxStyle.YesNo | MsgBoxStyle.Question, "Careful...") != MsgBoxResult.Yes)
            {
                return;
            }
            char[] delimiter             = { '\r' };
            string[] strArray1           = Clipboard.GetDataObject()?.GetData("System.String", true).ToString().Split(delimiter);
            delimiter[0]                 = '\t';
            DatabaseAPI.Database.Recipes = new Recipe[0];
            int num1 = strArray1.Length - 1;
            for (int index1 = 0; index1 <= num1; ++index1)
            {
                string[] strArray2 = strArray1[index1].Split(delimiter);
                if (strArray2.Length <= 7)
                {
                    continue;
                }
                string iName = strArray2[0].Replace("_Memorized", "").LastIndexOf("_", StringComparison.Ordinal) <= 0 ? strArray2[0] : strArray2[0].Substring(0, strArray2[0].Replace("_Memorized", "").LastIndexOf("_", StringComparison.Ordinal));
                if (!char.IsLetterOrDigit(iName[0]))
                {
                    iName = iName.Substring(1);
                }
                Recipe recipe1 = DatabaseAPI.GetRecipeByName(iName);
                if (recipe1 == null)
                {
                    recipe1 =
                        new Recipe
                    {
                        InternalName = iName,
                        ExternalName = strArray2[14] != "" ? "" : strArray2[1],
                        Rarity       = (Recipe.RecipeRarity)Math.Round(Conversion.Val(strArray2[15]) - 1.0)
                    };
                    DatabaseAPI.Database.Recipes = DatabaseAPI.Database.Recipes.Append(recipe1).ToArray();
                }

                int index2 = -1;
                int num2   = recipe1.Item.Length - 1;
                for (int index3 = 0; index3 <= num2; ++index3)
                {
                    if (Math.Abs(recipe1.Item[index3].Level - (Conversion.Val(strArray2[16]) - 1.0)) < float.Epsilon)
                    {
                        index2 = index3;
                    }
                }
                if (index2 < 0)
                {
                    recipe1.Item = (Recipe.RecipeEntry[])Utils.CopyArray(recipe1.Item, new Recipe.RecipeEntry[recipe1.Item.Length + 1]);
                    recipe1.Item[recipe1.Item.Length - 1] = new Recipe.RecipeEntry();
                    index2 = recipe1.Item.Length - 1;
                }
                recipe1.Item[index2].Level = (int)Math.Round(Conversion.Val(strArray2[16]) - 1.0);
                if (strArray2[0].IndexOf("Memorized", StringComparison.Ordinal) > -1)
                {
                    recipe1.Item[index2].BuyCostM   = (int)Math.Round(Conversion.Val(strArray2[19]) - 1.0);
                    recipe1.Item[index2].CraftCostM = (int)Math.Round(Conversion.Val(strArray2[17]) - 1.0);
                }
                else
                {
                    recipe1.Item[index2].BuyCost   = (int)Math.Round(Conversion.Val(strArray2[19]) - 1.0);
                    recipe1.Item[index2].CraftCost = (int)Math.Round(Conversion.Val(strArray2[17]) - 1.0);
                }
                int index4 = 0;
                do
                {
                    if (Conversion.Val(strArray2[4 + index4 * 2]) > 0.0)
                    {
                        recipe1.Item[index2].Count[index4]      = (int)Math.Round(Conversion.Val(strArray2[4 + index4 * 2]));
                        recipe1.Item[index2].Salvage[index4]    = strArray2[5 + index4 * 2];
                        recipe1.Item[index2].SalvageIdx[index4] = -1;
                    }
                    ++index4;
                }while (index4 <= 4);
            }
            DatabaseAPI.AssignRecipeSalvageIDs();
            DatabaseAPI.GuessRecipes();
            DatabaseAPI.AssignRecipeIDs();
            FillList();
            Interaction.MsgBox("Done. Recipe-Enhancement links have been guessed.", MsgBoxStyle.Information, "Import");
        });
        bool ImportRecipeCSV(string iFName1, string iFName2)
        {
            StreamReader iStream;
            StreamReader iStream2;

            try
            {
                iStream  = new StreamReader(iFName1);
                iStream2 = new StreamReader(iFName2);
            }
            catch (Exception ex)
            {
                Exception ex3 = ex;
                Interaction.MsgBox(ex3.Message, MsgBoxStyle.Critical, "Recipe CSVs Not Opened");
                return(false);
            }
            int num5 = 0;
            int num6 = 0;
            int num7 = 0;
            int num8 = 0;

            Recipe[] recipeArray = new Recipe[0];
            DatabaseAPI.Database.Recipes = recipeArray;
            try
            {
                string iLine2;
                do
                {
                    iLine2 = FileIO.ReadLineUnlimited(iStream, '\0');
                    if (iLine2 != null && !iLine2.StartsWith("#"))
                    {
                        num8++;
                        if (num8 >= 18)
                        {
                            this.BusyMsg(Strings.Format(num5, "###,##0") + " Recipes Created.");
                            num8 = 0;
                        }
                        string[] array = CSV.ToArray(iLine2);
                        if (array.Length >= 18)
                        {
                            bool   flag  = false;
                            string iName = array[0];
                            if (iName.Contains("_Memorized"))
                            {
                                iName = iName.Replace("_Memorized", "");
                                flag  = true;
                            }
                            if (iName.LastIndexOf("_", StringComparison.Ordinal) > 0)
                            {
                                iName = iName.Substring(0, iName.LastIndexOf("_", StringComparison.Ordinal));
                            }
                            int    num9   = (int)Math.Round(Conversion.Val(array[10]));
                            Recipe recipe = DatabaseAPI.GetRecipeByName(iName);
                            if (recipe == null)
                            {
                                IDatabase database = DatabaseAPI.Database;
                                recipeArray      = (Recipe[])Utils.CopyArray(database.Recipes, new Recipe[DatabaseAPI.Database.Recipes.Length + 1]);
                                database.Recipes = recipeArray;
                                DatabaseAPI.Database.Recipes[DatabaseAPI.Database.Recipes.Length - 1] = new Recipe();
                                recipe = DatabaseAPI.Database.Recipes[DatabaseAPI.Database.Recipes.Length - 1];
                                Recipe recipe2 = recipe;
                                recipe2.InternalName = iName;
                                if (array[1] != "")
                                {
                                    recipe2.ExternalName = array[1];
                                }
                                else
                                {
                                    recipe2.ExternalName = iName;
                                }
                                recipe2.Rarity = (Recipe.RecipeRarity)Math.Round(Conversion.Val(array[9]) - 1.0);
                            }
                            int    index   = -1;
                            Recipe recipe3 = recipe;
                            int    num10   = recipe3.Item.Length - 1;
                            for (int index2 = 0; index2 <= num10; index2++)
                            {
                                if (recipe3.Item[index2].Level == num9 - 1)
                                {
                                    index = index2;
                                }
                            }
                            if (index < 0)
                            {
                                index               = recipe3.Item.Length;
                                recipe3.Item        = (Recipe.RecipeEntry[])Utils.CopyArray(recipe3.Item, new Recipe.RecipeEntry[index + 1]);
                                recipe3.Item[index] = new Recipe.RecipeEntry();
                            }
                            recipe3.Item[index].Level = num9 - 1;
                            if (flag)
                            {
                                recipe3.Item[index].BuyCostM   = (int)Math.Round(Conversion.Val(array[15]));
                                recipe3.Item[index].CraftCostM = (int)Math.Round(Conversion.Val(array[11]));
                            }
                            else
                            {
                                recipe3.Item[index].BuyCost   = (int)Math.Round(Conversion.Val(array[15]));
                                recipe3.Item[index].CraftCost = (int)Math.Round(Conversion.Val(array[11]));
                            }
                            if (array[7].Length > 0)
                            {
                                int index3 = DatabaseAPI.NidFromUidEnhExtended(array[7]);
                                if (index3 > -1)
                                {
                                    recipe3.Enhancement = DatabaseAPI.Database.Enhancements[index3].UID;
                                    DatabaseAPI.Database.Enhancements[index3].RecipeName = recipe3.InternalName;
                                }
                            }
                            num5++;
                        }
                    }
                }while (iLine2 != null);
                iStream.Close();
                num5 = 0;
                do
                {
                    iLine2 = FileIO.ReadLineUnlimited(iStream2, '\0');
                    if (iLine2 != null && !iLine2.StartsWith("#"))
                    {
                        num8++;
                        if (num8 >= 18)
                        {
                            this.BusyMsg(Strings.Format(num5, "###,##0") + " Recipes Created.");
                            num8 = 0;
                        }
                        string[] array2 = CSV.ToArray(iLine2);
                        if (array2.Length >= 3)
                        {
                            int    num11  = -1;
                            bool   flag2  = false;
                            string iName2 = array2[0];
                            if (iName2.Contains("_Memorized"))
                            {
                                iName2 = iName2.Replace("_Memorized", "");
                                flag2  = true;
                            }
                            if (iName2.LastIndexOf("_", StringComparison.Ordinal) > 0)
                            {
                                num11  = (int)Math.Round(Conversion.Val(iName2.Substring(iName2.LastIndexOf("_", StringComparison.Ordinal) + 1)));
                                iName2 = iName2.Substring(0, iName2.LastIndexOf("_", StringComparison.Ordinal));
                            }
                            if (num11 > -1 & !flag2)
                            {
                                Recipe recipeByName = DatabaseAPI.GetRecipeByName(iName2);
                                if (recipeByName != null)
                                {
                                    int index4 = -1;
                                    num5++;
                                    Recipe recipe4 = recipeByName;
                                    int    num12   = recipe4.Item.Length - 1;
                                    for (int index5 = 0; index5 <= num12; index5++)
                                    {
                                        if (recipe4.Item[index5].Level == num11 - 1)
                                        {
                                            index4 = index5;
                                        }
                                    }
                                    if (index4 > -1)
                                    {
                                        int index6 = -1;
                                        int num13  = recipe4.Item[index4].Salvage.Length - 1;
                                        for (int index7 = 0; index7 <= num13; index7++)
                                        {
                                            if (recipe4.Item[index4].Salvage[index7] == "")
                                            {
                                                index6 = index7;
                                                break;
                                            }
                                        }
                                        if (index6 > -1)
                                        {
                                            recipe4.Item[index4].Salvage[index6]    = array2[2];
                                            recipe4.Item[index4].Count[index6]      = (int)Math.Round(Conversion.Val(array2[1]));
                                            recipe4.Item[index4].SalvageIdx[index6] = -1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }while (iLine2 != null);
                DatabaseAPI.AssignRecipeSalvageIDs();
                DatabaseAPI.GuessRecipes();
                DatabaseAPI.AssignRecipeIDs();
                Interaction.MsgBox("Done. Recipe-Enhancement links have been guessed.", MsgBoxStyle.Information, "Import");
            }
            catch (Exception ex2)
            {
                Exception exception = ex2;
                iStream.Close();
                iStream2.Close();
                this.BusyHide();
                Interaction.MsgBox(exception.Message, MsgBoxStyle.Critical, "CSV Parse Error");
                return(false);
            }
            this.BusyHide();
            iStream2.Close();
            Interaction.MsgBox(string.Concat(new string[]
            {
                "Parse Completed!\r\nTotal Records: ",
                Conversions.ToString(num5),
                "\r\nGood: ",
                Conversions.ToString(num6),
                "\r\nRejected: ",
                Conversions.ToString(num7)
            }), MsgBoxStyle.Information, "File Parsed");
            DatabaseAPI.SaveRecipes();
            DatabaseAPI.SaveEnhancementDb();
            return(true);
        }