Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
        private static void OnUpdate(UnityModManager.ModEntry modEntry, float z)
        {
            if (Game.Instance?.Player != null)
            {
                var corruption         = Game.Instance.Player.Corruption;
                var corruptionDisabled = (bool)corruption.Disabled;
                if (corruptionDisabled != settings.toggleDisableCorruption)
                {
                    if (settings.toggleDisableCorruption)
                    {
                        corruption.Disabled.Retain();
                    }
                    else
                    {
                        corruption.Disabled.ReleaseAll();
                    }
                }
            }
            Mod.logLevel = settings.loggingLevel;
            if (NeedsActionInit)
            {
                BagOfTricks.OnLoad();
                PhatLoot.OnLoad();
                NeedsActionInit = false;
            }
            //if (resetExtraCameraAngles) {
            //    Game.Instance.UI.GetCameraRig().TickRotate(); // Kludge - TODO: do something better...
            //}
            if (resetRequested)
            {
                var timeSinceRequest = DateTime.Now.Subtract(resetRequestTime).TotalMilliseconds;
                //Main.Log($"timeSinceRequest - {timeSinceRequest}");
                if (timeSinceRequest > 1000)
                {
                    Mod.Debug($"resetExecuted - {timeSinceRequest}".cyan());
                    needsResetGameUI = true;
                    resetRequested   = false;
                }
            }
            if (needsResetGameUI)
            {
                Game.Instance.ScheduleAction(() => {
                    needsResetGameUI = false;
                    Game.ResetUI();

                    // TODO - Find out why the intiative tracker comes up when I do Game.ResetUI.  The following kludge makes it go away

                    var canvas = Game.Instance?.UI?.Canvas?.transform;
                    //Main.Log($"canvas: {canvas}");
                    var hudLayout = canvas?.transform.Find("HUDLayout");
                    //Main.Log($"hudLayout: {hudLayout}");
                    var initiaveTracker = hudLayout.transform.Find("Console_InitiativeTrackerHorizontalPC");
                    //Main.Log($"    initiaveTracker: {initiaveTracker}");
                    initiaveTracker?.gameObject?.SetActive(false);
                });
            }
            var currentMode = Game.Instance.CurrentMode;

            if (IsModGUIShown || Event.current == null || !Event.current.isKey)
            {
                return;
            }
            UI.KeyBindings.OnUpdate();
            if (IsInGame &&
                settings.toggleTeleportKeysEnabled &&
                (currentMode == GameModeType.Default ||
                 currentMode == GameModeType.Pause ||
                 currentMode == GameModeType.GlobalMap
                )
                )
            {
                if (currentMode == GameModeType.GlobalMap)
                {
                    if (UI.KeyBindings.IsActive("TeleportParty"))
                    {
                        Teleport.TeleportPartyOnGlobalMap();
                    }
                }
                if (UI.KeyBindings.IsActive("TeleportMain"))
                {
                    Teleport.TeleportUnit(Game.Instance.Player.MainCharacter.Value, Utils.PointerPosition());
                }
                if (UI.KeyBindings.IsActive("TeleportSelected"))
                {
                    Teleport.TeleportSelected();
                }
                if (UI.KeyBindings.IsActive("TeleportParty"))
                {
                    Teleport.TeleportParty();
                }
            }
        }
Exemplo n.º 3
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;
            }
        }