Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 74c6f4c

Browse files
committed
fix: color code warn message
1 parent 2a39bbf commit 74c6f4c

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

gui/common/tooltips~boongui.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,11 @@ function setupStatHUDTreasureInfo(template)
188188
*/
189189
function getLocalizedResourceAmounts(resources, color = "255 255 255")
190190
{
191-
191+
if (/^[^0-9]/.test(color))
192+
{
193+
warn(`The received color input "${color}" cannot be processed. Falling back to the default color.`);
194+
color = "255 255 255";
195+
}
192196
color = brightenedColor(color);
193197
const amounts = g_ResourceData.GetCodes()
194198
.filter(type => !!resources[type])

gui/session/chat/ChatMessageFormatSimulation~boongui.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ ChatMessageFormatSimulation.tribute.prototype.parse = function(msg)
7777
if (msg.targetPlayer == Engine.GetPlayerID())
7878
{
7979
message = translate("%(player)s has sent you %(amounts)s.");
80-
color = "green";
80+
color = "0 200 0";
8181
}
8282
else if (msg.sourcePlayer == Engine.GetPlayerID())
8383
{
8484
message = translate("You have sent %(player2)s %(amounts)s.");
85-
color = "red";
85+
color = "200 0 0";
8686
}
8787
else if (Engine.ConfigDB_GetValue("user", "gui.session.notifications.tribute") == "true" &&
8888
(g_IsObserver || g_InitAttributes.settings.LockTeams &&
@@ -91,7 +91,7 @@ ChatMessageFormatSimulation.tribute.prototype.parse = function(msg)
9191
message = translate("%(player)s has sent %(player2)s %(amounts)s.");
9292

9393
return {
94-
"text": sprintf(message.replace(Regex_Period, ""), {
94+
"text": sprintf(message?.replace(Regex_Period, ""), {
9595
"player": colorizePlayernameByID(msg.sourcePlayer),
9696
"player2": colorizePlayernameByID(msg.targetPlayer),
9797
"amounts": getLocalizedResourceAmounts(msg.amounts, color)

gui/session/stats/BoonGUIStatsTopPanelRow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class BoonGUIStatsTopPanelRow
253253
if(g_ViewedPlayer > 0)
254254
tooltip += `\n${setStringTags(this.idleUnitsTooltip, { font })}`;
255255

256-
this.idleWorkerHeader.sprite = `streteched:color:${(!value || g_stats.lastPlayerLength > 1) ? "dimmedWhite" : redScale}:textureAsMask:session/phosphor/sleep.png`;
256+
this.idleWorkerHeader.sprite = `streteched:color:${(!value || g_stats.lastPlayerLength > 1) ? "dimmedWhite" : color}:textureAsMask:session/phosphor/sleep.png`;
257257
this.idleWorkerHighlight.tooltip = tooltip;
258258

259259
for (const resType of g_BoonGUIResTypes)

0 commit comments

Comments
 (0)