From: Mikko Rasa Date: Thu, 4 Nov 2010 07:12:01 +0000 (+0000) Subject: Add a constructor to Resources that loads a datafile X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=ae991f3bbd83fa0afff5e1fc31be50e1f2d17875;p=libs%2Fgltk.git Add a constructor to Resources that loads a datafile --- diff --git a/source/resources.cpp b/source/resources.cpp index 7415beb..825fc25 100644 --- a/source/resources.cpp +++ b/source/resources.cpp @@ -6,6 +6,7 @@ Distributed under the LGPL */ #include +#include #include "resources.h" using namespace std; @@ -16,6 +17,20 @@ 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_keyword("graphic"); add_keyword("texture"); @@ -26,6 +41,8 @@ Resources::Resources(): 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; } diff --git a/source/resources.h b/source/resources.h index c61d38a..e4d7f73 100644 --- a/source/resources.h +++ b/source/resources.h @@ -43,7 +43,11 @@ public: }; Resources(); + Resources(const FS::Path &); +private: + void init(); +public: void set_path(const FS::Path &); const GL::Font &get_default_font() const; private: