Example #1
0
        public static void OnGUI()
        {
            var characters = PartyEditor.GetCharacterList();

            if (characters == null)
            {
                return;
            }
            UI.ActionSelectionGrid(ref selectedIndex,
                                   characters.Select((ch) => ch.CharacterName).ToArray(),
                                   8,
                                   (index) => { BlueprintBrowser.UpdateSearchResults(); },
                                   UI.MinWidth(200));
            var selectedCharacter = GetSelectedCharacter();

            if (selectedCharacter != null)
            {
                UI.Space(10);
                UI.HStack(null, 0, () => {
                    UI.Label($"{GetSelectedCharacter().CharacterName}".orange().bold(), UI.AutoWidth());
                    UI.Space(5);
                    UI.Label("will be used for adding/remove features, buffs, etc ".green());
                });
            }
        }
Example #2
0
        public static void RemoveAbility(this UnitEntityData ch, BlueprintAbility ability)
        {
            if (ability.IsSpell)
            {
                if (PartyEditor.IsOnPartyEditor() && PartyEditor.SelectedSpellbook.TryGetValue(ch.HashKey(), out var selectedSpellbook))
                {
                    if (UIUtilityUnit.SpellbookHasSpell(selectedSpellbook, ability))
                    {
                        selectedSpellbook.RemoveSpell(ability);
                        return;
                    }
                }
                foreach (var spellbook in ch.Spellbooks)
                {
                    if (UIUtilityUnit.SpellbookHasSpell(spellbook, ability))
                    {
                        spellbook.RemoveSpell(ability);
                    }
                }
            }
            var abilities = ch.Descriptor.Abilities;

            if (abilities.HasFact(ability))
            {
                abilities.RemoveFact(ability);
            }
        }
Example #3
0
 public static bool HasAbility(this UnitEntityData ch, BlueprintAbility ability)
 {
     if (ability.IsSpell)
     {
         if (PartyEditor.IsOnPartyEditor() && PartyEditor.SelectedSpellbook.TryGetValue(ch.HashKey(), out var selectedSpellbook))
         {
             return(UIUtilityUnit.SpellbookHasSpell(selectedSpellbook, ability));
         }
     }
     return(ch.Spellbooks.Any(spellbook => spellbook.IsKnown(ability)) || ch.Descriptor.Abilities.HasFact(ability));
 }
Example #4
0
 static void ResetGUI(UnityModManager.ModEntry modEntry)
 {
     settings             = Settings.Load <Settings>(modEntry);
     settings.searchText  = "";
     settings.searchLimit = 100;
     CheapTricks.ResetGUI();
     PartyEditor.ResetGUI();
     CharacterPicker.ResetGUI();
     BlueprintBrowser.ResetGUI();
     QuestEditor.ResetGUI();
     caughtException = null;
 }
Example #5
0
        static public UnitEntityData GetSelectedCharacter()
        {
            var characters = PartyEditor.GetCharacterList();

            if (characters == null || characters.Count == 0)
            {
                return(Game.Instance.Player.MainCharacter);
            }
            if (selectedIndex > characters.Count)
            {
                selectedIndex = 0;
            }
            return(characters[selectedIndex]);
        }
Example #6
0
        static void OnGUI(UnityModManager.ModEntry modEntry)
        {
            Main.modEntry = modEntry;
            if (!Enabled)
            {
                return;
            }
            if (!IsInGame)
            {
                UI.Label("ToyBox has limited functionality from the main menu".yellow().bold());
            }
            try {
                Event e = Event.current;
                userHasHitReturn   = (e.keyCode == KeyCode.Return);
                focusedControlName = GUI.GetNameOfFocusedControl();

                if (caughtException != null)
                {
                    UI.Label("ERROR".red().bold() + $": caught exception {caughtException}");
                    UI.ActionButton("Reset".orange().bold(), () => { ResetGUI(modEntry); }, UI.AutoWidth());
                    return;
                }
#if false
                UI.Label("focused: "
                         + $"{GUI.GetNameOfFocusedControl()}".orange().bold()
                         + "(" + $"{GUIUtility.keyboardControl}".cyan().bold() + ")",
                         UI.AutoWidth());
#endif
                UI.TabBar(ref settings.selectedTab,
                          () => {
                    if (BlueprintBrowser.GetBlueprints() == null)
                    {
                        UI.Label("Blueprints".orange().bold() + " loading: " + BlueprintLoader.progress.ToString("P2").cyan().bold());
                    }
                    else
                    {
                        UI.Space(25);
                    }
                },
                          new NamedAction("Cheap Tricks", () => { CheapTricks.OnGUI(); }),
                          new NamedAction("Party Editor", () => { PartyEditor.OnGUI(); }),
                          new NamedAction("Search 'n Pick", () => { BlueprintBrowser.OnGUI(); }),
                          new NamedAction("Quest Editor", () => { QuestEditor.OnGUI(); })
                          );
            }
            catch (Exception e) {
                Console.Write($"{e}");
                caughtException = e;
            }
        }
