Added macros from the old wml_message.
mordante, do you know a better place for them?
This commit is contained in:
parent
0b56dba63a
commit
3e96305e73
1 changed files with 140 additions and 0 deletions
|
@ -278,3 +278,143 @@
|
|||
18
|
||||
#enddef
|
||||
|
||||
#TODO change comments a little
|
||||
###
|
||||
### The in game portrait dialogs.
|
||||
### Due to the excessive amount of dialogs it's not possible to split off the
|
||||
### window definitions. So this unit is a bit larger as wanted.
|
||||
###
|
||||
|
||||
# These might become global have to evaluate later.
|
||||
#define _GUI_HEIGHT_OFFSET
|
||||
25#enddef
|
||||
|
||||
# helper convert the scale factor, since we use it in two places define it as
|
||||
# helper value. (Two the not working and working version, but want to avoid
|
||||
# surprises when the not working version is fixed).
|
||||
#define __GUI_SIZE_FACTOR
|
||||
3#enddef
|
||||
|
||||
### 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:
|
||||
###
|
||||
### 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
|
||||
(gamemap_height - 4)
|
||||
#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
|
||||
(if(gamemap_width > {TEXT_WIDTH_SATURATION}, gamemap_width - {MAX_TEXT_WIDTH}, (gamemap_width / {__GUI_SIZE_FACTOR})))
|
||||
#enddef
|
||||
|
||||
#define __GUI_BEST_SIZE
|
||||
(if({BEST_WIDTH} > {__GUI_MAX_HEIGHT}, {__GUI_MAX_HEIGHT}, {BEST_WIDTH}))
|
||||
#enddef
|
||||
|
||||
#define ___GUI_IMAGE_WIDTH
|
||||
if({__GUI_BEST_SIZE} < 250, 250,
|
||||
if({__GUI_BEST_SIZE} > 500, 500, {__GUI_BEST_SIZE})
|
||||
)
|
||||
#enddef
|
||||
|
||||
# This is the version with debug info
|
||||
#define __GUI_IMAGE_WIDTH
|
||||
([[
|
||||
debug_print('screen_width ', screen_width),
|
||||
debug_print('screen_height ', screen_height),
|
||||
debug_print('gamemap_width ', gamemap_width),
|
||||
debug_print('gamemap_height ', gamemap_height),
|
||||
debug_print('__GUI_MAX_HEIGHT ', {__GUI_MAX_HEIGHT}),
|
||||
debug_print('BEST_WIDTH ', {BEST_WIDTH}),
|
||||
debug_print('__GUI_BEST_SIZE ', {__GUI_BEST_SIZE})
|
||||
],
|
||||
{___GUI_IMAGE_WIDTH}
|
||||
][1]
|
||||
)
|
||||
#enddef
|
||||
|
||||
#undef __GUI_IMAGE_WIDTH
|
||||
# This is the version without debug info
|
||||
#define __GUI_IMAGE_WIDTH
|
||||
({___GUI_IMAGE_WIDTH})#enddef
|
||||
|
||||
|
||||
# This is the macro for the image width which is can be used as string
|
||||
# parameter.
|
||||
#define _GUI_IMAGE_WIDTH
|
||||
"{__GUI_IMAGE_WIDTH}"#enddef
|
||||
|
||||
# the value the image needs to be scaled by, this version can be used as string
|
||||
# parameter.
|
||||
#define _GUI_IMAGE_SCALE_FACTOR
|
||||
(
|
||||
{__GUI_IMAGE_WIDTH} / 500
|
||||
)#enddef
|
||||
|
||||
|
||||
# The formula to set the widthe of the real image width depending on the
|
||||
# image real size
|
||||
#define __GUI_IMAGE_DISPLAYED_WIDTH
|
||||
(
|
||||
if((image_original_width < 300) and (image_original_height < 300),
|
||||
image_original_width,
|
||||
((image_original_width * {__GUI_IMAGE_WIDTH}) / 500))
|
||||
)#enddef
|
||||
|
||||
# The formula to set the heighte of the real image height depending on the
|
||||
# image real size
|
||||
#define __GUI_IMAGE_DISPLAYED_HEIGHT
|
||||
(
|
||||
if((image_original_width < 300) and (image_original_height < 300),
|
||||
image_original_height,
|
||||
((image_original_height * {__GUI_IMAGE_WIDTH}) / 500))
|
||||
)#enddef
|
||||
|
||||
# The X location of the image to display, only tested on the left side.
|
||||
#define __GUI_IMAGE_DISPLAYED_X X
|
||||
(
|
||||
if(image_original_width > 100,
|
||||
{X},
|
||||
({__GUI_IMAGE_WIDTH} - image_width) / 2)
|
||||
|
||||
)#enddef
|
||||
|
||||
# The Y location of the image to display, only tested on the left side.
|
||||
# Note since we don't know the exact height of the text we can't centre
|
||||
# the image. Instead we use the centre of the reserved image space.
|
||||
#
|
||||
# TODO the Y can't be determined properly since we don't know the height
|
||||
# of the panel. Disabled the centring for now.
|
||||
#
|
||||
#define __GUI_IMAGE_DISPLAYED_Y
|
||||
(
|
||||
if(image_original_height > 0,
|
||||
(height - image_height),
|
||||
height - (({__GUI_IMAGE_WIDTH} - image_height) / 2))
|
||||
|
||||
)#enddef
|
||||
|
|
Loading…
Add table
Reference in a new issue