Difference between revisions of "BuildingCampaignsTheCampaignFile"

From The Battle for Wesnoth Wiki
 
(Add info about [textdomain])
Line 1: Line 1:
Each campaign must contain a WML file which begins with a [campaign] tag. This file contains the information the game
+
Each campaign must contain a WML file which contains a [campaign] tag. In order for the campaign to be translatable, it must also contain a [textdomain] tag, which should precede the [campaign] tag.
needs to find the rest of the bits of
 
your campaign scattered in other files and put them together to have a playable campaign.  Much information about this
 
file can be found in the
 
[[CampaignWML]] entry.  What follows is a description of each line of the campaign file and an explanation of what it does.
 
  
For our purposes I'll assume we've already created a campaign called simple_campaign with the directory structure
+
This file contains the information the game needs to find the rest of the bits of your campaign scattered in other files and put them together to have a playable campaign.  Much information about this file can be found in the [[CampaignWML]] entry.  What follows is a description of each line of the campaign file and an explanation of what it does.
outlined in
 
[[BuildingCampaignsDirectoryStructure]].
 
  
The first line of the campiagn file is the [campaign] WML tag that lets the game know this is a campaign:
+
For our purposes I'll assume we've already created a campaign called simple_campaign with the directory structure outlined in [[BuildingCampaignsDirectoryStructure]].
 +
 
 +
The first line of the campaign file is the [textdomain] WML tag, which specifies where the game should look for translations to the strings in the campaign. The textdomain tag specifies a name for the textdomain, which is what is used in the [campaign] tag, and in f ex campaign scenarios to connect the strings with translations. The textdomain should be unique, and start with 'wesnoth-', to ensure that it does not conflict with other textdomains that might be specified on a given system.
 +
The textdomain also specifies a path to the directory where the compiled translation files will be stored. This should be a file inside the campaign directory.
 +
 
 +
Ex.
 +
    [textdomain]
 +
          name="wesnoth-Simple_Campaign"
 +
          path="data/campaigns/simple_campaign/translations"
 +
    [/textdomain]
 +
 
 +
 
 +
 
 +
Then follows the [campaign] WML tag that lets the game know this is a campaign:
  
 
     [campaign]
 
     [campaign]
 +
 +
First associate the campaign with the textdomain you have just defined:
 +
    #textdomain wesnoth-Simple_Campaign
  
 
The next group of lines uniquely identifies the campaign:
 
The next group of lines uniquely identifies the campaign:
Line 21: Line 31:
 
[In earlier version, there was also ''id'' which was a unique identifier used for translation, but now has no effect.]
 
[In earlier version, there was also ''id'' which was a unique identifier used for translation, but now has no effect.]
  
''name'' is the name of your campaign that the user will see.  It must be in quotation marks and be preceded by
+
''name'' is the name of your campaign that the user will see.  It must be in quotation marks and be preceded by an underscore to facilitate translation.  ''define'' creates a key that lets the game know when a user has selected to play a scenario from your campaign.  More on it in a bit.  If you are missing any of these your campaign will not work correctly.
an underscore to facilitate
 
translation.  ''define'' creates a key that lets the game know when a user has selected to play a scenario from your
 
campaign.  More on it in a bit.  If you
 
are missing any of these your campaign will not work correctly.
 
  
 
The next group gives the user information about your campaign when he selects it from the campaign menu:
 
The next group gives the user information about your campaign when he selects it from the campaign menu:
Line 33: Line 39:
 
     description= _ "Some text about my campaign!"
 
     description= _ "Some text about my campaign!"
  
''icon'' is a reference to any of the standard Wesnoth images.  It will be displayed in the campaign selection menu.
+
''icon'' is a reference to any of the standard Wesnoth images.  It will be displayed in the campaign selection menu.''image'' is an image that will be displayed when a user clicks on the campaign.  ''description'' is a text description that will be shown to the user at the same time as ''image''.  Note that none of these three are strictly necessary, but they do make your campaign look nice and professional.
''image'' is an image that will be
 
displayed when a user clicks on the campaign.  ''description'' is a text description that will be shown to the user at
 
the same time as ''image''.  Note
 
that none of these three are strictly necessary, but they do make your campaign look nice and professional.
 
  
 
     difficulties=EASY,NORMAL,HARD
 
     difficulties=EASY,NORMAL,HARD
 +
    difficulty_descriptions={MENU_IMG_TXT2 *&neutral-peasant.png _"Civilian" _"(trivial)"} +
 +
    ";" + {MENU_IMG_TXT2 human-spearman.png _"Soldier" _"(simple)"} +
 +
    ";" + {MENU_IMG_TXT2 human-pikeman.png _"Veteran" _"(easy)"}
  
difficulty_descriptions=*&neutral-peasant.png,Civilian,(trivial);*&human-spearman.png,Soldier,(simple);&human-pikeman.png,Veteran,(easy)
+
''difficulties'' creates three definitions for three different difficulty levels.  For more information on difficulty levels and balancing see [[BuildingCampaignsBalancing]].
 
 
''difficulties'' creates three definitions for three different difficulty levels.  For more information on difficulty
 
levels and balancing see
 
[[BuildingCampaignsBalancing]].  ''difficulty_descriptions'' is currently being modified, and will be different in 0.8.9, so
 
I'm not going to spend a lot of time
 
explaining it until the new syntax is released.
 
  
 
     first_scenario=the_first_scenario
 
     first_scenario=the_first_scenario
  
 
''first_scenario'' is a reference to the scenario ''id'' of the scenario that you intend to be loaded and played first.
 
''first_scenario'' is a reference to the scenario ''id'' of the scenario that you intend to be loaded and played first.
This line is essential.  Note that while
+
This line is essential.  Note that while you are debugging and testing your campaign, it's often useful to change this line to the scenario you're working on so you don't have to play through all
you are debugging and testing your campaign, it's often useful to change this line to the scenario you're working on so
 
you don't have to play through all
 
 
the scenarios that come before it.  (You could also just play through your campaign saving at each level.)
 
the scenarios that come before it.  (You could also just play through your campaign saving at each level.)
  
Line 61: Line 58:
 
That's all that needs to be in the [campaign] tag, so we can close it here.
 
That's all that needs to be in the [campaign] tag, so we can close it here.
  
There's more we want to do, though:  we've
+
There's more we want to do, though:  we've got to tell Wesnoth where our various
got to tell Wesnoth where our various
 
 
additional files are located (i.e. our maps, scenarios, units, images, and sounds).
 
additional files are located (i.e. our maps, scenarios, units, images, and sounds).
  
Line 71: Line 67:
 
     #enddef
 
     #enddef
  
The first thing worth noting is that the macro begins with SC_.  The SC stands for "simple_campaign", the name of our
+
The first thing worth noting is that the macro begins with SC_.  The SC stands for "simple_campaign", the name of our campaign.  It's important that you put a prefix like that in front of your macros so they don't interact badly with other user created campaigns (but only if you put the macros outside the campaign #ifdef).  We'll see how to use a macro like this later in the [[BuildingScenarios]] section.
campaign.  It's important that you
 
put a prefix like that in front of your macros so they don't interact badly with other user created campaigns (but only
 
if you put the macros outside the campaign #ifdef).  We'll see how to use a macro like this later in
 
the [[BuildingScenarios]] section.
 
  
 
You should put everything not in the [campaign] tag inside
 
You should put everything not in the [campaign] tag inside
Line 81: Line 73:
 
   ...
 
   ...
 
   #endif
 
   #endif
so that your custom macros, WML code, and inclusion of files do
+
so that your custom macros, WML code, and inclusion of files do not affect other campaigns and slow the game down.  The only exception to this is the [binary_path] tag specifying the path to custom images in your campaign, but you should only put this outside the #ifdef if you need custom images for the campaign selection menu and the difficulty selection menu.  Otherwise even this belongs inside the #ifdef.
not affect other campaigns and slow the game down.  The only exception
 
to this is the [binary_path] tag specifying the path to custom images
 
in your campaign, but you should only put this outside the #ifdef if
 
you need custom images for the campaign selection menu and the difficulty
 
selection menu.  Otherwise even this belongs inside the #ifdef.
 
  
 
More to come soon…
 
More to come soon…
Line 97: Line 84:
 
* [[BuildingCampaignsDirectoryStructure]]
 
* [[BuildingCampaignsDirectoryStructure]]
 
* [[BuildingCampaigns]]
 
* [[BuildingCampaigns]]
 

Revision as of 18:00, 25 September 2005

Each campaign must contain a WML file which contains a [campaign] tag. In order for the campaign to be translatable, it must also contain a [textdomain] tag, which should precede the [campaign] tag.

This file contains the information the game needs to find the rest of the bits of your campaign scattered in other files and put them together to have a playable campaign. Much information about this file can be found in the CampaignWML entry. What follows is a description of each line of the campaign file and an explanation of what it does.

For our purposes I'll assume we've already created a campaign called simple_campaign with the directory structure outlined in BuildingCampaignsDirectoryStructure.

The first line of the campaign file is the [textdomain] WML tag, which specifies where the game should look for translations to the strings in the campaign. The textdomain tag specifies a name for the textdomain, which is what is used in the [campaign] tag, and in f ex campaign scenarios to connect the strings with translations. The textdomain should be unique, and start with 'wesnoth-', to ensure that it does not conflict with other textdomains that might be specified on a given system. The textdomain also specifies a path to the directory where the compiled translation files will be stored. This should be a file inside the campaign directory.

Ex.

    [textdomain]
         name="wesnoth-Simple_Campaign"
         path="data/campaigns/simple_campaign/translations"
    [/textdomain]


Then follows the [campaign] WML tag that lets the game know this is a campaign:

    [campaign]

First associate the campaign with the textdomain you have just defined:

    #textdomain wesnoth-Simple_Campaign

The next group of lines uniquely identifies the campaign:

    name= _ "A Simple Campaign"
    define= CAMPAIGN_SIMPLE_CAMPAIGN


[In earlier version, there was also id which was a unique identifier used for translation, but now has no effect.]

name is the name of your campaign that the user will see. It must be in quotation marks and be preceded by an underscore to facilitate translation. define creates a key that lets the game know when a user has selected to play a scenario from your campaign. More on it in a bit. If you are missing any of these your campaign will not work correctly.

The next group gives the user information about your campaign when he selects it from the campaign menu:

    icon=a_wesnoth_icon.png
    image= simple_campaign_logo.png
    description= _ "Some text about my campaign!"

icon is a reference to any of the standard Wesnoth images. It will be displayed in the campaign selection menu.image is an image that will be displayed when a user clicks on the campaign. description is a text description that will be shown to the user at the same time as image. Note that none of these three are strictly necessary, but they do make your campaign look nice and professional.

    difficulties=EASY,NORMAL,HARD
    difficulty_descriptions={MENU_IMG_TXT2 *&neutral-peasant.png _"Civilian" _"(trivial)"} +
    ";" + {MENU_IMG_TXT2 human-spearman.png _"Soldier" _"(simple)"} +
    ";" + {MENU_IMG_TXT2 human-pikeman.png _"Veteran" _"(easy)"}

difficulties creates three definitions for three different difficulty levels. For more information on difficulty levels and balancing see BuildingCampaignsBalancing.

    first_scenario=the_first_scenario

first_scenario is a reference to the scenario id of the scenario that you intend to be loaded and played first. This line is essential. Note that while you are debugging and testing your campaign, it's often useful to change this line to the scenario you're working on so you don't have to play through all the scenarios that come before it. (You could also just play through your campaign saving at each level.)

    [/campaign]

That's all that needs to be in the [campaign] tag, so we can close it here.

There's more we want to do, though: we've got to tell Wesnoth where our various additional files are located (i.e. our maps, scenarios, units, images, and sounds).

The first bit of code we'll look at in this section is a macro definition:

    #define SC_MAP NAME
         map_data="{@campaigns/simple_campaign/maps/{NAME}}"
    #enddef

The first thing worth noting is that the macro begins with SC_. The SC stands for "simple_campaign", the name of our campaign. It's important that you put a prefix like that in front of your macros so they don't interact badly with other user created campaigns (but only if you put the macros outside the campaign #ifdef). We'll see how to use a macro like this later in the BuildingScenarios section.

You should put everything not in the [campaign] tag inside

 #ifdef CAMPAIGN_SIMPLE_CAMPAIGN
 ...
 #endif

so that your custom macros, WML code, and inclusion of files do not affect other campaigns and slow the game down. The only exception to this is the [binary_path] tag specifying the path to custom images in your campaign, but you should only put this outside the #ifdef if you need custom images for the campaign selection menu and the difficulty selection menu. Otherwise even this belongs inside the #ifdef.

More to come soon…

Next:

See Also