Esempio n. 1
0
            public void Draw(SpriteBatch spriteBatch, Vector2 iconAnchorPositionOnScreen, Player targetPlayer)
            {
                Rectangle rectangle = Utils.CenteredRectangle(iconAnchorPositionOnScreen, new Vector2(14f, 14f));
                Point     value     = Main.MouseScreen.ToPoint();
                Texture2D value2    = Texture.Value;
                bool      num       = rectangle.Contains(value) && !PlayerInput.IgnoreMouseInterface;
                bool      flag      = _toggleStateProvider(targetPlayer);
                Color     color     = flag ? Color.White : Color.Gray;

                if (num && Main.mouseLeft && Main.mouseLeftRelease)
                {
                    _performClickMethod(targetPlayer);
                    SoundEngine.PlaySound(12);
                    Main.mouseLeftRelease = false;
                }

                Rectangle sourceRectangle = Frame.GetSourceRectangle(value2);

                if (!flag && FrameOverrideWhenOff.HasValue)
                {
                    sourceRectangle = FrameOverrideWhenOff.Value.GetSourceRectangle(value2);
                }

                spriteBatch.Draw(value2, iconAnchorPositionOnScreen, sourceRectangle, color, 0f, sourceRectangle.Size() / 2f, 1f, SpriteEffects.None, 0f);
                if (num)
                {
                    targetPlayer.mouseInterface = true;
                    string textValue = Language.GetTextValue(flag ? _hoverWhenEnabledKey : _hoverWhenDisabledKey);
                    Main.instance.MouseText(textValue, 0, 0);
                    Main.mouseText = true;
                    Texture2D value3     = HoverOutlineTexture.Value;
                    Rectangle rectangle2 = HoverOutlineFrame.HasValue ? HoverOutlineFrame.Value.GetSourceRectangle(value3) : value3.Frame();
                    spriteBatch.Draw(value3, iconAnchorPositionOnScreen, rectangle2, Main.OurFavoriteColor, 0f, rectangle2.Size() / 2f, 1f, SpriteEffects.None, 0f);
                }
            }
Esempio n. 2
0
        public MapOverlayDrawContext.DrawResult Draw(
            Texture2D texture,
            Vector2 position,
            Color color,
            SpriteFrame frame,
            float scaleIfNotSelected,
            float scaleIfSelected,
            Alignment alignment)
        {
            position = (position - this._mapPosition) * this._mapScale + this._mapOffset;
            if (this._clippingRect.HasValue && !this._clippingRect.Value.Contains(position.ToPoint()))
            {
                return(MapOverlayDrawContext.DrawResult.Culled);
            }
            Rectangle sourceRectangle = frame.GetSourceRectangle(texture);
            Vector2   origin          = sourceRectangle.Size() * alignment.OffsetMultiplier;
            Vector2   position1       = position;
            float     num1            = this._drawScale * scaleIfNotSelected;
            Vector2   vector2         = position - origin * num1;
            int       num2            = new Rectangle((int)vector2.X, (int)vector2.Y, (int)((double)sourceRectangle.Width * (double)num1), (int)((double)sourceRectangle.Height * (double)num1)).Contains(Main.MouseScreen.ToPoint()) ? 1 : 0;
            float     scale           = num1;

            if (num2 != 0)
            {
                scale = this._drawScale * scaleIfSelected;
            }
            Main.spriteBatch.Draw(texture, position1, new Rectangle?(sourceRectangle), color, 0.0f, origin, scale, SpriteEffects.None, 0.0f);
            return(new MapOverlayDrawContext.DrawResult(num2 != 0));
        }
