Add custom text truncation support, and improve scoreboard legibility#7105
Add custom text truncation support, and improve scoreboard legibility#7105Lightningbulb2 wants to merge 9 commits into
Conversation
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds truncation support to the UI Text component and applies it to the scoreboard: separates name/division rendering, adds time/gameSpeed/gameQuality header controls with tooltips, positions those controls in compact layouts, and updates localization and changelog entries. ChangesScoreboard Text Truncation and Display Enhancement
🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
lua/maui/text.lua (1)
78-80: ⚡ Quick win
SetTruncationTextdoesn't reapply truncation to the current display.If called after text has already been set (e.g. to swap
"..."for"-"), the display won't update until the nextSetTextor width change. Consider re-triggering_applyTruncationhere when_fullTextis already populated.♻️ Proposed fix
SetTruncationText = function (self, text) self._truncationText = tostring(text) + if self._fullText ~= nil and self._initialized then + self:_applyTruncation() + end end,🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lua/maui/text.lua` around lines 78 - 80, SetTruncationText currently only updates self._truncationText and doesn't refresh the rendered text; modify SetTruncationText to set self._truncationText = tostring(text) and then, if self._fullText is non-nil/non-empty, call self:_applyTruncation() so the new truncation marker is applied immediately to the current display (same behavior as after SetText or width changes).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lua/maui/text.lua`:
- Around line 113-117: The loop is byte-oriented and can break multi-byte UTF‑8
characters: replace uses of string.len and str:sub(1, -2) with the UTF‑8 safe
helpers used elsewhere (use STR_Utf8Len to compute i and STR_Utf8SubString to
remove the last character), and ensure the truncation loop that calls
self:GetStringAdvance(str .. ellipsis) operates on the UTF‑8 substring so
multi‑byte characters aren’t split.
- Around line 106-110: In _applyTruncation: guard against _fullText being nil by
initializing it from the current display text (e.g. if self._fullText == nil
then self._fullText = self:GetDisplayText() or ""), then use that value when
calling GetStringAdvance; if the text fits (GetStringAdvance(...) <= maxWidth)
call SetDisplayText(self._fullText) and clear any truncation flag (e.g.
self._truncated = false) to restore the full text; otherwise perform the
truncation as before, call SetDisplayText(truncatedString) and set
self._truncated = true. Ensure you continue to use _truncationText/_fullText and
methods _applyTruncation, GetStringAdvance, SetDisplayText, GetDisplayText in
these changes.
In `@lua/ui/game/score.lua`:
- Around line 657-660: The variable q is being assigned without local scope
inside the block that checks sessionInfo.Options.Quality, causing a global leak;
make q a local variable (consistent with t and s used earlier) before assigning
string.format("Q:%.2f%%", sessionInfo.Options.Quality) and then call
controls.gameQuality:SetText(q) with that local q to avoid polluting the global
namespace.
- Line 132: The color string passed to controls.gameSpeed:SetColor is missing
the alpha channel; change the hex from 'BADAFF' to include an opaque alpha
prefix (match other calls like 'ff00dbff') so use an 8-character AARRGGBB string
(e.g. 'ffBADAFF') when calling controls.gameSpeed:SetColor to ensure the
intended opaque color is applied.
---
Nitpick comments:
In `@lua/maui/text.lua`:
- Around line 78-80: SetTruncationText currently only updates
self._truncationText and doesn't refresh the rendered text; modify
SetTruncationText to set self._truncationText = tostring(text) and then, if
self._fullText is non-nil/non-empty, call self:_applyTruncation() so the new
truncation marker is applied immediately to the current display (same behavior
as after SetText or width changes).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: dfbb29a2-64fd-486d-a6ff-1f7e5a1e0ec2
📒 Files selected for processing (6)
changelog/snippets/graphics.7105.mdloc/US/strings_db.lualua/maui/text.lualua/ui/game/layouts/score_mini.lualua/ui/game/score.lualua/ui/help/tooltips.lua
Description of the proposed changes
I wanted to improve scoreboard legibility.
I started by separating game speed, and game quality into their own controls to make modding and future changes easier. I added dropshadows, tooltips, and right aligned the ratings while making sure to crop player names if necessary. This led to the-
Implementation of SetTruncateText() which allows custom trailing strings like "...", "-", or even "NOFIT". This is executed through SetClipToWidth() and only activates if a truncation string is set.
To do this cleanly, and in a reusable way, I split SetText() into SetText() and its implicitly called SetDisplayText().
SetText() - controls the source text and behaves practically the same as before
SetDisplayText() - sends text changes to the engine without changing the Text object's internal string. This allows for better mod and source code capabilities for fancier text. The first example being custom text truncation.
Testing done on the proposed changes
I loaded up private AI matches and replays to check for console and visual errors. I got screenshots:
Original for reference (plus rank cropping issue)

Game start with lots of players

Full scoreboard

Replay scoreboard

Show full player names after hovering for a moment (in-case of cropped names)

Tooltips added for new players

Checklist
Summary by CodeRabbit
New Features
Style