コード例 #1
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)
             * {
             * }
             */
        }
コード例 #2
0
        /// <summary>
        /// Runs right before MainMenu opens
        /// </summary>
        private static void Initialize()
        {
            //Application.RegisterLogCallback(new Application.LogCallback(TroubleShoot));

            ID2Code = new Dictionary <int, string>()
            {
                { 0, "eng" },
                { 1, "fre" },
                { 2, "ita" },
                { 3, "ger" },
                { 4, "spa" },
                { 5, "por" },
                { 6, "jap" },
                { 7, "kor" }
            };
            if (ID2Code.TryGetValue(rw.options.language, out string code))
            {
                curLang = code;
            }
            else
            {
                curLang = "eng";
            }
            string curCurLang = curLang;

            InternalTranslator.LoadTranslation();

            #region PartialityMods
            loadedMods           = Partiality.PartialityManager.Instance.modManager.loadedMods;
            loadedModsDictionary = new Dictionary <string, PartialityMod>();
            ComModExists         = false;
            foreach (PartialityMod mod in loadedMods)
            {
                if (string.IsNullOrEmpty(mod.ModID))
                {
                    goto invaildID;
                }
                if (blackList.Contains <string>(mod.ModID)) //No Config for this :P
                {
                    if (mod.ModID == "CommunicationModule")
                    {
                        ComMod = mod; ComModExists = true;
                        if (rw.options.language != 5)
                        {
                            curLang = (string)mod.GetType().GetField("customLang", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static).GetValue(mod);
                        }
                        else
                        {
                            curLang = "eng";
                        }
                    }
                    continue;
                }
                if (mod.ModID.Substring(0, 1) == "_")
                {
                    continue;
                }                                                   //Skip this mod from configuration
                if (mod.ModID == "SlugBase")
                {
                    SlugBaseMod = mod; SlugBaseExists = true;
                }

                if (loadedModsDictionary.ContainsKey(mod.ModID))
                {
                    Debug.LogError($"Duplicate ModID detected! (dupe ID: {mod.ModID})");
                }
                else if (Regex.IsMatch(mod.ModID, "^[^\\/?%*:|\"<>/.]+$"))
                {
                    loadedModsDictionary.Add(mod.ModID, mod); continue;
                }

invaildID:
                string InvalidID = string.IsNullOrEmpty(mod.ModID) ? "No ModID" : mod.ModID;
                Debug.Log($"{InvalidID} does not support CompletelyOptional: Invalid Mod ID! Using Mod Type name instead.");
                mod.ModID = mod.GetType().Name;
                //Assembly.GetAssembly(this.mod.GetType());
                if (!ValidModIDCheck(mod.ModID))
                {
                    Debug.Log($"{mod.ModID} does not support CompletelyOptional either! Using Assembly Name instead.");
                    mod.ModID = Assembly.GetAssembly(mod.GetType()).GetName().Name;
                    if (!ValidModIDCheck(mod.ModID))
                    {
                        Debug.Log($"{mod.ModID} does not support CompletelyOptional either! Abandoning {InvalidID}!"); continue;
                    }
                }
                loadedModsDictionary.Add(mod.ModID, mod);
            }

            //Debug.Log(string.Concat("curLang: ", curLang));
            if (curCurLang != curLang)
            {
                InternalTranslator.LoadTranslation();
            }

            isOptionMenu        = false;
            loadedInterfaceDict = new Dictionary <string, OptionInterface>();
            loadedInterfaces    = new List <OptionInterface>();

            //No Mods Installed!
            if (loadedModsDictionary.Count == 0 && !OptionMod.ReferencesBepInEx)
            {
                loadedModsDictionary = new Dictionary <string, PartialityMod>(1);
                PartialityMod blankMod = new PartialityMod
                {
                    ModID   = "No Mods Installed",
                    Version = "XXXX",
                    author  = RainWorldMod.authorNull
                };
                loadedModsDictionary.Add(blankMod.ModID, blankMod);

                UnconfiguableOI itf = new UnconfiguableOI(blankMod, UnconfiguableOI.Reason.NoMod);
                loadedInterfaceDict.Add(blankMod.ModID, itf);
                loadedInterfaces.Add(itf);

                return;
            }

            //Load Mod Interfaces!
            foreach (KeyValuePair <string, PartialityMod> item in loadedModsDictionary)
            {
                PartialityMod   mod = loadedModsDictionary[item.Key];
                OptionInterface itf;

                try
                {
                    var method = mod.GetType().GetMethod("LoadOI");
                    if (method == null || method.GetParameters().Length > 0 || method.ContainsGenericParameters)
                    {
                        // Mod didn't attempt to interface with CompletelyOptional, don't bother logging it.
                        itf = new UnconfiguableOI(mod, UnconfiguableOI.Reason.NoInterface);
                    }
                    else if (method.Invoke(mod, null) is OptionInterface oi)
                    {
                        itf = oi;
                        //Your code
                        Debug.Log($"Loaded OptionInterface from {mod.ModID} (type: {itf.GetType()})");
                    }
                    else
                    {
                        itf = new UnconfiguableOI(mod, UnconfiguableOI.Reason.NoInterface);
                        Debug.Log($"{mod.ModID} did not return an OptionInterface in LoadOI.");
                    }
                }
                catch (Exception ex)
                {
                    Debug.Log($"{mod.ModID} threw an exception in LoadOI: {ex.Message}");
                    itf = new UnconfiguableOI(mod, UnconfiguableOI.Reason.NoInterface);
                }

                if (itf.rwMod.mod == null)
                {
                    NullModException e = new NullModException(mod.ModID);
                    Debug.Log(e); Debug.LogException(e);
                    itf.rwMod = new RainWorldMod(mod);
                    // itf = new UnconfiguableOI(mod, e);
                }

                try
                {
                    itf.Initialize();
                }
                catch (Exception ex)
                { //try catch better
                    itf = new UnconfiguableOI(mod, new GeneralInitializeException(ex));
                    itf.Initialize();
                }

                if (itf.Tabs == null || itf.Tabs.Length < 1)
                {
                    itf = new UnconfiguableOI(itf.rwMod, new NoTabException(mod.ModID));
                    itf.Initialize();
                    //OptionScript.loadedInterfaceDict.Remove(mod.ModID);
                    //OptionScript.loadedInterfaceDict.Add(mod.ModID, itf);
                }
                else if (itf.Configuable())
                {
                    if (itf.LoadConfig())
                    {
                        Debug.Log($"CompletelyOptional) {itf.rwMod.ModID} config has been loaded.");
                    }
                    else
                    {
                        Debug.Log($"CompletelyOptional) {itf.rwMod.ModID} does not have config.json.");
                        //itf.Initialize();
                        try
                        {
                            itf.SaveConfig(itf.GrabConfig());
                            Debug.Log($"CompletelyOptional) {itf.rwMod.ModID} uses default config.");
                        }
                        catch (Exception e)
                        {
                            Debug.Log("Saving Default Config Failed.");
                            Debug.Log(e);
                        }
                    }
                }

                loadedInterfaces.Add(itf);
                loadedInterfaceDict.Add(itf.rwMod.ModID, itf);
                //loadedModsDictionary[item.Key].GetType().GetMember("OI")
            }
            // Progression of loaded OIs
            ProgressData.SubPatch();
            if (OptionScript.rw.setup.loadProg)
            {
                ProgressData.LoadOIsProgression();
            }

            #endregion PartialityMods

            #region InternalTest
            if (OptionMod.testing)
            {
#pragma warning disable CS0162
                PartialityMod temp = new PartialityMod()
                {
                    author  = "topicular",
                    ModID   = "InternalTest",
                    Version = OptionMod.instance.Version
                };
                loadedModsDictionary.Add(temp.ModID, temp);
                OptionInterface itf = new InternalTestOI(temp);
                try { itf.Initialize(); }
                catch (Exception ex)
                {
                    itf = new UnconfiguableOI(temp, new GeneralInitializeException(ex));
                    itf.Initialize();
                }
                loadedInterfaces.Add(itf);
                loadedInterfaceDict.Add(temp.ModID, itf);
#pragma warning restore CS0162
            }
            #endregion InternalTest

            // dual's code
            if (OptionMod.ReferencesBepInEx)
            {
                LoadBaseUnityPlugins();
            }

            Debug.Log($"CompletelyOptional finished initializing {loadedInterfaceDict.Count} OIs.");
        }
コード例 #3
0
        private static void LoadBaseUnityPlugins()
        {
            BaseUnityPlugin[] plugins = FindObjectsOfType <BaseUnityPlugin>();
            if (plugins.Length < 1)
            {
                return;
            }

            foreach (BaseUnityPlugin plugin in plugins)
            {
                OptionInterface itf;

                // Load ITF
                try
                {
                    var method = plugin.GetType().GetMethod("LoadOI");
                    if (method == null || method.GetParameters().Length > 0 || method.ContainsGenericParameters)
                    {
                        // Mod didn't attempt to interface with CompletelyOptional, don't bother logging it.
                        itf = new UnconfiguableOI(plugin, UnconfiguableOI.Reason.NoInterface);
                    }
                    else if (method.Invoke(plugin, null) is OptionInterface oi)
                    {
                        itf = oi;
                        //Your code
                        Debug.Log($"Loaded OptionInterface from {itf.rwMod.ModID} (type: {itf.GetType()})");
                    }
                    else
                    {
                        itf = new UnconfiguableOI(plugin, UnconfiguableOI.Reason.NoInterface);
                        Debug.Log($"{itf.rwMod.ModID} did not return an OptionInterface in LoadOI.");
                    }
                }
                catch (Exception ex)
                {
                    itf = new UnconfiguableOI(plugin, UnconfiguableOI.Reason.NoInterface);

                    if (blackList.Contains(itf.rwMod.ModID) || itf.rwMod.ModID.Substring(0, 1) == "_")
                    {
                        continue;
                    }

                    Debug.Log($"{itf.rwMod.ModID} threw an exception in LoadOI: {ex.Message}");
                }

                if (itf is UnconfiguableOI && plugin.Config.Keys.Count > 0)
                {
                    // Use BepInEx Configuration
                    itf = new GeneratedOI(itf.rwMod, plugin.Config);
                }

                // Initialize the interface
                try
                {
                    itf.Initialize();
                }
                catch (Exception ex)
                {
                    // Try-catch better
                    itf = new UnconfiguableOI(itf.rwMod, new GeneralInitializeException(ex));
                    itf.Initialize();
                }
                if (itf.Tabs == null || itf.Tabs.Length < 1)
                {
                    itf = new UnconfiguableOI(itf.rwMod, new NoTabException(itf.rwMod.ModID));
                    itf.Initialize();
                    // OptionScript.loadedInterfaceDict.Remove(mod.ModID);
                    // OptionScript.loadedInterfaceDict.Add(mod.ModID, itf);
                }
                else if (itf.Configuable())
                {
                    if (itf.LoadConfig())
                    {
                        Debug.Log($"{itf.rwMod.ModID} config has been loaded.");
                    }
                    else
                    {
                        Debug.Log($"{itf.rwMod.ModID} does not have config.txt.");
                        //itf.Initialize();
                        try
                        {
                            itf.SaveConfig(itf.GrabConfig());
                            Debug.Log($"{itf.rwMod.ModID} uses default config.");
                        }
                        catch (Exception e)
                        {
                            Debug.Log("Saving Default Config Failed.");
                            Debug.Log(e);
                        }
                    }
                }

                loadedInterfaces.Add(itf);
                loadedInterfaceDict.Add(itf.rwMod.ModID, itf);
            }
        }
