43 enum color_std stdcolor;
47 for (stdcolor = color_std_begin(); stdcolor != color_std_end();
48 stdcolor = color_std_next(stdcolor)) {
49 struct rgbcolor *prgbcolor =
nullptr;
52 color_std_name(stdcolor))) {
53 *(
colors->stdcolors + stdcolor) = prgbcolor;
55 qCritical(
"Color %s: %s", color_std_name(stdcolor),
secfile_error());
68 enum color_std stdcolor;
70 for (stdcolor = color_std_begin(); stdcolor != color_std_end();
71 stdcolor = color_std_next(stdcolor)) {
75 delete[]
colors->stdcolors;
88 auto &color = *(
colors->stdcolors + stdcolor);
89 return QColor(color->r, color->g, color->b);
101 return pplayer->
rgb !=
nullptr;
110 const struct player *pplayer)
116 return QColor(pplayer->
rgb->
r, pplayer->
rgb->
g, pplayer->
rgb->
b);
123 const struct terrain *pterrain)
129 return QColor(pterrain->
rgb->
r, pterrain->
rgb->
g, pterrain->
rgb->
b);
145 for (
int i = 0; i < ncandidates; i++) {
147 int diff =
ABS(sbright - cbright);
149 if (i == 0 || diff > bestdiff) {
150 best = candidates[i];
166 rgbcolor prgb{color.red(), color.green(), color.blue()};
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.
int color_brightness_score(const QColor &color)
Return a number indicating the perceptual brightness of this color relative to others (larger is brig...
#define fc_assert_ret_val(condition, val)
const char * secfile_error()
Returns the last error which occurred in a string.
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Free rgbcolor structure.
bool rgbcolor_load(struct section_file *file, struct rgbcolor **prgbcolor, const char *path,...)
Lookup an RGB color definition ([colorpath].red, [colorpath].green and [colorpath]....
struct rgbcolor * rgbcolor_new(int r, int g, int b)
Allocate new rgbcolor structure.
int rgbcolor_brightness_score(struct rgbcolor *prgbcolor)
Return a number indicating the perceptual brightness of this color relative to others (larger is brig...
struct rgbcolor ** stdcolors
struct color_system * get_color_system(const struct tileset *t)
Return the tileset's color system.