从.ods电子表格生成纸牌游戏模型
proxyprinter的Python项目详细描述
为一个纸牌游戏生成一个好看的HTML代理 ODS电子表格。用于制作纸牌游戏原型。附带一些 基本CSS;您可以添加自己的样式规则,使代理更加漂亮。 或者更适合你的游戏。做一些启发性的文本调整以便 不同长度的文本更容易在不太小的情况下适应。
使用PIP安装
(需要python 3)
pip3 install proxyprinter
(根据您的系统,您可能需要使用sudo或virtualenv 设置。)
用法
proxyprinter example-cards.ods > output_file.html
对所有命令行的usage语句执行proxyprinter --help。 选项。
输入格式
Opendocument电子表格(ODF)文件。例子: example-cards.ods。文件中的每个“表” 是游戏中的一种牌。这张纸的名字是卡片 键入。工作表的第一行列出每个字段的标题。每个 下一行是一张卡片。
以下字段名在某些方面是特殊的:
- name:您的卡的名称(位于卡的标题区域)。
- traits:用逗号分隔的卡片标签列表。每个 获取类的自身跨度,以便您可以对其进行样式设置。程序性 生成样式规则以对其进行颜色编码。
- text:与flavor text放在同一个文本区域中。
- flavor text:放在文本旁边的单个文本区域中。
- version:列在页脚中。将此与-v开关一起使用 只打印最近更新的卡片。
- 份数:如果存在非负整数,则打印 作为整个打印页一部分的卡片副本。(否则, 打印页包含此卡的一份副本。)
在样式表设置中
您可以通过添加 ProxyPrinter Settingstab到您的电子表格。(纸张必须匹配 在那个电子表格页面中,在 工作表的第一行定义该设置的自定义值:
Setting | Description | How to Set |
---|---|---|
^{tt5}$ | The filename of an external CSS file to reference. | Put the value in the 2nd row, same column |
^{tt6}$ | 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 |
对于电子表格中定义的任何设置,也可以通过 命令行参数,如果 明确规定。
文本大小阈值
代理打印机根据 里面的人物。取决于您有多少可用空间 每个字段,您可能需要调整这些阈值,以便 中文本或小文本大小,文本较少(或更多)。
要自定义文本大小阈值,请设置以下3个设置 “设置表”选项卡第一行中的名称:
- TextSizeField
- TextSizeMediumIfOver
- TextSizeSmallIfOver
在其后的每一行中,可以定义要使用的阈值。在每一排, 将值放入以下列:
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. ^{tt10}$, ^{tt11}$, ^{tt12}$, etc.) The default for all fields is represented by the field name ^{tt13}$. | Decrease from big to medium size text if the number of characters is over this number. (Defaults: 30 for most fields, 140 for ^{tt10}$, 18 for ^{tt15}$) | Decrease from medium to small size if the number of characters is over this limit. (Defaults: 50 for most fields, 220 for ^{tt10}$, 24 for ^{tt15}$.) |
任何未重新定义的默认值都将保留。任何没有 定义的阈值使用*的阈值(无论您是否定义它 或者保留默认设置)。
富场置换
要在文本中内联包含特殊样式和图像,可以定义 将映射到中特定样式的电子表格值中的模式 HTML。例如,您可以使<5 G>被替换 文本中有一个“5黄金”图标。(可能需要自定义css,共个) 课程。)
将值RichFields放入“设置表”选项卡的第一行 定义应该以这种方式处理哪些字段。彼此排成一排, 将字段的名称放在同一列中。字段名*表示 “所有字段”。默认情况下,只处理Text字段。
要定义要进行的替换,请设置以下2 “设置表”选项卡第一行中的名称:
- ProcessPatterns
- ProcessReplacements
以后的每一个行,输入以下值:
ProcessPatterns column | ProcessReplacements column |
---|---|
Regular Expression to search for in the text. Example: ^{tt25}$ | Text to replace it with. Regular-expression backreferences are allowed. Example: ^{tt26}$ |
这些替换在转义出现在 因此,如果您的模式需要匹配<或>,则必须使用 改用转义版本<和>。而且,这意味着 替换可以包括原始HTML。