From e5da6bc3e1f32342e661893fbb3c1cf873422c2e Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 16 Jan 2013 18:58:51 +0200 Subject: [PATCH] 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. --- source/resources.cpp | 26 ++++++++++++++++++++++++-- source/resources.h | 7 +++++++ 2 files changed, 31 insertions(+), 2 deletions(-) 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