chilli-axe / mtg-photoshop-automation

Photoshop scripting to generate high-quality Magic card renders, inserting Scryfall data into Photoshop frame templates.
GNU General Public License v3.0
60 stars 39 forks source link

Project rewrite #28

Closed ndepaola closed 3 years ago

ndepaola commented 3 years ago

Rewrote the project from the ground up, as this was my first software project as an undergrad and I've learned a lot since then. Main focus was on separating the logic driving each template and maximising code reuse & code quality.

The Python-side code has been minimised and unpacking the Scryfall layout now takes place in layouts.jsx with a class per Scryfall layout that this project supports. Mapping layouts to templates that support that layout occurs through a something I'm calling card classes, which is a finer grained categorisation of a card's layout (e.g. transform is a layout while transform_front and transform_back are classes). Classes are mapped to templates and a default template for each class is nominated. Forcing the project to use a specific template only works if the template supports the card's class. Layouts built on the BaseLayout class come with the layer names needed for the card for free as well.

Text fields have been fleshed out and separated from template logic, and seven classes are available for minimising the boilerplate code needed for inserting text information into templates.

Templates are now built on top of a base template class which implements core functionality like setting the artist name, inserting card art, loading the template in Photoshop, etc. Text field objects are appended to this.text_layers and are automatically executed. There's a dedicated method for enabling frame layers which should be implemented by extending classes. Templates specify their filename and any suffixes that should be attached to card images produced by them (suffixes in parentheses).

The template class system is flexible enough that it has become easy to use this project as a platform for automating anyone's templates, not just mine.

Figured I'd leave this PR up for a bit before I merge in case I or someone else discovers an issue with it, but I've been testing it pretty often as I've been writing it and I'm confident it's as stable as master.