Added Proof-of-concept of the new background still has some flaws
* upon scrolling the background static (so maps scrolls over wood) * _off^usr has redraw glitches since background is only updated every now and then * the alpha at the border tends to "build up" * we impose a huge performance hit The code still needs a lot of work, but what needs to be done heavily depends on whether or not the half-hexes are reintroduced so that the is postponed until that descission has been made.
This commit is contained in:
parent
959d7e86a2
commit
6c31017094
5 changed files with 55 additions and 2 deletions
|
@ -33,6 +33,8 @@ Version 1.3.3+svn:
|
|||
* reduced "sea sickness" effect when scrolling at accelerated speed
|
||||
* allow to select item in menu with right-click
|
||||
* right-click outside of a cancelable dialog to close it
|
||||
* added experimental new background read comment before draw_background()
|
||||
in display.cpp
|
||||
* Miscellaneous and bugfixes
|
||||
* fix bug #4299: word wrap for menus with very long option strings
|
||||
* various bugfixes and code cleanups
|
||||
|
|
|
@ -854,4 +854,6 @@
|
|||
{TERRAIN_ADJACENT -560 Chw (!,Chw,Chr) water/coast}
|
||||
{TERRAIN_ADJACENT -570 (!,Chr,Chw) Chr flat/grass}
|
||||
|
||||
{TERRAIN_BASE _off^* off-map/alpha}
|
||||
|
||||
{TERRAIN_BASE_DEFAULT void}
|
||||
|
|
|
@ -25,6 +25,9 @@ Version 1.3.3+svn:
|
|||
an image of a new scenario immediately before entering it, is now only
|
||||
presented if the game was built with TINY_GUI. Non-tiny systems do this
|
||||
automatically without asking.
|
||||
* Added a new experimental background, this is under evaluation but causes
|
||||
a rather severe performance penalty especially while scrolling. This will
|
||||
be fixed once the decission of the final version has been made.
|
||||
|
||||
* Unit changes and balancing
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ display::display(unit_map& units, CVideo& video, const gamemap& map,
|
|||
screen_(video), xpos_(0), ypos_(0),
|
||||
zoom_(DefaultZoom), map_(map), units_(units),
|
||||
temp_unit_(NULL),
|
||||
minimap_(NULL), redrawMinimap_(false),
|
||||
minimap_(NULL), redrawMinimap_(false), redraw_background_(true),
|
||||
status_(status),
|
||||
teams_(t), nextDraw_(0),
|
||||
invalidateAll_(true), invalidateUnit_(true),
|
||||
|
@ -502,6 +502,7 @@ void display::scroll(int xmove, int ymove)
|
|||
_scroll_event.notify_observers();
|
||||
update_rect(map_area());
|
||||
|
||||
redraw_background_ = true;
|
||||
redrawMinimap_ = true;
|
||||
}
|
||||
|
||||
|
@ -536,6 +537,7 @@ void display::set_zoom(int amount)
|
|||
energy_bar_rects_.clear();
|
||||
image::set_zoom(zoom_);
|
||||
map_labels_.recalculate_labels();
|
||||
redraw_background_ = true;
|
||||
invalidate_all();
|
||||
|
||||
// Forces a redraw after zooming. This prevents some graphic glitches from occurring.
|
||||
|
@ -786,6 +788,8 @@ void display::redraw_everything()
|
|||
|
||||
map_labels_.recalculate_labels();
|
||||
|
||||
redraw_background_ = true;
|
||||
|
||||
invalidate_all();
|
||||
draw(true,true);
|
||||
}
|
||||
|
@ -902,6 +906,34 @@ static void draw_label(CVideo& video, surface target, const theme::label& label)
|
|||
update_rect(loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Proof-of-concept of the new background still has some flaws
|
||||
* * upon scrolling the background static (so maps scrolls over wood)
|
||||
* * _off^usr has redraw glitches since background is only updated every now and then
|
||||
* * the alpha at the border tends to "build up"
|
||||
* * we impose a huge performance hit
|
||||
*
|
||||
* needs quite some work to become fully working, but first evaluate whether
|
||||
* the new way is really wanted.
|
||||
*/
|
||||
static void draw_background(surface screen, const SDL_Rect& area)
|
||||
{
|
||||
static const surface wood(image::get_image("terrain/off-map/wood.png",image::UNSCALED));
|
||||
static const unsigned int width = wood->w;
|
||||
static const unsigned int height = wood->h;
|
||||
wassert(!wood.null());
|
||||
|
||||
const unsigned int w_count = static_cast<int>(ceil(static_cast<double>(area.w) / static_cast<double>(width)));
|
||||
const unsigned int h_count = static_cast<int>(ceil(static_cast<double>(area.h) / static_cast<double>(height)));
|
||||
|
||||
for(unsigned int w = 0, w_off = area.x; w < w_count; ++w, w_off += width) {
|
||||
for(unsigned int h = 0, h_off = area.y; h < h_count; ++h, h_off += height) {
|
||||
SDL_Rect clip = {w_off, h_off, 0, 0};
|
||||
SDL_BlitSurface(wood, NULL, screen, &clip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void display::draw(bool update,bool force)
|
||||
{
|
||||
bool changed = false;
|
||||
|
@ -935,6 +967,19 @@ void display::draw(bool update,bool force)
|
|||
changed = true;
|
||||
}
|
||||
|
||||
if(redraw_background_) {
|
||||
// full redraw of the background
|
||||
const SDL_Rect clip_rect = map_outside_area();
|
||||
const surface outside_surf(screen_.getSurface());
|
||||
clip_rect_setter set_clip_rect(outside_surf, clip_rect);
|
||||
draw_background(outside_surf, clip_rect);
|
||||
|
||||
redraw_background_ = false;
|
||||
|
||||
// force a full map redraw
|
||||
invalidateAll_ = true;
|
||||
}
|
||||
|
||||
if(invalidateAll_ && !map_.empty()) {
|
||||
INFO_DP << "draw() with invalidateAll\n";
|
||||
gamemap::location topleft;
|
||||
|
@ -1939,7 +1984,7 @@ std::vector<surface> display::get_terrain_images(const gamemap::location &loc,
|
|||
} else if(terrain_type == ADJACENT_BACKGROUND){
|
||||
// this should only happen with the off map tiles and now
|
||||
// return the void image. NOTE this is a temp hack
|
||||
const surface surface(image::get_image(game_config::void_image));
|
||||
const surface surface(image::get_image("terrain/off-map/alpha.png"));
|
||||
wassert(!surface.null());
|
||||
if (!surface.null()) {
|
||||
res.push_back(surface);
|
||||
|
|
|
@ -478,6 +478,7 @@ private:
|
|||
|
||||
surface minimap_;
|
||||
bool redrawMinimap_;
|
||||
bool redraw_background_;
|
||||
|
||||
paths::route route_;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue