Fix, Deprecate, Remove, and Replace tpt.element_func / tpt.graphics_func
This commit is contained in:
parent
fb7132a923
commit
79f6fd728c
@ -317,81 +317,6 @@ int luatpt_getelement(lua_State *l)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int luatpt_element_func(lua_State *l)
|
|
||||||
{
|
|
||||||
if (lua_isfunction(l, 1))
|
|
||||||
{
|
|
||||||
int element = luaL_optint(l, 2, 0);
|
|
||||||
int replace = luaL_optint(l, 3, 0);
|
|
||||||
if (luacon_sim->IsElement(element))
|
|
||||||
{
|
|
||||||
lua_el_func[element].Assign(l, 1);
|
|
||||||
if (replace == 2)
|
|
||||||
lua_el_mode[element] = 3; //update before
|
|
||||||
else if (replace)
|
|
||||||
lua_el_mode[element] = 2; //replace
|
|
||||||
else
|
|
||||||
lua_el_mode[element] = 1; //update after
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return luaL_error(l, "Invalid element");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (lua_isnil(l, 1))
|
|
||||||
{
|
|
||||||
int element = luaL_optint(l, 2, 0);
|
|
||||||
if (luacon_sim->IsElement(element))
|
|
||||||
{
|
|
||||||
lua_el_func[element].Clear();
|
|
||||||
lua_el_mode[element] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return luaL_error(l, "Invalid element");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return luaL_error(l, "Not a function");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int luatpt_graphics_func(lua_State *l)
|
|
||||||
{
|
|
||||||
if(lua_isfunction(l, 1))
|
|
||||||
{
|
|
||||||
int element = luaL_optint(l, 2, 0);
|
|
||||||
if (luacon_sim->IsElement(element))
|
|
||||||
{
|
|
||||||
lua_gr_func[element].Assign(l, 1);
|
|
||||||
luacon_ren->graphicscache[element].isready = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return luaL_error(l, "Invalid element");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (lua_isnil(l, 1))
|
|
||||||
{
|
|
||||||
int element = luaL_optint(l, 2, 0);
|
|
||||||
if (luacon_sim->IsElement(element))
|
|
||||||
{
|
|
||||||
lua_gr_func[element].Clear();
|
|
||||||
luacon_ren->graphicscache[element].isready = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return luaL_error(l, "Invalid element");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return luaL_error(l, "Not a function");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int luatpt_error(lua_State* l)
|
int luatpt_error(lua_State* l)
|
||||||
{
|
{
|
||||||
String errorMessage = ByteString(luaL_optstring(l, 1, "Error text")).FromUtf8();
|
String errorMessage = ByteString(luaL_optstring(l, 1, "Error text")).FromUtf8();
|
||||||
|
@ -52,10 +52,6 @@ int luacon_transitionwrite(lua_State* l);
|
|||||||
//tpt. api
|
//tpt. api
|
||||||
int luatpt_getelement(lua_State *l);
|
int luatpt_getelement(lua_State *l);
|
||||||
|
|
||||||
int luatpt_graphics_func(lua_State *l);
|
|
||||||
|
|
||||||
int luatpt_element_func(lua_State *l);
|
|
||||||
|
|
||||||
int luatpt_error(lua_State* l);
|
int luatpt_error(lua_State* l);
|
||||||
int luatpt_drawtext(lua_State* l);
|
int luatpt_drawtext(lua_State* l);
|
||||||
|
|
||||||
|
@ -216,8 +216,6 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
|
|||||||
{"screenshot",&luatpt_screenshot},
|
{"screenshot",&luatpt_screenshot},
|
||||||
{"record",&luatpt_record},
|
{"record",&luatpt_record},
|
||||||
{"element",&luatpt_getelement},
|
{"element",&luatpt_getelement},
|
||||||
{"element_func",&luatpt_element_func},
|
|
||||||
{"graphics_func",&luatpt_graphics_func},
|
|
||||||
{"get_clipboard", &platform_clipboardCopy},
|
{"get_clipboard", &platform_clipboardCopy},
|
||||||
{"set_clipboard", &platform_clipboardPaste},
|
{"set_clipboard", &platform_clipboardPaste},
|
||||||
{"setdrawcap", &luatpt_setdrawcap},
|
{"setdrawcap", &luatpt_setdrawcap},
|
||||||
|
@ -21,9 +21,10 @@ local function print_deprecation_warnings()
|
|||||||
print("\""..table.concat(deprecated, "\", \"").."\"")
|
print("\""..table.concat(deprecated, "\", \"").."\"")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tpt.DEPRECATION_WARNINGS = false
|
||||||
local function deprecationwarning()
|
local function deprecationwarning()
|
||||||
-- no warning for now
|
if not tpt.DEPRECATION_WARNINGS then return end
|
||||||
--[[local calling_file_info = debug.getinfo(3, "S")
|
local calling_file_info = debug.getinfo(3, "S")
|
||||||
if calling_file_info then
|
if calling_file_info then
|
||||||
calling_file_info = calling_file_info["short_src"]
|
calling_file_info = calling_file_info["short_src"]
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ local function deprecationwarning()
|
|||||||
event.register(event.tick, print_deprecation_warnings)
|
event.register(event.tick, print_deprecation_warnings)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end]]
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -223,3 +224,18 @@ function tpt.unregister_keypress(f)
|
|||||||
registered_keypresses[f] = nil
|
registered_keypresses[f] = nil
|
||||||
end
|
end
|
||||||
tpt.unregister_keyevent = tpt.unregister_keypress
|
tpt.unregister_keyevent = tpt.unregister_keypress
|
||||||
|
|
||||||
|
|
||||||
|
function tpt.element_func(f, element, replace)
|
||||||
|
deprecationwarning()
|
||||||
|
|
||||||
|
if f == nil then f = false end
|
||||||
|
elem.property(element, "Update", f, replace)
|
||||||
|
end
|
||||||
|
|
||||||
|
function tpt.graphics_func(f, element)
|
||||||
|
deprecationwarning()
|
||||||
|
|
||||||
|
if f == nil then f = false end
|
||||||
|
elem.property(element, "Graphics", f)
|
||||||
|
end
|
||||||
|
Reference in New Issue
Block a user