Modifications for bad eyes (KBPatcher13_3.18.0) introduces conditional branching. Conditions are fullfilled if certain flags are set or not. I take the following old-style patch (see the spoiler) to illustrate the usage:
With the first three "newpart="-lines, this patch sets hard coded values instead of the variables of the original code.
Code:
newpart=* { font-family: Georgia; font-size: 32px; line-height: 36px; } \n
newpart=ol { margin-left: 14px; } \n
newpart=ol p { font-size: 32px; font-weight:normal; }
Since this css block contains no differentiation according to models, I usually chose values proper for the Touch, and the user had to overwrite them with other values according to his needs and taste, and according to his device model. Whereas choosing values according to personal preferences is the reason for this patch, the need to change the patch file for each device model is annoying, especially if on owns several models.
Starting with the patch for 3.18.0, I replace these three lines with
Code:
if $aurahd or $h2o
newpart=* { font-family: Georgia; font-size: 50px; line-height: 54px; } \n
newpart=ol { margin-left: 28px; } \n
newpart=ol p { font-size: 50px; font-weight:normal; }
else if $glo or $aura
newpart=* { font-family: Georgia; font-size: 40px; line-height: 44px; } \n
newpart=ol { margin-left: 24px; } \n
newpart=ol p { font-size: 40px; font-weight:normal; }
else if $glohd
newpart=* { font-family: Georgia; font-size: 56px; line-height: 60px; } \n
newpart=ol { margin-left: 30px; } \n
newpart=ol p { font-size: 56px; font-weight:normal; }
else
newpart=* { font-family: Georgia; font-size: 32px; line-height: 36px; } \n
newpart=ol { margin-left: 14px; } \n
newpart=ol p { font-size: 32px; font-weight:normal; }
end
If one calls the patcher with the flag aurahd set, font-size will be set to 50px, if called with the flag glo set, font-size will be set to 40px, and so on.
Another example: In a certain patch, I get a problem since the compressed patched css code is larger then the compressed original code. I therefore skip certain parts depending on the target device (specified by a flag):
Code:
...
oldpart=div.spacing2.phoenix {\n\tmargin-top: 40px;\n}\n\n
oldpart=div.spacing2.dragon,\ndiv.spacing2.alyssum {\n\tmargin-top: 50px;\n}\n\n
oldpart=div.spacing2.trilogy {\n\tmargin-top: 20px;\n}\n\n
...
if $glo or $aura
newpart=div.spacing2.phoenix {\n\tmargin-top: 40px;\n}\n
else if $h20 or $aurahd or $glohd
newpart=div.spacing2.dragon,\ndiv.spacing2.alyssum {\n\tmargin-top: 50px;\n}\n
else
newpart=div.spacing2.trilogy {\n\tmargin-top: 20px;\n}\n
end
The patch executable does not know any predefined flags. It interprets any word preceded by "$" in a "if" or "else" context as being a flag. Therefore, you can do something like
Code:
if ($aurahd or $h2o) and $forMe
newpart=* { font-family: Georgia; font-size: 32px; line-height: 36px; } \n
else if ($aurahd or $h2o) and $forMyWife
newpart=* { font-family: Georgia; font-size: 22px; line-height: 24px; } \n
...
You cannot use nested constructions. The following code fragment is NOT valid:
Code:
if $aurahd
if $forMe
newpart=* { font-family: Georgia; font-size: 32px; line-height: 36px; } \n
else if $forMyWife
newpart=* { font-family: Georgia; font-size: 22px; line-height: 24px; } \n
else
newpart=* { font-family: Georgia; font-size: 24px; line-height: 26px; } \n
end
...
end
Concerning flags, there is no distinction between uppercase and lowercase letters.
As for how to set the flags when starting the patching process, see, for instance, 3.18.0_glo_aura.bat of KBPatcher13_3.18.0, which I will upload to the next post.
As for converting patch files to GeoffR-style, you would open a cmd window and execute the following two lines (for instance):
Code:
cd C:\data\KBPatcher13_3.18.0
3.18.0_convert.bat flags=glo
(Note that not everything can be converted to GeoffR-style.)