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.
This commit is contained in:
		
							parent
							
								
									9efe6adaf3
								
							
						
					
					
						commit
						1ec8275831
					
				|  | @ -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>(T options) where T : BaseOptions | ||||
|         { | ||||
|             options.RequiresRestart = false; | ||||
|             options.CanModifyCallback = CanModifyIfHost; | ||||
|             return options; | ||||
|         } | ||||
|     } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue