Add better protection for images not fitting.
Some UMC uses listbox rowes with less than 20 pixes which caused images to be resized to x - 20 which is negative and resulted into huge positive numbers. Modified the WML to return 0 in these cases and also added protection in the engine to ignore those images. (The latter is needed since people can create their own themes which might have this problem as well.) Fixes bug #14525 and probably bug #14002.
This commit is contained in:
parent
7913dfc335
commit
1459747252
12 changed files with 52 additions and 29 deletions
|
@ -22,6 +22,8 @@ Version 1.7.7+svn:
|
|||
* Add fallback scrollbars if a window doesn't fit (bug #13180)
|
||||
* Switch to the new MP lobby
|
||||
* Fix a NULL pointer deferring in the hover code
|
||||
* Protect against widgets being smaller as expected causing images with
|
||||
negative sizes (bug #14525)
|
||||
* WML engine:
|
||||
* Added two array element lookup macros, LOOKUP_INDEX and LOOKUP_VALUE.
|
||||
* Miscellaneous and bugfixes:
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
[image]
|
||||
x = {GROOVE_LEFT}
|
||||
y = 0
|
||||
w = "(width - {GROOVE_LEFT} - {GROOVE_RIGHT})"
|
||||
w = "(if(width - {GROOVE_LEFT} - {GROOVE_RIGHT} < 0
|
||||
, 0, width - {GROOVE_LEFT} - {GROOVE_RIGHT}))"
|
||||
h = 0
|
||||
stretch = true
|
||||
name = "buttons/scrollgroove{IMAGE_MIDDLE}-horizontal.png"
|
||||
|
@ -47,7 +48,9 @@
|
|||
[image]
|
||||
x = "(positioner_offset + {POSITIONER_LEFT})"
|
||||
y = 0
|
||||
w = "(positioner_length - {POSITIONER_LEFT} - {POSITIONER_RIGHT})"
|
||||
w = "(
|
||||
if(positioner_length - {POSITIONER_LEFT} - {POSITIONER_RIGHT} < 0
|
||||
, 0, positioner_length - {POSITIONER_LEFT} - {POSITIONER_RIGHT}))"
|
||||
stretch = true
|
||||
name = "buttons/scrollhorizontal{IMAGE_MIDDLE}{IMAGE_SUFFIX}"
|
||||
[/image]
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
[image]
|
||||
x = 5
|
||||
y = 0
|
||||
w = "(width - 14)"
|
||||
w = "(if(width < 14, 0, width - 14))"
|
||||
stretch = "true"
|
||||
name = "dialogs/translucent54-border-top.png"
|
||||
[/image]
|
||||
|
@ -51,7 +51,7 @@
|
|||
[image]
|
||||
x = "(width - 9)"
|
||||
y = 5
|
||||
h = "(height - 14)"
|
||||
h = "(if(height < 14, 0, height - 14))"
|
||||
stretch = "true"
|
||||
name = "dialogs/translucent54-border-right.png"
|
||||
[/image]
|
||||
|
@ -65,7 +65,7 @@
|
|||
[image]
|
||||
x = 5
|
||||
y = "(height - 9)"
|
||||
w = "(width - 14)"
|
||||
w = "(if(width < 14, 0, width - 14))"
|
||||
stretch = "true"
|
||||
name = "dialogs/translucent54-border-bottom.png"
|
||||
[/image]
|
||||
|
@ -79,7 +79,7 @@
|
|||
[image]
|
||||
x = 0
|
||||
y = 5
|
||||
h = "(height - 14)"
|
||||
h = "(if(height < 14, 0, height - 14))"
|
||||
stretch = "true"
|
||||
name = "dialogs/translucent54-border-left.png"
|
||||
[/image]
|
||||
|
@ -87,8 +87,8 @@
|
|||
[image]
|
||||
x = 5
|
||||
y = 5
|
||||
w = "(width - 14)"
|
||||
h = "(height - 14)"
|
||||
w = "(if(width < 14, 0, width - 14))"
|
||||
h = "(if(height < 14, 0, height - 14))"
|
||||
name = "dialogs/translucent54-background.png"
|
||||
[/image]
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
x = 0
|
||||
y = 5
|
||||
w = "(width)"
|
||||
h = "(height - 14)"
|
||||
h = "(if(height < 14, 0, height - 14))"
|
||||
name = "dialogs/" + {_GUI_BASE_NAME} + "-background.png"
|
||||
[/image]
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
[rectangle]
|
||||
x = 1
|
||||
y = 1
|
||||
w = "(width - 2)"
|
||||
h = "(height - 2)"
|
||||
w = "(if(width < 2, 0, width - 2))"
|
||||
h = "(if(height < 2, 0, height - 2))"
|
||||
|
||||
border_thickness = 1
|
||||
border_colour = {COLOUR}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
[text]
|
||||
x = {X_OFFSET}
|
||||
y = {GUI__TEXT_VERTICALLY_CENTRED}
|
||||
w = "(width - {X_OFFSET})"
|
||||
w = "(if(width < {X_OFFSET}, 0, width - {X_OFFSET}))"
|
||||
h = "(text_height)"
|
||||
font_size = {FONT_SIZE}
|
||||
colour = {FONT_COLOUR}
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
[text]
|
||||
x = 3
|
||||
y = {GUI__TEXT_VERTICALLY_CENTRED}
|
||||
w = "(width - 6)"
|
||||
w = "(if(width < 6, 0, width - 6))"
|
||||
h = "(text_height)"
|
||||
maximum_width = "(width - 6)"
|
||||
maximum_width = "(if(width < 6, 0, width - 6))"
|
||||
font_size = {FONT_SIZE}
|
||||
colour = {FONT_COLOUR}
|
||||
text = "(text)"
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
[text]
|
||||
x = {OFFSET}
|
||||
y = {GUI__TEXT_VERTICALLY_CENTRED}
|
||||
w = "(width - {OFFSET})"
|
||||
w = "(if(width < {OFFSET}, 0, width - {OFFSET}))"
|
||||
h = "(text_height)"
|
||||
font_size = {FONT_SIZE}
|
||||
colour = {FONT_COLOUR}
|
||||
|
|
|
@ -35,28 +35,28 @@
|
|||
[image]
|
||||
x = 10
|
||||
y = 0
|
||||
w = "(width - 20)"
|
||||
w = "(if(width < 20, 0, width - 20))"
|
||||
name = "misc/selection2_transparent-border-top.png"
|
||||
[/image]
|
||||
|
||||
[image]
|
||||
x = 10
|
||||
y = "(height - 3)"
|
||||
w = "(width - 20)"
|
||||
w = "(if(width < 20, 0, width - 20))"
|
||||
name = "misc/selection2_transparent-border-bottom.png"
|
||||
[/image]
|
||||
|
||||
[image]
|
||||
x = 0
|
||||
y = 10
|
||||
h= "(height - 20)"
|
||||
h = "(if(height < 20, 0, height - 20))"
|
||||
name = "misc/selection2_transparent-border-left.png"
|
||||
[/image]
|
||||
|
||||
[image]
|
||||
x = "(width - 3)"
|
||||
y = 10
|
||||
h = "(height - 20)"
|
||||
h = "(if(height < 20, 0, height - 20))"
|
||||
name = "misc/selection2_transparent-border-right.png"
|
||||
[/image]
|
||||
|
||||
|
@ -64,8 +64,8 @@
|
|||
[image]
|
||||
x = 3
|
||||
y = 3
|
||||
w = "(width - 6)"
|
||||
h = "(height - 6)"
|
||||
w = "(if(width < 6, 0, width - 6))"
|
||||
h = "(if(height < 6, 0, height - 6))"
|
||||
name = "misc/selection2_transparent-background.png"
|
||||
[/image]
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
[image]
|
||||
x = 0
|
||||
y = {GROOVE_TOP}
|
||||
h = "(height - {GROOVE_TOP} - {GROOVE_BOTTOM})"
|
||||
h = "(if(height - {GROOVE_TOP} - {GROOVE_BOTTOM} < 0
|
||||
, 0, height - {GROOVE_TOP} - {GROOVE_BOTTOM}))"
|
||||
stretch = true
|
||||
name = "buttons/scrollgroove{IMAGE_MIDDLE}-mid.png"
|
||||
[/image]
|
||||
|
@ -46,7 +47,9 @@
|
|||
[image]
|
||||
x = 0
|
||||
y = "(positioner_offset + {POSITIONER_TOP})"
|
||||
h = "(positioner_length - {POSITIONER_TOP} - {POSITIONER_BOTTOM})"
|
||||
h = "(
|
||||
if(positioner_length - {POSITIONER_TOP} - {POSITIONER_BOTTOM} < 0
|
||||
, 0, positioner_length - {POSITIONER_TOP} - {POSITIONER_BOTTOM}))"
|
||||
stretch = true
|
||||
name = "buttons/scrollmid{IMAGE_MIDDLE}{IMAGE_SUFFIX}"
|
||||
[/image]
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
[image]
|
||||
x = 5
|
||||
y = 0
|
||||
w = "(width - 14)"
|
||||
w = "(if(width < 14, 0, width - 14))"
|
||||
stretch = "true"
|
||||
name = "dialogs/{BASE_NAME}-border-top.png"
|
||||
[/image]
|
||||
|
@ -46,7 +46,7 @@
|
|||
[image]
|
||||
x = "(width - 9)"
|
||||
y = 5
|
||||
h = "(height - 14)"
|
||||
h = "(if(height < 14, 0, height - 14))"
|
||||
stretch = "true"
|
||||
name = "dialogs/{BASE_NAME}-border-right.png"
|
||||
[/image]
|
||||
|
@ -60,7 +60,7 @@
|
|||
[image]
|
||||
x = 5
|
||||
y = "(height - 9)"
|
||||
w = "(width - 14)"
|
||||
w = "(if(width < 14, 0, width - 14))"
|
||||
stretch = "true"
|
||||
name = "dialogs/{BASE_NAME}-border-bottom.png"
|
||||
[/image]
|
||||
|
@ -74,7 +74,7 @@
|
|||
[image]
|
||||
x = 0
|
||||
y = 5
|
||||
h = "(height - 14)"
|
||||
h = "(if(height < 14, 0, height - 14))"
|
||||
stretch = "true"
|
||||
name = "dialogs/{BASE_NAME}-border-left.png"
|
||||
[/image]
|
||||
|
@ -82,8 +82,8 @@
|
|||
[image]
|
||||
x = 5
|
||||
y = 5
|
||||
w = "(width - 14)"
|
||||
h = "(height - 14)"
|
||||
w = "(if(width < 14, 0, width - 14))"
|
||||
h = "(if(height < 14, 0, height - 14))"
|
||||
name = "dialogs/{BASE_NAME}-background.png"
|
||||
[/image]
|
||||
|
||||
|
|
|
@ -705,7 +705,22 @@ void timage::draw(surface& canvas,
|
|||
local_variables.add("image_original_height", variant(image_->h));
|
||||
|
||||
unsigned w = w_(local_variables);
|
||||
if(w && static_cast<int>(w) < 0) {
|
||||
ERR_GUI_D << "Image: file '"
|
||||
<< image_name_(variables)
|
||||
<< "' won't be drawn due to a negative width of "
|
||||
<< static_cast<int>(w) << ".\n";
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned h = h_(local_variables);
|
||||
if(h && static_cast<int>(h) < 0) {
|
||||
ERR_GUI_D << "Image: file '"
|
||||
<< image_name_(variables)
|
||||
<< "' won't be drawn due to a negative height of "
|
||||
<< static_cast<int>(h) << ".\n";
|
||||
return;
|
||||
}
|
||||
|
||||
local_variables.add("image_width", variant(w ? w : image_->w));
|
||||
local_variables.add("image_height", variant(h ? h : image_->h));
|
||||
|
|
Loading…
Add table
Reference in a new issue