Hook it up into a working demo state
This commit is contained in:
parent
42f92694b5
commit
5c5ef20589
@ -55,7 +55,7 @@ local function make_registration()
|
||||
local registerfunc = function(func)
|
||||
t[#t + 1] = func
|
||||
core.callback_origins[func] = {
|
||||
mod = core.get_current_modname() or "??",
|
||||
mod = core.get_current_modname and core.get_current_modname() or "??",
|
||||
name = getinfo(1, "n").name or "??"
|
||||
}
|
||||
--local origin = core.callback_origins[func]
|
||||
|
@ -772,3 +772,28 @@ function create_settings_dlg()
|
||||
|
||||
return dlg
|
||||
end
|
||||
|
||||
if INIT == "pause_menu" then
|
||||
local dialog
|
||||
|
||||
core.register_on_formspec_input(function(formname, fields)
|
||||
if dialog and formname == "__builtin:settings" then
|
||||
-- dialog is re-checked since the buttonhandler may have closed it
|
||||
if buttonhandler(dialog, fields) and dialog then
|
||||
core.show_formspec("__builtin:settings", get_formspec(dialog.data))
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
core.open_settings = function()
|
||||
load()
|
||||
dialog = {}
|
||||
dialog.data = {}
|
||||
dialog.page_id = update_filtered_pages("")
|
||||
dialog.delete = function()
|
||||
dialog = nil
|
||||
end
|
||||
|
||||
core.show_formspec("__builtin:settings", get_formspec(dialog.data))
|
||||
end
|
||||
end
|
||||
|
@ -408,7 +408,7 @@ function settingtypes.parse_config_file(read_all, parse_mods)
|
||||
file:close()
|
||||
end
|
||||
|
||||
if parse_mods then
|
||||
if INIT == "mainmenu" and parse_mods then
|
||||
-- Parse games
|
||||
local games_category_initialized = false
|
||||
for _, game in ipairs(pkgmgr.games) do
|
||||
|
@ -0,0 +1,9 @@
|
||||
local scriptpath = core.get_builtin_path()
|
||||
local clientpath = scriptpath.."client"..DIR_DELIM
|
||||
local commonpath = scriptpath.."common"..DIR_DELIM
|
||||
|
||||
-- we're in-game, so no absolute paths are needed
|
||||
defaulttexturedir = ""
|
||||
|
||||
dofile(clientpath .. "register.lua")
|
||||
dofile(commonpath .. "settings" .. DIR_DELIM .. "init.lua")
|
@ -77,8 +77,8 @@ struct LocalFormspecHandler : public TextDest
|
||||
m_formname = formname;
|
||||
}
|
||||
|
||||
LocalFormspecHandler(const std::string &formname, Client *client):
|
||||
m_client(client)
|
||||
LocalFormspecHandler(const std::string &formname, Client *client, PauseMenuScripting *pause_script):
|
||||
m_client(client), m_pause_script(pause_script)
|
||||
{
|
||||
m_formname = formname;
|
||||
}
|
||||
@ -136,11 +136,17 @@ struct LocalFormspecHandler : public TextDest
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_client->modsLoaded())
|
||||
m_client->getScript()->on_formspec_input(m_formname, fields);
|
||||
if (m_pause_script &&
|
||||
m_pause_script->on_formspec_input(m_formname, fields))
|
||||
return;
|
||||
|
||||
if (m_client && m_client->modsLoaded() &&
|
||||
m_client->getScript()->on_formspec_input(m_formname, fields))
|
||||
return;
|
||||
}
|
||||
|
||||
Client *m_client = nullptr;
|
||||
PauseMenuScripting *m_pause_script = nullptr;
|
||||
};
|
||||
|
||||
/* Form update callback */
|
||||
@ -236,7 +242,7 @@ void GameFormSpec::showLocalFormSpec(const std::string &formspec, const std::str
|
||||
{
|
||||
FormspecFormSource *fs_src = new FormspecFormSource(formspec);
|
||||
LocalFormspecHandler *txt_dst =
|
||||
new LocalFormspecHandler(formname, m_client);
|
||||
new LocalFormspecHandler(formname, m_client, m_pause_script.get());
|
||||
GUIFormSpecMenu::create(m_formspec, m_client, m_rendering_engine->get_gui_env(),
|
||||
&m_input->joystick, fs_src, txt_dst, m_client->getFormspecPrepend(),
|
||||
m_client->getSoundManager());
|
||||
@ -427,7 +433,7 @@ void GameFormSpec::showDeathFormspecLegacy()
|
||||
/* Note: FormspecFormSource and LocalFormspecHandler *
|
||||
* are deleted by guiFormSpecMenu */
|
||||
FormspecFormSource *fs_src = new FormspecFormSource(formspec_str);
|
||||
LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_DEATH_SCREEN", m_client);
|
||||
LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_DEATH_SCREEN", m_client, m_pause_script.get());
|
||||
|
||||
GUIFormSpecMenu::create(m_formspec, m_client, m_rendering_engine->get_gui_env(),
|
||||
&m_input->joystick, fs_src, txt_dst, m_client->getFormspecPrepend(),
|
||||
|
Loading…
Reference in New Issue
Block a user