added an int_to_color() utility function
This commit is contained in:
parent
70a0145bd1
commit
402c8e4c93
6 changed files with 14 additions and 16 deletions
|
@ -2427,13 +2427,9 @@ void display::add_chat_message(const std::string& speaker, int side, const std::
|
|||
for(std::vector<chat_message>::const_iterator m = chat_messages_.begin(); m != chat_messages_.end(); ++m) {
|
||||
ypos += font::get_floating_label_rect(m->handle).h;
|
||||
}
|
||||
|
||||
SDL_Color speaker_colour = {255,255,255,255};
|
||||
if(side >= 1) {
|
||||
Uint32 rgb = team::get_side_color_range(side).mid();
|
||||
speaker_colour.r = (0x00FF0000 & rgb)>>16;
|
||||
speaker_colour.g = (0x0000FF00 & rgb)>>8;
|
||||
speaker_colour.b = (0x000000FF & rgb);
|
||||
speaker_colour = int_to_color(team::get_side_color_range(side).mid());
|
||||
}
|
||||
|
||||
SDL_Color message_colour = chat_message_colour;
|
||||
|
|
|
@ -81,10 +81,7 @@ std::string::const_iterator parse_markup(std::string::const_iterator i1, std::st
|
|||
if(*i1 != '0')
|
||||
{
|
||||
Uint32 rgb = team::get_side_rgb(lexical_cast<int, char>(*i1));
|
||||
SDL_Color mid_colour = { (0x00FF0000 & rgb)>>16,
|
||||
(0x0000FF00 & rgb)>>8,
|
||||
(0x000000FF & rgb), 0} ;
|
||||
*colour = mid_colour;
|
||||
*colour = int_to_color(rgb);
|
||||
}
|
||||
++i1;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,15 @@
|
|||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
SDL_Color int_to_color(const Uint32 rgb) {
|
||||
SDL_Color to_return = {
|
||||
(0x00FF0000 & rgb)>>16,
|
||||
(0x0000FF00 & rgb)>>8,
|
||||
(0x000000FF & rgb), 0
|
||||
};
|
||||
return to_return;
|
||||
}
|
||||
|
||||
SDLKey sdl_keysym_from_name(std::string const &keyname)
|
||||
{
|
||||
static bool initialized = false;
|
||||
|
|
|
@ -133,6 +133,7 @@ bool operator!=(const SDL_Rect& a, const SDL_Rect& b);
|
|||
bool operator==(const SDL_Color& a, const SDL_Color& b);
|
||||
bool operator!=(const SDL_Color& a, const SDL_Color& b);
|
||||
SDL_Color inverse(const SDL_Color& colour);
|
||||
SDL_Color int_to_color(const Uint32 rgb);
|
||||
|
||||
class config; // no need to include config.hpp
|
||||
|
||||
|
|
|
@ -766,12 +766,7 @@ const color_range team::get_side_color_range(int side){
|
|||
|
||||
const SDL_Color team::get_side_colour(int side)
|
||||
{
|
||||
Uint32 rgb=get_side_color_range(side).rep();
|
||||
SDL_Color color={ (0x00FF0000 & rgb)>>16,
|
||||
(0x0000FF00 & rgb)>>8,
|
||||
(0x000000FF & rgb),
|
||||
0} ;
|
||||
return color;
|
||||
return int_to_color(get_side_color_range(side).rep());
|
||||
}
|
||||
|
||||
std::string team::get_side_colour_index(int side)
|
||||
|
|
|
@ -234,7 +234,7 @@ public:
|
|||
bool auto_shroud_updates() const { return auto_shroud_updates_; }
|
||||
void set_auto_shroud_updates(bool value) { auto_shroud_updates_ = value; }
|
||||
|
||||
std::string map_colour_to() const { return info_.colour; }
|
||||
std::string map_colour_to() const { return info_.colour; };
|
||||
|
||||
static int nteams();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue