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
1=== modified file 'src/wui/waresqueuedisplay.cc'
2--- src/wui/waresqueuedisplay.cc 2012-02-15 21:25:34 +0000
3+++ src/wui/waresqueuedisplay.cc 2012-04-20 19:45:30 +0000
4@@ -52,6 +52,7 @@
5 m_max_fill_indicator(g_gr->get_picture(PicMod_Game, pic_max_fill_indicator)),
6 m_cache_size(queue->get_max_size()),
7 m_cache_filled(queue->get_filled()),
8+m_cache_max_fill(queue->get_max_fill()),
9 m_total_height(0),
10 m_show_only(show_only)
11 {
12@@ -115,6 +116,13 @@
13
14 if (static_cast<uint32_t>(m_queue->get_filled()) != m_cache_filled)
15 update();
16+
17+ if (static_cast<uint32_t>(m_queue->get_max_fill()) != m_cache_max_fill) {
18+ m_cache_max_fill = m_queue->get_max_fill();
19+ compute_max_fill_buttons_enabled_state();
20+ update();
21+ }
22+
23 }
24
25 /**
26@@ -126,6 +134,7 @@
27 return;
28
29 m_cache_filled = m_queue->get_filled();
30+ m_cache_max_fill = m_queue->get_max_fill();
31
32 uint32_t nr_wares_to_draw = std::min(m_cache_filled, m_cache_size);
33 uint32_t nr_empty_to_draw = m_cache_size - nr_wares_to_draw;
34@@ -217,6 +226,9 @@
35 void WaresQueueDisplay::update_max_fill_buttons() {
36 delete m_increase_max_fill;
37 delete m_decrease_max_fill;
38+ m_increase_max_fill = 0;
39+ m_decrease_max_fill = 0;
40+
41 if (m_cache_size <= 0 or m_show_only)
42 return;
43
44@@ -242,12 +254,10 @@
45 m_increase_max_fill->sigclicked.connect
46 (boost::bind(&WaresQueueDisplay::increase_max_fill_clicked, boost::ref(*this)));
47
48- // Disable those buttons for replay watchers
49- bool const can_act = m_igb.can_act(m_building.owner().player_number());
50- if (not can_act) {
51- m_increase_max_fill->set_enabled(false);
52- m_decrease_max_fill->set_enabled(false);
53- }
54+ m_increase_max_fill->set_repeating(true);
55+ m_decrease_max_fill->set_repeating(true);
56+ compute_max_fill_buttons_enabled_state();
57+
58 }
59
60 /**
61@@ -278,23 +288,35 @@
62 */
63 void WaresQueueDisplay::decrease_max_fill_clicked()
64 {
65- uint32_t cur = m_queue->get_max_fill();
66-
67- if (cur <= 0)
68- return;
69+ assert (m_cache_max_fill > 0);
70
71 m_igb.game().send_player_set_ware_max_fill
72- (m_building, m_ware_index, cur - 1);
73+ (m_building, m_ware_index, m_cache_max_fill - 1);
74+
75 }
76
77 void WaresQueueDisplay::increase_max_fill_clicked()
78 {
79- uint32_t cur = m_queue->get_max_fill();
80
81- if (cur >= m_queue->get_max_size())
82- return;
83+ assert (m_cache_max_fill < m_queue->get_max_size());
84
85 m_igb.game().send_player_set_ware_max_fill
86- (m_building, m_ware_index, cur + 1);
87+ (m_building, m_ware_index, m_cache_max_fill + 1);
88+
89+}
90+
91+void WaresQueueDisplay::compute_max_fill_buttons_enabled_state()
92+{
93+
94+ // Disable those buttons for replay watchers
95+ bool const can_act = m_igb.can_act(m_building.owner().player_number());
96+ if (not can_act) {
97+ if (m_increase_max_fill) m_increase_max_fill->set_enabled(false);
98+ if (m_decrease_max_fill) m_decrease_max_fill->set_enabled(false);
99+ } else {
100+
101+ if (m_decrease_max_fill) m_decrease_max_fill->set_enabled(m_cache_max_fill > 0);
102+ if (m_increase_max_fill) m_increase_max_fill->set_enabled(m_cache_max_fill < m_queue->get_max_size());
103+ }
104 }
105
106
107=== modified file 'src/wui/waresqueuedisplay.h'
108--- src/wui/waresqueuedisplay.h 2012-02-15 21:25:34 +0000
109+++ src/wui/waresqueuedisplay.h 2012-04-20 19:45:30 +0000
110@@ -82,6 +82,7 @@
111
112 uint32_t m_cache_size;
113 uint32_t m_cache_filled;
114+ uint32_t m_cache_max_fill;
115 uint32_t m_total_height;
116 bool m_show_only;
117
118@@ -91,6 +92,8 @@
119 void decrease_max_fill_clicked();
120 void increase_max_fill_clicked();
121 void radiogroup_changed(int32_t);
122+
123+ void compute_max_fill_buttons_enabled_state();
124 };
125
126 #endif // _WARESQUEUEDISPLAY_H_

Subscribers

People subscribed via source and target branches

to status/vote changes: