mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-10 20:52:18 +00:00
adding team colors to flags
This commit is contained in:
parent
30dd619a4d
commit
abd9278fde
BIN
images/terrain/flag-1.png
Normal file
BIN
images/terrain/flag-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 995 B |
BIN
images/terrain/flag-2.png
Normal file
BIN
images/terrain/flag-2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 867 B |
@ -104,20 +104,46 @@ display::display(unit_map& units, CVideo& video, const gamemap& map,
|
|||||||
flags_.reserve(teams_.size());
|
flags_.reserve(teams_.size());
|
||||||
for(size_t i = 0; i != teams_.size(); ++i) {
|
for(size_t i = 0; i != teams_.size(); ++i) {
|
||||||
std::string flag;
|
std::string flag;
|
||||||
|
color_range new_rgb;
|
||||||
|
std::vector<Uint32> old_rgb;
|
||||||
|
|
||||||
if(teams_[i].flag().empty()) {
|
if(teams_[i].flag().empty()) {
|
||||||
flag = game_config::flag_image;
|
flag = game_config::flag_image;
|
||||||
std::string::size_type pos;
|
old_rgb = game_config::flag_rgb;
|
||||||
while((pos = flag.find("%d")) != std::string::npos) {
|
new_rgb = team::get_side_color_range(i+1);
|
||||||
std::ostringstream s;
|
|
||||||
s << teams_[i].map_colour_to();
|
|
||||||
flag.replace(pos, 2, s.str());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
flag = teams_[i].flag();
|
flag = teams_[i].flag();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_STREAM(info, display) << "Adding flag for team " << i << " from animation " << flag << "\n";
|
LOG_STREAM(info, display) << "Adding flag for team " << i << " from animation " << flag << "\n";
|
||||||
flags_.push_back(animated<image::locator>(flag));
|
|
||||||
|
//must recolor flag image
|
||||||
|
animated<image::locator> temp_anim;
|
||||||
|
|
||||||
|
std::vector<std::string> items = utils::split(flag);
|
||||||
|
int current_time = 0;
|
||||||
|
std::vector<std::string>::const_iterator itor = items.begin();
|
||||||
|
for(; itor != items.end(); ++itor) {
|
||||||
|
const std::vector<std::string>& items = utils::split(*itor, ':');
|
||||||
|
std::string str;
|
||||||
|
int time;
|
||||||
|
|
||||||
|
if(items.size() > 1) {
|
||||||
|
str = items.front();
|
||||||
|
time = atoi(items.back().c_str());
|
||||||
|
} else {
|
||||||
|
str = *itor;
|
||||||
|
time = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout<<" current time:"<<current_time<<std::endl;
|
||||||
|
std::cout<<" frame:"<<str<<std::endl;
|
||||||
|
image::locator flag_image(str, new_rgb, old_rgb);
|
||||||
|
temp_anim.add_frame(current_time, flag_image);
|
||||||
|
current_time += time;
|
||||||
|
}
|
||||||
|
temp_anim.add_frame(current_time);
|
||||||
|
flags_.push_back(temp_anim);
|
||||||
flags_.back().start_animation(0, animated<image::locator>::INFINITE_CYCLES);
|
flags_.back().start_animation(0, animated<image::locator>::INFINITE_CYCLES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ namespace game_config
|
|||||||
std::string enemy_energy_image = "misc/bar-energy-enemy.png";
|
std::string enemy_energy_image = "misc/bar-energy-enemy.png";
|
||||||
std::string ally_energy_image = "misc/bar-energy-ally.png";
|
std::string ally_energy_image = "misc/bar-energy-ally.png";
|
||||||
std::string flag_image = "terrain/flag-team%d-1.png:150,terrain/flag-team%d-2.png:150";
|
std::string flag_image = "terrain/flag-team%d-1.png:150,terrain/flag-team%d-2.png:150";
|
||||||
|
std::vector<Uint32> flag_rgb;
|
||||||
|
|
||||||
std::string dot_image = "misc/dot.png";
|
std::string dot_image = "misc/dot.png";
|
||||||
std::string cross_image = "misc/cross.png";
|
std::string cross_image = "misc/cross.png";
|
||||||
@ -130,6 +131,13 @@ namespace game_config
|
|||||||
enemy_energy_image = v["enemy_energy_image"];
|
enemy_energy_image = v["enemy_energy_image"];
|
||||||
ally_energy_image = v["ally_energy_image"];
|
ally_energy_image = v["ally_energy_image"];
|
||||||
flag_image = v["flag_image"];
|
flag_image = v["flag_image"];
|
||||||
|
flag_rgb = string2rgb(v["flag_rgb"]);
|
||||||
|
if( !flag_rgb.size()){
|
||||||
|
//set green as old_flag_color
|
||||||
|
for(int i=0;i!=256;i++){
|
||||||
|
flag_rgb.push_back((Uint32)(i<<8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cross_image = v["cross_image"];
|
cross_image = v["cross_image"];
|
||||||
dot_image = v["dot_image"];
|
dot_image = v["dot_image"];
|
||||||
|
@ -47,6 +47,8 @@ namespace game_config
|
|||||||
missile_n_image,missile_ne_image,terrain_mask_image,observer_image,download_campaign_image,
|
missile_n_image,missile_ne_image,terrain_mask_image,observer_image,download_campaign_image,
|
||||||
checked_menu_image,unchecked_menu_image,level_image,ellipsis_image;
|
checked_menu_image,unchecked_menu_image,level_image,ellipsis_image;
|
||||||
|
|
||||||
|
extern std::vector<Uint32> flag_rgb;
|
||||||
|
|
||||||
extern std::vector<std::string> foot_left_nw,foot_left_n,foot_right_nw,foot_right_n;
|
extern std::vector<std::string> foot_left_nw,foot_left_n,foot_right_nw,foot_right_n;
|
||||||
|
|
||||||
extern int title_logo_x, title_logo_y, title_buttons_x, title_buttons_y, title_buttons_padding, title_tip_x, title_tip_y, title_tip_width, title_tip_padding;
|
extern int title_logo_x, title_logo_y, title_buttons_x, title_buttons_y, title_buttons_padding, title_tip_x, title_tip_y, title_tip_width, title_tip_padding;
|
||||||
|
64
src/team.cpp
64
src/team.cpp
@ -908,82 +908,44 @@ bool team::shroud_map::copy_from(const std::vector<const shroud_map*>& maps)
|
|||||||
|
|
||||||
std::map<int, color_range> team::team_color_range_;
|
std::map<int, color_range> team::team_color_range_;
|
||||||
|
|
||||||
const Uint32 team::get_side_rgb(int side){
|
const color_range team::get_side_color_range(int side){
|
||||||
size_t index = size_t(get_side_colour_index(side));
|
size_t index = size_t(get_side_colour_index(side));
|
||||||
std::map<int, color_range>::iterator p=team_color_range_.find(index);
|
std::map<int, color_range>::iterator p=team_color_range_.find(index);
|
||||||
|
|
||||||
if(p != team_color_range_.end()){
|
if(p != team_color_range_.end()){
|
||||||
return(p->second.mid());
|
return(p->second);
|
||||||
}else{
|
}else{
|
||||||
p=team_color_range_.find(side);
|
p=team_color_range_.find(side);
|
||||||
if(p != team_color_range_.end()){
|
if(p != team_color_range_.end()){
|
||||||
return(p->second.mid());
|
return(p->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p=game_config::team_rgb_range.find(side);
|
p=game_config::team_rgb_range.find(side);
|
||||||
if(p != game_config::team_rgb_range.end()){
|
if(p != game_config::team_rgb_range.end()){
|
||||||
return(p->second.mid());
|
return(p->second);
|
||||||
}else{
|
}else{
|
||||||
p=game_config::team_rgb_range.find(side);
|
p=game_config::team_rgb_range.find(side);
|
||||||
if(p != game_config::team_rgb_range.end()){
|
if(p != game_config::team_rgb_range.end()){
|
||||||
return(p->second.mid());
|
return(p->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0x00FF0000;
|
return(color_range(0x00FF0000,0x00FFFFFF,0x00000000));
|
||||||
|
}
|
||||||
|
|
||||||
|
const Uint32 team::get_side_rgb(int side){
|
||||||
|
return(get_side_color_range(side).mid());
|
||||||
}
|
}
|
||||||
|
|
||||||
const Uint32 team::get_side_rgb_max(int side){
|
const Uint32 team::get_side_rgb_max(int side){
|
||||||
size_t index = size_t(get_side_colour_index(side));
|
return(get_side_color_range(side).max());
|
||||||
std::map<int, color_range>::iterator p=team_color_range_.find(index);
|
|
||||||
if(p != team_color_range_.end()){
|
|
||||||
return(p->second.max());
|
|
||||||
}else{
|
|
||||||
p=team_color_range_.find(side);
|
|
||||||
if(p != team_color_range_.end()){
|
|
||||||
return(p->second.max());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p=game_config::team_rgb_range.find(side);
|
|
||||||
if(p != game_config::team_rgb_range.end()){
|
|
||||||
return(p->second.max());
|
|
||||||
}else{
|
|
||||||
p=game_config::team_rgb_range.find(side);
|
|
||||||
if(p != game_config::team_rgb_range.end()){
|
|
||||||
return(p->second.max());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0x00FFFFFF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Uint32 team::get_side_rgb_min(int side){
|
const Uint32 team::get_side_rgb_min(int side){
|
||||||
size_t index = size_t(get_side_colour_index(side));
|
return(get_side_color_range(side).min());
|
||||||
std::map<int, color_range>::iterator p=team_color_range_.find(index);
|
|
||||||
if(p != team_color_range_.end()){
|
|
||||||
return(p->second.min());
|
|
||||||
}else{
|
|
||||||
p=team_color_range_.find(side);
|
|
||||||
if(p != team_color_range_.end()){
|
|
||||||
return(p->second.min());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p=game_config::team_rgb_range.find(side);
|
|
||||||
if(p != game_config::team_rgb_range.end()){
|
|
||||||
return(p->second.min());
|
|
||||||
}else{
|
|
||||||
p=game_config::team_rgb_range.find(side);
|
|
||||||
if(p != game_config::team_rgb_range.end()){
|
|
||||||
return(p->second.min());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0x00000000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const SDL_Color team::get_side_colour(int side)
|
const SDL_Color team::get_side_colour(int side)
|
||||||
{
|
{
|
||||||
Uint32 rgb=get_side_rgb(side);
|
Uint32 rgb=get_side_rgb(side);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user