widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #00881
[Merge] lp:~nomeata/widelands/726139 into lp:widelands
Joachim Breitner has proposed merging lp:~nomeata/widelands/726139 into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #726139 in widelands: "Numeric wares display in warehouses not updating correctly"
https://bugs.launchpad.net/widelands/+bug/726139
For more details, see:
https://code.launchpad.net/~nomeata/widelands/726139/+merge/131704
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.
--
https://code.launchpad.net/~nomeata/widelands/726139/+merge/131704
Your team Widelands Developers is requested to review the proposed merge of lp:~nomeata/widelands/726139 into lp:widelands.
=== modified directory 'build'
=== target is u'/tmp/build'
=== modified file 'src/logic/warelist.cc'
--- src/logic/warelist.cc 2012-02-15 21:25:34 +0000
+++ src/logic/warelist.cc 2012-10-26 23:12:24 +0000
@@ -50,6 +50,8 @@
m_wares.resize(i.value() + 1, 0);
m_wares[i] += count;
assert(m_wares[i] >= count);
+
+ changed();
}
@@ -74,6 +76,8 @@
assert(i.value() < m_wares.size());
assert(m_wares[i] >= count);
m_wares[i] -= count;
+
+ changed();
}
=== modified file 'src/logic/warelist.h'
--- src/logic/warelist.h 2012-07-13 20:46:30 +0000
+++ src/logic/warelist.h 2012-10-26 23:12:24 +0000
@@ -22,6 +22,9 @@
#include "widelands.h"
+#include <boost/signal.hpp>
+#include <boost/bind.hpp>
+
#include <SDL.h>
#include <cassert>
@@ -60,6 +63,8 @@
bool operator== (WareList const &) const;
bool operator!= (WareList const & wl) const {return not (*this == wl);}
+ mutable boost::signal<void ()> changed;
+
private:
vector_type m_wares;
};
=== modified file 'src/wui/stock_menu.cc'
--- src/wui/stock_menu.cc 2012-02-15 21:25:34 +0000
+++ src/wui/stock_menu.cc 2012-10-26 23:12:24 +0000
@@ -40,8 +40,6 @@
UI::UniqueWindow(&plr, "stock_menu", ®istry, 640, 480, _("Stock")),
m_player(plr)
{
- set_cache(false);
-
UI::Tab_Panel * tabs =
new UI::Tab_Panel
(this, 0, 0, g_gr->get_picture(PicMod_UI, "pics/but1.png"));
=== modified file 'src/wui/waresdisplay.cc'
--- src/wui/waresdisplay.cc 2012-07-11 18:18:07 +0000
+++ src/wui/waresdisplay.cc 2012-10-26 23:12:24 +0000
@@ -156,6 +156,7 @@
void WaresDisplay::remove_all_warelists() {
m_warelists.clear();
+ update();
}
@@ -345,6 +346,9 @@
{
// If you register something twice, it is counted twice. Not my problem.
m_warelists.push_back(&wares);
+
+ wares.changed.connect(boost::bind(&WaresDisplay::update, boost::ref(*this)));
+ update();
}
Follow ups