Example #1
0
        public void AppendErrorMessage(string text, string shortRimWorldMessage = null,
                                       bool rimWorldAlertMessage = true, bool sendToLog = false)
        {
            if (rimWorldAlertMessage)
            {
                if (PrepareLanding.Instance.MainWindow == null)
                {
                    Log.Error("[PrepareLanding] Main window is null in this context.");
                    return;
                }

                var tab          = PrepareLanding.Instance.MainWindow.TabController.TabById("WorldInfo");
                var tabName      = tab == null ? "World Info" : tab.Name;
                var shortMessage = shortRimWorldMessage == null ? "" : $": {shortRimWorldMessage}";
                Messages.Message(
                    $"[PrepareLanding] A filter error occurred{shortMessage}\nPlease see the \"{tabName}\" tab for an error description.",
                    MessageSound.RejectInput);
            }

            if (sendToLog)
            {
                Log.Message($"[PrepareLanding] {text}");
            }

            var errorText = RichText.Bold(RichText.Color(text, Color.red));

            AppendLine(errorText);
        }
Example #2
0
        public void AppendErrorMessage(string text, string shortRimWorldMessage = null,
                                       bool rimWorldAlertMessage = true, bool sendToLog = false)
        {
            if (rimWorldAlertMessage)
            {
                if (PrepareLanding.Instance.MainWindow == null)
                {
                    Log.Error("[PrepareLanding] Main window is null in this context.");
                    return;
                }

                var tab          = PrepareLanding.Instance.MainWindow.TabController.TabById("WorldInfo");
                var tabName      = tab == null ? "PLMWINF_WorldInfo".Translate() : tab.Name;
                var shortMessage = shortRimWorldMessage.NullOrEmpty() ? "" : $": {shortRimWorldMessage}";
                Messages.Message(
                    $"[PrepareLanding] {string.Format("PLFILIL_FilterErrorOccurred".Translate(), shortMessage, tabName)}",
                    MessageTypeDefOf.RejectInput);
            }

            if (sendToLog)
            {
                Log.Message($"[PrepareLanding] {text}");
            }

            var errorText = RichText.Bold(RichText.Color(text, Color.red));

            AppendLine(errorText);
        }
Example #3
0
        public void AppendWarningMessage(string text, bool sendToLog = false)
        {
            if (sendToLog)
            {
                Log.Message($"[PrepareLanding] {text}");
            }

            var warningText = RichText.Bold(RichText.Color(text, ColorLibrary.Orange));

            AppendLine(warningText);
        }
