]> git.tdb.fi Git - libs/gltk.git/commitdiff
Remove file lookup from Resources since a better mechanism exists now
authorMikko Rasa <tdb@tdb.fi>
Sun, 2 Dec 2012 17:27:05 +0000 (19:27 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 2 Dec 2012 17:27:05 +0000 (19:27 +0200)
source/resources.cpp
source/resources.h

index e83c1bb178e5adea2acc6525acfdc01c0b8b87f1..b7586e886ee41df0eb711230c1ebe4bfcba8402c 100644 (file)
@@ -7,33 +7,11 @@ namespace Msp {
 namespace GLtk {
 
 Resources::Resources():
-       path("."),
        default_font(0)
-{
-       init();
-}
-
-Resources::Resources(const FS::Path &fn):
-       path(FS::dirname(fn)),
-       default_font(0)
-{
-       init();
-
-       DataFile::load(*this, fn.str());
-}
-
-void Resources::init()
 {
        add_type<Graphic>().keyword("graphic");
-       add_type<GL::Texture2D>().keyword("texture").creator(&Resources::create_texture);
-       add_type<GL::Font>().creator(&Resources::create_font);
-}
-
-void Resources::set_path(const FS::Path &p)
-{
-       /* XXX bad, should change Collection API to allow creators to form paths
-       relative to the datafile location */
-       path = p;
+       add_type<GL::Texture2D>().keyword("texture");
+       add_type<GL::Font>().keyword("font");
 }
 
 const GL::Font &Resources::get_default_font() const
@@ -44,23 +22,6 @@ const GL::Font &Resources::get_default_font() const
        return *default_font;
 }
 
-GL::Font *Resources::create_font(const string &name)
-{
-       RefPtr<GL::Font> fnt = new GL::Font;
-       DataFile::load(*fnt, (path/name).str(), *this);
-       if(!default_font)
-               default_font = fnt.get();
-       return fnt.release();
-}
-
-GL::Texture2D *Resources::create_texture(const string &name)
-{
-       RefPtr<GL::Texture2D> tex = new GL::Texture2D;
-       tex->load_image((path/name).str());
-       tex->set_min_filter(GL::LINEAR);
-       return tex.release();
-}
-
 
 Resources::Loader::Loader(Resources &r):
        Collection::Loader(r),
index 52da3952916fb780cb873716d30f9381b86824d1..d183fc6c1cd2b94ac03f9401688e13240a27464e 100644 (file)
@@ -35,17 +35,10 @@ public:
                void style(const std::string &);
        };
 
+public:
        Resources();
-       Resources(const FS::Path &);
-private:
-       void init();
 
-public:
-       void set_path(const FS::Path &);
        const GL::Font &get_default_font() const;
-private:
-       GL::Font *create_font(const std::string &);
-       GL::Texture2D *create_texture(const std::string &);
 };
 
 } // namespace GLtk