Initial commit: Theriapolis baseline at port/godot branch point
Captures the pre-Godot-port state of the codebase. This is the rollback anchor for the Godot port (M0 of theriapolis-rpg-implementation-plan-godot-port.md). All Phase 0 through Phase 6.5 work is included; Phase 7 is in flight. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Theriapolis.Game.CodexUI.Core;
|
||||
|
||||
namespace Theriapolis.Game.CodexUI.Widgets;
|
||||
|
||||
/// <summary>
|
||||
/// Single-child container that paints a parchment fill and a 1-px ink rule
|
||||
/// border. The review-step summary blocks and the aside container both use
|
||||
/// this; for borderless wrappers (e.g. the page's main column) just nest in
|
||||
/// a <see cref="Column"/> instead.
|
||||
/// </summary>
|
||||
public sealed class CodexPanel : CodexWidget
|
||||
{
|
||||
public CodexWidget? Child { get; set; }
|
||||
public Color BackgroundColor { get; set; } = CodexColors.Bg2;
|
||||
public Color BorderColor { get; set; } = CodexColors.Rule;
|
||||
public bool Bordered { get; set; } = true;
|
||||
public Thickness Inset { get; set; } = new(18, 18, 20, 18);
|
||||
|
||||
private readonly CodexAtlas _atlas;
|
||||
|
||||
public CodexPanel(CodexAtlas atlas, CodexWidget? child = null)
|
||||
{
|
||||
_atlas = atlas;
|
||||
Child = child;
|
||||
if (child is not null) child.Parent = this;
|
||||
}
|
||||
|
||||
protected override Point MeasureCore(Point available)
|
||||
{
|
||||
if (Child is null) return new Point(Inset.HorizontalSum(), Inset.VerticalSum());
|
||||
var inner = new Point(available.X - Inset.HorizontalSum(), available.Y - Inset.VerticalSum());
|
||||
var s = Child.Measure(inner);
|
||||
return new Point(s.X + Inset.HorizontalSum(), s.Y + Inset.VerticalSum());
|
||||
}
|
||||
|
||||
protected override void ArrangeCore(Rectangle bounds)
|
||||
{
|
||||
Child?.Arrange(new Rectangle(
|
||||
bounds.X + Inset.Left,
|
||||
bounds.Y + Inset.Top,
|
||||
bounds.Width - Inset.HorizontalSum(),
|
||||
bounds.Height - Inset.VerticalSum()));
|
||||
}
|
||||
|
||||
public override void Update(GameTime gt, CodexInput input) => Child?.Update(gt, input);
|
||||
|
||||
public override void Draw(SpriteBatch sb, GameTime gt)
|
||||
{
|
||||
sb.Draw(_atlas.Pixel, Bounds, BackgroundColor);
|
||||
if (Bordered)
|
||||
{
|
||||
sb.Draw(_atlas.Pixel, new Rectangle(Bounds.X, Bounds.Y, Bounds.Width, 1), BorderColor);
|
||||
sb.Draw(_atlas.Pixel, new Rectangle(Bounds.X, Bounds.Bottom - 1, Bounds.Width, 1), BorderColor);
|
||||
sb.Draw(_atlas.Pixel, new Rectangle(Bounds.X, Bounds.Y, 1, Bounds.Height), BorderColor);
|
||||
sb.Draw(_atlas.Pixel, new Rectangle(Bounds.Right - 1, Bounds.Y, 1, Bounds.Height), BorderColor);
|
||||
}
|
||||
Child?.Draw(sb, gt);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user