feat: keep previous values in debug panel if cursor is not locked
This commit is contained in:
parent
497160a5b9
commit
7b45b4083b
@ -9,6 +9,7 @@
|
|||||||
#include "graphics/ui/elements/TextBox.hpp"
|
#include "graphics/ui/elements/TextBox.hpp"
|
||||||
#include "graphics/ui/elements/TrackBar.hpp"
|
#include "graphics/ui/elements/TrackBar.hpp"
|
||||||
#include "graphics/ui/elements/InputBindBox.hpp"
|
#include "graphics/ui/elements/InputBindBox.hpp"
|
||||||
|
#include "graphics/ui/GUI.hpp"
|
||||||
#include "graphics/render/WorldRenderer.hpp"
|
#include "graphics/render/WorldRenderer.hpp"
|
||||||
#include "graphics/render/ParticlesRenderer.hpp"
|
#include "graphics/render/ParticlesRenderer.hpp"
|
||||||
#include "graphics/render/ChunksRenderer.hpp"
|
#include "graphics/render/ChunksRenderer.hpp"
|
||||||
@ -43,10 +44,15 @@ static std::shared_ptr<Label> create_label(GUI& gui, wstringsupplier supplier) {
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool should_keep_previous(GUI& gui) {
|
||||||
|
return !gui.getInput().isCursorLocked();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: move to xml
|
// TODO: move to xml
|
||||||
// TODO: move to xml finally
|
// TODO: move to xml finally
|
||||||
// TODO: move to xml finally
|
// 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(
|
std::shared_ptr<UINode> create_debug_panel(
|
||||||
Engine& engine,
|
Engine& engine,
|
||||||
Level& level,
|
Level& level,
|
||||||
@ -81,7 +87,7 @@ std::shared_ptr<UINode> create_debug_panel(
|
|||||||
fpsMax = fps;
|
fpsMax = fps;
|
||||||
});
|
});
|
||||||
|
|
||||||
panel->listenInterval(1.0f, [&engine]() {
|
panel->listenInterval(1.0f, [&engine, &gui]() {
|
||||||
const auto& network = engine.getNetwork();
|
const auto& network = engine.getNetwork();
|
||||||
size_t totalDownload = network.getTotalDownload();
|
size_t totalDownload = network.getTotalDownload();
|
||||||
size_t totalUpload = network.getTotalUpload();
|
size_t totalUpload = network.getTotalUpload();
|
||||||
@ -135,7 +141,16 @@ std::shared_ptr<UINode> create_debug_panel(
|
|||||||
std::to_wstring(player.getId());
|
std::to_wstring(player.getId());
|
||||||
}));
|
}));
|
||||||
panel->add(create_label(gui, [&]() -> std::wstring {
|
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;
|
std::wstringstream stream;
|
||||||
stream << "r:" << vox.state.rotation << " s:"
|
stream << "r:" << vox.state.rotation << " s:"
|
||||||
<< std::bitset<3>(vox.state.segment) << " u:"
|
<< 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 {
|
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;
|
const auto& vox = selection.vox;
|
||||||
|
if (vox.id == BLOCK_VOID && should_keep_previous(gui)) {
|
||||||
|
selection = prevSelection;
|
||||||
|
} else {
|
||||||
|
prevSelection = selection;
|
||||||
|
}
|
||||||
|
|
||||||
if (vox.id == BLOCK_VOID) {
|
if (vox.id == BLOCK_VOID) {
|
||||||
return L"x: - y: - z: -";
|
return L"x: - y: - z: -";
|
||||||
}
|
}
|
||||||
@ -158,7 +182,16 @@ std::shared_ptr<UINode> create_debug_panel(
|
|||||||
L" z: " + std::to_wstring(selection.actualPosition.z);
|
L" z: " + std::to_wstring(selection.actualPosition.z);
|
||||||
}));
|
}));
|
||||||
panel->add(create_label(gui, [&]() {
|
panel->add(create_label(gui, [&]() {
|
||||||
|
// TODO: move to xml finally
|
||||||
|
static entityid_t prevEid = ENTITY_NONE;
|
||||||
|
|
||||||
auto eid = player.getSelectedEntity();
|
auto eid = player.getSelectedEntity();
|
||||||
|
if (eid == ENTITY_NONE && should_keep_previous(gui)) {
|
||||||
|
eid = prevEid;
|
||||||
|
} else {
|
||||||
|
prevEid = eid;
|
||||||
|
}
|
||||||
|
|
||||||
if (eid == ENTITY_NONE) {
|
if (eid == ENTITY_NONE) {
|
||||||
return std::wstring {L"entity: -"};
|
return std::wstring {L"entity: -"};
|
||||||
} else if (auto entity = level.entities->get(eid)) {
|
} else if (auto entity = level.entities->get(eid)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user