Difference between revisions of "DescriptionWML"
m (Reverted edit of GrabberBot, changed back to last version by Allefant) |
(Swap the order so the new format is documented first) |
||
(13 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{WML Tags}} | ||
+ | |||
+ | == WML Format == | ||
+ | |||
+ | {{DevFeature1.13|2}} | ||
+ | |||
+ | As of 1.13.2, the DescriptionWML format has changed to use WML tags. It goes in either a '''[difficulty]''' tag within '''[campaign]''' or an '''[option]''' tag within '''[message]''' and comprises the following attributes: | ||
+ | |||
+ | * '''default''': If yes, this item is the default selection (assuming no other items also have default=yes). | ||
+ | * '''image''': Optional path to an image file to display. | ||
+ | * '''label''': Text to display in the first text column. | ||
+ | * '''description''': Text to display in the second text column. | ||
+ | |||
== Description texts == | == Description texts == | ||
+ | |||
+ | {{DevFeature1.15|1}} '''Support for the image-icon plus text format in this section has been removed. It is documented here only for the benefit of people who wish to port old add-ons to the new format, documented above.''' | ||
A description is a part of the value of a menu attribute. | A description is a part of the value of a menu attribute. | ||
− | It | + | It represents a single option in the difficulty selection menu for a campaign, which consists of an image (called the ''icon'') followed by text. When appropriate, the icon should use [[ImagePathFunctions]] to replace any magenta with a team color. |
− | + | The description tag uses a special format: | |
* ''';''' if another description precedes it | * ''';''' if another description precedes it | ||
Line 10: | Line 25: | ||
* '''*''' if it should be the default selection | * '''*''' if it should be the default selection | ||
− | * '''&''image''=''text''''' image with text description | + | * '''&''image''=''text''''' image with one text description |
* '''&''image''=''text''=''text2''''' image with two text descriptions | * '''&''image''=''text''=''text2''''' image with two text descriptions | ||
− | Single text items are always enclosed in '''"''', and concatenated with '''+'''. This | + | Single text items are always enclosed in '''"''', and can be joined together (concatenated) with '''+'''. This allows the text to contain translatable items and span multiple lines. (Marking text with '''_''' indicates that it is translatable.) |
− | + | A sample difficulty description tag might look like this: | |
− | difficulty_descriptions="&" + "elvish-fighter.png" + "=" + _"Fighter" + "=" + _"(easiest)" + | + | difficulty_descriptions="&" + "units/elves-wood/elvish-fighter.png~TC(1,magenta)" + "=" + _"Fighter" + "=" + _"(easiest)" + |
− | ";*" + "&" + "elvish-hero.png" + "=" + _"Hero" + | + | ";*" + "&" + "units/elves-wood/elvish-hero.png~TC(1,magenta)" + "=" + _"Hero" + |
− | ";" + "&" + "elvish-champion.png" + "=" + _"Champion" + "=" + _"(hardest)" | + | ";" + "&" + "units/elves-wood/elvish-champion.png~TC(1,magenta)" + "=" + _"Champion" + "=" + _"(hardest)" |
− | The utility macros (see [ | + | The utility macros (see the [https://www.wesnoth.org/macro-reference.html#file:utils.cfg Macro Reference]) '''{MENU_IMG_TXT ''icon'' ''text''}''' |
and '''{MENU_IMG_TXT2 ''icon'' ''text'' ''text-2''}''' | and '''{MENU_IMG_TXT2 ''icon'' ''text'' ''text-2''}''' | ||
can be used to create descriptions more easily. The above example would become: | can be used to create descriptions more easily. The above example would become: | ||
− | difficulty_descriptions={MENU_IMG_TXT2 "elvish-fighter.png" _"Fighter" _"(easiest)"} + | + | difficulty_descriptions={MENU_IMG_TXT2 "units/elves-wood/elvish-fighter.png~TC(1,magenta)" _"Fighter" _"(easiest)"} + |
− | ";*" + {MENU_IMG_TXT "elvish-hero.png" _"Hero"} + ";" + | + | ";*" + {MENU_IMG_TXT "units/elves-wood/elvish-hero.png~TC(1,magenta)" _"Hero"} + ";" + |
− | {MENU_IMG_TXT2 "elvish-champion.png" _"Champion" _"(hardest)"} | + | {MENU_IMG_TXT2 "units/elves-wood/elvish-champion.png~TC(1,magenta)" _"Champion" _"(hardest)"} |
+ | |||
+ | ====Alternative Description Implementation==== | ||
+ | |||
+ | For still greater clarity, I have the following suggestion: | ||
+ | Before the start of the [campaign] tag, create a set of #define commands as follows: | ||
+ | # Image definitions | ||
+ | # NB Don't forget the trailing + symbols for all but the last entry. | ||
+ | #define EASY_IMAGE | ||
+ | "&units/elves-wood/elvish-fighter.png~TC(1,magenta)"+ | ||
+ | #enddef | ||
+ | |||
+ | #define NORMAL_IMAGE | ||
+ | ";*&units/elves-wood/elvish-hero.png~TC(1,magenta)"+ | ||
+ | #enddef | ||
+ | |||
+ | #define HARD_IMAGE | ||
+ | ";&units/elves-wood/elvish-champion.png~TC(1,magenta)"+ | ||
+ | #enddef | ||
+ | |||
+ | # Difficulty ratings | ||
+ | #po: NB be sure to retain the = signs in the translated text. | ||
+ | #define EASY_TEXT | ||
+ | _"=Fighter=(easiest)"+ | ||
+ | #enddef | ||
+ | |||
+ | #define NORMAL_TEXT | ||
+ | _"=Hero"+ | ||
+ | #enddef | ||
+ | |||
+ | #define HARD_TEXT | ||
+ | _"=Champion=(hardest)" | ||
+ | #enddef | ||
+ | |||
+ | '''Note:''' The above example assumes three difficulty levels, which gives six difficulty entries – three for the pictures and three for the text. If you have more or fewer than three difficulty levels, make sure that the last entry does ''not'' have a trailing plus sign and that all the others do. Note also that the first image description ''doesn't'' start with a semicolon, whereas the second and subsequent ones do. Finally, only the default difficulty entry is marked with a * character. | ||
+ | |||
+ | If you set up your difficulty strings in this way you can then use a standard difficulty_descriptions tag that you will rarely need to alter. Note that this string does ''not'' contain any plus signs. You have to have them in the difficulty ratings strings instead to avoid upsetting the Wesnoth preprocessor: | ||
+ | |||
+ | difficulty_descriptions={EASY_IMAGE}{EASY_TEXT}{NORMAL_IMAGE}{NORMAL_TEXT}{HARD_IMAGE}{HARD_TEXT} | ||
+ | |||
+ | The only time you would need to alter this string is if you have more or fewer than three difficulty levels for your campaign. | ||
+ | |||
+ | [[User:Simons Mith|Simons Mith]] 20:16, 18 November 2011 (UTC) | ||
== See Also == | == See Also == | ||
Line 35: | Line 92: | ||
* [[EraWML]] | * [[EraWML]] | ||
* [[ReferenceWML]] | * [[ReferenceWML]] | ||
+ | |||
+ | |||
+ | [[Category: WML Reference]] |
Latest revision as of 00:01, 25 July 2023
WML Format
(Version 1.13.2 and later only)
As of 1.13.2, the DescriptionWML format has changed to use WML tags. It goes in either a [difficulty] tag within [campaign] or an [option] tag within [message] and comprises the following attributes:
- default: If yes, this item is the default selection (assuming no other items also have default=yes).
- image: Optional path to an image file to display.
- label: Text to display in the first text column.
- description: Text to display in the second text column.
Description texts
(Version 1.15.1 and later only) Support for the image-icon plus text format in this section has been removed. It is documented here only for the benefit of people who wish to port old add-ons to the new format, documented above.
A description is a part of the value of a menu attribute. It represents a single option in the difficulty selection menu for a campaign, which consists of an image (called the icon) followed by text. When appropriate, the icon should use ImagePathFunctions to replace any magenta with a team color.
The description tag uses a special format:
- ; if another description precedes it
- * if it should be the default selection
- &image=text image with one text description
- &image=text=text2 image with two text descriptions
Single text items are always enclosed in ", and can be joined together (concatenated) with +. This allows the text to contain translatable items and span multiple lines. (Marking text with _ indicates that it is translatable.)
A sample difficulty description tag might look like this:
difficulty_descriptions="&" + "units/elves-wood/elvish-fighter.png~TC(1,magenta)" + "=" + _"Fighter" + "=" + _"(easiest)" + ";*" + "&" + "units/elves-wood/elvish-hero.png~TC(1,magenta)" + "=" + _"Hero" + ";" + "&" + "units/elves-wood/elvish-champion.png~TC(1,magenta)" + "=" + _"Champion" + "=" + _"(hardest)"
The utility macros (see the Macro Reference) {MENU_IMG_TXT icon text} and {MENU_IMG_TXT2 icon text text-2} can be used to create descriptions more easily. The above example would become:
difficulty_descriptions={MENU_IMG_TXT2 "units/elves-wood/elvish-fighter.png~TC(1,magenta)" _"Fighter" _"(easiest)"} + ";*" + {MENU_IMG_TXT "units/elves-wood/elvish-hero.png~TC(1,magenta)" _"Hero"} + ";" + {MENU_IMG_TXT2 "units/elves-wood/elvish-champion.png~TC(1,magenta)" _"Champion" _"(hardest)"}
Alternative Description Implementation
For still greater clarity, I have the following suggestion: Before the start of the [campaign] tag, create a set of #define commands as follows:
# Image definitions # NB Don't forget the trailing + symbols for all but the last entry. #define EASY_IMAGE "&units/elves-wood/elvish-fighter.png~TC(1,magenta)"+ #enddef #define NORMAL_IMAGE ";*&units/elves-wood/elvish-hero.png~TC(1,magenta)"+ #enddef #define HARD_IMAGE ";&units/elves-wood/elvish-champion.png~TC(1,magenta)"+ #enddef # Difficulty ratings #po: NB be sure to retain the = signs in the translated text. #define EASY_TEXT _"=Fighter=(easiest)"+ #enddef #define NORMAL_TEXT _"=Hero"+ #enddef #define HARD_TEXT _"=Champion=(hardest)" #enddef
Note: The above example assumes three difficulty levels, which gives six difficulty entries – three for the pictures and three for the text. If you have more or fewer than three difficulty levels, make sure that the last entry does not have a trailing plus sign and that all the others do. Note also that the first image description doesn't start with a semicolon, whereas the second and subsequent ones do. Finally, only the default difficulty entry is marked with a * character.
If you set up your difficulty strings in this way you can then use a standard difficulty_descriptions tag that you will rarely need to alter. Note that this string does not contain any plus signs. You have to have them in the difficulty ratings strings instead to avoid upsetting the Wesnoth preprocessor:
difficulty_descriptions={EASY_IMAGE}{EASY_TEXT}{NORMAL_IMAGE}{NORMAL_TEXT}{HARD_IMAGE}{HARD_TEXT}
The only time you would need to alter this string is if you have more or fewer than three difficulty levels for your campaign.
Simons Mith 20:16, 18 November 2011 (UTC)