-
Notifications
You must be signed in to change notification settings - Fork 2
ProxyGenerator
Documentation is in the process of being streamlined.
Status:
Missing some small explanations but should be complete.
The proxy generator.
- Overview
-
Block Elements
2.1. Location element
2.2. Text element
2.3. Border element
2.4. Wordwrap element -
Templates
3.1 Template element
3.2 Template matching
3.2.1 Matches element
3.2.2 Match element
3.3 Overlayblocks element
3.4 Textblocks element
3.5 Link element
3.5.1 Property element
3.5.2 Linebreak characters
3.6 Conditional element
3.6.1 If structure
3.6.1.1 If element
3.6.1.2 ElseIf element
3.6.1.3 Else element
3.6.2 Switch structure
3.6.2.1 Switch element
3.6.2.2 Case element
3.6.2.3 Default element
3.6.3 Value constants - Example XML
<templates>
-
<blocks>
-
<template>
##Overview
This is an option that can be used for definitions to generator mock cards with actual card data. I will try and explain how it is used.
Starting with the basic xml layout and then explaining the different tags in detail.
The basic framework:
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<blocks>
<block type="" id="" >
<location x="" y="" />
</block>
</blocks>
<template src="" >
<matches>
<match name="" value="" />
</matches>
<overlayblocks>
</overlayblocks>
<textblocks>
</textblocks>
</template>
</templates>
Template are made up of various blocks which can then be linked in any number of templates. For example you can have a default location of the card name. You define it once and then link it in the template you want to use.
Table of contents
##Block elements
Currently block elements have a few attributes of which most are mandatory and some are optional depending on the type of block defined.
Attributes:
- type Mandatory attribute. This defines what sort of block it is. Can only be set to overlay or text. Overlay blocks are used for constructing an image made of various parts. And the text blocks are used to define where on the image you want text to appear.
- id Mandatory attribute. This is the id to be used for linking it in various templates. Has be be a unique id not used in any other blocks.
-
src Optional attribute. This is only used if type is set to overlay. It should contain a relative path to the image file you want to use in constructing the card.
Overlay block:
<block type="overlay" id="overlay1" src="path/to/image">
Text block:
<block type="text" id="textblock1">
block elements can have various sub elements defining where they should be placed and for text blocks you can also define the text color, a rectangle to be used with word wrap and a border to be drawn around the text in a different color to improve readability.
The elements are:
- location Mandatory element. Where the block should be placed.
- text Optional element. What color the text should be and what font size.
- border Optional element. Draw a border around the text with a specified color and thickness.
- wordwrap Optional element. Define a rectangle of a specified height and width to apply word wrapping in.
Now to describe the elements used in blocks in detail.
###Location element Attributes:
- x Mandatory attribute. The placement of the block on the x axis.
- y Mandatory attribute. The placement of the block on the y axis.
- rotate Optional attribute. The amount of degrees to rotate the text.(0-359) Note: does not work with wordwrap.
- altrotate Optional attribute. Use an alternate rotate algorithm True or False. Defaults to False.
- flip Optional attribute. Flip the text True or False. Defaults to False.
<location x="0" y="0" rotate="0" altrotate="False" flip="False" />
NOTE: for artoverlay location elements, only x and y are used.
###Size element Attributes:
- height Mandatory attribute. The placement of the block on the x axis.
- width Mandatory attribute. The placement of the block on the y axis.
<size height="50" width="75" />
###Text element
Attributes:
- color Mandatory attribute. The color of the text in a html color format. The # at start of the color code is mandatory.
- size Mandatory attribute. The size of the font in em.
- font Optional attribute. Relative path to a font file.
<text color="#FFFFFF" size="12" font="relative/path/to/fontfile" />
###Border element
Attributes:
- color Mandatory attribute. The color of the border to be drawn around the text in html color format. The # at the start of the color code is mandatory.
- size Mandatory attribute. The size in pixels of the border to be drawn.
<border color="#000000" size="2" />
###Wordwrap element
Attributes:
- height Mandatory attribute. The height of the rectangle to word wrap in.
- width Mandatory attribute. The width of the rectangle to word wrap in.
- align Optional attribute. Horizontal text alignment. Options: near, center, far. Defaults to: near
- valign Optional attribute. Vertical text alignment. Options: near, center, far. Defaults to: near
- shrinktofit Optional attribute. Resize the text to fit the wordwrap box. Options: True, False. Defaults to False.
<wordwrap height="150" width="300" align="near" valign="near" shrinktofit="False" />
Note: The shrink to fit option does an approximation of a fitting size based on the dimensions of the wordwrap you defined. It wont be perfect but it should fit your box.
If your text still overflows your defined dimensions look into either increasing the size of the wordwrap and/or using bigger images since it will not shrink lower than 6 in font size to prevent unreadability.
Table of contents
##Templates
A template defines how all the various blocks are placed on a card both for images that get merged into one and the various text that should be used by a specific template. Also which template should be used based on rules you define for the selection.
The template to be used can consist of the base image defined in the template element src attribute, but can also have any number of other images added to it as overlays. For overlays to be used in a template the corresponding blocks with the images and locations have to be linked to the template in a overlayblocks element using the link element.
###Template element
Attributes:
- src Mandatory attribute. The relative path to the base template image.
- default Optional attribute. Its set to False by default. Adding it with True is required on a single template to be used a fallback should no matching templates be found when searching.
<template src="path/to/image" default="True">
###Template matching
Templates are matched on predefined values of certain properties which are declared in match elements. These match elements should always be nested in a single matches element.
There is no limit on the amount of match elements you can use for matching a card to a template.
####Matches element The matches element has no attributes and can only contain match elements.
<matches>
<match name="propertyName" value="propertyValue" />
</matches>
####Match element
Attributes:
- name Mandatory attribute. The case sensitive name of the card property to check for a value.
- value Mandatory attribute. The case sensitive value of the card property.
<match name="propertyName" value="thepropertyValue" />
NOTE: you can match to custom card sizes by using "CardSizeName", "CardSizeHeight", or "CardSizeWidth" for the name attribute.
###Overlayblocks element
Overlayblocks contains the various Link element and/or Conditional element to include images to be overlayed on the based template image.
The Link elements that are included should only link to Block Elements that are linking to images.
There is no limit on the amount of elements that can be placed here.
<overlayblocks>
</overlayblocks>
###Textblocks element
Textblocks contains the various Link element and/or Conditional element to include text blocks to be placed on the card.
The Link elements that are included should only link to Block Elements that are used for placing and formatting text.
There is no limit on the amount of elements that can be placed here.
<textblocks>
</textblocks>
###Link element
Attributes:
- block Mandatory attribute. The case sensitive id you assigned to the block you want to link here.
- separator Optional attribute. This property is used for text blocks which require various properties to be separated. Defined in this attribute is a string sequence that will be used as the glue for it.
<link block="overlay1" separator=" - " />
The text is printed on the image after the overlays are merged into the base image. It uses the same link element as overlays uses but with a sub element name property for getting the right properties printed to the defined locations. You can put multiple Property element under a single link element to have them separated with each other. The default separator is a single spacebar but if defined on the separator attribute of the Link element element it will use that instead.
####Property element
Attributes:
- name Mandatory attribute. The case sensitive card property to be printed here.
- format Optional attribute. Define how you want to format the property with optional text beside/around it. Defaults to "{}"
<property name="Name" format="{}" />
Note: format places the property in the location of the {} in the format attribute. format attributes that do not have the {} in them get ignored.
###Artoverlay element
The art overlay is a specialized overlayBlock which displays the art crop for the card. Art crops are images, typically the card's artwork, which are placed over the proxy image to provide a more realistic looking proxy card. Art crop images are stored in the /Cards/Crops in the imageDatabase's SetGUID folder.
Artoverlay has no attributes, and contains the Location element and Size element as children elements. Location is the top-left coordinate of where the image starts, and Size defines the height and width of the art box. The image will stretch to fit within the specified dimensions.
####Linebreak characters Linebreak character from property data:
or 

Linebreak characters for in the format attribute:
\r\n
###Conditional element
A conditional element can be used to add link elements to overlays or textblocks based on certain conditions.
And comes in two flavors namely the If structure and the Switch structure.
You can only have 1 of either defined in a conditional element but you can add as many conditional elements as you want.
Notes:
Conditional elements or its various sub elements cannot be nested in each other.
####If structure Basic structure:
<conditional>
<if property="propertyname" value="propertyvalue">
<link block="block" />
</if>
<elseif property="propertyname" value="propertvalue">
<link block="block" />
</elseif>
<else>
<link block="block" />
</else>
</conditional>
####If element
An if element can have any number of link elements nested in it. And you need to define either the value or contains attribute. Only use one or the other at a time.
Attributes:
- property Mandatory attribute. The name of the property to be used.
- value Optional attribute. The value to be matched exactly.
- contains Optional attribute. The value to be checked for presence in the property.(partial match)
<if property="propertyname" value="propertyvalue">
<link block="block" />
</if>
<if property="propertyname" contains="partialvalue">
<link block="block" />
</if>
####ElseIf element
The elseif element is the same as the If element but can be repeated any number of times.
<elseif property="propertyname" value="propertvalue">
<link block="block" />
</elseif>
<elseif property="propertyname" contains="partialvalue">
<link block="block" />
</elseif>
####Else element The else element is optional and can also contain any number of link elements.
<else>
<link block="block" />
</else>
####Switch structure
Basic structure:
<switch property="propertyname" >
<case value="propertyvalue" break="True">
<link block="block" />
</case>
<default>
<link block="block" />
</default>
</switch>
<switch property="propertyname" >
<case contains="partialvalue" break="True">
<link block="block" />
</case>
<default>
<link block="block" />
</default>
</switch>
####Switch element
Attributes:
- property Mandatory attribute. The name of the property to be used.
<switch property="propertyname">
</switch>
####Case element
Attributes:
- value Optional attribute. The value to be matched exactly.
- contains Optional attribute. The value to be checked for presence in the property.(partial match)
- break Optional attribute. Stop matching further matches after this one. Options: True, False. Defaults to: True
<case value="propertyvalue" break="True">
<link block="block" />
</case>
<case contains="partialvalue" break="True">
<link block="block" />
</case>
####Default element The default element gets added if the last matching case has break set to False or no cases matched.
<default>
<link block="block" />
</default>
####Value constants
For any of the conditional structures you can match for null or a non existant property by using the following constant but only with the value attribute on the conditional structure.
The constant:
#NULL#
Table of contents
#Example xml
<?xml version="1.0" encoding="utf-8" ?>
<templates>
<blocks>
<block type="overlay" id="colorlesstextbox" src="proxy/textbox/colorless.png">
<location x="0" y="0" />
</block>
<block type="overlay" id="colorlesstypeline" src="proxy/typeline/colorless.png">
<location x="0" y="0" />
</block>
<block type="overlay" id="colorlesspt" src="proxy/pt/colorless.png">
<location x="300" y="500" />
</block>
<block type="overlay" id="redtextbox" src="proxy/textbox/red.png">
<location x="0" y="0" />
</block>
<block type="overlay" id="redtypeline" src="proxy/typeline/red.png">
<location x="0" y="0" />
</block>
<block type="overlay" id="redpt" src="proxy/pt/red.png">
<location x="300" y="500" />
</block>
<block type="text" id="title">
<location x="40" y="34" />
<text color="#000000" size="15" />
<border color="#FFFFFF" size="2" />
</block>
<block type="text" id="cost">
<location x="295" y="34" />
<text color="#000000" size="15" />
<border color="#FFFFFF" size="2" />
</block>
<block type="text" id="cardtype">
<location x="40" y="300" />
<text color="#000000" size="15" />
<border color="#FFFFFF" size="2" />
</block>
<block type="text" id="text">
<location x="40" y="330" />
<text color="#000000" size="15" />
<border color="#FFFFFF" size="2" />
<wordwrap height="150" width="300" />
</block>
<block type="text" id="PTBox">
<location x="300" y="470" />
<text color="#000000" size="15" />
<border color="#FFFFFF" size="2" />
</block>
</blocks>
<template src="proxy/border/colorless.png" default="True">
<matches>
<match name="Color" value="value" />
<match name="property2" value="value" />
</matches>
<overlayblocks>
<link block="colorlesstextbox" />
<link block="colorlesstypeline" />
<link block="colorlesspt" />
</overlayblocks>
<textblocks>
<link block="title">
<property name="Name" />
</link>
<link block="cost">
<property name="Cost" />
</link>
<link block="cardtype" separator=" - ">
<property name="Type" />
<property name="Subtype" />
</link>
<link block="text">
<property name="Rules" />
</link>
<link block="PTBox">
<property name="PTBox" />
</link>
</textblocks>
</template>
<template src="proxy/border/red.png">
<matches>
<match name="Color" value="Red" />
<match name="Type" value="Creature" />
</matches>
<overlayblocks>
<link block="redtextbox" />
<link block="redtypeline" />
<link block="redpt" />
</overlayblocks>
<textblocks>
<link block="title">
<property name="Name" />
</link>
<link block="cost">
<property name="Cost" />
</link>
<link block="cardtype" separator=" - ">
<property name="Type" />
<property name="Subtype" />
</link>
<link block="text">
<property name="Rules" />
</link>
<link block="PTBox">
<property name="PTBox" />
</link>
</textblocks>
</template>
</templates>
example gamedef mapping
<proxygen definitionsrc="proxy/proxydef.xml">
</proxygen>
fully generated xml based on the xsd.
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<blocks>
<block type="" id="" src="" >
<location x="" y="" rotate="" altrotate="" flip="" />
<text color="" size="" font="" />
<border color="" size="" />
<wordwrap height="" width="" align="" valign="" />
</block>
</blocks>
<template src="" default="" >
<matches>
<match name="" value="" />
</matches>
<overlayblocks>
<conditional>
<if property="" value="" contains="" >
<link block="" separator="">
<property name="" />
</link>
</if>
<elseif property="" value="" contains="" >
<link block="" separator="">
<property name="" />
</link>
</elseif>
<else>
<link block="" separator="">
<property name="" />
</link>
</else>
</conditional>
<conditional>
<switch property="" >
<case value="" contains="" break="" >
<link block="" separator="">
<property name="" />
</link>
</case>
<default>
<link block="" separator="">
<property name="" />
</link>
</default>
</switch>
</conditional>
<link block="" separator="">
<property name="" />
</link>
</overlayblocks>
<textblocks>
<conditional>
<if property="" value="" contains="" >
<link block="" separator="">
<property name="" />
</link>
</if>
<elseif property="" value="" contains="" >
<link block="" separator="">
<property name="" />
</link>
</elseif>
<else>
<link block="" separator="">
<property name="" />
</link>
</else>
</conditional>
<conditional>
<switch property="" >
<case value="" contains="" break="" >
<link block="" separator="">
<property name="" />
</link>
</case>
<default>
<link block="" separator="">
<property name="" />
</link>
</default>
</switch>
</conditional>
<link block="" separator="">
<property name="" />
</link>
</textblocks>
</template>
</templates>
<?xml version="1.0" encoding="utf-8" ?>
<templates>
<blocks>
<block type="" id="" src=""> <!-- a block that will be linked in the templates -->
<!-- various options for a block are placed here -->
</block>
</blocks>
<template src="" default="True">
<matches>
<match name="property" value="" /><!-- match a template to a specified property and value-->
</matches>
<overlayblocks>
<link block="" /><!-- the blocks for overlays are linked here like this -->
</overlayblocks>
<textblocks>
<link block="" separator=""><!-- the blocks for text are linked here like this -->
<property name="" /><!-- The property defined on a card to be placed here -->
</link>
</textblocks>
</template>
</templates>