mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-21 19:07:16 +00:00
Added a new image type which only depends on the scaling factor,
...and used this type for units and haloes. renamed some items to scaled_to_hex (forgot that in the previous image change) I consider this too intrusive to port to the 1.2 branch. It fixes: * units are scaled properly when zooming also with tiny gui (bug #8703 and bug #6570) * haloes in tiny gui are now scaled (before unscaled, thus a factor 2 bigger as intended) * removes the scaling handling in the halo, removing quite some code
This commit is contained in:
parent
d2c5800ec7
commit
6d67ae6e92
@ -17,6 +17,8 @@ Version 1.3.1+svn:
|
||||
--enable-tinygui (bug #8720 patch #697)
|
||||
* rewrote the halo render engine which solves a few minor glitches but
|
||||
most importantly speeds up the drawing of the halos.
|
||||
* units are scaled properly when zooming also with tiny gui (bug #8703 and bug #6570)
|
||||
* haloes in tiny gui are now scaled (before unscaled, thus a factor 2 bigger as intended)
|
||||
* language and i18n:
|
||||
* updated translations: Bulgarian, Czech, Danish, Dutch, French, German,
|
||||
Hungarian, Italian, Norwegian, Portuguese (Brazil)
|
||||
@ -55,11 +57,12 @@ Version 1.3.1+svn:
|
||||
* user interface:
|
||||
* new sounds for user interface events
|
||||
* added the option to show warnings about deprecated WML usage
|
||||
* misceleanous bug fixes
|
||||
* misceleanous changes and bug fixes
|
||||
* an friendly healer hill now stop poisoned unit to lose HP
|
||||
* a unit that dies while attacking will now correctly play it's own death
|
||||
* turn bell can sound if other soundFX are turned off
|
||||
* the first turn starts again with the proper time of day (bug 8637)
|
||||
* removes the scaling handling in the halo, removing quite some code
|
||||
|
||||
Version 1.3.1:
|
||||
* Campaignd
|
||||
|
@ -14,6 +14,8 @@ Version 1.3.1+svn:
|
||||
screen.
|
||||
* Added new experimental new unit location in the hex.
|
||||
* Added some more speed optimizations.
|
||||
* Units are scaled properly when zooming, also with tiny gui.
|
||||
* Haloes in tiny gui are now scaled (before unscaled, thus a factor 2 bigger as intended).
|
||||
* Units changes and balancing:
|
||||
* Converted the cold resistance of the Elvish Sorceress line to a holy
|
||||
resistance.
|
||||
|
54
src/halo.cpp
54
src/halo.cpp
@ -52,16 +52,12 @@ public:
|
||||
private:
|
||||
|
||||
const std::string& current_image() { return images_.get_current_frame(); }
|
||||
void rezoom();
|
||||
|
||||
animated<std::string> images_;
|
||||
|
||||
std::string current_image_;
|
||||
|
||||
ORIENTATION orientation_;
|
||||
|
||||
int origx_, origy_, x_, y_;
|
||||
double origzoom_, zoom_;
|
||||
int x_, y_;
|
||||
surface surf_, buffer_;
|
||||
SDL_Rect rect_;
|
||||
|
||||
@ -96,8 +92,7 @@ std::set<int> changing_haloes;
|
||||
|
||||
effect::effect(int xpos, int ypos, const animated<std::string>::anim_description& img,
|
||||
const gamemap::location& loc, ORIENTATION orientation, bool infinite) :
|
||||
images_(img), orientation_(orientation), origx_(xpos), origy_(ypos),
|
||||
x_(xpos), y_(ypos), origzoom_(disp->zoom()), zoom_(disp->zoom()),
|
||||
images_(img), orientation_(orientation), x_(xpos), y_(ypos),
|
||||
surf_(NULL), buffer_(NULL), rect_(empty_rect), loc_(loc)
|
||||
{
|
||||
wassert(disp != NULL);
|
||||
@ -109,40 +104,13 @@ effect::effect(int xpos, int ypos, const animated<std::string>::anim_description
|
||||
if(!images_.animation_finished()) {
|
||||
images_.update_last_draw_time();
|
||||
}
|
||||
|
||||
current_image_ = "";
|
||||
rezoom();
|
||||
}
|
||||
|
||||
void effect::set_location(int x, int y)
|
||||
{
|
||||
const gamemap::location zero_loc(0,0);
|
||||
x_ = origx_ = x - disp->get_location_x(zero_loc);
|
||||
y_ = origy_ = y - disp->get_location_y(zero_loc);
|
||||
origzoom_ = disp->zoom();
|
||||
|
||||
if(zoom_ != origzoom_) {
|
||||
rezoom();
|
||||
}
|
||||
}
|
||||
|
||||
void effect::rezoom()
|
||||
{
|
||||
zoom_ = disp->zoom();
|
||||
x_ = int((origx_*zoom_)/origzoom_);
|
||||
y_ = int((origy_*zoom_)/origzoom_);
|
||||
|
||||
surf_.assign(image::get_image(current_image_,image::UNSCALED));
|
||||
if(surf_ != NULL && (orientation_ == HREVERSE || orientation_ == HVREVERSE)) {
|
||||
surf_.assign(image::reverse_image(surf_));
|
||||
}
|
||||
if(surf_ != NULL && (orientation_ == VREVERSE || orientation_ == HVREVERSE)) {
|
||||
surf_.assign(flop_surface(surf_));
|
||||
}
|
||||
|
||||
if(surf_ != NULL && zoom_ != 1.0) {
|
||||
surf_.assign(scale_surface(surf_,int(surf_->w*zoom_),int(surf_->h*zoom_)));
|
||||
}
|
||||
x_ = x - disp->get_location_x(zero_loc);
|
||||
y_ = y - disp->get_location_y(zero_loc);
|
||||
}
|
||||
|
||||
bool effect::render()
|
||||
@ -156,15 +124,16 @@ bool effect::render()
|
||||
}
|
||||
|
||||
images_.update_last_draw_time();
|
||||
const std::string& img = current_image();
|
||||
if(surf_ == NULL || zoom_ != disp->zoom() || current_image_ != img) {
|
||||
current_image_ = img;
|
||||
rezoom();
|
||||
}
|
||||
|
||||
surf_.assign(image::get_image(current_image(),image::SCALED_TO_ZOOM));
|
||||
if(surf_ == NULL) {
|
||||
return false;
|
||||
}
|
||||
if(orientation_ == HREVERSE || orientation_ == HVREVERSE) {
|
||||
surf_.assign(image::reverse_image(surf_));
|
||||
}
|
||||
if(orientation_ == VREVERSE || orientation_ == HVREVERSE) {
|
||||
surf_.assign(flop_surface(surf_));
|
||||
}
|
||||
|
||||
const gamemap::location zero_loc(0,0);
|
||||
const int screenx = disp->get_location_x(zero_loc);
|
||||
@ -388,7 +357,6 @@ void unrender(std::set<gamemap::location> invalidated_locations)
|
||||
|
||||
void render()
|
||||
{
|
||||
|
||||
if(preferences::show_haloes() == false || haloes.size() == 0 ||
|
||||
(new_haloes.size() == 0 && invalidated_haloes.size() == 0)) {
|
||||
return;
|
||||
|
@ -40,7 +40,7 @@ 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_;
|
||||
image::image_cache images_,scaled_to_hex_images_,scaled_to_zoom_,unmasked_images_;
|
||||
image::image_cache brightened_images_,semi_brightened_images_;
|
||||
|
||||
image::locator_cache alternative_images_;
|
||||
@ -82,7 +82,8 @@ mini_terrain_cache_map mini_terrain_cache;
|
||||
void flush_cache()
|
||||
{
|
||||
reset_cache(images_);
|
||||
reset_cache(scaled_images_);
|
||||
reset_cache(scaled_to_hex_images_);
|
||||
reset_cache(scaled_to_zoom_);
|
||||
reset_cache(unmasked_images_);
|
||||
reset_cache(brightened_images_);
|
||||
reset_cache(semi_brightened_images_);
|
||||
@ -102,7 +103,8 @@ void locator::init_index()
|
||||
locator_finder.insert(locator_finder_pair(val_, index_));
|
||||
|
||||
images_.push_back(cache_item<surface>());
|
||||
scaled_images_.push_back(cache_item<surface>());
|
||||
scaled_to_hex_images_.push_back(cache_item<surface>());
|
||||
scaled_to_zoom_.push_back(cache_item<surface>());
|
||||
unmasked_images_.push_back(cache_item<surface>());
|
||||
brightened_images_.push_back(cache_item<surface>());
|
||||
semi_brightened_images_.push_back(cache_item<surface>());
|
||||
@ -451,7 +453,8 @@ void set_colour_adjustment(int r, int g, int b)
|
||||
red_adjust = r;
|
||||
green_adjust = g;
|
||||
blue_adjust = b;
|
||||
reset_cache(scaled_images_);
|
||||
reset_cache(scaled_to_hex_images_);
|
||||
reset_cache(scaled_to_zoom_);
|
||||
reset_cache(brightened_images_);
|
||||
reset_cache(semi_brightened_images_);
|
||||
reset_cache(alternative_images_);
|
||||
@ -463,7 +466,8 @@ void set_image_mask(const std::string& image)
|
||||
{
|
||||
if(image_mask != image) {
|
||||
image_mask = image;
|
||||
reset_cache(scaled_images_);
|
||||
reset_cache(scaled_to_hex_images_);
|
||||
reset_cache(scaled_to_zoom_);
|
||||
reset_cache(brightened_images_);
|
||||
reset_cache(semi_brightened_images_);
|
||||
reset_cache(alternative_images_);
|
||||
@ -476,7 +480,8 @@ void set_zoom(int amount)
|
||||
{
|
||||
if(amount != zoom) {
|
||||
zoom = amount;
|
||||
reset_cache(scaled_images_);
|
||||
reset_cache(scaled_to_hex_images_);
|
||||
reset_cache(scaled_to_zoom_);
|
||||
reset_cache(brightened_images_);
|
||||
reset_cache(semi_brightened_images_);
|
||||
reset_cache(unmasked_images_);
|
||||
@ -503,7 +508,7 @@ surface get_unmasked(const locator i_locator)
|
||||
return res;
|
||||
}
|
||||
|
||||
surface get_scaled(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
||||
surface get_scaled_to_hex(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
||||
{
|
||||
surface res(get_image(i_locator, UNMASKED, adj));
|
||||
|
||||
@ -525,6 +530,19 @@ surface get_scaled(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
||||
return res;
|
||||
}
|
||||
|
||||
surface get_scaled_to_zoom(const locator i_locator)
|
||||
{
|
||||
wassert(zoom != tile_size);
|
||||
wassert(tile_size != 0);
|
||||
|
||||
surface res(get_image(i_locator, UNSCALED));
|
||||
// for some reason haloes seems to have invalid images, protect against crashing
|
||||
if(!res.null()) {
|
||||
return scale_surface(res, ((res.get()->w * zoom) / tile_size), ((res.get()->h * zoom) / tile_size));
|
||||
} else {
|
||||
return surface(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
surface get_brightened(const locator i_locator, COLOUR_ADJUSTMENT adj)
|
||||
{
|
||||
@ -546,12 +564,24 @@ surface get_image(const image::locator& i_locator, TYPE type, COLOUR_ADJUSTMENT
|
||||
if(i_locator.is_void())
|
||||
return surface(NULL);
|
||||
|
||||
bool is_unscaled = false;
|
||||
|
||||
switch(type) {
|
||||
case UNSCALED:
|
||||
is_unscaled = true;
|
||||
imap = &images_;
|
||||
break;
|
||||
case SCALED_TO_HEX:
|
||||
imap = &scaled_images_;
|
||||
imap = &scaled_to_hex_images_;
|
||||
break;
|
||||
case SCALED_TO_ZOOM:
|
||||
// only use separate cache if scaled
|
||||
if(zoom != tile_size) {
|
||||
imap = &scaled_to_zoom_;
|
||||
} else {
|
||||
is_unscaled = true;
|
||||
imap = &images_;
|
||||
}
|
||||
break;
|
||||
case UNMASKED:
|
||||
imap = &unmasked_images_;
|
||||
@ -571,7 +601,7 @@ surface get_image(const image::locator& i_locator, TYPE type, COLOUR_ADJUSTMENT
|
||||
|
||||
// If type is unscaled, directly load the image from the disk. Else,
|
||||
// create it from the unscaled image
|
||||
if(type == UNSCALED) {
|
||||
if(is_unscaled) {
|
||||
res = i_locator.load_from_disk();
|
||||
|
||||
if(res == NULL) {
|
||||
@ -584,7 +614,10 @@ surface get_image(const image::locator& i_locator, TYPE type, COLOUR_ADJUSTMENT
|
||||
|
||||
switch(type) {
|
||||
case SCALED_TO_HEX:
|
||||
res = get_scaled(i_locator, adj);
|
||||
res = get_scaled_to_hex(i_locator, adj);
|
||||
break;
|
||||
case SCALED_TO_ZOOM:
|
||||
res = get_scaled_to_zoom(i_locator);
|
||||
break;
|
||||
case UNMASKED:
|
||||
res = get_unmasked(i_locator);
|
||||
|
@ -27,6 +27,7 @@
|
||||
///images come in a number of varieties:
|
||||
/// - unscaled: no modifications have been done on the image.
|
||||
/// - scaled_to_hex: images are scaled to the size of a tile
|
||||
/// - scaled_to_zoom: images are scaled to the zoom factor, factor 1 is same as unscaled no other modifications are done
|
||||
/// - unmasked: images are scaled, but have no time of day masking applied to them
|
||||
/// - brightened: images are scaled and brighter than normal.
|
||||
namespace image {
|
||||
@ -176,7 +177,7 @@ namespace image {
|
||||
|
||||
// unscaled : image will be drawn "as is" without changing size, even in case of redraw
|
||||
// scaled_to_hex : image will be scaled to fit into a hex, taking zoom into account
|
||||
enum TYPE { UNSCALED, SCALED_TO_HEX, UNMASKED, BRIGHTENED, SEMI_BRIGHTENED };
|
||||
enum TYPE { UNSCALED, SCALED_TO_HEX, SCALED_TO_ZOOM, UNMASKED, BRIGHTENED, SEMI_BRIGHTENED };
|
||||
|
||||
enum COLOUR_ADJUSTMENT { ADJUST_COLOUR, NO_ADJUST_COLOUR };
|
||||
|
||||
|
@ -1490,7 +1490,7 @@ const surface unit::still_image() const
|
||||
}
|
||||
#endif
|
||||
|
||||
surface unit_image(image::get_image(loc,image::UNSCALED));
|
||||
surface unit_image(image::get_image(loc,image::SCALED_TO_ZOOM));
|
||||
return unit_image;
|
||||
}
|
||||
|
||||
@ -1807,7 +1807,7 @@ void unit::redraw_unit(display& disp,gamemap::location hex)
|
||||
#endif
|
||||
|
||||
surface image(image::get_image(loc,
|
||||
image::UNSCALED,image::ADJUST_COLOUR,
|
||||
image::SCALED_TO_ZOOM,image::ADJUST_COLOUR,
|
||||
#ifndef LOW_MEM
|
||||
true
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user