Restore leader unit image in Load Game dialog (bug #18683)

(Candidate for 1.10 branch.)

This functionality is back with a slight change to 2010-11-29T19:46:11Z!shadowm@wesnoth.org in order to
left-align the map snapshot only when the leader image cannot be loaded.
We also no longer spam stderr with errors about missing leader images
(which can be caused by unloaded campaigns or eras).

Anonymissimus pointed out this functionality was still found in the GUI2
version of the dialog (--new-widgets). Whoever last changed the saved
games summary code probably only bothered to update this experimental
code without fixing the normal GUI1 dialog. As I pointed out in the
tracker, the layout code was still in place.

As a compromise for the time being, we always assume the "magenta"
palette for TC recoloring now. This doesn't seem to be a problem since
the old code already made an annoying assumption of side 1 using the 1
(red) color range instead of permiting the use of the side.color value,
or reflecting the currently playing side number at the time of the save
generation.

I may later extend the saved games summary to include additional
information to get rid of the magenta and side 1 limitations.
This commit is contained in:
Ignacio R. Morelle 2012-02-04 20:45:05 +00:00
parent a7a9a5cb8f
commit 394c77f3d4
3 changed files with 20 additions and 6 deletions

View file

@ -35,6 +35,8 @@ Version 1.11.0-svn:
advancement to Great Wolves and Direwolves
* New extra_define ENABLE_TROLL_SHAMAN to optionally enable Troll Whelps
advancement to Troll Shamans (not in multiplayer)
* User interface:
* Restored leader unit image in Load Game dialog (bug #18683)
* Whiteboard
* Fixed bug #19369 : Using planning mode can cause losing ability to move my units
* Fixed bug #19408 : Crash shortly after executing invalid multi-turn move

View file

@ -21,6 +21,9 @@ Version 1.11.0-svn:
* Deprecated flowers (Ggf) and Volcano (Qv) terrains removed.
Use Gg^Ef and Mv respectively.
* User interface:
* Restored leader unit image in Load Game dialog (bug #18683)
* Whiteboard
* Fixed bug #19369 : Using planning mode can cause losing ability to move my units
* Fixed bug #19408 : Crash shortly after executing invalid multi-turn move

View file

@ -381,16 +381,23 @@ void save_preview_pane::draw_contents()
int ypos = area.y;
const unit_type *leader = unit_types.find(summary["leader"]);
if (leader)
bool have_leader_image = false;
const std::string& leader_image = summary["leader_image"].str();
if(!leader_image.empty() && image::exists(leader_image))
{
#ifdef LOW_MEM
const surface image(image::get_image(leader->image()));
const surface& image(image::get_image(leader_image));
#else
const surface image(image::get_image(leader->image() + "~RC(" + leader->flag_rgb() + ">1)"));
// NOTE: assuming magenta for TC here. This is what's used in all of
// mainline, so the compromise should be good enough until we add more
// summary fields to help with this and deciding the side color range.
const surface& image(image::get_image(leader_image + "~RC(magenta>1)"));
#endif
if(image != NULL) {
have_leader_image = !image.null();
if(have_leader_image) {
SDL_Rect image_rect = create_rect(area.x, area.y, image->w, image->h);
ypos += image_rect.h + save_preview_border;
@ -437,7 +444,9 @@ void save_preview_pane::draw_contents()
}
if(map_surf != NULL) {
SDL_Rect map_rect = create_rect(area.x
// Align the map to the left when the leader image is missing.
const int map_x = have_leader_image ? area.x + area.w - map_surf->w : area.x;
SDL_Rect map_rect = create_rect(map_x
, area.y
, map_surf->w
, map_surf->h);