Example #7
0
 private static void ResetGUI(UnityModManager.ModEntry modEntry)
 {
     settings             = UnityModManager.ModSettings.Load <Settings>(modEntry);
     settings.searchText  = "";
     settings.searchLimit = 100;
     BagOfTricks.ResetGUI();
     LevelUp.ResetGUI();
     PartyEditor.ResetGUI();
     CrusadeEditor.ResetGUI();
     CharacterPicker.ResetGUI();
     BlueprintBrowser.ResetGUI();
     QuestEditor.ResetGUI();
     BlueprintExensions.ResetCollationCache();
     caughtException = null;
 }
Example #8
0
        public static void AddAbility(this UnitEntityData ch, BlueprintAbility ability)
        {
            if (ability.IsSpell)
            {
                if (CanAddAbility(ch, ability))
                {
                    if (PartyEditor.IsOnPartyEditor() && PartyEditor.SelectedSpellbook.TryGetValue(ch.HashKey(), out var selectedSpellbook))
                    {
                        selectedSpellbook.AddKnown(PartyEditor.selectedSpellbookLevel, ability);
                        return;
                    }
                }

                Mod.Trace($"adding spell: {ability.Name}");
                foreach (var spellbook in ch.Spellbooks)
                {
                    var spellbookBP = spellbook.Blueprint;
                    var maxLevel    = spellbookBP.MaxSpellLevel;
                    Mod.Trace($"checking {spellbook.Blueprint.Name} maxLevel: {maxLevel}");
                    for (var level = 0; level <= maxLevel; level++)
                    {
                        var learnable   = spellbookBP.SpellList.GetSpells(level);
                        var allowsSpell = learnable.Contains(ability);
                        var allowText   = allowsSpell ? "FOUND" : "did not find";
                        Mod.Trace($"{allowText} spell {ability.Name} in {learnable.Count()} level {level} spells");
                        if (allowsSpell)
                        {
                            Mod.Trace($"spell level = {level}");
                            spellbook.AddKnown(level, ability);
                        }
                    }
                }
            }
            else
            {
                ch.Descriptor.AddFact(ability);
            }
        }
Example #9
0
        private static void OnGUI(UnityModManager.ModEntry modEntry)
        {
            if (!Enabled)
            {
                return;
            }
            IsModGUIShown = true;
            if (!IsInGame)
            {
                UI.Label("ToyBox has limited functionality from the main menu".yellow().bold());
            }
            if (!UI.IsWide)
            {
                UI.Label("Note ".magenta().bold() + "ToyBox was designed to offer the best user experience at widths of 1920 or higher. Please consider increasing your resolution up of at least 1920x1080 (ideally 4k) and go to Unity Mod Manager 'Settings' tab to change the mod window width to at least 1920.  Increasing the UI scale is nice too when running at 4k".orange().bold());
            }
            try {
                var e = Event.current;
                UI.userHasHitReturn   = e.keyCode == KeyCode.Return;
                UI.focusedControlName = GUI.GetNameOfFocusedControl();
                if (caughtException != null)
                {
                    UI.Label("ERROR".red().bold() + $": caught exception {caughtException}");
                    UI.ActionButton("Reset".orange().bold(), () => { ResetGUI(modEntry); }, UI.AutoWidth());
                    return;
                }
#if false
                using (UI.HorizontalScope()) {
                    UI.Label("Suggestions or issues click ".green(), UI.AutoWidth());
                    UI.LinkButton("here", "https://github.com/cabarius/ToyBox/issues");
                    UI.Space(50);
                    UI.Label("Chat with the Authors, Narria et all on the ".green(), UI.AutoWidth());
                    UI.LinkButton("WoTR Discord", "https://discord.gg/wotr");
                }
#endif
                UI.TabBar(ref settings.selectedTab,
                          () => {
                    if (BlueprintLoader.Shared.IsLoading)
                    {
                        UI.Label("Blueprints".orange().bold() + " loading: " + BlueprintLoader.Shared.progress.ToString("P2").cyan().bold());
                    }
                    else
                    {
                        UI.Space(25);
                    }
                },
                          new NamedAction("Bag of Tricks", () => BagOfTricks.OnGUI()),
                          new NamedAction("Level Up", () => LevelUp.OnGUI()),
                          new NamedAction("Party", () => PartyEditor.OnGUI()),
                          new NamedAction("Loot", () => PhatLoot.OnGUI()),
                          new NamedAction("Enchantment", () => EnchantmentEditor.OnGUI()),
#if false
                          new NamedAction("Playground", () => Playground.OnGUI()),
#endif
                          new NamedAction("Search 'n Pick", () => BlueprintBrowser.OnGUI()),
                          new NamedAction("Crusade", () => CrusadeEditor.OnGUI()),
                          new NamedAction("Armies", () => ArmiesEditor.OnGUI()),
                          new NamedAction("Events/Decrees", () => EventEditor.OnGUI()),
                          new NamedAction("Etudes", () => EtudesEditor.OnGUI()),
                          new NamedAction("Quests", () => QuestEditor.OnGUI()),
                          new NamedAction("Settings", () => SettingsUI.OnGUI())
                          );
            }
            catch (Exception e) {
                Console.Write($"{e}");
                caughtException = e;
            }
        }
Example #10
0
 public static bool CanAddSpellAsAbility(this UnitEntityData ch, BlueprintAbility ability) => ability.IsSpell && !ch.Descriptor.HasFact(ability) && !PartyEditor.IsOnPartyEditor();