Exemplo n.º 1
0
        public override void OnUpdate()
        {
            if (Input.GetKeyUp(Key))
            {
                State = !State;
            }

            if (State && !prevState)
            {
                OnEnable?.Invoke();
                OnToggle?.Invoke();
            }
            else if (!State && prevState)
            {
                OnDisable?.Invoke();
                OnToggle?.Invoke();
            }


            if (State)
            {
                Funky?.Invoke();
            }

            prevState = State;
        }
Exemplo n.º 2
0
 public IconBar(int x, int y, Texture2D texture, int w = 45, int h = 45)
     : base(x, y, w, h, texture, alpha: 1f)
 {
     AddEventListener(Drawing.Events.Event.CLICKLEFT, delegate
     {
         OnToggle?.Invoke();
     });
 }
Exemplo n.º 3
0
    void HandleClick()
    {
        isOn = !isOn;

        target.sprite = isOn ? spriteOn : spriteOff;

        OnToggle?.Invoke(isOn);
        OnToggleEvent.Invoke();
    }
Exemplo n.º 4
0
 public void InvokeToggleGUI(bool bToggled)
 {
     if ((bool)(OnToggle?.Invoke(this, bToggled)))
     {
         OnShowGUI?.Invoke(this);
     }
     else
     {
         OnHideGUI?.Invoke(this);
     }
 }
        public void ToggleEditMode()
        {
            if (OnToggle == null)
            {
                return;
            }



            IsInEditMode = !IsInEditMode;
            OnToggle.Invoke();
        }
Exemplo n.º 6
0
 public void OnSelectAtkActionButton(PlayerSeat Seat, AbilityID Id)
 {
     if (Seat == seat && ability != null && Id == ability.Ability.AbilityID)
     {
         OnToggle.Invoke(!actionOutline.Active);
         GameEvents.Instance.Notify <IActionBoard>(i => i.OnBoardActionCheck(seat, actionOutline.Active ? ability : null));
     }
     else
     {
         OnToggle.Invoke(false);
     }
 }
Exemplo n.º 7
0
        public override void Instantiate()
        {
            if (initialized)
            {
                return;
            }

            //We have to find our own target
            //TODO: Clean up time complexity issue. This is called for each new option
            SoloFreePlayFlowCoordinator sfpfc = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First();
            GameplaySetupViewController gsvc  = sfpfc.GetField <GameplaySetupViewController>("_gameplaySetupViewController");
            RectTransform container           = (RectTransform)gsvc.transform.Find("GameplayModifiers").Find("RightColumn");

            gameObject                         = UnityEngine.Object.Instantiate(container.Find("NoFail").gameObject, container);
            gameObject.name                    = optionName;
            gameObject.layer                   = container.gameObject.layer;
            gameObject.transform.parent        = container;
            gameObject.transform.localPosition = Vector3.zero;
            gameObject.transform.localScale    = Vector3.one;
            gameObject.transform.rotation      = Quaternion.identity;
            gameObject.SetActive(false);

            var gmt = gameObject.GetComponent <GameplayModifierToggle>();

            if (gmt != null)
            {
                gmt.toggle.isOn = GetValue;
                gmt.toggle.onValueChanged.RemoveAllListeners();
                gmt.toggle.onValueChanged.AddListener((bool e) => { OnToggle?.Invoke(e); });

                GameplayModifierParamsSO _gameplayModifier = new GameplayModifierParamsSO();
                _gameplayModifier.SetPrivateField("_modifierName", optionName);
                _gameplayModifier.SetPrivateField("_hintText", hintText);
                _gameplayModifier.SetPrivateField("_multiplier", 0.0f);
                _gameplayModifier.SetPrivateField("_icon", optionIcon == null ? gmt.GetPrivateField <GameplayModifierParamsSO>("_gameplayModifier").icon : optionIcon);
                gmt.SetPrivateField("_gameplayModifier", _gameplayModifier);

                if (hintText != String.Empty)
                {
                    var hoverHint = gmt.GetPrivateField <HoverHint>("_hoverHint");
                    hoverHint.text    = hintText;
                    hoverHint.name    = optionName;
                    hoverHint.enabled = true;
                    var hoverHintController = Resources.FindObjectsOfTypeAll <HoverHintController>().First();
                    hoverHint.SetPrivateField("_hoverHintController", hoverHintController);
                }
            }



            initialized = true;
        }
Exemplo n.º 8
0
 public bool CheckCorrectItem(BasicItem item)
 {
     if (item?.Kind != RequiredItem)
     {
         OnWrongItem.Invoke();
         return(false);
     }
     else
     {
         OnToggle.Invoke();
         return(true);
     }
 }
Exemplo n.º 9
0
        public void Hide(string id)
        {
            if (id == null || id == "")
            {
                throw new InvalidOperationException("Id must be used with Drop Down Manager");
            }

            foreach (KeyAndValue <string, bool> menu in MenuState)
            {
                menu.Value = false;
            }
            OnToggle.Invoke(this, new EventArgs());
        }
Exemplo n.º 10
0
        public CheckboxComponent(UIGroup uiGroup, Vector2 position, Vector2 size, bool defaultValue, Texture2D backgroundTexture, Texture2D checkTexture) :
            base(uiGroup, position, size)
        {
            // Create the toggle component
            ToggleComponent            = GameObject.AddComponent <Toggle>();
            ToggleComponent.transition = Selectable.Transition.ColorTint;
            ToggleComponent.isOn       = defaultValue;

            // Create background object with image
            var backgroundObject = new GameObject();

            backgroundObject.AddComponent <RectTransform>().sizeDelta = size;
            backgroundObject.AddComponent <CanvasRenderer>();

            var backgroundImage = backgroundObject.AddComponent <Image>();

            backgroundImage.sprite = CreateSpriteFromTexture(backgroundTexture);
            backgroundImage.type   = Image.Type.Simple;

            backgroundObject.transform.SetParent(GameObject.transform, false);
            ToggleComponent.targetGraphic = backgroundImage;
            // Dont destroy background object
            Object.DontDestroyOnLoad(backgroundObject);

            // Create checkmark object with image
            var checkmarkObject = new GameObject();

            checkmarkObject.AddComponent <RectTransform>().sizeDelta = size;
            checkmarkObject.AddComponent <CanvasRenderer>();

            var checkmarkImage = checkmarkObject.AddComponent <Image>();

            checkmarkImage.sprite = CreateSpriteFromTexture(checkTexture);
            checkmarkImage.type   = Image.Type.Simple;

            checkmarkObject.transform.SetParent(GameObject.transform, false);
            // Set the graphic of the Toggle component to the checkmark image
            // This will ensure that if the checkbox is checked it will display the image
            ToggleComponent.graphic = checkmarkImage;
            // Dont destroy background object
            Object.DontDestroyOnLoad(checkmarkObject);

            // Finally create the listener for when the checkbox is toggled
            ToggleComponent.onValueChanged.AddListener(newValue => {
                _onToggle?.Invoke(newValue);
            });
        }
Exemplo n.º 11
0
        public override void Instantiate()
        {
            gameObject       = UnityEngine.Object.Instantiate(Resources.FindObjectsOfTypeAll <GameplayModifierToggle>().Where(g => g.transform.Find("BG"))?.Last().gameObject, Container);
            gameObject.name  = optionName;
            gameObject.layer = Container.gameObject.layer;
            gameObject.transform.SetParent(Container);
            gameObject.transform.localPosition = Vector3.zero;
            gameObject.transform.localScale    = Vector3.one;
            gameObject.transform.rotation      = Quaternion.identity;
            gameObject.SetActive(false);

            // Add a separator for this menu option
            AddSeparator(Container);

            // Remove the multiplier text if the toggle has no multiplier
            if (multiplier == 0)
            {
                gameObject.AddComponent <ToggleNameOverride>();
            }

            var currentToggle = gameObject.GetComponent <GameplayModifierToggle>();

            if (currentToggle != null)
            {
                currentToggle.toggle.isOn = GetValue;
                currentToggle.toggle.onValueChanged.RemoveAllListeners();
                currentToggle.toggle.onValueChanged.AddListener((bool e) => OnToggle?.Invoke(e));
                currentToggle.name = optionName;

                GameplayModifierParamsSO _gameplayModifier = ScriptableObject.CreateInstance <GameplayModifierParamsSO>();
                _gameplayModifier.SetPrivateField("_modifierName", optionName);
                _gameplayModifier.SetPrivateField("_hintText", hintText);
                _gameplayModifier.SetPrivateField("_multiplier", multiplier);
                _gameplayModifier.SetPrivateField("_icon", optionIcon == null ? UIUtilities.BlankSprite : optionIcon);
                currentToggle.SetPrivateField("_gameplayModifier", _gameplayModifier);

                if (hintText != String.Empty)
                {
                    HoverHint hoverHint = currentToggle.GetPrivateField <HoverHint>("_hoverHint");
                    hoverHint.text = hintText;
                    hoverHint.name = optionName;
                    HoverHintController hoverHintController = Resources.FindObjectsOfTypeAll <HoverHintController>().First();
                    hoverHint.SetPrivateField("_hoverHintController", hoverHintController);
                }
            }
            initialized = true;
        }
