Skip to content

Commit 5937ef9

Browse files
feat(UI): Highlight installed outfit counts when all selected ships are of the same model and do not have the same number of outfits (endless-sky#10839)
1 parent b219767 commit 5937ef9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

data/_ui/interfaces.txt

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ color "logbook background" .125 .125 .125 1.
5151
color "logbook line" .2 .2 .2 1.
5252
color "message log background" .125 .125 .125 1.
5353
color "item selected" 0. 0. 0. .3
54+
color "outfitter difference highlight" 1. .5 0. 1.
5455

5556
# Colors used to draw certain HUD elements in-flight.
5657
color "shields" .43 .55 .85 .8

source/OutfitterPanel.cpp

+18-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ void OutfitterPanel::DrawItem(const string &name, const Point &point)
168168

169169
const Font &font = FontSet::Get(14);
170170
const Color &bright = *GameData::Colors().Get("bright");
171+
const Color &highlight = *GameData::Colors().Get("outfitter difference highlight");
172+
173+
bool highlightDifferences = false;
171174
if(playerShip || isLicense || mapSize)
172175
{
173176
int minCount = numeric_limits<int>::max();
@@ -178,8 +181,16 @@ void OutfitterPanel::DrawItem(const string &name, const Point &point)
178181
minCount = maxCount = player.HasMapped(mapSize);
179182
else
180183
{
184+
highlightDifferences = true;
185+
string firstModelName;
181186
for(const Ship *ship : playerShips)
182187
{
188+
// Highlight differences in installed outfit counts only when all selected ships are of the same model.
189+
string modelName = ship->TrueModelName();
190+
if(firstModelName.empty())
191+
firstModelName = modelName;
192+
else
193+
highlightDifferences &= (modelName == firstModelName);
183194
int count = ship->OutfitCount(outfit);
184195
minCount = min(minCount, count);
185196
maxCount = max(maxCount, count);
@@ -189,13 +200,19 @@ void OutfitterPanel::DrawItem(const string &name, const Point &point)
189200
if(maxCount)
190201
{
191202
string label = "installed: " + to_string(minCount);
203+
Color color = bright;
192204
if(maxCount > minCount)
205+
{
193206
label += " - " + to_string(maxCount);
207+
if(highlightDifferences)
208+
color = highlight;
209+
}
194210

195211
Point labelPos = point + Point(-OUTFIT_SIZE / 2 + 20, OUTFIT_SIZE / 2 - 38);
196-
font.Draw(label, labelPos, bright);
212+
font.Draw(label, labelPos, color);
197213
}
198214
}
215+
199216
// Don't show the "in stock" amount if the outfit has an unlimited stock.
200217
int stock = 0;
201218
if(!outfitter.Has(outfit))

0 commit comments

Comments
 (0)