ec69b4c192f299ef9ae03756a5816fcf12be3ab3.svn-base (1469B)
1 #ifndef HUD_H 2 #define HUD_H 3 4 #include "Utils.h" 5 #include "Console.h" 6 #include "Actor.h" 7 #include "MiscDraw.h" 8 #include "Event.h" 9 10 11 struct WidgetElement 12 { 13 SDL_Rect pos; 14 SDL_Texture* img; 15 }; 16 17 class Widget 18 { 19 public: 20 21 Widget() {} 22 23 Widget(SDL_Renderer* ren, SDL_Rect pos) : mPos(pos), mren(ren), mDisplay(true) 24 { 25 } 26 27 SDL_Rect* GetPos() 28 { 29 return &mPos; 30 } 31 32 virtual bool WidgetUpdate() = 0; 33 34 virtual bool WidgetDraw() = 0; 35 36 protected: 37 38 bool mDisplay; 39 SDL_Renderer* mren; 40 SDL_Rect mPos; 41 42 }; 43 44 SDL_Rect CalcElementScreenPosition(Widget* wid, SDL_Rect elementRect); 45 46 class LifeMeter : public Widget 47 { 48 public: 49 50 LifeMeter() {} 51 52 LifeMeter(Player* target, SDL_Rect pos, SDL_Renderer* ren, char* life_base, char* life_bar); 53 54 bool WidgetUpdate(); 55 56 bool WidgetDraw(); 57 58 protected: 59 60 int* mHP; 61 int* mHPmax; 62 WidgetElement mBase; 63 WidgetElement mLifebar; 64 65 }; 66 67 class Fader : public Widget, public EventReceiver //Must Subscribe to the player 68 { 69 public: 70 Fader() {} 71 72 Fader(SDL_Renderer* ren, char* black, char* red); 73 74 void PlayFade(int duration,int color, int opacity); 75 76 bool WidgetUpdate(); 77 78 bool WidgetDraw(); 79 80 bool EventProcess(Event eve); 81 82 protected: 83 84 WidgetElement mBlack; 85 WidgetElement mRed; 86 87 int mOpacityTarget; 88 int mFadeTime; 89 int mFadeColor; 90 91 int mTimer; 92 int mOpacity; 93 }; 94 95 class HUD 96 { 97 public: 98 99 HUD() : mIndex(0) {} 100 101 bool LogWidget(Widget* wid); 102 103 bool UpdateWidgets(); 104 105 bool DrawWidgets(); 106 107 protected: 108 109 Widget* mWidgets[10]; 110 int mIndex; 111 }; 112 113 114 115 #endif