changes to the way floating labels are shown

This commit is contained in:
Dave White 2004-04-02 14:50:50 +00:00
parent 186956a5ce
commit 7cb180bd7d
3 changed files with 23 additions and 3 deletions

View file

@ -343,6 +343,8 @@ battle_stats evaluate_battle_stats(
res.damage_attacker_takes = maximum<int>(1,base_damage + difference);
if(include_strings) {
percent *= is_negative;
std::stringstream str;
str << translate_string("total_damage") << "," << res.damage_attacker_takes
<< ",^" << (percent >= 0 ? "+" : "") << percent << "% (" << (difference >= 0 ? "+" : "") << difference << ")";
@ -460,6 +462,8 @@ battle_stats evaluate_battle_stats(
res.damage_defender_takes = maximum<int>(1,base_damage + difference);
if(include_strings) {
percent *= is_negative;
std::stringstream str;
str << translate_string("total_damage") << "," << res.damage_defender_takes
<< ",^" << (percent >= 0 ? "+" : "") << percent << "% (" << (difference >= 0 ? "+" : "") << difference << ")";

View file

@ -1791,6 +1791,14 @@ void display::move_unit(const std::vector<gamemap::location>& path, unit& u)
}
}
void display::float_label(const gamemap::location& loc, const std::string& text,
int red, int green, int blue)
{
const SDL_Color colour = {red,green,blue,255};
font::add_floating_label(text,20,colour,get_location_x(loc)+zoom_*0.5,get_location_y(loc),
0,-3,40,screen_area());
}
bool display::unit_attack_ranged(const gamemap::location& a,
const gamemap::location& b, int damage,
const attack_type& attack)
@ -1878,6 +1886,12 @@ bool display::unit_attack_ranged(const gamemap::location& a,
draw_tile(a.x,a.y,image);
}
if(damage > 0 && i == missile_impact) {
char buf[50];
sprintf(buf,"%d",damage);
float_label(b,buf,255,0,0);
}
Uint32 defensive_colour = 0;
double defensive_alpha = 1.0;
@ -2092,9 +2106,7 @@ bool display::unit_attack(const gamemap::location& a,
if(damage > 0 && i == 0) {
char buf[50];
sprintf(buf,"%d",damage);
const SDL_Color colour = {255,0,0,255};
font::add_floating_label(buf,20,colour,get_location_x(b)+zoom_*0.5,get_location_y(b),
0,-3,40,screen_area());
float_label(b,buf,255,0,0);
}
if(damage > 0 && i >= 0) {

View file

@ -164,6 +164,10 @@ public:
void draw_tile(int x, int y, SDL_Surface* unit_image=NULL,
double alpha=1.0, Uint32 blend_to=0);
//function to float a label above a tile
void float_label(const gamemap::location& loc, const std::string& text,
int red, int green, int blue);
private:
void draw_unit_on_tile(int x, int y, SDL_Surface* unit_image=NULL,
double alpha=1.0, Uint32 blend_to=0);