Esempio n. 3
0
            public void Draw(SpriteBatch spriteBatch, Vector2 iconAnchorPositionOnScreen, Player targetPlayer)
            {
                Rectangle       rectangle       = Utils.CenteredRectangle(iconAnchorPositionOnScreen, new Vector2(14f, 14f));
                Point           value           = Main.MouseScreen.ToPoint();
                Texture2D       value2          = Texture.get_Value();
                bool            flag            = rectangle.Contains(value) && !PlayerInput.IgnoreMouseInterface;
                WireToggleState wireToggleState = _stateProvider(targetPlayer);
                Color           color           = Color.White;

                switch (wireToggleState)
                {
                case WireToggleState.Bright:
                    color = Color.White;
                    break;

                case WireToggleState.Normal:
                    color = Color.Gray;
                    break;

                case WireToggleState.Faded:
                    color = Color.Gray * 0.66f;
                    break;
                }
                if (flag)
                {
                    targetPlayer.mouseInterface = true;
                    string arg = "";
                    switch (wireToggleState)
                    {
                    case WireToggleState.Bright:
                        arg = Language.GetTextValue("GameUI.Bright");
                        break;

                    case WireToggleState.Normal:
                        arg = Language.GetTextValue("GameUI.Normal");
                        break;

                    case WireToggleState.Faded:
                        arg = Language.GetTextValue("GameUI.Faded");
                        break;
                    }
                    string cursorText = $"{Language.GetTextValue(_nameKey)}: {arg}";
                    Main.instance.MouseText(cursorText, 0, 0);
                    Main.mouseText = true;
                    Texture2D value3 = TextureAssets.InfoIcon[13].get_Value();
                    spriteBatch.Draw(value3, iconAnchorPositionOnScreen, null, Main.OurFavoriteColor, 0f, value3.Size() / 2f, 1f, SpriteEffects.None, 0f);
                }
                if (flag && Main.mouseLeft && Main.mouseLeftRelease)
                {
                    _performClickMethod(targetPlayer);
                    SoundEngine.PlaySound(12);
                    Main.mouseLeftRelease = false;
                }
                Rectangle sourceRectangle = Frame.GetSourceRectangle(value2);

                spriteBatch.Draw(value2, iconAnchorPositionOnScreen, sourceRectangle, color, 0f, sourceRectangle.Size() / 2f, 1f, SpriteEffects.None, 0f);
            }
Esempio n. 4
0
        public DrawResult Draw(Texture2D texture, Vector2 position, SpriteFrame frame, Alignment alignment)
        {
            position = (position - _mapPosition) * _mapScale + _mapOffset;
            if (_clippingRect.HasValue && !_clippingRect.Value.Contains(position.ToPoint()))
            {
                return(DrawResult.Culled);
            }
            Rectangle sourceRectangle = frame.GetSourceRectangle(texture);
            Vector2   vector          = sourceRectangle.Size() * alignment.OffsetMultiplier;

            Main.spriteBatch.Draw(texture, position, sourceRectangle, Color.White, 0f, vector, _drawScale, SpriteEffects.None, 0f);
            position -= vector * _drawScale;
            return(new DrawResult(new Rectangle((int)position.X, (int)position.Y, (int)((float)texture.Width * _drawScale), (int)((float)texture.Height * _drawScale)).Contains(Main.MouseScreen.ToPoint())));
        }
Esempio n. 5
0
        public MapOverlayDrawContext.DrawResult Draw(
            Texture2D texture,
            Vector2 position,
            SpriteFrame frame,
            Alignment alignment)
        {
            position = (position - this._mapPosition) * this._mapScale + this._mapOffset;
            if (this._clippingRect.HasValue && !this._clippingRect.Value.Contains(position.ToPoint()))
            {
                return(MapOverlayDrawContext.DrawResult.Culled);
            }
            Rectangle sourceRectangle = frame.GetSourceRectangle(texture);
            Vector2   origin          = sourceRectangle.Size() * alignment.OffsetMultiplier;

            Main.spriteBatch.Draw(texture, position, new Rectangle?(sourceRectangle), Color.White, 0.0f, origin, this._drawScale, SpriteEffects.None, 0.0f);
            position -= origin * this._drawScale;
            return(new MapOverlayDrawContext.DrawResult(new Rectangle((int)position.X, (int)position.Y, (int)((double)texture.Width * (double)this._drawScale), (int)((double)texture.Height * (double)this._drawScale)).Contains(Main.MouseScreen.ToPoint())));
        }
Esempio n. 6
0
        public DrawResult Draw(Texture2D texture, Vector2 position, Color color, SpriteFrame frame, float scaleIfNotSelected, float scaleIfSelected, Alignment alignment)
        {
            position = (position - _mapPosition) * _mapScale + _mapOffset;
            if (_clippingRect.HasValue && !_clippingRect.Value.Contains(position.ToPoint()))
            {
                return(DrawResult.Culled);
            }
            Rectangle sourceRectangle = frame.GetSourceRectangle(texture);
            Vector2   vector          = sourceRectangle.Size() * alignment.OffsetMultiplier;
            Vector2   position2       = position;
            float     num             = _drawScale * scaleIfNotSelected;
            Vector2   vector2         = position - vector * num;
            bool      num2            = new Rectangle((int)vector2.X, (int)vector2.Y, (int)((float)sourceRectangle.Width * num), (int)((float)sourceRectangle.Height * num)).Contains(Main.MouseScreen.ToPoint());
            float     scale           = num;

            if (num2)
            {
                scale = _drawScale * scaleIfSelected;
            }
            Main.spriteBatch.Draw(texture, position2, sourceRectangle, color, 0f, vector, scale, SpriteEffects.None, 0f);
            return(new DrawResult(num2));
        }