示例#1
0
文件: Widget.cs 项目: vfrz/OtterUI
 /// <summary>
 /// Call this to manually simulate a click on a widget from within your code.
 /// </summary>
 public void Click()
 {
     hasClicked   = true;
     clickCounter = 0;
     isActive     = true;
     OnClickEvent.Invoke(this, null);
 }
示例#2
0
        public void Update(GameTime gameTime)
        {
            MouseState newMouseState = Mouse.GetState();

            if (Rect.Contains(newMouseState.X, newMouseState.Y))
            {
                ButtonMode = "hover";

                if (!hover)
                {
                    SndHover.Play();
                }

                hover = true;

                if (newMouseState.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Released)
                {
                    ButtonMode = "click";
                    OnClickEvent?.Invoke();
                }
            }
            else
            {
                hover      = false;
                ButtonMode = "normal";
            }

            oldMouseState = newMouseState;
        }
        public LLEGUIElement(Vector2 position, Texture2D texture, SpriteFont spriteFont, string label, OnClickEvent clickEvent)
            : base(position, texture)
        {
            mIsIconVisible = true;

            mSelected = mDisabled = false;

            if (clickEvent != null)
            {
                onClickEvent = clickEvent;
            }

            mSpriteFont = spriteFont;

            mLabel = label;

            mInitialX = getX();

            mInitialY = getY();

            mRenderBorder = false;

            mIsLabelVisible = true;

            mBorderColor = Color.Black;
        }
示例#4
0
        private void AddButton(String text, OnClickEvent lambda)
        {
            UIMenuItem item = new UIMenuItem(text);

            this.delegates.Add(item, lambda);
            menu.AddItem(item);
        }
        protected override void Awake()
        {
            Interactable = Button.interactable;

            button.onClick.AddListener(() =>
            {
                if (isShowRewardVideo)
                {
                    return;
                }
                isShowRewardVideo = true;
                MyAdManager.Instance.ShowRewardVideo(key, () =>
                {
                    isShowRewardVideo = false;
                    if (OnClickEvent != null)
                    {
                        OnClickEvent.Invoke();
                    }
                }, () =>
                {
                    isShowRewardVideo = false;
                    OnFailed.SafeInvoke();
                });
            });

            scaleCurve = MyAnimationCurves.Instance.GetAnimationCurve(MyAnimationCurveType.Notification);
        }
示例#6
0
        /// <summary>
        /// Получает данные о щелчке мыши и обрабатывает их
        /// </summary>
        /// <param name="Click">Параметры щелчка мыши</param>
        internal void OnClick(MouseClick Click)
        {
            switch (Click)
            {
            case MouseClick.LeftButton:

                if (locked)
                {
                    return;
                }

                changies = ChangiesStatus(Click);

                Blocked = !Blocked;

                BlockSwitch();

                break;

            case MouseClick.RightButton:

                changies = ChangiesStatus(Click);

                Marked = !Marked;

                MarkSwitch();

                break;
            }

            OnClickEvent?.Invoke(this, changies);
        }
示例#7
0
        public LLECheckBox(Vector2 position, Texture2D bgTexture, bool check, OnClickEvent clickEvent)
            : base(position, bgTexture, null, "X", clickEvent)
        {
            mChecked = check;

            mSpriteFontColor = Color.White;
        }
示例#8
0
        public void ClickDown(object sender, MouseButtonEventArgs e)
        {
            if (e == null || e.LeftButton == MouseButtonState.Pressed)
            {
                if (CheckLicense && Client.License == null)
                {
                    // Common.ShowToast("需要先授权才能执行本操作", Color.FromRgb(255, 36, 50), "off");
                    return;
                }


                foreach (var myTabItem in ItemList)
                {
                    myTabItem.IsSelected          = Equals(myTabItem, this);
                    myTabItem.MyCanvas.Background = myTabItem.IsSelected
                        ? FindResource("BlueLine") as SolidColorBrush
                        : new SolidColorBrush(Colors.Transparent);
                }

                if (IsSelected)
                {
                    OnClickEvent?.Invoke(this, PageName, IsDarkStyle);
                }
            }
        }
示例#9
0
 public Button(TextureMap tex, Vector2 pos, OnClickEvent evt)
 {
     Position = pos;
     OnClick = evt;
     Texture = tex;
     width = tex.width;
     height = tex.height;
 }
        public async Task LoadMoreBlogs()
        {
            Console.WriteLine("Fetching more blogs");
            await OnClickEvent.InvokeAsync(this); // trigger eventcallback passing object if needed using <T>

            // This then triggers OnAfterRenderAsync method to be invoked;
            GetBlogsByCategory();
        }
示例#11
0
        private void Click()
        {
            if (OnClickEvent == null)
            {
                return;
            }

            OnClickEvent.Invoke(_type);
        }
示例#12
0
        /// <summary>
        /// Creates a new instance
        /// </summary>
        /// <param name="grid">Grid for the playstones ellipeses</param>
        /// <param name="ellipsEvent">Event to assing to the ellipeses</param>
        public UiHelpFunctions(Grid grid, OnClickEvent ellipsEvent)
        {
            CoordinatesX = new double[7, 7];
            CoordinatesY = new double[7, 7];
            InitializeCoordinates();

            _workGrid = grid;
            _ellipsEvent = ellipsEvent;
        }
示例#13
0
    protected virtual void SetWidgetClick()
    {
        OnClickEvent handler = OnWidgetClick;

        if (handler != null)
        {
            handler(this);
        }
    }
示例#14
0
        public LLEButton(Vector2 position, Texture2D texture, Texture2D iconImg, OnClickEvent clickEvent)
            : base(position, texture, null, "", clickEvent)
        {
            mTextOnly = false;

            mIcon = iconImg;

            setDefaultColors();
        }
示例#15
0
 public virtual T OnClickFunc(IPlayContext context = null)
 {
     OnClickEvent?.Invoke();
     if (ClickFuncReturn != null)
     {
         return(ClickFuncReturn.Invoke(context));
     }
     return(default(T));
 }
示例#16
0
    public void ProcessClick(Vector3 clickPos)
    {
        if (OnClickEvent != null)
        {
            OnClickEvent(clickPos);
        }

        print(string.Format("GC: OnClickEvent triggered {0} event call(s)", OnClickEvent.GetInvocationList().Length));
    }
示例#17
0
    private void Awake()
    {
        m_ts = transform;

        if (clickEvent == null)
        {
            clickEvent = new OnClickEvent();
        }
    }
示例#18
0
 protected override void OnDisable()
 {
     base.OnDisable();
     OnClickEvent.RemoveListener(ExecuteOption);
     UIIDHolder.Panels[UIIDHolder.QAPanel].OnHidePanel.RemoveListener(HidePanel);
     if (Managers.Instance == null)
     {
         return;
     }
 }
示例#19
0
        public LLEButton(Vector2 position, Texture2D texture, SpriteFont spriteFont, 
            string label, bool isTextOnly, OnClickEvent clickEvent)
            : base(position, texture, spriteFont, label, clickEvent)
        {
            mTextOnly = isTextOnly;

            mIcon = null;

            setDefaultColors();
        }
    public void AddItem(String label, OnClickEvent onClickEvent)
    {
        ListItemInformationGroup newItem = new ListItemInformationGroup();

        newItem.label = label;
        if (onClickEvent != null)
        {
            newItem.onClick.AddListener(delegate() { onClickEvent(); });
        }
        listItems.Add(newItem);
    }
示例#21
0
    // Start is called before the first frame update
    void Start()
    {
        agent           = GetComponent <UnityEngine.AI.NavMeshAgent>();
        NavigatorScript = Navigator.GetComponent <OnClickEvent>();
        Target          = Navigator;
        if (Navigator == null)
        {
            throw new InvalidOperationException("You Did not set proper script reference (also can be done by injecting OnClickEvent script to student)");
        }



        isDoneMoving = false;
    }
示例#22
0
 public void ClearClickEvent()
 {
     if (OnClickEvent != null)
     {
         Delegate[] invokeList = OnClickEvent.GetInvocationList();
         if (invokeList != null)
         {
             foreach (Delegate del in invokeList)
             {
                 OnClickEvent -= (OnClickDlg)del;
             }
         }
     }
 }
示例#23
0
    private void OnEnemyClick(OnClickEvent <Unit> param)
    {
        var enemyUnit = param.OnClickObject;

        if (enemyUnit.IsEnemy && qUnit.SelectedUnit.IsEnemy)
        {
            Debug.Log("сам себя бить пытается");
            return;
        }

        if (enemyUnit.IsEnemy && qUnit.SelectedUnit.AttackableHexes.Contains(enemyUnit.CurrentHex))
        {
            enemyUnit.GetDamage(qUnit.SelectedUnit);
        }
    }
示例#24
0
 private void OnReceiveClick(Client sender, string eventName, params object[] arguments)
 {
     if (eventName.Equals("onClientClick"))
     {
         NetHandle handle = (NetHandle)arguments[0];
         OnClickEvent?.Invoke(sender, handle);
     }
     if (eventName.Equals("onClientClickWorld"))
     {
         Dictionary <string, dynamic> obj = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >((string)arguments[0]);
         OnClickWorldEvent?.Invoke(sender, new WorldObject(
                                       new Vector3((float)obj.Get("positionX"), (float)obj.Get("positionY"), (float)obj.Get("positionZ")),
                                       (int)obj.Get("hash")
                                       ));
     }
 }
示例#25
0
    private void OnHexClick(OnClickEvent <Hex> param)
    {
        var hex = param.OnClickObject;

        if (hex.isWalkable && qUnit.SelectedUnit.ReachableHexes.Contains(hex))
        {
            var currentPath = Pathfinding.Instance.GeneratePathTo(qUnit.SelectedUnit.CurrentHex, hex);

            qUnit.SelectedUnit.Move(currentPath);

            qUnit.SelectedUnit.CurrentHex.isWalkable   = true;
            qUnit.SelectedUnit.CurrentHex.render.color = Color.white;

            qUnit.SelectedUnit.CurrentHex = hex;

            qUnit.SelectedUnit.CurrentHex.isWalkable   = false;
            qUnit.SelectedUnit.CurrentHex.render.color = Color.black;
        }
    }
示例#26
0
        public void InitButton(
            ref UIButton button,
            ref UIPanel icon,
            string name,
            string pattern,
            Texture2D iconTexture,
            OnClickEvent onClick = null,
            UIElement parent     = null,
            bool pressable       = false,
            bool movable         = false,
            bool show            = true)
        {
            if (string.IsNullOrEmpty(pattern) || pattern.Length != 2)
            {
                return;
            }

            int x    = Convert.ToInt32(pattern[0].ToString());
            int y    = Convert.ToInt32(pattern[1].ToString());
            int posX = (parent != null ? 0 : transform.X) + btnDim * x;
            int posY = (parent != null ? 0 : transform.Y) + btnDim * y;

            button = new UIButton(name, new Rectangle(posX, posY, btnDim, btnDim), parent, AssetsManager.defaultTexture);
            if (show)
            {
                button.Show();
            }
            if (pressable)
            {
                button.canBePressed = true;
            }
            if (movable)
            {
                button.canBeMoved = true;
            }
            icon       = (UIPanel) new UIPanel(name + "_Icon", iconRect, button, iconTexture).Show();
            icon.color = Color.White;
            if (onClick != null)
            {
                button.onClick += onClick;
            }
        }
示例#27
0
        public override void Update()
        {
            UpdateState();

            if (_isPressed)
            {
                Sprite.Color = ClickedColor;
                if (!_isPressedLastFrame)
                {
                    OnClickEvent?.Invoke();
                }
            }
            else if (_isHovered)
            {
                Sprite.Color = HoveredColor;
            }
            else
            {
                Sprite.Color = ButtonColor;
            }
        }
示例#28
0
        public LLETextBox(Vector2 position, Texture2D bgTexture, Texture2D cursorImg, String text, SpriteFont font, 
                          int maxLength, OnClickEvent clickEvent)
            : base(position, bgTexture, font, "", clickEvent)
        {
            mCursorImg = cursorImg;

            mText = (string)text.Clone();

            mMaxLength = maxLength;

            setFontColors(Color.Black, Color.Black, Color.Gray);

            setColors(Color.DarkGray, Color.LightGray, Color.Gray);

            mIndex = -1;

            mHasFocus = false;

            mCursorColor = Color.Black;

            adjustCursor();
        }
