From fbafacc1ddb0d0d6973f337c49441089a990cf68 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Mon, 26 Oct 2026 17:48:37 -0400 Subject: Improve imgui navigation, add Screen parameters Signed-off-by: Andrew Opalach --- Plugin.cs | 174 +++++++++++++++++++++----------------------------------------- 1 file changed, 58 insertions(+), 116 deletions(-) (limited to 'Plugin.cs') diff --git a/Plugin.cs b/Plugin.cs index aa3f854..5ccf064 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -47,10 +47,9 @@ using SharpPluginLoader.Core.Resources; namespace WorldTuningTool { + using static Config; using static Utility; - using static Parameter; using static PFuncs; - using static Config; public unsafe class Plugin : IPlugin { @@ -104,9 +103,8 @@ namespace WorldTuningTool private static string selectedGlobal = ""; - private static string selectedSet = ""; - private static bool renamingSet = false; - private static string typedSetName = ""; + private static PresetSelection setSelection = null!; + private static string selectedSet => setSelection.Selected; private static Dictionary externalOverrides = new Dictionary(); private static int externalId = 0; @@ -219,7 +217,6 @@ namespace WorldTuningTool if (ImGui.Button("▲")) { // Create the new override before unsetting any lower priority overrides. - // Effectively, copy the current override value. (Vector4 v4, int i1) = param.GetValue(); Override ov = new Override(param, v4, i1); globalOverrides = config.Overrides[globalStage]; @@ -641,6 +638,7 @@ namespace WorldTuningTool private static MtObject? sMhScene = null; private static MtObject? sMhMain = null; private static MtObject? sMhRender = null; + private static MtObject? sMhGUI = null; private static MtObject? sTime = null; private static MtObject? sQuest = null; private static MtObject? sLightLinker = null; @@ -650,6 +648,16 @@ namespace WorldTuningTool private static Parameter hqMode = P("HQ Mode", 0xE9A3, ParameterType.BOOL); private static Patch defaultHqMode; + private static Parameter[] screenRenderParameters = { + P("Screen Trim", 0x7B440, ParameterType.BYTE, pStep((byte)1)), + P("Default Width", 0x142F74AFC, ParameterType.PATCH_FLOAT), + P("Default Height", 0x142F74AF8, ParameterType.PATCH_FLOAT) + }; + + private static Parameter[] screenGuiParameters = { + P("UI Center Offset", 0x1EC, ParameterType.FLOAT) + }; + private static bool setWeatherMode = false; private static int requestWeatherMode = 1; private static Parameter[] sTimeParameters = { @@ -1182,6 +1190,8 @@ namespace WorldTuningTool }; private static Parameter[] allParameters = new Parameter[]{ hqMode } + .Concat(screenRenderParameters) + .Concat(screenGuiParameters) .Concat(sTimeParameters) .Concat(lodParameters) .Concat(snowParameters) @@ -1402,7 +1412,7 @@ namespace WorldTuningTool #if SHADER_FEATURES private bool volumeUpsampleNoLinear = false; private bool fxaaMaxQuality = false; - private bool skinAllowNegativeWet = false; + private bool addTonemappers = false; #endif private bool fullResVolumeBlur = false; @@ -1824,6 +1834,7 @@ namespace WorldTuningTool public void OnPreMain() { Config config = getConfig(); + setSelection = new(config.Sets, "Set"); disableLightsFeature = config.DisableLightsFeature; if (!disableLightsFeature) { @@ -1870,7 +1881,7 @@ namespace WorldTuningTool } volumeUpsampleNoLinear = patches.VolumeUpsampleNoLinear; fxaaMaxQuality = patches.FXAAMaxQualityPreset; - skinAllowNegativeWet = patches.SkinAllowNegativeWetness; + addTonemappers = patches.AddTonemappers; #endif fullResVolumeBlur = patches.FullResolutionVolumeBlur; if (fullResVolumeBlur) @@ -1912,9 +1923,10 @@ namespace WorldTuningTool public void OnLoad() { + sMhScene = SingletonManager.GetSingleton("sMhScene")!; sMhMain = SingletonManager.GetSingleton("sMhMain")!; sMhRender = SingletonManager.GetSingleton("sMhRender")!; - sMhScene = SingletonManager.GetSingleton("sMhScene")!; + sMhGUI = SingletonManager.GetSingleton("sMhGUI")!; sTime = SingletonManager.GetSingleton("sTime")!; sQuest = SingletonManager.GetSingleton("sQuest")!; sLightLinker = SingletonManager.GetSingleton("sLightLinker")!; @@ -2011,6 +2023,16 @@ namespace WorldTuningTool hqMode.Update(sMhScene!.Instance); + foreach (Parameter param in screenRenderParameters) + { + param.Update(sMhRender!.Instance); + } + + foreach (Parameter param in screenGuiParameters) + { + param.Update(sMhGUI!.Instance); + } + if (setWeatherMode) { sQuest!.GetRef(0x293B4) = requestWeatherMode; @@ -2871,6 +2893,7 @@ namespace WorldTuningTool { selectedGlobal = name; } + if (isSelected) ImGui.SetItemDefaultFocus(); } ImGui.EndCombo(); } @@ -2989,98 +3012,16 @@ namespace WorldTuningTool ImGui.PushID("Set"); ImGui.Text("Quick Sets"); - ImGui.PushItemWidth(width * 0.35f); string prevSet = selectedSet; - if (ImGui.Button("+")) - { - string setName = "New Set"; - int setDup = 0; - while (config.Sets.ContainsKey(setName)) - { - setDup++; - setName = $"New Set ({setDup})"; - } - config.Sets[setName] = new List(); - selectedSet = setName; - } - ImGui.SameLine(); - if (renamingSet) - { - ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * disableAlphaFactor); - } - if (ImGui.BeginCombo("##Set", selectedSet)) - { - if (ImGui.Selectable("(None)", false)) - { - selectedSet = ""; - } - foreach ((string name, List overrides) in config.Sets) - { - bool isSelected = name == selectedSet; - if (ImGui.Selectable(name, isSelected)) - { - selectedSet = name; - } - } - ImGui.EndCombo(); - } - if (prevSet != selectedSet) + string preRenameSet = setSelection.Draw(width); + if (prevSet != preRenameSet) { BeginTransition(); HandleSetChange(prevSet, globalOverrides, stageOverrides); EndTransition(); } - if (renamingSet) - { - ImGui.PopStyleVar(); - ImGui.PopItemFlag(); - } - ImGui.PopItemWidth(); if (selectedSet != "") { - ImGui.SameLine(); - ImGui.PushItemWidth(width * 0.2f); - if (renamingSet) - { - ImGui.InputText("##Set Name", ref typedSetName, 99); - ImGui.SameLine(); - if (typedSetName == "") - { - ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * disableAlphaFactor); - } - if (ImGui.Button("Save")) - { - string setName = typedSetName; - if (setName != selectedSet) - { - int setDup = 0; - while (config.Sets.ContainsKey(setName)) - { - setDup++; - setName = $"{typedSetName} ({setDup})"; - } - List tmpOverrides = config.Sets[selectedSet]; - config.Sets.Remove(selectedSet); - config.Sets[setName] = tmpOverrides; - selectedSet = setName; - } - renamingSet = false; - } - if (typedSetName == "") - { - ImGui.PopStyleVar(); - ImGui.PopItemFlag(); - } - } - else if (ImGui.Button("Rename")) - { - renamingSet = true; - typedSetName = selectedSet; - } - ImGui.PopItemWidth(); - bool setOrderChanged = false; List setOverrides = config.Sets[selectedSet]; if (!editMode) @@ -3242,15 +3183,15 @@ namespace WorldTuningTool ImGui.EndTooltip(); } - if (ImGui.Checkbox("Skin Allow Negative Wetness", ref skinAllowNegativeWet)) + if (ImGui.Checkbox("Add Extra Tonemappers", ref addTonemappers)) { - patches.SkinAllowNegativeWetness = skinAllowNegativeWet; + patches.AddTonemappers = addTonemappers; config.Patches = patches; saveConfig(config); } if (ImGui.BeginItemTooltip()) { - ImGui.Text("Can be used to reverse the effect of wet by default modded armor."); + ImGui.Text("Tone Map Type: 7 = Uchimura."); ImGui.EndTooltip(); } #endif @@ -3418,6 +3359,22 @@ namespace WorldTuningTool { hqMode.Draw(width); + ImGui.PushID("Screen"); + if (ImGui.CollapsingHeader("Screen")) + { + ImGui.Text($"Address: 0x{sMhRender!.Instance:X}"); + foreach (Parameter param in screenRenderParameters) + { + param.Draw(width); + } + ImGui.Text($"Address: 0x{sMhGUI!.Instance:X}"); + foreach (Parameter param in screenGuiParameters) + { + param.Draw(width); + } + } + ImGui.PopID(); + ImGui.PushID("Time"); if (ImGui.CollapsingHeader("Time and Weather")) { @@ -3919,7 +3876,7 @@ namespace WorldTuningTool //} if (!System.IO.File.Exists(path)) { - Log.Warn($"File not found: {path}."); + Log.Error($"File not found: {path}."); return false; } byte[] shaderData; @@ -4036,32 +3993,17 @@ namespace WorldTuningTool } } - if (skinAllowNegativeWet) + if (addTonemappers) { - if (hash == "2eed1f00-e24d1b19-9d521064-17b9a586") - { - if (replaceShaderFromFile(info, $"{shaderPath}/body_skin.shdr", ShaderSourceType.Binary)) - { - Log.Info("Body skin shader replaced."); - } - } - else if (hash == "8e5e3c09-ebe77ee4-ba1cb659-d25bc7bf") + if (hash == "ca33bab6-2119df84-41786a69-404471cd") { - if (replaceShaderFromFile(info, $"{shaderPath}/face.shdr", ShaderSourceType.Binary)) + if (replaceShaderFromFile(info, $"{shaderPath}/color_grading_add_tonemappers.shdr", ShaderSourceType.Binary)) { - Log.Info("Face shader replaced."); + Log.Info("Color grading/Tonemapping shader replaced."); } } } - if (hash == "ca33bab6-2119df84-41786a69-404471cd") - { - if (replaceShaderFromFile(info, $"{shaderPath}/color_grading_ex_tonemappers.shdr", ShaderSourceType.Binary)) - { - Log.Info("Color grading shader replaced."); - } - } - /* if (hash == "0c3dacbd-32c175d5-10d80d04-cce7e689") { -- cgit v1.2.3-101-g0448