public static void SetModifiedValueButtonAttackType <T>(string name, string guid)
 {
     foreach (AttackType attackType in (AttackType[])Enum.GetValues(typeof(AttackType)))
     {
         if (GL.Button(Strings.GetText("button_SetTo") + $" {attackType}", GL.ExpandWidth(false)))
         {
             FileInfo file = new FileInfo(Storage.modEntryPath + Storage.modifiedBlueprintsFolder + "\\" + guid + ".json");
             if (File.Exists(file.FullName))
             {
                 T modifiedItem = ModifiedBlueprintTools.DeserialiseItem <T>(file);
                 Traverse.Create(modifiedItem).Property(name).SetValue(attackType);
                 string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented);
                 File.WriteAllText(file.FullName, json);
             }
             else
             {
                 T modifiedItem = default(T);
                 modifiedItem = Activator.CreateInstance <T>();
                 Traverse.Create(modifiedItem).Property(name).SetValue(attackType);
                 string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented);
                 File.WriteAllText(file.FullName, json);
             }
             ModifiedBlueprintTools.blueprintLists = false;
             ModifiedBlueprintTools.Patch();
         }
     }
 }
 public static void SetModifiedValueButtonDiceFormula <T>(int rolls, DiceType dice, string name, string guid)
 {
     if (GL.Button(Strings.GetText("button_SetTo") + $" {rolls} * {dice}", GL.ExpandWidth(false)))
     {
         ModifiedDiceFormula diceFormula = new ModifiedDiceFormula();
         diceFormula.m_Rolls = rolls;
         diceFormula.m_Dice  = dice;
         FileInfo file = new FileInfo(Storage.modEntryPath + Storage.modifiedBlueprintsFolder + "\\" + guid + ".json");
         if (File.Exists(file.FullName))
         {
             T modifiedItem = ModifiedBlueprintTools.DeserialiseItem <T>(file);
             Traverse.Create(modifiedItem).Property(name).SetValue(diceFormula);
             string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented);
             File.WriteAllText(file.FullName, json);
         }
         else
         {
             T modifiedItem = default(T);
             modifiedItem = Activator.CreateInstance <T>();
             Traverse.Create(modifiedItem).Property(name).SetValue(diceFormula);
             string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented);
             File.WriteAllText(file.FullName, json);
         }
         ModifiedBlueprintTools.blueprintLists = false;
         ModifiedBlueprintTools.Patch();
     }
 }
 public static void SetModifiedValueStatType <T>(string name, string guid)
 {
     StatType[] statTypes = (StatType[])Enum.GetValues(typeof(StatType));
     for (int i = 0; i < statTypes.Count(); i++)
     {
         switch (i)
         {
         case 0:
         case 4:
         case 8:
         case 12:
         case 16:
         case 20:
         case 24:
         case 28:
         case 32:
         case 36:
             GL.BeginHorizontal();
             break;
         }
         if (GL.Button(Strings.GetText("button_SetTo") + $" {statTypes[i]}", GL.Width(210f)))
         {
             FileInfo file = new FileInfo(Storage.modEntryPath + Storage.modifiedBlueprintsFolder + "\\" + guid + ".json");
             if (File.Exists(file.FullName))
             {
                 T modifiedItem = ModifiedBlueprintTools.DeserialiseItem <T>(file);
                 Traverse.Create(modifiedItem).Property(name).SetValue(statTypes[i]);
                 string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented);
                 File.WriteAllText(file.FullName, json);
             }
             else
             {
                 T modifiedItem = default(T);
                 modifiedItem = Activator.CreateInstance <T>();
                 Traverse.Create(modifiedItem).Property(name).SetValue(statTypes[i]);
                 string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented);
                 File.WriteAllText(file.FullName, json);
             }
             ModifiedBlueprintTools.blueprintLists = false;
             ModifiedBlueprintTools.Patch();
         }
         switch (i)
         {
         case 3:
         case 7:
         case 11:
         case 15:
         case 19:
         case 23:
         case 27:
         case 31:
         case 35:
         case 37:
             GL.EndHorizontal();
             break;
         }
     }
 }
        public static void RenderMenu()
        {
            GL.BeginVertical("box");
            GL.BeginHorizontal();
            GL.Label(RichText.MainCategoryFormat(Strings.GetText("mainCategory_BlueprintModding")));
            GL.FlexibleSpace();
            MenuTools.AddFavouriteButton("BlueprintModdingRender");
            GL.EndHorizontal();


            GL.BeginHorizontal();
            if (GL.Button(MenuTools.TextWithTooltip("misc_Enable", "tooltip_BlueprintModding", $"{ settings.toggleItemModding}" + " ", "", false), GL.ExpandWidth(false)))
            {
                if (settings.toggleItemModding == Storage.isFalseString)
                {
                    settings.toggleItemModding = Storage.isTrueString;
                    ModifiedBlueprintTools.Patch();
                }
                else if (settings.toggleItemModding == Storage.isTrueString)
                {
                    settings.toggleItemModding = Storage.isFalseString;
                }
            }
            GL.EndHorizontal();

            if (Strings.ToBool(settings.toggleItemModding))
            {
                MenuTools.SingleLineLabel(Strings.GetText("label_ItemModdingInfo"));

                GL.BeginHorizontal();
                if (GL.Button(new GUIContent("spacehamster's JSON Blueprint Dump on github", "https://github.com/spacehamster/KingmakerCustomBlueprints/releases/tag/blueprints"), GL.ExpandWidth(false)))
                {
                    Application.OpenURL("https://github.com/spacehamster/KingmakerCustomBlueprints/releases/tag/blueprints");
                }
                GL.EndHorizontal();

                GL.Space(10);

                GL.BeginHorizontal();
                if (GL.Button(MenuTools.TextWithTooltip("button_PatchManually", "tooltip_PatchManually", true), GL.ExpandWidth(false)))
                {
                    Patch();
                }
                GL.EndHorizontal();


                GL.Space(10);

                ItemTypesMenu();

                GL.Space(10);

                showModifiedBlueprints = GL.Toggle(showModifiedBlueprints, RichText.Bold(Strings.GetText("toggle_ShowModifiedItems")));
                if (showModifiedBlueprints)
                {
                    GL.Space(10);

                    GL.BeginHorizontal();
                    if (GL.Button(RichText.Bold(Strings.GetText("button_LoadRefresh")), GL.ExpandWidth(false)))
                    {
                        blueprintLists = false;
                    }
                    GL.EndHorizontal();

                    GL.Space(10);

                    try
                    {
                        if (!blueprintLists)
                        {
                            blueprintsPaths.Clear();
                            blueprintsNames.Clear();
                            blueprintsTypes.Clear();
                            string        path      = Storage.modEntryPath + Storage.modifiedBlueprintsFolder;
                            DirectoryInfo directory = new DirectoryInfo(path);
                            if (directory.GetFiles("*.json").Any())
                            {
                                foreach (FileInfo file in directory.GetFiles("*.json"))
                                {
                                    string json = File.ReadAllText(file.FullName);
                                    string guid = Path.GetFileNameWithoutExtension(file.Name);

                                    if (guid == "Example" && directory.GetFiles("*.json").Count() == 1)
                                    {
                                        MenuTools.SingleLineLabel(Strings.GetText("message_NoModItems"));
                                        continue;
                                    }
                                    else if (guid == "Example" && directory.GetFiles("*.json").Count() > 1)
                                    {
                                        continue;
                                    }

                                    BlueprintScriptableObject blueprintScriptableObject = Utilities.GetBlueprintByGuid <BlueprintScriptableObject>(guid);

                                    if (blueprintScriptableObject != null)
                                    {
                                        if (blueprintItemCategory.Contains(blueprintScriptableObject.GetType()) || blueprintTypeArmourCategory.Contains(blueprintScriptableObject.GetType()) || blueprintScriptableObject.GetType() == blueprintWeaponType)
                                        {
                                            blueprintsPaths.Add(file.FullName);
                                            blueprintsNames.Add(blueprintScriptableObject.name);
                                            blueprintsTypes.Add(blueprintScriptableObject.GetType().ToString());
                                        }
                                    }
                                }
                            }
                            blueprintLists = true;
                        }

                        if (blueprintsPaths.Any())
                        {
                            for (int i = 0; i < blueprintsPaths.Count(); i++)
                            {
                                GL.BeginVertical("box");
                                GL.BeginHorizontal();
                                GL.Label(blueprintsNames[i] + $" ({blueprintsTypes[i]})");
                                GL.FlexibleSpace();
                                if (GL.Button(MenuTools.TextWithTooltip("button_RemoveItemModification", "misc_RequiresRestart", true), GL.ExpandWidth(false)))
                                {
                                    try
                                    {
                                        blueprintLists = false;
                                        File.Delete(blueprintsPaths[i]);
                                    }
                                    catch (Exception e)
                                    {
                                        modLogger.Log(e.ToString());
                                    }
                                }
                                GL.EndHorizontal();
                                GL.EndVertical();
                            }
                        }
                        else
                        {
                            MenuTools.SingleLineLabel(Strings.GetText("message_NoModItems"));
                        }
                    }
                    catch (Exception e)
                    {
                        modLogger.Log(e.ToString());
                    }
                }
            }
            GL.EndVertical();
        }