Merge lp:~widelands-dev/widelands/choose-attack-soldiers into lp:widelands

Proposed by Benedikt Straub
Status: Merged
Merged at revision: 9122
Proposed branch: lp:~widelands-dev/widelands/choose-attack-soldiers
Merge into: lp:widelands
Diff against target: 59 lines (+3/-10)
2 files modified
src/wui/attack_box.cc (+3/-6)
src/wui/attack_box.h (+0/-4)
To merge this branch: bzr merge lp:~widelands-dev/widelands/choose-attack-soldiers
Reviewer Review Type Date Requested Status
GunChleoc Approve
Benedikt Straub Needs Resubmitting
Review via email: mp+367471@code.launchpad.net

Commit message

Use a MultilineTextarea for the soldier stats in the attack box

Description of the change

Now the height of the attack box changes instead of the width ;)
It´ll change whenever the mouse is moved in or out; the text line is now hidden when no soldier is pointed at, which looks more elegant than an empty space at the bottom IMHO.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4986. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/532836861.
Appveyor build 4767. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_choose_attack_soldiers-4767.

Revision history for this message
GunChleoc (gunchleoc) wrote :

The vertical size not being fixed is a problem - the attack box can start jumping up and down.

Revision history for this message
Benedikt Straub (nordfriese) wrote :

How many lines should I set as the always visible minimum? two?

Revision history for this message
Toni Förster (stonerl) wrote :

I'd say 2. That would be 20 soldiers right?

Revision history for this message
Benedikt Straub (nordfriese) wrote :

@Toni I mean the textarea showing the soldier stats below

Alternatively, option 5: since the usage tooltip is shown only over the headers, we could remove the textarea and put the soldier stats into an own tooltip

Revision history for this message
GunChleoc (gunchleoc) wrote :

I think the last idea is the best one :)

Revision history for this message
Benedikt Straub (nordfriese) wrote :

A tooltip it is :)

review: Needs Resubmitting
Revision history for this message
GunChleoc (gunchleoc) wrote :

Perfect :)

@bunnybot merge

review: Approve
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5041. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/537114220.
Appveyor build 4821. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_choose_attack_soldiers-4821.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/wui/attack_box.cc'
--- src/wui/attack_box.cc 2019-05-11 18:19:20 +0000
+++ src/wui/attack_box.cc 2019-05-25 09:26:45 +0000
@@ -246,9 +246,6 @@
246 mainbox.add(remaining_soldiers_.get(), UI::Box::Resizing::kFullSize);246 mainbox.add(remaining_soldiers_.get(), UI::Box::Resizing::kFullSize);
247 }247 }
248248
249 current_soldier_stats_.reset(new UI::Textarea(&mainbox, "", UI::Align::kCenter));
250 mainbox.add(current_soldier_stats_.get(), UI::Box::Resizing::kFullSize, UI::Align::kCenter);
251
252 soldiers_slider_->set_enabled(max_attackers > 0);249 soldiers_slider_->set_enabled(max_attackers > 0);
253 more_soldiers_->set_enabled(max_attackers > 0);250 more_soldiers_->set_enabled(max_attackers > 0);
254}251}
@@ -322,12 +319,12 @@
322}319}
323320
324void AttackBox::ListOfSoldiers::handle_mousein(bool) {321void AttackBox::ListOfSoldiers::handle_mousein(bool) {
325 attack_box_->set_soldier_info_text();322 set_tooltip(std::string());
326}323}
327324
328bool AttackBox::ListOfSoldiers::handle_mousemove(uint8_t, int32_t x, int32_t y, int32_t, int32_t) {325bool AttackBox::ListOfSoldiers::handle_mousemove(uint8_t, int32_t x, int32_t y, int32_t, int32_t) {
329 if (const Widelands::Soldier* soldier = soldier_at(x, y)) {326 if (const Widelands::Soldier* soldier = soldier_at(x, y)) {
330 attack_box_->set_soldier_info_text(327 set_tooltip(
331 (boost::format(_("HP: %1$u/%2$u AT: %3$u/%4$u DE: %5$u/%6$u EV: %7$u/%8$u")) %328 (boost::format(_("HP: %1$u/%2$u AT: %3$u/%4$u DE: %5$u/%6$u EV: %7$u/%8$u")) %
332 soldier->get_health_level() % soldier->descr().get_max_health_level() %329 soldier->get_health_level() % soldier->descr().get_max_health_level() %
333 soldier->get_attack_level() % soldier->descr().get_max_attack_level() %330 soldier->get_attack_level() % soldier->descr().get_max_attack_level() %
@@ -335,7 +332,7 @@
335 soldier->get_evade_level() % soldier->descr().get_max_evade_level())332 soldier->get_evade_level() % soldier->descr().get_max_evade_level())
336 .str());333 .str());
337 } else {334 } else {
338 attack_box_->set_soldier_info_text();335 set_tooltip(std::string());
339 }336 }
340 return true;337 return true;
341}338}
342339
=== modified file 'src/wui/attack_box.h'
--- src/wui/attack_box.h 2019-05-11 18:19:20 +0000
+++ src/wui/attack_box.h 2019-05-25 09:26:45 +0000
@@ -55,9 +55,6 @@
5555
56 size_t count_soldiers() const;56 size_t count_soldiers() const;
57 std::vector<Widelands::Serial> soldiers() const;57 std::vector<Widelands::Serial> soldiers() const;
58 void set_soldier_info_text(std::string text = "") {
59 current_soldier_stats_->set_text(text);
60 }
6158
62 UI::Button* get_attack_button() const {59 UI::Button* get_attack_button() const {
63 return attack_button_.get();60 return attack_button_.get();
@@ -161,7 +158,6 @@
161158
162 std::unique_ptr<ListOfSoldiers> attacking_soldiers_;159 std::unique_ptr<ListOfSoldiers> attacking_soldiers_;
163 std::unique_ptr<ListOfSoldiers> remaining_soldiers_;160 std::unique_ptr<ListOfSoldiers> remaining_soldiers_;
164 std::unique_ptr<UI::Textarea> current_soldier_stats_;
165 std::unique_ptr<UI::Button> attack_button_;161 std::unique_ptr<UI::Button> attack_button_;
166162
167 /// The last time the information in this Panel got updated163 /// The last time the information in this Panel got updated

Subscribers

People subscribed via source and target branches

to status/vote changes: