Freeciv21
Develop your civilization from humble roots to a global empire
colors_common.h
Go to the documentation of this file.
1 /**************************************************************************
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  part of Freeciv21. Freeciv21 is free software: you can redistribute it
4  and/or modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation, either version 3 of the
6  License, or (at your option) any later version. You should have received
7  a copy of the GNU General Public License along with Freeciv21. If not,
8  see https://www.gnu.org/licenses/.
9 **************************************************************************/
10 #pragma once
11 
12 #include <QColor>
13 
14 struct color;
15 struct color_system;
16 struct tileset;
17 struct rgbcolor;
18 
19 #define SPECENUM_NAME color_std
20 // Mapview colors
21 #define SPECENUM_VALUE0 COLOR_MAPVIEW_UNKNOWN // Black
22 #define SPECENUM_VALUE0NAME "mapview_unknown"
23 #define SPECENUM_VALUE1 COLOR_MAPVIEW_CITYTEXT // white
24 #define SPECENUM_VALUE1NAME "mapview_citytext"
25 #define SPECENUM_VALUE2 COLOR_MAPVIEW_CITYTEXT_DARK // black
26 #define SPECENUM_VALUE2NAME "mapview_citytext_dark"
27 #define SPECENUM_VALUE3 COLOR_MAPVIEW_CITYPROD_NEGATIVE // red
28 #define SPECENUM_VALUE3NAME "mapview_cityprod_negative"
29 #define SPECENUM_VALUE4 COLOR_MAPVIEW_CITYGROWTH_BLOCKED // red
30 #define SPECENUM_VALUE4NAME "mapview_cityblocked"
31 #define SPECENUM_VALUE5 COLOR_MAPVIEW_GOTO // cyan
32 #define SPECENUM_VALUE5NAME "mapview_goto"
33 #define SPECENUM_VALUE6 COLOR_MAPVIEW_UNSAFE_GOTO // red
34 #define SPECENUM_VALUE6NAME "mapview_unsafe_goto"
35 #define SPECENUM_VALUE7 COLOR_MAPVIEW_SELECTION // yellow
36 #define SPECENUM_VALUE7NAME "mapview_selection"
37 #define SPECENUM_VALUE8 COLOR_MAPVIEW_TRADE_ROUTE_LINE
38 #define SPECENUM_VALUE8NAME "mapview_trade_route_line"
39 #define SPECENUM_VALUE9 COLOR_MAPVIEW_TRADE_ROUTES_ALL_BUILT // green
40 #define SPECENUM_VALUE9NAME "mapview_trade_routes_all_built"
41 #define SPECENUM_VALUE10 COLOR_MAPVIEW_TRADE_ROUTES_SOME_BUILT // yellow
42 #define SPECENUM_VALUE10NAME "mapview_trade_routes_some_built"
43 #define SPECENUM_VALUE11 COLOR_MAPVIEW_TRADE_ROUTES_NO_BUILT // red
44 #define SPECENUM_VALUE11NAME "mapview_trade_routes_no_built"
45 #define SPECENUM_VALUE12 COLOR_MAPVIEW_CITY_LINK // green
46 #define SPECENUM_VALUE12NAME "mapview_city_link"
47 #define SPECENUM_VALUE13 COLOR_MAPVIEW_TILE_LINK // red
48 #define SPECENUM_VALUE13NAME "mapview_tile_link"
49 #define SPECENUM_VALUE14 COLOR_MAPVIEW_UNIT_LINK // cyan
50 #define SPECENUM_VALUE14NAME "mapview_unit_link"
51 // Spaceship colors
52 #define SPECENUM_VALUE15 COLOR_SPACESHIP_BACKGROUND // black
53 #define SPECENUM_VALUE15NAME "spaceship_background"
54 // Overview colors
55 #define SPECENUM_VALUE16 COLOR_OVERVIEW_UNKNOWN // Black
56 #define SPECENUM_VALUE16NAME "overview_unknown"
57 #define SPECENUM_VALUE17 COLOR_OVERVIEW_MY_CITY // white
58 #define SPECENUM_VALUE17NAME "overview_mycity"
59 #define SPECENUM_VALUE18 COLOR_OVERVIEW_ALLIED_CITY
60 #define SPECENUM_VALUE18NAME "overview_alliedcity"
61 #define SPECENUM_VALUE19 COLOR_OVERVIEW_ENEMY_CITY // cyan
62 #define SPECENUM_VALUE19NAME "overview_enemycity"
63 #define SPECENUM_VALUE20 COLOR_OVERVIEW_MY_UNIT // yellow
64 #define SPECENUM_VALUE20NAME "overview_myunit"
65 #define SPECENUM_VALUE21 COLOR_OVERVIEW_ALLIED_UNIT
66 #define SPECENUM_VALUE21NAME "overview_alliedunit"
67 #define SPECENUM_VALUE22 COLOR_OVERVIEW_ENEMY_UNIT // red
68 #define SPECENUM_VALUE22NAME "overview_enemyunit"
69 #define SPECENUM_VALUE23 COLOR_OVERVIEW_OCEAN /* ocean/blue */
70 #define SPECENUM_VALUE23NAME "overview_ocean"
71 #define SPECENUM_VALUE24 COLOR_OVERVIEW_LAND /* ground/green */
72 #define SPECENUM_VALUE24NAME "overview_ground"
73 #define SPECENUM_VALUE25 COLOR_OVERVIEW_FROZEN /* frozen/grey */
74 #define SPECENUM_VALUE25NAME "overview_frozen"
75 #define SPECENUM_VALUE26 COLOR_OVERVIEW_VIEWRECT // white
76 #define SPECENUM_VALUE26NAME "overview_viewrect"
77 // Reqtree colors
78 #define SPECENUM_VALUE27 COLOR_REQTREE_RESEARCHING // cyan
79 #define SPECENUM_VALUE27NAME "reqtree_researching"
80 #define SPECENUM_VALUE28 COLOR_REQTREE_KNOWN // green
81 #define SPECENUM_VALUE28NAME "reqtree_known"
82 #define SPECENUM_VALUE29 COLOR_REQTREE_GOAL_PREREQS_KNOWN
83 #define SPECENUM_VALUE29NAME "reqtree_goal_prereqs_known"
84 #define SPECENUM_VALUE30 COLOR_REQTREE_GOAL_UNKNOWN
85 #define SPECENUM_VALUE30NAME "reqtree_goal_unknown"
86 #define SPECENUM_VALUE31 COLOR_REQTREE_PREREQS_KNOWN // yellow
87 #define SPECENUM_VALUE31NAME "reqtree_prereqs_known"
88 #define SPECENUM_VALUE32 COLOR_REQTREE_UNKNOWN // red
89 #define SPECENUM_VALUE32NAME "reqtree_unknown"
90 #define SPECENUM_VALUE33 COLOR_REQTREE_UNREACHABLE
91 #define SPECENUM_VALUE33NAME "reqtree_unreachable"
92 #define SPECENUM_VALUE34 COLOR_REQTREE_NOT_GETTABLE
93 #define SPECENUM_VALUE34NAME "reqtree_not_gettable"
94 #define SPECENUM_VALUE35 COLOR_REQTREE_GOAL_NOT_GETTABLE
95 #define SPECENUM_VALUE35NAME "reqtree_goal_not_gettable"
96 #define SPECENUM_VALUE36 COLOR_REQTREE_BACKGROUND // black
97 #define SPECENUM_VALUE36NAME "reqtree_background"
98 #define SPECENUM_VALUE37 COLOR_REQTREE_TEXT // black
99 #define SPECENUM_VALUE37NAME "reqtree_text"
100 #define SPECENUM_VALUE38 COLOR_REQTREE_EDGE // gray
101 #define SPECENUM_VALUE38NAME "reqtree_edge"
102 // Player dialog
103 #define SPECENUM_VALUE39 COLOR_PLAYER_COLOR_BACKGROUND // black
104 #define SPECENUM_VALUE39NAME "playerdlg_background"
105 
106 #define SPECENUM_COUNT COLOR_LAST
107 #include "specenum_gen.h"
108 
109 QColor get_color(const struct tileset *t, enum color_std stdcolor);
110 bool player_has_color(const struct tileset *t, const struct player *pplayer);
111 QColor get_player_color(const struct tileset *t,
112  const struct player *pplayer);
113 QColor get_terrain_color(const struct tileset *t,
114  const struct terrain *pterrain);
115 
116 // Functions used by the tileset to allocate the color system.
117 struct color_system *color_system_read(struct section_file *file);
119 
120 // Utilities for color values
121 QColor color_best_contrast(const QColor &subject, const QColor *candidates,
122  int ncandidates);
void color_system_free(struct color_system *colors)
Called when the client first starts to free any allocated colors.
QColor color_best_contrast(const QColor &subject, const QColor *candidates, int ncandidates)
Find the colour from 'candidates' with the best perceptual contrast from 'subject'.
QColor get_color(const struct tileset *t, enum color_std stdcolor)
Return a pointer to the given "standard" color.
QColor get_terrain_color(const struct tileset *t, const struct terrain *pterrain)
Return a pointer to the given "terrain" color.
struct color_system * color_system_read(struct section_file *file)
Called when the client first starts to allocate the default colors.
bool player_has_color(const struct tileset *t, const struct player *pplayer)
Return whether the player has a color assigned yet.
QColor get_player_color(const struct tileset *t, const struct player *pplayer)
Return the color of the player.
Colors.
Definition: player.h:231