wesnoth-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Wesnoth-dev] Adding arithmetic operations to WML


From: Yann Dirson
Subject: Re: [Wesnoth-dev] Adding arithmetic operations to WML
Date: Sat, 19 Feb 2005 22:59:33 +0100
User-agent: Mutt/1.5.6+20040907i

On Sat, Feb 19, 2005 at 09:43:27AM -0600, David White wrote:
> Yann Dirson wrote:
> 
> >Any quick answer, or should I look at the code ?
> 
> The quick answer is that your code isn't going to work. Among other 
> things, Wesnoth does NOT do variable interpolation when it reads the 
> config file into memory. It does variable interpolation whenever it 
> looks at the config objects, and a variable has one definite value...the 
> value of a variable is never 'context dependent'.
> 
> Basically the pre-processor is currently the only way to do this, and 
> the variables model is very very far away from being able to do anything 
> like this.

OK.  So we will anyway have to add some feature, right ?

Note: the final idea is to store the font sizes only in the theme (it
is currently used throughout the code with C++ #defines).

One (weak) constraint is that the expansion of those font sizes should
be possible to delay until after [partialresolution] expansion, that
is they should not be resolved in the freshly-read config object (to
avoid current redundant "font_size={FONT320_NORMAL}" if possible).

A stronger constraint is that we should be able to use those values in
operations to derive other values (button height, etc.).

If I summarize the possible places to store the font sizes:
 - wml macros
        cannot satisfy the 1st constraint, but the 2nd one is easy to
        fulfill (maybe need to add the suggested {+ ...} macro ?)
 - wml variables
        would need restructuration of the variable system to get
        scoped variables
 - key/value
        satisfies the 1st constraint, but requires special constructs
        for operations. Maybe something like:

                [resolution]
                        [fonts]
                                normal=14
                        [/fonts]
                        [label]
                                font_size = ../resolution/fonts
                                height = ../resolution/fonts + 2
                        [/label]
                [/resolution]

        But there may be interacations with the "+" syntax for string
        concatenation ?

 - other ideas anyone ?

-- 
Yann Dirson    <address@hidden> |
Debian-related: <address@hidden> |   Support Debian GNU/Linux:
                                    |  Freedom, Power, Stability, Gratis
     http://ydirson.free.fr/        | Check <http://www.debian.org/>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]