Exemplo n.º 1
0
        protected override bool DrawSelf()
        {
            Player player = Main.LocalPlayer;

            // Don't draw if the player is dead or a ghost
            if (player.dead || player.ghost || !ClickerConfigClient.Instance.ShowCustomCursors)
            {
                return(true);
            }

            Item item = player.HeldItem;

            Texture2D borderTexture;
            Texture2D texture;

            if (CanDrawCursor(item))
            {
                string borderTexturePath = ClickerSystem.GetPathToBorderTexture(item.type);
                if (borderTexturePath != null)
                {
                    borderTexture = ModContent.GetTexture(borderTexturePath);
                }
                else
                {
                    //Default border
                    borderTexture = ClickerClass.mod.GetTexture("UI/CursorOutline");
                }
                texture = Main.itemTexture[item.type];
            }
            else
            {
                return(true);
            }

            Rectangle borderFrame  = borderTexture.Frame(1, 1);
            Vector2   borderOrigin = borderFrame.Size() / 2;

            Rectangle frame  = texture.Frame(1, 1);
            Vector2   origin = frame.Size() / 2;

            Vector2 borderPosition = Main.MouseScreen;
            // Actual cursor is not drawn in the top left of the border but a bit offset, have to add/substract origins here
            Vector2 position = Main.MouseScreen - origin + borderOrigin;

            Color color = Color.White;

            color.A = (byte)(_clickerAlpha * 255);

            // Draw cursor border
            Main.spriteBatch.Draw(borderTexture, borderPosition, borderFrame, Main.mouseBorderColorSlider.GetColor(), 0f, Vector2.Zero, _clickerScale, SpriteEffects.FlipHorizontally, 0f);
            // Actual cursor
            Main.spriteBatch.Draw(texture, position, frame, color, 0f, Vector2.Zero, _clickerScale, SpriteEffects.FlipHorizontally, 0f);

            return(true);
        }