Example #1
0
        public static void Postfix(OptionsMenuBehaviour __instance)
        {
            if (__instance.CensorChatButton != null)
            {
                if (origin == null)
                {
                    origin = __instance.CensorChatButton.transform.localPosition + Vector3.up * 0.25f;
                }
                __instance.CensorChatButton.transform.localPosition = origin.Value + Vector3.left * 1.3f;
            }

            if ((streamerModeButton == null || streamerModeButton.gameObject == null))
            {
                streamerModeButton = createCustomToggle("Hide Code: ", StreamHatsPlugin.HideCode.Value, Vector3.right * 1.3f, (UnityEngine.Events.UnityAction)streamerModeToggle, __instance);

                void streamerModeToggle()
                {
                    StreamHatsPlugin.HideCode.Value = !StreamHatsPlugin.HideCode.Value;
                    updateToggle(streamerModeButton, "Hide Code: ", StreamHatsPlugin.HideCode.Value);
                }
            }

            if ((ghostsSeeTasksandRolesButton == null || ghostsSeeTasksandRolesButton.gameObject == null))
            {
                ghostsSeeTasksandRolesButton = createCustomToggle("Ghosts See Other's Roles and Tasks: ", StreamHatsPlugin.ghostsSeeTasksandRoles.Value, new Vector2(0.0f, -0.5f), (UnityEngine.Events.UnityAction)ghostsSeeTaskToggle, __instance);

                void ghostsSeeTaskToggle()
                {
                    StreamHatsPlugin.ghostsSeeTasksandRoles.Value = !StreamHatsPlugin.ghostsSeeTasksandRoles.Value;
                    MapOptions.ghostsSeeTasksandRoles             = StreamHatsPlugin.ghostsSeeTasksandRoles.Value;
                    updateToggle(ghostsSeeTasksandRolesButton, "Ghosts See Other's Roles and Tasks: ", StreamHatsPlugin.ghostsSeeTasksandRoles.Value);
                }
            }
        }
Example #2
0
        private void Start(OptionsMenuBehaviour optionsMenu, GameObject parent)
        {
            //Get original components
            var oBackgroundComponent = Utils.GetChildComponentByName <Component>(optionsMenu, "Background");
            var oCloseButton         = Utils.GetChildComponentByName <Component>(optionsMenu, "CloseButton");
            var oControlText         = Utils.GetChildComponentByName <TextMeshPro>(optionsMenu, "ControlText_TMP");

            //Create component and add it to the parent
            holder = new GameObject(name);

            //Set button parent
            holder.transform.parent = parent == null ? optionsMenu.transform : parent.transform;

            //Configure holder and his components
            holder.layer = 5; //UI
            holder.transform.localScale    = new Vector3(1f, 1f, 1f);
            holder.transform.localPosition = Vector3.back * 20f;

            //clone original sub components
            _backgroundComponent = Object.Instantiate(oBackgroundComponent, holder.transform);
            if (oCloseButton != null)
            {
                _closeButton = Object.Instantiate(oCloseButton, holder.transform);
            }
            _controlText = Object.Instantiate(oControlText, holder.transform);

            //Configure background size
            _backgroundComponent.transform.localPosition = new Vector3(_backgroundComponent.transform.localPosition.x,
                                                                       _backgroundComponent.transform.localPosition.y, 9f);
            var renderer = _backgroundComponent.gameObject.GetComponent <SpriteRenderer>();

            renderer.size = size;
            var collider = _backgroundComponent.gameObject.GetComponent <BoxCollider2D>();

            collider.size = size;

            //Configure close button
            if (_closeButton != null)
            {
                _closeButton.transform.localPosition = new Vector3(pos.x, pos.y);
                var button = _closeButton.gameObject.GetComponent <PassiveButton>();
                Object.Destroy(button);
                button = _closeButton.gameObject.AddComponent <PassiveButton>();
                button.OnClick.AddListener((UnityAction)OnClose);
                button.OnMouseOver = new UnityEvent();
                button.OnMouseOut  = new UnityEvent();
            }

            //Configure title title
            _textRenderer = _controlText.gameObject.GetComponent <TextMeshPro>();
            //_textRenderer.Centered = true;
            _textRenderer.alignment = TextAlignmentOptions.Center;
            _controlText.transform.localPosition = new Vector3(/*-(size.x / 2) * 0.90f */ 0f, size.y / 2 * 0.92f);


            //Enable the button
            holder.gameObject.SetActive(false);
        }
