private void initButton(int btnXLocation, int btnYLocation, String btnText, System.Action btnAction, String btnToolTip, Color?btnBackgroundColor = null, Color?btnTextColor = null) { btnType = "SingleButton"; button = UnityEngine.Object.Instantiate(QMStuff.SingleButtonTemplate(), QMStuff.GetQuickMenuInstance().transform.Find(btnQMLoc), true); initShift[0] = -1; initShift[1] = 0; setLocation(btnXLocation, btnYLocation); setButtonText(btnText); setToolTip(btnToolTip); setAction(btnAction); if (btnBackgroundColor != null) { setBackgroundColor((Color)btnBackgroundColor); } else { OrigBackground = button.GetComponentInChildren <UnityEngine.UI.Image>().color; } if (btnTextColor != null) { setTextColor((Color)btnTextColor); } else { OrigText = button.GetComponentInChildren <Text>().color; } setActive(true); QMButtonAPI.allSingleButtons.Add(this); }
public void initButton(int btnXLocation, int btnYLocation, String btnText, String btnToolTip, Color?btnBackgroundColor = null, Color?btnTextColor = null, Color?backbtnBackgroundColor = null, Color?backbtnTextColor = null) { btnType = "NestedButton"; Transform menu = UnityEngine.Object.Instantiate <Transform>(QMStuff.NestedMenuTemplate(), QMStuff.GetQuickMenuInstance().transform); menuName = QMButtonAPI.identifier + btnQMLoc + "_" + btnXLocation + "_" + btnYLocation; menu.name = menuName; mainButton = new QMSingleButton(btnQMLoc, btnXLocation, btnYLocation, btnText, () => { QMStuff.ShowQuickmenuPage(menuName); }, btnToolTip, btnBackgroundColor, btnTextColor); Il2CppSystem.Collections.IEnumerator enumerator = menu.transform.GetEnumerator(); while (enumerator.MoveNext()) { Il2CppSystem.Object obj = enumerator.Current; Transform btnEnum = obj.Cast <Transform>(); if (btnEnum != null) { UnityEngine.Object.Destroy(btnEnum.gameObject); } } if (backbtnTextColor == null) { backbtnTextColor = Color.yellow; } QMButtonAPI.allNestedButtons.Add(this); backButton = new QMSingleButton(this, 5, 2, "Back", () => { QMStuff.ShowQuickmenuPage(btnQMLoc); }, "Go Back", backbtnBackgroundColor, backbtnTextColor); }
private void initButton(int btnXLocation, int btnYLocation, String btnTextOn, System.Action btnActionOn, String btnTextOff, System.Action btnActionOff, String btnToolTip, Color?btnBackgroundColor = null, Color?btnTextColor = null, bool shouldSaveInConf = false, bool defaultPosition = false) { btnType = "ToggleButton"; button = UnityEngine.Object.Instantiate <GameObject>(QMStuff.ToggleButtonTemplate(), QMStuff.GetQuickMenuInstance().transform.Find(btnQMLoc), true); btnOn = button.transform.Find("Toggle_States_Visible/ON").gameObject; btnOff = button.transform.Find("Toggle_States_Visible/OFF").gameObject; initShift[0] = -4; initShift[1] = 0; setLocation(btnXLocation, btnYLocation); setOnText(btnTextOn); setOffText(btnTextOff); Text[] btnTextsOn = btnOn.GetComponentsInChildren <Text>(); btnTextsOn[0].name = "Text_ON"; btnTextsOn[0].resizeTextForBestFit = true; btnTextsOn[1].name = "Text_OFF"; btnTextsOn[1].resizeTextForBestFit = true; Text[] btnTextsOff = btnOff.GetComponentsInChildren <Text>(); btnTextsOff[0].name = "Text_ON"; btnTextsOff[0].resizeTextForBestFit = true; btnTextsOff[1].name = "Text_OFF"; btnTextsOff[1].resizeTextForBestFit = true; setToolTip(btnToolTip); //button.transform.GetComponentInChildren<UiTooltip>().SetToolTipBasedOnToggle(); setAction(btnActionOn, btnActionOff); btnOn.SetActive(false); btnOff.SetActive(true); if (btnBackgroundColor != null) { setBackgroundColor((Color)btnBackgroundColor); } else { OrigBackground = btnOn.GetComponentsInChildren <Text>().First().color; } if (btnTextColor != null) { setTextColor((Color)btnTextColor); } else { OrigText = btnOn.GetComponentsInChildren <UnityEngine.UI.Image>().First().color; } setActive(true); shouldSaveInConfig = shouldSaveInConf; if (defaultPosition == true)// && !ButtonSettings.Contains(this)) { setToggleState(true, false); } QMButtonAPI.allToggleButtons.Add(this); //ButtonSettings.InitToggle(this); }
private IEnumerator WaitForTabMenu(int btnXLocation, int btnYLocation, string btnText, Action btnAction, string btnToolTip, Color?btnBackgroundColor, Color?btnTextColor) { while (QMStuff.GetQuickMenuInstance().transform.Find(btnQMLoc) == false) { yield return(null); } initButton(btnXLocation, btnYLocation, btnText, btnAction, btnToolTip, btnBackgroundColor, btnTextColor); yield break; }
private IEnumerator WaitForTabMenu(int btnXLocation, int btnYLocation, string btnTextOn, Action btnActionOn, string btnTextOff, Action btnActionOff, string btnToolTip, Color?btnBackgroundColor, Color?btnTextColor, bool shouldSaveInConfig, bool defaultPosition) { while (QMStuff.GetQuickMenuInstance().transform.Find(btnQMLoc) == false) { yield return(null); } initButton(btnXLocation, btnYLocation, btnTextOn, btnActionOn, btnTextOff, btnActionOff, btnToolTip, btnBackgroundColor, btnTextColor, shouldSaveInConfig, defaultPosition); yield break; }
public void initButton(int btnXLocation, int btnYLocation, String btnText, String btnToolTip, Color?btnBackgroundColor = null, Color?btnTextColor = null, Color?backbtnBackgroundColor = null, Color?backbtnTextColor = null) { btnType = "NestedButton"; Transform menu = UnityEngine.Object.Instantiate <Transform>(QMStuff.NestedMenuTemplate(), QMStuff.GetQuickMenuInstance().transform); menuName = QMButtonAPI.identifier + btnQMLoc + "_" + btnXLocation + "_" + btnYLocation; menu.name = menuName; CachedMenu = menu; mainButton = new QMSingleButton(btnQMLoc, btnXLocation, btnYLocation, btnText, () => { QMStuff.ShowQuickmenuPage(menuName); }, btnToolTip, btnBackgroundColor, btnTextColor); ClearButtons(); if (backbtnTextColor == null) { backbtnTextColor = Color.yellow; } backButton = new QMSingleButton(this, 5, 2, "Back", () => { QMStuff.ShowQuickmenuPage(btnQMLoc); }, "Go Back", backbtnBackgroundColor, backbtnTextColor); }
private void initButton(int btnXLocation, int btnYLocation, String btnTextOn, System.Action btnActionOn, String btnTextOff, System.Action btnActionOff, String btnToolTip, Color?btnBackgroundColor = null, Color?btnTextColor = null, bool shouldSaveInConf = false, bool defaultPosition = false) { btnType = "ToggleButton"; button = UnityEngine.Object.Instantiate <GameObject>(QMStuff.ToggleButtonTemplate(), QMStuff.GetQuickMenuInstance().transform.Find(btnQMLoc), true); btnOn = button.transform.Find("Toggle_States_Visible/ON").gameObject; btnOff = button.transform.Find("Toggle_States_Visible/OFF").gameObject; initShift[0] = -4; initShift[1] = 0; setLocation(btnXLocation, btnYLocation); setOnText(btnTextOn); setOffText(btnTextOff); Text[] btnTextsOn = btnOn.GetComponentsInChildren <Text>(); btnTextsOn[0].name = "Text_ON"; btnTextsOn[0].resizeTextForBestFit = true; btnTextsOn[0].color = (Color)btnTextColor; btnTextsOn[1].name = "Text_OFF"; btnTextsOn[1].resizeTextForBestFit = true; btnTextsOn[1].color = (Color)btnTextColor; Text[] btnTextsOff = btnOff.GetComponentsInChildren <Text>(); btnTextsOff[0].name = "Text_ON"; btnTextsOff[0].resizeTextForBestFit = true; btnTextsOff[0].color = (Color)btnTextColor; btnTextsOff[1].name = "Text_OFF"; btnTextsOff[1].resizeTextForBestFit = true; btnTextsOff[1].color = (Color)btnTextColor; btnOn.GetComponentInChildren <Image>().color = (Color)btnBackgroundColor; btnOff.GetComponentInChildren <Image>().color = (Color)btnBackgroundColor; setToolTip(btnToolTip); setAction(btnActionOn, btnActionOff); btnOn.SetActive(false); btnOff.SetActive(true); setActive(true); if (defaultPosition) { setToggleState(true, false); } GeneralUtils.Buttons.Add(this); }
private IEnumerator InitButtonNew(string Name, string base64image, string ImageURL, byte[] imagebytes) { menuName = QMButtonAPI.identifier + "_Custom_Menu_" + Name; while (MonoBehaviourPublicObCoGaCoObCoObCoUnique.prop_MonoBehaviourPublicObCoGaCoObCoObCoUnique_0 == null || MonoBehaviourPublicObCoGaCoObCoObCoUnique.prop_MonoBehaviourPublicObCoGaCoObCoObCoUnique_0.field_Public_ArrayOf_GameObject_0 == null) { yield return(null); } byte[] imagedata = null; if (base64image != null && ImageURL == null && imagebytes == null) { imagedata = Convert.FromBase64String(base64image); } else if (ImageURL != null && base64image == null && imagebytes == null) { WebClient wc = new WebClient(); imagedata = wc.DownloadData(ImageURL); } else if (imagebytes != null && ImageURL == null && base64image == null) { imagedata = imagebytes; } else { MelonLoader.MelonLogger.Error("Well Shit someone is dumb"); yield break; } Texture2D icontexture = new Texture2D(2, 2, TextureFormat.ARGB32, false); ImageConversion.LoadImage(icontexture, imagedata); Transform menu = UnityEngine.Object.Instantiate <Transform>(QMStuff.NestedMenuTemplate(), QMStuff.GetQuickMenuInstance().transform); menu.name = menuName; var TabButton = GameObject.Instantiate(GameObject.Find("UserInterface/QuickMenu/QuickModeTabs/NotificationsTab"), GameObject.Find("UserInterface/QuickMenu/QuickModeTabs").transform); TabButton.name = QMButtonAPI.identifier + "_" + Name; GameObject.Destroy(TabButton.transform.Find("Badge")); TabButton.GetComponent <Button>().onClick = new Button.ButtonClickedEvent(); TabButton.GetComponent <Button>().onClick.AddListener((Action) delegate() { QMStuff.ShowQuickmenuPage(menuName); }); TabButton.transform.Find("Icon").GetComponent <Image>().sprite = new Sprite(); TabButton.transform.Find("Icon").GetComponent <Image>().material = new Material(TabButton.transform.Find("Icon").GetComponent <Image>().material) { mainTexture = icontexture }; Il2CppSystem.Collections.IEnumerator enumerator = menu.transform.GetEnumerator(); while (enumerator.MoveNext()) { Il2CppSystem.Object obj = enumerator.Current; Transform btnEnum = obj.Cast <Transform>(); if (btnEnum != null) { UnityEngine.Object.Destroy(btnEnum.gameObject); } } QMButtonAPI.allNestedButtons.Add(this); backButton = new QMSingleButton(this, 5, 2, "Back", () => { QMStuff.ShowQuickmenuPage("ShortcutMenu"); }, "Go Back", Color.cyan, Color.yellow); yield break; }