Author: silene Date: Fri Dec 24 09:07:18 2010 New Revision: 48039 URL: http://svn.gna.org/viewcvs/wesnoth?rev=48039&view=rev Log: Added a get_image_size function for querying the width and height of an image. (Fix for bug #17387.)
Modified: trunk/src/scripting/lua.cpp Modified: trunk/src/scripting/lua.cpp URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/scripting/lua.cpp?rev=48039&r1=48038&r2=48039&view=diff ============================================================================== --- trunk/src/scripting/lua.cpp (original) +++ trunk/src/scripting/lua.cpp Fri Dec 24 09:07:18 2010 @@ -2861,6 +2861,23 @@ return 0; } +/** + * Gets the dimension of an image. + * - Arg 1: string. + * - Ret 1: width. + * - Ret 2: height. + */ +static int intf_get_image_size(lua_State *L) +{ + char const *m = luaL_checkstring(L, 1); + image::locator img(m); + if (!img.file_exists()) return 0; + surface s = get_image(img); + lua_pushinteger(L, s->w); + lua_pushinteger(L, s->h); + return 2; +} + LuaKernel::LuaKernel(const config &cfg) : mState(luaL_newstate()), level_(cfg) { @@ -2898,6 +2915,7 @@ { "fire_event", &intf_fire_event }, { "float_label", &intf_float_label }, { "get_dialog_value", &intf_get_dialog_value }, + { "get_image_size", &intf_get_image_size }, { "get_locations", &intf_get_locations }, { "get_map_size", &intf_get_map_size }, { "get_recall_units", &intf_get_recall_units }, _______________________________________________ Wesnoth-commits mailing list Wesnoth-commits@gna.org https://mail.gna.org/listinfo/wesnoth-commits