]> Dogcows Code - chaz/yoink/blob - src/Hud.hh
arch linux prefers pkgconfig for finding lua
[chaz/yoink] / src / Hud.hh
1
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
4 *
5 * vi:ts=4 sw=4 tw=75
6 *
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
9 *
10 **************************************************************************/
11
12 #ifndef _HUD_HH_
13 #define _HUD_HH_
14
15 /**
16 * @file Hud.hh
17 * Heads-up Display
18 */
19
20 #include <Moof/Drawable.hh>
21 #include <Moof/Layer.hh>
22 #include <Moof/Math.hh>
23 //#include <Moof/Rectangle.hh>
24 #include <Moof/Texture.hh>
25
26 #include "GameState.hh"
27
28
29 class Rectangle;
30
31 // TODO this stuff is still just hacked up
32
33 class ProgressBar : public Mf::Drawable
34 {
35 public:
36
37 ProgressBar(const Mf::Texture& tilemap, Mf::Texture::TileIndex index);
38
39 void resize(const Mf::Rectangle& rect);
40
41 void setProgress(Mf::Scalar progress);
42
43 void draw(Mf::Scalar alpha = 0.0) const;
44
45 private:
46
47 Mf::Scalar mProgress;
48
49 Mf::Vector2 mVertices[8];
50 Mf::Scalar mWidth;
51
52 Mf::Texture mTilemap;
53 Mf::Scalar mTexCoords[8];
54 Mf::Scalar mMidCoords[2];
55 };
56
57
58 class Hud;
59 typedef boost::shared_ptr<Hud> HudP;
60
61 class Hud : public Mf::Layer
62 {
63 public:
64
65 Hud(GameState& state);
66
67 static HudP alloc(GameState& state)
68 {
69 return HudP(new Hud(state));
70 }
71
72 void setBar1Progress(Mf::Scalar progress)
73 {
74 // pass through
75 mBar1.setProgress(progress);
76 }
77
78 void setBar2Progress(Mf::Scalar progress)
79 {
80 // pass through
81 mBar2.setProgress(progress);
82 }
83
84 void setNumber(unsigned value);
85
86 void resize(int width, int height);
87
88 void update(Mf::Scalar t, Mf::Scalar dt);
89 void draw(Mf::Scalar alpha = 0.0) const;
90 bool handleEvent(const Mf::Event& event);
91
92 private:
93
94 GameState& mState;
95
96 ProgressBar mBar1;
97 ProgressBar mBar2;
98
99 unsigned mNumber;
100 Mf::Texture mFont;
101
102 Mf::Matrix4 mProjection;
103 };
104
105
106 #endif // _HUD_HH_
107
This page took 0.033445 seconds and 4 git commands to generate.