/
GroupHandler.h
59 lines (44 loc) · 1.23 KB
/
GroupHandler.h
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
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#ifndef _GROUP_HANDLER_H
#define _GROUP_HANDLER_H
#include "System/creg/creg_cond.h"
#include <map>
#include <string>
#include <vector>
#include <set>
class CGroup;
/**
* Handles all groups of a single team.
* The default groups (aka hot-key groups) are the ones with
* single digit IDs (1 - 9).
* Groups with higher IDs are considered special.
* Manual group creation/selection only works for the default groups.
*/
class CGroupHandler {
private:
CR_DECLARE_STRUCT(CGroupHandler)
CGroupHandler(int teamId);
~CGroupHandler();
public:
/// lowest ID of the first group not reachable through a hot-key
static const size_t FIRST_SPECIAL_GROUP = 10;
void Update();
bool GroupCommand(int num);
bool GroupCommand(int num, const std::string& cmd);
CGroup* CreateNewGroup();
void RemoveGroup(CGroup* group);
void PushGroupChange(int id);
public:
std::vector<CGroup*> groups;
int team;
protected:
std::vector<int> freeGroups;
/**
* The lowest ID not in use.
* This is always greater or equal FIRST_SPECIAL_GROUP.
*/
int firstUnusedGroup;
std::set<int> changedGroups;
};
extern std::vector<CGroupHandler*> grouphandlers;
#endif // _GROUP_HANDLER_H