Merge lp:~widelands-dev/widelands/bug-794407-soldier-stats into lp:widelands

Proposed by GunChleoc
Status: Work in progress
Proposed branch: lp:~widelands-dev/widelands/bug-794407-soldier-stats
Merge into: lp:widelands
Diff against target: 1629 lines (+365/-340)
40 files modified
data/tribes/scripting/help/controls.lua (+2/-0)
src/economy/flag.cc (+1/-1)
src/economy/flag.h (+2/-2)
src/economy/portdock.h (+6/-2)
src/economy/road.h (+6/-2)
src/editor/editorinteractive.cc (+2/-11)
src/logic/map_objects/CMakeLists.txt (+1/-1)
src/logic/map_objects/bob.cc (+1/-1)
src/logic/map_objects/bob.h (+2/-2)
src/logic/map_objects/draw_text.h (+0/-44)
src/logic/map_objects/immovable.cc (+5/-5)
src/logic/map_objects/immovable.h (+5/-5)
src/logic/map_objects/info_to_draw.h (+34/-0)
src/logic/map_objects/map_object.cc (+11/-6)
src/logic/map_objects/map_object.h (+2/-2)
src/logic/map_objects/tribes/building.cc (+5/-7)
src/logic/map_objects/tribes/building.h (+2/-2)
src/logic/map_objects/tribes/constructionsite.cc (+2/-2)
src/logic/map_objects/tribes/constructionsite.h (+1/-1)
src/logic/map_objects/tribes/dismantlesite.cc (+2/-2)
src/logic/map_objects/tribes/dismantlesite.h (+1/-1)
src/logic/map_objects/tribes/productionsite.cc (+24/-10)
src/logic/map_objects/tribes/ship.cc (+4/-4)
src/logic/map_objects/tribes/ship.h (+1/-1)
src/logic/map_objects/tribes/soldier.cc (+111/-101)
src/logic/map_objects/tribes/soldier.h (+6/-5)
src/logic/map_objects/tribes/worker.cc (+1/-1)
src/logic/map_objects/tribes/worker.h (+1/-1)
src/network/gameclient.cc (+3/-4)
src/network/gamehost.cc (+2/-3)
src/wui/attack_box.cc (+1/-1)
src/wui/interactive_base.cc (+18/-8)
src/wui/interactive_base.h (+6/-4)
src/wui/interactive_gamebase.cc (+47/-12)
src/wui/interactive_gamebase.h (+8/-7)
src/wui/interactive_player.cc (+20/-43)
src/wui/interactive_player.h (+2/-2)
src/wui/interactive_spectator.cc (+9/-27)
src/wui/interactive_spectator.h (+4/-3)
src/wui/soldierlist.cc (+4/-4)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-794407-soldier-stats
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+371952@code.launchpad.net

Commit message

Improve soldier level graphics and chat menu code
- Improve visibility of health bar graphs
- Add toggle for soldier level/health bar graphics
- Indicate in building statistics whether workers are on their way
- Small refactoring for chat menu code

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

Continuous integration builds have changed state:

