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

Commit

Permalink
fix: color code warn message
Browse files Browse the repository at this point in the history
  • Loading branch information
LangLangBart committed Mar 25, 2023
1 parent 2a39bbf commit 74c6f4c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion gui/common/tooltips~boongui.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ function setupStatHUDTreasureInfo(template)
*/
function getLocalizedResourceAmounts(resources, color = "255 255 255")
{

if (/^[^0-9]/.test(color))
{
warn(`The received color input "${color}" cannot be processed. Falling back to the default color.`);
color = "255 255 255";
}
color = brightenedColor(color);
const amounts = g_ResourceData.GetCodes()
.filter(type => !!resources[type])
Expand Down
6 changes: 3 additions & 3 deletions gui/session/chat/ChatMessageFormatSimulation~boongui.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ ChatMessageFormatSimulation.tribute.prototype.parse = function(msg)
if (msg.targetPlayer == Engine.GetPlayerID())
{
message = translate("%(player)s has sent you %(amounts)s.");
color = "green";
color = "0 200 0";
}
else if (msg.sourcePlayer == Engine.GetPlayerID())
{
message = translate("You have sent %(player2)s %(amounts)s.");
color = "red";
color = "200 0 0";
}
else if (Engine.ConfigDB_GetValue("user", "gui.session.notifications.tribute") == "true" &&
(g_IsObserver || g_InitAttributes.settings.LockTeams &&
Expand All @@ -91,7 +91,7 @@ ChatMessageFormatSimulation.tribute.prototype.parse = function(msg)
message = translate("%(player)s has sent %(player2)s %(amounts)s.");

return {
"text": sprintf(message.replace(Regex_Period, ""), {
"text": sprintf(message?.replace(Regex_Period, ""), {
"player": colorizePlayernameByID(msg.sourcePlayer),
"player2": colorizePlayernameByID(msg.targetPlayer),
"amounts": getLocalizedResourceAmounts(msg.amounts, color)
Expand Down
2 changes: 1 addition & 1 deletion gui/session/stats/BoonGUIStatsTopPanelRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class BoonGUIStatsTopPanelRow
if(g_ViewedPlayer > 0)
tooltip += `\n${setStringTags(this.idleUnitsTooltip, { font })}`;

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

for (const resType of g_BoonGUIResTypes)
Expand Down

0 comments on commit 74c6f4c

Please sign in to comment.