diff options
Diffstat (limited to 'main/gui.cpp')
-rw-r--r-- | main/gui.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/main/gui.cpp b/main/gui.cpp index 37ca1227..8d2cb97e 100644 --- a/main/gui.cpp +++ b/main/gui.cpp @@ -1,6 +1,6 @@ #include "app.hpp" #include <Magnum/GL/Renderer.h> -#ifndef __CLION_IDE__zz +#ifndef __CLION_IDE__ #include "imgui-raii.hpp" #include <Magnum/ImGuiIntegration/Integration.h> #endif @@ -57,6 +57,7 @@ void app::draw_ui() const float main_menu_height = draw_main_menu(); draw_editor_pane(_editor.floor(), main_menu_height); draw_fps(); + draw_cursor_coord(); } void app::draw_editor_pane(tile_type& type, float main_menu_height) @@ -166,4 +167,33 @@ void app::draw_fps() } } +void app::draw_cursor_coord() +{ + if (!_cursor_tile) + return; + + auto c1 = push_style_var(ImGuiStyleVar_FramePadding, {0, 0}); + auto c2 = push_style_var(ImGuiStyleVar_WindowPadding, {0, 0}); + auto c3 = push_style_var(ImGuiStyleVar_WindowBorderSize, 0); + auto c4 = push_style_var(ImGuiStyleVar_WindowMinSize, {1, 1}); + auto c5 = push_style_var(ImGuiStyleVar_ScrollbarSize, 0); + auto c6 = push_style_color(ImGuiCol_Text, {.9, .9, .9, 1}); + + char buf[64]; + const auto coord = *_cursor_tile; + const auto chunk = coord.chunk(); + const auto local = coord.local(); + snprintf(buf, sizeof(buf), "%hd:%hd - %hhu:%hhu", chunk.x, chunk.y, local.x, local.y); + const auto size = ImGui::CalcTextSize(buf); + + ImGui::SetNextWindowPos({windowSize()[0]/2 - size.x/2, 3}); + ImGui::SetNextWindowSize(size); + if (auto flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoInputs | + ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground; + auto b = begin_window("tile-coord", ImGuiWindowFlags_(flags))) + { + ImGui::Text("%s", buf); + } +} + } // namespace floormat |