Example #4
0
        public void AppendSuccessMessage(string text, bool sendToLog = false)
        {
            if (sendToLog)
            {
                Log.Message($"[PrepareLanding] {text}");
            }

            var successText = RichText.Bold(RichText.Color(text, Color.green));

            AppendLine(successText);
        }
        public static void ItemTypesMenu()
        {
            showItemTypes = GL.Toggle(showItemTypes, RichText.Bold(Strings.GetText("toggle_ShowItemTypes")));
            if (showItemTypes)
            {
                GL.Space(10);
                itemTypesGrid.Render();
                GL.Space(10);
                if (selectedItemTypeOld != itemTypesGrid.selected)
                {
                    selectedItemTypeOld = itemTypesGrid.selected;
                    refreshItemTypes    = true;
                }
                switch (itemTypesGrid.selected)
                {
                case 0:
                    List <BlueprintArmorType> blueprintArmorTypes = ResourcesLibrary.GetBlueprints <BlueprintArmorType>().ToList();
                    if (refreshItemTypes)
                    {
                        itemTypeEdit.Clear();
                        foreach (BlueprintArmorType b in blueprintArmorTypes)
                        {
                            itemTypeEdit.Add(false);
                        }
                        refreshItemTypes = false;
                    }

                    for (int i = 0; i < blueprintArmorTypes.Count(); i++)
                    {
                        itemTypeEdit[i] = GL.Toggle(itemTypeEdit[i], blueprintArmorTypes[i].name);
                        if (itemTypeEdit[i])
                        {
                            GL.BeginVertical("box");

                            GL.BeginHorizontal();
                            GL.Label("m_ArcaneSpellFailureChance: " + blueprintArmorTypes[i].ArcaneSpellFailureChance.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArcaneSpellFailureChance", blueprintArmorTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_ArmorBonus: " + blueprintArmorTypes[i].ArmorBonus.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArmorBonus", blueprintArmorTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_ArmorChecksPenalty: " + blueprintArmorTypes[i].ArmorChecksPenalty.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArmorChecksPenalty", blueprintArmorTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_HasDexterityBonusLimit: " + blueprintArmorTypes[i].HasDexterityBonusLimit.ToString());
                            SetModifiedValueButtonBool <ModifiedArmourType>("m_HasDexterityBonusLimit", blueprintArmorTypes[i].AssetGuid);
                            GL.EndHorizontal();


                            GL.BeginHorizontal();
                            GL.Label("m_MaxDexterityBonus: " + blueprintArmorTypes[i].MaxDexterityBonus.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_MaxDexterityBonus", blueprintArmorTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_Weight: " + blueprintArmorTypes[i].Weight.ToString());
                            itemTypesTextFieldFloat.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldFloat.finalAmount, "m_Weight", blueprintArmorTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.EndVertical();
                        }
                    }
                    break;

                case 1:
                    List <BlueprintShieldType> blueprintShieldTypes = ResourcesLibrary.GetBlueprints <BlueprintShieldType>().ToList();
                    if (refreshItemTypes)
                    {
                        itemTypeEdit.Clear();
                        foreach (BlueprintShieldType b in blueprintShieldTypes)
                        {
                            itemTypeEdit.Add(false);
                        }
                        refreshItemTypes = false;
                    }

                    for (int i = 0; i < blueprintShieldTypes.Count(); i++)
                    {
                        itemTypeEdit[i] = GL.Toggle(itemTypeEdit[i], blueprintShieldTypes[i].name);
                        if (itemTypeEdit[i])
                        {
                            GL.BeginVertical("box");

                            GL.BeginHorizontal();
                            GL.Label("m_ArcaneSpellFailureChance: " + blueprintShieldTypes[i].ArcaneSpellFailureChance.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArcaneSpellFailureChance", blueprintShieldTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_ArmorBonus: " + blueprintShieldTypes[i].ArmorBonus.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArmorBonus", blueprintShieldTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_ArmorChecksPenalty: " + blueprintShieldTypes[i].ArmorChecksPenalty.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArmorChecksPenalty", blueprintShieldTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_HasDexterityBonusLimit: " + blueprintShieldTypes[i].HasDexterityBonusLimit.ToString());
                            SetModifiedValueButtonBool <ModifiedArmourType>("m_HasDexterityBonusLimit", blueprintShieldTypes[i].AssetGuid);
                            GL.EndHorizontal();


                            GL.BeginHorizontal();
                            GL.Label("m_MaxDexterityBonus: " + blueprintShieldTypes[i].MaxDexterityBonus.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_MaxDexterityBonus", blueprintShieldTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_Weight: " + blueprintShieldTypes[i].Weight.ToString());
                            itemTypesTextFieldFloat.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldFloat.finalAmount, "m_Weight", blueprintShieldTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.EndVertical();
                        }
                    }
                    break;

                case 2:
                    List <BlueprintWeaponType> blueprintWeaponTypes = ResourcesLibrary.GetBlueprints <BlueprintWeaponType>().ToList();
                    if (refreshItemTypes)
                    {
                        itemTypeEdit.Clear();
                        foreach (BlueprintWeaponType b in blueprintWeaponTypes)
                        {
                            itemTypeEdit.Add(false);
                        }
                        refreshItemTypes = false;
                    }

                    for (int i = 0; i < blueprintWeaponTypes.Count(); i++)
                    {
                        itemTypeEdit[i] = GL.Toggle(itemTypeEdit[i], blueprintWeaponTypes[i].name);
                        if (itemTypeEdit[i])
                        {
                            GL.BeginVertical("box");

                            GL.BeginHorizontal();
                            GL.Label("m_AttackType: " + blueprintWeaponTypes[i].AttackType.ToString());
                            SetModifiedValueButtonAttackType <ModifiedWeaponType>("m_AttackType", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();


                            GL.BeginHorizontal();
                            GL.Label("m_AttackRange: " + Traverse.Create(blueprintWeaponTypes[i]).Field("m_AttackRange").GetValue().ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedWeaponType>(itemTypesTextFieldInt.finalAmount.Feet(), "m_AttackRange", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();
                            MenuTools.SingleLineLabel("AttackRange = (m_AttackRange > 10) ? m_AttackRange : Math.Max(2, m_AttackRange - 4)");

                            GL.BeginVertical("box");
                            GL.BeginHorizontal();
                            GL.Label("m_BaseDamage: " + blueprintWeaponTypes[i].BaseDamage.ToString());
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            itemTypesTextFieldInt.RenderFieldNoGroup("misc_NumberOfRolls");
                            GL.EndHorizontal();

                            diceTypesGrid.Render();

                            GL.BeginHorizontal();
                            GL.FlexibleSpace();
                            SetModifiedValueButtonDiceFormula <ModifiedWeaponType>(itemTypesTextFieldInt.finalAmount, Common.IntToDiceType(diceTypesGrid.selected), "m_BaseDamage", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();
                            GL.EndVertical();

                            GL.BeginHorizontal();
                            GL.Label("m_CriticalRollEdge: " + blueprintWeaponTypes[i].CriticalRollEdge.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedWeaponType>(itemTypesTextFieldInt.finalAmount, "m_CriticalRollEdge", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_CriticalModifier: " + blueprintWeaponTypes[i].CriticalModifier.ToString());
                            SetModifiedValueDamageCriticalModifierType <ModifiedWeaponType>("m_CriticalModifier", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_Weight: " + blueprintWeaponTypes[i].Weight.ToString());
                            itemTypesTextFieldFloat.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedWeaponType>(itemTypesTextFieldFloat.finalAmount, "m_Weight", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_IsTwoHanded: " + blueprintWeaponTypes[i].IsTwoHanded.ToString());
                            SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsTwoHanded", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_IsLight: " + blueprintWeaponTypes[i].IsLight.ToString());
                            SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsLight", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_IsMonk: " + blueprintWeaponTypes[i].IsMonk.ToString());
                            SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsMonk", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_IsNatural: " + blueprintWeaponTypes[i].IsNatural.ToString());
                            SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsNatural", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_IsUnarmed: " + blueprintWeaponTypes[i].IsUnarmed.ToString());
                            SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsUnarmed", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_OverrideAttackBonusStat: " + Traverse.Create(blueprintWeaponTypes[i]).Field("m_OverrideAttackBonusStat").GetValue().ToString());
                            SetModifiedValueButtonBool <ModifiedWeaponType>("m_OverrideAttackBonusStat", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();


                            GL.BeginVertical("box");
                            GL.BeginHorizontal();
                            GL.Label("m_AttackBonusStatOverride: " + Traverse.Create(blueprintWeaponTypes[i]).Field("m_AttackBonusStatOverride").GetValue().ToString());
                            GL.EndHorizontal();
                            SetModifiedValueStatType <ModifiedWeaponType>("m_AttackBonusStatOverride", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndVertical();


                            GL.EndVertical();
                        }
                    }
                    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();
        }
        public static void RenderMenu()
        {
            GL.BeginVertical("box");
            GL.BeginHorizontal();
            GL.Label(RichText.MainCategoryFormat(Strings.GetText("label_ActionKey")));
            GL.FlexibleSpace();
            MenuTools.AddFavouriteButton("ActionKeyRender");
            GL.EndHorizontal();

            GL.BeginHorizontal();
            if (GL.Button(
                    MenuTools.TextWithTooltip("misc_Enable", "tooltip_ActionKey", $"{settings.toggleEnableActionKey}" + " ",
                                              ""), GL.ExpandWidth(false)))
            {
                if (settings.toggleEnableActionKey == Storage.isFalseString)
                {
                    settings.toggleEnableActionKey = Storage.isTrueString;
                    settings.actionKeyIndex        = 0;
                    settings.actionKeyKillIndex    = 0;
                }
                else if (settings.toggleEnableActionKey == Storage.isTrueString)
                {
                    settings.toggleEnableActionKey = Storage.isFalseString;
                    settings.actionKeyIndex        = 0;
                    settings.actionKeyKillIndex    = 0;
                }
            }

            GL.EndHorizontal();

            if (settings.toggleEnableActionKey == Storage.isTrueString)
            {
                GL.Space(10);

                GL.BeginHorizontal();
                GL.Label(Strings.GetText("label_ActionKey") + ": ", GL.ExpandWidth(false));
                MenuTools.SetKeyBinding(ref settings.actionKey);
                GL.EndHorizontal();

                GL.Space(10);

                GL.BeginHorizontal();
                if (GL.Button(
                        MenuTools.TextWithTooltip("label_ActionKeyEnableExperimental",
                                                  "tooltip_ActionKeyEnableExperimental", $"{settings.toggleActionKeyExperimental}" + " ", ""),
                        GL.ExpandWidth(false)))
                {
                    if (settings.toggleActionKeyExperimental == Storage.isFalseString)
                    {
                        settings.toggleActionKeyExperimental = Storage.isTrueString;
                        settings.actionKeyIndex     = 0;
                        settings.actionKeyKillIndex = 0;
                    }
                    else if (settings.toggleActionKeyExperimental == Storage.isTrueString)
                    {
                        settings.toggleActionKeyExperimental = Storage.isFalseString;
                        settings.actionKeyIndex     = 0;
                        settings.actionKeyKillIndex = 0;
                    }
                }

                GL.EndHorizontal();

                MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("warning_ActionKeyExperimentalMode")));

                GL.BeginHorizontal();
                if (!Strings.ToBool(settings.toggleActionKeyExperimental))
                {
                    settings.actionKeyIndex = GL.SelectionGrid(settings.actionKeyIndex, mainArray, 3);
                }
                else
                {
                    settings.actionKeyIndex = GL.SelectionGrid(settings.actionKeyIndex, mainExperimentalArray, 3);
                }
                GL.EndHorizontal();

                GL.Space(10);

                switch (settings.actionKeyIndex)
                {
                case 1:
                    MenuTools.ToggleButton(ref settings.toggleActionKeyLogInfo, "buttonToggle_LogInfoToFile",
                                           "tooltip_LogInfoToFile");
                    MenuTools.ToggleButton(ref settings.toggleActionKeyShowUnitInfoBox,
                                           "buttonToggle_ShowUnitInfoBox", "tooltip_ShowUnitInfoBox");

                    break;

                case 2:
                    if (Strings.ToBool(settings.toggleActionKeyExperimental))
                    {
                        GL.Space(10);
                        GL.BeginHorizontal();
                        settings.actionKeyKillIndex =
                            GL.SelectionGrid(settings.actionKeyKillIndex, experimentalKillArray, 3);
                        GL.EndHorizontal();
                    }

                    break;

                case 4:
                    if (!Storage.buffFavourites.Any())
                    {
                        MenuTools.SingleLineLabel(Strings.GetText("message_NoFavourites"));
                    }
                    else
                    {
                        if (Storage.buffFavouritesLoad == true)
                        {
                            Main.RefreshBuffFavourites();
                            Storage.buffFavouritesLoad = false;
                        }

                        GL.Space(10);
                        GL.BeginHorizontal();
                        settings.actionKeyBuffIndex = GL.SelectionGrid(settings.actionKeyBuffIndex,
                                                                       Storage.buffFavouriteNames.ToArray(), 2);
                        GL.EndHorizontal();
                    }

                    if (Storage.buffFavourites != Storage.buffFavouritesGuids)
                    {
                        Storage.buffFavourites = Storage.buffFavouritesGuids;
                    }
                    break;

                case 5:
                    if (editUnit != null && editUnit.IsInGame && !editUnit.Descriptor.State.IsFinallyDead)
                    {
                        ActionKeyEditStatsGui(editUnit);
                    }
                    else
                    {
                        MenuTools.SingleLineLabel(Strings.GetText("message_NoUnitSelected"));
                    }
                    break;

                case 6:
                    if (teleportUnit != null && teleportUnit.IsInGame)
                    {
                        MenuTools.SingleLineLabel(Strings.GetText("label_TeleportUnit") +
                                                  $": {teleportUnit.CharacterName}");
                    }
                    else
                    {
                        MenuTools.SingleLineLabel(Strings.GetText("message_NoUnitSelected"));
                    }
                    break;

                case 7:
                    if (Strings.ToBool(settings.toggleActionKeyExperimental))
                    {
                        settings.actionKeySpawnRandomEnemy = GL.Toggle(settings.actionKeySpawnRandomEnemy,
                                                                       " " + Strings.GetText("toggle_SpawnRandomEnemy"), GL.ExpandWidth(false));
                    }

                    GL.Space(10);

                    MenuTools.SingleLineLabel(Strings.GetText("label_ChallengeRating") + " " +
                                              Strings.Parenthesis(Strings.GetText("misc_Bandit")));
                    GL.BeginHorizontal();
                    banidtCrIndex = GL.SelectionGrid(banidtCrIndex, numberArray0t7, 8);
                    GL.EndHorizontal();

                    break;

                case 8:
                    if (rotateUnit != null && rotateUnit.IsInGame)
                    {
                        MenuTools.SingleLineLabel(Strings.GetText("arrayItem_ActionKeyMain_RotateUnit") +
                                                  $": {rotateUnit.CharacterName}");
                    }
                    else
                    {
                        MenuTools.SingleLineLabel(Strings.GetText("message_NoUnitSelected"));
                    }
                    break;

                case 9:
                    if (load)
                    {
                        animationTypes.Clear();
                        animationTypesNames.Clear();
                        foreach (var animation in (UnitAnimationType[])Enum.GetValues(typeof(UnitAnimationType)))
                        {
                            animationTypes.Add(animation);
                            animationTypesNames.Add(animation.ToString());
                        }

                        load = false;
                    }

                    GL.BeginHorizontal();
                    animationTypesIndex = GL.SelectionGrid(animationTypesIndex, animationTypesNames.ToArray(), 3);
                    GL.EndHorizontal();
                    break;

                case 13:
                    MenuTools.SingleLineLabel(Strings.GetText("message_RecreateUnitDescriptor"));
                    break;
                }
            }

            GL.EndVertical();
        }
        public static void ActionKeyEditStatsGui(UnitEntityData unit)
        {
            GL.Space(10);
            GL.BeginHorizontal();
            editUnitSelectedSizeIndex = GL.SelectionGrid(editUnitSelectedSizeIndex, Storage.charSizeArray, 4);
            GL.EndHorizontal();

            GL.Space(10);
            GL.BeginHorizontal();
            if (GL.Button(Strings.GetText("button_SetSizeTo") + $" {Storage.charSizeArray[editUnitSelectedSizeIndex]}",
                          GL.ExpandWidth(false)))
            {
                unit.Descriptor.State.Size = (Size)editUnitSelectedSizeIndex;
            }
            GL.EndHorizontal();
            GL.BeginHorizontal();
            if (GL.Button(Strings.GetText("button_SetToOriginalSize") + $" ({unit.Descriptor.OriginalSize})",
                          GL.ExpandWidth(false)))
            {
                unit.Descriptor.State.Size = unit.Descriptor.OriginalSize;
            }
            GL.EndHorizontal();
            MenuTools.SingleLineLabel(Strings.GetText("label_CurrentSize") + ": " + unit.Descriptor.State.Size);
            GL.Space(10);

            GL.BeginHorizontal();
            if (unit.Descriptor.HPLeft > 0)
            {
                if (GL.Button(Strings.GetText("button_Kill"), GL.ExpandWidth(false)))
                {
                    Common.Kill(unit);
                }
                if (GL.Button(Strings.GetText("button_Panic"), GL.ExpandWidth(false)))
                {
                    unit.Descriptor.AddFact(
                        (BlueprintUnitFact)Utilities.GetBlueprintByGuid <BlueprintBuff>(
                            "cf0e277e6b785f449bbaf4e993b556e0"), (MechanicsContext)null, new FeatureParam());
                }
                if (GL.Button(Strings.GetText("button_Freeze"), GL.ExpandWidth(false)))
                {
                    unit.Descriptor.AddFact(
                        (BlueprintUnitFact)Utilities.GetBlueprintByGuid <BlueprintBuff>(
                            "af1e2d232ebbb334aaf25e2a46a92591"), (MechanicsContext)null, new FeatureParam());
                }
                if (GL.Button(Strings.GetText("button_MakeCower"), GL.ExpandWidth(false)))
                {
                    unit.Descriptor.AddFact(
                        (BlueprintUnitFact)Utilities.GetBlueprintByGuid <BlueprintBuff>(
                            "6062e3a8206a4284d867cbb7120dc091"), (MechanicsContext)null, new FeatureParam());
                }
                if (GL.Button(Strings.GetText("button_SetOnFire"), GL.ExpandWidth(false)))
                {
                    unit.Descriptor.AddFact(
                        (BlueprintUnitFact)Utilities.GetBlueprintByGuid <BlueprintBuff>(
                            "315acb0b29671f74c8c7cc062b23b9d6"), (MechanicsContext)null, new FeatureParam());
                }
            }

            GL.EndHorizontal();

            GL.BeginHorizontal();
            editUnitStatsAmount = GL.TextField(editUnitStatsAmount, 10, GL.Width(85f));

            editUnitStatsAmount      = MenuTools.IntTestSettingStage1(editUnitStatsAmount);
            editUnitFinalStatsAmount = MenuTools.IntTestSettingStage2(editUnitStatsAmount, editUnitFinalStatsAmount);
            GL.EndHorizontal();

            var charStats = unit.Descriptor.Stats;

            MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("header_AttributesBaseValues")));
            foreach (var entry in Storage.statsAttributesDict)
            {
                MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, editUnitFinalStatsAmount);
            }
            MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("header_SkillsRanks")));
            foreach (var entry in Storage.statsSkillsDict)
            {
                MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, editUnitFinalStatsAmount);
            }
            MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("header_SocialSkillsBaseValues")));
            foreach (var entry in Storage.statsSocialSkillsDict)
            {
                MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, editUnitFinalStatsAmount);
            }
            MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("header_StatsSaves")));
            foreach (var entry in Storage.statsSavesDict)
            {
                MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, editUnitFinalStatsAmount);
            }
            MenuTools.SingleLineLabel(RichText.Bold(Strings.GetText("header_StatsCombat")));
            foreach (var entry in Storage.statsCombatDict)
            {
                MenuTools.CreateStatInterface(entry.Key, charStats, entry.Value, editUnitFinalStatsAmount);
            }
        }
Example #9
0
        private void DrawWorldRecord()
        {
            DrawEntryHeader("PLMWINF_WorldRecords".Translate(), backgroundColor: Color.yellow);

            if (_gameData.WorldData.WorldCharacteristics == null || _gameData.WorldData.WorldCharacteristics.Count == 0)
            {
                //Log.Error("[PrepareLanding] TabInfo.BuildWorldRecords: No Info");
                return;
            }

            // default line height
            const float gapLineHeight = 4f;

            // add a gap before the scroll view
            ListingStandard.Gap(gapLineHeight);

            /*
             * Calculate heights
             */

            // height of the scrollable outer Rect (visible portion of the scroll view, not the 'virtual' one)
            var maxScrollViewOuterHeight = InRect.height - ListingStandard.CurHeight - DefaultElementHeight;

            // height of the 'virtual' portion of the scroll view
            var numElements          = _gameData.WorldData.WorldCharacteristics.Count * 3; // 1 label + 2 elements  (highest + lowest) = 3
            var scrollableViewHeight = (numElements * DefaultElementHeight) + (_gameData.WorldData.WorldCharacteristics.Count * gapLineHeight);

            /*
             * Scroll view
             */
            var innerLs = ListingStandard.BeginScrollView(maxScrollViewOuterHeight, scrollableViewHeight,
                                                          ref _scrollPosWorldRecords, 16f);

            var selectedTileIndex = 0;

            foreach (var characteristicData in _gameData.WorldData.WorldCharacteristics)
            {
                var characteristicName = characteristicData.CharacteristicName;
                innerLs.Label(RichText.Bold(RichText.Color($"{characteristicName}:", Color.cyan)));

                // there might be no characteristics
                if (characteristicData.WorldTilesCharacteristics.Count == 0)
                {
                    innerLs.Label("No Info [DisableWorldData enabled]");
                    continue;
                }

                /*
                 *   lowest
                 */

                var lowestCharacteristicKvp = characteristicData.WorldTilesCharacteristics.First();

                // we need to follow user preference for temperature.
                var value = characteristicData.Characteristic == MostLeastCharacteristic.Temperature ?
                            GenTemperature.CelsiusTo(lowestCharacteristicKvp.Value, Prefs.TemperatureMode) : lowestCharacteristicKvp.Value;

                var vectorLongLat = Find.WorldGrid.LongLatOf(lowestCharacteristicKvp.Key);
                var textLowest    = $"{"PLMWINF_WorldLowest".Translate()} {characteristicName}: {value:F1} {characteristicData.CharacteristicMeasureUnit} [{lowestCharacteristicKvp.Key}; {vectorLongLat.y.ToStringLatitude()} - {vectorLongLat.x.ToStringLongitude()}]";

                var labelRect = innerLs.GetRect(DefaultElementHeight);
                var selected  = selectedTileIndex == _worldRecordSelectedTileIndex;
                if (Core.Gui.Widgets.LabelSelectable(labelRect, textLowest, ref selected, TextAnchor.MiddleLeft))
                {
                    // go to the location of the selected tile
                    _worldRecordSelectedTileIndex    = selectedTileIndex;
                    Find.WorldInterface.SelectedTile = lowestCharacteristicKvp.Key;
                    Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
                }

                selectedTileIndex++;

                /*
                 *   highest
                 */

                var highestCharacteristicKvp = characteristicData.WorldTilesCharacteristics.Last();
                // we need to follow user preference for temperature.
                value = characteristicData.Characteristic == MostLeastCharacteristic.Temperature ?
                        GenTemperature.CelsiusTo(highestCharacteristicKvp.Value, Prefs.TemperatureMode) : highestCharacteristicKvp.Value;

                vectorLongLat = Find.WorldGrid.LongLatOf(highestCharacteristicKvp.Key);
                var textHighest = $"{"PLMWINF_WorldHighest".Translate()} {characteristicName}: {value:F1} {characteristicData.CharacteristicMeasureUnit} [{highestCharacteristicKvp.Key}; {vectorLongLat.y.ToStringLatitude()} - {vectorLongLat.x.ToStringLongitude()}]";

                labelRect = innerLs.GetRect(DefaultElementHeight);
                selected  = selectedTileIndex == _worldRecordSelectedTileIndex;
                if (Core.Gui.Widgets.LabelSelectable(labelRect, textHighest, ref selected, TextAnchor.MiddleLeft))
                {
                    // go to the location of the selected tile
                    _worldRecordSelectedTileIndex    = selectedTileIndex;
                    Find.WorldInterface.SelectedTile = highestCharacteristicKvp.Key;
                    Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile));
                }

                selectedTileIndex++;

                // add a thin line between each label
                innerLs.GapLine(gapLineHeight);
            }

            ListingStandard.EndScrollView(innerLs);
        }