Added fourth color to team_rgb that is used to represent the color range,

e.g. in the minimap.  If the fourth color is absent, it should use the
mid color instead
This commit is contained in:
John W. C. McNabb 2006-10-29 04:16:38 +00:00
parent d9fbe695fd
commit 15845ee4f9
4 changed files with 23 additions and 18 deletions

View file

@ -38,6 +38,7 @@ Version 1.3-svn:
* show leader's name and colour at status table even when that team is fogged
(patch #605)
* WML engine
* added fourth color in team_rgb definitions for representative color in minimap
* fixed terrain probabilities for terrains defined with rotations (bug #7274)
* added a 'hide_help' key that prevents a unit type from being listed in the
in-game help (bug #5701)

View file

@ -1,54 +1,54 @@
[team_color]
side=1
team_rgb=255,0,0,255,255,255,0,0,0
team_rgb=255,0,0,255,255,255,0,0,0,255,0,0
name= _ "Red"
[/team_color]
[team_color]
side=2
team_rgb=46,65,155,255,255,255,15,15,15
team_rgb=46,65,155,255,255,255,15,15,15,46,65,155
name= _ "Blue"
[/team_color]
[team_color]
side=3
team_rgb=98,182,100,255,255,255,0,0,0
team_rgb=98,182,100,255,255,255,0,0,0,98,182,100
name= _ "Green"
[/team_color]
[team_color]
side=4
team_rgb=147,0,157,255,255,255,0,0,0
team_rgb=147,0,157,255,255,255,0,0,0,147,0,157
name= _ "Purple"
[/team_color]
[team_color]
side=7
team_rgb=240,114,0,240,240,240,0,0,0
team_rgb=240,114,0,240,240,240,0,0,0,240,114
name= _ "Orange"
[/team_color]
[team_color]
side=5
team_rgb=90,90,90,255,255,255,0,0,0
team_rgb=90,90,90,255,255,255,0,0,0,90,90,90
name= _ "Black"
[/team_color]
[team_color]
side=8
team_rgb=225,225,225,255,255,255,30,30,30
team_rgb=225,225,225,255,255,255,30,30,30,225,225,225
name= _ "White"
[/team_color]
[team_color]
side=6
team_rgb=148,80,39,255,255,255,0,0,0
team_rgb=148,80,39,255,255,255,0,0,0,148,80,39
name= _ "Brown"
[/team_color]
[team_color]
side=9
team_rgb=48,203,192,255,255,255,0,0,0
team_rgb=48,203,192,255,255,255,0,0,0,48,203,192
name= _ "Teal"
[/team_color]

View file

@ -24,28 +24,32 @@ std::vector<Uint32> string2rgb(std::string s);
class color_range
{
public:
color_range(Uint32 mid = 0x00808080 , Uint32 max = 0x00FFFFFF, Uint32 min = 0x00000000):mid_(mid),max_(max),min_(min){};
color_range(Uint32 mid , Uint32 max , Uint32 min , Uint32 rep):mid_(mid),max_(max),min_(min),rep_(rep){};
color_range(const std::vector<Uint32>& v)
{
{
mid_ = v.size() ? v[0] : 0x00808080;
max_ = v.size() ? v[1] : 0x00FFFFFF;
min_ = v.size() ? v[2] : 0x00000000;
max_ = v.size() > 1 ? v[1] : 0x00FFFFFF;
min_ = v.size() > 2 ? v[2] : 0x00000000;
rep_ = v.size() > 3 ? v[3] : mid_;
};
color_range(){color_range(0x00808080,0x00FFFFFF,0x00000000,0x00808080);};
Uint32 mid() const{return(mid_);};
Uint32 max() const{return(max_);};
Uint32 min() const{return(min_);};
Uint32 rep() const{return(rep_);};
bool operator<(const color_range& b) const
{
if(mid_ != b.mid()) return(mid_ < b.mid());
if(max_ != b.max()) return(max_ < b.max());
return(min_ < b.min());
if(min_ != b.min()) return(min_ < b.min());
return(rep_ < b.rep());
}
bool operator==(const color_range& b) const
{
return(mid_ == b.mid() && max_ == b.max() && min_ == b.min());
return(mid_ == b.mid() && max_ == b.max() && min_ == b.min() && rep_ == b.rep());
}
private:
Uint32 mid_ , max_ , min_;
Uint32 mid_ , max_ , min_ , rep_;
};
#endif

View file

@ -963,7 +963,7 @@ const color_range team::get_side_color_range(int side){
return(gp->second);
}
return(color_range(0x00FF0000,0x00FFFFFF,0x00000000));
return(color_range(0x00FF0000,0x00FFFFFF,0x00000000,0x00FF0000));
}
const Uint32 team::get_side_rgb(int side){
@ -980,7 +980,7 @@ const Uint32 team::get_side_rgb_min(int side){
const SDL_Color team::get_side_colour(int side)
{
Uint32 rgb=get_side_rgb(side);
Uint32 rgb=get_side_color_range(side).rep();
SDL_Color color={ (0x00FF0000 & rgb)>>16,
(0x0000FF00 & rgb)>>8,
(0x000000FF & rgb),