updates to the energy and xp bars
This commit is contained in:
parent
49c78c9590
commit
21d5fdbfef
14 changed files with 136 additions and 71 deletions
|
@ -62,6 +62,11 @@ SVN trunk (1.1-svn):
|
|||
* decreased strong trait hitpoints bonus from 2 to 1
|
||||
* added a fisher's clock to MP games to limit turn duration
|
||||
* graphics:
|
||||
* HP and XP bar modifications
|
||||
*movement ball seperated from bars
|
||||
*moved to left so xp bar under the ball
|
||||
*xpbar now changes color differently for AMLA then for regular leveling
|
||||
*bar colors and text color in report now forced to match.
|
||||
* team color:
|
||||
* units can now have colors redefined to match team colors:
|
||||
* team color can be defined in the side tag with "team_rgb=r,g,b"
|
||||
|
|
|
@ -67,11 +67,12 @@ default=yes
|
|||
sidebar_image="misc/rightside.png"
|
||||
sidebar_image_bottom="misc/rightside-bottom.png"
|
||||
|
||||
moved_energy_image="misc/bar-energy-moved.png"
|
||||
unmoved_energy_image="misc/bar-energy-unmoved.png"
|
||||
partmoved_energy_image="misc/bar-energy-partmoved.png"
|
||||
enemy_energy_image="misc/bar-energy-enemy.png"
|
||||
ally_energy_image="misc/bar-energy-ally.png"
|
||||
energy_image="misc/bar-energy.png"
|
||||
moved_ball_image="misc/ball-moved.png"
|
||||
unmoved_ball_image="misc/ball-unmoved.png"
|
||||
partmoved_ball_image="misc/ball-partmoved.png"
|
||||
enemy_ball_image="misc/ball-enemy.png"
|
||||
ally_ball_image="misc/ball-ally.png"
|
||||
flag_image="terrain/flag-1.png:150,terrain/flag-2.png:150"
|
||||
|
||||
cross_image="misc/cross.png"
|
||||
|
|
BIN
images/misc/ball-ally.png
Normal file
BIN
images/misc/ball-ally.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 782 B |
BIN
images/misc/ball-enemy.png
Normal file
BIN
images/misc/ball-enemy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 275 B |
BIN
images/misc/ball-moved.png
Normal file
BIN
images/misc/ball-moved.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 785 B |
BIN
images/misc/ball-partmoved.png
Normal file
BIN
images/misc/ball-partmoved.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 800 B |
BIN
images/misc/ball-unmoved.png
Normal file
BIN
images/misc/ball-unmoved.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 792 B |
BIN
images/misc/bar-energy.png
Normal file
BIN
images/misc/bar-energy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 257 B |
|
@ -1269,13 +1269,14 @@ void display::draw_unit_on_tile(int x, int y, surface unit_image_override,
|
|||
|
||||
double unit_energy = 0.0;
|
||||
|
||||
SDL_Color energy_colour = {0,0,0,0};
|
||||
|
||||
surface unit_image(unit_image_override);
|
||||
|
||||
const std::string* energy_file = NULL;
|
||||
const std::string* movement_file = NULL;
|
||||
const std::string* energy_file = &game_config::energy_image;
|
||||
|
||||
const unit& u = it->second;
|
||||
SDL_Color energy_colour = u.hp_color();
|
||||
|
||||
if(loc != hiddenUnit_ || !hideEnergy_) {
|
||||
if(unit_image == NULL) {
|
||||
|
@ -1292,20 +1293,25 @@ void display::draw_unit_on_tile(int x, int y, surface unit_image_override,
|
|||
if(size_t(u.side()) != currentTeam_+1) {
|
||||
if(team_valid() &&
|
||||
teams_[currentTeam_].is_enemy(it->second.side())) {
|
||||
energy_file = &game_config::enemy_energy_image;
|
||||
movement_file = &game_config::enemy_ball_image;
|
||||
} else {
|
||||
energy_file = &game_config::ally_energy_image;
|
||||
movement_file = &game_config::ally_ball_image;
|
||||
}
|
||||
} else {
|
||||
if(activeTeam_ == currentTeam_ && unit_move == unit_total_move && !it->second.user_end_turn()) {
|
||||
energy_file = &game_config::unmoved_energy_image;
|
||||
movement_file = &game_config::unmoved_ball_image;
|
||||
} else if(activeTeam_ == currentTeam_ && unit_can_move(loc,units_,map_,teams_) && !it->second.user_end_turn()) {
|
||||
energy_file = &game_config::partmoved_energy_image;
|
||||
movement_file = &game_config::partmoved_ball_image;
|
||||
} else {
|
||||
energy_file = &game_config::moved_energy_image;
|
||||
movement_file = &game_config::moved_ball_image;
|
||||
}
|
||||
}
|
||||
|
||||
wassert(movement_file != NULL);
|
||||
if(movement_file == NULL) {
|
||||
ERR_DP << "movement file is NULL\n";
|
||||
return;
|
||||
}
|
||||
wassert(energy_file != NULL);
|
||||
if(energy_file == NULL) {
|
||||
ERR_DP << "energy file is NULL\n";
|
||||
|
@ -1332,20 +1338,6 @@ void display::draw_unit_on_tile(int x, int y, surface unit_image_override,
|
|||
unit_energy = double(u.hitpoints())/double(u.max_hitpoints());
|
||||
}
|
||||
|
||||
if(unit_energy < 0.33) {
|
||||
energy_colour.r = 200;
|
||||
energy_colour.g = 0;
|
||||
energy_colour.b = 0;
|
||||
} else if(unit_energy < 0.66) {
|
||||
energy_colour.r = 200;
|
||||
energy_colour.g = 200;
|
||||
energy_colour.b = 0;
|
||||
} else {
|
||||
energy_colour.r = 0;
|
||||
energy_colour.g = 200;
|
||||
energy_colour.b = 0;
|
||||
}
|
||||
|
||||
if(u.facing_left() == false) {
|
||||
//reverse the image here. image::reverse_image is more efficient, however
|
||||
//it can be used only if we are sure that unit_image came from image::get_image.
|
||||
|
@ -1415,18 +1407,16 @@ void display::draw_unit_on_tile(int x, int y, surface unit_image_override,
|
|||
|
||||
const fixed_t bar_alpha = highlight_ratio < ftofxp(1.0) && blend_with == 0 ? highlight_ratio : (loc == mouseoverHex_ ? ftofxp(1.0): ftofxp(0.6));
|
||||
|
||||
if(energy_file != NULL) {
|
||||
draw_bar(*energy_file,xpos,ypos,(u.max_hitpoints()*2)/3,unit_energy,energy_colour,bar_alpha);
|
||||
}
|
||||
draw_bar(*movement_file,xpos,ypos,0,0,energy_colour,bar_alpha);
|
||||
|
||||
draw_bar(*energy_file,xpos-5,ypos,(u.max_hitpoints()*2)/3,unit_energy,energy_colour,bar_alpha);
|
||||
|
||||
if(u.experience() > 0 && u.can_advance()) {
|
||||
const double filled = double(u.experience())/double(u.max_experience());
|
||||
const int level = maximum<int>(u.type().level(),1);
|
||||
const SDL_Color normal_colour = {2,153,255,0}, near_advance_colour = {255,255,255,0};
|
||||
const bool near_advance = u.max_experience() - u.experience() <= game_config::kill_experience*level;
|
||||
const SDL_Color colour = near_advance ? near_advance_colour : normal_colour;
|
||||
|
||||
draw_bar("misc/bar-energy-enemy.png",xpos+5,ypos,u.max_experience()/(level*2),filled,colour,bar_alpha);
|
||||
SDL_Color colour=u.xp_color();
|
||||
draw_bar(*energy_file,xpos,ypos,u.max_experience()/(level*2),filled,colour,bar_alpha);
|
||||
}
|
||||
|
||||
if (u.can_recruit()) {
|
||||
|
|
|
@ -47,11 +47,12 @@ namespace game_config
|
|||
std::string rightside_image = "misc/rightside.png";
|
||||
std::string rightside_image_bot = "misc/rightside-bottom.png";
|
||||
|
||||
std::string moved_energy_image = "misc/bar-energy-moved.png";
|
||||
std::string unmoved_energy_image = "misc/bar-energy-unmoved.png";
|
||||
std::string partmoved_energy_image = "misc/bar-energy-partmoved.png";
|
||||
std::string enemy_energy_image = "misc/bar-energy-enemy.png";
|
||||
std::string ally_energy_image = "misc/bar-energy-ally.png";
|
||||
std::string energy_image = "misc/bar-energy.png";
|
||||
std::string moved_ball_image = "misc/ball-moved.png";
|
||||
std::string unmoved_ball_image = "misc/ball-unmoved.png";
|
||||
std::string partmoved_ball_image = "misc/ball-partmoved.png";
|
||||
std::string enemy_ball_image = "misc/ball-enemy.png";
|
||||
std::string ally_ball_image = "misc/ball-ally.png";
|
||||
std::string flag_image = "terrain/flag-team%d-1.png:150,terrain/flag-team%d-2.png:150";
|
||||
std::vector<Uint32> flag_rgb;
|
||||
|
||||
|
@ -125,11 +126,12 @@ namespace game_config
|
|||
rightside_image = v["sidebar_image"];
|
||||
rightside_image_bot = v["sidebar_image_bottom"];
|
||||
|
||||
moved_energy_image = v["moved_energy_image"];
|
||||
unmoved_energy_image = v["unmoved_energy_image"];
|
||||
partmoved_energy_image = v["partmoved_energy_image"];
|
||||
enemy_energy_image = v["enemy_energy_image"];
|
||||
ally_energy_image = v["ally_energy_image"];
|
||||
energy_image = v["energy_image"];
|
||||
moved_ball_image = v["moved_ball_image"];
|
||||
unmoved_ball_image = v["unmoved_ball_image"];
|
||||
partmoved_ball_image = v["partmoved_ball_image"];
|
||||
enemy_ball_image = v["enemy_ball_image"];
|
||||
ally_ball_image = v["ally_ball_image"];
|
||||
flag_image = v["flag_image"];
|
||||
flag_rgb = string2rgb(v["flag_rgb"]);
|
||||
if( !flag_rgb.size()){
|
||||
|
|
|
@ -41,11 +41,12 @@ namespace game_config
|
|||
extern std::string path;
|
||||
|
||||
extern std::string game_icon, game_title, game_logo, title_music, map_image, rightside_image, rightside_image_bot, anonymous_music,
|
||||
moved_energy_image, unmoved_energy_image, partmoved_energy_image,
|
||||
enemy_energy_image,ally_energy_image,flag_image,
|
||||
dot_image,cross_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;
|
||||
moved_ball_image, unmoved_ball_image, partmoved_ball_image,
|
||||
enemy_ball_image, ally_ball_image, energy_image,
|
||||
flag_image, dot_image, cross_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;
|
||||
|
||||
extern std::vector<Uint32> flag_rgb;
|
||||
|
||||
|
|
|
@ -81,6 +81,9 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
|
|||
const gamestatus& status, const std::set<std::string>& observers)
|
||||
{
|
||||
unit_map::const_iterator u = units.end();
|
||||
SDL_Color HPC;
|
||||
SDL_Color XPC;
|
||||
|
||||
|
||||
if(int(type) >= int(UNIT_REPORTS_BEGIN) && int(type) < int(UNIT_REPORTS_END) || type == POSITION) {
|
||||
|
||||
|
@ -175,29 +178,18 @@ Units cannot be killed by poison alone. The poison will not reduce it below 1 HP
|
|||
|
||||
return res;
|
||||
}
|
||||
case UNIT_HP:
|
||||
if(u->second.hitpoints() <= u->second.max_hitpoints()/3)
|
||||
str << "<200,0,0>";
|
||||
else if(u->second.hitpoints() > 2*(u->second.max_hitpoints()/3))
|
||||
str << "<0,200,0>";
|
||||
else
|
||||
str << "<200,200,0>";
|
||||
|
||||
|
||||
str << u->second.hitpoints()
|
||||
<< "/" << u->second.max_hitpoints();
|
||||
|
||||
break;
|
||||
case UNIT_XP:
|
||||
if(u->second.can_advance() == false) {
|
||||
str << u->second.experience() << "/-";
|
||||
} else {
|
||||
int x = (int)(128 + ((255-128)*((float)u->second.experience())/u->second.max_experience()));
|
||||
str << "<" << x << "," << x << "," << x <<">";
|
||||
str << u->second.experience() << "/" << u->second.max_experience();
|
||||
}
|
||||
|
||||
break;
|
||||
case UNIT_HP: {
|
||||
HPC=u->second.hp_color();
|
||||
str << "<" << (int) HPC.r << "," << (int) HPC.g << "," << (int) HPC.b << ">"
|
||||
<< u->second.hitpoints() << "/" << u->second.max_hitpoints();
|
||||
break;
|
||||
}
|
||||
case UNIT_XP: {
|
||||
XPC=u->second.xp_color();
|
||||
str << "<" << (int) XPC.r << "," << (int) XPC.g << "," << (int) XPC.b << ">"
|
||||
<< u->second.experience() << "/" << u->second.max_experience();
|
||||
break;
|
||||
}
|
||||
case UNIT_ADVANCEMENT_OPTIONS: {
|
||||
report res;
|
||||
const std::map<std::string,std::string>& adv_icons=u->second.advancement_icons();
|
||||
|
|
72
src/unit.cpp
72
src/unit.cpp
|
@ -402,11 +402,83 @@ int unit::max_hitpoints() const
|
|||
return maxHitpoints_;
|
||||
}
|
||||
|
||||
SDL_Colour unit::hp_color() const{
|
||||
double unit_energy = 0.0;
|
||||
SDL_Color energy_colour = {0,0,0,0};
|
||||
|
||||
if(max_hitpoints() > 0) {
|
||||
unit_energy = double(hitpoints())/double(max_hitpoints());
|
||||
}
|
||||
|
||||
if(1.0 == unit_energy){
|
||||
energy_colour.r = 33;
|
||||
energy_colour.g = 225;
|
||||
energy_colour.b = 0;
|
||||
} else if(unit_energy > 1.0) {
|
||||
energy_colour.r = 100;
|
||||
energy_colour.g = 255;
|
||||
energy_colour.b = 100;
|
||||
} else if(unit_energy >= 0.75) {
|
||||
energy_colour.r = 170;
|
||||
energy_colour.g = 255;
|
||||
energy_colour.b = 0;
|
||||
} else if(unit_energy >= 0.5) {
|
||||
energy_colour.r = 255;
|
||||
energy_colour.g = 155;
|
||||
energy_colour.b = 0;
|
||||
} else if(unit_energy >= 0.25) {
|
||||
energy_colour.r = 255;
|
||||
energy_colour.g = 175;
|
||||
energy_colour.b = 0;
|
||||
} else {
|
||||
energy_colour.r = 255;
|
||||
energy_colour.g = 0;
|
||||
energy_colour.b = 0;
|
||||
}
|
||||
return energy_colour;
|
||||
}
|
||||
|
||||
int unit::experience() const
|
||||
{
|
||||
return experience_;
|
||||
}
|
||||
|
||||
SDL_Colour unit::xp_color() const{
|
||||
const SDL_Color near_advance_colour = {255,255,255,0};
|
||||
const SDL_Color mid_advance_colour = {150,255,255,0};
|
||||
const SDL_Color far_advance_colour = {0,205,205,0};
|
||||
const SDL_Color normal_colour = {0,160,225,0};
|
||||
const SDL_Color near_amla_colour = {225,0,255,0};
|
||||
const SDL_Color mid_amla_colour = {169,30,255,0};
|
||||
const SDL_Color far_amla_colour = {139,0,237,0};
|
||||
const SDL_Color amla_colour = {100,0,150,0};
|
||||
const bool near_advance = max_experience() - experience() <= game_config::kill_experience;
|
||||
const bool mid_advance = max_experience() - experience() <= game_config::kill_experience*2;
|
||||
const bool far_advance = max_experience() - experience() <= game_config::kill_experience*3;
|
||||
|
||||
SDL_Color colour=normal_colour;
|
||||
if(type().advances_to().size()){
|
||||
if(near_advance){
|
||||
colour=near_advance_colour;
|
||||
} else if(mid_advance){
|
||||
colour=mid_advance_colour;
|
||||
} else if(far_advance){
|
||||
colour=far_advance_colour;
|
||||
}
|
||||
} else if (get_modification_advances().size()){
|
||||
if(near_advance){
|
||||
colour=near_amla_colour;
|
||||
} else if(mid_advance){
|
||||
colour=mid_amla_colour;
|
||||
} else if(far_advance){
|
||||
colour=far_amla_colour;
|
||||
} else {
|
||||
colour=amla_colour;
|
||||
}
|
||||
}
|
||||
return(colour);
|
||||
}
|
||||
|
||||
int unit::max_experience() const
|
||||
{
|
||||
return maxExperience_;
|
||||
|
|
|
@ -51,7 +51,9 @@ public:
|
|||
|
||||
int hitpoints() const;
|
||||
int max_hitpoints() const;
|
||||
SDL_Colour hp_color() const;
|
||||
int experience() const;
|
||||
SDL_Colour xp_color() const;
|
||||
int max_experience() const;
|
||||
bool get_experience(int xp);
|
||||
bool unrenamable() const; /** < Set to true for some scenario-specific units which should not be renamed */
|
||||
|
|
Loading…
Add table
Reference in a new issue