]> git.tdb.fi Git - libs/game.git/blobdiff - source/game/resources.cpp
Add resource container references to Director and Stage
[libs/game.git] / source / game / resources.cpp
diff --git a/source/game/resources.cpp b/source/game/resources.cpp
new file mode 100644 (file)
index 0000000..0893f97
--- /dev/null
@@ -0,0 +1,30 @@
+#include <msp/core/application.h>
+#include <msp/fs/dir.h>
+#include <msp/fs/stat.h>
+#include "resources.h"
+
+using namespace std;
+
+namespace Msp::Game {
+
+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_source(dir_src);
+#endif
+
+       FS::Path main_pack = FS::get_sys_data_dir()/(Application::get_name()+".mdp");
+       if(FS::exists(main_pack))
+               pack_src.add_pack_file(main_pack.str());
+       if(FS::exists(data_dir))
+       {
+               for(const string &f: FS::list_filtered(data_dir, "\\.mdp$"))
+                       pack_src.add_pack_file((data_dir/f).str());
+       }
+       add_source(pack_src);
+}
+
+} // namespace Msp::Game