Small refactoring step; hide the guts of what the display code uses...

...for announcements.
This commit is contained in:
Eric S. Raymond 2007-06-13 08:46:18 +00:00
parent 505e760245
commit 946203ac8f
3 changed files with 19 additions and 7 deletions

View file

@ -2027,10 +2027,8 @@ size_t move_unit(display* disp, const game_data& gamedata,
if(discovered_unit) {
if (ambushed_string.empty())
ambushed_string = _("Ambushed!");
//we've been ambushed, so display an appropriate message
font::add_floating_label(ambushed_string,font::SIZE_XLARGE,font::BAD_COLOUR,
disp->map_area().w/2,disp->map_area().h/3,
0.0,0.0,100,disp->map_area(),font::CENTER_ALIGN);
//we've been ambushed, display an appropriate message
disp->announce(ambushed_string, font::BAD_COLOUR);
}
if(continue_move == false && seen_units.empty() == false) {
@ -2089,9 +2087,7 @@ size_t move_unit(display* disp, const game_data& gamedata,
}
}
font::add_floating_label(message,font::SIZE_XLARGE,msg_colour,
disp->map_area().w/2,disp->map_area().h/3,
0.0,0.0,100,disp->map_area(),font::CENTER_ALIGN);
disp->announce(message, msg_colour);
}
disp->draw();

View file

@ -2692,4 +2692,16 @@ void display::remove_highlighted_loc(const gamemap::location &hex)
}
}
void display::announce(const std::string message, const SDL_Color& colour)
{
font::add_floating_label(message,
font::SIZE_XLARGE,
colour,
map_area().w/2,
map_area().h/3,
0.0,0.0,100,
map_area(),
font::CENTER_ALIGN);
}
display *display::singleton_ = NULL;

View file

@ -420,6 +420,10 @@ public:
void remove_highlighted_loc(const gamemap::location &hex);
// Announce a message prominently
void announce(const std::string msg,
const SDL_Color& colour = font::GOOD_COLOUR);
void begin_game();
bool in_game() const { return in_game_; }