Permalink
Browse files

Add wesnoth.set_dialog_markup Lua function

This adds functionality to enable or disable Pango markup on GUI2
widgets instantiated by Lua GUI2 dialogs.

The code is taken almost verbatim from patch #2759 by Exasperation
<https://gna.org/patch/?2759>, rebased against current master.
  • Loading branch information...
shikadiqueen committed Dec 23, 2013
1 parent 00442b4 commit cc75d12088b3a074348d90b2075e9abcfc6edbb0
Showing with 17 additions and 0 deletions.
  1. +17 −0 src/scripting/lua.cpp
View
@@ -2982,6 +2982,22 @@ static int intf_set_dialog_callback(lua_State *L)
return 0;
}
+/**
+ * Enables/disables Pango markup on the label of a widget of the current dialog.
+ * - Arg 1: boolean.
+ * - Args 2..n: path of strings and integers.
+ */
+static int intf_set_dialog_markup(lua_State *L)
+{
+ bool b = lua_toboolean(L, 1);
+ gui2::twidget *w = find_widget(L, 2, true);
+ gui2::tcontrol *c = dynamic_cast<gui2::tcontrol *>(w);
+ if (!c) return luaL_argerror(L, lua_gettop(L), "unsupported widget");
+
+ c->set_use_markup(b);
+ return 0;
+}
+
/**
* Sets a canvas on a widget of the current dialog.
* - Arg 1: integer.
@@ -3606,6 +3622,7 @@ LuaKernel::LuaKernel(const config &cfg)
{ "set_dialog_active", &intf_set_dialog_active },
{ "set_dialog_callback", &intf_set_dialog_callback },
{ "set_dialog_canvas", &intf_set_dialog_canvas },
+ { "set_dialog_markup", &intf_set_dialog_markup },
{ "set_dialog_value", &intf_set_dialog_value },
{ "set_music", &intf_set_music },
{ "set_terrain", &intf_set_terrain },

0 comments on commit cc75d12

Please sign in to comment.