Add toggle for debug HUD

This commit is contained in:
Kae 2023-07-04 04:42:16 +10:00
parent 081dd693ca
commit c343a7dfaf
3 changed files with 58 additions and 44 deletions

View File

@ -21,7 +21,7 @@ ClientCommandProcessor::ClientCommandProcessor(UniverseClientPtr universeClient,
{"reload", bind(&ClientCommandProcessor::reload, this)},
{"whoami", bind(&ClientCommandProcessor::whoami, this)},
{"gravity", bind(&ClientCommandProcessor::gravity, this)},
{"debug", bind(&ClientCommandProcessor::debug, this)},
{"debug", bind(&ClientCommandProcessor::debug, this, _1)},
{"boxes", bind(&ClientCommandProcessor::boxes, this)},
{"fullbright", bind(&ClientCommandProcessor::fullbright, this)},
{"asyncLighting", bind(&ClientCommandProcessor::asyncLighting, this)},
@ -105,6 +105,10 @@ bool ClientCommandProcessor::debugDisplayEnabled() const {
return m_debugDisplayEnabled;
}
bool ClientCommandProcessor::debugHudEnabled() const {
return m_debugHudEnabled;
}
bool ClientCommandProcessor::fixedCameraEnabled() const {
return m_fixedCameraEnabled;
}
@ -126,13 +130,19 @@ String ClientCommandProcessor::gravity() {
return strf("{}", m_universeClient->worldClient()->gravity(m_universeClient->mainPlayer()->position()));
}
String ClientCommandProcessor::debug() {
String ClientCommandProcessor::debug(StringList const& arguments) {
if (!adminCommandAllowed())
return "You must be an admin to use this command.";
if (!arguments.empty() && arguments.at(0).equalsIgnoreCase("hud")) {
m_debugHudEnabled = !m_debugHudEnabled;
return strf("Debug HUD {}", m_debugHudEnabled ? "enabled" : "disabled");
}
else {
m_debugDisplayEnabled = !m_debugDisplayEnabled;
return strf("Debug display {}", m_debugDisplayEnabled ? "enabled" : "disabled");
}
}
String ClientCommandProcessor::boxes() {
if (!adminCommandAllowed())

View File

@ -19,6 +19,7 @@ public:
StringList handleCommand(String const& commandLine);
bool debugDisplayEnabled() const;
bool debugHudEnabled() const;
bool fixedCameraEnabled() const;
private:
@ -28,7 +29,7 @@ private:
String reload();
String whoami();
String gravity();
String debug();
String debug(StringList const& arguments);
String boxes();
String fullbright();
String asyncLighting();
@ -66,6 +67,7 @@ private:
ShellParser m_parser;
LuaBaseComponent m_scriptComponent;
bool m_debugDisplayEnabled = false;
bool m_debugHudEnabled = true;
bool m_fixedCameraEnabled = false;
};

View File

@ -1258,6 +1258,7 @@ void MainInterface::renderDebug() {
return;
}
if (m_clientCommandProcessor->debugHudEnabled()) {
auto assets = Root::singleton().assets();
m_guiContext->setFontSize(m_config->debugFontSize);
m_guiContext->setFont(m_config->debugFont);
@ -1301,6 +1302,7 @@ void MainInterface::renderDebug() {
m_guiContext->setDefaultLineSpacing();
m_guiContext->setFontColor(Vec4B::filled(255));
m_guiContext->setFontProcessingDirectives("");
}
auto const& camera = m_worldPainter->camera();