Example #3
0
        public PopUpWindow(OptionsMenuBehaviour optionsMenu, string name, string title, Vector2 size, Vector2 pos,
                           GameObject parent = null)
        {
            this.name  = name;
            this.title = title;
            this.size  = size;
            this.pos   = pos;

            Windows.Add(this);
            Start(optionsMenu, parent);
        }
Example #4
0
        //Setup key listener

        public KeySelector(OptionsMenuBehaviour optionsMenu, string name, string label, KeyAction key, Vector2 labelPos,
                           Vector2 buttonPos, GameObject parent = null)
        {
            this.name      = name;
            this.label     = label;
            this.key       = key;
            this.labelPos  = labelPos;
            this.buttonPos = buttonPos;

            Selectors.Add(this);
            Start(optionsMenu, parent);
        }
Example #5
0
 public static bool Prefix(OptionsMenuBehaviour __instance)
 {
     if (KeySelector.canEscape)
     {
         return(true);
     }
     if (Input.GetKeyUp(KeyCode.Escape))
     {
         KeySelector.canEscape = true;
     }
     return(false);
 }
Example #6
0
        public OptionsMenuButton(OptionsMenuBehaviour optionsMenu, string name, string text, Action action, Vector2 pos,
                                 Vector2 size, GameObject parent = null)
        {
            this.text   = text;
            this.pos    = pos;
            this.name   = name;
            this.action = action;
            this.size   = size;

            Buttons.Add(this);
            Start(optionsMenu, parent);
        }
Example #7
0
        private void Start(OptionsMenuBehaviour optionsMenu, GameObject parent)
        {
            //Get original components
            var oControlGroup = Utils.GetChildComponentByName <Component>(optionsMenu, "ControlGroup");
            var oControlText  = Utils.GetChildComponentByName <TextMeshPro>(oControlGroup, "ControlText_TMP");
            var oIgnoreClose  = Utils.GetChildComponentByName <Component>(optionsMenu, "IgnoreClose");

            if (oIgnoreClose == null)
            {
                oIgnoreClose = Utils.GetChildComponentByName <Component>(optionsMenu, "CloseBackground");
            }

            //Create component and add it to the parent
            _holder = new GameObject(name);

            //Set button parent
            _holder.transform.parent = parent == null ? optionsMenu.transform : parent.transform;

            //Configure holder and his components
            _holder.layer = 5; //UI
            _holder.transform.localScale    = new Vector3(1f, 1f, 1f);
            _holder.transform.localPosition = Vector3.zero;

            //clone original sub components
            _label       = Object.Instantiate(oControlText, _holder.transform);
            _ignoreClose = Object.Instantiate(oIgnoreClose, _holder.transform);

            //Configure label
            _textRenderer = _label.gameObject.GetComponent <TextMeshPro>();
            _label.transform.localPosition = new Vector3(labelPos.x, labelPos.y);

            //Create button
            _button = new OptionsMenuButton(optionsMenu, key + "Button", ConfigManager.keyBinds[key].ToString(),
                                            OnClick, buttonPos + new Vector2(0f, -0.2f) /* Centered vertical anchor */, new Vector2(1.0f, 0.4f),
                                            _holder);
            _button.SetOnMouseOut(OnMouseOut);
            _button.SetOnMouseOver(OnMouseOver);

            //Configure ignoreClose
            _ignoreClose.gameObject.SetActive(false);
            _ignoreClose.transform.localPosition = new Vector3(_ignoreClose.transform.localPosition.x,
                                                               _ignoreClose.transform.localPosition.y, _ignoreClose.transform.localPosition.z - 1000f);

            var collider = _ignoreClose.gameObject.GetComponent <BoxCollider2D>();

            collider.size = new Vector2(Screen.width, Screen.height);
        }
