for now, there should only be two directives, text
, which takes, in order: index, text, x, y, width, height and font
, which takes, in order: family, size, attributes, htmlcolor
Examples:
font=Arial, 16, BU, #f0f0f0
text=1, "test", 0, 0, 1, 1
investigate using nearley to generate the grammar, and attempt to make an ace edit mode that is compatible with one generation step.
This should ultimately compile down to some javascript that looks like this:
text({ index: 1, x: 0, y: 0, width: 1, height: 1, string: 'test' });
Variables
shortly after, variables will need to be supported. variables are simply string substitution, so:
[TitleFont]=Arial, 16, BB, #000000
font=[TitleFont]
... would compile to:
font=Arial, 16, BB, #000000
- write a regex to rip out every variable and value
- go through each variable and splitjoin it in the source file
- remove variable declarations
Loops
Basic loop:
loop = <x = 0> to 10
text = <x>, "Test<x>", 0, <x>, 1, 2
endloop
More advanced loop:
loop = <x = 3> to 13
text = <x + 1>, "Test<x - 1>", 0, <x * 2>, 1, 2
endloop
Loop with vars (should be taken care of):
[Max] = 20
loop = <x = 0> to [Max]
text = <x>, "Test<x>", 0, <x>, 1, 2
endloop
Use math.js for evaluating these loops
It should also support looping over arbitrary values:
loop = <x>, <i> in { "Mage", "Thief", "Warrior", "Cleric" }
text= <i>, <x>, 0, 0, 1, 1
endloop
In this case, there's an index variable. It would also have to support nested loops so you can loop over a list of classes and then loop over a spreadsheet.
all variable types will have to be written like so (where appropriate):
rule_decimal -> null | decimal | loopvar
when postprocessing the loop, iterate through the contents of the loop and go through every property of each resulting object. if it is the string then it should be replaced with a number, but if it's a string like "data" then it should be still a string, but instead look like "data1"
Important
When looping over a spreadsheet, how is the data accessed?
TODO: