Lift the grid_ member and fix some comments.

This commit is contained in:
Eric S. Raymond 2007-06-25 19:54:30 +00:00
parent fbc7114fd6
commit a8fd00366d
2 changed files with 26 additions and 19 deletions

View file

@ -68,7 +68,7 @@ map_display::map_display(CVideo& video, const gamemap& map, const config& theme_
theme_(theme_cfg,screen_area()), zoom_(DefaultZoom),
builder_(cfg, level, map),
minimap_(NULL), redrawMinimap_(false), redraw_background_(true),
invalidateAll_(true),
invalidateAll_(true), grid_(false),
fps_handle_(0)
{
if(non_interactive()) {
@ -768,8 +768,10 @@ void map_display::draw_text_in_hex(const gamemap::location& loc, const std::stri
void display::draw_movement_info(const gamemap::location& loc)
{
//check if there is a path and if we are not at its start because
//we don't want to display movement info on the unit's hex (useless and unreadable)
//check if there is a path and if we are not at its start
//because we don't want to display movement info on the unit's
//hex (useless and unreadable)
if (route_.steps.empty() || route_.steps.front() == loc) return;
//search if there is a turn waypoint here
@ -822,7 +824,7 @@ display::display(unit_map& units, CVideo& video, const gamemap& map,
invalidateUnit_(true),
invalidateGameStatus_(true), panelsDrawn_(false),
currentTeam_(0), activeTeam_(0),
turbo_speed_(2), turbo_(false), grid_(false), sidebarScaling_(1.0),
turbo_speed_(2), turbo_(false), sidebarScaling_(1.0),
first_turn_(true), in_game_(false), map_labels_(*this,map, 0),
tod_hex_mask1(NULL), tod_hex_mask2(NULL), reach_map_changed_(true),
diagnostic_label_(0)
@ -1203,9 +1205,9 @@ void display::scroll_to_leader(unit_map& units, int side)
const unit_map::iterator leader = find_leader(units,side);
if(leader != units_.end()) {
/* YogiHH: I can't see why we need another key_handler here, therefore
i will comment it out
const hotkey::basic_handler key_events_handler(gui_);
/* YogiHH: I can't see why we need another key_handler
here, therefore i will comment it out const
hotkey::basic_handler key_events_handler(gui_);
*/
scroll_to_tile(leader->first, ONSCREEN);
}
@ -1423,10 +1425,12 @@ void display::draw(bool update,bool force)
// set the theortical next draw time
nextDraw_ += time_between_draws;
// if the next draw already should have been finished we'll enter an
// update frenzy, so make sure that the too late value doesn't keep
// growing. Note if force is used too often we can also get the
// opposite effect.
// if the next draw already should have been finished
// we'll enter an update frenzy, so make sure that the
// too late value doesn't keep growing. Note if force
// is used too often we can also get the opposite
// effect.
nextDraw_ = maximum<int>(nextDraw_, SDL_GetTicks());
}
}

View file

@ -37,7 +37,7 @@ class unit_map;
#include <set>
#include <string>
//display: class which takes care of displaying the map and
//map_display and display: classes which take care of displaying the map and
//game-data on the screen.
//
//the display is divided into two main sections: the game area,
@ -50,6 +50,7 @@ class unit_map;
// currently moused over (highlighted)
// - the unit status, which displays an image for, and stats for, the
// current unit.
class map_display
{
public:
@ -133,6 +134,10 @@ public:
int get_location_y(const gamemap::location& loc) const
{ return map_area().y + (loc.y + 1) * zoom_ - ypos_ + (is_odd(loc.x) ? zoom_/2 : 0); }
//function which determines whether a grid should be overlayed on the
//game board to more clearly show where hexes are.
void set_grid(const bool grid) { grid_ = grid; }
//returns the locations of 2 hexes that bind the visible area
//of the map.
void get_visible_hex_bounds(gamemap::location &topleft, gamemap::location &bottomright) const;
@ -188,6 +193,7 @@ protected:
bool redrawMinimap_;
bool redraw_background_;
bool invalidateAll_;
bool grid_;
// Not set by the initializer
std::vector<gui::button> buttons_;
std::set<gamemap::location> invalidated_;
@ -403,12 +409,9 @@ public:
//Delay routines: use these not SDL_Delay (for --nogui).
void delay(unsigned int milliseconds) const;
//function which determines whether a grid should be overlayed on the
//game board to more clearly show where hexes are.
void set_grid(const bool grid) { grid_ = grid; }
//a debug highlight draws a cross on a tile to emphasize something there.
//it is used in debug mode, typically to show AI plans.
//a debug highlight draws a cross on a tile to emphasize
//something there. it is used in debug mode, typically to
//show AI plans.
static void debug_highlight(const gamemap::location& loc, fixed_t amount);
static void clear_debug_highlights() { debugHighlights_.clear(); }
@ -562,7 +565,7 @@ private:
size_t currentTeam_, activeTeam_;
double turbo_speed_;
bool turbo_, grid_;
bool turbo_;
double sidebarScaling_;
bool first_turn_, in_game_;