summaryrefslogtreecommitdiffhomepage
path: root/editor
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-02-24 13:25:30 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-02-24 13:25:45 +0100
commit1524db15d4e89ad2e7462710c9b1de388fce6ba1 (patch)
treed151c58e4c9fe1f1c8d0c3acd6e59b6d36a77a0b /editor
parentd2eae22f0661703507dcbb1407788743827a2862 (diff)
editor: move imgui-inspect to its own file
Diffstat (limited to 'editor')
-rw-r--r--editor/imgui-inspect.cpp35
-rw-r--r--editor/imgui.cpp27
-rw-r--r--editor/inspect-types.cpp11
3 files changed, 41 insertions, 32 deletions
diff --git a/editor/imgui-inspect.cpp b/editor/imgui-inspect.cpp
new file mode 100644
index 00000000..d776e032
--- /dev/null
+++ b/editor/imgui-inspect.cpp
@@ -0,0 +1,35 @@
+#include "app.hpp"
+#include "inspect.hpp"
+#include "main/clickable.hpp"
+#include "floormat/main.hpp"
+#include "src/world.hpp"
+#include "imgui-raii.hpp"
+
+namespace floormat {
+
+using namespace floormat::imgui;
+
+void app::draw_inspector()
+{
+ auto b = push_id("inspector");
+ auto& w = M->world();
+ if (cursor.pixel)
+ if (const auto* sc = find_clickable_scenery(cursor.pixel))
+ inspected_scenery = {InPlaceInit, sc->chunk, sc->pos};
+ if (inspected_scenery)
+ {
+ auto [c, t] = w[*inspected_scenery];
+ if (auto s = t.scenery())
+ {
+ char buf[32]; std::snprintf(buf, sizeof buf, "i_0x%p", (void*)&s);
+ auto b = push_id(buf);
+ auto dpi = M->dpi_scale();
+ ImGui::SetNextWindowSize({300*dpi[0], 0});
+ auto b2 = begin_window("inspector"_s);
+ if (entities::inspect_type(s))
+ c.mark_scenery_modified();
+ }
+ }
+}
+
+} // namespace floormat
diff --git a/editor/imgui.cpp b/editor/imgui.cpp
index 38bae066..1accd9e5 100644
--- a/editor/imgui.cpp
+++ b/editor/imgui.cpp
@@ -2,10 +2,6 @@
#include "floormat/main.hpp"
#include "compat/format.hpp"
#include "imgui-raii.hpp"
-#include "world.hpp"
-#include "scenery.hpp"
-#include "inspect.hpp"
-#include "main/clickable.hpp"
#include <Magnum/Math/Color.h>
namespace floormat {
@@ -150,29 +146,6 @@ void app::draw_tile_under_cursor()
{window_size[0]*.5f - size.x/2, 3*dpi[1]}, (unsigned)-1, buf);
}
-void app::draw_inspector()
-{
- auto b = push_id("inspector");
- auto& w = M->world();
- if (cursor.pixel)
- if (const auto* sc = find_clickable_scenery(cursor.pixel))
- inspected_scenery = {InPlaceInit, sc->chunk, sc->pos};
- if (inspected_scenery)
- {
- auto [c, t] = w[*inspected_scenery];
- if (auto s = t.scenery())
- {
- char buf[32]; std::snprintf(buf, sizeof buf, "i_0x%p", (void*)&s);
- auto b = push_id(buf);
- auto dpi = M->dpi_scale();
- ImGui::SetNextWindowSize({300*dpi[0], 0});
- auto b2 = begin_window("inspector"_s);
- if (entities::inspect_type(s))
- c.mark_scenery_modified();
- }
- }
-}
-
void app::draw_editor_pane(float main_menu_height)
{
auto* ed = _editor.current_tile_editor();
diff --git a/editor/inspect-types.cpp b/editor/inspect-types.cpp
index d04c7913..69d40d81 100644
--- a/editor/inspect-types.cpp
+++ b/editor/inspect-types.cpp
@@ -7,17 +7,18 @@
#include "inspect.hpp"
#include "loader/loader.hpp"
#include <Corrade/Containers/ArrayViewStl.h>
-#include <Corrade/Containers/String.h>
//#define TEST_STR
-namespace floormat::entities {
-
#ifdef TEST_STR
-static String my_str;
+#include <Corrade/Containers/String.h>
+static Corrade::Containers::String my_str;
#endif
-template<> struct entity_accessors<scenery_ref> {
+namespace floormat::entities {
+
+template<>
+struct entity_accessors<scenery_ref> {
static constexpr auto accessors()
{
using entity = Entity<scenery_ref>;