using SoulHarvest.Common;
using SoulHarvest.Items;
using SoulHarvest.Tiles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.GameContent.UI.Elements;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.UI;
namespace SoulHarvest.UI;
internal sealed class DeathAltarFramePanel : UIPanel
{
public float LayoutScale { get; set; } = 1f;
public float SidebarDividerX { get; set; } = 218f;
protected override void DrawSelf(SpriteBatch spriteBatch)
{
base.DrawSelf(spriteBatch);
Rectangle bounds = GetDimensions().ToRectangle();
Texture2D pixel = TextureAssets.MagicPixel.Value;
int firstInset = Math.Max(1, (int)MathF.Round(3f * LayoutScale));
int secondInset = Math.Max(firstInset + 1, (int)MathF.Round(7f * LayoutScale));
int thirdInset = Math.Max(secondInset + 1, (int)MathF.Round(10f * LayoutScale));
DrawInsetBorder(spriteBatch, pixel, bounds, firstInset, new Color(38, 31, 33), Math.Max(1, (int)MathF.Round(3f * LayoutScale)));
DrawInsetBorder(spriteBatch, pixel, bounds, secondInset, new Color(139, 43, 52) * 0.78f, Math.Max(1, (int)MathF.Round(2f * LayoutScale)));
DrawInsetBorder(spriteBatch, pixel, bounds, thirdInset, new Color(184, 116, 102) * 0.28f, 1);
int horizontalMargin = Math.Max(6, (int)MathF.Round(14f * LayoutScale));
int headerY = bounds.Y + Math.Max(1, (int)MathF.Round(36f * LayoutScale));
spriteBatch.Draw(pixel, new Rectangle(bounds.X + horizontalMargin, headerY, Math.Max(1, bounds.Width - horizontalMargin * 2), Math.Max(1, (int)MathF.Round(2f * LayoutScale))), new Color(127, 43, 49) * 0.72f);
int dividerX = bounds.X + (int)MathF.Round(SidebarDividerX);
int dividerTop = bounds.Y + (int)MathF.Round(45f * LayoutScale);
int dividerBottomMargin = (int)MathF.Round(18f * LayoutScale);
spriteBatch.Draw(pixel, new Rectangle(dividerX, dividerTop, Math.Max(1, (int)MathF.Round(2f * LayoutScale)), Math.Max(1, bounds.Bottom - dividerBottomMargin - dividerTop)), new Color(152, 52, 58) * 0.42f);
float pulse = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2.3f) * 0.15f + 0.85f;
DrawDiamond(spriteBatch, pixel, new Vector2(bounds.Center.X - 270f * LayoutScale, bounds.Y + 18f * LayoutScale), 6f * LayoutScale, new Color(186, 50, 61) * pulse);
DrawDiamond(spriteBatch, pixel, new Vector2(bounds.Center.X + 270f * LayoutScale, bounds.Y + 18f * LayoutScale), 6f * LayoutScale, new Color(184, 129, 105) * pulse);
}
private static void DrawInsetBorder(SpriteBatch batch, Texture2D pixel, Rectangle bounds, int inset, Color color, int thickness)
{
batch.Draw(pixel, new Rectangle(bounds.Left + inset, bounds.Top + inset, bounds.Width - inset * 2, thickness), color);
batch.Draw(pixel, new Rectangle(bounds.Left + inset, bounds.Bottom - inset - thickness, bounds.Width - inset * 2, thickness), color);
batch.Draw(pixel, new Rectangle(bounds.Left + inset, bounds.Top + inset, thickness, bounds.Height - inset * 2), color);
batch.Draw(pixel, new Rectangle(bounds.Right - inset - thickness, bounds.Top + inset, thickness, bounds.Height - inset * 2), color);
}
private static void DrawDiamond(SpriteBatch batch, Texture2D pixel, Vector2 center, float size, Color color)
{
batch.Draw(pixel, center, null, color, MathHelper.PiOver4, pixel.Size() * 0.5f,
new Vector2(size / pixel.Width, size / pixel.Height), SpriteEffects.None, 0f);
}
}
using SoulHarvest.Common;
using SoulHarvest.Items;
using SoulHarvest.Tiles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.GameContent.UI.Elements;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.UI;
namespace SoulHarvest.UI;
internal sealed class DeathAltarFramePanel : UIPanel
{
public float LayoutScale { get; set; } = 1f;
public float SidebarDividerX { get; set; } = 218f;
protected override void DrawSelf(SpriteBatch spriteBatch)
{
base.DrawSelf(spriteBatch);
Rectangle bounds = GetDimensions().ToRectangle();
Texture2D pixel = TextureAssets.MagicPixel.Value;
int firstInset = Math.Max(1, (int)MathF.Round(3f * LayoutScale));
int secondInset = Math.Max(firstInset + 1, (int)MathF.Round(7f * LayoutScale));
int thirdInset = Math.Max(secondInset + 1, (int)MathF.Round(10f * LayoutScale));
DrawInsetBorder(spriteBatch, pixel, bounds, firstInset, new Color(38, 31, 33), Math.Max(1, (int)MathF.Round(3f * LayoutScale)));
DrawInsetBorder(spriteBatch, pixel, bounds, secondInset, new Color(139, 43, 52) * 0.78f, Math.Max(1, (int)MathF.Round(2f * LayoutScale)));
DrawInsetBorder(spriteBatch, pixel, bounds, thirdInset, new Color(184, 116, 102) * 0.28f, 1);
int horizontalMargin = Math.Max(6, (int)MathF.Round(14f * LayoutScale));
int headerY = bounds.Y + Math.Max(1, (int)MathF.Round(36f * LayoutScale));
spriteBatch.Draw(pixel, new Rectangle(bounds.X + horizontalMargin, headerY, Math.Max(1, bounds.Width - horizontalMargin * 2), Math.Max(1, (int)MathF.Round(2f * LayoutScale))), new Color(127, 43, 49) * 0.72f);
int dividerX = bounds.X + (int)MathF.Round(SidebarDividerX);
int dividerTop = bounds.Y + (int)MathF.Round(45f * LayoutScale);
int dividerBottomMargin = (int)MathF.Round(18f * LayoutScale);
spriteBatch.Draw(pixel, new Rectangle(dividerX, dividerTop, Math.Max(1, (int)MathF.Round(2f * LayoutScale)), Math.Max(1, bounds.Bottom - dividerBottomMargin - dividerTop)), new Color(152, 52, 58) * 0.42f);
float pulse = (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2.3f) * 0.15f + 0.85f;
DrawDiamond(spriteBatch, pixel, new Vector2(bounds.Center.X - 270f * LayoutScale, bounds.Y + 18f * LayoutScale), 6f * LayoutScale, new Color(186, 50, 61) * pulse);
DrawDiamond(spriteBatch, pixel, new Vector2(bounds.Center.X + 270f * LayoutScale, bounds.Y + 18f * LayoutScale), 6f * LayoutScale, new Color(184, 129, 105) * pulse);
}
private static void DrawInsetBorder(SpriteBatch batch, Texture2D pixel, Rectangle bounds, int inset, Color color, int thickness)
{
batch.Draw(pixel, new Rectangle(bounds.Left + inset, bounds.Top + inset, bounds.Width - inset * 2, thickness), color);
batch.Draw(pixel, new Rectangle(bounds.Left + inset, bounds.Bottom - inset - thickness, bounds.Width - inset * 2, thickness), color);
batch.Draw(pixel, new Rectangle(bounds.Left + inset, bounds.Top + inset, thickness, bounds.Height - inset * 2), color);
batch.Draw(pixel, new Rectangle(bounds.Right - inset - thickness, bounds.Top + inset, thickness, bounds.Height - inset * 2), color);
}
private static void DrawDiamond(SpriteBatch batch, Texture2D pixel, Vector2 center, float size, Color color)
{
batch.Draw(pixel, center, null, color, MathHelper.PiOver4, pixel.Size() * 0.5f,
new Vector2(size / pixel.Width, size / pixel.Height), SpriteEffects.None, 0f);
}
}