Ejemplo n.º 1
0
        protected override void UpdateInternal(TimeSpan delta, bool updateInput)
        {
            base.UpdateInternal(delta, updateInput);
            if (Texts.Count > 0 && !Enabled)
            {
                Texts[0].Text          = Button.Text;
                Texts[0].ColorOverride = Color4.Gray;
            }
            if ((Animation != null && Animation.Running) || !Enabled)
            {
                return;
            }

            var h   = Scene.GHeight * Style.Size.Height;
            var w   = h * Style.Size.Ratio;
            var pos = CalculatePosition();
            var r   = new Rectangle((int)pos.X, (int)pos.Y, (int)w, (int)h);

            hoverStyle.Reset();
            if (updateInput && r.Contains(Scene.MouseX, Scene.MouseY))
            {
                if (!lastInside)
                {
                    if (!string.IsNullOrEmpty(Button.OnEnter))
                    {
                        Scene.Call(Button.OnEnter);
                    }
                }
                lastInside = true;
                if (!lastDown && Scene.MouseDown(MouseButtons.Left))
                {
                    if (!string.IsNullOrEmpty(Button.OnClick))
                    {
                        Scene.Call(Button.OnClick);
                    }
                }
                if (hoverChunk != null)
                {
                    LuaStyleEnvironment.Do(hoverChunk, hoverStyle, (float)Scene.Manager.Game.TotalTime);
                }
            }
            else
            {
                lastInside = false;
            }
            modelColor  = hoverStyle.ModelColor;
            modelRotate = hoverStyle.Rotation;
            if (Enabled && Texts.Count > 0 && hoverStyle.TextColor != null)
            {
                Texts[0].ColorOverride = hoverStyle.TextColor;
            }
            else if (Enabled && Texts.Count > 0)
            {
                Texts[0].ColorOverride = null;
            }
            lastDown = Scene.MouseDown(MouseButtons.Left);
        }
Ejemplo n.º 2
0
        protected override void UpdateInternal(TimeSpan delta)
        {
            base.UpdateInternal(delta);
            if (Texts.Count > 0 && !Enabled)
            {
                Texts[0].Text          = Button.Text;
                Texts[0].ColorOverride = Color4.Gray;
            }
            if ((Animation != null && Animation.Running) || !Enabled)
            {
                return;
            }

            var h   = Manager.Game.Height * Style.Size.Height;
            var w   = h * Style.Size.Ratio;
            var pos = CalculatePosition();
            var r   = new Rectangle((int)pos.X, (int)pos.Y, (int)w, (int)h);

            hoverStyle.Reset();
            if (r.Contains(Manager.Game.Mouse.X, Manager.Game.Mouse.Y))
            {
                if (!lastDown && Manager.Game.Mouse.IsButtonDown(MouseButtons.Left))
                {
                    if (!string.IsNullOrEmpty(Button.OnClick))
                    {
                        Manager.Call(Button.OnClick);
                    }
                }
                if (hoverChunk != null)
                {
                    LuaStyleEnvironment.Do(hoverChunk, hoverStyle, (float)Manager.Game.TotalTime);
                }
            }
            modelColor  = hoverStyle.ModelColor;
            modelRotate = hoverStyle.Rotation;
            lastDown    = Manager.Game.Mouse.IsButtonDown(MouseButtons.Left);
            if (Texts.Count > 0)
            {
                Texts[0].Text          = Button.Text;
                Texts[0].ColorOverride = hoverStyle.TextColor;
            }
        }