Skip to content

Creating a Custom Card Type

Collin Heist edited this page May 14, 2022 · 3 revisions

Background

The creative process of creating a custom CardType is detailed on the Maker's wiki here. This page is instead dedicated to explaining how to modify your local custom CardType to become a remote CardType that exists on this repository (and can be used by others).

By nature of the Maker having to download and execute card types hosted on this repository, rather than them existing at runtime, there are a few specific modifications to your CardType classes required.

Assets

The main difference is how assets are referred to and stored. This primarily applies to fonts, and reference images. Since a user using a non-standard CardType will not have access to the font files and reference images (as they're not a part of the TitleCardMaker repository), these assets need to be specified as RemoteFile objects, and uploaded alongside the CardType Python file, so they can be downloaded at runtime.

The basic structure of this, in Python, is:

SOME_FILE = str(RemoteFile('MY_USERNAME', 'FILENAME.ext'))

This looks for and downloads the file at {this repository}/MY_USERNAME/FILENAME.ext. It is important to use the str() (string) of the object, because that returns the user-localized path to where that asset/file is downloaded.

Example

Take the example of my example CardType called BetterStandardTitleCard, located at CollinHeist/BetterStandardTitleCard (here). I am using a non-standard font (Comic Sans), and so I have uploaded that font file within my user folder at CollinHeist/Comic Sans MS.ttf. In order for this Card to download and use that font file, I have specified the file as such:

TITLE_FONT = str(RemoteFile('CollinHeist', 'Comic Sans MS.ttf'))

Reference Directory

If you want your CardType to utilize assets that are found within the TitleCardMaker repository (such as fonts, gradient images, etc.), then it's important to use the correct path. Once downloaded from this Repository, the card is written to /modules/.objects/, so the /modules/ref directory is determined as follows:

REF_DIRECTORY = Path(__file__).parent.parent / 'ref'

This would make the reference assets, such as the Gradient image, accessible at:

GRADIENT_IMAGE = REF_DIRECTORY / 'GRADIENT.png'
Clone this wiki locally