Merge pull request #664 from MihailRis/menu-back-on-escape
menu:back on escape pressed
This commit is contained in:
commit
21cb533f17
@ -441,7 +441,9 @@ function __vc_on_hud_open()
|
||||
end)
|
||||
input.add_callback("key:escape", function()
|
||||
if menu.page ~= "" then
|
||||
if not menu:back() then
|
||||
menu:reset()
|
||||
end
|
||||
elseif hud.is_inventory_open() then
|
||||
hud.close_inventory()
|
||||
else
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "graphics/core/ImageData.hpp"
|
||||
#include "graphics/core/Shader.hpp"
|
||||
#include "graphics/ui/GUI.hpp"
|
||||
#include "graphics/ui/elements/Menu.hpp"
|
||||
#include "objects/rigging.hpp"
|
||||
#include "logic/EngineController.hpp"
|
||||
#include "logic/CommandsInterpreter.hpp"
|
||||
@ -154,6 +155,14 @@ void Engine::initializeClient() {
|
||||
},
|
||||
true
|
||||
));
|
||||
|
||||
keepAlive(this->input->addKeyCallback(Keycode::ESCAPE, [this]() {
|
||||
auto& menu = *gui->getMenu();
|
||||
if (menu.hasOpenPage() && menu.back()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}));
|
||||
}
|
||||
|
||||
void Engine::initialize(CoreParameters coreParameters) {
|
||||
|
||||
@ -57,7 +57,7 @@ DocumentNode get_document_node(lua::State* L, int idx) {
|
||||
static int l_menu_back(lua::State* L) {
|
||||
auto node = get_document_node(L);
|
||||
if (auto menu = dynamic_cast<Menu*>(node.node.get())) {
|
||||
menu->back();
|
||||
return lua::pushboolean(L, menu->back());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user