Skip to content

Add custom text truncation support, and improve scoreboard legibility#7105

Open
Lightningbulb2 wants to merge 9 commits into
FAForever:developfrom
Lightningbulb2:develop
Open

Add custom text truncation support, and improve scoreboard legibility#7105
Lightningbulb2 wants to merge 9 commits into
FAForever:developfrom
Lightningbulb2:develop

Conversation

@Lightningbulb2
Copy link
Copy Markdown

@Lightningbulb2 Lightningbulb2 commented May 8, 2026

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)
Original


Game start with lots of players
GameStartExample


Full scoreboard
NEWSCOREBOARD


Replay scoreboard
REPLAY


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


Tooltips added for new players
gameQuality


gameSpeed

Checklist

Summary by CodeRabbit

  • New Features

    • Added game speed display showing requested vs. actual speed
    • Added game quality metric to the score overlay
    • Added hover tooltips revealing full player names when truncated
  • Style

    • Improved scoreboard alignment and added drop shadows for enhanced legibility
    • Enhanced text truncation with customizable trailing characters and smarter width-aware behavior

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3c8906e4-ddab-4c67-9c5f-4841f8cb5c97

📥 Commits

Reviewing files that changed from the base of the PR and between 5eb1c4d and 7e707b6.

📒 Files selected for processing (2)
  • lua/maui/text.lua
  • lua/ui/game/score.lua
🚧 Files skipped from review as they are similar to previous changes (2)
  • lua/maui/text.lua
  • lua/ui/game/score.lua

📝 Walkthrough

Walkthrough

Adds 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.

Changes

Scoreboard Text Truncation and Display Enhancement

Layer / File(s) Summary
Text truncation API
lua/maui/text.lua
Adds _fullText and _truncationText, exposes engine SetDisplayText/GetDisplayText, wraps SetText/GetText to preserve raw text, adds SetTruncationText, extends SetClipToWidth, and implements _applyTruncation.
Score UI header & rows
lua/ui/game/score.lua
CreateScoreUI adds time, gameSpeed, gameQuality, units header controls; per-army rows gain division text and nameHover tooltip; observer/map lines and constructor usage updated.
Name / division rendering
lua/ui/game/score.lua
updatePlayerName splits division into line.division, applies truncation to line.name, and updates division styling when focus changes.
Beat / runtime updates
lua/ui/game/score.lua
_OnBeat sets controls.time, controls.gameSpeed, and controls.gameQuality when session quality is enabled; runtime updates adjust division display styling.
Mini layout positioning
lua/ui/game/layouts/score_mini.lua
SetLayout positions controls.gameSpeed relative to controls.time and places controls.gameQuality within controls.bgTop.
Localization & changelog
loc/US/strings_db.lua, lua/ui/help/tooltips.lua, changelog/snippets/graphics.7105.md
Adds Game Speed/Game Quality localization entries, tooltip definitions, and changelog documenting UI and Text API changes.

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

area: changelog management

Suggested reviewers

  • BlackYps
  • lL1l1
  • 4z0t

Poem

🐰 I nibble words, keep full and neat,
Trim them gently so they fit your seat,
Names and ranks now sit apart,
Speed and quality play their part,
A rabbit's hop makes the scoreboard sweet.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main changes: adding custom text truncation support and improving scoreboard legibility, which are the primary objectives of the PR.
Description check ✅ Passed The description covers the proposed changes with visual evidence, testing methodology with multiple screenshots, changelog documentation, and mostly completed checklist items.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Lightningbulb2 Lightningbulb2 marked this pull request as ready for review May 8, 2026 04:03
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
lua/maui/text.lua (1)

78-80: ⚡ Quick win

SetTruncationText doesn'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 next SetText or width change. Consider re-triggering _applyTruncation here when _fullText is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 327d011 and 5eb1c4d.

📒 Files selected for processing (6)
  • changelog/snippets/graphics.7105.md
  • loc/US/strings_db.lua
  • lua/maui/text.lua
  • lua/ui/game/layouts/score_mini.lua
  • lua/ui/game/score.lua
  • lua/ui/help/tooltips.lua

Comment thread lua/maui/text.lua
Comment thread lua/maui/text.lua Outdated
Comment thread lua/ui/game/score.lua Outdated
Comment thread lua/ui/game/score.lua
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