diff --git a/games/BurglinGnomes/plugin/UltraWideFix.cs b/games/BurglinGnomes/plugin/UltraWideFix.cs index 6f1100a..fc260e7 100644 --- a/games/BurglinGnomes/plugin/UltraWideFix.cs +++ b/games/BurglinGnomes/plugin/UltraWideFix.cs @@ -80,14 +80,38 @@ namespace BurglinGnomes.UltraWideFix private void Start() => Apply(); // Canvases are created lazily (menus, popups), so re-apply periodically. + // We also re-read the config file each tick: BepInEx does NOT pick up + // external edits on its own, so without this you'd have to restart the + // game after every tweak. private void Update() { _timer += Time.unscaledDeltaTime; if (_timer < 2f) return; _timer = 0f; + + try + { + var stamp = System.IO.File.GetLastWriteTimeUtc(Config.ConfigFilePath); + if (stamp != _configStamp) + { + _configStamp = stamp; + Config.Reload(); + Logger.LogInfo($"Config reloaded: HudScale={_hudScale.Value} " + + $"WorldLabelScale={_worldScale.Value} " + + $"Match={_match.Value} Enabled={_enabled.Value}"); + // values changed -> re-derive from baselines on this pass + } + } + catch (System.Exception e) + { + Logger.LogWarning($"Config reload failed (check the .cfg syntax): {e.Message}"); + } + Apply(); } + private System.DateTime _configStamp; + private void Apply() { if (!_enabled.Value) return; @@ -132,9 +156,11 @@ namespace BurglinGnomes.UltraWideFix if (cs.referenceResolution != targetRef) { cs.referenceResolution = targetRef; - if (_verbose.Value) - Logger.LogInfo($"HUD '{cs.name}' ref {baseRef} -> {targetRef} " + - $"match={_match.Value}"); + // expected scale now; Canvas.scaleFactor lags a frame + float exp = Mathf.Pow(Screen.width / targetRef.x, 1f - _match.Value) * + Mathf.Pow(Screen.height / targetRef.y, _match.Value); + Logger.LogInfo($"HUD '{cs.name}' ref {baseRef} -> {targetRef} " + + $"match={_match.Value} => scale={exp:F3}"); } } }