Add toggle for debug HUD
This commit is contained in:
parent
081dd693ca
commit
c343a7dfaf
@ -21,7 +21,7 @@ ClientCommandProcessor::ClientCommandProcessor(UniverseClientPtr universeClient,
|
|||||||
{"reload", bind(&ClientCommandProcessor::reload, this)},
|
{"reload", bind(&ClientCommandProcessor::reload, this)},
|
||||||
{"whoami", bind(&ClientCommandProcessor::whoami, this)},
|
{"whoami", bind(&ClientCommandProcessor::whoami, this)},
|
||||||
{"gravity", bind(&ClientCommandProcessor::gravity, this)},
|
{"gravity", bind(&ClientCommandProcessor::gravity, this)},
|
||||||
{"debug", bind(&ClientCommandProcessor::debug, this)},
|
{"debug", bind(&ClientCommandProcessor::debug, this, _1)},
|
||||||
{"boxes", bind(&ClientCommandProcessor::boxes, this)},
|
{"boxes", bind(&ClientCommandProcessor::boxes, this)},
|
||||||
{"fullbright", bind(&ClientCommandProcessor::fullbright, this)},
|
{"fullbright", bind(&ClientCommandProcessor::fullbright, this)},
|
||||||
{"asyncLighting", bind(&ClientCommandProcessor::asyncLighting, this)},
|
{"asyncLighting", bind(&ClientCommandProcessor::asyncLighting, this)},
|
||||||
@ -105,6 +105,10 @@ bool ClientCommandProcessor::debugDisplayEnabled() const {
|
|||||||
return m_debugDisplayEnabled;
|
return m_debugDisplayEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ClientCommandProcessor::debugHudEnabled() const {
|
||||||
|
return m_debugHudEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
bool ClientCommandProcessor::fixedCameraEnabled() const {
|
bool ClientCommandProcessor::fixedCameraEnabled() const {
|
||||||
return m_fixedCameraEnabled;
|
return m_fixedCameraEnabled;
|
||||||
}
|
}
|
||||||
@ -126,12 +130,18 @@ String ClientCommandProcessor::gravity() {
|
|||||||
return strf("{}", m_universeClient->worldClient()->gravity(m_universeClient->mainPlayer()->position()));
|
return strf("{}", m_universeClient->worldClient()->gravity(m_universeClient->mainPlayer()->position()));
|
||||||
}
|
}
|
||||||
|
|
||||||
String ClientCommandProcessor::debug() {
|
String ClientCommandProcessor::debug(StringList const& arguments) {
|
||||||
if (!adminCommandAllowed())
|
if (!adminCommandAllowed())
|
||||||
return "You must be an admin to use this command.";
|
return "You must be an admin to use this command.";
|
||||||
|
|
||||||
m_debugDisplayEnabled = !m_debugDisplayEnabled;
|
if (!arguments.empty() && arguments.at(0).equalsIgnoreCase("hud")) {
|
||||||
return strf("Debug display {}", m_debugDisplayEnabled ? "enabled" : "disabled");
|
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() {
|
String ClientCommandProcessor::boxes() {
|
||||||
|
@ -19,6 +19,7 @@ public:
|
|||||||
StringList handleCommand(String const& commandLine);
|
StringList handleCommand(String const& commandLine);
|
||||||
|
|
||||||
bool debugDisplayEnabled() const;
|
bool debugDisplayEnabled() const;
|
||||||
|
bool debugHudEnabled() const;
|
||||||
bool fixedCameraEnabled() const;
|
bool fixedCameraEnabled() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -28,7 +29,7 @@ private:
|
|||||||
String reload();
|
String reload();
|
||||||
String whoami();
|
String whoami();
|
||||||
String gravity();
|
String gravity();
|
||||||
String debug();
|
String debug(StringList const& arguments);
|
||||||
String boxes();
|
String boxes();
|
||||||
String fullbright();
|
String fullbright();
|
||||||
String asyncLighting();
|
String asyncLighting();
|
||||||
@ -66,6 +67,7 @@ private:
|
|||||||
ShellParser m_parser;
|
ShellParser m_parser;
|
||||||
LuaBaseComponent m_scriptComponent;
|
LuaBaseComponent m_scriptComponent;
|
||||||
bool m_debugDisplayEnabled = false;
|
bool m_debugDisplayEnabled = false;
|
||||||
|
bool m_debugHudEnabled = true;
|
||||||
bool m_fixedCameraEnabled = false;
|
bool m_fixedCameraEnabled = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1257,51 +1257,53 @@ void MainInterface::renderDebug() {
|
|||||||
LogMap::clear();
|
LogMap::clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_clientCommandProcessor->debugHudEnabled()) {
|
||||||
|
auto assets = Root::singleton().assets();
|
||||||
|
m_guiContext->setFontSize(m_config->debugFontSize);
|
||||||
|
m_guiContext->setFont(m_config->debugFont);
|
||||||
|
m_guiContext->setLineSpacing(0.5f);
|
||||||
|
m_guiContext->setFontProcessingDirectives(m_config->debugFontDirectives);
|
||||||
|
m_guiContext->setFontColor(Color::White.toRgba());
|
||||||
|
m_guiContext->setFontMode(FontMode::Normal);
|
||||||
|
|
||||||
auto assets = Root::singleton().assets();
|
bool clearMap = m_debugMapClearTimer.wrapTick();
|
||||||
m_guiContext->setFontSize(m_config->debugFontSize);
|
auto logMapValues = LogMap::getValues();
|
||||||
m_guiContext->setFont(m_config->debugFont);
|
if (clearMap)
|
||||||
m_guiContext->setLineSpacing(0.5f);
|
LogMap::clear();
|
||||||
m_guiContext->setFontProcessingDirectives(m_config->debugFontDirectives);
|
|
||||||
m_guiContext->setFontColor(Color::White.toRgba());
|
|
||||||
m_guiContext->setFontMode(FontMode::Normal);
|
|
||||||
|
|
||||||
bool clearMap = m_debugMapClearTimer.wrapTick();
|
List<String> formatted;
|
||||||
auto logMapValues = LogMap::getValues();
|
formatted.reserve(logMapValues.size());
|
||||||
if (clearMap)
|
|
||||||
LogMap::clear();
|
|
||||||
|
|
||||||
List<String> formatted;
|
int counter = 0;
|
||||||
formatted.reserve(logMapValues.size());
|
for (auto const& pair : logMapValues) {
|
||||||
|
TextPositioning positioning = { Vec2F(m_config->debugOffset[0], windowHeight() - m_config->debugOffset[1] - m_config->fontSize * interfaceScale() * counter++) };
|
||||||
|
String& text = formatted.emplace_back(strf("{}^lightgray;:^green,set; {}", pair.first, pair.second));
|
||||||
|
m_debugTextRect.combine(m_guiContext->determineTextSize(text, positioning).padded(m_config->debugBackgroundPad));
|
||||||
|
}
|
||||||
|
|
||||||
int counter = 0;
|
if (!m_debugTextRect.isNull()) {
|
||||||
for (auto const& pair : logMapValues) {
|
RenderQuad& quad = m_guiContext->renderer()->immediatePrimitives()
|
||||||
TextPositioning positioning = {Vec2F(m_config->debugOffset[0], windowHeight() - m_config->debugOffset[1] - m_config->fontSize * interfaceScale() * counter++)};
|
.emplace_back(std::in_place_type_t<RenderQuad>(), m_debugTextRect, m_config->debugBackgroundColor.toRgba(), 0.0f).get<RenderQuad>();
|
||||||
String& text = formatted.emplace_back(strf("{}^lightgray;:^green,set; {}", pair.first, pair.second));
|
|
||||||
m_debugTextRect.combine(m_guiContext->determineTextSize(text, positioning).padded(m_config->debugBackgroundPad));
|
quad.b.color[3] = quad.c.color[3] = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
m_debugTextRect = RectF::null();
|
||||||
|
|
||||||
|
counter = 0;
|
||||||
|
for (auto const& pair : logMapValues) {
|
||||||
|
TextPositioning positioning = { Vec2F(m_config->debugOffset[0], windowHeight() - m_config->debugOffset[1] - m_config->fontSize * interfaceScale() * counter) };
|
||||||
|
m_guiContext->renderText(formatted[counter], positioning);
|
||||||
|
++counter;
|
||||||
|
}
|
||||||
|
m_guiContext->setFontSize(8);
|
||||||
|
m_guiContext->setDefaultFont();
|
||||||
|
m_guiContext->setDefaultLineSpacing();
|
||||||
|
m_guiContext->setFontColor(Vec4B::filled(255));
|
||||||
|
m_guiContext->setFontProcessingDirectives("");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_debugTextRect.isNull()) {
|
|
||||||
RenderQuad& quad = m_guiContext->renderer()->immediatePrimitives()
|
|
||||||
.emplace_back(std::in_place_type_t<RenderQuad>(), m_debugTextRect, m_config->debugBackgroundColor.toRgba(), 0.0f).get<RenderQuad>();
|
|
||||||
|
|
||||||
quad.b.color[3] = quad.c.color[3] = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
m_debugTextRect = RectF::null();
|
|
||||||
|
|
||||||
counter = 0;
|
|
||||||
for (auto const& pair : logMapValues) {
|
|
||||||
TextPositioning positioning = {Vec2F(m_config->debugOffset[0], windowHeight() - m_config->debugOffset[1] - m_config->fontSize * interfaceScale() * counter)};
|
|
||||||
m_guiContext->renderText(formatted[counter], positioning);
|
|
||||||
++counter;
|
|
||||||
}
|
|
||||||
m_guiContext->setFontSize(8);
|
|
||||||
m_guiContext->setDefaultFont();
|
|
||||||
m_guiContext->setDefaultLineSpacing();
|
|
||||||
m_guiContext->setFontColor(Vec4B::filled(255));
|
|
||||||
m_guiContext->setFontProcessingDirectives("");
|
|
||||||
|
|
||||||
auto const& camera = m_worldPainter->camera();
|
auto const& camera = m_worldPainter->camera();
|
||||||
|
|
||||||
bool clearSpatial = m_debugSpatialClearTimer.wrapTick();
|
bool clearSpatial = m_debugSpatialClearTimer.wrapTick();
|
||||||
|
Loading…
Reference in New Issue
Block a user