Pārlūkot izejas kodu

testbed: meta setup function proto

skypjack 10 mēneši atpakaļ
vecāks
revīzija
4dd03da2e2
4 mainītis faili ar 40 papildinājumiem un 0 dzēšanām
  1. 2 0
      TODO
  2. 1 0
      testbed/CMakeLists.txt
  3. 30 0
      testbed/meta/meta.cpp
  4. 7 0
      testbed/meta/meta.h

+ 2 - 0
TODO

@@ -35,3 +35,5 @@ TODO:
 * meta non-const allow_cast overloads: (const int &) to (int &) is not allowed, but (const int &) to (double &) is allowed (support only for convertibles)
 * review build process for testbed (i.e. tests first due to SDL)
 * use any for meta_custom_node
+* support names directly on meta nodes
+* fwd meta_ctx (and update testbed)

+ 1 - 0
testbed/CMakeLists.txt

@@ -51,6 +51,7 @@ target_sources(
 	PRIVATE
         application/application.cpp
         application/context.cpp
+        meta/meta.cpp
         system/hud_system.cpp
         system/imgui_system.cpp
         system/input_system.cpp

+ 30 - 0
testbed/meta/meta.cpp

@@ -0,0 +1,30 @@
+#include <component/input_listener_component.h>
+#include <component/position_component.h>
+#include <component/rect_component.h>
+#include <component/renderable_component.h>
+#include <entt/core/hashed_string.hpp>
+#include <entt/davey/meta.hpp>
+#include <entt/meta/factory.hpp>
+#include <meta/meta.h>
+
+namespace testbed {
+
+void meta_setup() {
+    using namespace entt::literals;
+
+    entt::meta_factory<input_listener_component>()
+        .custom<entt::davey_data>("input listener")
+        .data<&input_listener_component::command>("command"_hs)
+        .custom<entt::davey_data>("command");
+
+    entt::meta_factory<position_component>()
+        .custom<entt::davey_data>("position")
+        .data<&SDL_FPoint::x>("x"_hs)
+        .custom<entt::davey_data>("x")
+        .data<&SDL_FPoint::y>("y"_hs)
+        .custom<entt::davey_data>("y");
+
+    // bind components...
+}
+
+} // namespace testbed

+ 7 - 0
testbed/meta/meta.h

@@ -0,0 +1,7 @@
+#pragma once
+
+namespace testbed {
+
+void meta_setup();
+
+} // namespace testbed