X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fui%2Fui.cpp;h=6fa7356c790b25894a09a4bf22e5dc4076e7980b;hb=a1f911f8257f614f874c201fede5d5206f5b7e80;hp=198defb2850f5a628247784c2ebc1bddea41fed5;hpb=291ff5699aa1a1dd0e8aff49543849085e883c16;p=blank.git diff --git a/src/ui/ui.cpp b/src/ui/ui.cpp index 198defb..6fa7356 100644 --- a/src/ui/ui.cpp +++ b/src/ui/ui.cpp @@ -124,6 +124,10 @@ Interface::Interface( counter_text.Position(glm::vec3(-25.0f, 25.0f, 0.0f), Gravity::NORTH_EAST); counter_text.Foreground(glm::vec4(1.0f)); counter_text.Background(glm::vec4(0.5f)); + position_text.Hide(); + position_text.Position(glm::vec3(-25.0f, 25.0f + font.LineSkip(), 0.0f), Gravity::NORTH_EAST); + position_text.Foreground(glm::vec4(1.0f)); + position_text.Background(glm::vec4(0.5f)); messages.Position(glm::vec3(25.0f, -25.0f, 0.0f), Gravity::SOUTH_WEST); messages.Foreground(glm::vec4(1.0f)); messages.Background(glm::vec4(0.5f)); @@ -182,7 +186,7 @@ void Interface::HandlePress(const SDL_KeyboardEvent &event) { ToggleVisual(); break; case SDLK_F3: - ToggleCounter(); + ToggleDebug(); break; case SDLK_F4: ToggleAudio(); @@ -338,10 +342,12 @@ void Interface::ToggleVisual() { } } -void Interface::ToggleCounter() { +void Interface::ToggleDebug() { counter_text.Toggle(); + position_text.Toggle(); if (counter_text.Visible()) { UpdateCounter(); + UpdatePosition(); } } @@ -354,6 +360,12 @@ void Interface::UpdateCounter() { counter_text.Set(font, text); } +void Interface::UpdatePosition() { + std::stringstream s; + s << std::setprecision(3) << "pos: " << ctrl.Controlled().AbsolutePosition(); + position_text.Set(font, s.str()); +} + void Interface::Handle(const SDL_MouseMotionEvent &event) { if (config.mouse_disabled) return; @@ -487,6 +499,9 @@ void Interface::Update(int dt) { if (counter_text.Visible() && counter.Changed()) { UpdateCounter(); } + if (position_text.Visible()) { + UpdatePosition(); + } } namespace { @@ -522,6 +537,9 @@ void Interface::Render(Viewport &viewport) noexcept { if (counter_text.Visible()) { counter_text.Render(viewport); } + if (position_text.Visible()) { + position_text.Render(viewport); + } if (msg_timer.Running()) { messages.Render(viewport);