]> git.tdb.fi Git - libs/game.git/blobdiff - source/game/resources.cpp
Load the various setups through resources
[libs/game.git] / source / game / resources.cpp
index 0893f97525c564b6b5356e1fda5c420b309fbcc9..a4f9e76e7d1e9ee3a3bd63a9ad4b9c48eb9cc144 100644 (file)
@@ -2,17 +2,24 @@
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
 #include "resources.h"
+#include "setups.h"
 
 using namespace std;
 
 namespace Msp::Game {
 
+Resources::Resources()
+{
+       add_type<CameraSetup>().suffix(".camera.setup");
+}
+
+
 ApplicationResources::ApplicationResources()
 {
        FS::Path data_dir = FS::get_sys_data_dir()/"data";
 #ifdef DEBUG
        if(FS::exists(data_dir))
-               dir_src.add_directory(data_dir);
+               add_dir(data_dir);
        add_source(dir_src);
 #endif
 
@@ -27,4 +34,15 @@ ApplicationResources::ApplicationResources()
        add_source(pack_src);
 }
 
+void ApplicationResources::add_dir(const FS::Path &path)
+{
+       dir_src.add_directory(path);
+       for(const string &f: FS::list_files(path))
+       {
+               FS::Path p = path/f;
+               if(FS::is_dir(p))
+                       add_dir(p);
+       }
+}
+
 } // namespace Msp::Game