]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/resources.cpp
Enable loading of entry widgets from datafiles
[libs/gltk.git] / source / resources.cpp
index 35af009697647a8a2900718b46728ff3a0c8e2c3..2cfe022c1a1d74d5035aa855922dcc7ba9e5f0c8 100644 (file)
@@ -17,9 +17,7 @@ Resources::Resources():
        path("."),
        default_font(0)
 {
-       add_keyword<GL::Font>("font");
        add_keyword<Graphic>("graphic");
-       add_keyword<Style>("style");
 
        add_creator(&Resources::create_font);
        add_creator(&Resources::create_texture);
@@ -41,7 +39,7 @@ const GL::Font &Resources::get_default_font() const
 GL::Font *Resources::create_font(const string &name)
 {
        RefPtr<GL::Font> fnt=new GL::Font;
-       DataFile::load<GL::Font, Resources &>(*fnt, (path/(name+".font")).str(), *this);
+       DataFile::load<GL::Font, Resources &>(*fnt, (path/name).str(), *this);
        if(!default_font)
                default_font=fnt.get();
        return fnt.release();
@@ -50,7 +48,7 @@ GL::Font *Resources::create_font(const string &name)
 GL::Texture2D *Resources::create_texture(const string &name)
 {
        RefPtr<GL::Texture2D> tex=new GL::Texture2D;
-       tex->load_image((path/(name+".png")).str());
+       tex->load_image((path/name).str());
        tex->set_min_filter(GL::LINEAR);
        return tex.release();
 }
@@ -62,6 +60,7 @@ Resources::Loader::Loader(Resources &r):
 {
        add("default_font", &Loader::default_font);
        add("font", &Loader::font);
+       add("style", &Loader::style);
 }
 
 void Resources::Loader::default_font(const string &name)
@@ -79,5 +78,13 @@ void Resources::Loader::font(const string &name)
        fnt.release();
 }
 
+void Resources::Loader::style(const string &name)
+{
+       RefPtr<Style> stl=new Style(res);
+       load_sub(*stl, res);
+       res.add(name, stl.get());
+       stl.release();
+}
+
 } // namespace GLtk
 } // namespace Msp