Using custom themes in campaigns

From Wesnoth

It is possible to create custom themes for Wesnoth and include them with a campaign. This way, a campaign can be given a distinct look by, for example, changing the colors in the UI or adding small graphics. Every scenario can even use a different theme, to for example hide the top bar that shows gold, villages, upkeep and such from non-combat scenarios.

Note that this page discussed only how to use custom themes, not how a theme should be written. Read the pages ThemeWML and ThemeSystem for details on how to create or modify a theme.

Making a theme available

In order for a scenario to use a theme, it must be included just like any other .cfg files such as scenarios or unit definitions. This must be done in the campaign file. However, scenarios and unit definitions normally reside inside a campaign #ifdef, and are thus loaded only when the campaign is started. Themes, on the other hand, must be included when the game starts in order to become usable.

The game processes all of the campaign files when it starts, but since a campaign hasn't been started yet, the campaign #ifdefs aren't processed, so themes cannot be included from there. Themes must therefore be included from outside the campaign tag and campaign #ifdefs.

Here is an example:

   [campaign]
       id=MY_CAMPAIGN
       name= _ "My campaign"
       define=CAMPAIGN_MY_CAMPAIGN
       icon=elvish-fighter.png 
... [/campaign]
{@campaigns/my_campaign/themes/my_campaign-default.cfg} {@campaigns/my_campaign/themes/my_campaign-noncombat.cfg}
#ifdef CAMPAIGN_MY_CAMPAIGN {@campaigns/my_campaign/scenarios} #endif

The above means that my_campaign-default.cfg and my_campaign-noncombat.cfg are processed by the game when it starts, and the themes described in them can then be used by any scenario. Because of this, it is important to name themes so that your theme doesn't conflict with a theme from another campaign. Prefixing the theme name with the name (or abbreviation) of your campaign is a good idea.

Using a theme in a scenario

Finally, you may use your theme of choice in a scenario simply by adding a theme key inside the [scenario] tag, like this:

   [scenario]
       id=test
       name= _ "Test scenario"
       turns=25 
theme=my_campaign-default
... [/scenario]

where my_campaign-default is the name of the theme, specified in the [theme] tag.

This page was last modified 05:27, 24 February 2008.