Integration work pt. 1: settings button -> Lua error
This commit is contained in:
parent
f8cf405ec9
commit
c798906f61
@ -86,6 +86,11 @@ struct LocalFormspecHandler : public TextDest
|
||||
void gotText(const StringMap &fields)
|
||||
{
|
||||
if (m_formname == "MT_PAUSE_MENU") {
|
||||
if (fields.find("btn_settings") != fields.end()) {
|
||||
g_gamecallback->openSettings();
|
||||
return;
|
||||
}
|
||||
|
||||
if (fields.find("btn_sound") != fields.end()) {
|
||||
g_gamecallback->changeVolume();
|
||||
return;
|
||||
@ -331,6 +336,9 @@ void GameFormSpec::showPauseMenu()
|
||||
os << "field[4.95,0;5,1.5;;" << strgettext("Game paused") << ";]";
|
||||
}
|
||||
|
||||
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_settings;"
|
||||
<< strgettext("Settings") << "]";
|
||||
|
||||
#ifndef __ANDROID__
|
||||
#if USE_SOUND
|
||||
if (g_settings->getBool("enable_sound")) {
|
||||
@ -474,6 +482,11 @@ bool GameFormSpec::handleCallbacks()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (g_gamecallback->settings_requested) {
|
||||
m_pause_script->open_settings();
|
||||
g_gamecallback->settings_requested = false;
|
||||
}
|
||||
|
||||
if (g_gamecallback->changepassword_requested) {
|
||||
(void)make_irr<GUIPasswordChange>(guienv, guiroot, -1,
|
||||
&g_menumgr, m_client, texture_src);
|
||||
|
@ -15,6 +15,7 @@ class IGameCallback
|
||||
{
|
||||
public:
|
||||
virtual void exitToOS() = 0;
|
||||
virtual void openSettings() = 0;
|
||||
virtual void keyConfig() = 0;
|
||||
virtual void disconnect() = 0;
|
||||
virtual void changePassword() = 0;
|
||||
@ -109,6 +110,11 @@ public:
|
||||
shutdown_requested = true;
|
||||
}
|
||||
|
||||
void openSettings() override
|
||||
{
|
||||
settings_requested = true;
|
||||
}
|
||||
|
||||
void disconnect() override
|
||||
{
|
||||
disconnect_requested = true;
|
||||
@ -145,6 +151,7 @@ public:
|
||||
}
|
||||
|
||||
bool disconnect_requested = false;
|
||||
bool settings_requested = false;
|
||||
bool changepassword_requested = false;
|
||||
bool changevolume_requested = false;
|
||||
bool keyconfig_requested = false;
|
||||
|
@ -11,17 +11,10 @@ void ScriptApiPauseMenu::open_settings()
|
||||
|
||||
int error_handler = PUSH_ERROR_HANDLER(L);
|
||||
|
||||
// Get handler function
|
||||
lua_getglobal(L, "core");
|
||||
lua_getfield(L, -1, "open_settings");
|
||||
lua_remove(L, -2); // Remove core
|
||||
if (lua_isnil(L, -1)) {
|
||||
lua_pop(L, 1); // Pop open_settings
|
||||
return;
|
||||
}
|
||||
luaL_checktype(L, -1, LUA_TFUNCTION);
|
||||
|
||||
// Call it
|
||||
PCALL_RES(lua_pcall(L, 0, 0, error_handler));
|
||||
lua_pop(L, 1); // Pop error handler
|
||||
|
||||
lua_pop(L, 2); // Pop core, error handler
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user