Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trackplacer3 a utility to export and import tmx files (#4365) #4464

Merged
merged 1 commit into from Nov 14, 2019

Conversation

@stevecotton
Copy link
Contributor

stevecotton commented Oct 14, 2019

The python2 trackplacer included both the handling of the file format, and the
GUI application. This trackplacer3 is a library for the file format, without
the GUI.

The tmx_trackplacer is a command-line tool for exporting the data to Tiled's
.tmx format, and re-importing it back to .cfg files, so that the GUI of Tiled
can be used to avoid reimplementing the GUI of Trackplacer in Python 3.

The implementation uses Tiled's Object Layers (not Tile Layers). This allows
additional journey markers to be added with the "Insert Tile" tool, and
additional journeys to be added as new layers.

It can also read in a .cfg and then re-export it to a new .cfg file, to see if
the data is preserved. The format is chosen by the output filename.

----- Comments on the mainline campaigns: -----

AToTB, DM, LoW, NR and THoT will work with this. But:

Northern Rebirth's bigmap.cfg has a track RECOVERY whose STAGE1 starts with
an OLD_REST - that isn't handled by trackplacer, it must have been hand-edited.
That OLD_REST will be lost when read by either trackplacer2 or trackplacer3,
similarly the OLD_BATTLE of LoW's SAURIANS track will be lost.

Delfador's Memoirs SEARCH_STAGE1 is omitted from all subsequent parts of
SEARCH. Also in DM, SEARCH_STAGE3 has a point which is then moved in STAGE4
onwards - I guess a hand edit. Both of this will be overwritten if the file
is edited with either this tool or with the python2 trackplacer.

SotA's journey_chapter*.cfg files and WoV's bigmap.cfg file have some of the
trackplacer comments removed, they won't be handled by this tool, at least not
until better error handling is added.

@stevecotton stevecotton force-pushed the stevecotton:trackplacer3 branch from da906f4 to 09c1ec0 Oct 16, 2019
@stevecotton

This comment has been minimized.

Copy link
Contributor Author

stevecotton commented Oct 16, 2019

=== Usage ===

Assume the campaign that we want to make a map for is Story of Wose, which is set on the Green Isle.

Start by putting a copy of the map in the campaign:

mkdir Story_of_Wose/images/maps
cp WESNOTH_DIR/data/campaigns/The_Rise_Of_Wesnoth/images/maps/green_isle.png Story_of_Wose/images/maps/

Create a template .tmx file with the tool:

WESNOTH_DIR/data/tools/tmx_trackplacer Story_of_Wose/images/maps/green_isle.png -o temp.tmx

=== In Tiled ===

You'll need Tiled, a GPLv2 map editor:

  • Debian / Ubuntu: install the "tiled" package
  • other platforms: https://www.mapeditor.org/
  • these instructions were written with version 1.2.4

Start Tiled with the temp.tmx file. Expect to see the Green Isle map. On the right hand side of the screen there should be two windows:

  • in the top, tabs "Minimap, Objects, Layers". The Layers tab will have only "background".
  • in the bottom, tabs "Terrains, Tilesets". The Tilesets tab should have "wesnoth journey icons" with the red dot, battle and rest markers.
    welcome to tiled

In Layers, create a "New Layer" of type "Object Layer". A typical name for this layer is JOURNEY. Ensure that this layer is selected.
From the menu bar at the top, select "Insert Tile".
From the Tilesets tab, choose dots, battles or rests, and click on the map to add them. The first two items placed will define the start of the journey; every item placed after the first two will be inserted in to the sequence based on whether it appears to be at the end or in the middle.

For Story of Wose, the journey doubles back on itself. For this we'll split the journey in to two parts - rename JOURNEY to JOURNEY_PART1, and add a new layer JOURNEY_PART2. You can use the opacity control at the top of the layers window to see what's on each layer.

JOURNEY_PART1 starts with a battle, and ends with a battle:
journey part1

JOURNEY_PART2 starts with dots, has a battle and then ends with another battle:
journey part2

Save the .tmx file.

=== Creating the .cfg ===

Convert the .tmx file to a .cfg file:

WESNOTH_DIR/data/tools/tmx_trackplacer temp.tmx -o Story_of_Wose/utils/bigmap.cfg

Expect to see:

Read data: <Journey based on map file 'Story_of_Wose/images/maps/green_isle.png', with tracks {JOURNEY_PART1,JOURNEY_PART2}>
Exporting as cfg

For testing, let's put all of the journey in at the start of the first scenario, Story_of_Wose/scenarios/1_The_Oldwood.cfg

#define STORY_BACKGROUND
	[background_layer]
		image=maps/background.jpg
		scale_vertically=yes
		scale_horizontally=no
		keep_aspect_ratio=yes
	[/background_layer]
	[background_layer]
		image=maps/green_isle.png
		scale_vertically=yes
		scale_horizontally=no
		keep_aspect_ratio=yes
		base_layer=yes
	[/background_layer]
#enddef

[story]
    [part]
        {STORY_BACKGROUND}
        {JOURNEY_PART1_STAGE1}
    [/part]
    [part]
        {STORY_BACKGROUND}
        {JOURNEY_PART1_STAGE2}
    [/part]
    [part]
        {STORY_BACKGROUND}
        {JOURNEY_PART1_COMPLETE}
        {JOURNEY_PART2_STAGE1}
    [/part]
    [part]
        {STORY_BACKGROUND}
        {JOURNEY_PART1_COMPLETE}
        {JOURNEY_PART2_STAGE2}
    [/part]
    [part]
        story= _ "Today I want to tell you another story, a mere footnote in the history books if it is even remembered at all."

This should now show at the start of the campaign. Remember to refresh Wesnoth's cache if it doesn't appear.

=== Could this be integrated as a Tiled plugin? ===

Yes it could. Implementing it as a file converter was the easier option for development, and the code is (hopefully) modular enough for reuse.

The python2 trackplacer included both the handling of the file format, and the
GUI application. This trackplacer3 is a library for the file format, without
the GUI.

The new tmx_trackplacer is a command-line tool for exporting the data to
Tiled's .tmx format, and re-importing it back to .cfg files, so that the GUI of
Tiled can be used to avoid reimplementing the GUI of Trackplacer in Python 3.

The implementation uses Tiled's Object Layers (not Tile Layers).  This allows
additional journey markers to be added with the "Insert Tile" tool, and
additional journeys to be added as new layers.

It can also read in a .cfg and then re-export it to a new .cfg file, to see if
the data is preserved. The format is chosen by the output filename.

The old trackplacer2 isn't removed in this commit - before removing it, I think
trackplacer3 needs some way to preview the animation.

----- Comments on the mainline campaigns: -----

AToTB, DM, LoW, NR and THoT will work with this. But:

Northern Rebirth's bigmap.cfg has a track RECOVERY whose STAGE1 starts with
an OLD_REST - that isn't handled by trackplacer, it must have been hand-edited.
That OLD_REST will be lost when read by either trackplacer2 or trackplacer3,
similarly the OLD_BATTLE of LoW's SAURIANS track will be lost.

Delfador's Memoirs SEARCH_STAGE1 is omitted from all subsequent parts of
SEARCH. Also in DM, SEARCH_STAGE3 has a point which is then moved in STAGE4
onwards - I guess a hand edit. Both of this will be overwritten if the file
is edited with either this tool or with the python2 trackplacer.

SotA's journey_chapter*.cfg files and WoV's bigmap.cfg file have some of the
trackplacer comments removed, they won't be handled by this tool, at least not
until better error handling is added.
@stevecotton stevecotton force-pushed the stevecotton:trackplacer3 branch from 09c1ec0 to 3a8dc9c Nov 14, 2019
@stevecotton stevecotton merged commit 3a8dc9c into wesnoth:master Nov 14, 2019
0 of 2 checks passed
0 of 2 checks passed
Travis CI - Pull Request Build Errored
Details
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.