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

Commit

Permalink
fix: replace the eye catching red color for idle workers with the usu…
Browse files Browse the repository at this point in the history
…al colors of the stats overlay
  • Loading branch information
LangLangBart committed Mar 14, 2023
1 parent 5fbd986 commit ba5c0bb
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 37 deletions.
Binary file added art/textures/ui/session/phosphor/sleep.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions gui/session/boonGUI_XML/sprites.xml
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,9 @@
texture="session/phosphor/circle-empty.png"
/>
</sprite>

<sprite name="sleepSymbol">
<effect add_color="white" />
<image texture="session/phosphor/sleep.png" />
</sprite>
</sprites>
24 changes: 13 additions & 11 deletions gui/session/messages~boongui.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const boonGUI_ColorsSeenBefore = {};
const boonGUI_ColorsSeenBefore = new Map();

function colorizePlayernameByIDReturnNick(playerID)
{
Expand All @@ -25,18 +25,20 @@ function colorizePlayernameHelper(username, playerID)
function brightenedColor(color, brightnessThreshold = 115)
{
// check if a cached version is already available
if (boonGUI_ColorsSeenBefore[color])
return boonGUI_ColorsSeenBefore[color];
let [r, g, b] = color.split(" ").map(x => +x);
let i = 0;
while(r * 0.299 + g * 0.587 + b * 0.114 <= brightnessThreshold)
const key = `${color} ${brightnessThreshold}`;
if (!boonGUI_ColorsSeenBefore.has(key))
{
i += 0.001;
const [h, s, l] = rgbToHsl(r, g, b);
[r, g, b] = hslToRgb(h, s, l + i);
let [r, g, b] = color.split(" ").map(x => +x);
let i = 0;
while(r * 0.299 + g * 0.587 + b * 0.114 <= brightnessThreshold)
{
i += 0.001;
const [h, s, l] = rgbToHsl(r, g, b);
[r, g, b] = hslToRgb(h, s, l + i);
}
boonGUI_ColorsSeenBefore.set(key, [r, g, b].join(" "));
}
boonGUI_ColorsSeenBefore[color] = [r, g, b].join(" ");
return boonGUI_ColorsSeenBefore[color];
return boonGUI_ColorsSeenBefore.get(key);
}

function updateTutorial(notification)
Expand Down
2 changes: 1 addition & 1 deletion gui/session/stats/BoonGUIStatsModes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class BoonGUIStatsModes
static Modes = [
{ "type": "production", "icon": "cpu", "title": "Production" },
{ "type": "units", "icon": "users-three", "title": "Units" },
{ "type": "idle", "icon": "bed", "title": "Idle Workers" },
{ "type": "idle", "icon": "sleep", "title": "Idle Workers" },
{ "type": "civic_buildings", "icon": "house", "title": "Civic Buildings" },
{ "type": "military_buildings", "icon": "sword", "title": "Military Buildings" },
{ "type": "economic_buildings", "icon": "buildings", "title": "Economic Buildings" },
Expand Down
2 changes: 1 addition & 1 deletion gui/session/stats/BoonGUIStatsModesTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BoonGUIStatsModesTab
tab.size = BoonGUIGetRowSize(index, 40);
const text = Engine.GetGUIObjectByName(`${tab.name}_Text`);
const icon = Engine.GetGUIObjectByName(`${tab.name}_Icon`);
icon.sprite = `stretched:session/phosphor/${mode.icon}.png`;
icon.sprite = `stretched:color:dimmedWhite:textureAsMask:session/phosphor/${mode.icon}.png`;
tab.tooltip = colorizeHotkey(`${mode.title} %(hotkey)s`, `boongui.session.stats.mode.${index + 1}`);
tab.onPress = () => {
parent.selectMode(index);
Expand Down
1 change: 1 addition & 0 deletions gui/session/stats/BoonGUIStatsTopPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class BoonGUIStatsTopPanel {
playersStates.forEach(state => {
this.scales.addValue("popCount", state.popCount);
this.scales.addValue("popLimit", state.popLimit);
this.scales.addValue("idleWorker", state.queue.filter(x => x.mode === "idle").reduce((acc, val) => acc + val.count, 0));

this.scales.addValue("economyTechsCount", state.economyTechsCount);
this.scales.addValue("militaryTechsCount", state.militaryTechsCount);
Expand Down
19 changes: 8 additions & 11 deletions gui/session/stats/BoonGUIStatsTopPanelRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class BoonGUIStatsTopPanelRow
// TODO in observer mode the idle button is disabled, it shouldn't be.
this.idleWorkerHighlight.onPress = () => findIdleUnit(g_boonGUI_WorkerTypes);
this.idleWorkerCount = Engine.GetGUIObjectByName(`${PREFIX}_idleWorkerCount`);
this.idleWorkerAlphaMask = Engine.GetGUIObjectByName(`${PREFIX}_idleWorkerAlphaMask`);

this.resource = {
"counts": {},
Expand Down Expand Up @@ -107,7 +106,7 @@ class BoonGUIStatsTopPanelRow
font = "sans-stroke-14";
if (caption)
this.playerHighlight.tooltip += setStringTags(`\n${caption}`, { "color": "210 210 210", font });
this.playerHighlight.tooltip += setStringTags(`\n${this.jumpCivicCenterTooltip}`, { font });
this.playerHighlight.tooltip += setStringTags(`\n\n${this.jumpCivicCenterTooltip}`, { font });
this.team.tooltip = this.playerHighlight.tooltip;
this.rating.tooltip = this.playerHighlight.tooltip;
this.rating.caption = state.rating;
Expand Down Expand Up @@ -164,7 +163,7 @@ class BoonGUIStatsTopPanelRow
tooltip += progress ? g_Indent + Engine.FormatMillisecondsIntoDateStringGMT((phase_town || phase_city).timeRemaining, "m:ss") + g_Indent : "";
tooltip += techData.name.generic;
this.phaseHighlight.tooltip = tooltip;
this.phaseHighlight.tooltip += setStringTags(`\n${this.jumpCivicCenterTooltip}`, { font });
this.phaseHighlight.tooltip += setStringTags(`\n\n${this.jumpCivicCenterTooltip}`, { font });

this.phaseIcon.sprite = `stretched:session/portraits/${techData.icon}`;
if (progress == null)
Expand Down Expand Up @@ -225,12 +224,10 @@ class BoonGUIStatsTopPanelRow
value += state.queue[i].count;
}
}
this.idleWorkerHighlight.enabled = g_ViewedPlayer == state.index;

// Aim for dark red background and light red font color
this.idleWorkerAlphaMask.sprite = `color:200 0 0 ${Math.min(value, 18) * 10}`;
color = value > 0 ? "lightRed" : "dimmedWhite";
color = value > 0 ? scales.getColor("idleWorker", value, true) : "dimmedWhite";
font = value > 0 ? value > 99 ? "sans-bold-stroke-14" : "sans-bold-stroke-16" : "sans-stroke-16";

this.idleWorkerCount.caption = setStringTags(normalizeValue(value), { color, font });

tooltip += `Idle Workers${g_Indent}${g_Indent} ${setStringTags(value, { color })}\n`;
Expand All @@ -252,8 +249,8 @@ class BoonGUIStatsTopPanelRow
}
tooltip += setStringTags(`- ${className} ${value}\n`, { font, "color": value > 0 ? "lightRed" : "dimmedWhite" });
}

tooltip += `\n${setStringTags(this.idleUnitsTooltip, { font })}`;
if(g_ViewedPlayer > 0)
tooltip += `\n${setStringTags(this.idleUnitsTooltip, { font })}`;
this.idleWorkerHighlight.tooltip = tooltip;

for (const resType of g_BoonGUIResTypes)
Expand Down Expand Up @@ -388,8 +385,8 @@ class BoonGUIStatsTopPanelRow
this.killDeathRatioHighlight.tooltip = tooltip;
// Ever present slightly gray coloured empty circle, defined in the xml part.
// Place a full circle in the player's color over the gray circle, the gray circle is slightly visible, this is good for contrast with dark colors.
if(state.hasSharedLos || state.numberAllies == 1)
this.los.sprite = `stretched:color:${state.playerColor}:textureAsMask:session/phosphor/circle-full.png`;

this.los.sprite = (state.hasSharedLos || state.numberAllies == 1) ? `stretched:color:${state.playerColor}:textureAsMask:session/phosphor/circle-full.png` : `stretched:color:${state.playerColor}:textureAsMask:session/phosphor/circle-empty.png`;

color = state.brightenedPlayerColor;
tooltip = `${playerNick}\n`;
Expand Down
26 changes: 13 additions & 13 deletions gui/session/stats/sections/BoonGUIStatsTopPanel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@
type="text"
style="overlayHeader"
size="237 0 340 100%"
tooltip="Population">
tooltip="Population | Idle Worker">
<object
size="50%-17 -4 50%+18 28"
type="image"
sprite="stretched:session/icons/resources/population.png"
ghost="true"
/>
<object
size="50%+31 8 50%+47 24"
type="image"
sprite="sleepSymbol"
ghost="true"
/>
</object>

<object
Expand Down Expand Up @@ -264,18 +270,12 @@
type="button"
style="statsHighlighter">
<object
name="StatsTopPanelRow[n]_idleWorkerAlphaMask"
type="image"
ghost="true"
size="1 0 100%-1 100%-2">
<object
name="StatsTopPanelRow[n]_idleWorkerCount"
type="text"
text_align="center"
text_valign="center"
style="overlayMedium"
/>
</object>
name="StatsTopPanelRow[n]_idleWorkerCount"
type="text"
size="0 0 100% 100%-2"
text_align="center"
style="overlaySmall"
/>
</object>

<object
Expand Down

0 comments on commit ba5c0bb

Please sign in to comment.