test(D.2b): UiDatElement — cover DrawMode passthrough + media fallbacks

- Assert DrawMode values (not just File) in the existing named-vs-direct test
- Add ActiveMedia_NoMedia_ReturnsZero: empty StateMedia → (0,0)
- Add ActiveMedia_MissingNamedState_FallsBackToDirect: absent named key → DirectState
- OnDraw: replace `var (file, drawMode) = ...; _ = drawMode;` with idiomatic `var (file, _) = ...`
- Add `// exposed for unit testing` comment above ActiveMedia()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-06-15 13:34:50 +02:00
parent cc4de3ef77
commit 70dc391c41
2 changed files with 22 additions and 3 deletions

View file

@ -61,6 +61,7 @@ public sealed class UiDatElement : UiElement
/// falling back to the DirectState (<c>""</c> key) if the named state is absent.
/// Returns (0, 0) if neither exists.
/// </summary>
// exposed for unit testing
public (uint File, int DrawMode) ActiveMedia()
=> _info.StateMedia.TryGetValue(ActiveState, out var m) ? m
: _info.StateMedia.TryGetValue("", out var d) ? d
@ -68,7 +69,7 @@ public sealed class UiDatElement : UiElement
protected override void OnDraw(UiRenderContext ctx)
{
var (file, drawMode) = ActiveMedia();
var (file, _) = ActiveMedia();
if (file == 0) return;
var (tex, tw, th) = _resolve(file);
@ -78,8 +79,7 @@ public sealed class UiDatElement : UiElement
// matching ImgTex::TileCSI. Overlay/Alphablend are the same blit with a blend state; the
// sprite shader already alpha-blends, so the quad is identical for all draw modes in Plan 1.
// (No Stretch mode exists in DatReaderWriter.Enums.DrawModeType.)
// drawMode is not yet branched here — Plan 2 can add per-mode behavior if needed.
_ = drawMode; // suppress unused-variable warning until Plan 2 adds per-mode branches
// DrawMode is not yet branched here — Plan 2 can add per-mode behavior if needed.
float u1 = Width / tw;
float v1 = Height / th;
ctx.DrawSprite(tex, 0, 0, Width, Height, 0, 0, u1, v1, Vector4.One);