]> git.tdb.fi Git - libs/game.git/commitdiff
Make the shape component available for generated setups
authorMikko Rasa <tdb@tdb.fi>
Sat, 15 Mar 2025 10:53:46 +0000 (12:53 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 15 Mar 2025 12:55:38 +0000 (14:55 +0200)
source/game/setups.mgs
source/game/setups_special.cpp [new file with mode: 0644]
source/game/setups_special.h [new file with mode: 0644]
source/game/shape.cpp
source/game/shape.h

index 8e62edc821de1af2fadfcfe53a8ffdb530f91a70..d5ccfa301af5e808ee2a718a69c41c88ed7d4558 100644 (file)
@@ -1,6 +1,12 @@
 namespace "Msp::Game";
 api "MSPGAME_API" "msp/game/mspgame_api.h";
 
+external "msp/game/setups_special.h"
+{
+       namespace "Msp::Game";
+       component Shape;
+};
+
 enum CameraScaling
 {
        value ORIGINAL_SIZE;
diff --git a/source/game/setups_special.cpp b/source/game/setups_special.cpp
new file mode 100644 (file)
index 0000000..1e0ca79
--- /dev/null
@@ -0,0 +1,27 @@
+#include "setups_special.h"
+#include <msp/geometry/loader.h>
+
+namespace Msp::Game {
+
+ShapeSetup::Loader::Loader(ShapeSetup &s):
+       ObjectLoader(s)
+{
+       static ActionMap shared_actions;
+       set_actions(shared_actions);
+}
+
+void ShapeSetup::Loader::init_actions()
+{
+       add("render_detail", &ShapeSetup::render_detail);
+       add("shape", &Loader::shape);
+       add("technique_name", &ShapeSetup::technique_name);
+}
+
+void ShapeSetup::Loader::shape()
+{
+       Geometry::Loader<float, 3> ldr;
+       load_sub_with(ldr);
+       obj.shape = ldr.take_shape();
+}
+
+} // namespace Msp::Game
diff --git a/source/game/setups_special.h b/source/game/setups_special.h
new file mode 100644 (file)
index 0000000..9e6d206
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef MSP_GAME_SETUPSSPECIAL_H_
+#define MSP_GAME_SETUPSSPECIAL_H_
+
+#include <memory>
+#include <msp/datafile/objectloader.h>
+#include <msp/geometry/shape.h>
+#include "mspgame_api.h"
+
+namespace Msp::Game {
+
+struct MSPGAME_API ShapeSetup
+{
+       class MSPGAME_API Loader: public DataFile::ObjectLoader<ShapeSetup>
+       {
+       public:
+               Loader(ShapeSetup &);
+
+       private:
+               void init_actions() override;
+
+               void shape();
+       };
+
+       std::unique_ptr<Geometry::Shape<float, 3>> shape;
+       std::string technique_name;
+       unsigned render_detail = 4;
+};
+
+} // namespace Msp::Game
+
+#endif
index 05d3db41ef0f41f8578d43a4e12b954e667e0473..4834e942e35f4c8c241d24ece8ca6ba73cd91bde 100644 (file)
@@ -1,5 +1,4 @@
 #include "shape.h"
-#include <msp/geometry/loader.h>
 
 using namespace std;
 
@@ -13,25 +12,4 @@ Shape::Shape(Handle<Entity> e, const Setup &s):
                throw invalid_argument("Shape::Shape");
 }
 
-ShapeSetup::Loader::Loader(ShapeSetup &s):
-       ObjectLoader(s)
-{
-       static ActionMap shared_actions;
-       set_actions(shared_actions);
-}
-
-void ShapeSetup::Loader::init_actions()
-{
-       add("render_detail", &ShapeSetup::render_detail);
-       add("shape", &Loader::shape);
-       add("technique_name", &ShapeSetup::technique_name);
-}
-
-void ShapeSetup::Loader::shape()
-{
-       Geometry::Loader<float, 3> ldr;
-       load_sub_with(ldr);
-       obj.shape = ldr.take_shape();
-}
-
 } // namespace Msp::Game
index 8ebec84009ab9f642e4a6b658c31494a44f2ab4f..384c04753e84164dbd5cb2a7670c994908cf3655 100644 (file)
@@ -1,33 +1,12 @@
 #ifndef MSP_GAME_SHAPE_H_
 #define MSP_GAME_SHAPE_H_
 
-#include <memory>
-#include <msp/datafile/objectloader.h>
-#include <msp/geometry/shape.h>
 #include "component.h"
 #include "mspgame_api.h"
+#include "setups_special.h"
 
 namespace Msp::Game {
 
-// TODO Make this visible to the setup generator
-struct MSPGAME_API ShapeSetup
-{
-       class MSPGAME_API Loader: public DataFile::ObjectLoader<ShapeSetup>
-       {
-       public:
-               Loader(ShapeSetup &);
-
-       private:
-               void init_actions() override;
-
-               void shape();
-       };
-
-       std::unique_ptr<Geometry::Shape<float, 3>> shape;
-       std::string technique_name;
-       unsigned render_detail = 4;
-};
-
 class MSPGAME_API Shape: public Component
 {
 public: