citymania-org / grf-py

A Python framework for making NewGRFs for OpenTTD
GNU General Public License v2.0
15 stars 5 forks source link

Add support for compiling & decompiling the "layout" property #12

Closed ahyangyi closed 12 months ago

ahyangyi commented 1 year ago

Hi,

I am trying to add industry layouts, and the first step was to decompile FIRS for studying, and apparently the existing decompilation flattened the list of list into a list.

I'll add more stuff about industry layouts in this branch if I have time, but I think this bug fix itself is also pretty clear.

ahyangyi commented 1 year ago

I think I begin to understand the various todos and here is a preliminary implementation.

ahyangyi commented 1 year ago

@ldpl I think this PR is ready for review; the OldIndustryTile and NewIndustryTIle have both been working in my testing.

ahyangyi commented 1 year ago

Sample code that uses this layout property: https://github.com/ahyangyi/openttd-newgrfs/blob/main/industry/industries/forest/__init__.py

(make aegis to build that GRF, and set industry size to "enormous" to see that the functionality is working clearly -- you can't miss those 16x16 tile forests :P )

ldpl commented 12 months ago

Sorry for the delay. I decided to implement this one myself with property class. Didn't quite finish it yet so no encoding but I'll get to it eventually.

ldpl commented 12 months ago

I've added encoding support. Simple example can be found here: https://github.com/citymania-org/grf-py/blob/345d26a33775015728ca6df517fc14aa1ce47c4b/examples/industry_simple.py#L147-L157