Exemplo n.º 12
0
        public MySwitch()
        {
            HeightRequest = 30.0;

            InitializeComponent();

            BindingContext = this;

            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (s, e) =>
            {
                IsSelected = !IsSelected;
                OnToggle?.Invoke(this, e);
            };

            _image.GestureRecognizers.Add(tapGestureRecognizer);
        }
Exemplo n.º 13
0
 public void OnSelectMoheActionButton(PlayerSeat Seat, string instanceId)
 {
     if (Seat == seat && moheData != null && moheData.InstanceID == instanceId)
     {
         if (!waitingForSwap)
         {
             OnToggle.Invoke(true);
         }
         else
         {
             OnToggle.Invoke(false);
             GameEvents.Instance.Notify <IMoheSwap>(i => i.OnMoheSwap(seat, moheData.InstanceID));
         }
     }
     else
     {
         OnToggle.Invoke(false);
     }
 }
Exemplo n.º 14
0
        public void Toggle(string id)
        {
            if (id == null || id == "")
            {
                throw new InvalidOperationException("Id must be used with Drop Down Manager");
            }

            foreach (var menu in MenuState)
            {
                if (menu.Key == id)
                {
                    menu.Value = !menu.Value;
                }
                else
                {
                    menu.Value = false;
                }
            }
            OnToggle.Invoke(this, new EventArgs());
        }
