Merge lp:~widelands-dev/widelands/toggle_immovables into lp:widelands
- toggle_immovables
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 8422 | ||||
Proposed branch: | lp:~widelands-dev/widelands/toggle_immovables | ||||
Merge into: | lp:widelands | ||||
Prerequisite: | lp:~widelands-dev/widelands/toggle_resources | ||||
Diff against target: |
523 lines (+150/-77) 8 files modified
data/scripting/editor/editor_controls.lua (+8/-2) src/editor/editorinteractive.cc (+66/-63) src/editor/editorinteractive.h (+4/-0) src/graphic/game_renderer.cc (+29/-10) src/graphic/game_renderer.h (+9/-1) src/wui/interactive_base.cc (+18/-0) src/wui/interactive_base.h (+10/-0) src/wui/mapview.cc (+6/-1) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/toggle_immovables | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
GunChleoc | Approve | ||
Review via email: mp+328977@code.launchpad.net |
Commit message
Make display of bobs and immovables toggable.
Hotkeys are CTRL-<1-4>.
Description of the change
toptopple (7010622-q-deactivatedaccount) wrote : | # |
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 2537. State: failed. Details: https:/
Appveyor build 2360. State: success. Details: https:/
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 2537. State: passed. Details: https:/
Appveyor build 2360. State: success. Details: https:/
GunChleoc (gunchleoc) wrote : | # |
Code LTGM. Let's wait with merging until we have decided on the hotkeys.
SirVer (sirver) wrote : | # |
I changed the hotkeys to use CTRL 1 to 4, doubling CTRL 1 with SPACE (which is a slight ward). But CTRL 1-4 for the layers feels really good and quick. What do you think?
kaputtnik (franku) wrote : | # |
Didn't test it yet, but i think the order should be the same as we have icons in the tools menu?
That is from left to right:
- ..
- Immovables (here: 3), suggestion: 2
- Animals (here: 4), suggestion: 3
- Resources (here: 2), suggestion: 4
- ..
So there a little dependency with the visual representation and one could may better remember which hotkey toggles which overlay without always trying around.
kaputtnik (franku) wrote : | # |
Ah, forgotton:
If the hotkey for buildhelp is changed in editor, will it still be 'space' for playing games?
SirVer (sirver) wrote : | # |
> Didn't test it yet, but i think the order should be the same as we have icons in the tools menu?
true that. done.
> If the hotkey for buildhelp is changed in editor, will it still be 'space' for playing games?
It is not changed. It is duplicated - space still works. But for symmetry I added CTRL 1. That is what I meant with a slight ward. It feels really good using the for hotkeys will making a map though
kaputtnik (franku) wrote : | # |
Thanks for clarification :-)
GunChleoc (gunchleoc) wrote : | # |
I removed a blank line - xgettext can only pick up comments that are immediately above the gettext invocation, so a blank space might keep it from picking up the comment.
Code still LGTM, will do a bit of testing once the compiler is finished.
GunChleoc (gunchleoc) wrote : | # |
Tested and working :)
@bunnybot merge
Preview Diff
1 | === added file 'data/images/wui/menus/menu_toggle_bobs.png' |
2 | Binary files data/images/wui/menus/menu_toggle_bobs.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/menu_toggle_bobs.png 2017-08-16 05:34:38 +0000 differ |
3 | === added file 'data/images/wui/menus/menu_toggle_immovables.png' |
4 | Binary files data/images/wui/menus/menu_toggle_immovables.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/menu_toggle_immovables.png 2017-08-16 05:34:38 +0000 differ |
5 | === modified file 'data/scripting/editor/editor_controls.lua' |
6 | --- data/scripting/editor/editor_controls.lua 2017-08-14 09:06:04 +0000 |
7 | +++ data/scripting/editor/editor_controls.lua 2017-08-16 05:34:38 +0000 |
8 | @@ -21,10 +21,16 @@ |
9 | dl(help_format_hotkey("T"), _"Toggle tools menu") .. |
10 | toggle_minimap_hotkey .. |
11 | toggle_building_spaces_hotkey .. |
12 | + -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. |
13 | + dl(help_format_hotkey("Ctrl + 1"), _"Toggle building spaces") .. |
14 | + -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. |
15 | + dl(help_format_hotkey("Ctrl + 2"), _"Toggle immovables display") .. |
16 | + -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. |
17 | + dl(help_format_hotkey("Ctrl + 3"), _"Toggle animals display") .. |
18 | -- TRANSLATORS: This is an access key combination. The hotkey is 'p' |
19 | + dl(help_format_hotkey("Ctrl + 4"), _"Toggle resources display") .. |
20 | + -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. |
21 | dl(help_format_hotkey("P"), _"Toggle player menu") .. |
22 | - -- TRANSLATORS: This is an access key combination. The hotkey is 'q' |
23 | - dl(help_format_hotkey("Q"), _"Toggle resources display") .. |
24 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. |
25 | dl(help_format_hotkey("Ctrl + Z"), _"Undo") .. |
26 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. |
27 | |
28 | === modified file 'src/editor/editorinteractive.cc' |
29 | --- src/editor/editorinteractive.cc 2017-08-14 09:06:04 +0000 |
30 | +++ src/editor/editorinteractive.cc 2017-08-16 05:34:38 +0000 |
31 | @@ -118,6 +118,14 @@ |
32 | toggle_buildhelp_ = add_toolbar_button( |
33 | "wui/menus/menu_toggle_buildhelp", "buildhelp", _("Show Building Spaces (on/off)")); |
34 | toggle_buildhelp_->sigclicked.connect(boost::bind(&EditorInteractive::toggle_buildhelp, this)); |
35 | + toggle_immovables_ = add_toolbar_button( |
36 | + "wui/menus/menu_toggle_immovables", "immovables", _("Show Immovables (on/off)")); |
37 | + toggle_immovables_->set_perm_pressed(true); |
38 | + toggle_immovables_->sigclicked.connect([this]() { toggle_immovables(); }); |
39 | + toggle_bobs_ = add_toolbar_button( |
40 | + "wui/menus/menu_toggle_bobs", "animals", _("Show Animals (on/off)")); |
41 | + toggle_bobs_->set_perm_pressed(true); |
42 | + toggle_bobs_->sigclicked.connect([this]() { toggle_bobs(); }); |
43 | toggle_resources_ = add_toolbar_button( |
44 | "wui/menus/menu_toggle_resources", "resources", _("Show Resources (on/off)")); |
45 | toggle_resources_->set_perm_pressed(true); |
46 | @@ -339,54 +347,69 @@ |
47 | toggle_resources_->set_perm_pressed(value); |
48 | } |
49 | |
50 | +void EditorInteractive::toggle_immovables() { |
51 | + const bool value = !draw_immovables(); |
52 | + set_draw_immovables(value); |
53 | + toggle_immovables_->set_perm_pressed(value); |
54 | +} |
55 | + |
56 | +void EditorInteractive::toggle_bobs() { |
57 | + const bool value = !draw_bobs(); |
58 | + set_draw_bobs(value); |
59 | + toggle_bobs_->set_perm_pressed(value); |
60 | +} |
61 | + |
62 | bool EditorInteractive::handle_key(bool const down, SDL_Keysym const code) { |
63 | - bool handled = InteractiveBase::handle_key(down, code); |
64 | - |
65 | if (down) { |
66 | - // only on down events |
67 | - |
68 | switch (code.sym) { |
69 | // Sel radius |
70 | case SDLK_1: |
71 | - set_sel_radius_and_update_menu(0); |
72 | - handled = true; |
73 | - break; |
74 | + if (code.mod & (KMOD_CTRL)) { |
75 | + toggle_buildhelp(); |
76 | + } else { |
77 | + set_sel_radius_and_update_menu(0); |
78 | + } |
79 | + return true; |
80 | case SDLK_2: |
81 | - set_sel_radius_and_update_menu(1); |
82 | - handled = true; |
83 | - break; |
84 | + if (code.mod & (KMOD_CTRL)) { |
85 | + toggle_immovables(); |
86 | + } else { |
87 | + set_sel_radius_and_update_menu(1); |
88 | + } |
89 | + return true; |
90 | case SDLK_3: |
91 | - set_sel_radius_and_update_menu(2); |
92 | - handled = true; |
93 | - break; |
94 | + if (code.mod & (KMOD_CTRL)) { |
95 | + toggle_bobs(); |
96 | + } else { |
97 | + set_sel_radius_and_update_menu(2); |
98 | + } |
99 | + return true; |
100 | case SDLK_4: |
101 | - set_sel_radius_and_update_menu(3); |
102 | - handled = true; |
103 | - break; |
104 | + if (code.mod & (KMOD_CTRL)) { |
105 | + toggle_resources(); |
106 | + } else { |
107 | + set_sel_radius_and_update_menu(3); |
108 | + } |
109 | + return true; |
110 | case SDLK_5: |
111 | set_sel_radius_and_update_menu(4); |
112 | - handled = true; |
113 | - break; |
114 | + return true; |
115 | case SDLK_6: |
116 | set_sel_radius_and_update_menu(5); |
117 | - handled = true; |
118 | - break; |
119 | + return true; |
120 | case SDLK_7: |
121 | set_sel_radius_and_update_menu(6); |
122 | - handled = true; |
123 | - break; |
124 | + return true; |
125 | case SDLK_8: |
126 | set_sel_radius_and_update_menu(7); |
127 | - handled = true; |
128 | - break; |
129 | + return true; |
130 | case SDLK_9: |
131 | set_sel_radius_and_update_menu(8); |
132 | - handled = true; |
133 | - break; |
134 | + return true; |
135 | case SDLK_0: |
136 | if (!(code.mod & KMOD_CTRL)) { |
137 | set_sel_radius_and_update_menu(9); |
138 | - handled = true; |
139 | + return true; |
140 | } |
141 | break; |
142 | |
143 | @@ -394,8 +417,7 @@ |
144 | case SDLK_RSHIFT: |
145 | if (tools_->use_tool == EditorTool::First) |
146 | select_tool(tools_->current(), EditorTool::Second); |
147 | - handled = true; |
148 | - break; |
149 | + return true; |
150 | |
151 | case SDLK_LCTRL: |
152 | case SDLK_RCTRL: |
153 | @@ -405,80 +427,62 @@ |
154 | case SDLK_MODE: |
155 | if (tools_->use_tool == EditorTool::First) |
156 | select_tool(tools_->current(), EditorTool::Third); |
157 | - handled = true; |
158 | - break; |
159 | + return true; |
160 | |
161 | case SDLK_SPACE: |
162 | toggle_buildhelp(); |
163 | - handled = true; |
164 | - break; |
165 | + return true; |
166 | |
167 | case SDLK_c: |
168 | set_display_flag( |
169 | InteractiveBase::dfShowCensus, !get_display_flag(InteractiveBase::dfShowCensus)); |
170 | - handled = true; |
171 | - break; |
172 | + return true; |
173 | |
174 | case SDLK_h: |
175 | mainmenu_.toggle(); |
176 | - handled = true; |
177 | - break; |
178 | + return true; |
179 | |
180 | case SDLK_i: |
181 | select_tool(tools_->info, EditorTool::First); |
182 | - handled = true; |
183 | - break; |
184 | + return true; |
185 | |
186 | case SDLK_l: |
187 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) |
188 | new MainMenuLoadMap(*this); |
189 | - handled = true; |
190 | - break; |
191 | + return true; |
192 | |
193 | case SDLK_m: |
194 | minimap_registry().toggle(); |
195 | - handled = true; |
196 | - break; |
197 | + return true; |
198 | |
199 | case SDLK_p: |
200 | playermenu_.toggle(); |
201 | - handled = true; |
202 | - break; |
203 | - |
204 | - case SDLK_q: |
205 | - toggle_resources(); |
206 | - handled = true; |
207 | - break; |
208 | + return true; |
209 | |
210 | case SDLK_s: |
211 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) |
212 | new MainMenuSaveMap(*this); |
213 | - handled = true; |
214 | - break; |
215 | + return true; |
216 | |
217 | case SDLK_t: |
218 | toolmenu_.toggle(); |
219 | - handled = true; |
220 | - break; |
221 | + return true; |
222 | |
223 | case SDLK_y: |
224 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) |
225 | history_->redo_action(egbase().world()); |
226 | - handled = true; |
227 | - break; |
228 | + return true; |
229 | |
230 | case SDLK_z: |
231 | if ((code.mod & (KMOD_LCTRL | KMOD_RCTRL)) && (code.mod & (KMOD_LSHIFT | KMOD_RSHIFT))) |
232 | history_->redo_action(egbase().world()); |
233 | else if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) |
234 | history_->undo_action(egbase().world()); |
235 | - handled = true; |
236 | - break; |
237 | + return true; |
238 | |
239 | case SDLK_F1: |
240 | helpmenu_.toggle(); |
241 | - handled = true; |
242 | - break; |
243 | + return true; |
244 | |
245 | default: |
246 | break; |
247 | @@ -496,13 +500,12 @@ |
248 | case SDLK_MODE: |
249 | if (tools_->use_tool != EditorTool::First) |
250 | select_tool(tools_->current(), EditorTool::First); |
251 | - handled = true; |
252 | - break; |
253 | + return true; |
254 | default: |
255 | break; |
256 | } |
257 | } |
258 | - return handled; |
259 | + return InteractiveBase::handle_key(down, code); |
260 | } |
261 | |
262 | void EditorInteractive::select_tool(EditorTool& primary, EditorTool::ToolIndex const which) { |
263 | |
264 | === modified file 'src/editor/editorinteractive.h' |
265 | --- src/editor/editorinteractive.h 2017-08-14 09:06:04 +0000 |
266 | +++ src/editor/editorinteractive.h 2017-08-16 05:34:38 +0000 |
267 | @@ -157,6 +157,8 @@ |
268 | void on_buildhelp_changed(const bool value) override; |
269 | |
270 | void toggle_resources(); |
271 | + void toggle_immovables(); |
272 | + void toggle_bobs(); |
273 | |
274 | // state variables |
275 | bool need_save_; |
276 | @@ -181,6 +183,8 @@ |
277 | |
278 | UI::Button* toggle_buildhelp_; |
279 | UI::Button* toggle_resources_; |
280 | + UI::Button* toggle_immovables_; |
281 | + UI::Button* toggle_bobs_; |
282 | UI::Button* undo_; |
283 | UI::Button* redo_; |
284 | |
285 | |
286 | === modified file 'src/graphic/game_renderer.cc' |
287 | --- src/graphic/game_renderer.cc 2017-08-13 20:47:55 +0000 |
288 | +++ src/graphic/game_renderer.cc 2017-08-16 05:34:38 +0000 |
289 | @@ -96,7 +96,7 @@ |
290 | return brightness / 255.; |
291 | } |
292 | |
293 | -void draw_objects_for_visible_field(const EditorGameBase& egbase, |
294 | +void draw_immovables_for_visible_field(const EditorGameBase& egbase, |
295 | const FieldsToDraw::Field& field, |
296 | const float zoom, |
297 | const TextToDraw text_to_draw, |
298 | @@ -111,10 +111,17 @@ |
299 | draw_text_for_this_immovable = |
300 | static_cast<TextToDraw>(draw_text_for_this_immovable & ~TextToDraw::kStatistics); |
301 | } |
302 | - |
303 | imm->draw( |
304 | egbase.get_gametime(), draw_text_for_this_immovable, field.rendertarget_pixel, zoom, dst); |
305 | } |
306 | +} |
307 | + |
308 | +void draw_bobs_for_visible_field(const EditorGameBase& egbase, |
309 | + const FieldsToDraw::Field& field, |
310 | + const float zoom, |
311 | + const TextToDraw text_to_draw, |
312 | + const Player* player, |
313 | + RenderTarget* dst) { |
314 | for (Bob* bob = field.fcoords.field->get_first_bob(); bob; bob = bob->get_next_bob()) { |
315 | TextToDraw draw_text_for_this_bob = text_to_draw; |
316 | const Player* owner = bob->get_owner(); |
317 | @@ -127,7 +134,7 @@ |
318 | } |
319 | } |
320 | |
321 | -void draw_objects_for_formerly_visible_field(const FieldsToDraw::Field& field, |
322 | +void draw_immovables_for_formerly_visible_field(const FieldsToDraw::Field& field, |
323 | const Player::Field& player_field, |
324 | const float zoom, |
325 | RenderTarget* dst) { |
326 | @@ -209,6 +216,8 @@ |
327 | const FieldsToDraw& fields_to_draw, |
328 | const Player* player, |
329 | const TextToDraw text_to_draw, |
330 | + const GameRenderer::DrawImmovables& draw_immovables, |
331 | + const GameRenderer::DrawBobs& draw_bobs, |
332 | RenderTarget* dst) { |
333 | for (size_t current_index = 0; current_index < fields_to_draw.size(); ++current_index) { |
334 | const FieldsToDraw::Field& field = fields_to_draw.at(current_index); |
335 | @@ -220,7 +229,7 @@ |
336 | const FieldsToDraw::Field& bln = fields_to_draw.at(field.bln_index); |
337 | const FieldsToDraw::Field& brn = fields_to_draw.at(field.brn_index); |
338 | |
339 | - if (field.is_border) { |
340 | + if (field.is_border && draw_immovables == GameRenderer::DrawImmovables::kYes) { |
341 | assert(field.owner != nullptr); |
342 | uint32_t const anim_idx = field.owner->tribe().frontier_animation(); |
343 | if (field.vision) { |
344 | @@ -237,14 +246,19 @@ |
345 | } |
346 | |
347 | if (1 < field.vision) { // Render stuff that belongs to the node. |
348 | - draw_objects_for_visible_field(egbase, field, zoom, text_to_draw, player, dst); |
349 | - } else if (field.vision == 1) { |
350 | + if (draw_immovables == GameRenderer::DrawImmovables::kYes) { |
351 | + draw_immovables_for_visible_field(egbase, field, zoom, text_to_draw, player, dst); |
352 | + } |
353 | + if (draw_bobs == GameRenderer::DrawBobs::kYes) { |
354 | + draw_bobs_for_visible_field(egbase, field, zoom, text_to_draw, player, dst); |
355 | + } |
356 | + } else if (field.vision == 1 && draw_immovables == GameRenderer::DrawImmovables::kYes) { |
357 | // We never show census or statistics for objects in the fog. |
358 | assert(player != nullptr); |
359 | const Map& map = egbase.map(); |
360 | const Player::Field& player_field = |
361 | player->fields()[map.get_index(field.fcoords, map.get_width())]; |
362 | - draw_objects_for_formerly_visible_field(field, player_field, zoom, dst); |
363 | + draw_immovables_for_formerly_visible_field(field, player_field, zoom, dst); |
364 | } |
365 | |
366 | egbase.get_ibase()->field_overlay_manager().foreach_overlay( |
367 | @@ -271,21 +285,25 @@ |
368 | const Widelands::Player& player, |
369 | const Overlays& overlays, |
370 | RenderTarget* dst) { |
371 | - draw(egbase, viewpoint, zoom, overlays, &player, dst); |
372 | + draw(egbase, viewpoint, zoom, overlays, DrawImmovables::kYes, DrawBobs::kYes, &player, dst); |
373 | } |
374 | |
375 | void GameRenderer::rendermap(const Widelands::EditorGameBase& egbase, |
376 | const Vector2f& viewpoint, |
377 | const float zoom, |
378 | const Overlays& overlays, |
379 | + const DrawImmovables& draw_immovables, |
380 | + const DrawBobs& draw_bobs, |
381 | RenderTarget* dst) { |
382 | - draw(egbase, viewpoint, zoom, overlays, nullptr, dst); |
383 | + draw(egbase, viewpoint, zoom, overlays, draw_immovables, draw_bobs, nullptr, dst); |
384 | } |
385 | |
386 | void GameRenderer::draw(const EditorGameBase& egbase, |
387 | const Vector2f& viewpoint, |
388 | const float zoom, |
389 | const Overlays& overlays, |
390 | + const DrawImmovables& draw_immovables, |
391 | + const DrawBobs& draw_bobs, |
392 | const Player* player, |
393 | RenderTarget* dst) { |
394 | assert(viewpoint.x >= 0); // divisions involving negative numbers are bad |
395 | @@ -410,5 +428,6 @@ |
396 | i.program_id = RenderQueue::Program::kTerrainRoad; |
397 | RenderQueue::instance().enqueue(i); |
398 | |
399 | - draw_objects(egbase, scale, fields_to_draw_, player, overlays.text_to_draw, dst); |
400 | + draw_objects(egbase, scale, fields_to_draw_, player, overlays.text_to_draw, draw_immovables, |
401 | + draw_bobs, dst); |
402 | } |
403 | |
404 | === modified file 'src/graphic/game_renderer.h' |
405 | --- src/graphic/game_renderer.h 2017-08-12 20:13:24 +0000 |
406 | +++ src/graphic/game_renderer.h 2017-08-16 05:34:38 +0000 |
407 | @@ -43,6 +43,9 @@ |
408 | std::map<Widelands::Coords, uint8_t> road_building_preview; |
409 | }; |
410 | |
411 | + enum class DrawImmovables { kNo, kYes }; |
412 | + enum class DrawBobs { kNo, kYes }; |
413 | + |
414 | GameRenderer(); |
415 | ~GameRenderer(); |
416 | |
417 | @@ -57,11 +60,14 @@ |
418 | RenderTarget* dst); |
419 | |
420 | // Renders the map from an omniscient perspective. This is used |
421 | - // for spectators, players that see all, and in the editor. |
422 | + // for spectators, players that see all, and in the editor. Only in the editor we allow toggling |
423 | + // of immovables and bobs. |
424 | void rendermap(const Widelands::EditorGameBase& egbase, |
425 | const Vector2f& viewpoint, |
426 | float scale, |
427 | const Overlays& overlays, |
428 | + const DrawImmovables& draw_immovables, |
429 | + const DrawBobs& draw_bobs, |
430 | RenderTarget* dst); |
431 | |
432 | private: |
433 | @@ -71,6 +77,8 @@ |
434 | const Vector2f& viewpoint, |
435 | float scale, |
436 | const Overlays& overlays, |
437 | + const DrawImmovables& draw_immovables, |
438 | + const DrawBobs& draw_bobs, |
439 | const Widelands::Player* player, |
440 | RenderTarget* dst); |
441 | |
442 | |
443 | === modified file 'src/wui/interactive_base.cc' |
444 | --- src/wui/interactive_base.cc 2017-08-15 07:47:21 +0000 |
445 | +++ src/wui/interactive_base.cc 2017-08-16 05:34:38 +0000 |
446 | @@ -93,6 +93,8 @@ |
447 | lastframe_(SDL_GetTicks()), |
448 | frametime_(0), |
449 | avg_usframetime_(0), |
450 | + draw_immovables_(true), |
451 | + draw_bobs_(true), |
452 | road_buildhelp_overlay_jobid_(0), |
453 | buildroad_(nullptr), |
454 | road_build_player_(0), |
455 | @@ -223,6 +225,22 @@ |
456 | on_buildhelp_changed(t); |
457 | } |
458 | |
459 | +bool InteractiveBase::draw_bobs() const { |
460 | + return draw_bobs_; |
461 | +} |
462 | + |
463 | +void InteractiveBase::set_draw_bobs(const bool value) { |
464 | + draw_bobs_ = value; |
465 | +} |
466 | + |
467 | +bool InteractiveBase::draw_immovables() const { |
468 | + return draw_immovables_; |
469 | +} |
470 | + |
471 | +void InteractiveBase::set_draw_immovables(const bool value) { |
472 | + draw_immovables_ = value; |
473 | +} |
474 | + |
475 | void InteractiveBase::toggle_buildhelp() { |
476 | show_buildhelp(!field_overlay_manager_->buildhelp()); |
477 | } |
478 | |
479 | === modified file 'src/wui/interactive_base.h' |
480 | --- src/wui/interactive_base.h 2017-08-12 08:19:27 +0000 |
481 | +++ src/wui/interactive_base.h 2017-08-16 05:34:38 +0000 |
482 | @@ -100,6 +100,14 @@ |
483 | // Sets if the buildhelp should be displayed. Will also call on_buildhelp_changed(). |
484 | void show_buildhelp(bool t); |
485 | |
486 | + // Returns true if bobs or immovables should be rendered. |
487 | + bool draw_bobs() const; |
488 | + bool draw_immovables() const; |
489 | + |
490 | + // Sets if bobs or immovables should be rendered. |
491 | + void set_draw_bobs(bool value); |
492 | + void set_draw_immovables(bool value); |
493 | + |
494 | /** |
495 | * sel_triangles determines whether the mouse pointer selects triangles. |
496 | * (False meas that it selects nodes.) |
497 | @@ -256,6 +264,8 @@ |
498 | uint32_t lastframe_; // system time (milliseconds) |
499 | uint32_t frametime_; // in millseconds |
500 | uint32_t avg_usframetime_; // in microseconds! |
501 | + bool draw_immovables_; |
502 | + bool draw_bobs_; |
503 | |
504 | FieldOverlayManager::OverlayId road_buildhelp_overlay_jobid_; |
505 | Widelands::CoordPath* buildroad_; // path for the new road |
506 | |
507 | === modified file 'src/wui/mapview.cc' |
508 | --- src/wui/mapview.cc 2017-08-12 20:13:24 +0000 |
509 | +++ src/wui/mapview.cc 2017-08-16 05:34:38 +0000 |
510 | @@ -407,8 +407,13 @@ |
511 | renderer_->rendermap( |
512 | egbase, view_.viewpoint, view_.zoom, interactive_player->player(), overlays, &dst); |
513 | } else { |
514 | + const auto draw_immovables = intbase().draw_immovables() ? |
515 | + GameRenderer::DrawImmovables::kYes : |
516 | + GameRenderer::DrawImmovables::kNo; |
517 | + const auto draw_bobs = |
518 | + intbase().draw_bobs() ? GameRenderer::DrawBobs::kYes : GameRenderer::DrawBobs::kNo; |
519 | const GameRenderer::Overlays overlays{static_cast<TextToDraw>(text_to_draw), {}}; |
520 | - renderer_->rendermap(egbase, view_.viewpoint, view_.zoom, overlays, &dst); |
521 | + renderer_->rendermap(egbase, view_.viewpoint, view_.zoom, overlays, draw_immovables, draw_bobs, &dst); |
522 | } |
523 | } |
524 |
Very nice! I don't see a technical problem which hasn't been there in the unmodified program. :)
When I look into the specs of this task, however, there is no mention of the Animals class. So with your implementation we actually are dealing with an over-fulfillment of the task.
When I was designing the task, I didn't think of the Animals as something different to Immovables, probably because they don't move in the editor and better handling of the editor was my only purpose. We have to re-think. Anyways, short-key 'a' was targeted for the Animals tool and hence is placed falsely here (for the VIEW). I surmise we should discuss this matter in the task thread first and then continue here.