From 887bd5f7d60da0e4373de877127d663ba565b3cc Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Wed, 29 Sep 2010 20:21:54 +0000 Subject: [PATCH] Refresh the image from the locator upon redraw. This fixes the title screen logo and map not to change after changing the language. (Fixes bug #16631.) --- changelog | 2 ++ src/gui/auxiliary/canvas.cpp | 56 +++++++++++++----------------------- 2 files changed, 22 insertions(+), 36 deletions(-) diff --git a/changelog b/changelog index 2a257024564..ad75e5ae8c0 100644 --- a/changelog +++ b/changelog @@ -37,6 +37,8 @@ Version 1.9.1+svn: * Fixed: Enter no longer shows the credits in the title screen. * Changed: The title screen now has a maximum width for the tips text. * Changed: Improved the layout of the title screen. + * Fixed: Changing the language updates map and logo in title screen + (bug #16631). * WML Engine: * id= in SUFs now accepts a comma-separated list * [capture_village] now accepts a full SLF diff --git a/src/gui/auxiliary/canvas.cpp b/src/gui/auxiliary/canvas.cpp index 95eb3641dfb..f7e7e7ccd2d 100644 --- a/src/gui/auxiliary/canvas.cpp +++ b/src/gui/auxiliary/canvas.cpp @@ -785,20 +785,6 @@ timage::timage(const config& cfg) * Also the general variables are available, see [[#general_variables|Line]]. */ - if(!image_name_.has_formula()) { - surface tmp(image::get_image(image::locator(cfg["name"]))); - - if(!tmp) { - ERR_GUI_D << "Image: '" << cfg["name"] - << "' not found and won't be drawn.\n"; - return; - } - - image_.assign(make_neutral_surface(tmp)); - assert(image_); - src_clip_ = ::create_rect(0, 0, image_->w, image_->h); - } - const std::string& debug = (cfg["debug"]); if(!debug.empty()) { DBG_GUI_P << "Image: found debug message '" << debug << "'.\n"; @@ -815,32 +801,30 @@ void timage::draw(surface& canvas * silly unless there has been a resize. So to optimize we should use an * extra flag or do the calculation in a separate routine. */ - if(image_name_.has_formula()) { - const std::string& name = image_name_(variables); + const std::string& name = image_name_(variables); - if(name.empty()) { - DBG_GUI_D - << "Image: formula returned no value, will not be drawn.\n"; - return; - } - - surface tmp(image::get_image(image::locator(name))); - - if(!tmp) { - ERR_GUI_D << "Image: formula returned name '" - << name << "'not found and won't be drawn.\n"; - return; - } - - image_.assign(make_neutral_surface(tmp)); - assert(image_); - src_clip_ = ::create_rect(0, 0, image_->w, image_->h); - } else if(!image_){ - // The warning about no image should already have taken place - // so leave silently. + if(name.empty()) { + DBG_GUI_D + << "Image: formula returned no value, will not be drawn.\n"; return; } + /* + * The locator might return a different surface for every call so we can't + * cache the output, also not if no formula is used. + */ + surface tmp(image::get_image(image::locator(name))); + + if(!tmp) { + ERR_GUI_D << "Image: '" << name + << "' not found and won't be drawn.\n"; + return; + } + + image_.assign(make_neutral_surface(tmp)); + assert(image_); + src_clip_ = ::create_rect(0, 0, image_->w, image_->h); + game_logic::map_formula_callable local_variables(variables); local_variables.add("image_original_width", variant(image_->w)); local_variables.add("image_original_height", variant(image_->h));