コード例 #4
0
        public void Initialize() //UI
        {
            if (vanillaMenu != null)
            {
                vanillaMenu.ShutDownProcess();
                vanillaMenu = null;
            }

            instance = this;
            mute     = true;

#pragma warning disable CS0162 // 접근할 수 없는 코드가 있습니다.
            if (!OptionMod.testing)
            {
                if (!redUnlocked)
                {
                    this.scene = new InteractiveMenuScene(this, this.pages[0], (MenuScene.SceneID)(bgList[Mathf.FloorToInt(UnityEngine.Random.value * (bgList.Length))]));
                }
                else
                {
                    this.scene = new InteractiveMenuScene(this, this.pages[0], (MenuScene.SceneID)(bgListRed[Mathf.FloorToInt(UnityEngine.Random.value * (bgListRed.Length))]));
                }
                Debug.Log(string.Concat("Chosen Background : " + this.scene.sceneID.ToString()));
                this.pages[0].subObjects.Add(this.scene);
            }
            else
            {
                this.scene = new SlideShowMenuScene(this, this.pages[0], MenuScene.SceneID.Intro_4_Walking);
                this.pages[0].subObjects.Add(this.scene);
            }
#pragma warning restore CS0162

            this.fadeSprite.RemoveFromContainer();
            this.pages[0].Container.AddChild(this.fadeSprite); //reset fadeSprite

            this.darkSprite = new FSprite("pixel", true)
            {
                color   = new Color(0f, 0f, 0f),
                anchorX = 0f,
                anchorY = 0f,
                scaleX  = 1368f,
                scaleY  = 770f,
                x       = -1f,
                y       = -1f,
                alpha   = 0.6f
            };
            this.pages[0].Container.AddChild(this.darkSprite);

            modListBound = new OpRect(new Vector2(193f, 240f) - UIelement._offset, new Vector2(280f, 495f), 0.3f);
            //modCanvasBound = new OpRect(new Vector2(553f, 105f), new Vector2(630f, 630f), 0.4f);
            modCanvasBound = new OpRect(new Vector2(543f, 105f) - UIelement._offset, new Vector2(630f, 630f), 0.4f);
            //Base: new Vector2(468f, 120f);
            menuTab.AddItems(modListBound, modCanvasBound);
            this.pages[0].subObjects.Add(modListBound.rect);
            this.pages[0].subObjects.Add(modCanvasBound.rect);

            this.backButton = new SimpleButton(this, this.pages[0], InternalTranslator.Translate("BACK"), "CANCEL", new Vector2(450f, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.backButton);
            this.saveButton = new SimpleButton(this, this.pages[0], InternalTranslator.Translate("APPLY"), "APPLY", new Vector2(600f, 50f), new Vector2(110f, 30f));
            this.pages[0].subObjects.Add(this.saveButton);
            base.MutualHorizontalButtonBind(saveButton, backButton);
            this.resetButton = new HoldButton(this, this.pages[0], InternalTranslator.Translate("RESET CONFIG"), "RESET CONFIG", new Vector2(300f, 110f), 30f);
            this.pages[0].subObjects.Add(this.resetButton);
            this.alertLabel = new MenuLabel(this, this.pages[0], "", new Vector2(383f, 735f), new Vector2(600f, 30f), false);
            this.pages[0].subObjects.Add(this.alertLabel);
            this.alertLabelFade = 0f; this.lastAlertLabelFade = 0f; this.alertLabelSin = 0f;

            //Dark Box for ModList & Canvas
            //modlist x200 y400 w240 h600
            //canvas  x568 y120 w600 h600

            this.resetButton.nextSelectable[2] = this.backButton;
            this.backButton.nextSelectable[0]  = this.resetButton;
            this.backButton.nextSelectable[2]  = this.saveButton;
            this.saveButton.nextSelectable[0]  = this.backButton;

            menuTab.lblInfoButton           = new OpLabel(new Vector2(233f, 215f) - UIelement._offset, new Vector2(200f, 20f), "Config Machine " + MenuTab.GetCMVersion());
            menuTab.lblInfoButton.bumpBehav = new BumpBehaviour(menuTab.lblInfoButton);
            menuTab.AddItems(menuTab.lblInfoButton);
            this.pages[0].subObjects.Add(menuTab.lblInfoButton.label);

            List <OptionInterface> itfs = new List <OptionInterface>();

            // Initialize
            OptionScript.loadedInterfaceDict.Remove(InternalTranslator.Translate("Mod List")); // Remove old Mod List
            List <UnconfiguableOI> replacedOIs = new List <UnconfiguableOI>();
            foreach (string id in OptionScript.loadedInterfaceDict.Keys)
            {
                OptionInterface itf = OptionScript.loadedInterfaceDict[id];
                Debug.Log(string.Concat("OptionInterface Initializing: " + id));

#pragma warning disable CS0612
                try { itf.Initialize(); }
                catch (Exception ex)
                { itf = new UnconfiguableOI(itf.mod, new GeneralInitializeException(ex)); goto replaced; }

                if (itf.Tabs == null || itf.Tabs.Length < 1)
                {
                    itf = new UnconfiguableOI(itf.mod, new NoTabException(id)); goto replaced;
                }
                else if (itf.Tabs.Length > 20)
                {
                    itf = new UnconfiguableOI(itf.mod, new TooManyTabsException()); goto replaced;
                }

                try { itf.LoadConfig(); itf.ShowConfig(); }
                catch (Exception ex)
                {
                    itf = new UnconfiguableOI(itf.mod, new LoadDataException(string.Concat("OILoad/ShowConfigError: ", id, " had a problem in Load/ShowConfig()\nAre you editing LoadConfig()/ShowConfig()? That could cause serious error.",
                                                                                           Environment.NewLine, ex
                                                                                           )));
                    goto replaced;
                }
#pragma warning restore CS0612

                itfs.Add(itf);
                continue;

replaced:
                itf.Initialize();
                itfs.Add(itf);
                replacedOIs.Add(itf as UnconfiguableOI);
            }
            foreach (UnconfiguableOI itf in replacedOIs)
            {
                OptionScript.loadedInterfaceDict.Remove(itf.rwMod.ModID);
                OptionScript.loadedInterfaceDict.Add(itf.rwMod.ModID, itf);
            }

            // Remove Excess
            int                 priority    = (int)OptionInterface.Priority.NoInterface;
            UnconfiguableOI     listItf     = null;
            List <RainWorldMod> listIgnored = new List <RainWorldMod>();
            while (itfs.Count > 16 && priority < (int)OptionInterface.Priority.Inconfiguable) // 1
            {
                Debug.Log(string.Concat("Mod Count: ", itfs.Count, "! Discarding priority ", priority));

                /* if (priority == -2)
                 * {
                 *  List<OptionInterface> temp2 = new List<OptionInterface>();
                 *  foreach (OptionInterface oi in itfs) { if (oi.GetPriority() > -2) { temp2.Add(oi); } }
                 *  itfs = temp2; priority++; continue;
                 * } */
                if (priority == (int)OptionInterface.Priority.NoInterface)
                {
                    PartialityMod blankMod = new PartialityMod
                    {
                        ModID   = InternalTranslator.Translate("Mod List"),
                        Version = "XXXX",
                        author  = RainWorldMod.authorNull
                    };
                    listItf = new UnconfiguableOI(blankMod, UnconfiguableOI.Reason.TooManyMod);
                }
                List <OptionInterface> temp = new List <OptionInterface>();
                foreach (OptionInterface oi in itfs)
                {
                    if (oi.GetPriority() > priority)
                    {
                        temp.Add(oi);
                    }
                    else
                    {
                        listIgnored.Add(oi.rwMod);
                    }
                }
                itfs = temp;
                priority++;
            }

            // Sorting
            {
                List <OptionInterface>[] sortTemp = new List <OptionInterface> [(int)OptionInterface.Priority.Error + 2];
                for (int p = 0; p < sortTemp.Length; p++)
                {
                    sortTemp[p] = new List <OptionInterface>();
                }
                foreach (OptionInterface oi in itfs)
                {
                    sortTemp[oi.GetPriority() + 1].Add(oi);
                }
                int cmCount = 0;
                for (int p = 0; p < sortTemp.Length; p++)
                {
                    cmCount += sortTemp[p].Count; sortTemp[p].Sort(CompareOIModID);
                }

                itfs = new List <OptionInterface>();
                if (priority > (int)OptionInterface.Priority.NoInterface)
                {
                    OptionScript.loadedInterfaceDict.Add(InternalTranslator.Translate("Mod List"), listItf);
                    listItf.SetIgnoredModList(listIgnored);
                    if (cmCount > 15)
                    {
                        listItf.SetConfiguableModList(sortTemp);
                    }
                    else
                    {
                        listItf.SetConfiguableModList(null);
                    }
                    listItf.Initialize();
                    itfs.Add(listItf);
                }
                for (int p = sortTemp.Length - 1; p >= 0; p--)
                {
                    for (int i = 0; i < sortTemp[p].Count; i++)
                    {
                        itfs.Add(sortTemp[p][i]);
                    }
                }
            }

            // Add Buttons
            modButtons = new SelectOneButton[Math.Min(16, itfs.Count)];
            Dictionary <int, string> dictionary = new Dictionary <int, string>(itfs.Count);
            selectedModIndex = 0;
            for (int i = 0; i < itfs.Count; i++)
            {
                OptionInterface itf = itfs[i];
#pragma warning disable CS0162
                if (OptionMod.testing)
                {
                    Debug.Log(string.Concat("Mod(" + i + ") : " + itf.rwMod.ModID));
                }
#pragma warning restore CS0162
                for (int t = 0; t < itf.Tabs.Length; t++)
                {
                    OptionScript.tabs.Add(string.Concat(i.ToString("D3") + "_" + t.ToString("D2")), itf.Tabs[t]);
                    foreach (UIelement element in itf.Tabs[t].items)
                    {
                        foreach (MenuObject obj in element.subObjects)
                        {
                            this.pages[0].subObjects.Add(obj);
                        }
                        this.pages[0].Container.AddChild(element.myContainer);
                    }
                    itf.Tabs[t].Hide();
                }
                dictionary.Add(i, itf.rwMod.ModID);

                if (i > 15)
                {
                    continue;
                }
                modButtons[i] = new SelectOneButton(this, this.pages[0], itf.rwMod.ModID, "ModSelect", new Vector2(208f, 700f - 30f * i), new Vector2(250f, 24f), modButtons, i);
                this.pages[0].subObjects.Add(modButtons[i]);
            }
            modList    = dictionary;
            scrollMode = false;
            if (itfs.Count > 16)
            {
                scrollMode = true;
                scrollTop  = 1;
                modButtons[1].menuLabel.text  = InternalTranslator.Translate("Scroll Up");
                modButtons[1].signalText      = "ScrollUp";
                modButtons[15].menuLabel.text = InternalTranslator.Translate("Scroll Down");
                modButtons[15].signalText     = "ScrollDown";
                ScrollButtons();
            }

            if (this.modButtons.Length > 1)
            {
                for (int m = 0; m < this.modButtons.Length - 1; m++)
                {
                    this.modButtons[m].nextSelectable[3]     = this.modButtons[m + 1];
                    this.modButtons[m + 1].nextSelectable[1] = this.modButtons[m];
                }
                if (listItf != null)
                {
                    this.modButtons[0].menuLabel.text = listItf.rwMod.ModID;
                }
            }
            this.resetButton.nextSelectable[1] = this.modButtons[this.modButtons.Length - 1];
            this.backButton.nextSelectable[1]  = this.modButtons[this.modButtons.Length - 1];
            this.saveButton.nextSelectable[1]  = this.modButtons[this.modButtons.Length - 1];
            this.modButtons[this.modButtons.Length - 1].nextSelectable[3] = this.saveButton;

            //Load Tab
            selectedTabIndex = 0;
            currentInterface = OptionScript.loadedInterfaceDict[modList[0]];
            currentTab       = OptionScript.tabs[string.Concat(selectedModIndex.ToString("D3") + "_" + selectedTabIndex.ToString("D2"))];

            currentTab.Show();
            if (currentInterface.Configuable())
            {
                saveButton.buttonBehav.greyedOut  = false;
                resetButton.buttonBehav.greyedOut = false;
            }
            else
            {
                saveButton.buttonBehav.greyedOut  = true;
                resetButton.buttonBehav.greyedOut = true;
            }

            tabCtrler = new ConfigTabController(new Vector2(503f, 120f) - UIelement._offset, new Vector2(40f, 600f), menuTab, this);
            menuTab.AddItems(tabCtrler);
            foreach (MenuObject obj in tabCtrler.subObjects)
            {
                this.pages[0].subObjects.Add(obj);
            }

            this.selectedObject = this.backButton;

            OptionScript.configChanged = false;

            mute = false;
        }