Add Lua support for clickable gui2 elements.

Patch #2763.
This commit is contained in:
Mark de Wever 2011-11-01 21:12:12 +00:00
parent ba4e903ea5
commit 8dfe599e9e
2 changed files with 12 additions and 2 deletions

View file

@ -40,6 +40,8 @@ Version 1.9.9+svn:
* The side metatable provides also the side number
(like wesnoth.sides[i].side, which would be i)
* add function wesnoth.debug
* Added: Support for clickables (button and repeating button) to
wesnoth.set_dialog_callback (patch #2763).
* Terrain:
* Oasis may be placed on any terrain, aliased to base
* New terrain macro: MOUNTAIN_SINGLE_RANDOM

View file

@ -59,6 +59,7 @@
#include "unit.hpp"
#include "ai/lua/core.hpp"
#include "version.hpp"
#include "gui/widgets/clickable.hpp"
#ifdef GUI2_EXPERIMENTAL_LISTBOX
#include "gui/widgets/list.hpp"
#else
@ -3019,8 +3020,15 @@ static int intf_set_dialog_callback(lua_State *L)
if (lua_isnil(L, 1)) return 0;
if (gui2::tclickable_ *c = dynamic_cast<gui2::tclickable_ *>(w)) {
static tdialog_callback_wrapper wrapper;
c->connect_click_handler(boost::bind(
&tdialog_callback_wrapper::forward
, wrapper
, w));
}
#ifdef GUI2_EXPERIMENTAL_LISTBOX
if (gui2::tlist *l = dynamic_cast<gui2::tlist *>(w)) {
else if (gui2::tlist *l = dynamic_cast<gui2::tlist *>(w)) {
static tdialog_callback_wrapper wrapper;
connect_signal_notify_modified(*l
, boost::bind(
@ -3029,7 +3037,7 @@ static int intf_set_dialog_callback(lua_State *L)
, w));
}
#else
if (gui2::tlistbox *l = dynamic_cast<gui2::tlistbox *>(w)) {
else if (gui2::tlistbox *l = dynamic_cast<gui2::tlistbox *>(w)) {
l->set_callback_value_change(&dialog_callback);
}
#endif