]> git.tdb.fi Git - libs/demoscene.git/commitdiff
Add a builtin resource collection for storing necessary data
authorMikko Rasa <tdb@tdb.fi>
Wed, 12 Jun 2019 18:58:41 +0000 (21:58 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 12 Jun 2019 18:58:41 +0000 (21:58 +0300)
Build
source/resources.cpp
source/resources.h

diff --git a/Build b/Build
index e0d8537d261a7aae68ad569d05c709b00f543706..6fd553a855e25b58786cfb2762968accdf55de47 100644 (file)
--- a/Build
+++ b/Build
@@ -10,9 +10,20 @@ package "mspdemoscene"
        require "mspgl";
        require "mspal";
 
+       generate "RES"
+       {
+               in_suffix ".glsl";
+               out_suffix ".cpp";
+               command "mspdatatool";
+               arguments "-i" "-n" "Msp::DemoScene";
+               out_argument "-o";
+               processing_unit DIRECTORY;
+       };
+
        library "mspdemoscene"
        {
                source "source";
+               source "data";
                install true;
                install_map
                {
index 1742f06d41694cdb689b2db6be0a3b17be617d5a..f44d8c1985d05ef1e45c3651bcaa0a8b77cb4d1f 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/datafile/builtinsource.h>
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
 #include "resources.h"
@@ -7,6 +8,13 @@ using namespace std;
 namespace Msp {
 namespace DemoScene {
 
+void init_data(DataFile::BuiltinSource &);
+
+Resources::Resources()
+{
+       add_source(get_builtin_source());
+}
+
 Resources::Resources(const string &pack_name):
        ui_font(0),
        ui_text_technique(0)
@@ -27,6 +35,28 @@ Resources::Resources(const string &pack_name):
                pack_source.add_pack_file(pack_name);
                add_source(pack_source);
        }
+
+       add_source(get_builtin_source());
+}
+
+const DataFile::CollectionSource &Resources::get_builtin_source()
+{
+       static DataFile::BuiltinSource builtin_src;
+       bool init_done = false;
+
+       if(!init_done)
+       {
+               init_data(builtin_src);
+               init_done = true;
+       }
+
+       return builtin_src;
+}
+
+Resources &Resources::get_builtins()
+{
+       static Resources builtins;
+       return builtins;
 }
 
 const GL::Font &Resources::get_ui_font() const
index bb86933e39b7ebaf734f983d17ee5bddaf42f09b..fc7e7d2818c9abd8c27945712ee03770e48a8791 100644 (file)
@@ -19,9 +19,15 @@ private:
        const Msp::GL::Font *ui_font;
        const Msp::GL::Technique *ui_text_technique;
 
+       Resources();
 public:
        Resources(const std::string &);
 
+private:
+       static const DataFile::CollectionSource &get_builtin_source();
+public:
+       static Resources &get_builtins();
+
        const Msp::GL::Font &get_ui_font() const;
        const Msp::GL::Technique &get_ui_text_technique() const;
        void set_ui_text_resources(const std::string &, const std::string &);