1 #include <msp/gl/transform.h>
11 Part::Part(const string &n):
14 for(unsigned i=0; i<N_STATES_; ++i)
18 const Graphic *Part::get_graphic(State state) const
21 throw InvalidParameterValue("Invalid state");
23 return graphic[state];
26 void Part::render(const Geometry &parent, State state) const
31 Geometry rgeom = geom;
32 align.apply(rgeom, parent, margin);
33 GL::translate(rgeom.x, rgeom.y, 0);
34 graphic[state]->render(rgeom.w, rgeom.h);
38 Part::Loader::Loader(Part &p, Resources &r):
39 DataFile::CollectionObjectLoader<Part>(p, &r)
41 add("graphic", &Loader::graphic);
42 add("align", &Loader::align);
43 add("fill", &Loader::fill);
44 add("margin", &Loader::margin);
45 add("size", &Loader::size);
48 Part::Loader::~Loader()
50 for(unsigned i=0; i<N_STATES_; ++i)
53 const Graphic &grph = *obj.graphic[i];
54 const Sides &shadow = grph.get_shadow();
55 obj.geom.w = max(obj.geom.w, grph.get_width()-shadow.left-shadow.right);
56 obj.geom.h = max(obj.geom.h, grph.get_height()-shadow.bottom-shadow.top);
60 void Part::Loader::graphic(State s, const string &n)
62 Graphic *grph = get_collection().get<Graphic>(n);
63 for(int i=0; i<N_STATES_; ++i)
65 obj.graphic[i] = grph;
68 void Part::Loader::align(float x, float y)
74 void Part::Loader::fill(float w, float h)
80 void Part::Loader::margin()
85 void Part::Loader::size(unsigned w, unsigned h)