From 1ec8275831ab728242e6727aa6b9ee2d85fac55d Mon Sep 17 00:00:00 2001 From: ivan tkachenko Date: Wed, 15 Oct 2025 15:49:53 +0300 Subject: [PATCH] Drop restrictions on when/whether host/clients can modify config Lethal Config does not refresh that state reliably, it has only caused bugs and annoyances so far. If someone wants to change the track mid-day, there is a small chance to desync though. --- MuzikaGromche/Plugin.cs | 51 ++++------------------------------------- 1 file changed, 5 insertions(+), 46 deletions(-) diff --git a/MuzikaGromche/Plugin.cs b/MuzikaGromche/Plugin.cs index b50bb97..1521d24 100644 --- a/MuzikaGromche/Plugin.cs +++ b/MuzikaGromche/Plugin.cs @@ -2271,18 +2271,14 @@ namespace MuzikaGromche string buttonText = "Toggle"; var button = new GenericButtonConfigItem(section, buttonOptionName, buttonDescription, buttonText, () => { - if (CanModifyWeightsNow()) + var tracks = Plugin.Tracks.Where(t => t.Language.Equals(language)).ToList(); + var isOff = tracks.All(t => t.Weight.Value == 0); + var newWeight = isOff ? 50 : 0; + foreach (var t in tracks) { - var tracks = Plugin.Tracks.Where(t => t.Language.Equals(language)).ToList(); - var isOff = tracks.All(t => t.Weight.Value == 0); - var newWeight = isOff ? 50 : 0; - foreach (var t in tracks) - { - t.Weight.Value = newWeight; - } + t.Weight.Value = newWeight; } }); - button.ButtonOptions.CanModifyCallback = CanModifyWeightsNow; LethalConfigManager.AddConfigItem(button); } @@ -2308,40 +2304,6 @@ namespace MuzikaGromche #endif } - public static CanModifyResult CanModifyIfHost() - { - var startOfRound = StartOfRound.Instance; - if (!startOfRound) - { - return CanModifyResult.True(); // Main menu - } - if (!startOfRound.IsHost) - { - return CanModifyResult.False("Only for host"); - } - return CanModifyResult.True(); - } - - public static CanModifyResult CanModifyWeightsNow() - { - var startOfRound = StartOfRound.Instance; - if (!startOfRound) - { - return CanModifyResult.True(); // Main menu - } - if (!startOfRound.IsHost) - { - return CanModifyResult.False("Only for host"); - } -#if !DEBUG // Changing tracks on the fly might lead to a desync. But it may speed up development process - if (!startOfRound.inShipPhase) - { - return CanModifyResult.False("Only while orbiting"); - } -#endif - return CanModifyResult.True(); - } - #if DEBUG private void SetupEntriesForExtrapolation(ConfigFile configFile) { @@ -2388,7 +2350,6 @@ namespace MuzikaGromche var loadButton = new GenericButtonConfigItem(section, "Load Palette from the Current Track", "Override custom palette with the built-in palette of the current track.", "Load", load); - loadButton.ButtonOptions.CanModifyCallback = CanModifyIfHost; LethalConfigManager.AddConfigItem(loadButton); customPaletteSizeEntry = configFile.Bind(section, "Palette Size", 0, new ConfigDescription( @@ -2458,7 +2419,6 @@ namespace MuzikaGromche var loadButton = new GenericButtonConfigItem(section, "Load Timings from the Current Track", "Override custom timings with the built-in timings of the current track.", "Load", load); - loadButton.ButtonOptions.CanModifyCallback = CanModifyIfHost; LethalConfigManager.AddConfigItem(loadButton); overrideTimingsEntry = configFile.Bind(section, "Override Timings", false, @@ -2697,7 +2657,6 @@ namespace MuzikaGromche private T Default(T options) where T : BaseOptions { options.RequiresRestart = false; - options.CanModifyCallback = CanModifyIfHost; return options; } }