Exemplo n.º 1
0
        private void OnFavouriteCheckboxMouseUp(UIComponent component, UIMouseEventParameter eventParam)
        {
            switch (eventParam.buttons)
            {
            case UIMouseButton.Right: {
                bool blackListed = !_itemData.IsBlacklisted;
                _itemData.IsBlacklisted = blackListed;
                if (blackListed)
                {
                    _favouriteCheckbox.isChecked = true;
                    _checkedSprite.spriteName    = UISprites.Blacklisted;
                    _uncheckedSprite.spriteName  = "";
                    if (_itemData.IsFavourite)
                    {
                        _itemData.IsFavourite = false;
                        EventFavouriteChanged?.Invoke(_itemData.ID, false);
                    }
                }
                else
                {
                    if (!_itemData.IsFavourite)
                    {
                        _favouriteCheckbox.isChecked = false;
                    }
                    _uncheckedSprite.spriteName = UISprites.StarOutline;
                }
                EventBlacklistedChanged?.Invoke(_itemData.ID, blackListed);
                break;
            }

            case UIMouseButton.Left: {
                bool favourite = !_itemData.IsFavourite;
                _itemData.IsFavourite = favourite;
                if (favourite)
                {
                    _favouriteCheckbox.isChecked = true;
                    _checkedSprite.spriteName    = UISprites.Star;
                    _uncheckedSprite.spriteName  = UISprites.StarOutline;
                    if (_itemData.IsBlacklisted)
                    {
                        _itemData.IsBlacklisted = false;
                        EventBlacklistedChanged?.Invoke(_itemData.ID, false);
                    }
                }
                else
                {
                    if (!_itemData.IsBlacklisted)
                    {
                        _favouriteCheckbox.isChecked = false;
                    }
                }
                EventFavouriteChanged?.Invoke(_itemData.ID, favourite);
                break;
            }
            }

            UpdateCheckboxTooltip();
        }
Exemplo n.º 2
0
 private void OnFavouriteCheckboxMouseUp(UIComponent component, UIMouseEventParameter eventParam)
 {
     if (eventParam.buttons == UIMouseButton.Right)
     {
         if (itemData.IsDefault)
         {
             return;
         }
         bool blackListed = !itemData.IsBlacklisted;
         itemData.IsBlacklisted = blackListed;
         if (blackListed)
         {
             favouriteCheckbox.isChecked = true;
             checkedSprite.spriteName    = Resources.Blacklisted;
             uncheckedSprite.spriteName  = "";
             if (itemData.IsFavourite)
             {
                 itemData.IsFavourite = false;
                 EventFavouriteChanged?.Invoke(itemData.ID, false);
             }
         }
         else
         {
             if (!itemData.IsFavourite)
             {
                 favouriteCheckbox.isChecked = false;
             }
             uncheckedSprite.spriteName = Resources.StarOutline;
         }
         EventBlacklistedChanged?.Invoke(itemData.ID, blackListed);
     }
     else if (eventParam.buttons == UIMouseButton.Left)
     {
         bool favourite = !itemData.IsFavourite;
         itemData.IsFavourite = favourite;
         if (favourite)
         {
             favouriteCheckbox.isChecked = true;
             checkedSprite.spriteName    = Resources.Star;
             uncheckedSprite.spriteName  = Resources.StarOutline;
             if (itemData.IsBlacklisted)
             {
                 itemData.IsBlacklisted = false;
                 EventBlacklistedChanged?.Invoke(itemData.ID, false);
             }
         }
         else
         {
             if (!itemData.IsBlacklisted)
             {
                 favouriteCheckbox.isChecked = false;
             }
         }
         EventFavouriteChanged?.Invoke(itemData.ID, favourite);
     }
     UpdateCheckboxTooltip();
 }