Skip to content

Refactor Text class for improved rendering and dimension handling#52

Merged
amasiye merged 2 commits into
mainfrom
develop
Mar 24, 2026
Merged

Refactor Text class for improved rendering and dimension handling#52
amasiye merged 2 commits into
mainfrom
develop

Conversation

@amasiye

@amasiye amasiye commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces several improvements to the UI text rendering and scene layout logic, focusing on more accurate dimension calculations, improved font management, and better handling of dynamic content in the TitleScene. The changes ensure that UI elements such as the title text and menu are positioned and sized correctly, even when fonts or console state change at runtime.

UI Text Rendering and Font Management:

  • Refactored the Text class to separate font and text management, introducing setFontName() and getFontName() methods, and ensuring that changes to text or font immediately update the raw lines and dimensions. Also added a refreshDimensions() helper for best-effort dimension recalculation. [1] [2] [3]
  • Overrode setPosition() in Text to recalculate dimensions before updating position, ensuring layout remains accurate if the text content or font changes.

Scene and Menu Layout Improvements:

  • Added a computed uiHeight property to TitleScene for dynamic UI sizing based on title text and menu items.
  • Improved menu layout logic by explicitly creating a Rect for menu dimensions and refining calculation of menu margins. [1] [2]

Title Text Positioning and Debugging:

  • Enhanced setTitleText() in TitleScene to refresh text dimensions after updating the text, ensuring correct centering and layout. Added detailed debug logging for easier troubleshooting.

Screen Dimension Fixes:

  • Corrected screen height detection in the Game class to use tput lines instead of tput cols, fixing a bug where the screen height could be set incorrectly.
  • Fixed resolveScreenWidth() in TitleScene to remove an unnecessary call to get_screen_width(), relying on internal state and settings for consistency.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@amasiye amasiye merged commit 44f1788 into main Mar 24, 2026
0 of 2 checks passed
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