public Selector(int index, ConfigTabController ctrler) : base(new Vector2(), new Vector2()) { this.index = index; this.ctrl = ctrler; this.bumpBehav = new BumpBehaviour(this); }
public SelectButton(int index, ConfigTabController ctrler) : base(index, 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.rectH = new DyeableRect(menu, owner, this.pos, this.size, false) { tab = true }; this.label = new MenuLabel(menu, owner, this.name, this.pos, this.size, false); this.subObjects.Add(this.rect); this.subObjects.Add(this.rectH); this.subObjects.Add(this.label); }
public SelectTab(int index, ConfigTabController ctrler) : base(index, ctrler) { float height = Mathf.Min(120f, 600f / ctrler._tabCount); //ctrler._tabCount this._pos = ctrl.pos + new Vector2(17f, height * (-index - 1) + 603f); //ctrl.pos + new Vector2(17f, height * (ctrler._tabCount - index - 1) + 3f); //Debug.Log(string.Concat("Idx: ", index, " y: ", this._pos.y - ctrl.pos.y)); this._size = new Vector2(30f, height - 6f); this.rect = new DyeableRect(menu, owner, this.pos, this.size, true) { tab = true }; this.rectH = new DyeableRect(menu, owner, this.pos, this.size, false) { tab = true }; this.label = new MenuLabel(menu, owner, this.name, this.pos, this.size, false); this.subObjects.Add(this.rect); this.subObjects.Add(this.rectH); this.subObjects.Add(this.label); }
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; }