Ejemplo n.º 1
0
        /// <summary>
        /// Adds Basic Profile on top of OpTab
        /// </summary>
        /// <param name="tab"><see cref="OpTab"/> which will contain the profile</param>
        /// <param name="mod"><see cref="RainWorldMod"/> that has basic information of the mod</param>
        public static void AddBasicProfile(OpTab tab, RainWorldMod mod)
        {
            tab.AddItems(new OpLabel(new Vector2(100f, 550f), new Vector2(400f, 50f), mod.ModID, FLabelAlignment.Center, true));
            tab.AddItems(new OpLabel(new Vector2(50f, 500f), new Vector2(100f, 20f), InternalTranslator.Translate("Version: <ModVersion>").Replace("<ModVersion>", mod.Version), FLabelAlignment.Left));

            if (mod.author != RainWorldMod.authorNull)
            {
                tab.AddItems(new OpLabel(new Vector2(350f, 500f), new Vector2(200f, 20f), InternalTranslator.Translate("Author: <ModAuthor>").Replace("<ModAuthor>", mod.author), FLabelAlignment.Right)
                {
                    autoWrap = true
                });
            }

            /*
             * if (mod.coauthor != RainWorldMod.authorNull)
             * {
             *  labelCoauthor = new OpLabel(new Vector2(100f, 420f), new Vector2(300f, 20f), string.Concat("Coautor: ", mod.coauthor));
             *  Tabs[0].AddItem(labelCoauthor);
             *  labelCoauthor.autoWrap = true;
             * }
             * if(mod.description != RainWorldMod.authorNull)
             * {
             *  labelDesc = new OpLabel(new Vector2(80f, 350f), new Vector2(340f, 20f), mod.description, FLabelAlignment.Left);
             *  Tabs[0].AddItem(labelDesc);
             *  labelDesc.autoWrap = true;
             * } */
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds Basic Profile on top of <see cref="OpScrollBox"/>
        /// </summary>
        /// <param name="box"><see cref="OpScrollBox"/> which will contain the profile</param>
        /// <param name="mod"><see cref="RainWorldMod"/> that has basic information of the mod</param>
        public static void AddBasicProfile(OpScrollBox box, RainWorldMod mod)
        {
            box.AddItems(new OpLabel(new Vector2(100f, box.GetContentSize() - 600f + 550f), new Vector2(400f, 50f), mod.ModID, FLabelAlignment.Center, true));
            box.AddItems(new OpLabel(new Vector2(50f, box.GetContentSize() - 600f + 500f), new Vector2(100f, 20f), InternalTranslator.Translate("Version: <ModVersion>").Replace("<ModVersion>", mod.Version), FLabelAlignment.Left));

            if (mod.author != RainWorldMod.authorNull)
            {
                box.AddItems(new OpLabel(new Vector2(350f, box.GetContentSize() - 600f + 500f), new Vector2(200f, 20f), InternalTranslator.Translate("Author: <ModAuthor>").Replace("<ModAuthor>", mod.author), FLabelAlignment.Right)
                {
                    autoWrap = true
                });
            }
        }
Ejemplo n.º 3
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)
             * {
             * }
             */
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Comparator for Sorting OptionInterfaces by ModID
 /// </summary>
 private static int CompareModID(RainWorldMod x, RainWorldMod y)
 {
     return(ListItem.GetRealName(x.ModID).CompareTo(ListItem.GetRealName(y.ModID)));
 }
Ejemplo n.º 5
0
 public UnconfiguableOI(RainWorldMod rwMod, Exception exception) : base(rwMod)
 {
     CtorInitError(exception);
 }
Ejemplo n.º 6
0
 public UnconfiguableOI(RainWorldMod rwMod, Reason type) : base(rwMod)
 {
     this.reason = type;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// If you're using BepInEx.Configuration and not using LoadOI, this is called automatically.
 /// <para>Sections will be separated by OpTab.</para>
 /// </summary>
 public GeneratedOI(RainWorldMod mod, ConfigFile config) : base(mod)
 {
     mode         = GenMode.BepInExConfig;
     bepConfigObj = config;
 }