Beispiel #1
0
            public SelectButton(int index, ConfigTabController ctrler) : base(new Vector2(), new Vector2())
            {
                this.index = index;
                this.ctrl  = ctrler;

                this._pos = ctrl.pos + new Vector2(18f, 30f * (19 - index) + 3f);
                this.size = new Vector2(30f, 24f);
                this.rect = new DyeableRect(menu, owner, this.pos, this.size, true)
                {
                    tab = true
                };
                this.subObjects.Add(this.rect);
                this.rect.fillAlpha = 0.3f;
            }
Beispiel #2
0
            public SelectTab(int index, ConfigTabController ctrler) : base(new Vector2(), new Vector2())
            {
                this.index = index;
                this.ctrl  = ctrler;
                float height = Mathf.Min(120f, 600f / ctrler._tabCount);

                this._pos = ctrl.pos + new Vector2(17f, height * (ctrler._tabCount - index - 1) + 3f);
                this.size = new Vector2(30f, height - 6f);
                this.rect = new DyeableRect(menu, owner, this.pos, this.size, true)
                {
                    tab = true
                };

                this.subObjects.Add(this.rect);
                this.rect.fillAlpha = 0.3f;
            }
Beispiel #3
0
        public void Initialize() //UI
        {
            if (vanillaMenu != null)
            {
                vanillaMenu.ShutDownProcess();
                vanillaMenu = null;
            }



            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);

            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(205f, 225f) - UIelement._offset, new Vector2(280f, 510f), 0.3f);
            //modCanvasBound = new OpRect(new Vector2(553f, 105f), new Vector2(630f, 630f), 0.4f);
            modCanvasBound = new OpRect(new Vector2(533f, 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], "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], "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], "RESET CONFIG", "RESET CONFIG", new Vector2(300f, 90f), 30f);
            this.pages[0].subObjects.Add(this.resetButton);

            //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;



            modButtons = new SelectOneButton[OptionScript.loadedModsDictionary.Count]; //<==MenuLabel
            int i = 0; selectedModIndex = 0;
            Dictionary <int, string> dictionary  = new Dictionary <int, string>(modButtons.Length);
            Dictionary <int, bool>   dictionary0 = new Dictionary <int, bool>(modButtons.Length);

            foreach (string id in OptionScript.loadedModsDictionary.Keys)
            {
                modButtons[i] = new SelectOneButton(this, this.pages[0], id, "ModSelect", new Vector2(220f, 700f - 30f * i), new Vector2(250f, 24f), modButtons, i);

                this.pages[0].subObjects.Add(modButtons[i]);

                dictionary.Add(i, id);
                Debug.Log(string.Concat("Mod(" + i + ") : " + id));
                OptionInterface itf = OptionScript.loadedInterfaceDict[id];
                try
                {
                    itf.Initialize();
                }
                catch (Exception ex)
                {
                    itf = new UnconfiguableOI(itf.mod, new Exception(string.Concat("OIinitializeError: ", id, " had a problem in Initialize().",
                                                                                   Environment.NewLine, ex
                                                                                   )));
                    OptionScript.loadedInterfaceDict.Remove(id);
                    OptionScript.loadedInterfaceDict.Add(id, itf);
                    itf.Initialize();
                }


                if (itf.Tabs == null || itf.Tabs.Length < 1)
                {
                    itf = new UnconfiguableOI(itf.mod, new Exception(string.Concat("TabIsNull: ", id, " OI has No OpTabs! ",
                                                                                   Environment.NewLine, "Did you put base.Initialize() after your code?",
                                                                                   Environment.NewLine, "Leaving OI.Initialize() completely blank will prevent the mod from using LoadData/SaveData."
                                                                                   )));
                    OptionScript.loadedInterfaceDict.Remove(id);
                    OptionScript.loadedInterfaceDict.Add(id, itf);
                    itf.Initialize();
                }
                else if (itf.Tabs.Length > 20)
                {
                    itf = new UnconfiguableOI(itf.mod, new Exception("Too Many Tabs! D: Maximum tab number is 20.\nAlso what are you going to do with all those settings?"));
                    OptionScript.loadedInterfaceDict.Remove(id);
                    OptionScript.loadedInterfaceDict.Add(id, itf);
                    itf.Initialize();
                }

                try
                {
                    itf.LoadConfig();
                    itf.ShowConfig();
                }
                catch (Exception ex)
                {
                    itf = new UnconfiguableOI(itf.mod, new Exception(string.Concat("OILoad/ShowConfigError: ", id, " had a problem in Load/ShowConfig()\nAre you editing LoadConfig()/ShowConfig()? That could cause serious error.",
                                                                                   Environment.NewLine, ex
                                                                                   )));
                    OptionScript.loadedInterfaceDict.Remove(id);
                    OptionScript.loadedInterfaceDict.Add(id, itf);
                    itf.Initialize();

                    itf.LoadConfig();
                    itf.ShowConfig();
                }

                dictionary0.Add(i, itf.Configuable());


                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();
                }

                i++;
            }
            modList           = dictionary;
            modConfiguability = dictionary0;


            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;
            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];
                }
            }



            //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(493f, 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;
        }