X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fresources.cpp;h=e14934de03e89e94fe077452513a5ac542dcb07f;hb=cc966845eb995805e22d63600d8670328c4feae3;hp=b1b129b757fd6a65139a9cfb00c6a8663e75af17;hpb=94ac63c6f41227ce57790d9903039ec18a6ef3fd;p=libs%2Fgltk.git diff --git a/source/resources.cpp b/source/resources.cpp index b1b129b..e14934d 100644 --- a/source/resources.cpp +++ b/source/resources.cpp @@ -1,11 +1,4 @@ -/* $Id$ - -This file is part of libmspgltk -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include +#include #include "resources.h" using namespace std; @@ -13,45 +6,62 @@ using namespace std; namespace Msp { namespace GLtk { -Resources::Resources(): - path("."), - default_font(0) +Resources::Resources() { - add_keyword("graphic"); - add_keyword("texture"); - - add_creator(&Resources::create_font); - add_creator(&Resources::create_texture); + init(); } -void Resources::set_path(const FS::Path &p) +Resources::Resources(const FS::Path &fn) { - path=p; + init(); + + dir_src = new DataFile::DirectorySource; + dir_src->add_directory(FS::dirname(fn)); + add_source(*dir_src); + + DataFile::load(*this, fn.str()); } -const GL::Font &Resources::get_default_font() const +void Resources::init() { - if(!default_font) - throw InvalidState("No default font"); + default_font = 0; + dir_src = 0; + add_type().keyword("graphic"); + add_type().keyword("texture").creator(&Resources::create_texture); + add_type().keyword("font"); + add_type