Skip to content

Commit 7052b57

Browse files
committed
add base url and docs updates
1 parent ac8bf69 commit 7052b57

File tree

4 files changed

+53
-12
lines changed

4 files changed

+53
-12
lines changed

README.md

+25-7
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ Proxy Printer
44
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.
55

66

7-
Installing with pip
7+
Installing (Python 3 required)
88
------
99

10-
(Python 3 required)
11-
1210
```
13-
pip3 install proxyprinter
11+
pip install proxyprinter
1412
```
1513

16-
(You might need to use `sudo` or a VirtualEnv depending on your system setup.)
14+
(You might need to use a VirtualEnv depending on your system.)
1715

1816

1917
Usage
@@ -23,6 +21,12 @@ Usage
2321

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

24+
There's also an (experimental) GUI, which you can run as:
25+
26+
proxyprintergui
27+
28+
The GUI provides access to most settings although currently it doesn't let you save them for later.
29+
2630

2731
Input Format
2832
-------------
@@ -47,12 +51,13 @@ You can customize various settings for your project by adding a `ProxyPrinter Se
4751
|------------|-------------|------------|
4852
| `CSSFile` | The filename of an external CSS file to reference. | Put the value in the **2nd row**, same column |
4953
| `Copyright` | The copyright owner to print at the bottom of the cards. | Put the value in the **2nd row**, same column |
54+
| `BaseURL` | The base URL for images to use when making Tabletop Simulator exports, e.g. `https://example.com/some/folders/`. | Put the value in the **2nd row**, same column |
5055
| Text Size Thresholds | Downsize text when it exceeds length thresholds. | [Text Size Thresholds](#text-size-thresholds) |
5156
| Rich Field Substitution | Substitution patterns to embed special styles or symbols in field text | [Rich Field Substitutions](#rich-field-substitutions) |
5257

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

55-
### Text Size Thresholds ###
60+
### Text Size Thresholds
5661

5762
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.
5863

@@ -71,7 +76,7 @@ In each row after it, you can define a threshold to use. In each row, put the v
7176
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).
7277

7378

74-
### Rich Field Substitutions ###
79+
### Rich Field Substitutions
7580

7681
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.)
7782

@@ -89,3 +94,16 @@ In each later row, put the following values:
8994
| [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>` |
9095

9196
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.
97+
98+
99+
Tabletop Simulator Export
100+
-------------------------
101+
102+
TTS export is experimental/janky, but the tool _can_ create a zip file with images and JSON files you can then use to import a page of cards into [Tabletop Simulator](https://store.steampowered.com/app/286160/Tabletop_Simulator/) for playing online.
103+
104+
1. Set the `BaseURL` in your sheet to the path at a website where you can upload image files
105+
2. Build the proxy sheet HTML file using these tools
106+
3. Load the proxy sheet _from a web server_. It won't work if you access it using a `file://` URL (something about HTML5 Canvas security settings). You can use `python -m http.server` from the folder you wrote the output to
107+
4. Click the "Make ZIP" button (at the end of the card list) and wait. It might take a while and scroll the page a bit before starting a zip file download
108+
5. Extract the zip and upload the images to the site you set in the Base URL. Optionally add a `back.jpeg` image depicting the card back to use
109+
6. Move the JSON file from the zip to your Tabletop Simulator's saved objects folder. Open TTS and load the file as a saved object. It might take a few moments to load all the card images

proxyprinter/gui.py

+10
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ def __init__(self):
6060
setting_2.addWidget(lbl_css)
6161
setting_2.addWidget(self.css_file)
6262
lo_sb.addLayout(setting_2)
63+
64+
setting_3 = QtWidgets.QHBoxLayout()
65+
lbl_baseurl = QtWidgets.QLabel("Base URL (for TTS images)")
66+
self.base_url = QtWidgets.QLineEdit("", self)
67+
lbl_baseurl.setBuddy(self.base_url)
68+
setting_3.addWidget(lbl_baseurl)
69+
setting_3.addWidget(self.base_url)
70+
lo_sb.addLayout(setting_3)
71+
6372
self.toggles = []
6473
for tog in ("Include default CSS", "Colorize Traits", "Add Zip button for Tabletop Simulator export"):
6574
btn_tog = QtWidgets.QCheckBox(tog, self)
@@ -174,6 +183,7 @@ def read_settings(self):
174183
"""
175184
self.sheet_settings.copyowner = self.copyright.text()
176185
self.sheet_settings.addcss = self.css_file.text()
186+
self.sheet_settings.base_url = self.base_url.text()
177187

178188
self.sheet_settings.defaultcss = self.toggles[0].isChecked()
179189
self.sheet_settings.colorize = self.toggles[1].isChecked()

proxyprinter/proxyprinter.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
SETTING_LABEL_RICHFIELDS = "RichFields"
4646
SETTING_LABEL_PROCESSPATTERNS = "ProcessPatterns"
4747
SETTING_LABEL_PROCESSREPLACEMENTS = "ProcessReplacements"
48+
SETTING_LABEL_BASEURL = "BaseURL"
4849

4950

5051
#Set up logging
@@ -285,7 +286,7 @@ def html(self):
285286
class ProxyPrinter:
286287
def __init__(self, spreadsheet, copyowner=None, version=None, addcss=None,
287288
defaultcss=True, text_subs={}, colorize=True, rich_fields=[],
288-
addzipbutton=True, size_thresholds={}):
289+
addzipbutton=True, size_thresholds={}, base_url=""):
289290
self.read_sheet(spreadsheet)
290291
self.copyowner = copyowner
291292
self.version = version
@@ -296,6 +297,7 @@ def __init__(self, spreadsheet, copyowner=None, version=None, addcss=None,
296297
self.rich_fields = rich_fields
297298
self.addzipbutton = addzipbutton
298299
self.size_thresholds = size_thresholds
300+
self.base_url = base_url
299301
self.counter = CardCounter()
300302

301303
self.parse_settings()
@@ -412,6 +414,16 @@ def parse_settings(self):
412414
repl = row[pos_processreplacements]
413415
text_subs[pattern] = repl
414416
self.text_subs = text_subs
417+
418+
if not self.base_url:
419+
try:
420+
self.base_url = setting_simple_values[
421+
setting_keys.index(SETTING_LABEL_BASEURL)]
422+
if self.base_url and self.base_url[-1:] != "/":
423+
self.base_url = self.base_url + "/"
424+
except ValueError:
425+
logger.info("Failed to get Base URL from settings")
426+
415427

416428
def parse_sheet_cards(self):
417429
self.cards = []
@@ -484,7 +496,7 @@ def render_all(self):
484496
s += "</body></html>"
485497
return s
486498

487-
def tts(self, url_base="http://localhost/proxyprinter/tts/"): #TODO: url_base
499+
def tts(self): #TODO: base_url
488500
DEFAULT_TRANSFORM = {
489501
"posX": 0,
490502
"posY": 0,
@@ -512,8 +524,8 @@ def tts(self, url_base="http://localhost/proxyprinter/tts/"): #TODO: url_base
512524
})
513525
deck_ids.append(c_id*100)
514526
custom_deck[str(c_id)] = {
515-
"FaceURL": url_base+str(c_id)+".jpg",
516-
"BackURL": "https://mduo13.com/stuff/back.jpg",
527+
"FaceURL": self.base_url+str(c_id)+".jpg",
528+
"BackURL": self.base_url+"back.jpg",
517529
"NumHeight": 1,
518530
"NumWidth": 1,
519531
"BackIsHidden": True
@@ -546,6 +558,7 @@ def __init__(self, spreadsheet):
546558
self.rich_fields = []
547559
self.addzipbutton = True
548560
self.size_thresholds = {}
561+
self.base_url = ""
549562

550563
self.read_sheet(spreadsheet)
551564
self.parse_settings()

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
setup(
1111
name='proxyprinter',
12-
version='0.4.0-a27',
12+
version='0.4.0-a29',
1313
description='Generate card game mockups from .ods spreadsheets',
1414
long_description=long_description,
1515
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)