]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/teams.qh
Merge branch 'master' into terencehill/translate_colors_2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / teams.qh
1 #ifndef TEAMS_H
2 #define TEAMS_H
3
4 #ifdef TEAMNUMBERS_THAT_ARENT_STUPID
5 const int NUM_TEAM_1 = 1;  // red
6 const int NUM_TEAM_2 = 2; // blue
7 const int NUM_TEAM_3 = 3; // yellow
8 const int NUM_TEAM_4 = 4; // pink
9 const int NUM_SPECTATOR = 5;
10 #else
11 #ifdef CSQC
12 const int NUM_TEAM_1 = 4;  // red
13 const int NUM_TEAM_2 = 13; // blue
14 const int NUM_TEAM_3 = 12; // yellow
15 const int NUM_TEAM_4 = 9; // pink
16 #else
17 const int NUM_TEAM_1 = 5;  // red
18 const int NUM_TEAM_2 = 14; // blue
19 const int NUM_TEAM_3 = 13; // yellow
20 const int NUM_TEAM_4 = 10; // pink
21 #endif
22 const int NUM_SPECTATOR = 1337;
23 #endif
24
25 const string COL_TEAM_1 = "^1";
26 const string COL_TEAM_2 = "^4";
27 const string COL_TEAM_3 = "^3";
28 const string COL_TEAM_4 = "^6";
29 // must be #defined, const globals drop the translation attribute
30 #define NAME_TEAM_1 CTX(_("TEAM^Red"))
31 #define NAME_TEAM_2 CTX(_("TEAM^Blue"))
32 #define NAME_TEAM_3 CTX(_("TEAM^Yellow"))
33 #define NAME_TEAM_4 CTX(_("TEAM^Pink"))
34 #define NAME_TEAM _("Team")
35 #define NAME_NEUTRAL _("Neutral")
36
37 // items colors, so they are handled properly in languages which decline things with grammatical gender
38 #define KEY_TEAM_1 CTX(_("KEY^Red"))
39 #define KEY_TEAM_2 CTX(_("KEY^Blue"))
40 #define KEY_TEAM_3 CTX(_("KEY^Yellow"))
41 #define KEY_TEAM_4 CTX(_("KEY^Pink"))
42 #define FLAG_TEAM_1 CTX(_("FLAG^Red"))
43 #define FLAG_TEAM_2 CTX(_("FLAG^Blue"))
44 #define FLAG_TEAM_3 CTX(_("FLAG^Yellow"))
45 #define FLAG_TEAM_4 CTX(_("FLAG^Pink"))
46 #define GENERATOR_TEAM_1 CTX(_("GENERATOR^Red"))
47 #define GENERATOR_TEAM_2 CTX(_("GENERATOR^Blue"))
48 #define GENERATOR_TEAM_3 CTX(_("GENERATOR^Yellow"))
49 #define GENERATOR_TEAM_4 CTX(_("GENERATOR^Pink"))
50
51 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
52 const string STATIC_NAME_TEAM_1 = "Red";
53 const string STATIC_NAME_TEAM_2 = "Blue";
54 const string STATIC_NAME_TEAM_3 = "Yellow";
55 const string STATIC_NAME_TEAM_4 = "Pink";
56
57 #ifdef CSQC
58 float teamplay;
59 float myteam;
60 #endif
61
62 string Team_ColorCode(float teamid)
63 {
64         switch(teamid)
65         {
66                 case NUM_TEAM_1: return COL_TEAM_1;
67                 case NUM_TEAM_2: return COL_TEAM_2;
68                 case NUM_TEAM_3: return COL_TEAM_3;
69                 case NUM_TEAM_4: return COL_TEAM_4;
70         }
71
72         return "^7";
73 }
74
75 vector Team_ColorRGB(float teamid)
76 {
77         switch(teamid)
78         {
79                 case NUM_TEAM_1: return '1 0.0625 0.0625'; // 0xFF0F0F
80                 case NUM_TEAM_2: return '0.0625 0.0625 1'; // 0x0F0FFF
81                 case NUM_TEAM_3: return '1 1 0.0625'; // 0xFFFF0F
82                 case NUM_TEAM_4: return '1 0.0625 1'; // 0xFF0FFF
83         }
84
85     return '0 0 0';
86 }
87
88 string Team_ColorName(float teamid)
89 {
90         switch(teamid)
91         {
92                 case NUM_TEAM_1: return NAME_TEAM_1;
93                 case NUM_TEAM_2: return NAME_TEAM_2;
94                 case NUM_TEAM_3: return NAME_TEAM_3;
95                 case NUM_TEAM_4: return NAME_TEAM_4;
96         }
97
98     return NAME_NEUTRAL;
99 }
100
101 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
102 string Static_Team_ColorName(float teamid)
103 {
104         switch(teamid)
105         {
106                 case NUM_TEAM_1: return STATIC_NAME_TEAM_1;
107                 case NUM_TEAM_2: return STATIC_NAME_TEAM_2;
108                 case NUM_TEAM_3: return STATIC_NAME_TEAM_3;
109                 case NUM_TEAM_4: return STATIC_NAME_TEAM_4;
110         }
111
112     return NAME_NEUTRAL;
113 }
114
115 float Team_ColorToTeam(string team_color)
116 {
117         switch(strtolower(team_color))
118         {
119                 case "red": return NUM_TEAM_1;
120                 case "blue": return NUM_TEAM_2;
121                 case "yellow": return NUM_TEAM_3;
122                 case "pink": return NUM_TEAM_4;
123                 case "auto": return 0;
124         }
125
126         return -1;
127 }
128
129 float Team_NumberToTeam(float number)
130 {
131         switch(number)
132         {
133                 case 1: return NUM_TEAM_1;
134                 case 2: return NUM_TEAM_2;
135                 case 3: return NUM_TEAM_3;
136                 case 4: return NUM_TEAM_4;
137         }
138
139         return -1;
140 }
141
142 float Team_TeamToNumber(float teamid)
143 {
144         switch(teamid)
145         {
146                 case NUM_TEAM_1: return 1;
147                 case NUM_TEAM_2: return 2;
148                 case NUM_TEAM_3: return 3;
149                 case NUM_TEAM_4: return 4;
150         }
151
152         return -1;
153 }
154
155
156 // legacy aliases for shitty code
157 #define TeamByColor(teamid) (Team_TeamToNumber(teamid) - 1)
158 #define ColorByTeam(number) Team_NumberToTeam(number + 1)
159
160 // useful aliases
161 #define Team_ColorName_Lower(teamid) strtolower(Team_ColorName(teamid))
162 #define Team_ColorName_Upper(teamid) strtoupper(Team_ColorName(teamid))
163
164 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
165 #define Static_Team_ColorName_Lower(teamid) strtolower(Static_Team_ColorName(teamid))
166 #define Static_Team_ColorName_Upper(teamid) strtoupper(Static_Team_ColorName(teamid))
167
168 #define Team_FullName(teamid) strcat(Team_ColorName(teamid), " ", NAME_TEAM, "^7")
169 #define Team_ColoredFullName(teamid) strcat(Team_ColorCode(teamid), Team_ColorName(teamid), " ", NAME_TEAM, "^7")
170
171 #define Team_NumberToFullName(number) Team_FullName(Team_NumberToTeam(number))
172 #define Team_NumberToColoredFullName(number) Team_ColoredFullName(Team_NumberToTeam(number))
173
174 // replace these flags in a string with the strings provided
175 #define TCR(input,type,team) strreplace("^TC", COL_TEAM_##team, strreplace("^TT", strtoupper(type##_TEAM_##team), input))
176
177 // safe team comparisons
178 #define SAME_TEAM(a,b) (teamplay ? (a.team == b.team) : (a == b))
179 #define DIFF_TEAM(a,b) (teamplay ? (a.team != b.team) : (a != b))
180
181 #endif