ddnet / ddnet

DDraceNetwork, a free cooperative platformer game
https://ddnet.org
Other
510 stars 381 forks source link

map_create_pixelart tool issue board #8345

Open AssassinTee opened 3 weeks ago

AssassinTee commented 3 weeks ago

I am currently working with the map_create_pixelart tool, which converts a pixelart (png) into quads and wanted to share issues and missing features:

Issues

No download available

While this tool is part of ddnet and can be build with make --build build --target tools, there is no download available, neither on the ddnet website (also tested nightly) or here on github. This issue is big, because most people aren't able to compile for themself.

Path length

The path of the map/image isn't long enough, I tried the following:

./ddnet-tools/map_create_pixelart.exe pixelart/img_masked/ice_mountain_12.png 1 ~/AppData/Roaming/Teeworlds/maps/JumpKingDitherTest.map 0 0 0 0 4 output-map.map 1 0

2024-05-10 17:26:12 I map_create_pixelart: image_file='pixelart/img_masked/ice_mountain_12.png'; image_pixelsize='1px'; input_map='output-map.map'; layergroup_id='#0'; layer_id='#0'; pos_x='#0px'; pos_y='0px'; quad_pixelsize='4px'; output_map='pixelart/img_masked/ice_mountain_12.png'; optimize='1'; centralize='0'
2024-05-10 17:26:12 I storage: added path '$CURRENTDIR' ('C:\Users\<USER>\Desktop\workspace\JumpKingScript')
2024-05-10 17:26:12 I datafile: could not open 'C:/Users/<USER>/AppData/Roaming/Teeworlds/maps/JumpKingDitherTe'
2024-05-10 17:26:12 I map_create_pixelart: ERROR: unable to open map 'C:/Users/<USER>/AppData/Roaming/Teeworlds/maps/JumpKingDitherTe'

As you can see, the input map is cut off. My guess, is that the number of bytes allocated for the path aren't big enough. I worked around this by copying the map in another location (with shorter path), then use the tool, then copy it back.

wrong variable repetition

As you can see above, the variables, which I entered into the script, didn't get echoed back right:

2024-05-10 17:26:12 I map_create_pixelart: image_file='pixelart/img_masked/ice_mountain_12.png'; image_pixelsize='1px'; input_map='output-map.map'; layergroup_id='#0'; layer_id='#0'; pos_x='#0px'; pos_y='0px'; quad_pixelsize='4px'; output_map='pixelart/img_masked/ice_mountain_12.png'; optimize='1'; centralize='0'

input_map is wrong output_map is echoed wrong

input map equal to output map

when input map and output map are equal, it either ends with a segmentation fault or with an empty 0 byte map. So I recommend to always do backups before doing CLI-mapping operations

(Missing) features

Add group and layer automatically

instead of needing a group and a layer, just add a group with a layer. You can still move it afterwards

Default values

this tool has 12 values and needs all for them in order to run. Add default values to most of them, all you really need is input_map, input_image, quad_pixelsize and potentially output_map. Everything else can be assumed:

No value for

layergroup_id
layer_id

assume create new instead

you can always move a group

pos_x = 0
pos_y = 0
optimize=1
centralize=0

input_map eq output_map

allow input_map and output_map to be the same in order to allow in-situ operations

Add Quadart

In the editor, you can press Tools->Add Tileart, why not add Quadart and call this tool?

Workaround

I worked around most of this issues with a custom bash script, ask me on discord if you want it


I might do a PR myself in the future if I find time

BlaiZephyr commented 3 weeks ago

this is insanely detailed and very interesting :1st_place_medal:

AssassinTee commented 3 weeks ago

@furo321 Thank you very much! This was very fast