Fix, Deprecate, Remove, and Replace tpt.element_func / tpt.graphics_func

This commit is contained in:
jacob1 2022-06-04 22:13:20 -04:00
parent fb7132a923
commit 79f6fd728c
No known key found for this signature in database
GPG Key ID: 4E58A32D510E1995
4 changed files with 19 additions and 84 deletions

View File

@ -317,81 +317,6 @@ int luatpt_getelement(lua_State *l)
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)
{
String errorMessage = ByteString(luaL_optstring(l, 1, "Error text")).FromUtf8();

View File

@ -52,10 +52,6 @@ int luacon_transitionwrite(lua_State* l);
//tpt. api
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_drawtext(lua_State* l);

View File

@ -216,8 +216,6 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
{"screenshot",&luatpt_screenshot},
{"record",&luatpt_record},
{"element",&luatpt_getelement},
{"element_func",&luatpt_element_func},
{"graphics_func",&luatpt_graphics_func},
{"get_clipboard", &platform_clipboardCopy},
{"set_clipboard", &platform_clipboardPaste},
{"setdrawcap", &luatpt_setdrawcap},

View File

@ -21,9 +21,10 @@ local function print_deprecation_warnings()
print("\""..table.concat(deprecated, "\", \"").."\"")
end
tpt.DEPRECATION_WARNINGS = false
local function deprecationwarning()
-- no warning for now
--[[local calling_file_info = debug.getinfo(3, "S")
if not tpt.DEPRECATION_WARNINGS then return end
local calling_file_info = debug.getinfo(3, "S")
if calling_file_info then
calling_file_info = calling_file_info["short_src"]
@ -34,7 +35,7 @@ local function deprecationwarning()
event.register(event.tick, print_deprecation_warnings)
end
end
end]]
end
end
@ -223,3 +224,18 @@ function tpt.unregister_keypress(f)
registered_keypresses[f] = nil
end
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