Exemplo n.º 15
0
 protected override void OnMouseClick(MouseButtonEventArgs data)
 {
     On = !On;
     OnToggle?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 16
0
 public static void ToggleInverted() => OnToggle?.Invoke();
Exemplo n.º 17
0
 public void Toggle()
 {
     OnToggle.Invoke();
 }
Exemplo n.º 18
0
 public virtual void HandleNoEnergyToggleDidSwitch(HMUI.Toggle toggle, bool isOn)
 {
     this.Value = isOn;
     ModPrefs.SetBool(Plugin.PluginName, _prefKey, isOn);
     OnToggle?.Invoke(isOn);
 }
Exemplo n.º 19
0
 private void HandleTriggerDown(float triggerValue)
 {
     OnToggle?.Invoke();
 }
        public override void Instantiate()
        {
            //We have to find our own target
            //TODO: Clean up time complexity issue. This is called for each new option
            SoloFreePlayFlowCoordinator sfpfc = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First();
            GameplaySetupViewController gsvc  = sfpfc.GetField <GameplaySetupViewController>("_gameplaySetupViewController");
            RectTransform container           = (RectTransform)gsvc.transform.Find(pageName).Find(panelName);

            gameObject       = UnityEngine.Object.Instantiate(Resources.FindObjectsOfTypeAll <GameplayModifierToggle>().Where(g => g.transform.Find("BG"))?.Last().gameObject, container);
            gameObject.name  = optionName;
            gameObject.layer = container.gameObject.layer;
            gameObject.transform.SetParent(container);
            gameObject.transform.localPosition = Vector3.zero;
            gameObject.transform.localScale    = Vector3.one;
            gameObject.transform.rotation      = Quaternion.identity;
            gameObject.SetActive(false);

            foreach (Transform t in container)
            {
                if (t.name.StartsWith("Separator"))
                {
                    separator      = UnityEngine.Object.Instantiate(t.gameObject, container);
                    separator.name = "ExtraSeparator";
                    separator.SetActive(false);
                    break;
                }
            }

            string ConflictText  = "\r\n\r\n<size=60%><color=#ff0000ff><b>Conflicts </b></color>";
            var    currentToggle = gameObject.GetComponent <GameplayModifierToggle>();

            if (currentToggle != null)
            {
                currentToggle.toggle.isOn = GetValue;
                currentToggle.toggle.onValueChanged.RemoveAllListeners();
                currentToggle.toggle.onValueChanged.AddListener((bool e) => OnToggle?.Invoke(e));
                currentToggle.name = optionName.Replace(" ", "");

                GameplayModifierToggle[] gameplayModifierToggles = Resources.FindObjectsOfTypeAll <GameplayModifierToggle>();

                if (conflicts.Count > 0)
                {
                    hintText += ConflictText;
                    foreach (string conflict in conflicts)
                    {
                        var conflictingModifier = gameplayModifierToggles.Where(t => t?.gameplayModifier?.modifierName == conflict).FirstOrDefault();
                        if (conflictingModifier)
                        {
                            if (!hintText.Contains(ConflictText))
                            {
                                hintText += ConflictText;
                            }

                            hintText += Char.ConvertFromUtf32((char)0xE069) + conflict + Char.ConvertFromUtf32((char)0xE069);
                        }
                    }
                }

                GameplayModifierParamsSO _gameplayModifier = new GameplayModifierParamsSO();
                _gameplayModifier.SetPrivateField("_modifierName", optionName);
                _gameplayModifier.SetPrivateField("_hintText", hintText);
                _gameplayModifier.SetPrivateField("_multiplier", multiplier);
                _gameplayModifier.SetPrivateField("_icon", optionIcon == null ? UIUtilities.BlankSprite : optionIcon);
                currentToggle.SetPrivateField("_gameplayModifier", _gameplayModifier);

                string currentDisplayName = Char.ConvertFromUtf32((char)0xE069) + optionName + Char.ConvertFromUtf32((char)0xE069);
                foreach (string conflictingModifierName in conflicts)
                {
                    GameplayModifierToggle conflictToggle = gameplayModifierToggles.Where(t => t?.gameplayModifier?.modifierName == conflictingModifierName).FirstOrDefault();
                    if (conflictToggle)
                    {
                        if (!conflictToggle.gameplayModifier.hintText.Contains(ConflictText))
                        {
                            conflictToggle.gameplayModifier.SetPrivateField("_hintText", conflictToggle.gameplayModifier.hintText + ConflictText);
                        }

                        if (!conflictToggle.gameplayModifier.hintText.Contains(currentDisplayName))
                        {
                            conflictToggle.gameplayModifier.SetPrivateField("_hintText", conflictToggle.gameplayModifier.hintText + currentDisplayName);
                        }

                        conflictToggle.toggle.onValueChanged.AddListener((e) => { if (e)
                                                                                  {
                                                                                      currentToggle.toggle.isOn = false;
                                                                                  }
                                                                         });
                        currentToggle.toggle.onValueChanged.AddListener((e) => { if (e)
                                                                                 {
                                                                                     conflictToggle.toggle.isOn = false;
                                                                                 }
                                                                        });
                    }
                }

                if (hintText != String.Empty)
                {
                    HoverHint hoverHint = currentToggle.GetPrivateField <HoverHint>("_hoverHint");
                    hoverHint.text = hintText;
                    hoverHint.name = optionName;
                    HoverHintController hoverHintController = Resources.FindObjectsOfTypeAll <HoverHintController>().First();
                    hoverHint.SetPrivateField("_hoverHintController", hoverHintController);
                }
            }
            initialized = true;
        }
Exemplo n.º 21
0
 public void OnResetAtkActionButton()
 {
     OnToggle.Invoke(false);
 }
 public void Set(bool descending)
 {
     SetWithoutNotify(descending);
     OnToggle?.Invoke(descending);
 }
 public override bool Toggle()
 {
     Value = _state;
     OnToggle?.Invoke(Value);
     return(Value);
 }
Exemplo n.º 24
0
        internal void ToggleNavMap(bool ignoreCursorLock = false)
        {
            if (MapRenderer.i == null)
            {
                return;
            }

            scrollRect.StopMovement();

            isOpen = !isOpen;
            scrollRect.gameObject.SetActive(isOpen);
            MapRenderer.i.parcelHighlightEnabled = isOpen;

            if (isOpen)
            {
                cursorLockedBeforeOpening = Utils.isCursorLocked;
                if (!ignoreCursorLock && cursorLockedBeforeOpening)
                {
                    Utils.UnlockCursor();
                }

                minimapViewport          = MapRenderer.i.atlas.viewport;
                mapRendererMinimapParent = MapRenderer.i.transform.parent;
                atlasOriginalPosition    = MapRenderer.i.atlas.chunksParent.transform.localPosition;

                MapRenderer.i.atlas.viewport = scrollRect.viewport;
                MapRenderer.i.transform.SetParent(scrollRectContentTransform);
                MapRenderer.i.atlas.UpdateCulling();

                scrollRect.content = MapRenderer.i.atlas.chunksParent.transform as RectTransform;

                // Reparent the player icon parent to scroll everything together
                MapRenderer.i.atlas.overlayLayerGameobject.transform.SetParent(scrollRect.content);

                // Center map
                MapRenderer.i.atlas.CenterToTile(Utils.WorldToGridPositionUnclamped(CommonScriptableObjects.playerWorldPosition));

                // Set shorter interval of time for populated scenes markers fetch
                MapRenderer.i.usersPositionMarkerController?.SetUpdateMode(MapGlobalUsersPositionMarkerController.UpdateMode.FOREGROUND);

                AudioScriptableObjects.dialogOpen.Play(true);

                CommonScriptableObjects.isFullscreenHUDOpen.Set(true);
            }
            else
            {
                if (!ignoreCursorLock && cursorLockedBeforeOpening)
                {
                    Utils.LockCursor();
                }

                toastView.OnCloseClick();

                MapRenderer.i.atlas.viewport = minimapViewport;
                MapRenderer.i.transform.SetParent(mapRendererMinimapParent);
                MapRenderer.i.atlas.chunksParent.transform.localPosition = atlasOriginalPosition;
                MapRenderer.i.atlas.UpdateCulling();

                // Restore the player icon to its original parent
                MapRenderer.i.atlas.overlayLayerGameobject.transform.SetParent(MapRenderer.i.atlas.chunksParent.transform.parent);
                (MapRenderer.i.atlas.overlayLayerGameobject.transform as RectTransform).anchoredPosition = Vector2.zero;

                MapRenderer.i.UpdateRendering(Utils.WorldToGridPositionUnclamped(CommonScriptableObjects.playerWorldPosition.Get()));

                // Set longer interval of time for populated scenes markers fetch
                MapRenderer.i.usersPositionMarkerController?.SetUpdateMode(MapGlobalUsersPositionMarkerController.UpdateMode.BACKGROUND);

                AudioScriptableObjects.dialogClose.Play(true);
                CommonScriptableObjects.isFullscreenHUDOpen.Set(false);
            }

            OnToggle?.Invoke(isOpen);
        }
Exemplo n.º 25
0
 public void Toggle()
 {
     Active = !Active;
     OnToggle?.Invoke();
 }
Exemplo n.º 26
0
        public override void Instantiate()
        {
            //We have to find our own target
            //TODO: Clean up time complexity issue. This is called for each new option
            StandardLevelDetailViewController _sldvc = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().First();
            GameplayOptionsViewController     _govc  = _sldvc.GetField <GameplayOptionsViewController>("_gameplayOptionsViewController");
            RectTransform container = (RectTransform)_govc.transform.Find("Switches").Find("Container");

            //TODO: Can probably slim this down a bit
            gameObject = UnityEngine.Object.Instantiate(container.Find("NoEnergy").gameObject, container);
            gameObject.GetComponentInChildren <TextMeshProUGUI>().text = optionName;
            gameObject.name                    = optionName;
            gameObject.layer                   = container.gameObject.layer;
            gameObject.transform.parent        = container;
            gameObject.transform.localPosition = Vector3.zero;
            gameObject.transform.localScale    = Vector3.one;
            gameObject.transform.rotation      = Quaternion.identity;
            gameObject.SetActive(false); //All options start disabled

            gameObject.GetComponentInChildren <HMUI.Toggle>().isOn            = GetValue;
            gameObject.GetComponentInChildren <HMUI.Toggle>().didSwitchEvent += (_, e) => { OnToggle?.Invoke(e); };
        }