Travis build 5354. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/578065755.
Appveyor build 5124. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_794407_soldier_stats-5124.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5367. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/579089392.
Appveyor build 5137. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_794407_soldier_stats-5137.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'data/images/wui/menus/toggle_soldier_levels.png'
2Binary files data/images/wui/menus/toggle_soldier_levels.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/toggle_soldier_levels.png 2019-09-08 17:21:06 +0000 differ
3=== modified file 'data/tribes/scripting/help/controls.lua'
4--- data/tribes/scripting/help/controls.lua 2018-04-28 09:24:11 +0000
5+++ data/tribes/scripting/help/controls.lua 2019-09-08 17:21:06 +0000
6@@ -50,6 +50,8 @@
7 dl(help_format_hotkey("C"), _"Toggle census") ..
8 -- TRANSLATORS: This is an access key combination. The hotkey is 's'
9 dl(help_format_hotkey("S"), _"Toggle statistics") ..
10+ -- TRANSLATORS: This is an access key combination. The hotkey is 'l'
11+ dl(help_format_hotkey("L"), _"Toggle soldier health bars and level icons") ..
12 toggle_minimap_hotkey ..
13 toggle_building_spaces_hotkey ..
14 -- TRANSLATORS: This is an access key combination. The hotkey is 'o'
15
16=== modified file 'src/economy/flag.cc'
17--- src/economy/flag.cc 2019-07-05 11:16:24 +0000
18+++ src/economy/flag.cc 2019-09-08 17:21:06 +0000
19@@ -785,7 +785,7 @@
20 }
21
22 void Flag::draw(uint32_t gametime,
23- const TextToDraw,
24+ const InfoToDraw,
25 const Vector2f& field_on_dst,
26 const Coords& coords,
27 float scale,
28
29=== modified file 'src/economy/flag.h'
30--- src/economy/flag.h 2019-04-24 06:01:37 +0000
31+++ src/economy/flag.h 2019-09-08 17:21:06 +0000
32@@ -26,7 +26,7 @@
33
34 #include "base/macros.h"
35 #include "economy/routing_node.h"
36-#include "logic/map_objects/draw_text.h"
37+#include "logic/map_objects/info_to_draw.h"
38 #include "logic/map_objects/immovable.h"
39 #include "logic/map_objects/walkingdir.h"
40
41@@ -154,7 +154,7 @@
42 void cleanup(EditorGameBase&) override;
43
44 void draw(uint32_t gametime,
45- TextToDraw draw_text,
46+ InfoToDraw info_to_draw,
47 const Vector2f& point_on_dst,
48 const Coords& coords,
49 float scale,
50
51=== modified file 'src/economy/portdock.h'
52--- src/economy/portdock.h 2019-07-05 11:16:24 +0000
53+++ src/economy/portdock.h 2019-09-08 17:21:06 +0000
54@@ -135,8 +135,12 @@
55 friend struct Fleet;
56
57 // Does nothing - we do not show them on the map
58- void draw(uint32_t, TextToDraw, const Vector2f&, const Coords&, float, RenderTarget*) override {
59- }
60+ void draw(uint32_t,
61+ InfoToDraw,
62+ const Vector2f&,
63+ const Coords&,
64+ float,
65+ RenderTarget*) override {}
66
67 void init_fleet(EditorGameBase& egbase);
68 void set_fleet(Fleet* fleet);
69
70=== modified file 'src/economy/road.h'
71--- src/economy/road.h 2019-07-05 11:16:24 +0000
72+++ src/economy/road.h 2019-09-08 17:21:06 +0000
73@@ -132,8 +132,12 @@
74
75 private:
76 /** The road is drawn by the terrain renderer via marked fields. */
77- void draw(uint32_t, TextToDraw, const Vector2f&, const Coords&, float, RenderTarget*) override {
78- }
79+ void draw(uint32_t,
80+ InfoToDraw,
81+ const Vector2f&,
82+ const Coords&,
83+ float,
84+ RenderTarget*) override {}
85
86 void set_path(EditorGameBase&, const Path&);
87
88
89=== modified file 'src/editor/editorinteractive.cc'
90--- src/editor/editorinteractive.cc 2019-09-04 12:14:06 +0000
91+++ src/editor/editorinteractive.cc 2019-09-08 17:21:06 +0000
92@@ -588,7 +588,7 @@
93 Widelands::BaseImmovable* const imm = field.fcoords.field->get_immovable();
94 if (imm != nullptr && imm->get_positions(ebase).front() == field.fcoords) {
95 imm->draw(
96- gametime, TextToDraw::kNone, field.rendertarget_pixel, field.fcoords, scale, &dst);
97+ gametime, InfoToDraw::kNone, field.rendertarget_pixel, field.fcoords, scale, &dst);
98 }
99 }
100
101@@ -596,7 +596,7 @@
102 for (Widelands::Bob* bob = field.fcoords.field->get_first_bob(); bob;
103 bob = bob->get_next_bob()) {
104 bob->draw(
105- ebase, TextToDraw::kNone, field.rendertarget_pixel, field.fcoords, scale, &dst);
106+ ebase, InfoToDraw::kNone, field.rendertarget_pixel, field.fcoords, scale, &dst);
107 }
108 }
109
110@@ -784,19 +784,10 @@
111 select_tool(tools_->current(), EditorTool::Third);
112 return true;
113
114- case SDLK_SPACE:
115- toggle_buildhelp();
116- return true;
117-
118 case SDLK_g:
119 toggle_grid();
120 return true;
121
122- case SDLK_c:
123- set_display_flag(
124- InteractiveBase::dfShowCensus, !get_display_flag(InteractiveBase::dfShowCensus));
125- return true;
126-
127 case SDLK_h:
128 mainmenu_.toggle();
129 return true;
130
131=== modified file 'src/logic/map_objects/CMakeLists.txt'
132--- src/logic/map_objects/CMakeLists.txt 2019-08-09 17:29:40 +0000
133+++ src/logic/map_objects/CMakeLists.txt 2019-09-08 17:21:06 +0000
134@@ -29,7 +29,6 @@
135 buildcost.h
136 checkstep.cc
137 checkstep.h
138- draw_text.h
139 findbob.cc
140 findbob.h
141 findimmovable.cc
142@@ -39,6 +38,7 @@
143 immovable.cc
144 immovable.h
145 immovable_program.h
146+ info_to_draw.h
147 map_object.cc
148 map_object.h
149 terrain_affinity.cc
150
151=== modified file 'src/logic/map_objects/bob.cc'
152--- src/logic/map_objects/bob.cc 2019-09-05 19:57:55 +0000
153+++ src/logic/map_objects/bob.cc 2019-09-08 17:21:06 +0000
154@@ -758,7 +758,7 @@
155 /// Note that the current node is actually the node that we are walking to, not
156 /// the the one that we start from.
157 void Bob::draw(const EditorGameBase& egbase,
158- const TextToDraw&,
159+ const InfoToDraw&,
160 const Vector2f& field_on_dst,
161 const Widelands::Coords& coords,
162 const float scale,
163
164=== modified file 'src/logic/map_objects/bob.h'
165--- src/logic/map_objects/bob.h 2019-04-24 06:01:37 +0000
166+++ src/logic/map_objects/bob.h 2019-09-08 17:21:06 +0000
167@@ -25,7 +25,7 @@
168 #include "economy/route.h"
169 #include "graphic/animation.h"
170 #include "graphic/diranimations.h"
171-#include "logic/map_objects/draw_text.h"
172+#include "logic/map_objects/info_to_draw.h"
173 #include "logic/map_objects/map_object.h"
174 #include "logic/map_objects/walkingdir.h"
175 #include "logic/widelands_geometry.h"
176@@ -264,7 +264,7 @@
177 // starting field) in pixel space of 'dst' (including scale). The 'scale' is
178 // required to draw the bob in the right size.
179 virtual void draw(const EditorGameBase&,
180- const TextToDraw& draw_text,
181+ const InfoToDraw& info_to_draw,
182 const Vector2f& field_on_dst,
183 const Coords& coords,
184 float scale,
185
186=== removed file 'src/logic/map_objects/draw_text.h'
187--- src/logic/map_objects/draw_text.h 2019-03-29 16:27:34 +0000
188+++ src/logic/map_objects/draw_text.h 1970-01-01 00:00:00 +0000
189@@ -1,44 +0,0 @@
190-/*
191- * Copyright (C) 2006-2019 by the Widelands Development Team
192- *
193- * This program is free software; you can redistribute it and/or
194- * modify it under the terms of the GNU General Public License
195- * as published by the Free Software Foundation; either version 2
196- * of the License, or (at your option) any later version.
197- *
198- * This program is distributed in the hope that it will be useful,
199- * but WITHOUT ANY WARRANTY; without even the implied warranty of
200- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
201- * GNU General Public License for more details.
202- *
203- * You should have received a copy of the GNU General Public License
204- * along with this program; if not, write to the Free Software
205- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
206- *
207- */
208-
209-#ifndef WL_LOGIC_MAP_OBJECTS_DRAW_TEXT_H
210-#define WL_LOGIC_MAP_OBJECTS_DRAW_TEXT_H
211-
212-// Only declare powers of 2 and adjust the ~ operator below if you add any values to this enum
213-// class.
214-enum class TextToDraw {
215- kNone = 0,
216- kCensus = 1,
217- kStatistics = 2,
218-};
219-
220-inline TextToDraw operator|(TextToDraw a, TextToDraw b) {
221- return static_cast<TextToDraw>(static_cast<int>(a) | static_cast<int>(b));
222-}
223-inline TextToDraw operator&(TextToDraw a, TextToDraw b) {
224- return static_cast<TextToDraw>(static_cast<int>(a) & static_cast<int>(b));
225-}
226-inline TextToDraw removeFromTextToDraw(TextToDraw base, TextToDraw remove) {
227- const int result = static_cast<int>(base) & ~static_cast<int>(remove);
228- assert(result >= 0);
229- assert(result <= 2);
230- return static_cast<TextToDraw>(result);
231-}
232-
233-#endif // end of include guard: WL_LOGIC_MAP_OBJECTS_DRAW_TEXT_H
234
235=== modified file 'src/logic/map_objects/immovable.cc'
236--- src/logic/map_objects/immovable.cc 2019-08-21 17:57:37 +0000
237+++ src/logic/map_objects/immovable.cc 2019-09-08 17:21:06 +0000
238@@ -463,7 +463,7 @@
239 }
240
241 void Immovable::draw(uint32_t gametime,
242- const TextToDraw draw_text,
243+ const InfoToDraw info_to_draw,
244 const Vector2f& point_on_dst,
245 const Widelands::Coords& coords,
246 float scale,
247@@ -474,15 +474,15 @@
248 if (!anim_construction_total_) {
249 dst->blit_animation(point_on_dst, coords, scale, anim_, gametime - animstart_);
250 if (former_building_descr_) {
251- do_draw_info(draw_text, former_building_descr_->descname(), "", point_on_dst, scale, dst);
252+ do_draw_info(info_to_draw, former_building_descr_->descname(), "", point_on_dst, scale, dst);
253 }
254 } else {
255- draw_construction(gametime, draw_text, point_on_dst, coords, scale, dst);
256+ draw_construction(gametime, info_to_draw, point_on_dst, coords, scale, dst);
257 }
258 }
259
260 void Immovable::draw_construction(const uint32_t gametime,
261- const TextToDraw draw_text,
262+ const InfoToDraw info_to_draw,
263 const Vector2f& point_on_dst,
264 const Widelands::Coords& coords,
265 const float scale,
266@@ -525,7 +525,7 @@
267
268 // Additionally, if statistics are enabled, draw a progression string
269 do_draw_info(
270- draw_text, descr().descname(),
271+ info_to_draw, descr().descname(),
272 g_gr->styles().color_tag((boost::format(_("%i%% built")) % (100 * done / total)).str(),
273 g_gr->styles().building_statistics_style().construction_color()),
274 point_on_dst, scale, dst);
275
276=== modified file 'src/logic/map_objects/immovable.h'
277--- src/logic/map_objects/immovable.h 2019-04-24 06:01:37 +0000
278+++ src/logic/map_objects/immovable.h 2019-09-08 17:21:06 +0000
279@@ -26,7 +26,7 @@
280 #include "base/macros.h"
281 #include "graphic/animation.h"
282 #include "logic/map_objects/buildcost.h"
283-#include "logic/map_objects/draw_text.h"
284+#include "logic/map_objects/info_to_draw.h"
285 #include "logic/map_objects/map_object.h"
286 #include "logic/widelands_geometry.h"
287 #include "notifications/note_ids.h"
288@@ -97,13 +97,13 @@
289 virtual PositionList get_positions(const EditorGameBase&) const = 0;
290
291 // Draw this immovable onto 'dst' choosing the frame appropriate for
292- // 'gametime'. 'draw_text' decides if census and statistics are written too.
293+ // 'gametime'. 'info_to_draw' decides if census and statistics are written too.
294 // The 'coords_to_draw' are passed one to give objects that occupy multiple
295 // fields a way to only draw themselves once. The 'point_on_dst' determines
296 // the point for the hotspot of the animation and 'scale' determines how big
297 // the immovable will be plotted.
298 virtual void draw(uint32_t gametime,
299- TextToDraw draw_text,
300+ InfoToDraw info_to_draw,
301 const Vector2f& point_on_dst,
302 const Coords& coords,
303 float scale,
304@@ -229,7 +229,7 @@
305 void cleanup(EditorGameBase&) override;
306 void act(Game&, uint32_t data) override;
307 void draw(uint32_t gametime,
308- TextToDraw draw_text,
309+ InfoToDraw info_to_draw,
310 const Vector2f& point_on_dst,
311 const Coords& coords,
312 float scale,
313@@ -316,7 +316,7 @@
314
315 void increment_program_pointer();
316 void draw_construction(uint32_t gametime,
317- TextToDraw draw_text,
318+ InfoToDraw info_to_draw,
319 const Vector2f& point_on_dst,
320 const Widelands::Coords& coords,
321 float scale,
322
323=== added file 'src/logic/map_objects/info_to_draw.h'
324--- src/logic/map_objects/info_to_draw.h 1970-01-01 00:00:00 +0000
325+++ src/logic/map_objects/info_to_draw.h 2019-09-08 17:21:06 +0000
326@@ -0,0 +1,34 @@
327+/*
328+ * Copyright (C) 2006-2017 by the Widelands Development Team
329+ *
330+ * This program is free software; you can redistribute it and/or
331+ * modify it under the terms of the GNU General Public License
332+ * as published by the Free Software Foundation; either version 2
333+ * of the License, or (at your option) any later version.
334+ *
335+ * This program is distributed in the hope that it will be useful,
336+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
337+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
338+ * GNU General Public License for more details.
339+ *
340+ * You should have received a copy of the GNU General Public License
341+ * along with this program; if not, write to the Free Software
342+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
343+ *
344+ */
345+
346+#ifndef WL_LOGIC_MAP_OBJECTS_INFO_TO_DRAW_H
347+#define WL_LOGIC_MAP_OBJECTS_INFO_TO_DRAW_H
348+
349+enum InfoToDraw {
350+ kNone = 0,
351+ kCensus = 1,
352+ kStatistics = 2,
353+ kSoldierLevels = 4,
354+};
355+
356+inline InfoToDraw operator|(InfoToDraw a, InfoToDraw b) {
357+ return static_cast<InfoToDraw>(static_cast<int>(a) | static_cast<int>(b));
358+}
359+
360+#endif // end of include guard: WL_LOGIC_MAP_OBJECTS_INFO_TO_DRAW_H
361
362=== modified file 'src/logic/map_objects/map_object.cc'
363--- src/logic/map_objects/map_object.cc 2019-05-27 21:04:13 +0000
364+++ src/logic/map_objects/map_object.cc 2019-09-08 17:21:06 +0000
365@@ -506,20 +506,24 @@
366 egbase.objects().remove(*this);
367 }
368
369-void MapObject::do_draw_info(const TextToDraw& draw_text,
370+void MapObject::do_draw_info(const InfoToDraw& info_to_draw,
371 const std::string& census,
372 const std::string& statictics,
373 const Vector2f& field_on_dst,
374 float scale,
375 RenderTarget* dst) const {
376- if (draw_text == TextToDraw::kNone) {
377+ if (!(info_to_draw & (InfoToDraw::kCensus | InfoToDraw::kStatistics))) {
378 return;
379 }
380
381 // Rendering text is expensive, so let's just do it for only a few sizes.
382+ const float granularity = 4.f;
383+ float text_scale = scale;
384 // The formula is a bit fancy to avoid too much text overlap.
385- scale = std::round(2.f * (scale > 1.f ? std::sqrt(scale) : std::pow(scale, 2.f))) / 2.f;
386- if (scale < 1.f) {
387+ text_scale = std::round(granularity * (text_scale > 1.f ? std::sqrt(text_scale) : std::pow(text_scale, 2.f))) / granularity;
388+
389+ // Skip tiny text for performance reasons
390+ if (text_scale < 0.5f) {
391 return;
392 }
393
394@@ -530,11 +534,12 @@
395 std::shared_ptr<const UI::RenderedText> rendered_census =
396 UI::g_fh->render(as_richtext_paragraph(census, census_font, UI::Align::kCenter), 120 * scale);
397 Vector2i position = field_on_dst.cast<int>() - Vector2i(0, 48) * scale;
398- if ((draw_text & TextToDraw::kCensus) != TextToDraw::kNone) {
399+ if (info_to_draw & InfoToDraw::kCensus) {
400 rendered_census->draw(*dst, position, UI::Align::kCenter);
401 }
402
403- if ((draw_text & TextToDraw::kStatistics) != TextToDraw::kNone && !statictics.empty()) {
404+ // Draw statistics if we want them, they are available and they fill fit
405+ if (info_to_draw & InfoToDraw::kStatistics && !statictics.empty() && scale >= 0.5f) {
406 UI::FontStyleInfo statistics_font(
407 g_gr->styles().building_statistics_style().statistics_font());
408 statistics_font.set_size(scale * statistics_font.size());
409
410=== modified file 'src/logic/map_objects/map_object.h'
411--- src/logic/map_objects/map_object.h 2019-05-25 08:51:42 +0000
412+++ src/logic/map_objects/map_object.h 2019-09-08 17:21:06 +0000
413@@ -35,7 +35,7 @@
414 #include "graphic/color.h"
415 #include "graphic/image.h"
416 #include "logic/cmd_queue.h"
417-#include "logic/map_objects/draw_text.h"
418+#include "logic/map_objects/info_to_draw.h"
419 #include "logic/map_objects/tribes/training_attribute.h"
420 #include "logic/widelands.h"
421 #include "scripting/lua_table.h"
422@@ -407,7 +407,7 @@
423 virtual void cleanup(EditorGameBase&);
424
425 /// Draws census and statistics on screen
426- void do_draw_info(const TextToDraw& draw_text,
427+ void do_draw_info(const InfoToDraw& info_to_draw,
428 const std::string& census,
429 const std::string& statictics,
430 const Vector2f& field_on_dst,
431
432=== modified file 'src/logic/map_objects/tribes/building.cc'
433--- src/logic/map_objects/tribes/building.cc 2019-09-05 19:57:55 +0000
434+++ src/logic/map_objects/tribes/building.cc 2019-09-08 17:21:06 +0000
435@@ -673,7 +673,7 @@
436 }
437
438 void Building::draw(uint32_t gametime,
439- const TextToDraw draw_text,
440+ const InfoToDraw info_to_draw,
441 const Vector2f& point_on_dst,
442 const Widelands::Coords& coords,
443 const float scale,
444@@ -689,7 +689,7 @@
445 // door animation?
446
447 // overlay strings (draw when enabled)
448- draw_info(draw_text, point_on_dst, scale, dst);
449+ draw_info(info_to_draw, point_on_dst, scale, dst);
450 }
451
452 /*
453@@ -697,15 +697,13 @@
454 Draw overlay help strings when enabled.
455 ===============
456 */
457-void Building::draw_info(const TextToDraw draw_text,
458+void Building::draw_info(const InfoToDraw info_to_draw,
459 const Vector2f& point_on_dst,
460 const float scale,
461 RenderTarget* dst) {
462 const std::string statistics_string =
463- ((draw_text & TextToDraw::kStatistics) != TextToDraw::kNone) ?
464- info_string(InfoStringFormat::kStatistics) :
465- "";
466- do_draw_info(draw_text, info_string(InfoStringFormat::kCensus), statistics_string, point_on_dst,
467+ (info_to_draw & InfoToDraw::kStatistics) ? info_string(InfoStringFormat::kStatistics) : "";
468+ do_draw_info(info_to_draw, info_string(InfoStringFormat::kCensus), statistics_string, point_on_dst,
469 scale, dst);
470 }
471
472
473=== modified file 'src/logic/map_objects/tribes/building.h'
474--- src/logic/map_objects/tribes/building.h 2019-09-05 19:57:55 +0000
475+++ src/logic/map_objects/tribes/building.h 2019-09-08 17:21:06 +0000
476@@ -353,13 +353,13 @@
477 void act(Game&, uint32_t data) override;
478
479 void draw(uint32_t gametime,
480- TextToDraw draw_text,
481+ InfoToDraw info_to_draw,
482 const Vector2f& point_on_dst,
483 const Coords& coords,
484 float scale,
485 RenderTarget* dst) override;
486 void
487- draw_info(TextToDraw draw_text, const Vector2f& point_on_dst, float scale, RenderTarget* dst);
488+ draw_info(InfoToDraw info_to_draw, const Vector2f& point_on_dst, float scale, RenderTarget* dst);
489
490 void set_seeing(bool see);
491 void set_attack_target(AttackTarget* new_attack_target);
492
493=== modified file 'src/logic/map_objects/tribes/constructionsite.cc'
494--- src/logic/map_objects/tribes/constructionsite.cc 2019-09-05 19:57:55 +0000
495+++ src/logic/map_objects/tribes/constructionsite.cc 2019-09-08 17:21:06 +0000
496@@ -611,7 +611,7 @@
497 ===============
498 */
499 void ConstructionSite::draw(uint32_t gametime,
500- TextToDraw draw_text,
501+ InfoToDraw info_to_draw,
502 const Vector2f& point_on_dst,
503 const Widelands::Coords& coords,
504 float scale,
505@@ -642,6 +642,6 @@
506 info_.draw(point_on_dst, coords, scale, player_color, dst);
507
508 // Draw help strings
509- draw_info(draw_text, point_on_dst, scale, dst);
510+ draw_info(info_to_draw, point_on_dst, scale, dst);
511 }
512 } // namespace Widelands
513
514=== modified file 'src/logic/map_objects/tribes/constructionsite.h'
515--- src/logic/map_objects/tribes/constructionsite.h 2019-06-23 11:41:17 +0000
516+++ src/logic/map_objects/tribes/constructionsite.h 2019-09-08 17:21:06 +0000
517@@ -143,7 +143,7 @@
518 static void wares_queue_callback(Game&, InputQueue*, DescriptionIndex, Worker*, void* data);
519
520 void draw(uint32_t gametime,
521- TextToDraw draw_text,
522+ InfoToDraw info_to_draw,
523 const Vector2f& point_on_dst,
524 const Coords& coords,
525 float scale,
526
527=== modified file 'src/logic/map_objects/tribes/dismantlesite.cc'
528--- src/logic/map_objects/tribes/dismantlesite.cc 2019-09-05 19:57:55 +0000
529+++ src/logic/map_objects/tribes/dismantlesite.cc 2019-09-08 17:21:06 +0000
530@@ -253,7 +253,7 @@
531 ===============
532 */
533 void DismantleSite::draw(uint32_t gametime,
534- const TextToDraw draw_text,
535+ const InfoToDraw info_to_draw,
536 const Vector2f& point_on_dst,
537 const Widelands::Coords& coords,
538 float scale,
539@@ -275,6 +275,6 @@
540 &player_color, 100 - ((get_built_per64k() * 100) >> 16));
541
542 // Draw help strings
543- draw_info(draw_text, point_on_dst, scale, dst);
544+ draw_info(info_to_draw, point_on_dst, scale, dst);
545 }
546 } // namespace Widelands
547
548=== modified file 'src/logic/map_objects/tribes/dismantlesite.h'
549--- src/logic/map_objects/tribes/dismantlesite.h 2019-08-22 19:30:40 +0000
550+++ src/logic/map_objects/tribes/dismantlesite.h 2019-09-08 17:21:06 +0000
551@@ -92,7 +92,7 @@
552 }
553
554 void draw(uint32_t gametime,
555- TextToDraw draw_text,
556+ InfoToDraw info_to_draw,
557 const Vector2f& point_on_dst,
558 const Widelands::Coords& coords,
559 float scale,
560
561=== modified file 'src/logic/map_objects/tribes/productionsite.cc'
562--- src/logic/map_objects/tribes/productionsite.cc 2019-08-31 20:49:36 +0000
563+++ src/logic/map_objects/tribes/productionsite.cc 2019-09-08 17:21:06 +0000
564@@ -311,18 +311,20 @@
565 * Display whether we're occupied.
566 */
567 void ProductionSite::update_statistics_string(std::string* s) {
568- uint32_t const nr_working_positions = descr().nr_working_positions();
569- uint32_t nr_workers = 0;
570- for (uint32_t i = nr_working_positions; i;)
571- nr_workers += working_positions_[--i].worker ? 1 : 0;
572-
573- if (nr_workers == 0) {
574- *s = g_gr->styles().color_tag(
575- _("(not occupied)"), g_gr->styles().building_statistics_style().low_color());
576- return;
577+ uint32_t nr_requests = 0;
578+ uint32_t nr_coming = 0;
579+ for (uint32_t i = 0; i < descr().nr_working_positions(); ++i) {
580+ const Widelands::Request* request = working_positions_[i].worker_request;
581+ if (request) {
582+ if (request->is_open()) {
583+ ++nr_requests;
584+ } else {
585+ ++nr_coming;
586+ }
587+ }
588 }
589
590- if (uint32_t const nr_requests = nr_working_positions - nr_workers) {
591+ if (nr_requests > 0) {
592 *s = g_gr->styles().color_tag(
593 (nr_requests == 1 ?
594 /** TRANSLATORS: Productivity label on a building if there is 1 worker missing */
595@@ -334,6 +336,18 @@
596 return;
597 }
598
599+ if (nr_coming > 0) {
600+ *s = g_gr->styles().color_tag(
601+ (nr_coming == 1 ?
602+ /** TRANSLATORS: Productivity label on a building if there is 1 worker missing */
603+ _("Worker is coming") :
604+ /** TRANSLATORS: Productivity label on a building if there is more than 1 worker
605+ missing. If you need plural forms here, please let us know. */
606+ _("Workers are coming")),
607+ g_gr->styles().building_statistics_style().low_color());
608+ return;
609+ }
610+
611 if (is_stopped_) {
612 *s = g_gr->styles().color_tag(
613 _("(stopped)"), g_gr->styles().building_statistics_style().neutral_color());
614
615=== modified file 'src/logic/map_objects/tribes/ship.cc'
616--- src/logic/map_objects/tribes/ship.cc 2019-08-21 17:57:37 +0000
617+++ src/logic/map_objects/tribes/ship.cc 2019-09-08 17:21:06 +0000
618@@ -1020,16 +1020,16 @@
619 }
620
621 void Ship::draw(const EditorGameBase& egbase,
622- const TextToDraw& draw_text,
623+ const InfoToDraw& info_to_draw,
624 const Vector2f& point_on_dst,
625 const Widelands::Coords& coords,
626 const float scale,
627 RenderTarget* dst) const {
628- Bob::draw(egbase, draw_text, point_on_dst, coords, scale, dst);
629+ Bob::draw(egbase, info_to_draw, point_on_dst, coords, scale, dst);
630
631 // Show ship name and current activity
632 std::string statistics_string;
633- if ((draw_text & TextToDraw::kStatistics) != TextToDraw::kNone) {
634+ if (info_to_draw & InfoToDraw::kStatistics) {
635 switch (ship_state_) {
636 case (ShipStates::kTransport):
637 if (destination_.is_set()) {
638@@ -1066,7 +1066,7 @@
639 statistics_string, g_gr->styles().building_statistics_style().medium_color());
640 }
641
642- do_draw_info(draw_text, shipname_, statistics_string, calc_drawpos(egbase, point_on_dst, scale),
643+ do_draw_info(info_to_draw, shipname_, statistics_string, calc_drawpos(egbase, point_on_dst, scale),
644 scale, dst);
645 }
646
647
648=== modified file 'src/logic/map_objects/tribes/ship.h'
649--- src/logic/map_objects/tribes/ship.h 2019-04-24 06:51:31 +0000
650+++ src/logic/map_objects/tribes/ship.h 2019-09-08 17:21:06 +0000
651@@ -236,7 +236,7 @@
652
653 protected:
654 void draw(const EditorGameBase&,
655- const TextToDraw& draw_text,
656+ const InfoToDraw& info_to_draw,
657 const Vector2f& point_on_dst,
658 const Coords& coords,
659 float scale,
660
661=== modified file 'src/logic/map_objects/tribes/soldier.cc'
662--- src/logic/map_objects/tribes/soldier.cc 2019-09-05 19:57:55 +0000
663+++ src/logic/map_objects/tribes/soldier.cc 2019-09-08 17:21:06 +0000
664@@ -57,7 +57,7 @@
665 namespace Widelands {
666
667 namespace {
668-
669+constexpr int kSoldierHealthBarWidth = 13;
670 constexpr int kRetreatWhenHealthDropsBelowThisPercentage = 50;
671 } // namespace
672
673@@ -548,7 +548,7 @@
674 * Draw this soldier. This basically draws him as a worker, but add health points
675 */
676 void Soldier::draw(const EditorGameBase& game,
677- const TextToDraw&,
678+ const InfoToDraw& info_to_draw,
679 const Vector2f& field_on_dst,
680 const Coords& coords,
681 float scale,
682@@ -562,133 +562,143 @@
683 draw_info_icon(
684 point_on_dst.cast<int>() -
685 Vector2i(0, (g_gr->animations().get_animation(get_current_anim()).height() - 7) * scale),
686- scale, true, dst);
687+ scale, InfoMode::kWalkingAround, info_to_draw, dst);
688 draw_inner(game, point_on_dst, coords, scale, dst);
689 }
690
691 /**
692 * Draw the info icon (level indicators + health bar) for this soldier.
693+ * 'draw_mode' determines whether the soldier info is displayed in a building window
694+ * or on top of a soldier walking around. 'info_to_draw' checks which info the user wants to see
695+ * for soldiers walking around.
696 */
697 void Soldier::draw_info_icon(Vector2i draw_position,
698 float scale,
699- const bool anchor_below,
700+ const InfoMode draw_mode,
701+ const InfoToDraw info_to_draw,
702 RenderTarget* dst) const {
703+ if (!(info_to_draw & InfoToDraw::kSoldierLevels)) {
704+ return;
705+ }
706+
707 // Since the graphics below are all pixel perfect and scaling them as floats
708- // looks weird, we round to the nearest fullest integer.
709- scale = std::round(scale);
710- if (scale == 0.f) {
711- return;
712- }
713-
714- const Image* healthpic = get_health_level_pic();
715- const Image* attackpic = get_attack_level_pic();
716- const Image* defensepic = get_defense_level_pic();
717- const Image* evadepic = get_evade_level_pic();
718+ // looks weird, we round to the nearest fullest integer. We do allow half size though.
719+ scale = std::max(0.5f, std::round(scale));
720
721 #ifndef NDEBUG
722- // This function assumes stuff about our data files: level icons are all the
723- // same size and this is smaller than the width of the healthbar. This
724- // simplifies the drawing code below a lot. Before it had a lot of if () that
725- // were never tested - since our data files never changed.
726- const int dimension = attackpic->width();
727- assert(attackpic->height() == dimension);
728- assert(healthpic->width() == dimension);
729- assert(healthpic->height() == dimension);
730- assert(defensepic->width() == dimension);
731- assert(defensepic->height() == dimension);
732- assert(evadepic->width() == dimension);
733- assert(evadepic->height() == dimension);
734- assert(kSoldierHealthBarWidth > dimension);
735+ {
736+ // This function assumes stuff about our data files: level icons are all the
737+ // same size and this is smaller than the width of the healthbar. This
738+ // simplifies the drawing code below a lot. Before it had a lot of if () that
739+ // were never tested - since our data files never changed.
740+ const Image* healthpic = get_health_level_pic();
741+
742+ const Image* attackpic = get_attack_level_pic();
743+ const Image* defensepic = get_defense_level_pic();
744+ const Image* evadepic = get_evade_level_pic();
745+
746+ const int dimension = attackpic->width();
747+ assert(attackpic->height() == dimension);
748+ assert(healthpic->width() == dimension);
749+ assert(healthpic->height() == dimension);
750+ assert(defensepic->width() == dimension);
751+ assert(defensepic->height() == dimension);
752+ assert(evadepic->width() == dimension);
753+ assert(evadepic->height() == dimension);
754+ assert(kSoldierHealthBarWidth > dimension);
755+ }
756 #endif
757
758- const int icon_size = healthpic->width();
759-
760- if (!anchor_below) {
761+ const int icon_size = get_health_level_pic()->height();
762+
763+ // Draw health info in building windows, or if kSoldierLevels is on.
764+ const bool draw_health_bar = draw_mode == InfoMode::kInBuilding || (info_to_draw & InfoToDraw::kSoldierLevels);
765+
766+ switch (draw_mode) {
767+ case InfoMode::kInBuilding:
768 draw_position.x += kSoldierHealthBarWidth * scale;
769 draw_position.y += 2 * icon_size * scale;
770- } else {
771- draw_position.y -= 5 * scale;
772+ break;
773+ case InfoMode::kWalkingAround:
774+ if (draw_health_bar) {
775+ draw_position.y -= 5 * scale;
776+ }
777 }
778
779- // Draw energy bar
780- assert(get_max_health());
781- const Recti energy_outer(draw_position - Vector2i(kSoldierHealthBarWidth, 0) * scale,
782- kSoldierHealthBarWidth * 2 * scale, 5 * scale);
783- dst->fill_rect(energy_outer, RGBColor(255, 255, 255));
784-
785- // Adjust health to current animation tick
786- uint32_t health_to_show = current_health_;
787- if (battle_) {
788- uint32_t pending_damage = battle_->get_pending_damage(this);
789- if (pending_damage > 0) {
790- int32_t timeshift = owner().egbase().get_gametime() - get_animstart();
791- timeshift = std::min(std::max(0, timeshift), 1000);
792-
793- pending_damage *= timeshift;
794- pending_damage /= 1000;
795-
796- if (pending_damage > health_to_show) {
797- health_to_show = 0;
798- } else {
799- health_to_show -= pending_damage;
800+ if (draw_health_bar) {
801+ // Draw energy bar
802+ assert(get_max_health());
803+ const RGBColor& color = owner().get_playercolor();
804+ const uint16_t color_sum = color.r + color.g + color.b;
805+
806+ // The frame gets a slight tint of player color
807+ const Recti energy_outer(draw_position - Vector2i(kSoldierHealthBarWidth, 0) * scale,
808+ kSoldierHealthBarWidth * 2 * scale, 5 * scale);
809+ dst->fill_rect(energy_outer, color);
810+ dst->brighten_rect(energy_outer, 230 - color_sum / 3);
811+
812+
813+ // Adjust health to current animation tick
814+ uint32_t health_to_show = current_health_;
815+ if (battle_) {
816+ uint32_t pending_damage = battle_->get_pending_damage(this);
817+ if (pending_damage > 0) {
818+ int32_t timeshift = owner().egbase().get_gametime() - get_animstart();
819+ timeshift = std::min(std::max(0, timeshift), 1000);
820+
821+ pending_damage *= timeshift;
822+ pending_damage /= 1000;
823+
824+ if (pending_damage > health_to_show) {
825+ health_to_show = 0;
826+ } else {
827+ health_to_show -= pending_damage;
828+ }
829 }
830 }
831- }
832-
833- int health_width = 2 * (kSoldierHealthBarWidth - 1) * health_to_show / get_max_health();
834- Recti energy_inner(draw_position + Vector2i(-kSoldierHealthBarWidth + 1, 1) * scale,
835- health_width * scale, 3 * scale);
836- Recti energy_complement(energy_inner.origin() + Vector2i(health_width, 0) * scale,
837- (2 * (kSoldierHealthBarWidth - 1) - health_width) * scale, 3 * scale);
838-
839- const RGBColor& color = owner().get_playercolor();
840- RGBColor complement_color;
841- if (static_cast<uint32_t>(color.r) + color.g + color.b > 128 * 3) {
842- complement_color = RGBColor(32, 32, 32);
843- } else {
844- complement_color = RGBColor(224, 224, 224);
845- }
846-
847- dst->fill_rect(energy_inner, color);
848- dst->fill_rect(energy_complement, complement_color);
849-
850- const auto draw_level_image = [icon_size, scale, &draw_position, dst](
851- const Vector2i& offset, const Image* image) {
852- dst->blitrect_scale(
853- Rectf(draw_position + offset * icon_size * scale, icon_size * scale, icon_size * scale),
854- image, Recti(0, 0, icon_size, icon_size), 1.f, BlendMode::UseAlpha);
855- };
856- draw_level_image(Vector2i(-1, -2), attackpic);
857- draw_level_image(Vector2i(0, -2), defensepic);
858- draw_level_image(Vector2i(-1, -1), healthpic);
859- draw_level_image(Vector2i(0, -1), evadepic);
860+
861+ // Now draw the health bar itself
862+ const int health_width =
863+ 2 * (kSoldierHealthBarWidth - 1) * health_to_show / get_max_health();
864+
865+ Recti energy_inner(draw_position + Vector2i(-kSoldierHealthBarWidth + 1, 1) * scale,
866+ health_width * scale, 3 * scale);
867+ Recti energy_complement(energy_inner.origin() + Vector2i(health_width, 0) * scale,
868+ (2 * (kSoldierHealthBarWidth - 1) - health_width) * scale, 3 * scale);
869+
870+ const RGBColor complement_color = color_sum > 128 * 3 ? RGBColor(32, 32, 32) : RGBColor(224, 224, 224);
871+ dst->fill_rect(energy_inner, color);
872+ dst->fill_rect(energy_complement, complement_color);
873+ }
874+
875+ // Draw level info in building windows, or if kSoldierLevels is on.
876+ if (draw_mode == InfoMode::kInBuilding || (info_to_draw & InfoToDraw::kSoldierLevels)) {
877+ const auto draw_level_image = [icon_size, scale, &draw_position, dst](
878+ const Vector2i& offset, const Image* image) {
879+ dst->blitrect_scale(Rectf(draw_position + offset * icon_size * scale, icon_size * scale,
880+ icon_size * scale),
881+ image, Recti(0, 0, icon_size, icon_size), 1.f, BlendMode::UseAlpha);
882+ };
883+
884+ draw_level_image(Vector2i(-1, -2), get_attack_level_pic());
885+ draw_level_image(Vector2i(0, -2), get_defense_level_pic());
886+ draw_level_image(Vector2i(-1, -1), get_health_level_pic());
887+ draw_level_image(Vector2i(0, -1), get_evade_level_pic());
888+ }
889 }
890
891 /**
892 * Compute the size of the info icon (level indicators + health bar) for soldiers of
893 * the given tribe.
894 */
895-void Soldier::calc_info_icon_size(const TribeDescr& tribe, uint32_t& w, uint32_t& h) {
896+void Soldier::calc_info_icon_size(const TribeDescr& tribe, int& w, int& h) {
897 const SoldierDescr* soldierdesc =
898 static_cast<const SoldierDescr*>(tribe.get_worker_descr(tribe.soldier()));
899- const Image* healthpic = soldierdesc->get_health_level_pic(0);
900- const Image* attackpic = soldierdesc->get_attack_level_pic(0);
901- const Image* defensepic = soldierdesc->get_defense_level_pic(0);
902- const Image* evadepic = soldierdesc->get_evade_level_pic(0);
903- uint16_t hpw = healthpic->width();
904- uint16_t hph = healthpic->height();
905- uint16_t atw = attackpic->width();
906- uint16_t ath = attackpic->height();
907- uint16_t dew = defensepic->width();
908- uint16_t deh = defensepic->height();
909- uint16_t evw = evadepic->width();
910- uint16_t evh = evadepic->height();
911-
912- uint16_t animw;
913- animw = kSoldierHealthBarWidth;
914-
915- w = std::max(std::max(atw + dew, hpw + evw), 2 * animw);
916- h = 5 + std::max(hph + ath, evh + deh);
917+ // The function draw_info_icon() already assumes that all icons have the same dimensions,
918+ // so we can make the same assumption here too.
919+ const int dimension = soldierdesc->get_health_level_pic(0)->height();
920+ w = 2 * std::max(dimension, kSoldierHealthBarWidth);
921+ h = 5 + 2 * dimension;
922 }
923
924 void Soldier::pop_task_or_fight(Game& game) {
925
926=== modified file 'src/logic/map_objects/tribes/soldier.h'
927--- src/logic/map_objects/tribes/soldier.h 2019-05-27 14:25:47 +0000
928+++ src/logic/map_objects/tribes/soldier.h 2019-09-08 17:21:06 +0000
929@@ -210,6 +210,8 @@
930 MO_DESCR(SoldierDescr)
931
932 public:
933+ enum class InfoMode { kWalkingAround, kInBuilding };
934+
935 explicit Soldier(const SoldierDescr&);
936
937 bool init(EditorGameBase&) override;
938@@ -246,20 +248,21 @@
939
940 /// Draw this soldier
941 void draw(const EditorGameBase&,
942- const TextToDraw& draw_text,
943+ const InfoToDraw& info_to_draw,
944 const Vector2f& point_on_dst,
945 const Widelands::Coords& coords,
946 float scale,
947 RenderTarget* dst) const override;
948
949- static void calc_info_icon_size(const TribeDescr&, uint32_t& w, uint32_t& h);
950+ static void calc_info_icon_size(const TribeDescr&, int& w, int& h);
951
952 // Draw the info icon containing health bar and levels. If 'anchor_below' is
953 // true, the icon is drawn horizontally centered above Otherwise, the icon
954 // is drawn below and right of 'draw_position'.
955 void draw_info_icon(Vector2i draw_position,
956 const float scale,
957- const bool anchor_below,
958+ const InfoMode draw_mode,
959+ const InfoToDraw info_to_draw,
960 RenderTarget*) const;
961
962 uint32_t get_current_health() const {
963@@ -371,8 +374,6 @@
964 std::pair<std::unique_ptr<SoldierLevelRange>, std::unique_ptr<DirAnimations>>
965 walking_animations_cache_;
966
967- static constexpr uint8_t kSoldierHealthBarWidth = 13;
968-
969 /// Number of consecutive blocked signals until the soldiers are considered permanently stuck
970 static constexpr uint8_t kBockCountIsStuck = 10;
971
972
973=== modified file 'src/logic/map_objects/tribes/worker.cc'
974--- src/logic/map_objects/tribes/worker.cc 2019-09-05 19:57:55 +0000
975+++ src/logic/map_objects/tribes/worker.cc 2019-09-08 17:21:06 +0000
976@@ -3077,7 +3077,7 @@
977 * Draw the worker, taking the carried ware into account.
978 */
979 void Worker::draw(const EditorGameBase& egbase,
980- const TextToDraw&,
981+ const InfoToDraw&,
982 const Vector2f& field_on_dst,
983 const Widelands::Coords& coords,
984 const float scale,
985
986=== modified file 'src/logic/map_objects/tribes/worker.h'
987--- src/logic/map_objects/tribes/worker.h 2019-09-03 10:40:20 +0000
988+++ src/logic/map_objects/tribes/worker.h 2019-09-08 17:21:06 +0000
989@@ -184,7 +184,7 @@
990 const float scale,
991 RenderTarget* dst) const;
992 void draw(const EditorGameBase&,
993- const TextToDraw& draw_text,
994+ const InfoToDraw& info_to_draw,
995 const Vector2f& field_on_dst,
996 const Widelands::Coords& coords,
997 float scale,
998
999=== modified file 'src/network/gameclient.cc'
1000--- src/network/gameclient.cc 2019-09-05 20:04:47 +0000
1001+++ src/network/gameclient.cc 2019-09-08 17:21:06 +0000
1002@@ -167,12 +167,12 @@
1003 (boost::format("%s_netclient%u") % kAutosavePrefix % static_cast<unsigned int>(pn)).str());
1004 InteractiveGameBase* igb;
1005 if (pn > 0) {
1006- igb = new InteractivePlayer(*game, get_config_section(), pn, true);
1007+ igb = new InteractivePlayer(*game, get_config_section(), pn, true, parent);
1008 } else {
1009- igb = new InteractiveSpectator(*game, get_config_section(), true);
1010+ igb = new InteractiveSpectator(*game, get_config_section(), true, parent);
1011 }
1012+
1013 game->set_ibase(igb);
1014- igb->set_chat_provider(*parent);
1015 if (settings.savegame) { // savegame
1016 game->init_savegame(loader, settings);
1017 } else { // new map
1018@@ -277,7 +277,6 @@
1019 d->game = &game;
1020 InteractiveGameBase* igb = d->init_game(this, loader_ui.get());
1021 d->run_game(igb, loader_ui.get());
1022-
1023 } catch (...) {
1024 WLApplication::emergency_save(game);
1025 d->game = nullptr;
1026
1027=== modified file 'src/network/gamehost.cc'
1028--- src/network/gamehost.cc 2019-09-05 20:04:47 +0000
1029+++ src/network/gamehost.cc 2019-09-08 17:21:06 +0000
1030@@ -667,11 +667,10 @@
1031 }
1032
1033 if ((pn > 0) && (pn <= UserSettings::highest_playernum())) {
1034- igb = new InteractivePlayer(game, get_config_section(), pn, true);
1035+ igb = new InteractivePlayer(game, get_config_section(), pn, true, &d->chat);
1036 } else {
1037- igb = new InteractiveSpectator(game, get_config_section(), true);
1038+ igb = new InteractiveSpectator(game, get_config_section(), true, &d->chat);
1039 }
1040- igb->set_chat_provider(d->chat);
1041 game.set_ibase(igb);
1042
1043 if (!d->settings.savegame) // new game
1044
1045=== modified file 'src/wui/attack_box.cc'
1046--- src/wui/attack_box.cc 2019-05-26 17:21:15 +0000
1047+++ src/wui/attack_box.cc 2019-09-08 17:21:06 +0000
1048@@ -403,7 +403,7 @@
1049 int32_t row = 0;
1050 for (uint32_t i = 0; i < nr_soldiers; ++i) {
1051 Vector2i location(column * kSoldierIconWidth, row * kSoldierIconHeight);
1052- soldiers_[i]->draw_info_icon(location, 1.0f, false, &dst);
1053+ soldiers_[i]->draw_info_icon(location, 1.0f, Soldier::InfoMode::kInBuilding, InfoToDraw::kSoldierLevels, &dst);
1054 if (restricted_row_number_) {
1055 ++row;
1056 if (row >= current_size_) {
1057
1058=== modified file 'src/wui/interactive_base.cc'
1059--- src/wui/interactive_base.cc 2019-08-25 14:50:16 +0000
1060+++ src/wui/interactive_base.cc 2019-09-08 17:21:06 +0000
1061@@ -178,9 +178,9 @@
1062 workareas_cache_(nullptr),
1063 egbase_(the_egbase),
1064 #ifndef NDEBUG // not in releases
1065- display_flags_(dfDebug),
1066+ display_flags_(dfDebug | kSoldierLevels),
1067 #else
1068- display_flags_(0),
1069+ display_flags_(kSoldierLevels),
1070 #endif
1071 lastframe_(SDL_GetTicks()),
1072 frametime_(0),
1073@@ -389,16 +389,22 @@
1074 set_sel_pos(get_sel_pos()); // redraw
1075 }
1076
1077-TextToDraw InteractiveBase::get_text_to_draw() const {
1078- TextToDraw text_to_draw = TextToDraw::kNone;
1079+InfoToDraw InteractiveBase::get_info_to_draw(bool show) const {
1080+ InfoToDraw info_to_draw = InfoToDraw::kNone;
1081+ if (!show) {
1082+ return info_to_draw;
1083+ }
1084 auto display_flags = get_display_flags();
1085 if (display_flags & InteractiveBase::dfShowCensus) {
1086- text_to_draw = text_to_draw | TextToDraw::kCensus;
1087+ info_to_draw = info_to_draw | InfoToDraw::kCensus;
1088 }
1089 if (display_flags & InteractiveBase::dfShowStatistics) {
1090- text_to_draw = text_to_draw | TextToDraw::kStatistics;
1091- }
1092- return text_to_draw;
1093+ info_to_draw = info_to_draw | InfoToDraw::kStatistics;
1094+ }
1095+ if (display_flags & InteractiveBase::dfShowSoldierLevels) {
1096+ info_to_draw = info_to_draw | InfoToDraw::kSoldierLevels;
1097+ }
1098+ return info_to_draw;
1099 }
1100
1101 void InteractiveBase::unset_sel_picture() {
1102@@ -1169,6 +1175,10 @@
1103 this, debugconsole_, *DebugConsole::get_chat_provider());
1104 return true;
1105 #endif
1106+ // Common shortcuts for InteractivePlayer, InteractiveSpectator and EditorInteractive
1107+ case SDLK_SPACE:
1108+ toggle_buildhelp();
1109+ return true;
1110 case SDLK_m:
1111 toggle_minimap();
1112 return true;
1113
1114=== modified file 'src/wui/interactive_base.h'
1115--- src/wui/interactive_base.h 2019-08-25 14:50:16 +0000
1116+++ src/wui/interactive_base.h 2019-09-08 17:21:06 +0000
1117@@ -61,11 +61,12 @@
1118 class InteractiveBase : public UI::Panel, public DebugConsole::Handler {
1119 public:
1120 enum {
1121- dfShowCensus = 1, ///< show census report on buildings
1122- dfShowStatistics = 2, ///< show statistics report on buildings
1123- dfDebug = 4, ///< general debugging info
1124+ dfShowCensus = 1, /// show census report on buildings
1125+ dfShowStatistics = 2, /// show statistics report on buildings
1126+ dfShowSoldierLevels = 4, /// show level information above soldiers
1127 dfShowWorkareaOverlap =
1128 8, ///< highlight overlapping workareas when placing a constructionsite
1129+ dfDebug = 16 /// general debugging info
1130 };
1131
1132 // Overlays displayed while a road is under construction.
1133@@ -252,7 +253,8 @@
1134 }
1135
1136 // Returns the information which overlay text should currently be drawn.
1137- TextToDraw get_text_to_draw() const;
1138+ // Returns InfoToDraw::kNone if not 'show'
1139+ InfoToDraw get_info_to_draw(bool show) const;
1140
1141 // Returns the current overlays for the work area previews.
1142 Workareas get_workarea_overlays(const Widelands::Map& map);
1143
1144=== modified file 'src/wui/interactive_gamebase.cc'
1145--- src/wui/interactive_gamebase.cc 2019-09-04 12:14:06 +0000
1146+++ src/wui/interactive_gamebase.cc 2019-09-08 17:21:06 +0000
1147@@ -64,9 +64,10 @@
1148 InteractiveGameBase::InteractiveGameBase(Widelands::Game& g,
1149 Section& global_s,
1150 PlayerType pt,
1151- bool const multiplayer)
1152+ bool const multiplayer,
1153+ ChatProvider* chat_provider)
1154 : InteractiveBase(g, global_s),
1155- chat_provider_(nullptr),
1156+ chat_provider_(chat_provider),
1157 multiplayer_(multiplayer),
1158 playertype_(pt),
1159 showhidemenu_(toolbar(),
1160@@ -132,6 +133,10 @@
1161 break;
1162 }
1163 });
1164+
1165+ if (chat_provider_ != nullptr) {
1166+ chat_overlay()->set_chat_provider(*chat_provider_);
1167+ }
1168 }
1169
1170 void InteractiveGameBase::add_main_menu() {
1171@@ -218,11 +223,20 @@
1172
1173 showhidemenu_.add(get_display_flag(dfShowStatistics) ?
1174 /** TRANSLATORS: An entry in the game's show/hide menu to toggle whether
1175- * building staristics are shown */
1176+ * building statistics are shown */
1177 _("Hide Statistics") :
1178 _("Show Statistics"),
1179 ShowHideEntry::kStatistics,
1180 g_gr->images().get("images/wui/menus/toggle_statistics.png"), false, "", "s");
1181+
1182+
1183+ showhidemenu_.add(get_display_flag(dfShowSoldierLevels) ?
1184+ /** TRANSLATORS: An entry in the game's show/hide menu to toggle whether
1185+ * level information is shown above soldiers' heads */
1186+ _("Hide Soldier Levels") :
1187+ _("Show Soldier Levels"),
1188+ ShowHideEntry::kSoldierLevels,
1189+ g_gr->images().get("images/wui/menus/toggle_soldier_levels.png"), false, "", "l");
1190 }
1191
1192 void InteractiveGameBase::showhide_menu_selected(ShowHideEntry entry) {
1193@@ -236,6 +250,9 @@
1194 case ShowHideEntry::kStatistics: {
1195 set_display_flag(dfShowStatistics, !get_display_flag(dfShowStatistics));
1196 } break;
1197+ case ShowHideEntry::kSoldierLevels: {
1198+ set_display_flag(dfShowSoldierLevels, !get_display_flag(dfShowSoldierLevels));
1199+ } break;
1200 case ShowHideEntry::kWorkareaOverlap: {
1201 set_display_flag(dfShowWorkareaOverlap, !get_display_flag(dfShowWorkareaOverlap));
1202 } break;
1203@@ -299,6 +316,15 @@
1204 }
1205 }
1206
1207+void InteractiveGameBase::add_chat_ui() {
1208+ add_toolbar_button("wui/menus/chat", "chat", _("Chat"), &chat_, true);
1209+ chat_.open_window = [this] {
1210+ if (chat_provider_) {
1211+ GameChatMenu::create_chat_console(this, chat_, *chat_provider_);
1212+ }
1213+ };
1214+}
1215+
1216 void InteractiveGameBase::increase_gamespeed() {
1217 if (GameController* const ctrl = get_game()->game_controller()) {
1218 ctrl->set_desired_speed(ctrl->desired_speed() + 1000);
1219@@ -348,6 +374,24 @@
1220 case SDLK_PAGEDOWN:
1221 decrease_gamespeed();
1222 return true;
1223+
1224+ case SDLK_c:
1225+ set_display_flag(
1226+ InteractiveBase::dfShowCensus, !get_display_flag(InteractiveBase::dfShowCensus));
1227+ return true;
1228+
1229+ case SDLK_l:
1230+ set_display_flag(dfShowSoldierLevels, !get_display_flag(dfShowSoldierLevels));
1231+ return true;
1232+
1233+ case SDLK_s:
1234+ if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
1235+ new GameMainMenuSaveGame(*this, menu_windows_.savegame);
1236+ } else {
1237+ set_display_flag(dfShowStatistics, !get_display_flag(dfShowStatistics));
1238+ }
1239+ return true;
1240+
1241 default:
1242 break;
1243 }
1244@@ -364,15 +408,6 @@
1245 return dynamic_cast<Widelands::Game&>(egbase());
1246 }
1247
1248-void InteractiveGameBase::set_chat_provider(ChatProvider& chat) {
1249- chat_provider_ = &chat;
1250- chat_overlay()->set_chat_provider(chat);
1251-}
1252-
1253-ChatProvider* InteractiveGameBase::get_chat_provider() {
1254- return chat_provider_;
1255-}
1256-
1257 void InteractiveGameBase::draw_overlay(RenderTarget& dst) {
1258 InteractiveBase::draw_overlay(dst);
1259
1260
1261=== modified file 'src/wui/interactive_gamebase.h'
1262--- src/wui/interactive_gamebase.h 2019-08-25 14:50:16 +0000
1263+++ src/wui/interactive_gamebase.h 2019-09-08 17:21:06 +0000
1264@@ -38,17 +38,14 @@
1265 public:
1266 InteractiveGameBase(Widelands::Game&,
1267 Section& global_s,
1268- PlayerType pt = NONE,
1269- bool multiplayer = false);
1270+ PlayerType pt,
1271+ bool multiplayer,
1272+ ChatProvider* chat_provider);
1273 ~InteractiveGameBase() override {
1274 }
1275 Widelands::Game* get_game() const;
1276 Widelands::Game& game() const;
1277
1278- // Chat messages
1279- void set_chat_provider(ChatProvider&);
1280- ChatProvider* get_chat_provider();
1281-
1282 virtual bool can_see(Widelands::PlayerNumber) const = 0;
1283 virtual bool can_act(Widelands::PlayerNumber) const = 0;
1284 virtual Widelands::PlayerNumber player_number() const = 0;
1285@@ -90,7 +87,7 @@
1286
1287 protected:
1288 // For referencing the items in showhidemenu_
1289- enum class ShowHideEntry { kBuildingSpaces, kCensus, kStatistics, kWorkareaOverlap };
1290+ enum class ShowHideEntry { kBuildingSpaces, kCensus, kStatistics, kSoldierLevels, kWorkareaOverlap };
1291
1292 // Adds the mapviewmenu_ to the toolbar
1293 void add_main_menu();
1294@@ -100,6 +97,9 @@
1295 // Adds the gamespeedmenu_ to the toolbar
1296 void add_gamespeed_menu();
1297
1298+ // Adds a chat toolbar button and registers the chat console window
1299+ void add_chat_ui();
1300+
1301 bool handle_key(bool down, SDL_Keysym code) override;
1302
1303 void draw_overlay(RenderTarget&) override;
1304@@ -119,6 +119,7 @@
1305 } menu_windows_;
1306
1307 ChatProvider* chat_provider_;
1308+ UI::UniqueWindow::Registry chat_;
1309 bool multiplayer_;
1310 PlayerType playertype_;
1311
1312
1313=== modified file 'src/wui/interactive_player.cc'
1314--- src/wui/interactive_player.cc 2019-08-25 14:50:16 +0000
1315+++ src/wui/interactive_player.cc 2019-09-08 17:21:06 +0000
1316@@ -44,7 +44,6 @@
1317 #include "wui/debugconsole.h"
1318 #include "wui/fieldaction.h"
1319 #include "wui/game_chat_menu.h"
1320-#include "wui/game_main_menu_save_game.h"
1321 #include "wui/game_message_menu.h"
1322 #include "wui/game_objectives_menu.h"
1323 #include "wui/general_statistics_menu.h"
1324@@ -81,28 +80,28 @@
1325 }
1326 return brightness / 255.;
1327 }
1328-
1329 // Remove statistics from the text to draw if the player does not match the map object's owner
1330-TextToDraw filter_text_to_draw(TextToDraw text_to_draw,
1331+InfoToDraw filter_info_to_draw(InfoToDraw info_to_draw,
1332 const Widelands::MapObject* object,
1333 const Widelands::Player& player) {
1334- TextToDraw result = text_to_draw;
1335+ InfoToDraw result = info_to_draw;
1336 const Widelands::Player* owner = object->get_owner();
1337 if (owner != nullptr && !player.see_all() && player.is_hostile(*owner)) {
1338- result = removeFromTextToDraw(result, TextToDraw::kStatistics);
1339+ result = static_cast<InfoToDraw>(result & ~InfoToDraw::kStatistics);
1340 }
1341 return result;
1342 }
1343
1344-void draw_immovable_for_visible_field(const Widelands::EditorGameBase& egbase,
1345- const FieldsToDraw::Field& field,
1346- const float scale,
1347- const TextToDraw text_to_draw,
1348- const Widelands::Player& player,
1349- RenderTarget* dst) {
1350+
1351+void draw_immovables_for_visible_field(const Widelands::EditorGameBase& egbase,
1352+ const FieldsToDraw::Field& field,
1353+ const float scale,
1354+ const InfoToDraw info_to_draw,
1355+ const Widelands::Player& player,
1356+ RenderTarget* dst) {
1357 Widelands::BaseImmovable* const imm = field.fcoords.field->get_immovable();
1358 if (imm != nullptr && imm->get_positions(egbase).front() == field.fcoords) {
1359- imm->draw(egbase.get_gametime(), filter_text_to_draw(text_to_draw, imm, player),
1360+ imm->draw(egbase.get_gametime(), filter_info_to_draw(info_to_draw, imm, player),
1361 field.rendertarget_pixel, field.fcoords, scale, dst);
1362 }
1363 }
1364@@ -110,12 +109,12 @@
1365 void draw_bobs_for_visible_field(const Widelands::EditorGameBase& egbase,
1366 const FieldsToDraw::Field& field,
1367 const float scale,
1368- const TextToDraw text_to_draw,
1369+ const InfoToDraw info_to_draw,
1370 const Widelands::Player& player,
1371 RenderTarget* dst) {
1372 for (Widelands::Bob* bob = field.fcoords.field->get_first_bob(); bob;
1373 bob = bob->get_next_bob()) {
1374- bob->draw(egbase, filter_text_to_draw(text_to_draw, bob, player), field.rendertarget_pixel,
1375+ bob->draw(egbase, filter_info_to_draw(info_to_draw, bob, player), field.rendertarget_pixel,
1376 field.fcoords, scale, dst);
1377 }
1378 }
1379@@ -154,8 +153,9 @@
1380 InteractivePlayer::InteractivePlayer(Widelands::Game& g,
1381 Section& global_s,
1382 Widelands::PlayerNumber const plyn,
1383- bool const multiplayer)
1384- : InteractiveGameBase(g, global_s, NONE, multiplayer),
1385+ bool const multiplayer,
1386+ ChatProvider* chat_provider)
1387+ : InteractiveGameBase(g, global_s, NONE, multiplayer, chat_provider),
1388 auto_roadbuild_mode_(global_s.get_bool("auto_roadbuild_mode", true)),
1389 flag_to_connect_(Widelands::Coords::null()),
1390 statisticsmenu_(toolbar(),
1391@@ -183,12 +183,7 @@
1392
1393 toolbar()->add_space(15);
1394 if (multiplayer) {
1395- toggle_chat_ = add_toolbar_button("wui/menus/chat", "chat", _("Chat"), &chat_, true);
1396- chat_.open_window = [this] {
1397- if (chat_provider_) {
1398- GameChatMenu::create_chat_console(this, chat_, *chat_provider_);
1399- }
1400- };
1401+ add_chat_ui();
1402 toolbar()->add_space(15);
1403 }
1404
1405@@ -344,10 +339,6 @@
1406 flag_to_connect_ = Widelands::Coords::null();
1407 }
1408 }
1409- if (is_multiplayer()) {
1410- toggle_chat_->set_visible(chat_provider_);
1411- toggle_chat_->set_enabled(chat_provider_);
1412- }
1413 {
1414 char const* msg_icon = "images/wui/menus/message_old.png";
1415 std::string msg_tooltip = _("Messages");
1416@@ -417,9 +408,9 @@
1417
1418 // Render stuff that belongs to the node.
1419 if (f->vision > 1) {
1420- const auto text_to_draw = get_text_to_draw();
1421- draw_immovable_for_visible_field(gbase, *f, scale, text_to_draw, plr, dst);
1422- draw_bobs_for_visible_field(gbase, *f, scale, text_to_draw, plr, dst);
1423+ const auto info_to_draw = get_info_to_draw(!given_map_view->is_animating());
1424+ draw_immovables_for_visible_field(gbase, *f, scale, info_to_draw, plr, dst);
1425+ draw_bobs_for_visible_field(gbase, *f, scale, info_to_draw, plr, dst);
1426 } else if (f->vision == 1) {
1427 // We never show census or statistics for objects in the fog.
1428 draw_immovable_for_formerly_visible_field(*f, player_field, scale, dst);
1429@@ -516,9 +507,6 @@
1430 bool InteractivePlayer::handle_key(bool const down, SDL_Keysym const code) {
1431 if (down) {
1432 switch (code.sym) {
1433- case SDLK_SPACE:
1434- toggle_buildhelp();
1435- return true;
1436
1437 case SDLK_i:
1438 menu_windows_.stats_stock.toggle();
1439@@ -536,10 +524,6 @@
1440 encyclopedia_.toggle();
1441 return true;
1442
1443- case SDLK_c:
1444- set_display_flag(dfShowCensus, !get_display_flag(dfShowCensus));
1445- return true;
1446-
1447 case SDLK_b:
1448 if (menu_windows_.stats_buildings.window == nullptr) {
1449 new BuildingStatisticsMenu(*this, menu_windows_.stats_buildings);
1450@@ -558,13 +542,6 @@
1451 }
1452 return true;
1453
1454- case SDLK_s:
1455- if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
1456- new GameMainMenuSaveGame(*this, menu_windows_.savegame);
1457- else
1458- set_display_flag(dfShowStatistics, !get_display_flag(dfShowStatistics));
1459- return true;
1460-
1461 case SDLK_w:
1462 set_display_flag(dfShowWorkareaOverlap, !get_display_flag(dfShowWorkareaOverlap));
1463 return true;
1464
1465=== modified file 'src/wui/interactive_player.h'
1466--- src/wui/interactive_player.h 2019-08-25 14:50:16 +0000
1467+++ src/wui/interactive_player.h 2019-09-08 17:21:06 +0000
1468@@ -42,7 +42,8 @@
1469 InteractivePlayer(Widelands::Game&,
1470 Section& global_s,
1471 Widelands::PlayerNumber,
1472- bool multiplayer);
1473+ bool multiplayer,
1474+ ChatProvider* chat_provider = nullptr);
1475
1476 bool can_see(Widelands::PlayerNumber) const override;
1477 bool can_act(Widelands::PlayerNumber) const override;
1478@@ -96,7 +97,6 @@
1479 bool auto_roadbuild_mode_;
1480 Widelands::Coords flag_to_connect_;
1481
1482- UI::Button* toggle_chat_;
1483 UI::Button* toggle_message_menu_;
1484
1485 // Statistics menu on the toolbar
1486
1487=== modified file 'src/wui/interactive_spectator.cc'
1488--- src/wui/interactive_spectator.cc 2019-08-25 14:50:16 +0000
1489+++ src/wui/interactive_spectator.cc 2019-09-08 17:21:06 +0000
1490@@ -36,8 +36,9 @@
1491 */
1492 InteractiveSpectator::InteractiveSpectator(Widelands::Game& g,
1493 Section& global_s,
1494- bool const multiplayer)
1495- : InteractiveGameBase(g, global_s, OBSERVER, multiplayer) {
1496+ bool const multiplayer,
1497+ ChatProvider* chat_provider)
1498+ : InteractiveGameBase(g, global_s, OBSERVER, multiplayer, chat_provider) {
1499 add_main_menu();
1500
1501 add_toolbar_button("wui/menus/statistics_general", "general_stats", _("Statistics"),
1502@@ -55,12 +56,7 @@
1503 toolbar()->add_space(15);
1504
1505 if (is_multiplayer()) {
1506- add_toolbar_button("wui/menus/chat", "chat", _("Chat"), &chat_, true);
1507- chat_.open_window = [this] {
1508- if (chat_provider_) {
1509- GameChatMenu::create_chat_console(this, chat_, *chat_provider_);
1510- }
1511- };
1512+ add_chat_ui();
1513 }
1514
1515 finalize_toolbar();
1516@@ -95,7 +91,7 @@
1517 const float scale = 1.f / given_map_view->view().zoom;
1518 const uint32_t gametime = the_game.get_gametime();
1519
1520- const auto text_to_draw = get_text_to_draw();
1521+ const auto info_to_draw = get_info_to_draw(!given_map_view->is_animating());
1522 for (size_t idx = 0; idx < fields_to_draw->size(); ++idx) {
1523 const FieldsToDraw::Field& field = fields_to_draw->at(idx);
1524
1525@@ -103,12 +99,12 @@
1526
1527 Widelands::BaseImmovable* const imm = field.fcoords.field->get_immovable();
1528 if (imm != nullptr && imm->get_positions(the_game).front() == field.fcoords) {
1529- imm->draw(gametime, text_to_draw, field.rendertarget_pixel, field.fcoords, scale, dst);
1530+ imm->draw(gametime, info_to_draw, field.rendertarget_pixel, field.fcoords, scale, dst);
1531 }
1532
1533 for (Widelands::Bob* bob = field.fcoords.field->get_first_bob(); bob;
1534 bob = bob->get_next_bob()) {
1535- bob->draw(the_game, text_to_draw, field.rendertarget_pixel, field.fcoords, scale, dst);
1536+ bob->draw(the_game, info_to_draw, field.rendertarget_pixel, field.fcoords, scale, dst);
1537 }
1538
1539 // Draw build help.
1540@@ -190,23 +186,8 @@
1541 * Global in-game keypresses:
1542 */
1543 bool InteractiveSpectator::handle_key(bool const down, SDL_Keysym const code) {
1544- if (down)
1545+ if (down) {
1546 switch (code.sym) {
1547- case SDLK_SPACE:
1548- toggle_buildhelp();
1549- return true;
1550-
1551- case SDLK_c:
1552- set_display_flag(dfShowCensus, !get_display_flag(dfShowCensus));
1553- return true;
1554-
1555- case SDLK_s:
1556- if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
1557- new GameMainMenuSaveGame(*this, menu_windows_.savegame);
1558- } else
1559- set_display_flag(dfShowStatistics, !get_display_flag(dfShowStatistics));
1560- return true;
1561-
1562 case SDLK_RETURN:
1563 case SDLK_KP_ENTER:
1564 if (chat_provider_) {
1565@@ -219,6 +200,7 @@
1566 default:
1567 break;
1568 }
1569+ }
1570
1571 return InteractiveGameBase::handle_key(down, code);
1572 }
1573
1574=== modified file 'src/wui/interactive_spectator.h'
1575--- src/wui/interactive_spectator.h 2019-08-25 14:50:16 +0000
1576+++ src/wui/interactive_spectator.h 2019-09-08 17:21:06 +0000
1577@@ -38,7 +38,10 @@
1578 * This class provides the UI, runs the game logic, etc.
1579 */
1580 struct InteractiveSpectator : public InteractiveGameBase {
1581- InteractiveSpectator(Widelands::Game&, Section& global_s, bool multiplayer = false);
1582+ InteractiveSpectator(Widelands::Game&,
1583+ Section& global_s,
1584+ bool multiplayer = false,
1585+ ChatProvider* chat_provider = nullptr);
1586
1587 Widelands::Player* get_player() const override;
1588
1589@@ -54,8 +57,6 @@
1590 bool can_act(Widelands::PlayerNumber) const override;
1591 Widelands::PlayerNumber player_number() const override;
1592 void node_action(const Widelands::NodeAndTriangle<>& node_and_triangle) override;
1593-
1594- UI::UniqueWindow::Registry chat_;
1595 };
1596
1597 #endif // end of include guard: WL_WUI_INTERACTIVE_SPECTATOR_H
1598
1599=== modified file 'src/wui/soldierlist.cc'
1600--- src/wui/soldierlist.cc 2019-05-26 17:21:15 +0000
1601+++ src/wui/soldierlist.cc 2019-09-08 17:21:06 +0000
1602@@ -44,7 +44,7 @@
1603
1604 constexpr uint32_t kMaxColumns = 6;
1605 constexpr uint32_t kAnimateSpeed = 300; ///< in pixels per second
1606-constexpr uint32_t kIconBorder = 2;
1607+constexpr int kIconBorder = 2;
1608
1609 } // namespace
1610
1611@@ -105,8 +105,8 @@
1612 uint32_t rows_;
1613 uint32_t cols_;
1614
1615- uint32_t icon_width_;
1616- uint32_t icon_height_;
1617+ int icon_width_;
1618+ int icon_height_;
1619
1620 int32_t last_animate_time_;
1621 };
1622@@ -296,7 +296,7 @@
1623 continue;
1624
1625 constexpr float kNoZoom = 1.f;
1626- soldier->draw_info_icon(icon.pos + Vector2i(kIconBorder, kIconBorder), kNoZoom, false, &dst);
1627+ soldier->draw_info_icon(icon.pos + Vector2i(kIconBorder, kIconBorder), kNoZoom, Soldier::InfoMode::kInBuilding, InfoToDraw::kSoldierLevels, &dst);
1628 }
1629 }
1630

Subscribers

People subscribed via source and target branches

to status/vote changes: