X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fresources.h;h=e4d7f731cf10aff1f634e97810a81d9c85cc479d;hb=73afd124ab87e8bace98db55517a56c797a9b8c7;hp=40e44220a5b7de1b53011a14cb16d2ebe67ee6ee;hpb=131ac8ff2c06f94d40f4bf98d4a6ec0d113cdffc;p=libs%2Fgltk.git diff --git a/source/resources.h b/source/resources.h index 40e4422..e4d7f73 100644 --- a/source/resources.h +++ b/source/resources.h @@ -1,62 +1,58 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #ifndef MSP_GLTK_RESOURCES_H_ #define MSP_GLTK_RESOURCES_H_ #include #include -#include +#include +#include #include "graphic.h" #include "style.h" namespace Msp { namespace GLtk { -class Resources +/** +Stores resources such as styles and graphics. All widgets require a Resources +instance in constructor. +*/ +class Resources: public DataFile::Collection { -public: +private: + FS::Path path; + GL::Font *default_font; - class Loader: public Msp::DataFile::Loader +public: + class Loader: public Collection::Loader { - public: - Loader(Resources &); private: Resources &res; + public: + Loader(Resources &); + private: + void default_font(const std::string &); void font(const std::string &); - void texture(const std::string &); - void graphic(const std::string &); - void style(const std::string &, const std::string &); + void style(const std::string &); }; Resources(); - ~Resources(); - const GL::Font &get_font(const std::string &) const; - const GL::Font &get_default_font() const; - const GL::Texture2D &get_texture(const std::string &) const; - const Graphic &get_graphic(const std::string &) const; - const Style &get_style(const std::string &, const std::string &) const; + Resources(const FS::Path &); private: - struct StyleId - { - std::string widget; - std::string name; - - StyleId(const std::string &w, const std::string &n): widget(w), name(n) { } - bool operator<(const StyleId &) const; - }; - - typedef std::map FontMap; - typedef std::map TextureMap; - typedef std::map GraphicMap; - typedef std::map StyleMap; + void init(); - FontMap fonts; - GL::Font *default_font; - TextureMap textures; - GraphicMap graphics; - StyleMap styles; - - Resources(const Resources &); - Resources &operator=(const Resources &); +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