XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

DeathMod

【Terraria】DeathMod (now aka Soul Harvest)

公开
关注 0 Fork 0 Star 0
UTF-8
using SoulHarvest.Common;
using SoulHarvest.Items;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using System;
using System.Collections.Generic;
using System.Text;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.GameContent.UI.Elements;
using Terraria.GameInput;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.UI;

namespace SoulHarvest.UI;

internal sealed class ReaperTreeViewportOverlay : UIElement
{
    private readonly ReaperTreeViewport viewport;

    public ReaperTreeViewportOverlay(ReaperTreeViewport viewport)
    {
        this.viewport = viewport;
        SetPadding(0f);
    }

    protected override void DrawSelf(SpriteBatch spriteBatch)
    {
        Rectangle bounds = GetDimensions().ToRectangle();
        Texture2D pixel = TextureAssets.MagicPixel.Value;
        float scale = viewport.LayoutScale;
        int stripHeight = Math.Max(15, (int)MathF.Round(27f * scale));
        Rectangle hintStrip = new(bounds.X + 2, bounds.Bottom - stripHeight - 2, Math.Max(1, bounds.Width - 4), stripHeight);
        spriteBatch.Draw(pixel, hintStrip, new Color(7, 8, 10) * 0.82f);
        string hint = Language.GetTextValue("Mods.SoulHarvest.UI.ReaperTree.PanHint");
        float textScale = 0.48f * scale;
        string fittedHint = AltarDrawHelpers.FitText(hint, Math.Max(8f, bounds.Width - 20f * scale), textScale);
        Utils.DrawBorderString(spriteBatch, fittedHint, new Vector2(bounds.X + 10f * scale, bounds.Bottom - 22f * scale), new Color(156, 147, 138), textScale);
        ReaperTreeDraw.DrawBorder(spriteBatch, pixel, bounds, new Color(71, 63, 61), Math.Max(1, (int)(2f * scale)));
        ReaperTreeDraw.DrawInsetBorder(spriteBatch, pixel, bounds, Math.Max(2, (int)(5f * scale)), new Color(124, 39, 47) * 0.5f, 1);
    }
}