ThemeSystem

From The Battle for Wesnoth Wiki
Revision as of 20:39, 17 September 2005 by HaJo (talk | contribs) (label)

- 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:

Code:

[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:

Code:

[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 a 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 language 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__ senter on the leader
  • __undo__ undo last action
  • __redo__ redo undone action
  • __zoomin__ zoom the map in
  • __zoomout__ zoom the map out
  • __zoomdefault__ return to default zoom
  • __fullscreen__ switch fulscreen 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 previous scenarion
  • __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