1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ 2 3 #ifndef _END_GAME_BOX_H_ 4 #define _END_GAME_BOX_H_ 5 6 #include "InputReceiver.h" 7 #include "Rendering/GL/myGL.h" 8 #include "Rendering/Textures/Bitmap.h" 9 10 #include <vector> 11 12 13 class CEndGameBox : public CInputReceiver 14 { 15 public: 16 CEndGameBox(const std::vector<unsigned char>& winningAllyTeams); 17 ~CEndGameBox(); 18 19 virtual bool MousePress(int x, int y, int button); 20 virtual void MouseMove(int x, int y, int dx, int dy, int button); 21 virtual void MouseRelease(int x, int y, int button); 22 virtual void Draw(); 23 virtual bool IsAbove(int x, int y); 24 virtual std::string GetTooltip(int x, int y); 25 26 static bool enabled; Create(const std::vector<unsigned char> & winningAllyTeams)27 static void Create(const std::vector<unsigned char>& winningAllyTeams) { if (endGameBox == NULL) new CEndGameBox(winningAllyTeams);} Destroy()28 static void Destroy() { if (endGameBox != NULL) { delete endGameBox; endGameBox = NULL; } } 29 30 protected: 31 static CEndGameBox* endGameBox; 32 void FillTeamStats(); 33 ContainerBox box; 34 35 ContainerBox exitBox; 36 37 ContainerBox playerBox; 38 ContainerBox sumBox; 39 ContainerBox difBox; 40 41 bool moveBox; 42 43 int dispMode; 44 45 int stat1; 46 int stat2; 47 48 struct Stat { StatStat49 Stat(std::string s) : name(s), max(1), maxdif(1) {} 50 AddStatStat51 void AddStat(int team, float value) { 52 if (value > max) { 53 max = value; 54 } 55 if (team >= 0 && static_cast<size_t>(team) >= values.size()) { 56 values.resize(team + 1); 57 } 58 if (values[team].size() > 0 && math::fabs(value-values[team].back()) > maxdif) { 59 maxdif = math::fabs(value-values[team].back()); 60 } 61 62 values[team].push_back(value); 63 } 64 std::string name; 65 float max; 66 float maxdif; 67 68 std::vector< std::vector<float> > values; 69 }; 70 71 std::vector<unsigned char> winners; 72 73 std::vector<Stat> stats; 74 GLuint graphTex; 75 CBitmap bm; 76 }; 77 78 #endif // _END_GAME_BOX_H_ 79