languages menu moved to xml + minor refactor
This commit is contained in:
@@ -362,6 +362,32 @@ static int l_gui_reindex(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// @brief gui.get_locales_info() -> table of tables
|
||||
static int l_gui_get_locales_info(lua_State* L) {
|
||||
auto& locales = langs::locales_info;
|
||||
lua_createtable(L, 0, locales.size());
|
||||
for (auto& entry : locales) {
|
||||
lua_createtable(L, 0, 1);
|
||||
lua_pushstring(L, entry.second.name.c_str());
|
||||
lua_setfield(L, -2, "name");
|
||||
lua_setfield(L, -2, entry.first.c_str());
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// @brief gui.get_locale() -> string
|
||||
static int l_gui_get_locale(lua_State* L) {
|
||||
lua_pushstring(L, langs::current->getId().c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// @brief gui.set_locale(locale: string) -> nil
|
||||
static int l_gui_set_locale(lua_State* L) {
|
||||
auto locale = lua_tostring(L, 1);
|
||||
scripting::engine->setLanguage(locale);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg guilib [] = {
|
||||
{"get_viewport", lua_wrap_errors<l_gui_getviewport>},
|
||||
{"getattr", lua_wrap_errors<l_gui_getattr>},
|
||||
@@ -369,5 +395,8 @@ const luaL_Reg guilib [] = {
|
||||
{"get_env", lua_wrap_errors<l_gui_get_env>},
|
||||
{"str", lua_wrap_errors<l_gui_str>},
|
||||
{"reindex", lua_wrap_errors<l_gui_reindex>},
|
||||
{"get_locale", lua_wrap_errors<l_gui_get_locale>},
|
||||
{"set_locale", lua_wrap_errors<l_gui_set_locale>},
|
||||
{"get_locales_info", lua_wrap_errors<l_gui_get_locales_info>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -7,23 +7,23 @@
|
||||
#include <cmath>
|
||||
|
||||
static int l_world_get_total_time(lua_State* L) {
|
||||
lua_pushnumber(L, scripting::level->world->totalTime);
|
||||
lua_pushnumber(L, scripting::level->getWorld()->totalTime);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_world_get_day_time(lua_State* L) {
|
||||
lua_pushnumber(L, scripting::level->world->daytime);
|
||||
lua_pushnumber(L, scripting::level->getWorld()->daytime);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_world_set_day_time(lua_State* L) {
|
||||
double value = lua_tonumber(L, 1);
|
||||
scripting::level->world->daytime = fmod(value, 1.0);
|
||||
scripting::level->getWorld()->daytime = fmod(value, 1.0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_world_get_seed(lua_State* L) {
|
||||
lua_pushinteger(L, scripting::level->world->getSeed());
|
||||
lua_pushinteger(L, scripting::level->getWorld()->getSeed());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user