1 /* 2 Copyright (C) 2009 Andrew Caudwell (acaudwell@gmail.com) 3 4 This program is free software; you can redistribute it and/or 5 modify it under the terms of the GNU General Public License 6 as published by the Free Software Foundation; either version 7 3 of the License, or (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef PAWN_H 19 #define PAWN_H 20 21 #include <string> 22 23 #include "gource_settings.h" 24 25 #include "core/display.h" 26 #include "core/fxfont.h" 27 #include "core/vectors.h" 28 #include "core/quadtree.h" 29 30 class Pawn : public QuadItem { 31 protected: 32 vec2 pos; 33 vec2 shadowOffset; 34 35 std::string name; 36 float namewidth; 37 vec2 accel; 38 float speed; 39 40 float elapsed; 41 float fadetime; 42 43 float nametime; 44 float name_interval; 45 vec3 namecol; 46 47 bool shadow; 48 49 bool hidden; 50 51 int tagid; 52 53 FXFont font; 54 55 bool mouseover; 56 57 virtual bool nameVisible() const; 58 drawNameText(float alpha)59 virtual void drawNameText(float alpha) {}; 60 virtual const vec3& getNameColour() const; 61 protected: 62 bool selected; 63 public: 64 float size; 65 float graphic_ratio; 66 TextureResource* graphic; 67 vec3 screenpos; 68 vec2 dims; 69 70 Pawn(const std::string& name, vec2 pos, int tagid); getPos()71 const vec2 & getPos() const { return pos; } 72 void setPos(vec2 pos); 73 74 void calcScreenPos(const vec2& offset); 75 76 void updateQuadItemBounds(); 77 78 void showName(); 79 80 void setMouseOver(bool over); 81 82 float getSize(); 83 int getTagID(); 84 getName()85 const std::string& getName() const { return name; } 86 87 virtual void setSelected(bool selected); isSelected()88 bool isSelected() { return selected; }; 89 setHidden(bool hidden)90 void setHidden(bool hidden){ this->hidden = hidden; } isHidden()91 bool isHidden() const { return hidden; } 92 getAlpha()93 virtual float getAlpha() const{ return std::min(elapsed/fadetime, 1.0f); } getColour()94 virtual vec3 getColour() const { return vec3(1.0, 1.0, 1.0); } 95 96 void setGraphic(TextureResource* graphic); 97 98 void logic(float dt); 99 void draw(float dt); 100 void drawShadow(float dt); 101 102 void drawName(); 103 }; 104 105 extern float gGourceShadowStrength; 106 107 #endif 108 109