Exemple #1
0
        public ConfigTabController(Vector2 pos, Vector2 size, MenuTab tab, ConfigMenu menu) : base(pos, size)
        {
            this.menuTab  = tab;
            tab.tabCtrler = this;
            this.cfgMenu  = menu;
            this.mode     = TabMode.NULL;
            subElements   = new List <UIelement>();

            OnChange();
        }
Exemple #2
0
        /// <summary>
        /// MonoBehavior Update
        /// </summary>
        public void Update()
        {
            if (!init)
            {
                rw = UnityEngine.Object.FindObjectOfType <RainWorld>();
                if (rw == null)
                {
                    return;
                }
                pm = rw.processManager;
                if (pm.upcomingProcess == ProcessManager.ProcessID.MainMenu)
                {
                    try
                    {
                        Initialize();
                    }
                    catch (Exception ex) { Debug.LogError(ex); }
                    init = true;
                }
                ConfigMenu.currentTab = null;
                return;
            }
            if (pm == null)
            {
                rw = UnityEngine.Object.FindObjectOfType <RainWorld>();
                if (rw == null)
                {
                    return;
                }
                pm = rw.processManager;
                return;
            }

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

            //Option is running
            ConfigMenu.script = this;

            if (ConfigMenu.currentTab != null)
            {
                ConfigMenu.description = "";
                ConfigMenu.menuTab.Update(Time.deltaTime);
                if (soundFill > 0)
                {
                    soundFill--;
                }
                try
                {
                    if (!ConfigMenu.freezeMenu)
                    {
                        ConfigMenu.currentTab.Update(Time.deltaTime);
                    }
                    else
                    {
                        bool h = false;
                        foreach (UIelement element in ConfigMenu.currentTab.items)
                        {
                            if (element.GetType().IsSubclassOf(typeof(UIconfig)))
                            {
                                if ((element as UIconfig).held)
                                {
                                    h = true; element.Update(Time.deltaTime); continue;
                                }
                            }
                        }
                        if (!h)
                        {
                            foreach (UIelement element in ConfigMenu.currentTab.items)
                            {
                                element.Update(Time.deltaTime);
                            }
                        }
                    }
                    ConfigMenu.currentInterface.Update(Time.deltaTime);
                }
                catch (Exception ex)
                { //Update Error Handle!
                    PartialityMod    mod    = ConfigMenu.currentInterface.mod;
                    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];

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

            return;

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

            /*
             * foreach (OptionInterface oi in loadedInterfaces)
             * {
             *
             * }
             */
        }
        public static void SingalPatch(On.Menu.OptionsMenu.orig_Singal orig, OptionsMenu menu, MenuObject sender, string message)
        {
            if (message != null)
            {
                if (tuch6A == null)
                {
                    Dictionary <string, int> dictionary = new Dictionary <string, int>(6)
                    {
                        { "Toggle Fullscreen", 0 },
                        { "BACK", 1 },
                        { "CREDITS", 2 },
                        { "RESET PROGRESS", 3 },
                        { "INPUT", 4 },

                        { "MOD CONFIG", 5 }
                    };//5
                    tuch6A = dictionary;
                }
                if (tuch6A.TryGetValue(message, out int num))
                {
                    switch (num)
                    {
                    case 0:
                        menu.manager.rainWorld.options.windowed = !menu.manager.rainWorld.options.windowed;
                        resolutionDirty = true;
                        menu.PlaySound(SoundID.MENU_Button_Standard_Button_Pressed);
                        break;

                    case 1:
                        menu.manager.RequestMainProcessSwitch(ProcessManager.ProcessID.MainMenu);
                        menu.PlaySound(SoundID.MENU_Switch_Page_Out);
                        menu.manager.rainWorld.options.Save();
                        break;

                    case 2:
                        menu.manager.RequestMainProcessSwitch(ProcessManager.ProcessID.Credits);
                        menu.PlaySound(SoundID.MENU_Switch_Page_In);
                        menu.manager.rainWorld.options.Save();
                        break;

                    case 3:
                        menu.manager.rainWorld.progression.WipeAll();
                        menu.PlaySound(SoundID.MENU_Switch_Page_In);
                        menu.manager.RequestMainProcessSwitch(ProcessManager.ProcessID.OptionsMenu);
                        break;

                    case 4:
                        menu.manager.RequestMainProcessSwitch(ProcessManager.ProcessID.InputOptions);
                        menu.PlaySound(SoundID.MENU_Switch_Page_In);
                        menu.manager.rainWorld.options.Save();
                        break;

                    case 5:
                        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();
                        break;
                    }
                }
            }
        }