From 4b67df0db466d32d8c7ec548b70ea35e1e150b66 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Mon, 7 Oct 2019 19:49:38 +1100 Subject: [PATCH] ShaderPatch: add `` replacement tag (filename), and Nametags patches using it --- source-code/data/plugins/ShaderPatch.ini | 22 ++++++++++++++++++- .../plugins/ShaderPatch/src/dllmain.cpp | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/source-code/data/plugins/ShaderPatch.ini b/source-code/data/plugins/ShaderPatch.ini index 4cf764a..2a22ba9 100644 --- a/source-code/data/plugins/ShaderPatch.ini +++ b/source-code/data/plugins/ShaderPatch.ini @@ -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, ; .*tone_map_npr1.*=cfg:toon_lines||from:MUL density.y, density.y, 0.25;||to:MUL density.y, density.y, ; -.*tone_map_npr1.*=cfg:toon_lines||from:MAD density.w, density.x, 0.7, 0.25;||to:MAD density.w, density.x, , ; \ No newline at end of file +.*tone_map_npr1.*=cfg:toon_lines||from:MAD density.w, density.x, 0.7, 0.25;||to:MAD density.w, density.x, , ; + +# 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#$1$2 +.*=cfg:nametags_val2||from:([\s\S]*?(\r?\n)[\s\S]*)||to:$1$2# \ No newline at end of file diff --git a/source-code/source/plugins/ShaderPatch/src/dllmain.cpp b/source-code/source/plugins/ShaderPatch/src/dllmain.cpp index 2550d3e..a86d1c8 100644 --- a/source-code/source/plugins/ShaderPatch/src/dllmain.cpp +++ b/source-code/source/plugins/ShaderPatch/src/dllmain.cpp @@ -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, "", file.fileName.GetCharBuf()); if (patch.cfg.length() > 0) // patch has a config setting {