示例#29
0
        internal override void OnUpdate()
        {
            Vector2f mousePosition = Input.TackInput.MousePosition();

            if (mousePosition.X >= Bounds.X && mousePosition.X <= (Bounds.X + Bounds.Width))
            {
                if (mousePosition.Y >= Bounds.Y && mousePosition.Y <= (Bounds.Y + Bounds.Height))
                {
                    m_hovering = true;

                    if (TackInput.MouseButtonDown(MouseButtonKey.Left))
                    {
                        m_pressing = true;

                        if (OnClickEvent != null)
                        {
                            if (OnClickEvent.GetInvocationList().Length > 0)
                            {
                                OnClickEvent.Invoke(this, EventArgs.Empty);
                            }
                        }
                    }
                }
                else
                {
                    m_hovering = false;
                }
            }
            else
            {
                m_hovering = false;
            }

            if (TackInput.MouseButtonUp(MouseButtonKey.Left))
            {
                m_pressing = false;
            }
        }
示例#30
0
        /// <summary>
        /// Generates an ellipse
        /// </summary>
        /// <param name="left">x coordinate</param>
        /// <param name="top">y coordinate</param>
        /// <param name="playstoneState">State of the palystone</param>
        /// <param name="clickEvent">Event to assign to the ellipse</param>
        /// <returns></returns>
        private Ellipse GenerateEllipse(double left, double top, PlaystoneState playstoneState, OnClickEvent clickEvent)
        {
            double radiusToUse = 0;
            Ellipse ellipse = new Ellipse
            {
                VerticalAlignment = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            #region get radius for ellipse
            switch (playstoneState)
            {
                case PlaystoneState.Neutral:
                    radiusToUse = nonselectablePlaystoneRadius;
                    break;
                case PlaystoneState.Player1:
                case PlaystoneState.Player2:
                case PlaystoneState.Selectable:
                    radiusToUse = selectablePlaystoneRadius;
                    break;
                default:
                    radiusToUse = 0;
                    break;
            }
            ellipse.Width = radiusToUse;
            ellipse.Height = radiusToUse;
            #endregion

            #region set color
            switch (playstoneState)
            {
                case PlaystoneState.Player1:
                    ellipse.Fill = Brushes.Crimson;
                    break;
                case PlaystoneState.Player2:
                    ellipse.Fill = Brushes.DarkCyan;
                    break;
                case PlaystoneState.Selectable:
                    ellipse.Fill = Brushes.Gray;
                    break;
                default:
                    ellipse.Fill = Brushes.Black;
                    break;
            }
            #endregion

            #region assign event
            switch (playstoneState)
            {
                case PlaystoneState.Player1:
                case PlaystoneState.Player2:
                case PlaystoneState.Selectable:
                    ellipse.MouseDown +=
                        new MouseButtonEventHandler(clickEvent);
                    break;
                default:
                    break;
            }
            #endregion

            #region set coordinates
            Thickness margin = new Thickness()
            {
                Left = (left + radiusToUse / 2) - radiusToUse,
                Top = (top + radiusToUse / 2) - radiusToUse
            };
            ellipse.Margin = margin;
            #endregion

            return ellipse;
        }
示例#31
0
 public virtual void OnClick()
 {
     OnClickEvent?.Invoke(this);
 }
示例#32
0
 public virtual void OnClick()
 {
     gameObject.OnClick();
     OnClickEvent?.Invoke(this, null);
 }
示例#33
0
 protected virtual void ClickEvent(EventArgs e)
 {
     OnClickEvent?.Invoke(this, e);
 }
示例#34
0
 public void OnPointerClick(PointerEventData eventData)
 {
     OnClickEvent?.Invoke();
 }
示例#35
0
 public void OnMouseClickHandler()
 {
     OnClickEvent?.Invoke(this);
 }
示例#36
0
 // 逻辑注册
 public void RegisterClickEvent(OnClickEvent click)
 {
     m_onClickBtn = click;
 }
示例#37
0
 public async Task GetSelectedBlog()
 {
     Console.WriteLine("BlogBase Selected");
     this.Trim = false;
     await OnClickEvent.InvokeAsync(this);
 }
 private void Grid_MouseUp(object sender, MouseButtonEventArgs e)
 {
     OnClickEvent?.Invoke();
 }