From: Mikko Rasa Date: Wed, 16 Jan 2013 16:58:51 +0000 (+0200) Subject: Reintroduce the Resources constructor that immediately loads a file X-Git-Url: http://git.tdb.fi/?p=libs%2Fgltk.git;a=commitdiff_plain;h=e5da6bc3e1f32342e661893fbb3c1cf873422c2e Reintroduce the Resources constructor that immediately loads a file This covers many simple use cases and avoids the need of creating a sub-class to add sources or load data before a Root is created. --- diff --git a/source/resources.cpp b/source/resources.cpp index 045096e..36be79e 100644 --- a/source/resources.cpp +++ b/source/resources.cpp @@ -6,15 +6,37 @@ using namespace std; namespace Msp { namespace GLtk { -Resources::Resources(): - default_font(0) +Resources::Resources() { + init(); +} + +Resources::Resources(const FS::Path &fn) +{ + init(); + + dir_src = new DataFile::DirectorySource; + dir_src->add_directory(FS::dirname(fn)); + add_source(*dir_src); + + DataFile::load(*this, fn.str()); +} + +void Resources::init() +{ + default_font = 0; + dir_src = 0; add_type().keyword("graphic"); add_type().keyword("texture").creator(&Resources::create_texture); add_type().keyword("font"); add_type