Graphic::Loader::Loader(Graphic &g, Resources &r):
- graph(g),
- res(r)
+ DataFile::CollectionObjectLoader<Graphic, Resources>(g, &r)
{
add("texture", &Loader::texture);
add("slice", &Loader::slice);
void Graphic::Loader::texture(const string &n)
{
- graph.texture = &res.get<GL::Texture2D>(n);
- graph.slice = Geometry(0, 0, graph.texture->get_width(), graph.texture->get_height());
+ obj.texture = &get_collection().get<GL::Texture2D>(n);
+ obj.slice = Geometry(0, 0, obj.texture->get_width(), obj.texture->get_height());
}
void Graphic::Loader::slice(unsigned x, unsigned y, unsigned w, unsigned h)
{
- graph.slice = Geometry(x, y, w, h);
+ obj.slice = Geometry(x, y, w, h);
}
void Graphic::Loader::border()
{
- load_sub(graph.border);
+ load_sub(obj.border);
}
void Graphic::Loader::shadow()
{
- load_sub(graph.shadow);
+ load_sub(obj.shadow);
}
} // namespace GLtk
#include <msp/gl/primitivebuilder.h>
#include <msp/gl/texture2d.h>
-#include <msp/datafile/loader.h>
+#include <msp/datafile/objectloader.h>
#include "geometry.h"
namespace Msp {
class Graphic
{
public:
- class Loader: public DataFile::Loader
+ class Loader: public DataFile::CollectionObjectLoader<Graphic, Resources>
{
- private:
- Graphic &graph;
- Resources &res;
-
public:
- typedef Resources Collection;
-
Loader(Graphic &, Resources &);
- Graphic &get_object() const { return graph; }
+
private:
void texture(const std::string &);
void slice(unsigned, unsigned, unsigned, unsigned);
namespace GLtk {
Logic::Loader::Loader(Logic &l, const map<string, Widget *> &w):
- logic(l),
+ DataFile::ObjectLoader<Logic>(l),
widgets(w)
{
add("bind", &Loader::bind);
act.type = data.substr(0, colon);
if(colon!=string::npos)
act.data = data.substr(colon+1);
- logic.bindings.push_back(act);
+ obj.bindings.push_back(act);
}
} // namespace GLtk
#include <map>
#include <string>
#include <sigc++/slot.h>
-#include <msp/datafile/loader.h>
+#include <msp/datafile/objectloader.h>
namespace Msp {
namespace GLtk {
class Logic
{
public:
- class Loader: public DataFile::Loader
+ class Loader: public DataFile::ObjectLoader<Logic>
{
private:
- Logic &logic;
const std::map<std::string, Widget *> &widgets;
public:
Style::Loader::Loader(Style &s, Resources &r):
- style(s),
- res(r)
+ DataFile::CollectionObjectLoader<Style, Resources>(s, &r)
{
- if(!style.font)
+ if(!obj.font)
{
- style.font = &r.get_default_font();
- style.font_size = style.font->get_native_size();
+ obj.font = &get_collection().get_default_font();
+ obj.font_size = obj.font->get_native_size();
}
add("font", &Loader::font);
void Style::Loader::font(const string &n)
{
- style.font = &res.get<GL::Font>(n);
- style.font_size = style.font->get_native_size();
+ obj.font = &get_collection().get<GL::Font>(n);
+ obj.font_size = obj.font->get_native_size();
}
void Style::Loader::font_color(float r, float g, float b)
{
- style.font_color = GL::Color(r, g, b);
+ obj.font_color = GL::Color(r, g, b);
}
void Style::Loader::part()
void Style::Loader::part(const string &n)
{
Part p(n);
- load_sub(p, res);
- style.parts.push_back(p);
+ load_sub(p, get_collection());
+ obj.parts.push_back(p);
}
} // namespace GLtk
#include <msp/gl/color.h>
#include <msp/gl/font.h>
-#include <msp/datafile/loader.h>
+#include <msp/datafile/objectloader.h>
#include "part.h"
namespace Msp {
class Style
{
public:
- class Loader: public DataFile::Loader
+ class Loader: public DataFile::CollectionObjectLoader<Style, Resources>
{
- private:
- Style &style;
- Resources &res;
-
public:
- typedef Resources Collection;
-
Loader(Style &, Resources &);
- Style &get_object() const { return style; }
- Resources &get_collection() const { return res; }
+
private:
void font(const std::string &);
void font_color(float, float, float);