1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

In-game settings menu using separate Lua environment (#15614)

This commit is contained in:
grorp 2025-01-19 13:07:04 -05:00 committed by GitHub
parent 3cb07d5fb6
commit eeb6cab4c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 652 additions and 290 deletions

View file

@ -875,27 +875,6 @@ int ModApiMainMenu::l_download_file(lua_State *L)
return 1;
}
/******************************************************************************/
int ModApiMainMenu::l_get_video_drivers(lua_State *L)
{
auto drivers = RenderingEngine::getSupportedVideoDrivers();
lua_newtable(L);
for (u32 i = 0; i != drivers.size(); i++) {
auto &info = RenderingEngine::getVideoDriverInfo(drivers[i]);
lua_newtable(L);
lua_pushstring(L, info.name.c_str());
lua_setfield(L, -2, "name");
lua_pushstring(L, info.friendly_name.c_str());
lua_setfield(L, -2, "friendly_name");
lua_rawseti(L, -2, i + 1);
}
return 1;
}
/******************************************************************************/
int ModApiMainMenu::l_get_language(lua_State *L)
{
@ -907,16 +886,6 @@ int ModApiMainMenu::l_get_language(lua_State *L)
return 1;
}
/******************************************************************************/
int ModApiMainMenu::l_gettext(lua_State *L)
{
const char *srctext = luaL_checkstring(L, 1);
const char *text = *srctext ? gettext(srctext) : "";
lua_pushstring(L, text);
return 1;
}
/******************************************************************************/
int ModApiMainMenu::l_get_window_info(lua_State *L)
{
@ -949,14 +918,6 @@ int ModApiMainMenu::l_get_window_info(lua_State *L)
}
/******************************************************************************/
int ModApiMainMenu::l_get_active_driver(lua_State *L)
{
auto drivertype = RenderingEngine::get_video_driver()->getDriverType();
lua_pushstring(L, RenderingEngine::getVideoDriverInfo(drivertype).name.c_str());
return 1;
}
int ModApiMainMenu::l_get_active_renderer(lua_State *L)
{
lua_pushstring(L, RenderingEngine::get_video_driver()->getName());
@ -980,14 +941,6 @@ int ModApiMainMenu::l_get_active_irrlicht_device(lua_State *L)
return 1;
}
/******************************************************************************/
int ModApiMainMenu::l_irrlicht_device_supports_touch(lua_State *L)
{
lua_pushboolean(L, RenderingEngine::get_raw_device()->supportsTouchEvents());
return 1;
}
/******************************************************************************/
int ModApiMainMenu::l_get_min_supp_proto(lua_State *L)
{
@ -1122,13 +1075,9 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
API_FCT(show_path_select_dialog);
API_FCT(download_file);
API_FCT(get_language);
API_FCT(gettext);
API_FCT(get_video_drivers);
API_FCT(get_window_info);
API_FCT(get_active_driver);
API_FCT(get_active_renderer);
API_FCT(get_active_irrlicht_device);
API_FCT(irrlicht_device_supports_touch);
API_FCT(get_min_supp_proto);
API_FCT(get_max_supp_proto);
API_FCT(get_formspec_version);
@ -1165,5 +1114,4 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top)
API_FCT(get_max_supp_proto);
API_FCT(get_formspec_version);
API_FCT(get_language);
API_FCT(gettext);
}