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)
|
end)
|
||||||
input.add_callback("key:escape", function()
|
input.add_callback("key:escape", function()
|
||||||
if menu.page ~= "" then
|
if menu.page ~= "" then
|
||||||
menu:reset()
|
if not menu:back() then
|
||||||
|
menu:reset()
|
||||||
|
end
|
||||||
elseif hud.is_inventory_open() then
|
elseif hud.is_inventory_open() then
|
||||||
hud.close_inventory()
|
hud.close_inventory()
|
||||||
else
|
else
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
#include "graphics/core/ImageData.hpp"
|
#include "graphics/core/ImageData.hpp"
|
||||||
#include "graphics/core/Shader.hpp"
|
#include "graphics/core/Shader.hpp"
|
||||||
#include "graphics/ui/GUI.hpp"
|
#include "graphics/ui/GUI.hpp"
|
||||||
|
#include "graphics/ui/elements/Menu.hpp"
|
||||||
#include "objects/rigging.hpp"
|
#include "objects/rigging.hpp"
|
||||||
#include "logic/EngineController.hpp"
|
#include "logic/EngineController.hpp"
|
||||||
#include "logic/CommandsInterpreter.hpp"
|
#include "logic/CommandsInterpreter.hpp"
|
||||||
@ -154,6 +155,14 @@ void Engine::initializeClient() {
|
|||||||
},
|
},
|
||||||
true
|
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) {
|
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) {
|
static int l_menu_back(lua::State* L) {
|
||||||
auto node = get_document_node(L);
|
auto node = get_document_node(L);
|
||||||
if (auto menu = dynamic_cast<Menu*>(node.node.get())) {
|
if (auto menu = dynamic_cast<Menu*>(node.node.get())) {
|
||||||
menu->back();
|
return lua::pushboolean(L, menu->back());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user