Merge lp:~widelands-dev/widelands/remove_update into lp:widelands

Proposed by SirVer
Status: Merged
Merged at revision: 7758
Proposed branch: lp:~widelands-dev/widelands/remove_update
Merge into: lp:widelands
Diff against target: 1233 lines (+20/-280)
34 files modified
src/editor/ui_menus/editor_tool_menu.cc (+0/-1)
src/graphic/graphic.cc (+0/-19)
src/graphic/graphic.h (+0/-5)
src/logic/map_objects/tribes/production_program.cc (+1/-1)
src/ui_basic/button.cc (+1/-11)
src/ui_basic/checkbox.cc (+0/-7)
src/ui_basic/editbox.cc (+0/-13)
src/ui_basic/icon.cc (+0/-1)
src/ui_basic/listselect.cc (+0/-7)
src/ui_basic/multilineeditbox.cc (+0/-8)
src/ui_basic/multilinetextarea.cc (+0/-6)
src/ui_basic/panel.cc (+13/-102)
src/ui_basic/panel.h (+0/-3)
src/ui_basic/progressbar.cc (+0/-4)
src/ui_basic/progresswindow.cc (+1/-3)
src/ui_basic/scrollbar.cc (+0/-5)
src/ui_basic/slider.cc (+1/-17)
src/ui_basic/table.cc (+0/-8)
src/ui_basic/tabpanel.cc (+0/-7)
src/ui_basic/textarea.cc (+0/-2)
src/ui_basic/window.cc (+0/-1)
src/wui/game_message_menu.cc (+0/-3)
src/wui/game_summary.cc (+0/-1)
src/wui/game_tips.cc (+0/-2)
src/wui/interactive_base.cc (+0/-5)
src/wui/itemwaresdisplay.cc (+1/-5)
src/wui/mapview.cc (+0/-2)
src/wui/minimap.cc (+0/-2)
src/wui/productionsitewindow.cc (+0/-1)
src/wui/soldierlist.cc (+0/-1)
src/wui/waresdisplay.cc (+0/-14)
src/wui/waresdisplay.h (+0/-3)
src/wui/waresqueuedisplay.cc (+2/-9)
src/wui/waresqueuedisplay.h (+0/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/remove_update
Reviewer Review Type Date Requested Status
GunChleoc testing Approve
Review via email: mp+284524@code.launchpad.net

Commit message

Removed graphic::update() and Panel::update() and always redraw at maxfps.
Changed default maxfps to 30 (instead of 25).

Description of the change

The UI kept track of changes that happened - if you did not move the mouse in a menu, it would not redraw the screen. That was nice, because it meant that Widelands would not eat any CPU in a menu. Ingame we always redraw at maxfps anyways, so this request does not change anything there.

Keeping track of the dirty state has a lot of complexity though - each widget has to remember to call update() when it needs to be redrawn. Even worse, in-game, each widget needs to get reminded to update if some external state changes. That is easy to get wrong.

This change makes Widelands use more CPU in menus when you do not interact with the game (13% CPU vs 3% before on my system, but if you move the mouse it is equal), but it makes the code easier to reason about and less prone to bugs. A lot of the widgets could now be written much simpler - since they do not need to try to cache state (for example WaresQueueDisplay). It seems to me that it should go in, but I am not sure.

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

Hi, I am bunnybot (https://github.com/widelands/bunnybot).

I am keeping the source branch lp:~widelands-dev/widelands/remove_update mirrored to https://github.com/widelands/widelands/tree/_widelands_dev_widelands_remove_update

You can give me commands by starting a line with @bunnybot <command>. I understand:
 merge: Merges the source branch into the target branch, closing the merge proposal. I will use the proposed commit message if it is set.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 453. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/105948529.
Appveyor build 350. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_remove_update-350.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I find update annoying and difficult too, so I'm all for it. I expect that the added CPU load won't increase for long games, so I think we can afford the extra CPU time - the recent graphics changes have already saved a lot, so we'll still be better off than we were before you started working on the graphics.

Code LGTM, just 1 question. Not tested yet.

review: Approve (code)
Revision history for this message
GunChleoc (gunchleoc) wrote :

I have tested this now - everything seems ok.

review: Approve (testing)
Revision history for this message
SirVer (sirver) wrote :

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

Running 'bzr merge ../_widelands_dev_widelands_remove_update' failed. Output:

 M src/editor/ui_menus/editor_tool_menu.cc
 M src/graphic/graphic.cc
 M src/graphic/graphic.h
 M src/logic/map_objects/tribes/production_program.cc
 M src/ui_basic/button.cc
 M src/ui_basic/checkbox.cc
 M src/ui_basic/editbox.cc
 M src/ui_basic/icon.cc
 M src/ui_basic/listselect.cc
 M src/ui_basic/multilineeditbox.cc
 M src/ui_basic/multilinetextarea.cc
 M src/ui_basic/panel.cc
 M src/ui_basic/panel.h
 M src/ui_basic/progressbar.cc
 M src/ui_basic/progresswindow.cc
 M src/ui_basic/scrollbar.cc
 M src/ui_basic/slider.cc
 M src/ui_basic/table.cc
 M src/ui_basic/tabpanel.cc
 M src/ui_basic/textarea.cc
 M src/ui_basic/window.cc
 M src/wui/game_message_menu.cc
 M src/wui/game_summary.cc
 M src/wui/game_tips.cc
 M src/wui/interactive_base.cc
 M src/wui/itemwaresdisplay.cc
 M src/wui/mapview.cc
 M src/wui/minimap.cc
 M src/wui/productionsitewindow.cc
 M src/wui/soldierlist.cc
 M src/wui/waresdisplay.cc
 M src/wui/waresdisplay.h
 M src/wui/waresqueuedisplay.cc
 M src/wui/waresqueuedisplay.h
Text conflict in src/ui_basic/editbox.cc
1 conflicts encountered.

Revision history for this message
SirVer (sirver) wrote :

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/editor/ui_menus/editor_tool_menu.cc'
--- src/editor/ui_menus/editor_tool_menu.cc 2016-01-18 19:35:25 +0000
+++ src/editor/ui_menus/editor_tool_menu.cc 2016-01-31 14:49:41 +0000
@@ -152,7 +152,6 @@
152 parent.mutable_field_overlay_manager()->register_overlay_callback_function(152 parent.mutable_field_overlay_manager()->register_overlay_callback_function(
153 boost::bind(&editor_Tool_set_port_space_callback, _1, boost::ref(map)));153 boost::bind(&editor_Tool_set_port_space_callback, _1, boost::ref(map)));
154 map.recalc_whole_map(parent.egbase().world());154 map.recalc_whole_map(parent.egbase().world());
155 update();
156 }155 }
157156
158 if (current_registry_pointer) {157 if (current_registry_pointer) {
159158
=== modified file 'src/graphic/graphic.cc'
--- src/graphic/graphic.cc 2016-01-28 07:00:21 +0000
+++ src/graphic/graphic.cc 2016-01-31 14:49:41 +0000
@@ -76,7 +76,6 @@
76 bool init_fullscreen) {76 bool init_fullscreen) {
77 window_mode_width_ = window_mode_w;77 window_mode_width_ = window_mode_w;
78 window_mode_height_ = window_mode_h;78 window_mode_height_ = window_mode_h;
79 requires_update_ = true;
8079
81 if (SDL_GL_LoadLibrary(nullptr) == -1) {80 if (SDL_GL_LoadLibrary(nullptr) == -1) {
82 throw wexception("SDL_GL_LoadLibrary failed: %s", SDL_GetError());81 throw wexception("SDL_GL_LoadLibrary failed: %s", SDL_GetError());
@@ -169,8 +168,6 @@
169 render_target_.reset(new RenderTarget(screen_.get()));168 render_target_.reset(new RenderTarget(screen_.get()));
170169
171 Notifications::publish(GraphicResolutionChanged{new_w, new_h});170 Notifications::publish(GraphicResolutionChanged{new_w, new_h});
172
173 update();
174}171}
175172
176/**173/**
@@ -214,18 +211,6 @@
214 resolution_changed();211 resolution_changed();
215}212}
216213
217
218void Graphic::update() {
219 requires_update_ = true;
220}
221
222/**
223 * Returns true if parts of the screen have been marked for refreshing.
224*/
225bool Graphic::need_update() const {
226 return requires_update_;
227}
228
229/**214/**
230 * Bring the screen uptodate.215 * Bring the screen uptodate.
231*/216*/
@@ -255,7 +240,6 @@
255 }240 }
256241
257 SDL_GL_SwapWindow(sdl_window_);242 SDL_GL_SwapWindow(sdl_window_);
258 requires_update_ = false;
259}243}
260244
261/**245/**
@@ -264,7 +248,4 @@
264void Graphic::screenshot(const string& fname)248void Graphic::screenshot(const string& fname)
265{249{
266 screenshot_filename_ = fname;250 screenshot_filename_ = fname;
267
268 // Force a redraw of the screen soon.
269 update();
270}251}
271252
=== modified file 'src/graphic/graphic.h'
--- src/graphic/graphic.h 2016-01-24 12:43:26 +0000
+++ src/graphic/graphic.h 2016-01-31 14:49:41 +0000
@@ -71,8 +71,6 @@
71 void set_fullscreen(bool);71 void set_fullscreen(bool);
7272
73 RenderTarget * get_render_target();73 RenderTarget * get_render_target();
74 void update();
75 bool need_update() const;
76 void refresh();74 void refresh();
77 SDL_Window* get_sdlwindow() {return sdl_window_;}75 SDL_Window* get_sdlwindow() {return sdl_window_;}
7876
@@ -103,9 +101,6 @@
103 /// A RenderTarget for screen_. This is initialized during init()101 /// A RenderTarget for screen_. This is initialized during init()
104 std::unique_ptr<RenderTarget> render_target_;102 std::unique_ptr<RenderTarget> render_target_;
105103
106 /// This marks the complete screen for updating.
107 bool requires_update_;
108
109 /// Non-volatile cache of independent images.104 /// Non-volatile cache of independent images.
110 std::unique_ptr<ImageCache> image_cache_;105 std::unique_ptr<ImageCache> image_cache_;
111106
112107
=== modified file 'src/logic/map_objects/tribes/production_program.cc'
--- src/logic/map_objects/tribes/production_program.cc 2016-01-24 07:45:11 +0000
+++ src/logic/map_objects/tribes/production_program.cc 2016-01-31 14:49:41 +0000
@@ -121,7 +121,7 @@
121 } else if (*p != *pattern)121 } else if (*p != *pattern)
122 return false;122 return false;
123123
124 return false;124 NEVER_HERE();
125}125}
126126
127ProductionProgram::ActReturn::Condition * create_economy_condition127ProductionProgram::ActReturn::Condition * create_economy_condition
128128
=== modified file 'src/ui_basic/button.cc'
--- src/ui_basic/button.cc 2015-11-28 14:19:26 +0000
+++ src/ui_basic/button.cc 2016-01-31 14:49:41 +0000
@@ -107,8 +107,6 @@
107 return;107 return;
108108
109 m_pic_custom = pic;109 m_pic_custom = pic;
110
111 update();
112}110}
113111
114112
@@ -121,8 +119,6 @@
121119
122 m_pic_custom = nullptr;120 m_pic_custom = nullptr;
123 m_title = title;121 m_title = title;
124
125 update();
126}122}
127123
128124
@@ -147,7 +143,6 @@
147 m_enabled = false;143 m_enabled = false;
148 m_highlighted = false;144 m_highlighted = false;
149 }145 }
150 update();
151}146}
152147
153148
@@ -319,8 +314,6 @@
319 sigmousein();314 sigmousein();
320 else315 else
321 sigmouseout();316 sigmouseout();
322
323 update();
324}317}
325318
326319
@@ -340,10 +333,9 @@
340 set_thinks(true);333 set_thinks(true);
341 }334 }
342 }335 }
343 update();
344
345 return true;336 return true;
346}337}
338
347bool Button::handle_mouserelease(uint8_t const btn, int32_t, int32_t) {339bool Button::handle_mouserelease(uint8_t const btn, int32_t, int32_t) {
348 if (btn != SDL_BUTTON_LEFT)340 if (btn != SDL_BUTTON_LEFT)
349 return false;341 return false;
@@ -352,7 +344,6 @@
352 m_pressed = false;344 m_pressed = false;
353 set_thinks(false);345 set_thinks(false);
354 grab_mouse(false);346 grab_mouse(false);
355 update();
356 if (m_highlighted && m_enabled) {347 if (m_highlighted && m_enabled) {
357 play_click();348 play_click();
358 sigclicked();349 sigclicked();
@@ -372,7 +363,6 @@
372void Button::set_perm_pressed(bool state) {363void Button::set_perm_pressed(bool state) {
373 if (state != m_permpressed) {364 if (state != m_permpressed) {
374 m_permpressed = state;365 m_permpressed = state;
375 update();
376 }366 }
377}367}
378368
379369
=== modified file 'src/ui_basic/checkbox.cc'
--- src/ui_basic/checkbox.cc 2015-12-17 09:36:59 +0000
+++ src/ui_basic/checkbox.cc 2016-01-31 14:49:41 +0000
@@ -98,8 +98,6 @@
98 set_flags98 set_flags
99 (Is_Highlighted, (m_flags & Is_Highlighted) && (m_flags & Is_Enabled));99 (Is_Highlighted, (m_flags & Is_Highlighted) && (m_flags & Is_Enabled));
100 }100 }
101
102 update();
103}101}
104102
105103
@@ -113,7 +111,6 @@
113 set_flags(Is_Checked, on);111 set_flags(Is_Checked, on);
114 changed();112 changed();
115 changedto(on);113 changedto(on);
116 update();
117 }114 }
118}115}
119116
@@ -170,11 +167,7 @@
170 * Highlight the checkbox when the mouse moves into it167 * Highlight the checkbox when the mouse moves into it
171 */168 */
172void Statebox::handle_mousein(bool const inside) {169void Statebox::handle_mousein(bool const inside) {
173 bool oldhl = m_flags & Is_Highlighted;
174 set_flags(Is_Highlighted, inside && (m_flags & Is_Enabled));170 set_flags(Is_Highlighted, inside && (m_flags & Is_Enabled));
175
176 if (oldhl != (m_flags & Is_Highlighted))
177 update();
178}171}
179172
180173
181174
=== modified file 'src/ui_basic/editbox.cc'
--- src/ui_basic/editbox.cc 2016-01-29 08:50:22 +0000
+++ src/ui_basic/editbox.cc 2016-01-31 14:49:41 +0000
@@ -134,8 +134,6 @@
134 m->text.erase(m->text.begin() + m->maxLength, m->text.end());134 m->text.erase(m->text.begin() + m->maxLength, m->text.end());
135 if (caretatend || m->caret > m->text.size())135 if (caretatend || m->caret > m->text.size())
136 m->caret = m->text.size();136 m->caret = m->text.size();
137
138 update();
139}137}
140138
141139
@@ -164,7 +162,6 @@
164 m->caret = m->text.size();162 m->caret = m->text.size();
165163
166 check_caret();164 check_caret();
167 update();
168 }165 }
169}166}
170167
@@ -176,7 +173,6 @@
176{173{
177 if (btn == SDL_BUTTON_LEFT && get_can_focus()) {174 if (btn == SDL_BUTTON_LEFT && get_can_focus()) {
178 focus();175 focus();
179 update();
180 return true;176 return true;
181 }177 }
182178
@@ -238,7 +234,6 @@
238 m->text.erase(m->text.begin() + m->caret);234 m->text.erase(m->text.begin() + m->caret);
239 check_caret();235 check_caret();
240 changed();236 changed();
241 update();
242 }237 }
243 return true;238 return true;
244239
@@ -256,8 +251,6 @@
256 break;251 break;
257252
258 check_caret();253 check_caret();
259
260 update();
261 }254 }
262 return true;255 return true;
263256
@@ -281,7 +274,6 @@
281 }274 }
282275
283 check_caret();276 check_caret();
284 update();
285 }277 }
286 return true;278 return true;
287279
@@ -295,7 +287,6 @@
295 m->caret = 0;287 m->caret = 0;
296288
297 check_caret();289 check_caret();
298 update();
299 }290 }
300 return true;291 return true;
301292
@@ -308,7 +299,6 @@
308 if (m->caret != m->text.size()) {299 if (m->caret != m->text.size()) {
309 m->caret = m->text.size();300 m->caret = m->text.size();
310 check_caret();301 check_caret();
311 update();
312 }302 }
313 return true;303 return true;
314304
@@ -326,7 +316,6 @@
326 m->text = m_history[m_history_position];316 m->text = m_history[m_history_position];
327 m->caret = m->text.size();317 m->caret = m->text.size();
328 check_caret();318 check_caret();
329 update();
330 }319 }
331 }320 }
332 return true;321 return true;
@@ -345,7 +334,6 @@
345 m->text = m_history[m_history_position];334 m->text = m_history[m_history_position];
346 m->caret = m->text.size();335 m->caret = m->text.size();
347 check_caret();336 check_caret();
348 update();
349 }337 }
350 }338 }
351 return true;339 return true;
@@ -364,7 +352,6 @@
364 m->caret += input_text.length();352 m->caret += input_text.length();
365 check_caret();353 check_caret();
366 changed();354 changed();
367 update();
368 }355 }
369 return true;356 return true;
370}357}
371358
=== modified file 'src/ui_basic/icon.cc'
--- src/ui_basic/icon.cc 2014-12-04 09:00:20 +0000
+++ src/ui_basic/icon.cc 2016-01-31 14:49:41 +0000
@@ -38,7 +38,6 @@
3838
39void Icon::set_icon(const Image* picture_id) {39void Icon::set_icon(const Image* picture_id) {
40 m_pic = picture_id;40 m_pic = picture_id;
41 update();
42}41}
4342
44void Icon::set_frame(const RGBColor& color)43void Icon::set_frame(const RGBColor& color)
4544
=== modified file 'src/ui_basic/listselect.cc'
--- src/ui_basic/listselect.cc 2016-01-28 21:27:04 +0000
+++ src/ui_basic/listselect.cc 2016-01-31 14:49:41 +0000
@@ -152,8 +152,6 @@
152152
153 m_scrollbar.set_steps(m_entry_records.size() * get_lineheight() - get_h());153 m_scrollbar.set_steps(m_entry_records.size() * get_lineheight() - get_h());
154154
155 update(0, 0, get_w(), get_h());
156
157 if (sel)155 if (sel)
158 select(m_entry_records.size() - 1);156 select(m_entry_records.size() - 1);
159}157}
@@ -194,8 +192,6 @@
194192
195 m_scrollbar.set_steps(m_entry_records.size() * get_lineheight() - get_h());193 m_scrollbar.set_steps(m_entry_records.size() * get_lineheight() - get_h());
196194
197 update(0, 0, get_w(), get_h());
198
199 if (sel)195 if (sel)
200 select(0);196 select(0);
201}197}
@@ -254,8 +250,6 @@
254 return;250 return;
255251
256 m_scrollpos = i;252 m_scrollpos = i;
257
258 update(0, 0, get_w(), get_h());
259}253}
260254
261255
@@ -291,7 +285,6 @@
291 m_selection = i;285 m_selection = i;
292286
293 selected(m_selection);287 selected(m_selection);
294 update(0, 0, get_w(), get_h());
295}288}
296289
297/**290/**
298291
=== modified file 'src/ui_basic/multilineeditbox.cc'
--- src/ui_basic/multilineeditbox.cc 2016-01-28 21:27:04 +0000
+++ src/ui_basic/multilineeditbox.cc 2016-01-31 14:49:41 +0000
@@ -122,7 +122,6 @@
122void MultilineEditbox::Data::update()122void MultilineEditbox::Data::update()
123{123{
124 ww_valid = false;124 ww_valid = false;
125 owner.update();
126}125}
127126
128/**127/**
@@ -443,7 +442,6 @@
443 */442 */
444void MultilineEditbox::focus(bool topcaller) {443void MultilineEditbox::focus(bool topcaller) {
445 Panel::focus(topcaller);444 Panel::focus(topcaller);
446 update();
447}445}
448446
449/**447/**
@@ -499,8 +497,6 @@
499void MultilineEditbox::Data::insert(uint32_t where, const std::string & s)497void MultilineEditbox::Data::insert(uint32_t where, const std::string & s)
500{498{
501 text.insert(where, s);499 text.insert(where, s);
502 update();
503
504 if (cursor_pos >= where)500 if (cursor_pos >= where)
505 set_cursor_pos(cursor_pos + s.size());501 set_cursor_pos(cursor_pos + s.size());
506}502}
@@ -517,7 +513,6 @@
517 return;513 return;
518514
519 cursor_pos = newpos;515 cursor_pos = newpos;
520 owner.update();
521516
522 scroll_cursor_into_view();517 scroll_cursor_into_view();
523}518}
@@ -538,10 +533,8 @@
538533
539 if (top < int32_t(scrollbar.get_scrollpos())) {534 if (top < int32_t(scrollbar.get_scrollpos())) {
540 scrollbar.set_scrollpos(top - lineheight);535 scrollbar.set_scrollpos(top - lineheight);
541 owner.update();
542 } else if (top + lineheight > int32_t(scrollbar.get_scrollpos()) + owner.get_h()) {536 } else if (top + lineheight > int32_t(scrollbar.get_scrollpos()) + owner.get_h()) {
543 scrollbar.set_scrollpos(top - owner.get_h() + 2 * lineheight);537 scrollbar.set_scrollpos(top - owner.get_h() + 2 * lineheight);
544 owner.update();
545 }538 }
546}539}
547540
@@ -550,7 +543,6 @@
550 */543 */
551void MultilineEditbox::scrollpos_changed(int32_t)544void MultilineEditbox::scrollpos_changed(int32_t)
552{545{
553 update();
554}546}
555547
556/**548/**
557549
=== modified file 'src/ui_basic/multilinetextarea.cc'
--- src/ui_basic/multilinetextarea.cc 2016-01-29 08:50:22 +0000
+++ src/ui_basic/multilinetextarea.cc 2016-01-31 14:49:41 +0000
@@ -59,8 +59,6 @@
59 m_scrollbar.set_force_draw(always_show_scrollbar);59 m_scrollbar.set_force_draw(always_show_scrollbar);
6060
61 recompute();61 recompute();
62
63 update(0, 0, get_eff_w(), get_h());
64}62}
6563
6664
@@ -113,8 +111,6 @@
113 break; // No need to wrap twice.111 break; // No need to wrap twice.
114 }112 }
115 }113 }
116
117 update(0, 0, get_eff_w(), get_h());
118}114}
119115
120/**116/**
@@ -122,7 +118,6 @@
122 */118 */
123void MultilineTextarea::scrollpos_changed(int32_t const /* pixels */)119void MultilineTextarea::scrollpos_changed(int32_t const /* pixels */)
124{120{
125 update(0, 0, get_eff_w(), get_h());
126}121}
127122
128/**123/**
@@ -194,7 +189,6 @@
194189
195void MultilineTextarea::scroll_to_top() {190void MultilineTextarea::scroll_to_top() {
196 m_scrollbar.set_scrollpos(0);191 m_scrollbar.set_scrollpos(0);
197 update(0, 0, 0, 0);
198}192}
199193
200} // namespace UI194} // namespace UI
201195
=== modified file 'src/ui_basic/panel.cc'
--- src/ui_basic/panel.cc 2016-01-27 08:06:40 +0000
+++ src/ui_basic/panel.cc 2016-01-31 14:49:41 +0000
@@ -73,7 +73,6 @@
73 _parent->_fchild = this;73 _parent->_fchild = this;
74 } else74 } else
75 _prev = _next = nullptr;75 _prev = _next = nullptr;
76 update(0, 0, _w, _h);
77}76}
7877
79/**78/**
@@ -81,8 +80,6 @@
81 */80 */
82Panel::~Panel()81Panel::~Panel()
83{82{
84 update();
85
86 // Release pointers to this object83 // Release pointers to this object
87 if (_g_mousegrab == this)84 if (_g_mousegrab == this)
88 _g_mousegrab = nullptr;85 _g_mousegrab = nullptr;
@@ -150,15 +147,9 @@
150147
151 // Panel-specific startup code. This might call end_modal()!148 // Panel-specific startup code. This might call end_modal()!
152 start();149 start();
153 g_gr->update();
154150
155 uint32_t minTime;151 const uint32_t minimum_frame_time =
156 {152 1000 / std::max(5, g_options.pull_section("global").get_int("maxfps", 30));
157 int maxfps = g_options.pull_section("global").get_int("maxfps", 25);
158 if (maxfps < 5)
159 maxfps = 5;
160 minTime = 1000 / maxfps;
161 }
162153
163 while (_running) {154 while (_running) {
164 const uint32_t startTime = SDL_GetTicks();155 const uint32_t startTime = SDL_GetTicks();
@@ -178,32 +169,22 @@
178169
179 do_think();170 do_think();
180171
181 if (g_gr->need_update()) {172 RenderTarget& rt = *g_gr->get_render_target();
182 RenderTarget & rt = *g_gr->get_render_target();173 forefather->do_draw(rt);
183174 rt.blit(app->get_mouse_position() - Point(3, 7),
184 forefather->do_draw(rt);175 WLApplication::get()->is_mouse_pressed() ? s_default_cursor_click : s_default_cursor);
185176 forefather->do_tooltip();
186 rt.blit177 g_gr->refresh();
187 (app->get_mouse_position() - Point(3, 7),
188 WLApplication::get()->is_mouse_pressed() ?
189 s_default_cursor_click :
190 s_default_cursor);
191
192 forefather->do_tooltip();
193
194 g_gr->refresh();
195 }
196178
197 if (_flags & pf_child_die)179 if (_flags & pf_child_die)
198 check_child_death();180 check_child_death();
199181
200 // Wait until 1second/maxfps are over.182 // Wait until 1second/maxfps are over.
201 const uint32_t diffTime = SDL_GetTicks() - startTime;183 const uint32_t frame_time = SDL_GetTicks() - startTime;
202 if (diffTime < minTime) {184 if (frame_time < minimum_frame_time) {
203 SDL_Delay(minTime - diffTime);185 SDL_Delay(minimum_frame_time - frame_time);
204 }186 }
205 }187 }
206 g_gr->update();
207 end();188 end();
208189
209 // Done190 // Done
@@ -242,8 +223,6 @@
242 if (nw == _w && nh == _h)223 if (nw == _w && nh == _h)
243 return;224 return;
244225
245 int const upw = std::min(nw, _w);
246 int const uph = std::min(nh, _h);
247 _w = nw;226 _w = nw;
248 _h = nh;227 _h = nh;
249228
@@ -251,18 +230,14 @@
251 move_inside_parent();230 move_inside_parent();
252231
253 layout();232 layout();
254
255 update(0, 0, upw, uph);
256}233}
257234
258/**235/**
259 * Move the panel. Panel's position is relative to the parent.236 * Move the panel. Panel's position is relative to the parent.
260 */237 */
261void Panel::set_pos(const Point n) {238void Panel::set_pos(const Point n) {
262 update(0, 0, _w, _h);
263 _x = n.x;239 _x = n.x;
264 _y = n.y;240 _y = n.y;
265 update(0, 0, _w, _h);
266}241}
267242
268/**243/**
@@ -383,7 +358,6 @@
383 _rborder = r;358 _rborder = r;
384 _tborder = t;359 _tborder = t;
385 _bborder = b;360 _bborder = b;
386 update();
387}361}
388362
389/**363/**
@@ -425,8 +399,6 @@
425 _flags &= ~pf_visible;399 _flags &= ~pf_visible;
426 if (on)400 if (on)
427 _flags |= pf_visible;401 _flags |= pf_visible;
428
429 update(0, 0, _w, _h);
430}402}
431403
432/**404/**
@@ -447,63 +419,6 @@
447*/419*/
448void Panel::draw_overlay(RenderTarget &) {}420void Panel::draw_overlay(RenderTarget &) {}
449421
450
451/**
452 * Mark a part of a panel for updating.
453 */
454void Panel::update(int x, int y, int w, int h)
455{
456 if
457 (x >= _w || x + w <= 0
458 ||
459 y >= _h || y + h <= 0)
460 return;
461
462 if (_parent) {
463 _parent->update_inner(x + _x, y + _y, w, h);
464 } else {
465 if (x < 0) {
466 w += x;
467 x = 0;
468 }
469 if (x + w > g_gr->get_xres())
470 w = g_gr->get_xres() - x;
471 if (w <= 0)
472 return;
473
474 if (y < 0) {
475 h += y;
476 y = 0;
477 }
478 if (y + h > g_gr->get_yres())
479 h = g_gr->get_yres() - y;
480 if (h <= 0)
481 return;
482
483 g_gr->update();
484 }
485}
486
487
488/**
489 * Overload for convenience.
490 *
491 * Equivalent to update(0, 0, get_w(), get_h());
492 */
493void Panel::update()
494{
495 update(0, 0, get_w(), get_h());
496}
497
498
499/**
500 * Mark a part of a panel for updating.
501 */
502void Panel::update_inner(int32_t x, int32_t y, int32_t w, int32_t h)
503{
504 update(x - _lborder, y - _tborder, w, h);
505}
506
507/**422/**
508 * Called once per event loop pass, unless set_think(false) has423 * Called once per event loop pass, unless set_think(false) has
509 * been called. It is intended to be used for animations and game logic.424 * been called. It is intended to be used for animations and game logic.
@@ -627,7 +542,6 @@
627 while (p != _focus) {542 while (p != _focus) {
628 if (p->get_can_focus()) {543 if (p->get_can_focus()) {
629 p->focus();544 p->focus();
630 p->update();
631 break;545 break;
632 }546 }
633 if (p == _lchild) {547 if (p == _lchild) {
@@ -1110,11 +1024,8 @@
1110 return true;1024 return true;
1111 }1025 }
11121026
1113 Panel * p;1027 Panel* const p = ui_trackmouse(x, y);
1114 g_gr->update();1028 if (p == nullptr)
1115
1116 p = ui_trackmouse(x, y);
1117 if (!p)
1118 return false;1029 return false;
11191030
1120 return p->do_mousemove(state, x, y, xdiff, ydiff);1031 return p->do_mousemove(state, x, y, xdiff, ydiff);
11211032
=== modified file 'src/ui_basic/panel.h'
--- src/ui_basic/panel.h 2016-01-27 08:06:40 +0000
+++ src/ui_basic/panel.h 2016-01-31 14:49:41 +0000
@@ -186,9 +186,6 @@
186 virtual void draw (RenderTarget &);186 virtual void draw (RenderTarget &);
187 virtual void draw_border (RenderTarget &);187 virtual void draw_border (RenderTarget &);
188 virtual void draw_overlay(RenderTarget &);188 virtual void draw_overlay(RenderTarget &);
189 void update(int32_t x, int32_t y, int32_t w, int32_t h);
190 void update();
191 void update_inner(int32_t x, int32_t y, int32_t w, int32_t h);
192189
193 // Events190 // Events
194 virtual void think();191 virtual void think();
195192
=== modified file 'src/ui_basic/progressbar.cc'
--- src/ui_basic/progressbar.cc 2015-12-17 09:36:59 +0000
+++ src/ui_basic/progressbar.cc 2016-01-31 14:49:41 +0000
@@ -49,8 +49,6 @@
49void ProgressBar::set_state(uint32_t state)49void ProgressBar::set_state(uint32_t state)
50{50{
51 m_state = state;51 m_state = state;
52
53 update();
54}52}
5553
5654
@@ -61,8 +59,6 @@
61{59{
62 assert(total);60 assert(total);
63 m_total = total;61 m_total = total;
64
65 update();
66}62}
6763
6864
6965
=== modified file 'src/ui_basic/progresswindow.cc'
--- src/ui_basic/progresswindow.cc 2015-12-17 09:36:59 +0000
+++ src/ui_basic/progresswindow.cc 2016-01-31 14:49:41 +0000
@@ -89,7 +89,6 @@
89 m_background = "pics/progress.png";89 m_background = "pics/progress.png";
90 }90 }
91 draw_background(rt, g_gr->get_xres(), g_gr->get_yres());91 draw_background(rt, g_gr->get_xres(), g_gr->get_yres());
92 update(true);
93}92}
9493
95void ProgressWindow::step(const std::string & description) {94void ProgressWindow::step(const std::string & description) {
@@ -106,13 +105,11 @@
106 UI::g_fh1->render(as_uifont(description, UI_FONT_SIZE_SMALL, PROGRESS_FONT_COLOR_FG)),105 UI::g_fh1->render(as_uifont(description, UI_FONT_SIZE_SMALL, PROGRESS_FONT_COLOR_FG)),
107 BlendMode::UseAlpha,106 BlendMode::UseAlpha,
108 UI::Align::kCenter);107 UI::Align::kCenter);
109 g_gr->update();
110108
111#ifdef _WIN32109#ifdef _WIN32
112 // Pump events to prevent "not responding" on windows110 // Pump events to prevent "not responding" on windows
113 SDL_PumpEvents();111 SDL_PumpEvents();
114#endif112#endif
115
116 update(true);113 update(true);
117}114}
118115
@@ -121,6 +118,7 @@
121 visualization->update(repaint); // let visualizations do their work118 visualization->update(repaint); // let visualizations do their work
122 }119 }
123 g_gr->refresh();120 g_gr->refresh();
121
124}122}
125123
126/**124/**
127125
=== modified file 'src/ui_basic/scrollbar.cc'
--- src/ui_basic/scrollbar.cc 2016-01-17 20:04:07 +0000
+++ src/ui_basic/scrollbar.cc 2016-01-31 14:49:41 +0000
@@ -79,7 +79,6 @@
79 set_scrollpos(steps - 1);79 set_scrollpos(steps - 1);
8080
81 m_steps = steps;81 m_steps = steps;
82 update();
83}82}
8483
8584
@@ -136,8 +135,6 @@
136135
137 m_pos = pos;136 m_pos = pos;
138 moved(pos);137 moved(pos);
139
140 update();
141}138}
142139
143140
@@ -428,7 +425,6 @@
428 default:425 default:
429 break;426 break;
430 }427 }
431 update();
432 return result;428 return result;
433}429}
434bool Scrollbar::handle_mouserelease(const uint8_t btn, int32_t, int32_t) {430bool Scrollbar::handle_mouserelease(const uint8_t btn, int32_t, int32_t) {
@@ -446,7 +442,6 @@
446 default:442 default:
447 break;443 break;
448 }444 }
449 update();
450 return result;445 return result;
451}446}
452447
453448
=== modified file 'src/ui_basic/slider.cc'
--- src/ui_basic/slider.cc 2015-12-17 09:36:59 +0000
+++ src/ui_basic/slider.cc 2016-01-31 14:49:41 +0000
@@ -82,7 +82,6 @@
82 m_value = new_value;82 m_value = new_value;
83 calculate_cursor_position();83 calculate_cursor_position();
84 send_value_changed();84 send_value_changed();
85 update();
86 }85 }
87}86}
8887
@@ -115,7 +114,6 @@
115 assert(m_min_value <= new_max);114 assert(m_min_value <= new_max);
116 if (m_max_value != new_max) {115 if (m_max_value != new_max) {
117 calculate_cursor_position();116 calculate_cursor_position();
118 update();
119 }117 }
120 m_max_value = new_max;118 m_max_value = new_max;
121 set_value(m_value);119 set_value(m_value);
@@ -130,7 +128,6 @@
130 assert(m_max_value >= new_min);128 assert(m_max_value >= new_min);
131 if (m_min_value != new_min) {129 if (m_min_value != new_min) {
132 calculate_cursor_position();130 calculate_cursor_position();
133 update();
134 }131 }
135 m_min_value = new_min;132 m_min_value = new_min;
136 set_value(m_value);133 set_value(m_value);
@@ -216,13 +213,11 @@
216 m_highlighted = false;213 m_highlighted = false;
217 grab_mouse(false);214 grab_mouse(false);
218 }215 }
219 update();
220}216}
221217
222218
223/**219/**
224 * Set whether the sliding button should be highlighted,220 * Set whether the sliding button should be highlighted.
225 * and trigger a draw update when necessary.
226 */221 */
227void Slider::set_highlighted(bool highlighted)222void Slider::set_highlighted(bool highlighted)
228{223{
@@ -230,7 +225,6 @@
230 return;225 return;
231226
232 m_highlighted = highlighted;227 m_highlighted = highlighted;
233 update();
234}228}
235229
236230
@@ -260,8 +254,6 @@
260254
261 // cursor position: align to integer value255 // cursor position: align to integer value
262 calculate_cursor_position();256 calculate_cursor_position();
263
264 update();
265 }257 }
266 return true;258 return true;
267}259}
@@ -275,8 +267,6 @@
275 * \param y The y position of the mouse pointer.267 * \param y The y position of the mouse pointer.
276 */268 */
277void Slider::cursor_moved(int32_t pointer, int32_t x, int32_t y) {269void Slider::cursor_moved(int32_t pointer, int32_t x, int32_t y) {
278 int32_t o_cursor_pos = m_cursor_pos;
279
280 if (!m_enabled)270 if (!m_enabled)
281 return;271 return;
282272
@@ -313,9 +303,6 @@
313 m_value = new_value;303 m_value = new_value;
314 send_value_changed();304 send_value_changed();
315 }305 }
316
317 if (o_cursor_pos != m_cursor_pos)
318 update();
319}306}
320307
321308
@@ -334,8 +321,6 @@
334 m_relative_move = pointer - m_cursor_pos;321 m_relative_move = pointer - m_cursor_pos;
335322
336 play_click();323 play_click();
337
338 update();
339}324}
340325
341326
@@ -376,7 +361,6 @@
376 send_value_changed();361 send_value_changed();
377362
378 m_relative_move = ofs;363 m_relative_move = ofs;
379 update();
380}364}
381365
382void VerticalSlider::layout() {366void VerticalSlider::layout() {
383367
=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc 2016-01-29 08:50:22 +0000
+++ src/ui_basic/table.cc 2016-01-31 14:49:41 +0000
@@ -448,7 +448,6 @@
448 if (column.is_checkbox_column) {448 if (column.is_checkbox_column) {
449 play_click();449 play_click();
450 m_entry_records.at(row)->toggle(col);450 m_entry_records.at(row)->toggle(col);
451 update(0, 0, get_eff_w(), get_h());
452 }451 }
453 break;452 break;
454 }453 }
@@ -524,7 +523,6 @@
524 m_selection = i;523 m_selection = i;
525524
526 selected(m_selection);525 selected(m_selection);
527 update(0, 0, get_eff_w(), get_h());
528}526}
529527
530/**528/**
@@ -551,8 +549,6 @@
551 select(m_entry_records.size() - 1);549 select(m_entry_records.size() - 1);
552 m_scrollbar->set_scrollpos(std::numeric_limits<int32_t>::max());550 m_scrollbar->set_scrollpos(std::numeric_limits<int32_t>::max());
553 }551 }
554
555 update(0, 0, get_eff_w(), get_h());
556 return result;552 return result;
557}553}
558554
@@ -562,8 +558,6 @@
562void Table<void *>::set_scrollpos(int32_t const i)558void Table<void *>::set_scrollpos(int32_t const i)
563{559{
564 m_scrollpos = i;560 m_scrollpos = i;
565
566 update(0, 0, get_eff_w(), get_h());
567}561}
568562
569/**563/**
@@ -631,8 +625,6 @@
631 newselection = i;625 newselection = i;
632 }626 }
633 m_selection = newselection;627 m_selection = newselection;
634
635 update();
636}628}
637629
638/**630/**
639631
=== modified file 'src/ui_basic/tabpanel.cc'
--- src/ui_basic/tabpanel.cc 2016-01-28 21:27:04 +0000
+++ src/ui_basic/tabpanel.cc 2016-01-31 14:49:41 +0000
@@ -385,7 +385,6 @@
385void TabPanel::handle_mousein(bool inside)385void TabPanel::handle_mousein(bool inside)
386{386{
387 if (!inside && highlight_ != kNotFound) {387 if (!inside && highlight_ != kNotFound) {
388 update(tabs_[highlight_]->get_x(), 0, tabs_[highlight_]->get_w(), kTabPanelButtonHeight);
389 highlight_ = kNotFound;388 highlight_ = kNotFound;
390 }389 }
391}390}
@@ -400,12 +399,6 @@
400 size_t hl = find_tab(x, y);399 size_t hl = find_tab(x, y);
401400
402 if (hl != highlight_) {401 if (hl != highlight_) {
403 if (hl != kNotFound) {
404 update(tabs_[hl]->get_x(), 0, tabs_[hl]->get_w(), kTabPanelButtonHeight);
405 }
406 if (highlight_ != kNotFound) {
407 update(tabs_[highlight_]->get_x(), 0, tabs_[highlight_]->get_w(), kTabPanelButtonHeight);
408 }
409 highlight_ = hl;402 highlight_ = hl;
410 set_tooltip(highlight_ != kNotFound ? tabs_[highlight_]->tooltip : "");403 set_tooltip(highlight_ != kNotFound ? tabs_[highlight_]->tooltip : "");
411 }404 }
412405
=== modified file 'src/ui_basic/textarea.cc'
--- src/ui_basic/textarea.cc 2016-01-28 21:27:04 +0000
+++ src/ui_basic/textarea.cc 2016-01-31 14:49:41 +0000
@@ -137,8 +137,6 @@
137 expand();137 expand();
138 else if (m_layoutmode == Layouted)138 else if (m_layoutmode == Layouted)
139 update_desired_size();139 update_desired_size();
140
141 update();
142}140}
143141
144const std::string& Textarea::get_text()142const std::string& Textarea::get_text()
145143
=== modified file 'src/ui_basic/window.cc'
--- src/ui_basic/window.cc 2016-01-28 21:27:04 +0000
+++ src/ui_basic/window.cc 2016-01-31 14:49:41 +0000
@@ -110,7 +110,6 @@
110void Window::set_title(const string & text)110void Window::set_title(const string & text)
111{111{
112 m_title = is_richtext(text) ? text : as_window_title(text);112 m_title = is_richtext(text) ? text : as_window_title(text);
113 update(0, 0, get_w(), TP_B_PIXMAP_THICKNESS);
114}113}
115114
116/**115/**
117116
=== modified file 'src/wui/game_message_menu.cc'
--- src/wui/game_message_menu.cc 2016-01-28 21:27:04 +0000
+++ src/wui/game_message_menu.cc 2016-01-31 14:49:41 +0000
@@ -339,9 +339,6 @@
339 if (list->size()) {339 if (list->size()) {
340 if (!list->has_selection())340 if (!list->has_selection())
341 list->select(0);341 list->select(0);
342 // TODO(unknown): Workaround for bug #691928: There should
343 // be a solution without this extra update().
344 list->update();
345 } else {342 } else {
346 centerviewbtn_->set_enabled(false);343 centerviewbtn_->set_enabled(false);
347 message_body.set_text(std::string());344 message_body.set_text(std::string());
348345
=== modified file 'src/wui/game_summary.cc'
--- src/wui/game_summary.cc 2016-01-28 21:27:04 +0000
+++ src/wui/game_summary.cc 2016-01-31 14:49:41 +0000
@@ -218,7 +218,6 @@
218 % static_cast<unsigned int>(teawon_)).str());218 % static_cast<unsigned int>(teawon_)).str());
219 }219 }
220 }220 }
221 players_table_->update();
222 if (!players_status.empty()) {221 if (!players_status.empty()) {
223 players_table_->select(current_player_position);222 players_table_->select(current_player_position);
224 }223 }
225224
=== modified file 'src/wui/game_tips.cc'
--- src/wui/game_tips.cc 2016-01-24 20:11:53 +0000
+++ src/wui/game_tips.cc 2016-01-31 14:49:41 +0000
@@ -119,6 +119,4 @@
119 Point center(tips_area.x + tips_area.w / 2, tips_area.y + tips_area.h / 2);119 Point center(tips_area.x + tips_area.w / 2, tips_area.y + tips_area.h / 2);
120 const Image* rendered_text = UI::g_fh1->render(as_game_tip(tips_[index].text), tips_area.w);120 const Image* rendered_text = UI::g_fh1->render(as_game_tip(tips_[index].text), tips_area.w);
121 rt.blit(center - Point(rendered_text->width() / 2, rendered_text->height() / 2), rendered_text);121 rt.blit(center - Point(rendered_text->width() / 2, rendered_text->height() / 2), rendered_text);
122
123 g_gr->update();
124}122}
125123
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc 2016-01-28 21:27:04 +0000
+++ src/wui/interactive_base.cc 2016-01-31 14:49:41 +0000
@@ -335,13 +335,8 @@
335 set_rel_viewpoint(Point (scrollval, 0), false);335 set_rel_viewpoint(Point (scrollval, 0), false);
336 }336 }
337 }337 }
338
339 egbase().think(); // Call game logic here. The game advances.338 egbase().think(); // Call game logic here. The game advances.
340339
341 // The entire screen needs to be redrawn (unit movement, tile animation,
342 // etc...)
343 g_gr->update();
344
345 UI::Panel::think();340 UI::Panel::think();
346}341}
347342
348343
=== modified file 'src/wui/itemwaresdisplay.cc'
--- src/wui/itemwaresdisplay.cc 2016-01-24 20:11:53 +0000
+++ src/wui/itemwaresdisplay.cc 2016-01-31 14:49:41 +0000
@@ -52,10 +52,7 @@
52 */52 */
53void ItemWaresDisplay::clear()53void ItemWaresDisplay::clear()
54{54{
55 if (!items_.empty()) {55 items_.clear();
56 items_.clear();
57 update();
58 }
59}56}
6057
61/**58/**
@@ -100,7 +97,6 @@
100 it.worker = worker;97 it.worker = worker;
101 it.index = index;98 it.index = index;
102 items_.push_back(it);99 items_.push_back(it);
103 update();
104}100}
105101
106void ItemWaresDisplay::draw(RenderTarget & dst)102void ItemWaresDisplay::draw(RenderTarget & dst)
107103
=== modified file 'src/wui/mapview.cc'
--- src/wui/mapview.cc 2016-01-24 20:11:53 +0000
+++ src/wui/mapview.cc 2016-01-31 14:49:41 +0000
@@ -168,8 +168,6 @@
168168
169 if (!intbase().get_sel_freeze())169 if (!intbase().get_sel_freeze())
170 track_sel(Point(x, y));170 track_sel(Point(x, y));
171
172 g_gr->update();
173 return true;171 return true;
174}172}
175173
176174
=== modified file 'src/wui/minimap.cc'
--- src/wui/minimap.cc 2016-01-24 20:11:53 +0000
+++ src/wui/minimap.cc 2016-01-31 14:49:41 +0000
@@ -54,8 +54,6 @@
54{54{
55 viewx_ = x / TRIANGLE_WIDTH;55 viewx_ = x / TRIANGLE_WIDTH;
56 viewy_ = y / TRIANGLE_HEIGHT;56 viewy_ = y / TRIANGLE_HEIGHT;
57
58 update();
59}57}
6058
6159
6260
=== modified file 'src/wui/productionsitewindow.cc'
--- src/wui/productionsitewindow.cc 2016-01-28 21:27:04 +0000
+++ src/wui/productionsitewindow.cc 2016-01-31 14:49:41 +0000
@@ -202,7 +202,6 @@
202 continue;202 continue;
203 }203 }
204 }204 }
205 worker_table_->update();
206}205}
207206
208void ProductionSiteWindow::evict_worker() {207void ProductionSiteWindow::evict_worker() {
209208
=== modified file 'src/wui/soldierlist.cc'
--- src/wui/soldierlist.cc 2016-01-28 21:27:04 +0000
+++ src/wui/soldierlist.cc 2016-01-31 14:49:41 +0000
@@ -271,7 +271,6 @@
271 if (changes) {271 if (changes) {
272 Point mousepos = get_mouse_position();272 Point mousepos = get_mouse_position();
273 m_mouseover_fn(find_soldier(mousepos.x, mousepos.y));273 m_mouseover_fn(find_soldier(mousepos.x, mousepos.y));
274 update();
275 }274 }
276}275}
277276
278277
=== modified file 'src/wui/waresdisplay.cc'
--- src/wui/waresdisplay.cc 2016-01-28 21:27:04 +0000
+++ src/wui/waresdisplay.cc 2016-01-31 14:49:41 +0000
@@ -260,7 +260,6 @@
260 }260 }
261 }261 }
262 }262 }
263 update();
264}263}
265264
266265
@@ -273,10 +272,6 @@
273272
274void WaresDisplay::remove_all_warelists() {273void WaresDisplay::remove_all_warelists() {
275 warelists_.clear();274 warelists_.clear();
276 for (boost::signals2::connection& c : connections_)
277 c.disconnect();
278 connections_.clear();
279 update();
280}275}
281276
282277
@@ -384,7 +379,6 @@
384 return;379 return;
385380
386 selected_[ware] = true;381 selected_[ware] = true;
387 update();
388 if (callback_function_)382 if (callback_function_)
389 callback_function_(ware, true);383 callback_function_(ware, true);
390}384}
@@ -395,7 +389,6 @@
395 return;389 return;
396390
397 selected_[ware] = false;391 selected_[ware] = false;
398 update();
399 if (callback_function_)392 if (callback_function_)
400 callback_function_(ware, false);393 callback_function_(ware, false);
401}394}
@@ -409,18 +402,14 @@
409{402{
410 if (hidden_[ware])403 if (hidden_[ware])
411 return;404 return;
412
413 hidden_[ware] = true;405 hidden_[ware] = true;
414 update();
415}406}
416407
417void AbstractWaresDisplay::unhide_ware(Widelands::DescriptionIndex ware)408void AbstractWaresDisplay::unhide_ware(Widelands::DescriptionIndex ware)
418{409{
419 if (!hidden_[ware])410 if (!hidden_[ware])
420 return;411 return;
421
422 hidden_[ware] = false;412 hidden_[ware] = false;
423 update();
424}413}
425414
426bool AbstractWaresDisplay::ware_hidden(Widelands::DescriptionIndex ware) {415bool AbstractWaresDisplay::ware_hidden(Widelands::DescriptionIndex ware) {
@@ -463,9 +452,6 @@
463{452{
464 // If you register something twice, it is counted twice. Not my problem.453 // If you register something twice, it is counted twice. Not my problem.
465 warelists_.push_back(&wares);454 warelists_.push_back(&wares);
466
467 connections_.push_back(wares.changed.connect(boost::bind(&WaresDisplay::update, boost::ref(*this))));
468 update();
469}455}
470456
471457
472458
=== modified file 'src/wui/waresdisplay.h'
--- src/wui/waresdisplay.h 2016-01-24 20:11:53 +0000
+++ src/wui/waresdisplay.h 2016-01-31 14:49:41 +0000
@@ -22,8 +22,6 @@
2222
23#include <vector>23#include <vector>
2424
25#include <boost/signals2.hpp>
26
27#include "logic/map_objects/tribes/tribe_descr.h"25#include "logic/map_objects/tribes/tribe_descr.h"
28#include "logic/map_objects/tribes/warelist.h"26#include "logic/map_objects/tribes/warelist.h"
29#include "logic/map_objects/tribes/wareworker.h"27#include "logic/map_objects/tribes/wareworker.h"
@@ -144,7 +142,6 @@
144private:142private:
145 using WareListVector = std::vector<const Widelands::WareList *>;143 using WareListVector = std::vector<const Widelands::WareList *>;
146 WareListVector warelists_;144 WareListVector warelists_;
147 std::vector<boost::signals2::connection> connections_;
148};145};
149146
150std::string waremap_to_richtext147std::string waremap_to_richtext
151148
=== modified file 'src/wui/waresqueuedisplay.cc'
--- src/wui/waresqueuedisplay.cc 2016-01-24 20:11:53 +0000
+++ src/wui/waresqueuedisplay.cc 2016-01-31 14:49:41 +0000
@@ -52,7 +52,6 @@
52ware_type_(Widelands::wwWARE),52ware_type_(Widelands::wwWARE),
53max_fill_indicator_(g_gr->images().get(pic_max_fill_indicator)),53max_fill_indicator_(g_gr->images().get(pic_max_fill_indicator)),
54cache_size_(queue->get_max_size()),54cache_size_(queue->get_max_size()),
55cache_filled_(queue->get_filled()),
56cache_max_fill_(queue->get_max_fill()),55cache_max_fill_(queue->get_max_fill()),
57total_height_(0),56total_height_(0),
58show_only_(show_only)57show_only_(show_only)
@@ -112,15 +111,11 @@
112 if (static_cast<uint32_t>(queue_->get_max_size()) != cache_size_)111 if (static_cast<uint32_t>(queue_->get_max_size()) != cache_size_)
113 max_size_changed();112 max_size_changed();
114113
115 if (static_cast<uint32_t>(queue_->get_filled()) != cache_filled_)114 // TODO(sirver): It seems cache_max_fill_ is not really useful for anything.
116 update();
117
118 if (static_cast<uint32_t>(queue_->get_max_fill()) != cache_max_fill_) {115 if (static_cast<uint32_t>(queue_->get_max_fill()) != cache_max_fill_) {
119 cache_max_fill_ = queue_->get_max_fill();116 cache_max_fill_ = queue_->get_max_fill();
120 compute_max_fill_buttons_enabled_state();117 compute_max_fill_buttons_enabled_state();
121 update();
122 }118 }
123
124}119}
125120
126/**121/**
@@ -131,10 +126,9 @@
131 if (!cache_size_)126 if (!cache_size_)
132 return;127 return;
133128
134 cache_filled_ = queue_->get_filled();
135 cache_max_fill_ = queue_->get_max_fill();129 cache_max_fill_ = queue_->get_max_fill();
136130
137 uint32_t nr_wares_to_draw = std::min(cache_filled_, cache_size_);131 uint32_t nr_wares_to_draw = std::min(queue_->get_filled(), cache_size_);
138 uint32_t nr_empty_to_draw = cache_size_ - nr_wares_to_draw;132 uint32_t nr_empty_to_draw = cache_size_ - nr_wares_to_draw;
139133
140 Point point;134 Point point;
@@ -258,7 +252,6 @@
258 increase_max_fill_->set_repeating(true);252 increase_max_fill_->set_repeating(true);
259 decrease_max_fill_->set_repeating(true);253 decrease_max_fill_->set_repeating(true);
260 compute_max_fill_buttons_enabled_state();254 compute_max_fill_buttons_enabled_state();
261
262}255}
263256
264/**257/**
265258
=== modified file 'src/wui/waresqueuedisplay.h'
--- src/wui/waresqueuedisplay.h 2016-01-24 20:11:53 +0000
+++ src/wui/waresqueuedisplay.h 2016-01-31 14:49:41 +0000
@@ -82,7 +82,6 @@
8282
8383
84 uint32_t cache_size_;84 uint32_t cache_size_;
85 uint32_t cache_filled_;
86 uint32_t cache_max_fill_;85 uint32_t cache_max_fill_;
87 uint32_t total_height_;86 uint32_t total_height_;
88 bool show_only_;87 bool show_only_;

Subscribers

People subscribed via source and target branches

to status/vote changes: