GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
/* |
||
2 |
* The ManaPlus Client |
||
3 |
* Copyright (C) 2008 Douglas Boffey <[email protected]> |
||
4 |
* Copyright (C) 2009 The Mana World Development Team |
||
5 |
* Copyright (C) 2009-2010 The Mana Developers |
||
6 |
* Copyright (C) 2011-2019 The ManaPlus Developers |
||
7 |
* Copyright (C) 2019-2021 Andrei Karas |
||
8 |
* |
||
9 |
* This file is part of The ManaPlus Client. |
||
10 |
* |
||
11 |
* This program is free software; you can redistribute it and/or modify |
||
12 |
* it under the terms of the GNU General Public License as published by |
||
13 |
* the Free Software Foundation; either version 2 of the License, or |
||
14 |
* any later version. |
||
15 |
* |
||
16 |
* This program is distributed in the hope that it will be useful, |
||
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
19 |
* GNU General Public License for more details. |
||
20 |
* |
||
21 |
* You should have received a copy of the GNU General Public License |
||
22 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
23 |
*/ |
||
24 |
|||
25 |
#include "gui/userpalette.h" |
||
26 |
|||
27 |
#include "configuration.h" |
||
28 |
|||
29 |
#include "utils/foreach.h" |
||
30 |
#include "utils/gettext.h" |
||
31 |
|||
32 |
#include "debug.h" |
||
33 |
|||
34 |
UserPalette *userPalette = nullptr; |
||
35 |
|||
36 |
✓✓ | 3 |
const std::string ColorTypeNames[CAST_SIZE( |
37 |
UserColorId::USER_COLOR_LAST)] = |
||
38 |
{ |
||
39 |
"", |
||
40 |
"ColorBeing", |
||
41 |
"ColorFriend", |
||
42 |
"ColorDisregarded", |
||
43 |
"ColorIgnored", |
||
44 |
"ColorErased", |
||
45 |
"ColorEnemy", |
||
46 |
"ColorPlayer", |
||
47 |
"ColorSelf", |
||
48 |
"ColorGM", |
||
49 |
"ColorNPC", |
||
50 |
"ColorMonster", |
||
51 |
"ColorPet", |
||
52 |
"ColorMercenary", |
||
53 |
"ColorHomunculus", |
||
54 |
"ColorSkillUnit", |
||
55 |
"ColorParty", |
||
56 |
"ColorGuild", |
||
57 |
"ColorTeam1", |
||
58 |
"ColorTeam2", |
||
59 |
"ColorTeam3", |
||
60 |
"", |
||
61 |
"ColorParticle", |
||
62 |
"ColorPickupInfo", |
||
63 |
"ColorExpInfo", |
||
64 |
"", |
||
65 |
"ColorPlayerHp", |
||
66 |
"ColorPlayerHp2", |
||
67 |
"ColorMonsterHp", |
||
68 |
"ColorMonsterHp2", |
||
69 |
"ColorHomunHp", |
||
70 |
"ColorHomunHp2", |
||
71 |
"ColorMercHp", |
||
72 |
"ColorMercHp2", |
||
73 |
"ColorElementalHp", |
||
74 |
"ColorElementalHp2", |
||
75 |
"", |
||
76 |
"ColorHitPlayerMonster", |
||
77 |
"ColorHitMonsterPlayer", |
||
78 |
"ColorHitPlayerPlayer", |
||
79 |
"ColorHitCritical", |
||
80 |
"ColorHitLocalPlayerMonster", |
||
81 |
"ColorHitLocalPlayerCritical", |
||
82 |
"ColorHitLocalPlayerMiss", |
||
83 |
"ColorMiss", |
||
84 |
"", |
||
85 |
"ColorPortalHighlight", |
||
86 |
"ColorCollisionHighlight", |
||
87 |
"ColorCollisionAirHighlight", |
||
88 |
"ColorCollisionWaterHighlight", |
||
89 |
"ColorCollisionMonsterHighlight", |
||
90 |
"ColorCollisionGroundtopHighlight", |
||
91 |
"ColorWalkableTileHighlight", |
||
92 |
"ColorNet", |
||
93 |
"", |
||
94 |
"ColorAttackRange", |
||
95 |
"ColorAttackRangeBorder", |
||
96 |
"ColorMonsterAttackRange", |
||
97 |
"ColorSkillAttackRange", |
||
98 |
"", |
||
99 |
"ColorFloorItemText", |
||
100 |
"ColorHomePlace", |
||
101 |
"ColorHomePlaceBorder", |
||
102 |
"ColorRoadPoint", |
||
103 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✗✗ |
129 |
}; |
104 |
|||
105 |
std::string UserPalette::getConfigName(const std::string &typeName) |
||
106 |
{ |
||
107 |
std::string res("Color" + typeName); |
||
108 |
size_t pos = 5; |
||
109 |
for (size_t i = 0; i < typeName.length(); i++) |
||
110 |
{ |
||
111 |
if (i == 0 || typeName[i] == '_') |
||
112 |
{ |
||
113 |
if (i > 0) |
||
114 |
i++; |
||
115 |
|||
116 |
res[pos] = typeName[i]; |
||
117 |
} |
||
118 |
else |
||
119 |
{ |
||
120 |
res[pos] = CAST_S8(tolower(typeName[i])); |
||
121 |
} |
||
122 |
pos ++; |
||
123 |
} |
||
124 |
res.erase(pos, res.length() - pos); |
||
125 |
return res; |
||
126 |
} |
||
127 |
|||
128 |
158 |
UserPalette::UserPalette() : |
|
129 |
Palette(CAST_S32(UserColorId::USER_COLOR_LAST)), |
||
130 |
316 |
ListModel() |
|
131 |
{ |
||
132 |
474 |
mColors[CAST_SIZE(UserColorId::BEING)] = ColorElem(); |
|
133 |
474 |
mColors[CAST_SIZE(UserColorId::PC)] = ColorElem(); |
|
134 |
474 |
mColors[CAST_SIZE(UserColorId::SELF)] = ColorElem(); |
|
135 |
474 |
mColors[CAST_SIZE(UserColorId::GM)] = ColorElem(); |
|
136 |
474 |
mColors[CAST_SIZE(UserColorId::NPC)] = ColorElem(); |
|
137 |
474 |
mColors[CAST_SIZE(UserColorId::MONSTER)] = ColorElem(); |
|
138 |
|||
139 |
✓✗ | 474 |
addLabel(UserColorId::LABEL_BEING, |
140 |
// TRANSLATORS: palette label |
||
141 |
✓✗ | 316 |
_("Beings")); |
142 |
✓✗ | 632 |
addColor(UserColorId::BEING, |
143 |
0xffffff, |
||
144 |
GradientType::STATIC, |
||
145 |
// TRANSLATORS: palette color |
||
146 |
158 |
_("Being"), |
|
147 |
✓✗ | 158 |
GRADIENT_DELAY); |
148 |
✓✗ | 632 |
addColor(UserColorId::FRIEND, |
149 |
0xb0ffb0, |
||
150 |
GradientType::STATIC, |
||
151 |
// TRANSLATORS: palette color |
||
152 |
158 |
_("Friend names"), |
|
153 |
✓✗ | 158 |
GRADIENT_DELAY); |
154 |
✓✗ | 632 |
addColor(UserColorId::DISREGARDED, |
155 |
0xa00000, |
||
156 |
GradientType::STATIC, |
||
157 |
// TRANSLATORS: palette color |
||
158 |
158 |
_("Disregarded names"), |
|
159 |
✓✗ | 158 |
GRADIENT_DELAY); |
160 |
✓✗ | 632 |
addColor(UserColorId::IGNORED, |
161 |
0xff0000, |
||
162 |
GradientType::STATIC, |
||
163 |
// TRANSLATORS: palette color |
||
164 |
158 |
_("Ignored names"), |
|
165 |
✓✗ | 158 |
GRADIENT_DELAY); |
166 |
✓✗ | 632 |
addColor(UserColorId::ERASED, |
167 |
0xff0000, |
||
168 |
GradientType::STATIC, |
||
169 |
// TRANSLATORS: palette color |
||
170 |
158 |
_("Erased names"), |
|
171 |
✓✗ | 158 |
GRADIENT_DELAY); |
172 |
✓✗ | 632 |
addColor(UserColorId::ENEMY, |
173 |
0xff4040, |
||
174 |
GradientType::STATIC, |
||
175 |
// TRANSLATORS: palette color |
||
176 |
158 |
_("Enemy"), |
|
177 |
✓✗ | 158 |
GRADIENT_DELAY); |
178 |
✓✗ | 632 |
addColor(UserColorId::PC, |
179 |
0xffffff, |
||
180 |
GradientType::STATIC, |
||
181 |
// TRANSLATORS: palette color |
||
182 |
158 |
_("Other players names"), |
|
183 |
✓✗ | 158 |
GRADIENT_DELAY); |
184 |
✓✗ | 632 |
addColor(UserColorId::SELF, |
185 |
0xff8040, |
||
186 |
GradientType::STATIC, |
||
187 |
// TRANSLATORS: palette color |
||
188 |
158 |
_("Own name"), |
|
189 |
✓✗ | 158 |
GRADIENT_DELAY); |
190 |
✓✗ | 632 |
addColor(UserColorId::GM, |
191 |
0x00ff00, |
||
192 |
GradientType::STATIC, |
||
193 |
// TRANSLATORS: palette color |
||
194 |
158 |
_("GM names"), |
|
195 |
✓✗ | 158 |
GRADIENT_DELAY); |
196 |
✓✗ | 632 |
addColor(UserColorId::NPC, |
197 |
0xc8c8ff, |
||
198 |
GradientType::STATIC, |
||
199 |
// TRANSLATORS: palette color |
||
200 |
158 |
_("NPCs"), |
|
201 |
✓✗ | 158 |
GRADIENT_DELAY); |
202 |
✓✗ | 632 |
addColor(UserColorId::MONSTER, |
203 |
0xff4040, |
||
204 |
GradientType::STATIC, |
||
205 |
// TRANSLATORS: palette color |
||
206 |
158 |
_("Monsters"), |
|
207 |
✓✗ | 158 |
GRADIENT_DELAY); |
208 |
✓✗ | 632 |
addColor(UserColorId::PET, |
209 |
0xffffff, |
||
210 |
GradientType::STATIC, |
||
211 |
// TRANSLATORS: palette color |
||
212 |
158 |
_("Pets"), |
|
213 |
✓✗ | 158 |
GRADIENT_DELAY); |
214 |
✓✗ | 632 |
addColor(UserColorId::MERCENARY, |
215 |
0xffffff, |
||
216 |
GradientType::STATIC, |
||
217 |
// TRANSLATORS: palette color |
||
218 |
158 |
_("Mercenary"), |
|
219 |
✓✗ | 158 |
GRADIENT_DELAY); |
220 |
✓✗ | 632 |
addColor(UserColorId::HOMUNCULUS, |
221 |
0xffffff, |
||
222 |
GradientType::STATIC, |
||
223 |
// TRANSLATORS: palette color |
||
224 |
158 |
_("Homunculus"), |
|
225 |
✓✗ | 158 |
GRADIENT_DELAY); |
226 |
✓✗ | 632 |
addColor(UserColorId::SKILLUNIT, |
227 |
0xffffff, |
||
228 |
GradientType::STATIC, |
||
229 |
// TRANSLATORS: palette color |
||
230 |
158 |
_("Skill unit"), |
|
231 |
✓✗ | 158 |
GRADIENT_DELAY); |
232 |
✓✗ | 632 |
addColor(UserColorId::PARTY, |
233 |
0xff00d8, |
||
234 |
GradientType::STATIC, |
||
235 |
// TRANSLATORS: palette color |
||
236 |
158 |
_("Party members"), |
|
237 |
✓✗ | 158 |
GRADIENT_DELAY); |
238 |
✓✗ | 632 |
addColor(UserColorId::GUILD, |
239 |
0xff00d8, |
||
240 |
GradientType::STATIC, |
||
241 |
// TRANSLATORS: palette color |
||
242 |
158 |
_("Guild members"), |
|
243 |
✓✗ | 158 |
GRADIENT_DELAY); |
244 |
addColor(UserColorId::TEAM1, |
||
245 |
0x0000ff, |
||
246 |
GradientType::STATIC, |
||
247 |
// TRANSLATORS: palette color |
||
248 |
✓✗ | 316 |
strprintf(_("Team %d"), 1), |
249 |
✓✗ | 158 |
GRADIENT_DELAY); |
250 |
addColor(UserColorId::TEAM2, |
||
251 |
0x00a020, |
||
252 |
GradientType::STATIC, |
||
253 |
// TRANSLATORS: palette color |
||
254 |
✓✗ | 316 |
strprintf(_("Team %d"), 2), |
255 |
✓✗ | 158 |
GRADIENT_DELAY); |
256 |
addColor(UserColorId::TEAM3, |
||
257 |
0xffff20, |
||
258 |
GradientType::STATIC, |
||
259 |
// TRANSLATORS: palette color |
||
260 |
✓✗ | 316 |
strprintf(_("Team %d"), 3), |
261 |
✓✗ | 158 |
GRADIENT_DELAY); |
262 |
✓✗ | 632 |
addLabel(UserColorId::LABEL_PARTICLES, |
263 |
// TRANSLATORS: palette label |
||
264 |
✓✗ | 316 |
_("Particles")); |
265 |
✓✗ | 632 |
addColor(UserColorId::PARTICLE, |
266 |
0xffffff, |
||
267 |
GradientType::STATIC, |
||
268 |
// TRANSLATORS: palette color |
||
269 |
158 |
_("Particle effects"), |
|
270 |
✓✗ | 158 |
GRADIENT_DELAY); |
271 |
✓✗ | 632 |
addColor(UserColorId::PICKUP_INFO, |
272 |
0x28dc28, |
||
273 |
GradientType::STATIC, |
||
274 |
// TRANSLATORS: palette color |
||
275 |
158 |
_("Pickup notification"), |
|
276 |
✓✗ | 158 |
GRADIENT_DELAY); |
277 |
✓✗ | 632 |
addColor(UserColorId::EXP_INFO, |
278 |
0xffff00, |
||
279 |
GradientType::STATIC, |
||
280 |
// TRANSLATORS: palette color |
||
281 |
158 |
_("Exp notification"), |
|
282 |
✓✗ | 158 |
GRADIENT_DELAY); |
283 |
✓✗ | 632 |
addLabel(UserColorId::LABEL_HP, |
284 |
// TRANSLATORS: palette label |
||
285 |
✓✗ | 316 |
_("Hp bars")); |
286 |
✓✗ | 632 |
addColor(UserColorId::PLAYER_HP, |
287 |
0x00ff00, |
||
288 |
GradientType::STATIC, |
||
289 |
// TRANSLATORS: palette color |
||
290 |
✓✗ | 316 |
_("Player HP bar"), 50); |
291 |
✓✗ | 632 |
addColor(UserColorId::PLAYER_HP2, |
292 |
0xff0000, |
||
293 |
GradientType::STATIC, |
||
294 |
// TRANSLATORS: palette color |
||
295 |
158 |
_("Player HP bar (second color)"), |
|
296 |
✓✗ | 158 |
50); |
297 |
✓✗ | 632 |
addColor(UserColorId::MONSTER_HP, |
298 |
0x00ff00, |
||
299 |
GradientType::STATIC, |
||
300 |
// TRANSLATORS: palette color |
||
301 |
158 |
_("Monster HP bar"), |
|
302 |
✓✗ | 158 |
50); |
303 |
✓✗ | 632 |
addColor(UserColorId::MONSTER_HP2, |
304 |
0xff0000, |
||
305 |
GradientType::STATIC, |
||
306 |
// TRANSLATORS: palette color |
||
307 |
158 |
_("Monster HP bar (second color)"), |
|
308 |
✓✗ | 158 |
50); |
309 |
✓✗ | 632 |
addColor(UserColorId::HOMUN_HP, |
310 |
0x00ff00, |
||
311 |
GradientType::STATIC, |
||
312 |
// TRANSLATORS: palette color |
||
313 |
158 |
_("Homunculus HP bar"), |
|
314 |
✓✗ | 158 |
50); |
315 |
✓✗ | 632 |
addColor(UserColorId::HOMUN_HP2, |
316 |
0xff0000, |
||
317 |
GradientType::STATIC, |
||
318 |
// TRANSLATORS: palette color |
||
319 |
158 |
_("Homunculus HP bar (second color)"), |
|
320 |
✓✗ | 158 |
50); |
321 |
✓✗ | 632 |
addColor(UserColorId::MERC_HP, |
322 |
0x00ff00, |
||
323 |
GradientType::STATIC, |
||
324 |
// TRANSLATORS: palette color |
||
325 |
158 |
_("Mercenary HP bar"), |
|
326 |
✓✗ | 158 |
50); |
327 |
✓✗ | 632 |
addColor(UserColorId::MERC_HP2, |
328 |
0xff0000, |
||
329 |
GradientType::STATIC, |
||
330 |
// TRANSLATORS: palette color |
||
331 |
158 |
_("Mercenary HP bar (second color)"), |
|
332 |
✓✗ | 158 |
50); |
333 |
|||
334 |
✓✗ | 632 |
addColor(UserColorId::ELEMENTAL_HP, |
335 |
0x00ff00, |
||
336 |
GradientType::STATIC, |
||
337 |
// TRANSLATORS: palette color |
||
338 |
158 |
_("Elemental HP bar"), |
|
339 |
✓✗ | 158 |
50); |
340 |
✓✗ | 632 |
addColor(UserColorId::ELEMENTAL_HP2, |
341 |
0xff0000, |
||
342 |
GradientType::STATIC, |
||
343 |
// TRANSLATORS: palette color |
||
344 |
158 |
_("Elemental HP bar (second color)"), |
|
345 |
✓✗ | 158 |
50); |
346 |
✓✗ | 632 |
addLabel(UserColorId::LABEL_HITS, |
347 |
// TRANSLATORS: palette label |
||
348 |
✓✗ | 316 |
_("Hits")); |
349 |
✓✗ | 632 |
addColor(UserColorId::HIT_PLAYER_MONSTER, |
350 |
0x0064ff, |
||
351 |
GradientType::STATIC, |
||
352 |
// TRANSLATORS: palette color |
||
353 |
158 |
_("Player hits monster"), |
|
354 |
✓✗ | 158 |
GRADIENT_DELAY); |
355 |
✓✗ | 632 |
addColor(UserColorId::HIT_MONSTER_PLAYER, |
356 |
0xff3232, |
||
357 |
GradientType::STATIC, |
||
358 |
// TRANSLATORS: palette color |
||
359 |
158 |
_("Monster hits player"), |
|
360 |
✓✗ | 158 |
GRADIENT_DELAY); |
361 |
✓✗ | 632 |
addColor(UserColorId::HIT_PLAYER_PLAYER, |
362 |
0xff5050, |
||
363 |
GradientType::STATIC, |
||
364 |
// TRANSLATORS: palette color |
||
365 |
158 |
_("Other player hits local player"), |
|
366 |
✓✗ | 158 |
GRADIENT_DELAY); |
367 |
✓✗ | 632 |
addColor(UserColorId::HIT_CRITICAL, |
368 |
0xff0000, |
||
369 |
GradientType::RAINBOW, |
||
370 |
// TRANSLATORS: palette color |
||
371 |
158 |
_("Critical Hit"), |
|
372 |
✓✗ | 158 |
GRADIENT_DELAY); |
373 |
✓✗ | 632 |
addColor(UserColorId::HIT_LOCAL_PLAYER_MONSTER, |
374 |
0x00ff00, |
||
375 |
GradientType::STATIC, |
||
376 |
// TRANSLATORS: palette color |
||
377 |
158 |
_("Local player hits monster"), |
|
378 |
✓✗ | 158 |
GRADIENT_DELAY); |
379 |
✓✗ | 632 |
addColor(UserColorId::HIT_LOCAL_PLAYER_CRITICAL, |
380 |
0xff0000, |
||
381 |
GradientType::RAINBOW, |
||
382 |
// TRANSLATORS: palette color |
||
383 |
158 |
_("Local player critical hit"), |
|
384 |
✓✗ | 158 |
GRADIENT_DELAY); |
385 |
✓✗ | 632 |
addColor(UserColorId::HIT_LOCAL_PLAYER_MISS, |
386 |
0x00ffa6, |
||
387 |
GradientType::STATIC, |
||
388 |
// TRANSLATORS: palette color |
||
389 |
158 |
_("Local player miss"), |
|
390 |
✓✗ | 158 |
GRADIENT_DELAY); |
391 |
✓✗ | 632 |
addColor(UserColorId::MISS, 0xffff00, |
392 |
GradientType::STATIC, |
||
393 |
// TRANSLATORS: palette color |
||
394 |
158 |
_("Misses"), |
|
395 |
✓✗ | 158 |
GRADIENT_DELAY); |
396 |
✓✗ | 632 |
addLabel(UserColorId::LABEL_TILES, |
397 |
// TRANSLATORS: palette label |
||
398 |
✓✗ | 316 |
_("Tiles")); |
399 |
✓✗ | 632 |
addColor(UserColorId::PORTAL_HIGHLIGHT, |
400 |
0xC80000, |
||
401 |
GradientType::STATIC, |
||
402 |
// TRANSLATORS: palette color |
||
403 |
158 |
_("Portal highlight"), |
|
404 |
✓✗ | 158 |
GRADIENT_DELAY); |
405 |
✓✗ | 632 |
addColor(UserColorId::COLLISION_HIGHLIGHT, |
406 |
0x0000C8, |
||
407 |
GradientType::STATIC, |
||
408 |
// TRANSLATORS: palette color |
||
409 |
158 |
_("Default collision highlight"), |
|
410 |
✓✗ | 158 |
64); |
411 |
✓✗ | 632 |
addColor(UserColorId::AIR_COLLISION_HIGHLIGHT, |
412 |
0xe0e0ff, |
||
413 |
GradientType::STATIC, |
||
414 |
// TRANSLATORS: palette color |
||
415 |
158 |
_("Air collision highlight"), |
|
416 |
✓✗ | 158 |
64); |
417 |
✓✗ | 632 |
addColor(UserColorId::WATER_COLLISION_HIGHLIGHT, |
418 |
0x2050e0, |
||
419 |
GradientType::STATIC, |
||
420 |
// TRANSLATORS: palette color |
||
421 |
158 |
_("Water collision highlight"), |
|
422 |
✓✗ | 158 |
64); |
423 |
✓✗ | 632 |
addColor(UserColorId::MONSTER_COLLISION_HIGHLIGHT, |
424 |
0x2050e0, |
||
425 |
GradientType::STATIC, |
||
426 |
// TRANSLATORS: palette color |
||
427 |
158 |
_("Monster collision highlight"), |
|
428 |
✓✗ | 158 |
64); |
429 |
✓✗ | 632 |
addColor(UserColorId::GROUNDTOP_COLLISION_HIGHLIGHT, |
430 |
0xffff00, |
||
431 |
GradientType::STATIC, |
||
432 |
// TRANSLATORS: palette color |
||
433 |
158 |
_("Special ground collision highlight"), |
|
434 |
✓✗ | 158 |
20); |
435 |
✓✗ | 632 |
addColor(UserColorId::WALKABLE_HIGHLIGHT, |
436 |
0x00D000, |
||
437 |
GradientType::STATIC, |
||
438 |
// TRANSLATORS: palette color |
||
439 |
158 |
_("Walkable highlight"), |
|
440 |
✓✗ | 158 |
255); |
441 |
✓✗ | 632 |
addColor(UserColorId::NET, |
442 |
0x000000, |
||
443 |
GradientType::STATIC, |
||
444 |
// TRANSLATORS: palette color |
||
445 |
✓✗ | 316 |
_("Tiles border"), 64); |
446 |
✓✗ | 632 |
addLabel(UserColorId::LABEL_RANGES, |
447 |
// TRANSLATORS: palette label |
||
448 |
✓✗ | 316 |
_("Ranges")); |
449 |
✓✗ | 632 |
addColor(UserColorId::ATTACK_RANGE, |
450 |
0xffffff, |
||
451 |
GradientType::STATIC, |
||
452 |
// TRANSLATORS: palette color |
||
453 |
158 |
_("Local player attack range"), |
|
454 |
✓✗ | 158 |
5); |
455 |
✓✗ | 632 |
addColor(UserColorId::ATTACK_RANGE_BORDER, |
456 |
0x0, |
||
457 |
GradientType::STATIC, |
||
458 |
// TRANSLATORS: palette color |
||
459 |
158 |
_("Local player attack range border"), |
|
460 |
✓✗ | 158 |
76); |
461 |
✓✗ | 632 |
addColor(UserColorId::MONSTER_ATTACK_RANGE, |
462 |
0xff0000, |
||
463 |
GradientType::STATIC, |
||
464 |
// TRANSLATORS: palette color |
||
465 |
158 |
_("Monster attack range"), |
|
466 |
✓✗ | 158 |
20); |
467 |
✓✗ | 632 |
addColor(UserColorId::SKILL_ATTACK_RANGE, |
468 |
0x0, |
||
469 |
GradientType::STATIC, |
||
470 |
// TRANSLATORS: palette color |
||
471 |
158 |
_("Skill attack range border"), |
|
472 |
✓✗ | 158 |
76); |
473 |
✓✗ | 632 |
addLabel(UserColorId::LABEL_OTHER, |
474 |
// TRANSLATORS: palette label |
||
475 |
✓✗ | 316 |
_("Other")); |
476 |
✓✗ | 632 |
addColor(UserColorId::FLOOR_ITEM_TEXT, |
477 |
0xffffff, |
||
478 |
GradientType::STATIC, |
||
479 |
// TRANSLATORS: palette color |
||
480 |
158 |
_("Floor item amount color"), |
|
481 |
✓✗ | 158 |
100); |
482 |
✓✗ | 632 |
addColor(UserColorId::HOME_PLACE, |
483 |
0xffffff, |
||
484 |
GradientType::STATIC, |
||
485 |
// TRANSLATORS: palette color |
||
486 |
158 |
_("Home place"), |
|
487 |
✓✗ | 158 |
20); |
488 |
✓✗ | 632 |
addColor(UserColorId::HOME_PLACE_BORDER, |
489 |
0xffff00, |
||
490 |
GradientType::STATIC, |
||
491 |
// TRANSLATORS: palette color |
||
492 |
158 |
_("Home place border"), |
|
493 |
✓✗ | 158 |
200); |
494 |
✓✗ | 632 |
addColor(UserColorId::ROAD_POINT, |
495 |
0x000000, |
||
496 |
GradientType::STATIC, |
||
497 |
// TRANSLATORS: palette color |
||
498 |
✓✗ | 316 |
_("Road point"), 100); |
499 |
158 |
commit(true); |
|
500 |
158 |
} |
|
501 |
|||
502 |
632 |
UserPalette::~UserPalette() |
|
503 |
{ |
||
504 |
✓✓ | 11060 |
FOR_EACH (Colors::const_iterator, col, mColors) |
505 |
{ |
||
506 |
✓✓ | 10112 |
if (col->grad == GradientType::LABEL) |
507 |
continue; |
||
508 |
9006 |
const std::string &configName = ColorTypeNames[col->type]; |
|
509 |
18012 |
config.setValue(configName + "Gradient", |
|
510 |
18012 |
CAST_S32(col->committedGrad)); |
|
511 |
18012 |
config.setValue(configName + "Delay", col->delay); |
|
512 |
|||
513 |
✓✓✗✓ ✓✓ |
9322 |
if (col->grad == GradientType::STATIC || |
514 |
316 |
col->grad == GradientType::PULSE) |
|
515 |
{ |
||
516 |
char buffer[20]; |
||
517 |
26070 |
snprintf(buffer, sizeof(buffer), "0x%06x", col->getRGB()); |
|
518 |
8690 |
buffer[19] = 0; |
|
519 |
34760 |
config.setValue(configName, std::string(buffer)); |
|
520 |
} |
||
521 |
} |
||
522 |
316 |
} |
|
523 |
|||
524 |
void UserPalette::setColor(const UserColorIdT type, |
||
525 |
const int r, |
||
526 |
const int g, |
||
527 |
const int b) |
||
528 |
{ |
||
529 |
Color &color = mColors[CAST_SIZE(type)].color; |
||
530 |
color.r = r; |
||
531 |
color.g = g; |
||
532 |
color.b = b; |
||
533 |
} |
||
534 |
|||
535 |
void UserPalette::setGradient(const UserColorIdT type, |
||
536 |
const GradientTypeT grad) |
||
537 |
{ |
||
538 |
ColorElem *const elem = &mColors[CAST_SIZE(type)]; |
||
539 |
|||
540 |
if (elem->grad != GradientType::STATIC && grad == GradientType::STATIC) |
||
541 |
{ |
||
542 |
const size_t sz = mGradVector.size(); |
||
543 |
for (size_t i = 0; i < sz; i++) |
||
544 |
{ |
||
545 |
if (mGradVector[i] == elem) |
||
546 |
{ |
||
547 |
mGradVector.erase(mGradVector.begin() + i); |
||
548 |
break; |
||
549 |
} |
||
550 |
} |
||
551 |
} |
||
552 |
else if (elem->grad == GradientType::STATIC && |
||
553 |
grad != GradientType::STATIC) |
||
554 |
{ |
||
555 |
mGradVector.push_back(elem); |
||
556 |
} |
||
557 |
|||
558 |
if (elem->grad != grad) |
||
559 |
elem->grad = grad; |
||
560 |
} |
||
561 |
|||
562 |
std::string UserPalette::getElementAt(int i) |
||
563 |
{ |
||
564 |
if (i < 0 || i >= getNumberOfElements()) |
||
565 |
return ""; |
||
566 |
|||
567 |
return mColors[i].text; |
||
568 |
} |
||
569 |
|||
570 |
158 |
void UserPalette::commit(const bool commitNonStatic) |
|
571 |
{ |
||
572 |
✓✓ | 10744 |
FOR_EACH (Colors::iterator, i, mColors) |
573 |
{ |
||
574 |
10112 |
i->committedGrad = i->grad; |
|
575 |
10112 |
i->committedDelay = i->delay; |
|
576 |
✗✓✗✗ ✓✗ |
10112 |
if (commitNonStatic || i->grad == GradientType::STATIC) |
577 |
10112 |
i->committedColor = i->color; |
|
578 |
else if (i->grad == GradientType::PULSE) |
||
579 |
i->committedColor = i->testColor; |
||
580 |
} |
||
581 |
158 |
} |
|
582 |
|||
583 |
void UserPalette::rollback() |
||
584 |
{ |
||
585 |
FOR_EACH (Colors::iterator, i, mColors) |
||
586 |
{ |
||
587 |
if (i->grad != i->committedGrad) |
||
588 |
setGradient(static_cast<UserColorIdT>(i->type), i->committedGrad); |
||
589 |
|||
590 |
const Color &committedColor = i->committedColor; |
||
591 |
setGradientDelay(static_cast<UserColorIdT>(i->type), |
||
592 |
i->committedDelay); |
||
593 |
setColor(static_cast<UserColorIdT>(i->type), |
||
594 |
committedColor.r, |
||
595 |
committedColor.g, |
||
596 |
committedColor.b); |
||
597 |
|||
598 |
if (i->grad == GradientType::PULSE) |
||
599 |
{ |
||
600 |
Color &testColor = i->testColor; |
||
601 |
testColor.r = committedColor.r; |
||
602 |
testColor.g = committedColor.g; |
||
603 |
testColor.b = committedColor.b; |
||
604 |
} |
||
605 |
} |
||
606 |
} |
||
607 |
|||
608 |
int UserPalette::getColorTypeAt(const int i) |
||
609 |
{ |
||
610 |
if (i < 0 || i >= getNumberOfElements()) |
||
611 |
return 0; |
||
612 |
|||
613 |
return mColors[i].type; |
||
614 |
} |
||
615 |
|||
616 |
9006 |
void UserPalette::addColor(const UserColorIdT type, |
|
617 |
const unsigned rgb, |
||
618 |
GradientTypeT grad, |
||
619 |
const std::string &text, |
||
620 |
int delay) |
||
621 |
{ |
||
622 |
const unsigned maxType = sizeof(ColorTypeNames) |
||
623 |
9006 |
/ sizeof(ColorTypeNames[0]); |
|
624 |
|||
625 |
✓✗ | 9006 |
if (CAST_U32(type) >= maxType) |
626 |
return; |
||
627 |
|||
628 |
9006 |
const std::string &configName = ColorTypeNames[CAST_SIZE(type)]; |
|
629 |
char buffer[20]; |
||
630 |
9006 |
snprintf(buffer, sizeof(buffer), "0x%06x", rgb); |
|
631 |
9006 |
buffer[19] = 0; |
|
632 |
|||
633 |
const std::string rgbString = config.getValue( |
||
634 |
✓✗ | 45030 |
configName, std::string(buffer)); |
635 |
9006 |
unsigned int rgbValue = 0; |
|
636 |
✓✗✓✗ ✗✓✓✗ |
27018 |
if (rgbString.length() == 8 && rgbString[0] == '0' && rgbString[1] == 'x') |
637 |
✓✗ | 9006 |
rgbValue = atox(rgbString); |
638 |
else |
||
639 |
rgbValue = atoi(rgbString.c_str()); |
||
640 |
9006 |
const Color &trueCol = Color(rgbValue); |
|
641 |
grad = static_cast<GradientTypeT>(config.getValue( |
||
642 |
✓✗ | 18012 |
configName + "Gradient", |
643 |
✓✗ | 9006 |
CAST_S32(grad))); |
644 |
✓✗✓✗ |
18012 |
delay = config.getValueInt(configName + "Delay", delay); |
645 |
18012 |
mColors[CAST_SIZE(type)].set(CAST_S32(type), |
|
646 |
9006 |
trueCol, grad, delay); |
|
647 |
27018 |
mColors[CAST_SIZE(type)].text = text; |
|
648 |
|||
649 |
✓✓ | 9006 |
if (grad != GradientType::STATIC) |
650 |
948 |
mGradVector.push_back(&mColors[CAST_SIZE(type)]); |
|
651 |
} |
||
652 |
|||
653 |
1106 |
void UserPalette::addLabel(const UserColorIdT type, |
|
654 |
const std::string &text) |
||
655 |
{ |
||
656 |
const unsigned maxType = sizeof(ColorTypeNames) |
||
657 |
1106 |
/ sizeof(ColorTypeNames[0]); |
|
658 |
|||
659 |
✓✗ | 1106 |
if (CAST_U32(type) >= maxType) |
660 |
return; |
||
661 |
|||
662 |
|||
663 |
3318 |
mColors[CAST_SIZE(type)] = ColorElem(); |
|
664 |
const std::string str(" \342\200\225\342\200\225\342\200\225" |
||
665 |
4424 |
"\342\200\225\342\200\225 "); |
|
666 |
2212 |
mColors[CAST_SIZE(type)].grad = GradientType::LABEL; |
|
667 |
2212 |
mColors[CAST_SIZE(type)].text = |
|
668 |
6636 |
std::string(str).append(text).append(str); |
|
669 |
} |
||
670 |
|||
671 |
int UserPalette::getIdByChar(const signed char c, bool &valid) const |
||
672 |
{ |
||
673 |
const CharColors::const_iterator it = mCharColors.find(c); |
||
674 |
if (it != mCharColors.end()) |
||
675 |
{ |
||
676 |
valid = true; |
||
677 |
return (*it).second; |
||
678 |
} |
||
679 |
|||
680 |
valid = false; |
||
681 |
return 0; |
||
682 |
✓✗✓✗ |
3 |
} |
Generated by: GCOVR (Version 3.3) |