Improved the portrait width in the wml_message.

The width of a portrait is 1/3 of the text width until it reaches the
maximum portrait width. This change also looks whether the maximum
text width has been reached, once reached the portrait no longer takes
1/3 but all width available.

This change means that portraits reach their maximum size at a smaller
resolution. The issue was brought to my attention by zookeeper.
This commit is contained in:
Mark de Wever 2010-11-29 21:18:50 +00:00
parent 1953ce1a25
commit 82ab772179
2 changed files with 33 additions and 21 deletions

View file

@ -19,6 +19,8 @@ Version 1.9.2+svn:
* Added a new hotkey sequence (by default unassigned) to toggle animated map
mode (feature #15976).
* Removed bottom border from character [message] dialogs.
* Improved the width of portraits in the wml_message once the maximum text
width is reached.
* WML engine:
* Created tag [petrify] (bug #17077). Moved [unpetrify] to lua. Syntax
changed from [unpetrify][filter]<SUF> to [unpetrify]<SUF>.

View file

@ -15,31 +15,41 @@
#define __GUI_SIZE_FACTOR
3#enddef
# This is the function I want to use for the image width, but the formula system
# has no way to create variables (outside the AI scope). So instead of this
# macro there's a more verbose version which doesn't use variable.
#define __GUI_IMAGE_WIDTH
([
max_height = screen_height - {_GUI_HEIGHT_OFFSET},
best_width = gamemap_width / {__GUI_SIZE_FACTOR},
best_width = if(best_width > max_height, max_height, best_width),
if(best_width < 250, 250,
if(best_width > 500, 500, best_width))
][4])#enddef
#undef __GUI_IMAGE_WIDTH
### The formula language doesn't support variables so macros are used to
### emulate them. This makes the code what harder to read, so the algorithm for
### __GUI_IMAGE_WIDTH is described here:
###
### The verbose version
### if gamemap_width <= TEXT_WIDTH_SATURATION
### __GUI_IMAGE_WIDTH = gamemap_width / 3
### else
### # Text reached it maximum width, take all space.
### __GUI_IMAGE_WIDTH = gamemap_width - MAX_TEXT_WIDTH
### fi
###
### if __GUI_IMAGE_WIDTH < 250
### __GUI_IMAGE_WIDTH = 250
### fi
###
### if __GUI_IMAGE_WIDTH > 500
### __GUI_IMAGE_WIDTH = 500
### fi
#define __GUI_MAX_HEIGHT
(screen_height - {_GUI_HEIGHT_OFFSET})
#enddef
# The maximum width of the text
#define MAX_TEXT_WIDTH
675
#enddef
# gamemap_width width needed to reach the MAX_TEXT_WIDTH
#define TEXT_WIDTH_SATURATION
((3 * {_GUI_HEIGHT_OFFSET}) / 2)
#enddef
#define BEST_WIDTH
(gamemap_width / {__GUI_SIZE_FACTOR})
(if(gamemap_width > {TEXT_WIDTH_SATURATION}, gamemap_width - {MAX_TEXT_WIDTH}, (gamemap_width / {__GUI_SIZE_FACTOR})))
#enddef
#define __GUI_BEST_SIZE
@ -470,8 +480,8 @@
[spacer]
width = "(
if(gamemap_width - ({__GUI_IMAGE_WIDTH}) > 675
, gamemap_width - (({__GUI_IMAGE_WIDTH}) + 675)
if(gamemap_width - ({__GUI_IMAGE_WIDTH}) > {MAX_TEXT_WIDTH}
, gamemap_width - (({__GUI_IMAGE_WIDTH}) + {MAX_TEXT_WIDTH})
, 0
))"
height = 75
@ -691,8 +701,8 @@ if(gamemap_width - ({__GUI_IMAGE_WIDTH}) > 675
[spacer]
width = "(
if(gamemap_width - (10 + ({__GUI_IMAGE_WIDTH})) > 675
, gamemap_width - (10 + ({__GUI_IMAGE_WIDTH}) + 675)
if(gamemap_width - (10 + ({__GUI_IMAGE_WIDTH})) > {MAX_TEXT_WIDTH}
, gamemap_width - (10 + ({__GUI_IMAGE_WIDTH}) + {MAX_TEXT_WIDTH})
, 0
))"
height = 75