Skip to content

Commit 4d9d7b6

Browse files
committed
MenuActiveEffects: Cleaner display of stack count
1 parent 1a022ab commit 4d9d7b6

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

src/MenuActiveEffects.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ FLARE. If not, see http://www.gnu.org/licenses/
4040
#include "UtilsFileSystem.h"
4141
#include "UtilsParsing.h"
4242
#include "WidgetLabel.h"
43+
#include <sstream>
4344

4445
MenuActiveEffects::MenuActiveEffects()
4546
: timer(NULL)
@@ -93,19 +94,19 @@ void MenuActiveEffects::logic() {
9394
continue;
9495

9596
size_t most_recent_id = effect_icons.size()-1;
96-
if(ed.group_stack){
97-
if( effect_icons.size()>0
97+
if (ed.group_stack){
98+
if ( effect_icons.size() > 0
9899
&& effect_icons[most_recent_id].type == ed.type
99100
&& effect_icons[most_recent_id].name == ed.name
100101
&& effect_icons[most_recent_id].icon == ed.icon){
101102

102103
effect_icons[most_recent_id].stacks++;
103104

104-
if(ed.type == Effect::SHIELD){
105+
if (ed.type == Effect::SHIELD){
105106
//Shields stacks in momment of addition, we never have to reach that
106-
}else if (ed.type == Effect::HEAL){
107+
} else if (ed.type == Effect::HEAL){
107108
//No special behavior
108-
}else{
109+
} else{
109110
if (ed.timer.getCurrent() < static_cast<unsigned>(effect_icons[most_recent_id].current)){
110111
if (ed.timer.getDuration() > 0)
111112
effect_icons[most_recent_id].overlay.y = (eset->resolutions.icon_size * ed.timer.getCurrent()) / ed.timer.getDuration();
@@ -116,13 +117,15 @@ void MenuActiveEffects::logic() {
116117
}
117118
}
118119

119-
if(!effect_icons[most_recent_id].stacksLabel){
120+
if (!effect_icons[most_recent_id].stacksLabel){
120121
effect_icons[most_recent_id].stacksLabel = new WidgetLabel();
121122
effect_icons[most_recent_id].stacksLabel->setPos(effect_icons[most_recent_id].pos.x, effect_icons[most_recent_id].pos.y);
122123
effect_icons[most_recent_id].stacksLabel->setMaxWidth(eset->resolutions.icon_size);
123124
}
124125

125-
effect_icons[most_recent_id].stacksLabel->setText(msg->getv("x%d", effect_icons[most_recent_id].stacks));
126+
std::stringstream ss;
127+
ss << "×" << effect_icons[most_recent_id].stacks;
128+
effect_icons[most_recent_id].stacksLabel->setText(ss.str());
126129

127130
continue;
128131
}
@@ -205,13 +208,20 @@ void MenuActiveEffects::renderTooltips(const Point& position) {
205208

206209
for (size_t i = 0; i < effect_icons.size(); ++i) {
207210
if (Utils::isWithinRect(effect_icons[i].pos, position)) {
208-
if (!effect_icons[i].name.empty())
209-
tip_data.addText(msg->get(effect_icons[i].name));
211+
std::stringstream ss;
212+
if (!effect_icons[i].name.empty()) {
213+
ss << msg->get(effect_icons[i].name);
214+
if (effect_icons[i].type != Effect::SHIELD && effect_icons[i].stacks > 1) {
215+
ss << " " << "" << effect_icons[i].stacks << ")";
216+
217+
}
218+
tip_data.addText(ss.str());
219+
}
210220

211221
if (effect_icons[i].type == Effect::HEAL)
212222
continue;
213223

214-
std::stringstream ss;
224+
ss.str("");
215225
if (effect_icons[i].type == Effect::SHIELD) {
216226
ss << "(" << effect_icons[i].current << "/" << effect_icons[i].max << ")";
217227
tip_data.addText(ss.str());
@@ -221,12 +231,6 @@ void MenuActiveEffects::renderTooltips(const Point& position) {
221231
tip_data.addText(ss.str());
222232
}
223233

224-
if(effect_icons[i].type != Effect::SHIELD){
225-
if(effect_icons[i].stacks > 1){
226-
tip_data.addText(msg->getv("x%d stacks", effect_icons[i].stacks));
227-
}
228-
}
229-
230234
break;
231235
}
232236
}

src/Version.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ FLARE. If not, see http://www.gnu.org/licenses/
3030

3131
#include <SDL.h>
3232

33-
Version VersionInfo::ENGINE(1, 14, 250);
33+
Version VersionInfo::ENGINE(1, 14, 251);
3434
Version VersionInfo::MIN(0, 0, 0);
3535
Version VersionInfo::MAX(USHRT_MAX, USHRT_MAX, USHRT_MAX);
3636

0 commit comments

Comments
 (0)