Move screen up to the map_display class.

This commit is contained in:
Eric S. Raymond 2007-06-22 11:36:30 +00:00
parent 3144c21d4c
commit 63e81a6a31
2 changed files with 24 additions and 26 deletions

View file

@ -63,8 +63,13 @@ namespace {
size_t sunset_timer = 0;
}
map_display::map_display(const gamemap& map, const config& theme_cfg) : map_(map), theme_(theme_cfg,screen_area()), zoom_(DefaultZoom)
map_display::map_display(CVideo& video, const gamemap& map, const config& theme_cfg) : screen_(video), map_(map), theme_(theme_cfg,screen_area()), zoom_(DefaultZoom)
{
if(non_interactive()) {
screen_.lock_updates(true);
}
image::set_zoom(zoom_);
}
map_display::~map_display()
@ -114,9 +119,9 @@ std::map<gamemap::location,fixed_t> display::debugHighlights_;
display::display(unit_map& units, CVideo& video, const gamemap& map,
const gamestatus& status, const std::vector<team>& t,
const config& theme_cfg, const config& cfg, const config& level) :
map_display(map, theme_cfg),
map_display(video, map, theme_cfg),
_scroll_event("scrolled"),
screen_(video), xpos_(0), ypos_(0),
xpos_(0), ypos_(0),
units_(units),
temp_unit_(NULL),
minimap_(NULL), redrawMinimap_(false), redraw_background_(true),
@ -132,14 +137,8 @@ display::display(unit_map& units, CVideo& video, const gamemap& map,
diagnostic_label_(0), fps_handle_(0)
{
singleton_ = this;
if(non_interactive()) {
screen_.lock_updates(true);
}
std::fill(reportRects_,reportRects_+reports::NUM_REPORTS,empty_rect);
image::set_zoom(zoom_);
//inits the flag list
flags_.reserve(teams_.size());
for(size_t i = 0; i != teams_.size(); ++i) {

View file

@ -53,12 +53,26 @@ class unit_map;
class map_display
{
public:
map_display(const gamemap& map, const config& theme_cfg);
map_display(CVideo& video, const gamemap& map, const config& theme_cfg);
~map_display();
static Uint32 rgb(Uint8 red, Uint8 green, Uint8 blue)
{ return 0xFF000000 | (red << 16) | (green << 8) | blue; }
//the dimensions of the display. x and y are
//width/height. mapx is the width of the portion of the
//display which shows the game area. Between mapx and x is the
//sidebar region.
int w() const { return screen_.getx(); }
int h() const { return screen_.gety(); }
const SDL_Rect& minimap_area() const
{ return theme_.mini_map_location(screen_area()); }
const SDL_Rect& unit_image_area() const
{ return theme_.unit_image_location(screen_area()); }
SDL_Rect screen_area() const
{ const SDL_Rect res = {0,0,w(),h()}; return res; }
/**
* Returns the area used for the map
*/
@ -82,6 +96,7 @@ public:
int hex_size() const { return zoom_; }
protected:
CVideo& screen_;
const gamemap& map_;
theme theme_;
int zoom_;
@ -153,21 +168,6 @@ public:
//even if running behind.
void draw(bool update=true,bool force=false);
//the dimensions of the display. x and y are width/height. mapx is the
//width of the portion of the display which shows the game area. Between
//mapx and x is the sidebar region.
int w() const { return screen_.getx(); }
int h() const { return screen_.gety(); }
const SDL_Rect& minimap_area() const
{ return theme_.mini_map_location(screen_area()); }
const SDL_Rect& unit_image_area() const
{ return theme_.unit_image_location(screen_area()); }
SDL_Rect screen_area() const
{ const SDL_Rect res = {0,0,w(),h()}; return res; }
//check if pixel x,y is outside specified area
bool outside_area(const SDL_Rect& area, const int x, const int y) const;
@ -474,7 +474,6 @@ private:
//this surface must be freed by the caller
surface get_minimap(int w, int h);
CVideo& screen_;
CKey keys_;
int xpos_, ypos_;