Example #8
0
        private void Start(OptionsMenuBehaviour optionsMenu, GameObject parent)
        {
            //Get original components
            var joyStickButtonComponent = Utils.GetChildComponentByName <Component>(optionsMenu, "JoystickModeButton");
            var oBackgroundComponent    = Utils.GetChildComponentByName <Component>(joyStickButtonComponent, "Background");
            var oTextComponent          = Utils.GetChildComponentByName <TextMeshPro>(joyStickButtonComponent, "Text_TMP");//oBackgroundComponent.GetComponentInChildren<TextRenderer>();//Utils.GetChildComponentByName<TextRenderer>(joyStickButtonComponent, "Text_TMP");

            //Create component and add it to the parent
            holder = new GameObject(name);

            //Set button parent
            holder.transform.parent =
                parent == null ? joyStickButtonComponent.transform.parent.transform : parent.transform;

            //Configure holder and his components
            holder.layer = 5; //UI
            holder.transform.localScale = new Vector3(1f, 1f, 1f);
            //holder.transform.localPosition = new Vector3(holder.transform.localPosition.x, holder.transform.localPosition.y, holder.transform.localPosition.z - 100f);
            var collider = holder.gameObject.AddComponent <BoxCollider2D>();

            collider.size = size;

            //clone original sub components
            backgroundComponent = Object.Instantiate(oBackgroundComponent, holder.transform);
            textComponent       = Object.Instantiate(oTextComponent, holder.transform);

            //Configure background size
            var renderer = backgroundComponent.gameObject.GetComponent <SpriteRenderer>();

            renderer.size = size;

            //Add PassiveButton component
            button = holder.gameObject.AddComponent <PassiveButton>();
            button.OnClick.AddListener(action);
            button.OnMouseOut = new UnityEvent();
            button.OnMouseOut.AddListener((UnityAction)OnOut);
            button.OnMouseOver = new UnityEvent();
            button.OnMouseOver.AddListener((UnityAction)OnOver);

            //Enable the button
            OnOut();
            holder.gameObject.SetActive(true);
            textComponent.text             = text;
            holder.transform.localPosition = new Vector3(pos.x, pos.y);
        }
        public static void Postfix(OptionsMenuBehaviour __instance)
        {
            if ((streamerModeButton == null || streamerModeButton.gameObject == null) && __instance.CensorChatButton != null)
            {
                streamerModeButton = UnityEngine.Object.Instantiate(__instance.CensorChatButton, __instance.CensorChatButton.transform.parent);
                streamerModeButton.transform.localPosition          += Vector3.down * 0.25f;
                __instance.CensorChatButton.transform.localPosition += Vector3.up * 0.25f;
                PassiveButton button = streamerModeButton.GetComponent <PassiveButton>();
                button.OnClick = new Button.ButtonClickedEvent();
                button.OnClick.AddListener((UnityEngine.Events.UnityAction)onClick);
                updateStreamerModeButton();
            }

            void onClick()
            {
                TheOtherRolesPlugin.StreamerMode.Value = !TheOtherRolesPlugin.StreamerMode.Value;
                updateStreamerModeButton();
            }
        }
Example #10
0
        private static void CreateCustom(OptionsMenuBehaviour prefab)
        {
            popUp = Object.Instantiate(prefab.gameObject);
            Object.DontDestroyOnLoad(popUp);
            var transform = popUp.transform;
            var pos       = transform.localPosition;

            pos.z = -810f;
            transform.localPosition = pos;

            Object.Destroy(popUp.GetComponent <OptionsMenuBehaviour>());
            foreach (var gObj in popUp.gameObject.GetAllChilds())
            {
                if (gObj.name != "Background" && gObj.name != "CloseButton")
                {
                    Object.Destroy(gObj);
                }
            }

            popUp.SetActive(false);
        }
Example #11
0
        private static void InitializeMoreButton(OptionsMenuBehaviour __instance)
        {
            __instance.BackButton.transform.localPosition += Vector3.right * 1.8f;
            moreOptions = Object.Instantiate(buttonPrefab, __instance.CensorChatButton.transform.parent);
            moreOptions.transform.localPosition = __instance.CensorChatButton.transform.localPosition + Vector3.down * 0.5f;

            moreOptions.gameObject.SetActive(true);
            moreOptions.Text.text = ModTranslation.getString("modOptionsText");
            var moreOptionsButton = moreOptions.GetComponent <PassiveButton>();

            moreOptionsButton.OnClick = new ButtonClickedEvent();
            moreOptionsButton.OnClick.AddListener((Action)(() =>
            {
                if (!popUp)
                {
                    return;
                }

                if (__instance.transform.parent && __instance.transform.parent == HudManager.Instance.transform)
                {
                    popUp.transform.SetParent(HudManager.Instance.transform);
                    popUp.transform.localPosition = new Vector3(0, 0, -800f);
                }
                else
                {
                    popUp.transform.SetParent(null);
                    Object.DontDestroyOnLoad(popUp);
                }

                CheckSetTitle();
                RefreshOpen();
            }));

            var leaveGameButton = GameObject.Find("LeaveGameButton");

            if (leaveGameButton != null)
            {
                leaveGameButton.transform.localPosition += (Vector3.right * 1.3f);
            }
        }
Example #12
0
        private void Start(OptionsMenuBehaviour optionsMenu)
        {
            //Setup separator
            separator = new GameObject("Separator");
            separator.transform.parent = holder.transform;
            var start = new Vector3(0f, size.y / 2 * 0.75f, holder.transform.position.z - 21f);

            separator.transform.position = start;

            /*
             * var lr = separator.AddComponent<LineRenderer>();
             * lr.material = new Material(Shader.Find("Unlit/ColoredVertices"));
             * lr.SetColors(Color.white, Color.white);
             * lr.SetWidth(0.05f, 0.05f);
             * lr.SetPosition(0, start);
             * lr.SetPosition(1, new Vector3(0f, -size.y / 2 * 0.9f, holder.transform.position.z - 21f));
             */
            //Create child elements
            var i = 0;

            foreach (KeyAction action in Enum.GetValues(typeof(KeyAction)))
            {
                const int   numRows    = 5;
                var         column     = i / numRows;
                var         row        = i % numRows;
                const float topPercent = 0.70f;
                const float botPercent = 0.90f;

                var selectorPos = new Vector2(-size.x / 2 * botPercent + column * (size.x / 2),
                                              size.y / 2 * topPercent - row * (size.y * (topPercent + botPercent) / 2 / numRows));
                content.Add(new KeySelector(optionsMenu,
                                            action.ToString(),
                                            action.ToString(),
                                            action,
                                            selectorPos + new Vector2(1.1f, -0.17f),
                                            selectorPos + new Vector2(size.x / 3, 0f),
                                            holder));
                i++;
            }
        }
Example #13
0
        public static void OptionsMenuBehaviour_StartPostfix(OptionsMenuBehaviour __instance)
        {
            if (!__instance.CensorChatButton)
            {
                return;
            }

            if (!popUp)
            {
                CreateCustom(__instance);
            }

            if (!buttonPrefab)
            {
                buttonPrefab = Object.Instantiate(__instance.CensorChatButton);
                Object.DontDestroyOnLoad(buttonPrefab);
                buttonPrefab.name = "CensorChatPrefab";
                buttonPrefab.gameObject.SetActive(false);
            }

            SetUpOptions();
            InitializeMoreButton(__instance);
        }
Example #14
0
 public SettingsWindow(OptionsMenuBehaviour optionsMenu) : base(optionsMenu, "KeyBindPopUp", "Keybinds",
                                                                new Vector2(5.5f, 4f), new Vector2(-3f, 1.75f))
 {
     SetButtonListener(OnClose);
     Start(optionsMenu);
 }
Example #15
0
        private static ToggleButtonBehaviour createCustomToggle(string text, bool on, Vector3 offset, UnityEngine.Events.UnityAction onClick, OptionsMenuBehaviour __instance)
        {
            if (__instance.CensorChatButton != null)
            {
                var button = UnityEngine.Object.Instantiate(__instance.CensorChatButton, __instance.CensorChatButton.transform.parent);
                button.transform.localPosition = (origin ?? Vector3.zero) + offset;
                PassiveButton passiveButton = button.GetComponent <PassiveButton>();
                passiveButton.OnClick = new Button.ButtonClickedEvent();
                passiveButton.OnClick.AddListener(onClick);
                updateToggle(button, text, on);

                return(button);
            }
            return(null);
        }
Example #16
0
 public static void Postfix(OptionsMenuBehaviour __instance)
 {
     new OptionsMenuButton(__instance, "OpenKeyBindMenuButton", "KeyBinds", OpenKeyBindMenu,
                           new Vector2(0f, -0.9f));
     _keyBindsPopUp = new SettingsWindow(__instance);
 }
Example #17
0
 public OptionsMenuButton(OptionsMenuBehaviour optionsMenu, string name, string text, Action action, Vector2 pos,
                          GameObject parent = null) : this(optionsMenu, name, text, action, pos, new Vector2(2.0f, 0.4f), parent)
 {
 }