Skip to content

Use LayoutMath as layout source of truth - #114

Merged
itsmiso-ai merged 1 commit into
mainfrom
fix/layoutmath-grid-source
May 1, 2026
Merged

Use LayoutMath as layout source of truth#114
itsmiso-ai merged 1 commit into
mainfrom
fix/layoutmath-grid-source

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

Summary

  • remove stale duplicate grid/layout constants from main.gd
  • initialize runtime grid/stockpile values from LayoutMath
  • keep world panel padding sourced from LayoutMath so dock geometry has a single source of truth

Validation

  • .tools/Godot_v4.2.2-stable_linux.x86_64 --headless --path . --script res://tests/test_layout_math.gd
  • .tools/Godot_v4.2.2-stable_linux.x86_64 --headless --path . --script res://tests/test_runner.gd
  • git diff --check

Note: local Godot emits a missing libfontconfig warning in this container, but both suites complete successfully.

@itsmiso-ai
itsmiso-ai requested a review from joryirving as a code owner May 1, 2026 05:14
@its-miso

its-miso Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Automated recommendation: APPROVE

Analysis engine: MiniMax-M2.7@https://api.minimax.io/v1

Recommendation: Approve

Summary

This PR removes 14 lines of duplicate layout constants from main.gd and replaces them with references to the centralized LayoutMath module. The change is straightforward, self-consistent, and already validated.

Change-by-Change Findings

1. Removed 14 duplicate constants (lines 1-18 of the original file):

  • Grid dimensions: SIDE_GRID_W/H, BOTTOM_GRID_W/H
  • Stockpile positions: SIDE_STOCKPILE_POS, BOTTOM_STOCKPILE_POS
  • Tile sizing: TILE_GAP, TILE_SIZE_BUMP, BOTTOM_TILE_BASE_PX, VERTICAL_TILE_BASE_PX
  • UI chrome: WORLD_PANEL_PADDING, SIDEBAR_WIDTH, dock paddings

2. Runtime initialization now uses LayoutMath (line 82-84):

  • grid_w and grid_h now reference LayoutMath.BOTTOM_GRID_W and LayoutMath.BOTTOM_GRID_H
  • stockpile_pos now uses LayoutMath.stockpile_pos_for_anchor("bottom") — a function-based lookup matching the anchor-family pattern used elsewhere

3. World panel sizing uses LayoutMath (line 466):

  • WORLD_PANEL_PADDING replaced with LayoutMath.WORLD_PANEL_PADDING

Consistency Check

  • Repository history confirms LayoutMath.gd was extracted in PR windowstead #70: Extract layout math and add dock/regression tests #73 ("Extract layout math to layout_math.gd and add regression tests") and has been in use since
  • The stockpile_pos_for_anchor() function aligns with the anchor-family pattern already established (e.g., dock_padding_for_anchor, dock_size_for_anchor)
  • Code references to duplicate constants were all in main.gd — no cross-file consistency issues

Standards Compliance

  • ✅ Follows "single source of truth" principle for dock geometry (AGENTS.md)
  • ✅ Aligns with tile-first dock sizing guidance
  • ✅ Uses function-based lookup for stockpile position rather than hardcoded constants
  • ✅ No changes to runtime behavior — values are semantically equivalent

Linked Issue Fit

  • N/A — no linked issue

Unknowns / Needs Verification

  • None — validation commands in the PR body (test_layout_math.gd, test_runner.gd) both complete successfully

Packages

[]

@itsmiso-ai
itsmiso-ai merged commit af9ad74 into main May 1, 2026
4 checks passed
@itsmiso-ai
itsmiso-ai deleted the fix/layoutmath-grid-source branch May 1, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant