widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #00747
[Merge] lp:~alocritani/widelands/bug984165 into lp:widelands
Angelo Locritani has proposed merging lp:~alocritani/widelands/bug984165 into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #984165 in widelands: "Make the increase/reduce wares buttons repeatable"
https://bugs.launchpad.net/widelands/+bug/984165
For more details, see:
https://code.launchpad.net/~alocritani/widelands/bug984165/+merge/102756
I've made the max fill buttons repeatable
also disabled them when wares queue is completely full or completely empty
--
https://code.launchpad.net/~alocritani/widelands/bug984165/+merge/102756
Your team Widelands Developers is requested to review the proposed merge of lp:~alocritani/widelands/bug984165 into lp:widelands.
=== modified file 'src/wui/waresqueuedisplay.cc'
--- src/wui/waresqueuedisplay.cc 2012-02-15 21:25:34 +0000
+++ src/wui/waresqueuedisplay.cc 2012-04-19 19:54:21 +0000
@@ -52,6 +52,7 @@
m_max_fill_indicator(g_gr->get_picture(PicMod_Game, pic_max_fill_indicator)),
m_cache_size(queue->get_max_size()),
m_cache_filled(queue->get_filled()),
+m_cache_max_fill(queue->get_max_fill()),
m_total_height(0),
m_show_only(show_only)
{
@@ -115,6 +116,12 @@
if (static_cast<uint32_t>(m_queue->get_filled()) != m_cache_filled)
update();
+
+ if (static_cast<uint32_t>(m_queue->get_max_fill()) != m_cache_max_fill) {
+ compute_max_fill_buttons_enabled_state();
+ update();
+ }
+
}
/**
@@ -126,6 +133,7 @@
return;
m_cache_filled = m_queue->get_filled();
+ m_cache_max_fill = m_queue->get_max_fill();
uint32_t nr_wares_to_draw = std::min(m_cache_filled, m_cache_size);
uint32_t nr_empty_to_draw = m_cache_size - nr_wares_to_draw;
@@ -217,6 +225,9 @@
void WaresQueueDisplay::update_max_fill_buttons() {
delete m_increase_max_fill;
delete m_decrease_max_fill;
+ m_increase_max_fill = 0;
+ m_decrease_max_fill = 0;
+
if (m_cache_size <= 0 or m_show_only)
return;
@@ -242,12 +253,10 @@
m_increase_max_fill->sigclicked.connect
(boost::bind(&WaresQueueDisplay::increase_max_fill_clicked, boost::ref(*this)));
- // Disable those buttons for replay watchers
- bool const can_act = m_igb.can_act(m_building.owner().player_number());
- if (not can_act) {
- m_increase_max_fill->set_enabled(false);
- m_decrease_max_fill->set_enabled(false);
- }
+ m_increase_max_fill->set_repeating(true);
+ m_decrease_max_fill->set_repeating(true);
+ compute_max_fill_buttons_enabled_state();
+
}
/**
@@ -280,21 +289,37 @@
{
uint32_t cur = m_queue->get_max_fill();
- if (cur <= 0)
- return;
+ assert (cur > 0);
m_igb.game().send_player_set_ware_max_fill
(m_building, m_ware_index, cur - 1);
+
}
void WaresQueueDisplay::increase_max_fill_clicked()
{
uint32_t cur = m_queue->get_max_fill();
- if (cur >= m_queue->get_max_size())
- return;
+ assert (cur < m_queue->get_max_size());
m_igb.game().send_player_set_ware_max_fill
(m_building, m_ware_index, cur + 1);
+
+}
+
+void WaresQueueDisplay::compute_max_fill_buttons_enabled_state()
+{
+
+ // Disable those buttons for replay watchers
+ bool const can_act = m_igb.can_act(m_building.owner().player_number());
+ if (not can_act) {
+ if (m_increase_max_fill) m_increase_max_fill->set_enabled(false);
+ if (m_decrease_max_fill) m_decrease_max_fill->set_enabled(false);
+ } else {
+ uint32_t cur = m_queue->get_max_fill();
+
+ if (m_decrease_max_fill) m_decrease_max_fill->set_enabled(cur > 0);
+ if (m_increase_max_fill) m_increase_max_fill->set_enabled(cur < m_queue->get_max_size());
+ }
}
=== modified file 'src/wui/waresqueuedisplay.h'
--- src/wui/waresqueuedisplay.h 2012-02-15 21:25:34 +0000
+++ src/wui/waresqueuedisplay.h 2012-04-19 19:54:21 +0000
@@ -82,6 +82,7 @@
uint32_t m_cache_size;
uint32_t m_cache_filled;
+ uint32_t m_cache_max_fill;
uint32_t m_total_height;
bool m_show_only;
@@ -91,6 +92,8 @@
void decrease_max_fill_clicked();
void increase_max_fill_clicked();
void radiogroup_changed(int32_t);
+
+ void compute_max_fill_buttons_enabled_state();
};
#endif // _WARESQUEUEDISPLAY_H_
Follow ups