コード例 #1
0
        public override void Signal(UItrigger trigger, string signal)
        {
            base.Signal(trigger, signal);
            if (reason != Reason.TooManyMod)
            {
                return;
            }

            foreach (KeyValuePair <int, string> mod in ConfigMenu.instance.modList)
            {
                if (mod.Value == signal)
                {
                    ConfigMenu.selectedModIndex = mod.Key; break;
                }
            }

            if (ConfigMenu.selectedModIndex < ConfigMenu.scrollTop)
            {
                ConfigMenu.scrollTop = ConfigMenu.selectedModIndex; ConfigMenu.ScrollButtons();
            }
            else if (ConfigMenu.selectedModIndex > ConfigMenu.scrollTop + 12)
            {
                ConfigMenu.scrollTop = ConfigMenu.selectedModIndex - 12; ConfigMenu.ScrollButtons();
            }

            ConfigMenu.instance.ChangeSelectedMod();
        }
コード例 #2
0
        public ConfigTabController(Vector2 pos, Vector2 size, MenuTab tab, ConfigMenu menu) : base(pos, size)
        {
            this.menuTab   = tab;
            this.cfgMenu   = menu;
            this.mode      = TabMode.NULL;
            subElements    = new List <UIelement>();
            this.greyedOut = false;

            OnChange();
        }
コード例 #3
0
        internal static void SingalPatch(On.Menu.OptionsMenu.orig_Singal orig, OptionsMenu menu, MenuObject sender, string message)
        {
            if (message == "MOD CONFIG")
            {
                mod = true;
                menu.PlaySound(SoundID.MENU_Switch_Page_In);
                menu.manager.rainWorld.options.Save();
                //this.manager.RequestMainProcessSwitch(ProcessManager.ProcessID.OptionsMenu);
                menu.manager.soundLoader.ReleaseAllUnityAudio();

                modmenu = new ConfigMenu(menu.manager);
                menu.manager.currentMainLoop = modmenu;
                modmenu.vanillaMenu          = menu;
                modmenu.OpenMenu();
            }
            else
            {
                orig.Invoke(menu, sender, message);
            }
        }
コード例 #4
0
        /// <summary>
        /// MonoBehavior Update
        /// </summary>
        public void Update()
        {
            if (!init)
            {
                return;
            }

            if (pm.currentMainLoop?.ID != ProcessManager.ProcessID.OptionsMenu)
            {
                goto BackgroundUpdate;
            }
            else if (!OptionsMenuPatch.mod)
            {
                return;
            }

            //Option is running
            ConfigMenu.script = this;
            isOptionMenu      = true;

            #region curFramerate
            dtHistory[dtHistoryMark] = Time.deltaTime;
            dtHistoryMark--; if (dtHistoryMark < 0)
            {
                dtHistoryMark = dtHistory.Length - 1;
            }
            float sum = 0;
            for (int h = 0; h < dtHistory.Length; h++)
            {
                sum += dtHistory[h];
            }
            curFramerate = dtHistory.Length / sum;
            #endregion curFramerate

            if (soundFill > 0)
            {
                soundFill--;
            }
            ConfigMenu.description = "";
            if (ConfigMenu.currentTab != null)
            {
                bool fade = ConfigMenu.instance.fadeSprite != null;
                ConfigMenu.menuTab.Update(Time.deltaTime);
                if (MenuTab.logMode)
                {
                    ConfigMenu.instance.saveButton.buttonBehav.greyedOut  = true;
                    ConfigMenu.instance.resetButton.buttonBehav.greyedOut = true;
                    return;
                }
                ConfigMenu.instance.backButton.buttonBehav.greyedOut = fade;
                try
                {
                    if (!ConfigMenu.freezeMenu)
                    {
                        ConfigMenu.currentTab.Update(Time.deltaTime);
                        ConfigMenu.instance.saveButton.buttonBehav.greyedOut = fade || false;
                        for (int m = 0; m < ConfigMenu.instance.modButtons.Length; m++)
                        {
                            ConfigMenu.instance.modButtons[m].buttonBehav.greyedOut = fade || false;
                        }
                        ConfigMenu.tabCtrler.greyedOut = fade || false;
                    }
                    else
                    {
                        bool h = false;
                        foreach (UIelement element in ConfigMenu.currentTab.items)
                        {
                            if (element.GetType().IsSubclassOf(typeof(UIconfig)))
                            {
                                if ((element as UIconfig).held)
                                {
                                    h = true;
                                    if (Input.GetKey(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl))
                                    {
                                        if (Input.GetKey(KeyCode.V) && !string.IsNullOrEmpty(UniClipboard.GetText()))
                                        {
                                            string grab = UniClipboard.GetText();
                                            if ((element as UIconfig).CopyFromClipboard(grab))
                                            {
                                                (element as UIconfig).bumpBehav.flash = 1f;
                                                if ((element as UIconfig).cosmetic)
                                                {
                                                    ConfigMenu.alert = InternalTranslator.Translate("Pasted <Text> from Clipboard").Replace("<Text>", grab);
                                                }
                                                else
                                                {
                                                    ConfigMenu.alert = InternalTranslator.Translate("Pasted <Text> from Clipboard to <ObjectName>").Replace("<Text>", grab).Replace("<ObjectName>", (element as UIconfig).key);
                                                }
                                            }
                                        }
                                        else if (Input.GetKey(KeyCode.C))
                                        {
                                            string grab = (element as UIconfig).CopyToClipboard();
                                            if (!string.IsNullOrEmpty(grab))
                                            {
                                                (element as UIconfig).bumpBehav.flash = 1f;
                                                UniClipboard.SetText(grab);
                                                if ((element as UIconfig).cosmetic)
                                                {
                                                    ConfigMenu.alert = InternalTranslator.Translate("Copied <Text> to Clipboard").Replace("<Text>", grab);
                                                }
                                                else
                                                {
                                                    ConfigMenu.alert = InternalTranslator.Translate("Copied <Text> to Clipboard from <ObjectName>").Replace("<Text>", grab).Replace("<ObjectName>", (element as UIconfig).key);
                                                }
                                            }
                                        }
                                    }
                                    element.Update(Time.deltaTime);
                                    continue;
                                }
                            }
                            if (element.GetType().IsSubclassOf(typeof(UItrigger)))
                            {
                                if ((element as UItrigger).held)
                                {
                                    h = true; element.Update(Time.deltaTime); continue;
                                }
                            }
                        }
                        if (!h)
                        {
                            foreach (UIelement element in ConfigMenu.currentTab.items)
                            {
                                element.Update(Time.deltaTime);
                            }
                        }
                        ConfigMenu.instance.saveButton.buttonBehav.greyedOut = fade || h;
                        for (int m = 0; m < ConfigMenu.instance.modButtons.Length; m++)
                        {
                            ConfigMenu.instance.modButtons[m].buttonBehav.greyedOut = fade || h;
                        }
                        ConfigMenu.tabCtrler.greyedOut = h;
                    }
                    ConfigMenu.currentInterface.Update(Time.deltaTime);
                }
                catch (Exception ex)
                { //Update Error Handle!
                    RainWorldMod     mod    = ConfigMenu.currentInterface.rwMod;
                    List <Exception> unload = new List <Exception>();
                    ConfigMenu       menu   = (pm.currentMainLoop as ConfigMenu);
                    foreach (OpTab tab in ConfigMenu.currentInterface.Tabs)
                    {
                        try
                        {
                            tab.Hide();
                            tab.Unload();
                        }
                        catch (Exception ex0) { unload.Add(ex0); }
                    }
                    string fullLog = string.Concat(
                        mod.ModID, " had error in Update(Time.deltaTime)!", Environment.NewLine,
                        ex.ToString());
                    foreach (Exception ex0 in unload)
                    {
                        fullLog += Environment.NewLine + "TabUnloadError: " + ex0.ToString();
                    }

                    UnconfiguableOI newItf = new UnconfiguableOI(mod, new GenericUpdateException(fullLog));
                    loadedInterfaceDict.Remove(mod.ModID);
                    loadedInterfaceDict.Add(mod.ModID, newItf);

                    int index = 0;
                    foreach (KeyValuePair <int, string> item in menu.modList)
                    {
                        if (item.Value == mod.ModID)
                        {
                            index = item.Key; break;
                        }
                    }
                    int i = 0;
                    do
                    {
                        string key = string.Concat(index.ToString("D3") + "_" + i.ToString("D2"));
                        if (tabs.ContainsKey(key))
                        {
                            tabs.Remove(key);
                        }
                        else
                        {
                            break;
                        }
                        i++;
                    } while (i < 100);

                    newItf.Initialize();
                    ConfigMenu.selectedTabIndex = 0;
                    tabs.Add(string.Concat(index.ToString("D3") + "_00"), newItf.Tabs[0]);

                    foreach (UIelement element in newItf.Tabs[0].items)
                    {
                        foreach (MenuObject obj in element.subObjects)
                        {
                            menu.pages[0].subObjects.Add(obj);
                        }
                        menu.pages[0].Container.AddChild(element.myContainer);
                    }
                    newItf.Tabs[0].Show();

                    ConfigMenu.currentInterface = newItf;
                    ConfigMenu.currentTab       = newItf.Tabs[0];
                    ConfigMenu.tabCtrler.Reset();

                    (pm.currentMainLoop as ConfigMenu).PlaySound(SoundID.MENU_Error_Ping);
                    (pm.currentMainLoop as ConfigMenu).opened = false;
                    (pm.currentMainLoop as ConfigMenu).OpenMenu();
                }
            }

            return;

BackgroundUpdate:
            isOptionMenu = false;
            //Background running
            // if (pm.currentMainLoop?.ID == ProcessManager.ProcessID.IntroRoll) { return; }

            /*
             * foreach (OptionInterface oi in loadedInterfaces)
             * {
             * }
             */
        }