|
|
@@ -215,7 +215,6 @@ void GameFormSpec::deleteFormspec()
|
|
|
|
m_formspec->drop();
|
|
|
|
m_formspec->drop();
|
|
|
|
m_formspec = nullptr;
|
|
|
|
m_formspec = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_formname.clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GameFormSpec::~GameFormSpec() {
|
|
|
|
GameFormSpec::~GameFormSpec() {
|
|
|
@@ -227,8 +226,10 @@ GameFormSpec::~GameFormSpec() {
|
|
|
|
bool GameFormSpec::handleEmptyFormspec(const std::string &formspec, const std::string &formname)
|
|
|
|
bool GameFormSpec::handleEmptyFormspec(const std::string &formspec, const std::string &formname)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (formspec.empty()) {
|
|
|
|
if (formspec.empty()) {
|
|
|
|
if (m_formspec && (formname.empty() || formname == m_formname)) {
|
|
|
|
GUIModalMenu *menu = g_menumgr.tryGetTopMenu();
|
|
|
|
m_formspec->quitMenu();
|
|
|
|
if (menu && (formname.empty() || formname == menu->getName())) {
|
|
|
|
|
|
|
|
// `m_formspec` will be fixed up in `GameFormSpec::update()`
|
|
|
|
|
|
|
|
menu->quitMenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -245,10 +246,11 @@ void GameFormSpec::showFormSpec(const std::string &formspec, const std::string &
|
|
|
|
TextDestPlayerInventory *txt_dst =
|
|
|
|
TextDestPlayerInventory *txt_dst =
|
|
|
|
new TextDestPlayerInventory(m_client, formname);
|
|
|
|
new TextDestPlayerInventory(m_client, formname);
|
|
|
|
|
|
|
|
|
|
|
|
m_formname = formname;
|
|
|
|
// Replace the currently open formspec
|
|
|
|
GUIFormSpecMenu::create(m_formspec, m_client, m_rendering_engine->get_gui_env(),
|
|
|
|
GUIFormSpecMenu::create(m_formspec, m_client, m_rendering_engine->get_gui_env(),
|
|
|
|
&m_input->joystick, fs_src, txt_dst, m_client->getFormspecPrepend(),
|
|
|
|
&m_input->joystick, fs_src, txt_dst, m_client->getFormspecPrepend(),
|
|
|
|
m_client->getSoundManager());
|
|
|
|
m_client->getSoundManager());
|
|
|
|
|
|
|
|
m_formspec->setName(formname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GameFormSpec::showCSMFormSpec(const std::string &formspec, const std::string &formname)
|
|
|
|
void GameFormSpec::showCSMFormSpec(const std::string &formspec, const std::string &formname)
|
|
|
@@ -260,10 +262,10 @@ void GameFormSpec::showCSMFormSpec(const std::string &formspec, const std::strin
|
|
|
|
LocalScriptingFormspecHandler *txt_dst =
|
|
|
|
LocalScriptingFormspecHandler *txt_dst =
|
|
|
|
new LocalScriptingFormspecHandler(formname, m_client->getScript());
|
|
|
|
new LocalScriptingFormspecHandler(formname, m_client->getScript());
|
|
|
|
|
|
|
|
|
|
|
|
m_formname = formname;
|
|
|
|
|
|
|
|
GUIFormSpecMenu::create(m_formspec, m_client, m_rendering_engine->get_gui_env(),
|
|
|
|
GUIFormSpecMenu::create(m_formspec, m_client, m_rendering_engine->get_gui_env(),
|
|
|
|
&m_input->joystick, fs_src, txt_dst, m_client->getFormspecPrepend(),
|
|
|
|
&m_input->joystick, fs_src, txt_dst, m_client->getFormspecPrepend(),
|
|
|
|
m_client->getSoundManager());
|
|
|
|
m_client->getSoundManager());
|
|
|
|
|
|
|
|
m_formspec->setName(formname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GameFormSpec::showPauseMenuFormSpec(const std::string &formspec, const std::string &formname)
|
|
|
|
void GameFormSpec::showPauseMenuFormSpec(const std::string &formspec, const std::string &formname)
|
|
|
@@ -272,20 +274,25 @@ void GameFormSpec::showPauseMenuFormSpec(const std::string &formspec, const std:
|
|
|
|
// the in-game settings formspec.
|
|
|
|
// the in-game settings formspec.
|
|
|
|
// Neither CSM nor the server must be allowed to mess with it.
|
|
|
|
// Neither CSM nor the server must be allowed to mess with it.
|
|
|
|
|
|
|
|
|
|
|
|
if (handleEmptyFormspec(formspec, formname))
|
|
|
|
// If we send updated formspec contents, we can either (1) recycle the old
|
|
|
|
|
|
|
|
// GUIFormSpecMenu or (2) close the old and open a new one. This is option 2.
|
|
|
|
|
|
|
|
(void)handleEmptyFormspec("", formname);
|
|
|
|
|
|
|
|
if (formspec.empty())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
FormspecFormSource *fs_src = new FormspecFormSource(formspec);
|
|
|
|
FormspecFormSource *fs_src = new FormspecFormSource(formspec);
|
|
|
|
LocalScriptingFormspecHandler *txt_dst =
|
|
|
|
LocalScriptingFormspecHandler *txt_dst =
|
|
|
|
new LocalScriptingFormspecHandler(formname, m_pause_script.get());
|
|
|
|
new LocalScriptingFormspecHandler(formname, m_pause_script.get());
|
|
|
|
|
|
|
|
|
|
|
|
m_formname = formname;
|
|
|
|
GUIFormSpecMenu *fs = nullptr;
|
|
|
|
GUIFormSpecMenu::create(m_formspec, m_client, m_rendering_engine->get_gui_env(),
|
|
|
|
GUIFormSpecMenu::create(fs, m_client, m_rendering_engine->get_gui_env(),
|
|
|
|
// Ignore formspec prepend.
|
|
|
|
// Ignore formspec prepend.
|
|
|
|
&m_input->joystick, fs_src, txt_dst, "",
|
|
|
|
&m_input->joystick, fs_src, txt_dst, "",
|
|
|
|
m_client->getSoundManager());
|
|
|
|
m_client->getSoundManager());
|
|
|
|
|
|
|
|
|
|
|
|
m_formspec->doPause = true;
|
|
|
|
fs->setName(formname);
|
|
|
|
|
|
|
|
fs->doPause = true;
|
|
|
|
|
|
|
|
fs->drop(); // 1 reference held by `g_menumgr`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GameFormSpec::showNodeFormspec(const std::string &formspec, const v3s16 &nodepos)
|
|
|
|
void GameFormSpec::showNodeFormspec(const std::string &formspec, const v3s16 &nodepos)
|
|
|
@@ -299,7 +306,6 @@ void GameFormSpec::showNodeFormspec(const std::string &formspec, const v3s16 &no
|
|
|
|
&m_client->getEnv().getClientMap(), nodepos);
|
|
|
|
&m_client->getEnv().getClientMap(), nodepos);
|
|
|
|
TextDest *txt_dst = new TextDestNodeMetadata(nodepos, m_client);
|
|
|
|
TextDest *txt_dst = new TextDestNodeMetadata(nodepos, m_client);
|
|
|
|
|
|
|
|
|
|
|
|
m_formname = "";
|
|
|
|
|
|
|
|
GUIFormSpecMenu::create(m_formspec, m_client, m_rendering_engine->get_gui_env(),
|
|
|
|
GUIFormSpecMenu::create(m_formspec, m_client, m_rendering_engine->get_gui_env(),
|
|
|
|
&m_input->joystick, fs_src, txt_dst, m_client->getFormspecPrepend(),
|
|
|
|
&m_input->joystick, fs_src, txt_dst, m_client->getFormspecPrepend(),
|
|
|
|
m_client->getSoundManager());
|
|
|
|
m_client->getSoundManager());
|
|
|
@@ -336,7 +342,7 @@ void GameFormSpec::showPlayerInventory()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TextDest *txt_dst = new TextDestPlayerInventory(m_client);
|
|
|
|
TextDest *txt_dst = new TextDestPlayerInventory(m_client);
|
|
|
|
m_formname = "";
|
|
|
|
|
|
|
|
GUIFormSpecMenu::create(m_formspec, m_client, m_rendering_engine->get_gui_env(),
|
|
|
|
GUIFormSpecMenu::create(m_formspec, m_client, m_rendering_engine->get_gui_env(),
|
|
|
|
&m_input->joystick, fs_src, txt_dst, m_client->getFormspecPrepend(),
|
|
|
|
&m_input->joystick, fs_src, txt_dst, m_client->getFormspecPrepend(),
|
|
|
|
m_client->getSoundManager());
|
|
|
|
m_client->getSoundManager());
|
|
|
|