diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-28 20:13:20 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-28 20:13:20 +0100 |
commit | 5bead7daaf1782ecb142a57ac57bd8ba405ba150 (patch) | |
tree | 0b45d1b643ff4f44d3e8e9949e00f06c93811531 /src | |
parent | f825cf0e35966869fe22ae0629a1c7256160add4 (diff) | |
download | dragonfireclient-5bead7daaf1782ecb142a57ac57bd8ba405ba150.tar.xz |
Added minetest.close_formspec
Diffstat (limited to 'src')
-rw-r--r-- | src/client/game.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp index 8537ba39a..f79fdba8c 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -1889,13 +1889,21 @@ void Game::handleClientEvent_ShowFormSpec(ClientEvent *event, CameraOrientation } void Game::handleClientEvent_ShowLocalFormSpec(ClientEvent *event, CameraOrientation *cam) -{ - FormspecFormSource *fs_src = new FormspecFormSource(*event->show_formspec.formspec); - LocalFormspecHandler *txt_dst = - new LocalFormspecHandler(*event->show_formspec.formname, client); - GUIFormSpecMenu::create(m_game_ui->getFormspecGUI(), client, &input->joystick, +{ + if (event->show_formspec.formspec->empty()) { + auto formspec = m_game_ui->getFormspecGUI(); + if (formspec && (event->show_formspec.formname->empty() + || *(event->show_formspec.formname) == m_game_ui->getFormspecName())) { + formspec->quitMenu(); + } + } else { + FormspecFormSource *fs_src = new FormspecFormSource(*event->show_formspec.formspec); + LocalFormspecHandler *txt_dst = + new LocalFormspecHandler(*event->show_formspec.formname, client); + GUIFormSpecMenu::create(m_game_ui->getFormspecGUI(), client, &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound); - + } + delete event->show_formspec.formspec; delete event->show_formspec.formname; } |