private void createMenu() { toys = new ButtonGroup("Toy" + id, name); int step = (int)(maxSpeed * ((float)VibratorController.buttonStep / 100)); changeMode = new SingleButton(() => changeHand(), VibratorController.CreateSpriteFromTexture2D(GetTexture()), $"Mode\n{hand}", "mode", "Change Mode"); inc = new SingleButton(() => { if (lastSpeed + step <= maxSpeed) { setSpeed(lastSpeed + step); } }, VibratorController.CreateSpriteFromTexture2D(GetTexture()), "Inc", "inc", "Increment Speed"); dec = new SingleButton(() => { if (lastSpeed - step >= 0) { setSpeed(lastSpeed - step); } }, VibratorController.CreateSpriteFromTexture2D(GetTexture()), "Dec", "dec", "Decrement Speed"); label = new Label($"Current Speed: {lastSpeed}", "Battery not available", "BatteryStatus"); label.TextComponent.fontSize = 24; toys.AddButton(changeMode); toys.AddButton(inc); toys.AddButton(dec); toys.AddButton(label); menu.AddButtonGroup(toys); //fix if added after init phase toys.gameObject.transform.localScale = Vector3.one; toys.Header.gameObject.transform.localScale = Vector3.one; toys.gameObject.transform.localRotation = Quaternion.Euler(0, 0, 0); toys.Header.gameObject.transform.localRotation = Quaternion.Euler(0, 0, 0); var pos = toys.gameObject.transform.localPosition; var pos2 = toys.Header.gameObject.transform.localPosition; toys.gameObject.transform.localPosition = new Vector3(0, pos.y, 0); toys.Header.gameObject.transform.localPosition = new Vector3(0, pos2.y, 0); }
public static void Init() { try { SubMenu headLightSub = new SubMenu("Head Light", "headLightSubMenu", "Head Light"); SubMenu headLightColorSub = new SubMenu("Head Light Colors", "headLightColorSubMen", "HeadLight Colors"); SubMenu headLightColorAdjustSub = new SubMenu("Head Light Color Adjust", "headLightColorAdjuSubMen", "HeadLight Color Adjust"); headLightSub.PageLayoutGroup.m_Spacing = -15; ButtonGroup buttgroup = null; headLightSub.AddButtonGroup(new ButtonGroup("Head Light", "Head Light", new System.Collections.Generic.List <IButtonGroupElement>() { new ToggleButton((state) => ToggleLight(state), LightOn, LightOff, "Head Light Toggle", "HeadlightToggle", "Toggle Headlight On", "Toggle Headlight Off"), new ToggleButton((state) => { if (state) { Config.lightType = LightType.Point; } else { Config.lightType = LightType.Spot; } UpdateLight(); }, LightOn, flashLight, "Spot/Point", "SpotPointToggle", "Switch to Point Light", "Switch to Spot Light"), new SingleButton(() => { UiManager.OpenSubMenu(UiManager.QMStateController.field_Private_UIPage_0, headLightColorSub.uiPage); }, ColorPicker, "Color", "ColorAdj", "Adjust Colors"), }, (group) => buttgroup = group) ); buttgroup.ButtonLayoutGroup.constraintCount = 3; buttgroup.RemoveButtonHeader(); headLightSub.AddButtonGroup(new ButtonGroup("Options", "Options", new System.Collections.Generic.List <IButtonGroupElement>() { new SingleButton(() => { Config.lightIntensity += .1f; UpdateLight(); }, BrightnessHigher, "Intensity +", "Intensity+Button", "Brighten"), new SingleButton(() => { Config.lightSpotAngle += 5f; UpdateLight(); }, AnglePlus, "Angle +", "Angle+Button", "Widen Angle"), new SingleButton(() => { Config.lightRange += 1f; UpdateLight(); }, SizePlus, "Range +", "Range+Button", "Increase Range"), new SingleButton(() => { Config.lightIntensity = Utils.Clamp(Config.lightIntensity - .1f, 0, 1000); UpdateLight(); }, BrightnessLower, "Intensity -", "Intensity-Button", "Dim"), new SingleButton(() => { Config.lightSpotAngle = Utils.Clamp(Config.lightSpotAngle - 5f, 0, 2000); UpdateLight(); }, AngleMinus, "Angle -", "Angle-Button", "Narrow Angle"), new SingleButton(() => { Config.lightRange = Utils.Clamp(Config.lightRange - 1f, 0, 2000); UpdateLight(); }, SizeMinus, "Range -", "Range-Button", "Lower Range"), new SingleButton(() => { Config.lightIntensity = 1f; UpdateLight(); }, Reset, "Reset", "IntensityResetButton", "Reset Brightness"), new SingleButton(() => { Config.lightSpotAngle = 40f; UpdateLight(); }, Reset, "Reset", "AngleResetButton", "Reset Angle"), new SingleButton(() => { Config.lightRange = 10f; UpdateLight(); }, Reset, "Reset", "RangeResetButton", "Reset Range"), }, (group) => buttgroup = group) ); buttgroup.ButtonLayoutGroup.constraintCount = 3; headLightColorSub.AddButtonGroup(new ButtonGroup("Options", "Options", new System.Collections.Generic.List <IButtonGroupElement>() { new SingleButton(() => { Config.lightColor = Color.white; UpdateLight(); }, Trans, "<color=#FFFFFF>White</color>", "WhiteButton"), new SingleButton(() => { Config.lightColor = Color.red; UpdateLight(); }, Trans, "<color=#FF0000>Red</color>", "RedButton"), new SingleButton(() => { Config.lightColor = Color.green; UpdateLight(); }, Trans, "<color=#00FF00>Green</color>", "GreenButton"), new SingleButton(() => { Config.lightColor = Color.blue; UpdateLight(); }, Trans, "<color=#0000FF>Blue</color>", "BlueButton"), new SingleButton(() => UiManager.OpenSubMenu(UiManager.QMStateController.field_Private_UIPage_0, headLightColorAdjustSub.uiPage), Trans, "<color=#FF0000>C</color><color=#FFFF00>u</color><color=#00FF00>s</color><color=#00FFFF>t</color><color=#0000FF>o</color><color=#FF00FF>m</color> Color", "CustomColorButton", "Adjust the color"), new SingleButton(() => { Config.lightColor = Color.magenta; UpdateLight(); }, Trans, "<color=#FF00FF>Magenta</color>", "MagentaButton"), new SingleButton(() => { Config.lightColor = Color.yellow; UpdateLight(); }, Trans, "<color=#FFFF00>Yellow</color>", "YellowButton"), new SingleButton(() => { Config.lightColor = Color.cyan; UpdateLight(); }, Trans, "<color=#00FFFF>Cyan</color>", "CyanButton"), }) ); headLightColorAdjustSub.AddButtonGroup(new ButtonGroup("Options", "Options", new System.Collections.Generic.List <IButtonGroupElement>() { new SingleButton(() => { Config.lightColor.r = Utils.Clamp(Config.lightColor.r + .1f, 0f, 2f); UpdateLight(); }, Trans, "<color=#FF0000>Red +</color>", "Red+Button"), new SingleButton(() => { Config.lightColor.g = Utils.Clamp(Config.lightColor.g + .1f, 0f, 2f); UpdateLight(); }, Trans, "<color=#00FF00>Green +</color>", "Green+Button"), new SingleButton(() => { Config.lightColor.b = Utils.Clamp(Config.lightColor.b + .1f, 0f, 2f); UpdateLight(); }, Trans, "<color=#0000FF>Blue +</color>", "Blue+Button"), new SingleButton(() => { Config.lightColor.r = Utils.Clamp(Config.lightColor.r + .1f, 0f, 2f); Config.lightColor.g = Utils.Clamp(Config.lightColor.g + .1f, 0f, 2f); Config.lightColor.b = Utils.Clamp(Config.lightColor.b + .1f, 0f, 2f); UpdateLight(); }, Trans, "<color=#FF0000>A</color><color=#00FF00>L</color><color=#0000FF>L</color> +", "All+Button"), new SingleButton(() => { Config.lightColor.r = Utils.Clamp(Config.lightColor.r - .1f, 0f, 2f); UpdateLight(); }, Trans, "<color=#FF0000>Red -</color>", "Red-Button"), new SingleButton(() => { Config.lightColor.g = Utils.Clamp(Config.lightColor.g - .1f, 0f, 2f); UpdateLight(); }, Trans, "<color=#00FF00>Green -</color>", "Green-Button"), new SingleButton(() => { Config.lightColor.b = Utils.Clamp(Config.lightColor.b - .1f, 0f, 2f); UpdateLight(); }, Trans, "<color=#0000FF>Blue -</color>", "Blue-Button"), new SingleButton(() => { Config.lightColor.r = Utils.Clamp(Config.lightColor.r - .1f, 0f, 2f); Config.lightColor.g = Utils.Clamp(Config.lightColor.g - .1f, 0f, 2f); Config.lightColor.b = Utils.Clamp(Config.lightColor.b - .1f, 0f, 2f); UpdateLight(); }, Trans, "<color=#FF0000>A</color><color=#00FF00>L</color><color=#0000FF>L</color> -", "All-Button"), new SingleButton(() => { Config.lightColor.r = 1f; UpdateLight(); }, Reset, "Reset", "RedResetButton"), new SingleButton(() => { Config.lightColor.g = 1f; UpdateLight(); }, Reset, "Reset", "GreenResetButton"), new SingleButton(() => { Config.lightColor.b = 1f; UpdateLight(); }, Reset, "Reset", "BlueResetButton"), new SingleButton(() => { Config.lightColor.r = 1f; Config.lightColor.g = 1f; Config.lightColor.b = 1f; UpdateLight(); }, Reset, "Reset", "AllResetButton") }, (group) => buttgroup = group) ); var origButt = UiManager.QMStateController.transform.Find("Container/Window/QMParent/Menu_Here/QMHeader_H1/RightItemContainer/Button_QM_Expand"); var newButt = UnityEngine.Object.Instantiate(origButt); var butAction = new System.Action(() => { UiManager.OpenSubMenu(UiManager.QMStateController.field_Private_UIPage_0, headLightSub.uiPage); }); newButt.name = "HeadLight_UI"; newButt.SetParent(UiManager.QMStateController.transform.Find("Container/Window/QMParent/Menu_Here/QMHeader_H1")); newButt.localPosition = new Vector3(buttX.Value, buttY.Value, 0f); //200f, -60f newButt.GetComponent <Button>().onClick = new Button.ButtonClickedEvent(); newButt.GetComponent <Button>().onClick.AddListener(butAction); newButt.GetComponent <VRC.UI.Elements.Tooltips.UiTooltip>().field_Public_String_0 = "HeadLight"; newButt.GetComponentInChildren <Image>().overrideSprite = flashLight; uiButton = newButt; buttX.OnValueChanged += OnPositionChange; buttY.OnValueChanged += OnPositionChange; } catch (System.Exception ex) { MelonLogger.Error("LocalHeadLightMoid Init: " + ex.ToString()); } }