Difference between revisions of "ThemeSystem"

From The Battle for Wesnoth Wiki
m (label)
(Fix formatting)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
- themes are used both for the wesnoth game and the wesnoth editor
+
* Themes are used both for the wesnoth game and the wesnoth editor
- themes are stored in data/themes, one theme per file.
+
* Themes are stored in data/themes, one theme per file.
- themes allow flexible configuration of how everything is laid out on-screen
+
* Themes allow flexible configuration of how everything is laid out on-screen
- format of a theme is:
+
* Format of a theme is:
  
Code:
+
<syntaxhighlight lang=wml>
 
  [theme]
 
  [theme]
 
     name=<name>
 
     name=<name>
Line 10: Line 10:
 
     width=<x>
 
     width=<x>
 
     height=<y>
 
     height=<y>
        ....'content tags'....
+
    # Content tags....
 
     [/resolution]
 
     [/resolution]
     ...more resolution tags...
+
     # More resolution tags...
 
  [/theme]
 
  [/theme]
 +
</syntaxhighlight>
  
* the [resolution] tags are scanned until the first one which is of the same or lower resolution than is currently being used is found, and this is used as our theme. This allows us to define themes to work differently on different resolutions, and will allow us to support both high and low resolutions elegantly.
+
* the '''[resolution]''' tags are scanned until the first one which is of the same or lower resolution than is currently being used is found, and this is used as our theme. This allows us to define themes to work differently on different resolutions, and will allow us to support both high and low resolutions elegantly.
* the 'content tags' define where everything goes on-screen. The most common content tag is the 'main_map' tag, it has the following format:
+
* the '''content tags''' define where everything goes on-screen. The most common content tag is the '''main_map''' tag, it has the following format:
  
Code:
+
<syntaxhighlight lang=wml>
 
  [main_map]
 
  [main_map]
 
     rect=x1,y1,x2,y2
 
     rect=x1,y1,x2,y2
Line 24: Line 25:
 
     yanchor=top|bottom|fixed|proportional
 
     yanchor=top|bottom|fixed|proportional
 
  [/main_map]
 
  [/main_map]
 +
</syntaxhighlight>
  
The purpose of the 'main_map' tag is to define where the main game display (i.e. all the hexagons and units) is displayed. The rect field defines the rectangle the map is displayed on. The rectangle is given for a 1024x768 display -- the game's "canonical" resolution.
+
The purpose of the '''main_map''' tag is to define where the main game display (i.e. all the hexagons and units) is displayed. The ''rect'' field defines the rectangle the map is displayed on. The rectangle is given for a 1024x768 display -- the game's "canonical" resolution.
  
 
xanchor and yanchor control the behavior of how this rectangle changes as the resolution changes.
 
xanchor and yanchor control the behavior of how this rectangle changes as the resolution changes.
Line 35: Line 37:
  
 
== mini_map ==
 
== mini_map ==
determines where the mini map is displayed
+
Determines where the mini map is displayed.
  
 
== main_map ==
 
== main_map ==
determines where the main map is displayed
+
Determines where the main map is displayed.
  
 
== label ==
 
== label ==
Line 53: Line 55:
  
 
== menu ==
 
== menu ==
displays a button which, when pressed will reveal a menu or do a an action.
+
displays a button which, when pressed, will reveal a menu or do an action.
 
* '''title''' the id of the string to write on the button
 
* '''title''' the id of the string to write on the button
* '''title_literal''' a string that will be displayed "as is" in all language after the title
+
* '''title_literal''' a string that will be displayed "as is" in all languages after the title
 
* '''image''' the image to use if available
 
* '''image''' the image to use if available
* '''is_context_menu''' if set to true this menu will not be placed, but displayed on a right click
+
* '''is_context_menu''' if set to true, this menu will not be placed, but displayed on a right click
* '''items''' comma separated list of actions to put in the menu. if there is only one action, it will be executed immediately and no menu will be displayed
+
* '''items''' comma separated list of actions to put in the menu. If there is only one action, it will be executed immediately and no menu will be displayed
  
