Skip to main content

Generate card game mockups from .ods spreadsheets

Project description

Proxy Printer

Generates reasonably good-looking HTML proxies for a card game from an ODS spreadsheet. Useful for making card game prototypes. Comes with some basic CSS; you can add your own style rules to make the proxies prettier or better suited to your game. Does some heuristic text resizing so that text of different lengths is more likely to fit without being too small.

Installing with pip

(Python 3 required)

pip3 install proxyprinter

(You might need to use sudo or a VirtualEnv depending on your system setup.)

Usage

 proxyprinter example-cards.ods > output_file.html

Do proxyprinter --help for usage statement with all commandline options.

Input Format

OpenDocument Spreadsheet (ODF) file. Example: example-cards.ods. Each "Sheet" in the document is one type of card in your game. The name of the sheet is the card type. The first row in the sheet lists the titles for each field. Each subsequent row is a card.

The following field names are special in some way:

  • Name: The name of your card (goes in the title area of the card).
  • Traits: A comma-separated list of tags/labels for the card. Each gets its own span with a class so you can style it. Procedurally generates style rules to color-code these.
  • Text: Gets put in a single text_area alongside Flavor Text.
  • Flavor Text: Gets put in a single text_area alongside Text.
  • Version: Listed in the footer. Use this with the -v switch to only print recently-updated cards.
  • Copies: If present and a non-negative integer, prints that many copies of the card as part of the overall print sheet. (Otherwise, the print sheet contains 1 copy of this card.)

In-Stylesheet Settings

You can customize various settings for your project by adding a ProxyPrinter Settings tab to your spreadsheet. (The sheet must match that name exactly.) In that spreadsheet page, put a setting name in the first row of the sheet to define a custom value for that setting:

Setting Description How to Set
CSSFile The filename of an external CSS file to reference. Put the value in the 2nd row, same column
Copyright The copyright owner to print at the bottom of the cards. Put the value in the 2nd row, same column
Text Size Thresholds Downsize text when it exceeds length thresholds. Text Size Thresholds
Rich Field Substitution Substitution patterns to embed special styles or symbols in field text Rich Field Substitutions

For any setting defined in the spreadsheet that can also be set by commandline parameter, the commandline parameter overrides it if specified.

Text Size Thresholds

The Proxy Printer sizes down text for most fields based on the number of characters in it. Depending on how much space you have available for each field, you may need to adjust these thresholds, so that it goes down to medium or small text sizes with less (or more) text.

To customize the text sizing thresholds, put the following 3 setting names in the first row of your settings sheet tab:

  • TextSizeField
  • TextSizeMediumIfOver
  • TextSizeSmallIfOver

In each row after it, you can define a threshold to use. In each row, put the values in the columns as follows:

TextSizeField column TextSizeMediumIfOver TextSizeSmallIfOver
Name of the field these thresholds apply to. (Each "Field" is a column from one of the card pages in your spreadsheet, e.g. Text, Flavor Text, Cost, etc.) The default for all fields is represented by the field name *. Decrease from big to medium size text if the number of characters is over this number. (Defaults: 30 for most fields, 140 for Text, 18 for Name) Decrease from medium to small size if the number of characters is over this limit. (Defaults: 50 for most fields, 220 for Text, 24 for Name.)

Any default values you don't redefine remain. Any fields that don't have thresholds defined use the thresholds for * (whether you defined it or left it default).

Rich Field Substitutions

To include special styles and images inline in your text, you can define patterns from the spreadsheet values that will map to specific styles in the HTML. For example, you can make it so that <5 G> gets replaced with a "5 Gold" icon in the text. (Custom CSS may be necessary, of course.)

Put the value RichFields in the first row of your settings sheet tab to define which fields should get processed this way. In each other row, put the name of a field in the same column. The field name * means "all fields". By default, only the Text field is processed.

To do define which substitutions to make, put the following 2 setting names in the first row of your settings sheet tab:

  • ProcessPatterns
  • ProcessReplacements

In each later row, put the following values:

ProcessPatterns column ProcessReplacements column
Regular Expression to search for in the text. Example: \<([0-9]+) G\> Text to replace it with. Regular-expression backreferences are allowed. Example: <span class='gold_coin'>\1</span>

These substitutions apply after escaping any HTML that appears in the text, so if your pattern needs to match < or >, you must use the escaped versions &lt; and &gt; instead. Also, this means your substitutions can include raw HTML.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

proxyprinter-0.3.2.tar.gz (11.9 kB view details)

Uploaded Source

File details

Details for the file proxyprinter-0.3.2.tar.gz.

File metadata

  • Download URL: proxyprinter-0.3.2.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for proxyprinter-0.3.2.tar.gz
Algorithm Hash digest
SHA256 04c60a4c8576cdf2bf41cfebd4d5aa2d9bfb8126d9317c43800c7b164a27e600
MD5 059a942df95bd26f7aed19f88b64adfa
BLAKE2b-256 eeaa2ef25fdb4a224b407b0570a01004a9186a16ef4a347474f8cb64d89247c2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page