From 85c7ce8a5d8dbe7e049143932528e9d74d0394ca Mon Sep 17 00:00:00 2001 From: Prozon <104065803+Prozon@users.noreply.github.com> Date: Mon, 15 Jun 2026 08:20:32 -0700 Subject: [PATCH] Reverting Change To Configs Reverting changes from config fix. Incompatible with Nexus at this time. I'll re-do to try to implement reverse compatibility or look into adjusting Nexus' method. --- Torch.Server/Managers/InstanceManager.cs | 6 +- Torch.Server/Views/ConfigControl.xaml.cs | 48 ++-- Torch.Server/Views/ModsControl.xaml.cs | 289 ++++++++++++++++++++--- 3 files changed, 278 insertions(+), 65 deletions(-) diff --git a/Torch.Server/Managers/InstanceManager.cs b/Torch.Server/Managers/InstanceManager.cs index 57885062..e08ce0d2 100644 --- a/Torch.Server/Managers/InstanceManager.cs +++ b/Torch.Server/Managers/InstanceManager.cs @@ -199,12 +199,12 @@ private void ImportWorldConfig(bool modsOnly = true) } } - public bool SaveConfig() + public void SaveConfig() { if (((TorchServer)Torch).HasRun) { Log.Warn("Checkpoint cache is stale, not saving dedicated config."); - return false; + return; } DedicatedConfig.Save(Path.Combine(Torch.Config.InstancePath, CONFIG_NAME)); @@ -238,8 +238,6 @@ public bool SaveConfig() Log.Error("Failed to write sandbox config, changes will not appear on server"); Log.Error(e); } - - return true; } /// diff --git a/Torch.Server/Views/ConfigControl.xaml.cs b/Torch.Server/Views/ConfigControl.xaml.cs index 41e94bc4..0441683d 100644 --- a/Torch.Server/Views/ConfigControl.xaml.cs +++ b/Torch.Server/Views/ConfigControl.xaml.cs @@ -41,8 +41,7 @@ public ConfigControl(TorchServer server) _server.PropertyChanged += (sender, args) => { - if (args.PropertyName == nameof(TorchServer.CanRun) || - args.PropertyName == nameof(TorchServer.HasRun)) + if (args.PropertyName == nameof(TorchServer.CanRun)) { Dispatcher.Invoke(SetReadOnly); } @@ -167,59 +166,58 @@ private void RoleEdit_Onlick(object sender, RoutedEventArgs e) private void SetReadOnly() { - // Config is only editable before the first start of the session. After the server - // has run the checkpoint is stale and saving is blocked, so the - // entire panel is locked even after a stop. - bool editable = _server.CanRun && !_server.HasRun; - foreach (var textbox in GetAllChildren(this)) { - // Track fields that are inherently read-only (Such as AnalyticsToken) - // so they stay read-only even when the panel is editable. - if (textbox.IsReadOnly && textbox.Tag == null) - textbox.Tag = "InherentlyReadOnly"; - - bool inherentlyReadOnly = textbox.Tag as string == "InherentlyReadOnly"; - - // Gray out when the panel is locked, otherwise enable- but keep - // inherently-read-only fields non-editable. - textbox.IsEnabled = editable; - textbox.IsReadOnly = !editable || inherentlyReadOnly; + // Don't make inherently read-only textboxes editable + // (e.g., AnalyticsToken with ReadOnly=true in DisplayAttribute) + if (!_server.CanRun) + textbox.IsReadOnly = true; + // Only make editable if it wasn't marked as inherently read-only + // We use Tag to track this - PropertyGrid doesn't set Tag on TextBoxes + else if (textbox.Tag as string != "InherentlyReadOnly") + { + // Check if this is the first time and textbox is already read-only + // If so, mark it as inherently read-only + if (textbox.IsReadOnly && textbox.Tag == null) + textbox.Tag = "InherentlyReadOnly"; + else + textbox.IsReadOnly = false; + } } foreach (var button in GetAllChildren