Commit graph

120 commits

Author SHA1 Message Date
gfgtdf
cce53d5aa9 fix a compiler warning 2015-09-20 21:47:34 +02:00
Ignacio R. Morelle
48def4ff0a Replace alphanumeric and operator spelling
Some (all?) versions of MSVC++ doesn't like it without including
<ciso646>, and we don't really want to use the alternate operator
spellings anyway.
2015-09-20 06:09:22 -03:00
Celtic Minstrel
e3fc258ce9 Simplify wesnoth.show_message_dialog implementation 2015-09-19 12:13:27 -04:00
Celtic Minstrel
376020097f Port [object] ActionWML tag from C++ to Lua
Lua API additions:
- wesnoth.show_popup_dialog()
- optional write_to_mods parameter to wesnoth.add_modification
2015-09-19 12:13:25 -04:00
Celtic Minstrel
91ac90db11 Lua API: Add wesnoth.show_message_dialog() 2015-09-18 00:23:54 -04:00
Ignacio R. Morelle
928b6e8008 Comment spelling fixes 2015-09-15 23:22:37 -03:00
Ignacio R. Morelle
b4de73f83b Add wesnoth.set_dialog_visible function
Sets a given widget's visibility property.
2015-08-22 23:07:03 -03:00
Ignacio R. Morelle
ba6257129a Add wesnoth.set_dialog_focus function
Gives keyboard focus to the given widget.
2015-08-22 22:12:02 -03:00
gfgtdf
90ee0a2e9b add wesnoth.remove_dialog_item
a function to remove items from gui2 lists
2015-05-26 03:28:19 +02:00
gfgtdf
7dc59fcab5 Enable tree_view gui2 widget for lua
wesnoth.add_dialog_tree_node to add nodes to a tree_value
wesnoth.set_dialog_callback support for tree_views (triggers when the
selected node was changed)
wesnoth.get_dialog_value support for tree_views returns an array of
integers that describe the path to the currebntly selected node.
2015-04-08 16:35:10 +02:00
gfgtdf
b892e16b94 include lua/... files after others
headers from lua/..  contain macros that can break other headers in
wesnoth, boost or other libraries.

In this case it was a macro
#define cast(t, exp) ((t)(exp))
defined in lua/llimits.h that broke a boost header.
2015-03-27 00:54:22 +01:00
Ignacio R. Morelle
57ae45387a New Year copyright update 2015-01-01 19:07:35 -03:00
Chris Beck
2486b8ba4b lua: refactor to use lua 5.2 syntax for custom metatables
In lua 5.0, the preferred way to define custom metatables is to
use registry keys defined by pushing pointers as lightuserdata to
lua. (These pointers can be pointers to arbitrary constant objects,
as long as they are unique.)

In lua 5.2, the preferred way is to use constant strings as the
registry indices, and several lua API functions are introduced:
"luaL_newmetatable, luaL_setmetatable, luaL_checkudata,
luaL_testudata" which greatly simplify the operations for creating
the metatable, assigning it to a userdata, and checking if the
userdata has that type.

This commit switches over the keys associated to textdomains,
translatable strings, vconfigs, and lua gui2 dialogs to use the
new style, and simplifies some of the implementation details in
the process. For instance, luaW_toconfig no longer has to have an
optional argument to an index on the stack where the tstring
metatable is... these details are handled by the lua API instead.
2014-12-25 23:58:00 -05:00
Chris Beck
9922b98fa3 move wml [inspect] impl to lua (and lua_gui2 namespace) 2014-12-24 05:00:44 -05:00
Chris Beck
84f5677155 add wesnoth.show_lua_console, as a debugging aide
This allows some sort of "drop into debug" mode for lua if your
script detects an error.

We could consider to actually add an "option to attach debugger"
as an error handling mechanism, but it might be complicated
because of wesnoth exceptions which must go through lua and be
treated as lua errors, and we cannot handle two exceptions at once
obviously, so the lua interpreter is probably not safe to run that
way in general. Anyways this commit does not do that.
2014-11-28 18:11:32 -05:00
Chris Beck
925b999b5c add some missing copyright statements 2014-11-20 20:04:12 -05:00
Chris Beck
caeaa6ba67 refactor lua show_dialog
The lua show dialog used to get the video object from resources,
which is not ideal. In this version, lua kernel base internalizes
a pointer to the video object, and show_dialog is bound to a
method of the lua kernel base.

From now on, lua kernels which want to show dialogs need to be
constructed with a pointer to a CVideo, if it is null the lua will
fail with a runtime error.

The application lua kernel is constructed with the video for
game_launcher, and the game lua kernel is modified so that it is
owned by the play controller and not the game events manager, and
held in a boost scoped pointer rather than manually deleted. This
is because the game events manager doesn't have a video object,
also it conceptually seems independent of the lua kernel anyways.

The map generator lua kernels are constructed with NULL, but if a
user configuration dialog is provided (new feature) then when they
try to run it they will update with the mp_create's video pointer.
2014-11-17 17:03:00 -05:00
Chris Beck
445fda6325 fixup lua_gui2.?pp 2014-11-11 12:10:32 -05:00
Chris Beck
ee67de3e97 add a null pointer check 2014-11-10 20:20:52 -05:00
Chris Beck
91f5778068 move all gui2 lua bindings to their own file 2014-11-10 20:12:09 -05:00