File: EndGameBox.h

package info (click to toggle)
spring 106.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 55,316 kB
  • sloc: cpp: 543,954; ansic: 44,800; python: 12,575; java: 12,201; awk: 5,889; sh: 1,796; asm: 1,546; xml: 655; perl: 405; php: 211; objc: 194; makefile: 76; sed: 2
file content (75 lines) | stat: -rw-r--r-- 1,830 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#ifndef _END_GAME_BOX_H_
#define _END_GAME_BOX_H_

#include "InputReceiver.h"
#include "Rendering/GL/myGL.h"

#include <vector>


class CEndGameBox : public CInputReceiver
{
public:
	CEndGameBox(const std::vector<unsigned char>& winningAllyTeams);
	~CEndGameBox();

	virtual bool MousePress(int x, int y, int button) override;
	virtual void MouseMove(int x, int y, int dx, int dy, int button) override;
	virtual void MouseRelease(int x, int y, int button) override;
	virtual void Draw() override;
	virtual bool IsAbove(int x, int y) override;
	virtual std::string GetTooltip(int x, int y) override;

	static bool enabled;
	static void Create(const std::vector<unsigned char>& winningAllyTeams) { if (endGameBox == nullptr) new CEndGameBox(winningAllyTeams);}
	static void Destroy() { if (endGameBox != nullptr) { delete endGameBox; endGameBox = nullptr; } }

protected:
	static CEndGameBox* endGameBox;
	void FillTeamStats();

	TRectangle<float> box;

	TRectangle<float>   exitBox;
	TRectangle<float> playerBox;
	TRectangle<float>    sumBox;
	TRectangle<float>    difBox;

	bool moveBox = false;

	int dispMode = 0;

	int stat1 =  1;
	int stat2 = -1;

	struct Stat {
		Stat(const char* s) : name(s), max(1), maxdif(1) {}

		void AddStat(int team, float value) {
			max = std::max(max, value);

			if (team >= 0 && static_cast<size_t>(team) >= values.size())
				values.resize(team + 1);

			if (values[team].size() > 0)
				maxdif = std::max(math::fabs(value - values[team].back()), maxdif);

			values[team].push_back(value);
		}

		const char* name;
		float max;
		float maxdif;

		std::vector< std::vector<float> > values;
	};

	std::vector<unsigned char> winners;
	std::vector<Stat> stats;

	GLuint graphTex = 0;
};

#endif // _END_GAME_BOX_H_