1 | /*! |
---|
2 | * @file element_2d.h |
---|
3 | * @brief Definition of the 2D elements rendered on top through the GraphicsEngine |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _ELEMENT_2D_H |
---|
7 | #define _ELEMENT_2D_H |
---|
8 | |
---|
9 | #include "base_object.h" |
---|
10 | |
---|
11 | // FORWARD DECLARATION |
---|
12 | class PNode; |
---|
13 | |
---|
14 | //!< An enumerator defining the Depth of a 2D-element. |
---|
15 | typedef enum |
---|
16 | { |
---|
17 | E2D_TOP, //!< Will be rendered on top of everything else |
---|
18 | E2D_MEDIUM, //!< Will be rendered on the medium Layer. |
---|
19 | E2D_BOTTOM, //!< Will be rendered on the bottom Layer |
---|
20 | E2D_BELOW_ALL //!< Will be rendered below the 3D-scene. @todo make this work. |
---|
21 | } E2DLayer; |
---|
22 | |
---|
23 | |
---|
24 | typedef enum |
---|
25 | { |
---|
26 | ELEM2D_ALIGN_NONE, |
---|
27 | ELEM2D_ALIGN_LEFT, |
---|
28 | ELEM2D_ALIGN_RIGHT, |
---|
29 | ELEM2D_ALIGN_CENTER, |
---|
30 | ELEM2D_ALIGN_SCREEN_CENTER |
---|
31 | } ELEM2D_ALIGNMENT; |
---|
32 | |
---|
33 | //! A Struct defining the Position of an Element in 2D-space |
---|
34 | struct Position2D |
---|
35 | { |
---|
36 | float x; //!< The x-coordinate. |
---|
37 | float y; //!< The y-coordinate. |
---|
38 | float depth; //!< The distance from the viewing plane. |
---|
39 | |
---|
40 | }; |
---|
41 | |
---|
42 | //! A class for ... |
---|
43 | class Element2D : public BaseObject { |
---|
44 | |
---|
45 | public: |
---|
46 | Element2D(); |
---|
47 | virtual ~Element2D(); |
---|
48 | |
---|
49 | void setPosition(int xCoord, int yCoord); |
---|
50 | void setLayer(E2DLayer layer); |
---|
51 | /** @param visible true if the Element should be visible false otherwise (will not be rendered) */ |
---|
52 | inline void setVisibility(bool visible) { this->visible = visible; }; |
---|
53 | /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */ |
---|
54 | inline void setBindNode(const PNode* bindNode) { this->bindNode = bindNode; }; |
---|
55 | |
---|
56 | /** @returns the visibility state */ |
---|
57 | inline bool isVisible() { return this->visible; }; |
---|
58 | |
---|
59 | void positioning(); |
---|
60 | virtual void tick(float dt); |
---|
61 | virtual void draw() const = NULL; |
---|
62 | |
---|
63 | private: |
---|
64 | void init(); |
---|
65 | |
---|
66 | private: |
---|
67 | bool visible; |
---|
68 | int relPos2D[2]; //!< X-coord, Y-Coord (relative to the Coordinates of the alignment if given.) |
---|
69 | Position2D absPos2D; //!< The absolute position of the 2D-Element. |
---|
70 | E2DLayer layer; |
---|
71 | |
---|
72 | ELEM2D_ALIGNMENT alignment; //!< How the Element is aligned around its Position |
---|
73 | const PNode* bindNode; //!< a node over which to display this 2D-element |
---|
74 | }; |
---|
75 | |
---|
76 | |
---|
77 | #endif /* _ELEMENT_2D_H */ |
---|