ShaderPatch: add <fname> replacement tag (filename), and Nametags patches using it

This commit is contained in:
somewhatlurker
2019-10-07 19:49:38 +11:00
parent 4c54304dff
commit 4b67df0db4
2 changed files with 22 additions and 1 deletions
+21 -1
View File
@@ -31,6 +31,14 @@ Toon_Lines_Val2=0.75
# Thickness Offset(?)
Toon_Lines_Val3=0.75
# Debug patches:
# Nametags
# Adds comments with the shader file name to the shader text. Useful for debugging issues.
# `nametags_val1` and `nametags_val2` are a dirty hack to hide this in launcher (options ending in _val. must belong to a parent to be displayed)
# `nametags_val2` is a bit faster, but the tags are placed at the end of the file and you may not like this
Nametags_Val1=0
Nametags_Val2=0
[Patches]
# Compatibility patches:
# Star Story (and etc.) stage corruption (Maxwell+)
@@ -46,4 +54,16 @@ cloth_npr1\.fp=arch:TU||cfg:compat||from:SSG _tmp0.yw, ybr.xxzz;||to:TEMP _tmpFo
.*eye.*=cfg:toon_eyes||from:ADD o_color_f0.w, diff.x, diff.y;||to:
.*hair_npr1.*=cfg:toon_hair||from:MUL spec.x, tmp.x, 0.7;||to:MUL spec.x, tmp.x, 0.7; MUL diff, diff, <val1>;
.*tone_map_npr1.*=cfg:toon_lines||from:MUL density.y, density.y, 0.25;||to:MUL density.y, density.y, <val1>;
.*tone_map_npr1.*=cfg:toon_lines||from:MAD density.w, density.x, 0.7, 0.25;||to:MAD density.w, density.x, <val2>, <val3>;
.*tone_map_npr1.*=cfg:toon_lines||from:MAD density.w, density.x, 0.7, 0.25;||to:MAD density.w, density.x, <val2>, <val3>;
# Debug patches:
# Nametags
# Adds comments with the shader file name to the shader text. Useful for debugging issues
# `nametags_val1` and `nametags_val2` are a dirty hack to hide this in launcher (options ending in _val. must belong to a parent to be displayed)
# `nametags_val2` is a bit faster, but the tags are placed at the end of the file and you may not like this
# Notes:
# * `(\r?\n)` is used to capture the line ending type used and ensure we're at the start of a line
# * `[^!]` ensures the comment is inserted after all start program lines (not sure if this even matters)
# * `[\s\S]` matches all characters *including* new lines
.*=cfg:nametags_val1||from:(\r?\n)([^!][\s\S]*)||to:$1#<fname>$1$2
.*=cfg:nametags_val2||from:([\s\S]*?(\r?\n)[\s\S]*)||to:$1$2#<fname>
@@ -238,6 +238,7 @@ void hookedLoadFromFarcThunk(FArchivedFile** ppFile)
modifiedStr = std::string(file.data, file.dataSize);
modifiedStr = std::regex_replace(modifiedStr, patch.dataRegex, patch.dataReplace);
modifiedStr = StringReplace(modifiedStr, "<fname>", file.fileName.GetCharBuf());
if (patch.cfg.length() > 0) // patch has a config setting
{