resource files and dirs in campaign file
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
resource files and dirs in campaign file
Hello,
I'm not sure at all to understand how external files and dirs should be declared -- or not--; how, why, what for; and how these data are then (pre)processed, how the content of files and dirs are included or how they interact with the main config files (eg [scenario]), how the game engine copes with all that mess.
I wonder why this is so confusing. Also why it's defined apart. Why not (just an example):
?
Is there something obvious I'm not aware of?
All hints welcome (don't bother pointing to wiki).
I'm not sure at all to understand how external files and dirs should be declared -- or not--; how, why, what for; and how these data are then (pre)processed, how the content of files and dirs are included or how they interact with the main config files (eg [scenario]), how the game engine copes with all that mess.
I wonder why this is so confusing. Also why it's defined apart. Why not (just an example):
Code: Select all
[campaign]
...
[resources]
# dir containing possible pics used in campaign and difficulty menues
presentation=
[game]
# preprocessor flag used to consider this data
# (only) when campaign actually played
flag=
scenarios=
maps=
macros=
units=
images=
music=
sounds=
more=
[/game]
[/resources]
[/campaign]
Is there something obvious I'm not aware of?
All hints welcome (don't bother pointing to wiki).
Denis
life is strange
various stuff about BfW (rules, stats, alternatives) and WML (parser, semantic schema, evolution)
life is strange
various stuff about BfW (rules, stats, alternatives) and WML (parser, semantic schema, evolution)
Re: resource files and dirs in campaign file
why? that would at least answer your first questions...spir wrote:All hints welcome (don't bother pointing to wiki).
maybe because it's quite flexible the way it is?spir wrote:I wonder why this is so confusing.
- solsword
- Code Contributor
- Posts: 291
- Joined: January 12th, 2009, 10:21 pm
- Location: Santa Cruz, CA
- Contact:
Re: resource files and dirs in campaign file
Since you don't want to be pointed to the wiki, I'll quote from it:
There's one exception to this rule: if you want to use custom images, music, or sounds in your campaign, you need to tell Wesnoth where to find them. You do this by using a [binary_path] tag: this tag tells Wesnoth "hey, when you're looking for an image, music, or sound file, you'd better check this place as well as any other places that you normally look." The exception to the rule is that Wesnoth will look in the declared path for "images", "music" and "sounds" folders, named exactly that. So those folder names are necessary (and thus 'special') if you want to use custom images, music, or sounds.
The [binary_path] tag and the {~<filename>} syntax are the two ways in which you tell Wesnoth about your files. So you're free to organize things however you want. But you must put the proper macro includes into your _main.cfg file (or some other file already included by that) and if you want to use images, music, or sounds, you'll need a [binary_path] declaration that points to a folder within which you've got appropriately-named subfolders. Note that the [binary_path] tag allows images to be anywhere under the 'images' subfolder of the declared path, and the same for music and sounds, so you can nest folders recursively. However, there's no recursive include macro, and if you do nest folders, you need to refer to your image or sound by giving the rest of the relative path.
So there's nothing special about any directory inherently. It's just that the main Wesnoth configuration files point to certain directories. *But there are no default directories within a campaign*. The *only* file that Wesnoth reads in your add-on is "_main.cfg". It doesn't care what the directory structure of your campaign is, and in fact, there's no requirement that your campaign have a directory structure at all: you could just dump all of the WML files into the base directory, and tell WML to process them there. Heck, you could just put *all* of the WML for your campaign into the _main.cfg file. The reason to use folders is to keep yourself (and other people reading your campaign) sane.PreprocessorRef wrote: Wesnoth loads just one configuration file directly: data/_main.cfg. However the WML preprocessor allows game.cfg to load in more files. Whenever a WML file is read by Wesnoth, it is passed through the preprocessor.
There's one exception to this rule: if you want to use custom images, music, or sounds in your campaign, you need to tell Wesnoth where to find them. You do this by using a [binary_path] tag: this tag tells Wesnoth "hey, when you're looking for an image, music, or sound file, you'd better check this place as well as any other places that you normally look." The exception to the rule is that Wesnoth will look in the declared path for "images", "music" and "sounds" folders, named exactly that. So those folder names are necessary (and thus 'special') if you want to use custom images, music, or sounds.
The [binary_path] tag and the {~<filename>} syntax are the two ways in which you tell Wesnoth about your files. So you're free to organize things however you want. But you must put the proper macro includes into your _main.cfg file (or some other file already included by that) and if you want to use images, music, or sounds, you'll need a [binary_path] declaration that points to a folder within which you've got appropriately-named subfolders. Note that the [binary_path] tag allows images to be anywhere under the 'images' subfolder of the declared path, and the same for music and sounds, so you can nest folders recursively. However, there's no recursive include macro, and if you do nest folders, you need to refer to your image or sound by giving the rest of the relative path.
The Knights of the Silver Spire campaign.
http://www.cs.hmc.edu/~pmawhorter - my website.
Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?
http://www.cs.hmc.edu/~pmawhorter - my website.
Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?
Re: resource files and dirs in campaign file
I fully endorse the above post. I'm not sure how related it is to the topic since I'm not sure what spir was after exactly, but it's a good explanation nevertheless.
Re: resource files and dirs in campaign file
Thank you very much, solsword.
Well, I find this basically complicated anyway, and I wonder whether we could do something else. Either at the preprocessor and engine levels (I understand the need for a preprocessor flag). Or by reforming the expected WML syntax. See my example above. First of all, I would enjoy having the flag set inside [campaign], like the one for the difficulty levels. And the rest too, why not? The campaign main config must have been read anyway, so why not define resource locations there?
Well, I needed a clear, precise, complete explanation of the topic, thus the bunch of questions. That's what solsword gave, thank s again. I will try to digest this and maybe improve the related wiki page(s) if I feel bold enough .I fully endorse the above post. I'm not sure how related it is to the topic since I'm not sure what spir was after exactly, but it's a good explanation nevertheless.
Well, I find this basically complicated anyway, and I wonder whether we could do something else. Either at the preprocessor and engine levels (I understand the need for a preprocessor flag). Or by reforming the expected WML syntax. See my example above. First of all, I would enjoy having the flag set inside [campaign], like the one for the difficulty levels. And the rest too, why not? The campaign main config must have been read anyway, so why not define resource locations there?
Denis
life is strange
various stuff about BfW (rules, stats, alternatives) and WML (parser, semantic schema, evolution)
life is strange
various stuff about BfW (rules, stats, alternatives) and WML (parser, semantic schema, evolution)
Re: resource files and dirs in campaign file
the preprocessor is called so for a reason - it doesn't know about tags...
- solsword
- Code Contributor
- Posts: 291
- Joined: January 12th, 2009, 10:21 pm
- Location: Santa Cruz, CA
- Contact:
Re: resource files and dirs in campaign file
Please do improve the wiki pages if you're up for it. We all know that they can use some work.spir wrote: Well, I needed a clear, precise, complete explanation of the topic, thus the bunch of questions. That's what solsword gave, thank s again. I will try to digest this and maybe improve the related wiki page(s) if I feel bold enough .
Hmm... I think that it's rather a matter of how they are presented in the wiki. I find the current setup to be extremely simple and clear, once you understand it. Basically, the preprocessor goes around pasting together files like you tell it to, until it has collected the giant, ultimate hairball containing all of the WML for everything. Then it passes that to Wesnoth. The one caveat that I pointed out is that things like images and music are found at run-time, so there's a WML tag for helping find those, as opposed to just including them via the preprocessor. But the WML tag is pretty simple in its functionality: it adds to the search path, and since all references are relative anyways, it's clear what's going on (at least to me).spir wrote: Well, I find this basically complicated anyway, and I wonder whether we could do something else. Either at the preprocessor and engine levels (I understand the need for a preprocessor flag). Or by reforming the expected WML syntax. See my example above. First of all, I would enjoy having the flag set inside [campaign], like the one for the difficulty levels. And the rest too, why not? The campaign main config must have been read anyway, so why not define resource locations there?
One thing about resource locations is that they're optional. You don't actually need to have a scenarios directory at all, so making them part of the [campaign] tag would restrict things. Also note that the current preprocessor include strategy works (and is used for) things other than campaigns, like eras, and in fact any sort of add-on. That's one good reason not to make resource declarations part of any specific tag, like [campaign], and it's the reason that the [binary_path] tag exists separately from the [campaign] tag.
The Knights of the Silver Spire campaign.
http://www.cs.hmc.edu/~pmawhorter - my website.
Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?
http://www.cs.hmc.edu/~pmawhorter - my website.
Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?