Merge lp:~nomeata/widelands/726139 into lp:widelands

Proposed by Joachim Breitner
Status: Merged
Merged at revision: 6435
Proposed branch: lp:~nomeata/widelands/726139
Merge into: lp:widelands
Diff against target: 79 lines (+13/-2)
4 files modified
src/logic/warelist.cc (+4/-0)
src/logic/warelist.h (+5/-0)
src/wui/stock_menu.cc (+0/-2)
src/wui/waresdisplay.cc (+4/-0)
To merge this branch: bzr merge lp:~nomeata/widelands/726139
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+131704@code.launchpad.net

Description of the change

I have pushed a branch that implements updating of WaresDisplay (e.g. in a warehouse) using a boost::signal. The code is very straight forward; the effect though is very nice and slick – when a worker enters the building it updates so fast that I don’t even see the number changing.

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 directory 'build'
2=== target is u'/tmp/build'
3=== modified file 'src/logic/warelist.cc'
4--- src/logic/warelist.cc 2012-02-15 21:25:34 +0000
5+++ src/logic/warelist.cc 2012-10-26 23:12:24 +0000
6@@ -50,6 +50,8 @@
7 m_wares.resize(i.value() + 1, 0);
8 m_wares[i] += count;
9 assert(m_wares[i] >= count);
10+
11+ changed();
12 }
13
14
15@@ -74,6 +76,8 @@
16 assert(i.value() < m_wares.size());
17 assert(m_wares[i] >= count);
18 m_wares[i] -= count;
19+
20+ changed();
21 }
22
23
24
25=== modified file 'src/logic/warelist.h'
26--- src/logic/warelist.h 2012-07-13 20:46:30 +0000
27+++ src/logic/warelist.h 2012-10-26 23:12:24 +0000
28@@ -22,6 +22,9 @@
29
30 #include "widelands.h"
31
32+#include <boost/signal.hpp>
33+#include <boost/bind.hpp>
34+
35 #include <SDL.h>
36
37 #include <cassert>
38@@ -60,6 +63,8 @@
39 bool operator== (WareList const &) const;
40 bool operator!= (WareList const & wl) const {return not (*this == wl);}
41
42+ mutable boost::signal<void ()> changed;
43+
44 private:
45 vector_type m_wares;
46 };
47
48=== modified file 'src/wui/stock_menu.cc'
49--- src/wui/stock_menu.cc 2012-02-15 21:25:34 +0000
50+++ src/wui/stock_menu.cc 2012-10-26 23:12:24 +0000
51@@ -40,8 +40,6 @@
52 UI::UniqueWindow(&plr, "stock_menu", &registry, 640, 480, _("Stock")),
53 m_player(plr)
54 {
55- set_cache(false);
56-
57 UI::Tab_Panel * tabs =
58 new UI::Tab_Panel
59 (this, 0, 0, g_gr->get_picture(PicMod_UI, "pics/but1.png"));
60
61=== modified file 'src/wui/waresdisplay.cc'
62--- src/wui/waresdisplay.cc 2012-07-11 18:18:07 +0000
63+++ src/wui/waresdisplay.cc 2012-10-26 23:12:24 +0000
64@@ -156,6 +156,7 @@
65
66 void WaresDisplay::remove_all_warelists() {
67 m_warelists.clear();
68+ update();
69 }
70
71
72@@ -345,6 +346,9 @@
73 {
74 // If you register something twice, it is counted twice. Not my problem.
75 m_warelists.push_back(&wares);
76+
77+ wares.changed.connect(boost::bind(&WaresDisplay::update, boost::ref(*this)));
78+ update();
79 }
80
81

Subscribers

People subscribed via source and target branches

to status/vote changes: