Merge branch 'dev' into canvases-and-atlases
This commit is contained in:
commit
b89888969f
@ -441,7 +441,9 @@ function __vc_on_hud_open()
|
||||
end)
|
||||
input.add_callback("key:escape", function()
|
||||
if menu.page ~= "" then
|
||||
menu:reset()
|
||||
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) {
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "graphics/ui/elements/TextBox.hpp"
|
||||
#include "graphics/ui/elements/TrackBar.hpp"
|
||||
#include "graphics/ui/elements/InputBindBox.hpp"
|
||||
#include "graphics/ui/GUI.hpp"
|
||||
#include "graphics/render/WorldRenderer.hpp"
|
||||
#include "graphics/render/ParticlesRenderer.hpp"
|
||||
#include "graphics/render/ChunksRenderer.hpp"
|
||||
@ -43,10 +44,15 @@ static std::shared_ptr<Label> create_label(GUI& gui, wstringsupplier supplier) {
|
||||
return label;
|
||||
}
|
||||
|
||||
static bool should_keep_previous(GUI& gui) {
|
||||
return !gui.getInput().isCursorLocked();
|
||||
}
|
||||
|
||||
// TODO: move to xml
|
||||
// TODO: move to xml finally
|
||||
// TODO: move to xml finally
|
||||
// TODO: move to xml finally
|
||||
// TODO: move to xml finally
|
||||
std::shared_ptr<UINode> create_debug_panel(
|
||||
Engine& engine,
|
||||
Level& level,
|
||||
@ -81,7 +87,7 @@ std::shared_ptr<UINode> create_debug_panel(
|
||||
fpsMax = fps;
|
||||
});
|
||||
|
||||
panel->listenInterval(1.0f, [&engine]() {
|
||||
panel->listenInterval(1.0f, [&engine, &gui]() {
|
||||
const auto& network = engine.getNetwork();
|
||||
size_t totalDownload = network.getTotalDownload();
|
||||
size_t totalUpload = network.getTotalUpload();
|
||||
@ -135,7 +141,16 @@ std::shared_ptr<UINode> create_debug_panel(
|
||||
std::to_wstring(player.getId());
|
||||
}));
|
||||
panel->add(create_label(gui, [&]() -> std::wstring {
|
||||
const auto& vox = player.selection.vox;
|
||||
// TODO: move to xml finally
|
||||
static voxel prevVox = {BLOCK_VOID, {}};
|
||||
|
||||
auto vox = player.selection.vox;
|
||||
if (vox.id == BLOCK_VOID && should_keep_previous(gui)) {
|
||||
vox = prevVox;
|
||||
} else {
|
||||
prevVox = vox;
|
||||
}
|
||||
|
||||
std::wstringstream stream;
|
||||
stream << "r:" << vox.state.rotation << " s:"
|
||||
<< std::bitset<3>(vox.state.segment) << " u:"
|
||||
@ -148,8 +163,17 @@ std::shared_ptr<UINode> create_debug_panel(
|
||||
}
|
||||
}));
|
||||
panel->add(create_label(gui, [&]() -> std::wstring {
|
||||
const auto& selection = player.selection;
|
||||
// TODO: move to xml finally
|
||||
static CursorSelection prevSelection {};
|
||||
|
||||
auto selection = player.selection;
|
||||
const auto& vox = selection.vox;
|
||||
if (vox.id == BLOCK_VOID && should_keep_previous(gui)) {
|
||||
selection = prevSelection;
|
||||
} else {
|
||||
prevSelection = selection;
|
||||
}
|
||||
|
||||
if (vox.id == BLOCK_VOID) {
|
||||
return L"x: - y: - z: -";
|
||||
}
|
||||
@ -158,7 +182,16 @@ std::shared_ptr<UINode> create_debug_panel(
|
||||
L" z: " + std::to_wstring(selection.actualPosition.z);
|
||||
}));
|
||||
panel->add(create_label(gui, [&]() {
|
||||
// TODO: move to xml finally
|
||||
static entityid_t prevEid = ENTITY_NONE;
|
||||
|
||||
auto eid = player.getSelectedEntity();
|
||||
if (eid == ENTITY_NONE && should_keep_previous(gui)) {
|
||||
eid = prevEid;
|
||||
} else {
|
||||
prevEid = eid;
|
||||
}
|
||||
|
||||
if (eid == ENTITY_NONE) {
|
||||
return std::wstring {L"entity: -"};
|
||||
} else if (auto entity = level.entities->get(eid)) {
|
||||
|
||||
@ -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