Refactor map loading & add support for variants #1179
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds support for map variants in the xml:
Why?
This is a tool to simplify map management for mapdevs, currently if they have slightly different versions of the maps they need to be copy-pasting them and keeping different folders up-to-date, even later on when changes are made. This isn't a great experience.
How do variants work?
Essentially the xml sample above, will load this as if it was 4 different maps:
Map Name
,Map Name: 5v5
,Map Name: TE
andSpooky Map Name
.If you /maps, they're 4 different maps, same for /setnext, or any other pgm command that takes maps in. It was designed this way to avoid as most breakage as possible, anything relying on map names or map ids/slugs will still be able to use those systems, as the name + variant will be the new slug.
What features do variants enable?
if
,unless
, they will enable certain blocks of XML being added or not, depending on the variantconstant
allows you to define text constants, which get replaced in any xml text along the xml in any text that has${constant-name}
. This is useful to replace text in attributes conditionally without needing to re-define sometimes large portions of XML just to change one value.Note: the constants are NOT necessarily tied to variants, you CAN use constants in your xml without variants. This can prove useful for includes. example:
Include:
Your map:
In this example the include defines the team (it is assumed that the rest of the include would use the team id etc). Now your map can simply override the team color & name for a team, without breaking or needing to have parts of the include in your own XML.
Other changes
This PR also adds changes to how git map sources/factories load stuff, this simplifies the codebase around that and should also make adding map url display in /map easier (see #1178 )
Future work (for future PRs)