the possible buttons are:
+
The possible buttons are:
* __cycle__ move to next movable unit
+
* __cycle__         move to next movable unit
* __endunitturn__ consume this unit's move and cycle to the next one
+
* __endunitturn__   consume this unit's move and cycle to the next one
* __leader__ senter on the leader
+
* __leader__         center map on the leader
* __undo__ undo last action
+
* __undo__           undo last action
* __redo__ redo undone action
+
* __redo__           redo undone action
* __zoomin__ zoom the map in
+
* __zoomin__         zoom into the map
* __zoomout__ zoom the map out
+
* __zoomout__       zoom out of the map
* __zoomdefault__ return to default zoom
+
* __zoomdefault__   return to default zoom
* __fullscreen__ switch fulscreen mode
+
* __fullscreen__     switch fullscreen mode
* __accelerated__ switch turbo mode
+
* __accelerated__   switch turbo mode
* __resistance__ show resistance table of current unit
+
* __resistance__     show resistance table of current unit
* __terraintable__ show terrain table of current unit
+
* __terraintable__   show terrain table of current unit
* __describeunit__ show unit description
+
* __describeunit__   show unit description
* __renameunit__ change unit name
+
* __renameunit__     change unit name
* __save__ save the game
+
* __save__           save the game
* __recruit__ recruit a unit
+
* __recruit__       recruit a unit
* __repeatrecruit__ repeat last recruitement
+
* __repeatrecruit__ repeat last recruitement
* __recall__ recall a unit from previous scenarion
+
* __recall__         recall a unit from a previous scenario
* __endturn__ end current turn
+
* __endturn__       end current turn
* __togglegrid__ toggle grid display
+
* __togglegrid__     toggle grid display
* __statustable__ show status table
+
* __statustable__   show status table
* __mute__ mute all sounds
+
* __mute__           mute all sounds
* __speak__ send message to other players
+
* __speak__         send message to other players
* __createunit__ ''debug'' create a unit on the map
+
* __createunit__     ''debug'' create a unit on the map
* __preferences__ open preference dialog
+
* __preferences__   open preference dialog
* __objectives__ show objective window
+
* __objectives__     show objective window
* __unitlist__ list units
+
* __unitlist__       list units
* __statistics__ show game statistics
+
* __statistics__     show game statistics
* __quit__ quit the game
+
* __quit__           quit the game
* __labelterrain__ label current location
+
* __labelterrain__   label current location
* __showenemymoves__ show grids reachable by the enemy
+
* __showenemymoves__ show grids reachable by the enemy
* __bestenemymoves__ show grids reachable by the enemy with no zone of control
+
* __bestenemymoves__ show grids reachable by the enemy with no zone of control
* __editnewmap__ ''editor only'' start a new map
+
* __editnewmap__     ''editor only'' start a new map
* __editloadmap__ ''editor only'' loads an existing map
+
* __editloadmap__     ''editor only'' loads an existing map
* __editsavemap__ ''editor only'' saves the current map
+
* __editsavemap__     ''editor only'' saves the current map
* __editsaveas__ ''editor only'' saves the current map, let you choose a filename
+
* __editsaveas__     ''editor only'' saves the current map, let you choose a filename
 
* __editsetstartpos__ ''editor only'' set a starting position for a team
 
* __editsetstartpos__ ''editor only'' set a starting position for a team
* __editfloodfill__ ''editor only'' flood the map with a terrain
+
* __editfloodfill__   ''editor only'' flood the map with a terrain
* __toggleshroud__ toggle the "moving removes shroud" behaviour
+
* __toggleshroud__   toggle the "moving removes shroud" behaviour
* __updateshroud__ removes all possible shroud
+
* __updateshroud__   removes all possible shroud
  
 
== status ==
 
== status ==
Line 145: Line 147:
  
 
__NOTOC__
 
__NOTOC__
 +
 +
[[Category:WML Reference]]

Latest revision as of 16:48, 20 June 2024

  • Themes are used both for the wesnoth game and the wesnoth editor
  • Themes are stored in data/themes, one theme per file.
  • Themes allow flexible configuration of how everything is laid out on-screen
  • Format of a theme is:
 [theme]
     name=<name>
     [resolution]
     width=<x>
     height=<y>
     # Content tags....
     [/resolution]
     # More resolution tags...
 [/theme]
  • the [resolution] tags are scanned until the first one which is of the same or lower resolution than is currently being used is found, and this is used as our theme. This allows us to define themes to work differently on different resolutions, and will allow us to support both high and low resolutions elegantly.
  • the content tags define where everything goes on-screen. The most common content tag is the main_map tag, it has the following format:
 [main_map]
     rect=x1,y1,x2,y2
     xanchor=left|right|fixed|proportional
     yanchor=top|bottom|fixed|proportional
 [/main_map]

The purpose of the main_map tag is to define where the main game display (i.e. all the hexagons and units) is displayed. The rect field defines the rectangle the map is displayed on. The rectangle is given for a 1024x768 display -- the game's "canonical" resolution.

xanchor and yanchor control the behavior of how this rectangle changes as the resolution changes.

  • A rectangle anchored to the left will have its distance from the left side of the screen always remain the same, while changes in the resolution will change its size by the same amount (top for the y axis).
  • A rectangle anchored to the right will have its size always remain the same, as well as its distance to the right side of the screen (bottom for the y axis).
  • A rectangle that is fixed will have its co-ordinates in that axis remain constant
  • A rectangle that is proportional will have its co-ordinates multiplied by the ratio of the resolution being used to the canonical resolution.

mini_map

Determines where the mini map is displayed.

main_map

Determines where the main map is displayed.

label

displays a text label on screen.

  • prefix a string that will be printed before the text in all languages
  • text a text string id to be displayed
  • postfix a string that will be printed after the text in all languages
  • icon an image that will be displayed instead of the text if it is available
  • font_size the size of the font to use for the label

panel

displays an image as a panel on-screen.

  • image the image used for the panel

menu

displays a button which, when pressed, will reveal a menu or do an action.

  • title the id of the string to write on the button
  • title_literal a string that will be displayed "as is" in all languages after the title
  • image the image to use if available
  • is_context_menu if set to true, this menu will not be placed, but displayed on a right click
  • items comma separated list of actions to put in the menu. If there is only one action, it will be executed immediately and no menu will be displayed

The possible buttons are:

  • __cycle__ move to next movable unit
  • __endunitturn__ consume this unit's move and cycle to the next one
  • __leader__ center map on the leader
  • __undo__ undo last action
  • __redo__ redo undone action
  • __zoomin__ zoom into the map
  • __zoomout__ zoom out of the map
  • __zoomdefault__ return to default zoom
  • __fullscreen__ switch fullscreen mode
  • __accelerated__ switch turbo mode
  • __resistance__ show resistance table of current unit
  • __terraintable__ show terrain table of current unit
  • __describeunit__ show unit description
  • __renameunit__ change unit name
  • __save__ save the game
  • __recruit__ recruit a unit
  • __repeatrecruit__ repeat last recruitement
  • __recall__ recall a unit from a previous scenario
  • __endturn__ end current turn
  • __togglegrid__ toggle grid display
  • __statustable__ show status table
  • __mute__ mute all sounds
  • __speak__ send message to other players
  • __createunit__ debug create a unit on the map
  • __preferences__ open preference dialog
  • __objectives__ show objective window
  • __unitlist__ list units
  • __statistics__ show game statistics
  • __quit__ quit the game
  • __labelterrain__ label current location
  • __showenemymoves__ show grids reachable by the enemy
  • __bestenemymoves__ show grids reachable by the enemy with no zone of control
  • __editnewmap__ editor only start a new map
  • __editloadmap__ editor only loads an existing map
  • __editsavemap__ editor only saves the current map
  • __editsaveas__ editor only saves the current map, let you choose a filename
  • __editsetstartpos__ editor only set a starting position for a team
  • __editfloodfill__ editor only flood the map with a terrain
  • __toggleshroud__ toggle the "moving removes shroud" behaviour
  • __updateshroud__ removes all possible shroud

status

this tag contains many other tags, which determine where other game statistics, such as the current turn, and a description of selected units go. For instance, the time_of_day tag will determine where the time of day image goes. each subtag can contain the following attributes

  • font_size the size of font to use for the status
  • rect the rectangle as for the main_map attribute
  • xanchor the x-wise anchoring as for the main_map attribute
  • yanchor the y-wise anchoring as for the main_map attribute
  • prefix the string to display before the actual status, this is the string id for internationalisation
  • prefix_literal a string to put after the prefix, but before the label for all languages.
  • postfix_literal a string to put after the status
  • postfix the string to display after the postfix_literal, this is the string id for internationalisation

the following stati are recognised:

  • __unit_description__ the description of the current unit
  • __unit_type__ the type of the current unit
  • __unit_level__ the level of the current unit
  • __unit_traits__ the traits of the current unit
  • __unit_status__ the status of the current unit
  • __unit_alignment__ the alignment of the current unit
  • __unit_abilities__ the abilities of the current unit
  • __unit_hp__ the HP of the current unit
  • __unit_xp__ the XP of the current unit
  • __unit_moves__ the moves remaining for the current unit
  • __unit_weapons__ the attacks of the current unit
  • __unit_image__ the icon for the current unit
  • __unit_profile__
  • __time_of_day__ the time of day on the current location
  • __turn__ the turn number and turn remaining
  • __gold__ the gold remaining
  • __villages__ the number of villages owned
  • __num_units__ the number of units owned
  • __upkeep__ the money needed to keep your units every turn
  • __expenses__ the money lost each turn when you don't have enough income
  • __income__ the income per turn (can be positive)
  • __terrain__ the text description of the current terrain
  • __position__ the current terrain's position
  • __side_playing__ the current playing side
  • __observers__ the current observers

See Also

This page was last edited on 20 June 2024, at 16:48.