remove the darkened image cache, overlay images/terrain/darken.png instead.

this should reduce mem consumption a lot... but there is still work to
do. Artists should feel free to imprve the new image
This commit is contained in:
Jérémy Rosen 2006-11-24 20:07:01 +00:00
parent 8ece9584ce
commit 8fa217d398
6 changed files with 21 additions and 49 deletions

View file

@ -10,6 +10,8 @@ Version 1.3-svn:
secured (fixes #7360)
* graphics
* fixed terrain selection probabilites (patch #617)
* stoned units do not use a separate cache
* no more "darkened" cache. we now overlay terrain/darken.png
* multiplayer maps:
* new multiplayer maps: The Manzivan Traps
* units:

BIN
images/terrain/darken.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 627 B

View file

@ -1386,15 +1386,6 @@ void display::draw_tile(const gamemap::location &loc, const SDL_Rect &clip_rect)
mask = tod_at.image_mask;
}
//find if this tile should be darkened or bightened (reach of a unit)
if (!reach_map_.empty()) {
reach = reach_map_.find(loc);
if (reach == reach_map_.end()) {
image_type = image::DARKENED;
} else {
image_type = image::UNMASKED;
}
}
unit_map::iterator un = find_visible_unit(units_, loc, map_,
teams_,teams_[currentTeam_]);
@ -1482,6 +1473,17 @@ void display::draw_tile(const gamemap::location &loc, const SDL_Rect &clip_rect)
SDL_BlitSurface(img,NULL,dst,&dstrect);
}
}
//find if this tile should be darkened or bightened (reach of a unit)
if (!reach_map_.empty()) {
reach = reach_map_.find(loc);
if (reach == reach_map_.end()) {
const surface img(image::get_image("terrain/darken.png",image::UNMASKED,image::NO_ADJUST_COLOUR));
if(img != NULL) {
SDL_Rect dstrect = { xpos, ypos, 0, 0 };
SDL_BlitSurface(img,NULL,dst,&dstrect);
}
}
}
if(grid_) {
surface grid_surface(image::get_image("terrain/grid.png"));

View file

@ -40,8 +40,8 @@ typedef std::pair<image::locator::value, int> locator_finder_pair;
locator_finder_t locator_finder;
// Definition of all image maps
image::image_cache images_,scaled_images_,unmasked_images_,greyed_images_;
image::image_cache brightened_images_,semi_brightened_images_,darkened_images_;
image::image_cache images_,scaled_images_,unmasked_images_;
image::image_cache brightened_images_,semi_brightened_images_;
image::locator_cache alternative_images_;
@ -88,8 +88,6 @@ void flush_cache()
reset_cache(images_);
reset_cache(scaled_images_);
reset_cache(unmasked_images_);
reset_cache(greyed_images_);
reset_cache(darkened_images_);
reset_cache(brightened_images_);
reset_cache(semi_brightened_images_);
reset_cache(alternative_images_);
@ -110,8 +108,6 @@ void locator::init_index()
images_.push_back(cache_item<surface>());
scaled_images_.push_back(cache_item<surface>());
unmasked_images_.push_back(cache_item<surface>());
greyed_images_.push_back(cache_item<surface>());
darkened_images_.push_back(cache_item<surface>());
brightened_images_.push_back(cache_item<surface>());
semi_brightened_images_.push_back(cache_item<surface>());
@ -488,8 +484,6 @@ void set_colour_adjustment(int r, int g, int b)
green_adjust = g;
blue_adjust = b;
reset_cache(scaled_images_);
reset_cache(greyed_images_);
reset_cache(darkened_images_);
reset_cache(brightened_images_);
reset_cache(semi_brightened_images_);
reset_cache(alternative_images_);
@ -519,8 +513,6 @@ void set_image_mask(const std::string& image)
if(image_mask != image) {
image_mask = image;
reset_cache(scaled_images_);
reset_cache(greyed_images_);
reset_cache(darkened_images_);
reset_cache(brightened_images_);
reset_cache(semi_brightened_images_);
reset_cache(alternative_images_);
@ -534,8 +526,6 @@ void set_zoom(int amount)
if(amount != zoom) {
zoom = amount;
reset_cache(scaled_images_);
reset_cache(greyed_images_);
reset_cache(darkened_images_);
reset_cache(brightened_images_);
reset_cache(semi_brightened_images_);
reset_cache(unmasked_images_);
@ -584,19 +574,6 @@ surface get_scaled(const locator i_locator, COLOUR_ADJUSTMENT adj)
return res;
}
surface get_greyed(const locator i_locator, COLOUR_ADJUSTMENT adj)
{
surface image(get_image(i_locator, SCALED, adj));
return surface(greyscale_image(image));
}
surface get_darkened(const locator i_locator, COLOUR_ADJUSTMENT adj)
{
surface image(get_image(i_locator, SCALED, adj));
return surface(darken_image(image));
}
surface get_brightened(const locator i_locator, COLOUR_ADJUSTMENT adj)
{
@ -628,12 +605,6 @@ surface get_image(const image::locator& i_locator, TYPE type, COLOUR_ADJUSTMENT
case UNMASKED:
imap = &unmasked_images_;
break;
case GREYED:
imap = &greyed_images_;
break;
case DARKENED:
imap = &darkened_images_;
break;
case BRIGHTENED:
imap = &brightened_images_;
break;
@ -667,12 +638,6 @@ surface get_image(const image::locator& i_locator, TYPE type, COLOUR_ADJUSTMENT
case UNMASKED:
res = get_unmasked(i_locator);
break;
case GREYED:
res = get_greyed(i_locator, adj);
break;
case DARKENED:
res = get_darkened(i_locator, adj);
break;
case BRIGHTENED:
res = get_brightened(i_locator, adj);
break;

View file

@ -28,7 +28,6 @@
/// - unscaled: no modifications have been done on the image.
/// - scaled: images are scaled to the size of a tile
/// - unmasked: images are scaled, but have no time of day masking applied to them
/// - greyed: images are scaled and in greyscale
/// - brightened: images are scaled and brighter than normal.
namespace image {
template<typename T>
@ -174,7 +173,7 @@ namespace image {
// unscaled : image will be drawn "as is" without changing size, even in case of redraw
// scaled : image will be scaled to fit into a hex, taking zoom into account
enum TYPE { UNSCALED, SCALED, UNMASKED, GREYED, DARKENED, BRIGHTENED, SEMI_BRIGHTENED };
enum TYPE { UNSCALED, SCALED, UNMASKED, BRIGHTENED, SEMI_BRIGHTENED };
enum COLOUR_ADJUSTMENT { ADJUST_COLOUR, NO_ADJUST_COLOUR };

View file

@ -32,6 +32,7 @@
#include "actions.hpp"
#include "game_events.hpp"
#include "sound.hpp"
#include "sdl_utils.hpp"
#include <ctime>
#include <algorithm>
@ -1949,7 +1950,7 @@ void unit::redraw_unit(display& disp,gamemap::location hex)
#endif
surface image(image::get_image(loc,
utils::string_bool(get_state("stoned"))?image::GREYED : image::UNSCALED,image::ADJUST_COLOUR,
image::UNSCALED,image::ADJUST_COLOUR,
#ifndef LOW_MEM
true));
#else
@ -1959,6 +1960,9 @@ void unit::redraw_unit(display& disp,gamemap::location hex)
if(image == NULL) {
image = still_image();
}
if(utils::string_bool(get_state("stoned"))) {
image = greyscale_image(image);
}
if(facing_ == gamemap::location::NORTH_WEST || facing_ == gamemap::location::SOUTH_WEST) {
image.assign(image::reverse_image(image));