mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 22:41:49 +00:00
feat: go back in menu on Escape pressed
This commit is contained in:
parent
7b45b4083b
commit
c565e9897f
3 changed files with 13 additions and 2 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue