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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
|
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#include "graphics/2d.h"
#include "parse/parselo.h"
#include "globalincs/def_files.h"
#include "globalincs/alphacolors.h"
SCP_map<SCP_string, team_color> Team_Colors;
SCP_vector<SCP_string> Team_Names;
// -----------------------------------------------------------------------------------
// ALPHA DEFINES/VARS
//
color Color_blue, Color_bright_blue, Color_green, Color_bright_green;
color Color_black, Color_grey, Color_silver, Color_white, Color_bright_white;
color Color_violet_gray, Color_violet, Color_pink, Color_light_pink;
color Color_dim_red, Color_red, Color_bright_red, Color_yellow, Color_bright_yellow;
color Color_ui_light_green, Color_ui_green;
color Color_ui_light_pink, Color_ui_pink;
// netplayer colors
color *Color_netplayer[NETPLAYER_COLORS] = {
&Color_blue,
&Color_bright_blue,
&Color_green,
&Color_bright_green,
&Color_pink,
&Color_grey,
&Color_silver,
&Color_white,
&Color_bright_white,
&Color_violet_gray,
&Color_violet,
&Color_dim_red,
&Color_red,
&Color_bright_red,
&Color_yellow,
&Color_bright_yellow,
&Color_ui_light_green,
&Color_ui_green,
&Color_ui_light_pink,
&Color_ui_pink,
};
// -----------------------------------------------------------------------------------
// ALPHA FUNCTIONS
//
/**
* CommanderDJ: initialise alpha colors based on colors.tbl
* \return 1 if successful, 0 if init fails for any reason
*/
int new_alpha_colors_init()
{
int err_code;
if ((err_code = setjmp(parse_abort)) != 0)
{
mprintf(("Unable to parse 'colors.tbl'! Error code = %d.\n", err_code));
return 0;
}
if (cf_exists_full("colors.tbl", CF_TYPE_TABLES))
{
read_file_text("colors.tbl", CF_TYPE_TABLES);
mprintf(("TABLES => Starting parse of 'colors.tbl'...\n"));
}
else
{
//colors.tbl doesn't exist
mprintf(("TABLES => Unable to find 'colors.tbl'. Initialising colors with default values.\n"));
return 0;
}
reset_parse();
// we search for the colors based on their order of definition above
// if the color isn't found, we just use default values
if (required_string("#Start Colors"))
{
// vars for holding rgba values
int rgba[4] = {0,0,0,0};
color *colors[TOTAL_COLORS] = {
&Color_blue,
&Color_bright_blue,
&Color_green,
&Color_bright_green,
&Color_black,
&Color_grey,
&Color_silver,
&Color_white,
&Color_bright_white,
&Color_violet_gray,
&Color_violet,
&Color_dim_red,
&Color_red,
&Color_bright_red,
&Color_pink,
&Color_light_pink,
&Color_yellow,
&Color_bright_yellow,
&Color_ui_light_green,
&Color_ui_green,
&Color_ui_light_pink,
&Color_ui_pink,
};
char* color_names[TOTAL_COLORS] = {
"$Blue:",
"$Bright Blue:",
"$Green:",
"$Bright Green:",
"$Black:",
"$Grey:",
"$Silver:",
"$White:",
"$Bright White:",
"$Violet Gray:",
"$Violet:",
"$Dim Red:",
"$Red:",
"$Bright Red:",
"$Pink:",
"$Light Pink:",
"$Yellow:",
"$Bright Yellow:",
"$UI Light Green:",
"$UI Green:",
"$UI Light Pink:",
"$UI Pink:"
};
int rgba_defaults[TOTAL_COLORS][4] = {
{93, 93, 128, 255},
{185, 185, 255, 255},
{0, 120, 0, 255},
{50, 190, 50, 255},
{0, 0, 0, 255},
{65, 65, 65, 255},
{160, 160, 160, 255},
{105, 105, 105, 255},
{255, 255, 255 ,255},
{160, 144, 160, 255},
{192, 104, 192, 255},
{80, 6, 6, 255},
{126, 6, 6, 255},
{200, 0, 0, 255},
{185, 150, 150, 255},
{230, 190, 190, 255},
{255, 255, 122, 255},
{255, 255, 0, 255},
{161, 184, 161, 255},
{190, 228, 190, 255},
{184, 161, 161, 255},
{228, 190, 190, 255}
};
// now for each color, check if it's corresponding string is there
for (int i=0; i<TOTAL_COLORS; i++)
{
if (optional_string(color_names[i]))
{
// if so, get its rgba values and initialise it using them
mprintf(("'%s' has been redefined.\n", color_names[i]));
stuff_int_list(rgba, 4, RAW_INTEGER_TYPE);
for (int j=0; j<4; j++)
{
if (rgba[j] < 0)
{
Warning(LOCATION, "RGBA value for '%s' in colors.tbl too low (%d), capping to 0.", color_names[i], rgba[j]);
rgba[j] = 0;
}
else if (rgba[j] > 255)
{
Warning(LOCATION, "RGBA value for '%s' in colors.tbl too high (%d), capping to 255.", color_names[i], rgba[j]);
rgba[j] = 255;
}
}
gr_init_alphacolor(colors[i], rgba[0], rgba[1], rgba[2], rgba[3]);
}
// otherwise use its defaults
else
gr_init_alphacolor(colors[i], rgba_defaults[i][0], rgba_defaults[i][1], rgba_defaults[i][2], rgba_defaults[i][3]);
}
required_string("#End");
}
//Team coloring
if (optional_string("#Team Colors")) {
while (required_string_either("#End", "$Team Name:")) {
required_string("$Team Name:"); // required to move the parse pointer forward
char temp[NAME_LENGTH];
SCP_string temp2;
team_color temp_color;
stuff_string(temp, F_NAME, NAME_LENGTH);
temp2 = SCP_string(temp);
if (required_string("$Team Stripe Color:")) {
int rgb[3];
stuff_int_list(rgb, 3, RAW_INTEGER_TYPE);
for (int i = 0; i < 3; i++) {
CLAMP(rgb[i], 0, 255);
}
temp_color.stripe.r = rgb[0] / 255.0f;
temp_color.stripe.g = rgb[1] / 255.0f;
temp_color.stripe.b = rgb[2] / 255.0f;
}
if (required_string("$Team Base Color:")) {
int rgb[3];
stuff_int_list(rgb, 3, RAW_INTEGER_TYPE);
for (int i = 0; i < 3; i++) {
CLAMP(rgb[i], 0, 255);
}
temp_color.base.r = rgb[0] / 255.0f;
temp_color.base.g = rgb[1] / 255.0f;
temp_color.base.b = rgb[2] / 255.0f;
}
Team_Colors[temp2] = temp_color;
Team_Names.push_back(temp2);
}
}
return 1;
}
// initialize all alpha colors (call at startup)
void old_alpha_colors_init()
{
// See the variable declarations above for color usage
gr_init_alphacolor( &Color_blue, 93, 93, 128, 255 );
gr_init_alphacolor( &Color_bright_blue, 185, 185, 255, 255 );
gr_init_alphacolor( &Color_green, 0, 120, 0, 255 );
gr_init_alphacolor( &Color_bright_green, 50, 190, 50, 255 );
gr_init_alphacolor( &Color_black, 0, 0, 0, 255 );
gr_init_alphacolor( &Color_grey, 65, 65, 65, 255 );
gr_init_alphacolor( &Color_silver, 160, 160, 160, 255 );
gr_init_alphacolor( &Color_white, 105, 105, 105, 255 );
gr_init_alphacolor( &Color_bright_white, 255, 255, 255, 255 );
gr_init_alphacolor( &Color_violet_gray, 160, 144, 160, 255 );
gr_init_alphacolor( &Color_violet, 192, 104, 192, 255 );
gr_init_alphacolor( &Color_dim_red, 80, 6, 6, 255 );
gr_init_alphacolor( &Color_red, 126, 6, 6, 255 );
gr_init_alphacolor( &Color_bright_red, 200, 0, 0, 255 );
gr_init_alphacolor( &Color_pink, 185, 150, 150, 255 );
gr_init_alphacolor( &Color_light_pink, 230, 190, 190, 255 );
gr_init_alphacolor( &Color_yellow, 255, 255, 122, 255 );
gr_init_alphacolor( &Color_bright_yellow, 255, 255, 0, 255 );
gr_init_alphacolor( &Color_ui_light_green, 161, 184, 161, 255 );
gr_init_alphacolor( &Color_ui_green, 190, 228, 190, 255 );
gr_init_alphacolor( &Color_ui_light_pink, 184, 161, 161, 255 );
gr_init_alphacolor( &Color_ui_pink, 228, 190, 190, 255 );
}
|