Merge lp:~alocritani/widelands/bug984165 into lp:widelands

Proposed by Angelo Locritani
Status: Merged
Merged at revision: 6352
Proposed branch: lp:~alocritani/widelands/bug984165
Merge into: lp:widelands
Diff against target: 126 lines (+40/-15)
2 files modified
src/wui/waresqueuedisplay.cc (+37/-15)
src/wui/waresqueuedisplay.h (+3/-0)
To merge this branch: bzr merge lp:~alocritani/widelands/bug984165
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+102756@code.launchpad.net

Description of the change

I've made the max fill buttons repeatable
also disabled them when wares queue is completely full or completely empty

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/wui/waresqueuedisplay.cc'
--- src/wui/waresqueuedisplay.cc 2012-02-15 21:25:34 +0000
+++ src/wui/waresqueuedisplay.cc 2012-04-20 19:45:30 +0000
@@ -52,6 +52,7 @@
52m_max_fill_indicator(g_gr->get_picture(PicMod_Game, pic_max_fill_indicator)),52m_max_fill_indicator(g_gr->get_picture(PicMod_Game, pic_max_fill_indicator)),
53m_cache_size(queue->get_max_size()),53m_cache_size(queue->get_max_size()),
54m_cache_filled(queue->get_filled()),54m_cache_filled(queue->get_filled()),
55m_cache_max_fill(queue->get_max_fill()),
55m_total_height(0),56m_total_height(0),
56m_show_only(show_only)57m_show_only(show_only)
57{58{
@@ -115,6 +116,13 @@
115116
116 if (static_cast<uint32_t>(m_queue->get_filled()) != m_cache_filled)117 if (static_cast<uint32_t>(m_queue->get_filled()) != m_cache_filled)
117 update();118 update();
119
120 if (static_cast<uint32_t>(m_queue->get_max_fill()) != m_cache_max_fill) {
121 m_cache_max_fill = m_queue->get_max_fill();
122 compute_max_fill_buttons_enabled_state();
123 update();
124 }
125
118}126}
119127
120/**128/**
@@ -126,6 +134,7 @@
126 return;134 return;
127135
128 m_cache_filled = m_queue->get_filled();136 m_cache_filled = m_queue->get_filled();
137 m_cache_max_fill = m_queue->get_max_fill();
129138
130 uint32_t nr_wares_to_draw = std::min(m_cache_filled, m_cache_size);139 uint32_t nr_wares_to_draw = std::min(m_cache_filled, m_cache_size);
131 uint32_t nr_empty_to_draw = m_cache_size - nr_wares_to_draw;140 uint32_t nr_empty_to_draw = m_cache_size - nr_wares_to_draw;
@@ -217,6 +226,9 @@
217void WaresQueueDisplay::update_max_fill_buttons() {226void WaresQueueDisplay::update_max_fill_buttons() {
218 delete m_increase_max_fill;227 delete m_increase_max_fill;
219 delete m_decrease_max_fill;228 delete m_decrease_max_fill;
229 m_increase_max_fill = 0;
230 m_decrease_max_fill = 0;
231
220 if (m_cache_size <= 0 or m_show_only)232 if (m_cache_size <= 0 or m_show_only)
221 return;233 return;
222234
@@ -242,12 +254,10 @@
242 m_increase_max_fill->sigclicked.connect254 m_increase_max_fill->sigclicked.connect
243 (boost::bind(&WaresQueueDisplay::increase_max_fill_clicked, boost::ref(*this)));255 (boost::bind(&WaresQueueDisplay::increase_max_fill_clicked, boost::ref(*this)));
244256
245 // Disable those buttons for replay watchers257 m_increase_max_fill->set_repeating(true);
246 bool const can_act = m_igb.can_act(m_building.owner().player_number());258 m_decrease_max_fill->set_repeating(true);
247 if (not can_act) {259 compute_max_fill_buttons_enabled_state();
248 m_increase_max_fill->set_enabled(false);260
249 m_decrease_max_fill->set_enabled(false);
250 }
251}261}
252262
253/**263/**
@@ -278,23 +288,35 @@
278 */288 */
279void WaresQueueDisplay::decrease_max_fill_clicked()289void WaresQueueDisplay::decrease_max_fill_clicked()
280{290{
281 uint32_t cur = m_queue->get_max_fill();291 assert (m_cache_max_fill > 0);
282
283 if (cur <= 0)
284 return;
285292
286 m_igb.game().send_player_set_ware_max_fill293 m_igb.game().send_player_set_ware_max_fill
287 (m_building, m_ware_index, cur - 1);294 (m_building, m_ware_index, m_cache_max_fill - 1);
295
288}296}
289297
290void WaresQueueDisplay::increase_max_fill_clicked()298void WaresQueueDisplay::increase_max_fill_clicked()
291{299{
292 uint32_t cur = m_queue->get_max_fill();
293300
294 if (cur >= m_queue->get_max_size())301 assert (m_cache_max_fill < m_queue->get_max_size());
295 return;
296302
297 m_igb.game().send_player_set_ware_max_fill303 m_igb.game().send_player_set_ware_max_fill
298 (m_building, m_ware_index, cur + 1);304 (m_building, m_ware_index, m_cache_max_fill + 1);
305
306}
307
308void WaresQueueDisplay::compute_max_fill_buttons_enabled_state()
309{
310
311 // Disable those buttons for replay watchers
312 bool const can_act = m_igb.can_act(m_building.owner().player_number());
313 if (not can_act) {
314 if (m_increase_max_fill) m_increase_max_fill->set_enabled(false);
315 if (m_decrease_max_fill) m_decrease_max_fill->set_enabled(false);
316 } else {
317
318 if (m_decrease_max_fill) m_decrease_max_fill->set_enabled(m_cache_max_fill > 0);
319 if (m_increase_max_fill) m_increase_max_fill->set_enabled(m_cache_max_fill < m_queue->get_max_size());
320 }
299}321}
300322
301323
=== modified file 'src/wui/waresqueuedisplay.h'
--- src/wui/waresqueuedisplay.h 2012-02-15 21:25:34 +0000
+++ src/wui/waresqueuedisplay.h 2012-04-20 19:45:30 +0000
@@ -82,6 +82,7 @@
8282
83 uint32_t m_cache_size;83 uint32_t m_cache_size;
84 uint32_t m_cache_filled;84 uint32_t m_cache_filled;
85 uint32_t m_cache_max_fill;
85 uint32_t m_total_height;86 uint32_t m_total_height;
86 bool m_show_only;87 bool m_show_only;
8788
@@ -91,6 +92,8 @@
91 void decrease_max_fill_clicked();92 void decrease_max_fill_clicked();
92 void increase_max_fill_clicked();93 void increase_max_fill_clicked();
93 void radiogroup_changed(int32_t);94 void radiogroup_changed(int32_t);
95
96 void compute_max_fill_buttons_enabled_state();
94};97};
9598
96#endif // _WARESQUEUEDISPLAY_H_99#endif // _WARESQUEUEDISPLAY_H_

Subscribers

People subscribed via source and target branches

to status/vote changes: