maps smaller than the screen are now shown centered on the screen

for test also changed the minimum map size is to 1 in the editor
this feature might be handy for special maps so leave it in.

I'm not too happy with the name of display::map_outside_area()
This commit is contained in:
Mark de Wever 2007-05-28 12:19:24 +00:00
parent 9c02d7d6bd
commit 286cbd4a04
6 changed files with 53 additions and 8 deletions

View File

@ -1,4 +1,6 @@
Version 1.3.3+svn:
* map editor
* the minimum map size is reduced to 1
* graphics
* added sickle and scythe attack icons
* added weapon-shop tent and oak tree
@ -11,6 +13,9 @@ Version 1.3.3+svn:
* removed deprecated keys image_healing and image_halo_healing
* user interface:
* fixed a lag in the path rendering when there is a lot of units
* maps smaller than the screen are now shown centered on the screen
* Miscellaneous and bugfixes
* various bugfixes and code cleanups
Version 1.3.3:
* campaigns:

View File

@ -12,7 +12,11 @@ Version 1.3.3+svn:
* Language and translations
* Updated translations: Italian, Polish, Swedish.
* Map editor
* Minimum map size reduced to 1 hex.
* User interface
* Maps smaller than the screen are now shown centered on the screen.
* Unit changes and balancing

View File

@ -200,6 +200,32 @@ void display::adjust_colours(int r, int g, int b)
image::set_colour_adjustment(tod.red+r,tod.green+g,tod.blue+b);
}
const SDL_Rect& display::map_area() const
{
static SDL_Rect res = {0, 0, 0, 0};
res = map_outside_area();
// hex_size() is always a multiple of 4 and hex_width() a multiple of
// 3 so there shouldn't be off by one errors due to rounding
// To display a hex fully on screen a little bit extra space is needed
const int width = lexical_cast<int>((map_.x() + (1.0/3.0)) * hex_width());
const int height = lexical_cast<int>((map_.y() + 0.5) * hex_size());
if(width < res.w) {
// map is smaller, center
res.x += (res.w - width)/2;
res.w = width;
}
if(height < res.h) {
// map is smaller, center
res.y += (res.h - height)/2;
res.h = height;
}
return res;
}
bool display::outside_area(const SDL_Rect& area, const int x, const int y) const
{
const int x_thresh = hex_width();

View File

@ -86,9 +86,6 @@ public:
// Returns the current zoom factor.
double get_zoom_factor() { return double(zoom_)/double(image::tile_size); }
//function to make a screenshot and save it in a default location
void screenshot();
//function which returns the size of a hex in pixels
//(from top tip to bottom tip or left edge to right edge)
int hex_size() const { return zoom_; }
@ -97,6 +94,9 @@ public:
//(i.e. not entirely from tip to tip -- use hex_size() to get the distance from tip to tip)
int hex_width() const { return (zoom_*3)/4; }
//function to make a screenshot and save it in a default location
void screenshot();
enum SCROLL_TYPE { SCROLL, WARP, ONSCREEN };
//function which will scroll such that location loc is on-screen.
@ -128,7 +128,17 @@ public:
int w() const { return screen_.getx(); }
int h() const { return screen_.gety(); }
const SDL_Rect& map_area() const
/**
* Returns the area used for the map
*/
const SDL_Rect& map_area() const;
/**
* Returns the available area for a map, this may differ
* from the above. This area will get the background area
* applied to it.
*/
const SDL_Rect& map_outside_area() const
{ return theme_.main_map_location(screen_area()); }
const SDL_Rect& minimap_area() const
{ return theme_.mini_map_location(screen_area()); }

View File

@ -35,8 +35,8 @@
namespace {
const int map_min_height = 20;
const int map_min_width = 20;
const int map_min_height = 1;
const int map_min_width = 1;
const int map_max_height = 200;
const int map_max_width = 200;
}

View File

@ -35,9 +35,9 @@ size_specs::size_specs() {
}
void adjust_sizes(const display &disp, size_specs &sizes) {
sizes.brush_x = disp.map_area().w + 23;
sizes.brush_x = disp.map_outside_area().w + 23;
sizes.brush_y = 190;
sizes.palette_x = disp.map_area().w + 13;
sizes.palette_x = disp.map_outside_area().w + 13;
sizes.palette_y = sizes.brush_y + 160 + 10;
sizes.palette_w = sizes.terrain_space * default_palette_width;
sizes.palette_h = disp.h() - sizes.palette_y - 60;