Skip to content

Commit

Permalink
Custom settings from spreadsheet for text sizing, replacements, copyr…
Browse files Browse the repository at this point in the history
…ight, css file
  • Loading branch information
mDuo13 committed May 2, 2016
1 parent 222091c commit 3d47e01
Show file tree
Hide file tree
Showing 4 changed files with 307 additions and 67 deletions.
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Proxy Printer
=============

Generates reasonbly good-looking 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.
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.


Setup
Expand All @@ -25,7 +25,60 @@ OpenDocument Spreadsheet (ODF) file. Example: [cards.ods](cards.ods). Each "Shee
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.
- **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.


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](#text-size-thresholds) |
| Rich Field Substitution | Substitution patterns to embed special styles or symbols in field text | [Rich Field Substitutions](#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](https://docs.python.org/3/library/re.html) 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.
Binary file modified cards.ods
Binary file not shown.
6 changes: 3 additions & 3 deletions proxyprinter.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ body {
margin-top: 0.06in;
}

.text_area.bigtext {
.bigtext {
font-size: 0.18in;
}
.text_area.mediumtext {
.mediumtext {
font-size: 0.14in;
}
.text_area.smalltext {
.smalltext {
font-size: 0.10in;
}
Loading

0 comments on commit 3d47e01

Please sign in to comment.