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
					
				|  | @ -2270,8 +2270,6 @@ namespace MuzikaGromche | ||||||
|                     string buttonDescription = "Toggle all tracks in this section ON or OFF. Effective immediately."; |                     string buttonDescription = "Toggle all tracks in this section ON or OFF. Effective immediately."; | ||||||
|                     string buttonText = "Toggle"; |                     string buttonText = "Toggle"; | ||||||
|                     var button = new GenericButtonConfigItem(section, buttonOptionName, buttonDescription, buttonText, () => |                     var button = new GenericButtonConfigItem(section, buttonOptionName, buttonDescription, buttonText, () => | ||||||
|                     { |  | ||||||
|                         if (CanModifyWeightsNow()) |  | ||||||
|                     { |                     { | ||||||
|                         var tracks = Plugin.Tracks.Where(t => t.Language.Equals(language)).ToList(); |                         var tracks = Plugin.Tracks.Where(t => t.Language.Equals(language)).ToList(); | ||||||
|                         var isOff = tracks.All(t => t.Weight.Value == 0); |                         var isOff = tracks.All(t => t.Weight.Value == 0); | ||||||
|  | @ -2280,9 +2278,7 @@ namespace MuzikaGromche | ||||||
|                         { |                         { | ||||||
|                             t.Weight.Value = newWeight; |                             t.Weight.Value = newWeight; | ||||||
|                         } |                         } | ||||||
|                         } |  | ||||||
|                     }); |                     }); | ||||||
|                     button.ButtonOptions.CanModifyCallback = CanModifyWeightsNow; |  | ||||||
|                     LethalConfigManager.AddConfigItem(button); |                     LethalConfigManager.AddConfigItem(button); | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|  | @ -2308,40 +2304,6 @@ namespace MuzikaGromche | ||||||
| #endif | #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 | #if DEBUG | ||||||
|         private void SetupEntriesForExtrapolation(ConfigFile configFile) |         private void SetupEntriesForExtrapolation(ConfigFile configFile) | ||||||
|         { |         { | ||||||
|  | @ -2388,7 +2350,6 @@ namespace MuzikaGromche | ||||||
| 
 | 
 | ||||||
|             var loadButton = new GenericButtonConfigItem(section, "Load Palette from the Current Track", |             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); |                 "Override custom palette with the built-in palette of the current track.", "Load", load); | ||||||
|             loadButton.ButtonOptions.CanModifyCallback = CanModifyIfHost; |  | ||||||
|             LethalConfigManager.AddConfigItem(loadButton); |             LethalConfigManager.AddConfigItem(loadButton); | ||||||
| 
 | 
 | ||||||
|             customPaletteSizeEntry = configFile.Bind(section, "Palette Size", 0, new ConfigDescription( |             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", |             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); |                 "Override custom timings with the built-in timings of the current track.", "Load", load); | ||||||
|             loadButton.ButtonOptions.CanModifyCallback = CanModifyIfHost; |  | ||||||
|             LethalConfigManager.AddConfigItem(loadButton); |             LethalConfigManager.AddConfigItem(loadButton); | ||||||
| 
 | 
 | ||||||
|             overrideTimingsEntry = configFile.Bind(section, "Override Timings", false, |             overrideTimingsEntry = configFile.Bind(section, "Override Timings", false, | ||||||
|  | @ -2697,7 +2657,6 @@ namespace MuzikaGromche | ||||||
|         private T Default<T>(T options) where T : BaseOptions |         private T Default<T>(T options) where T : BaseOptions | ||||||
|         { |         { | ||||||
|             options.RequiresRestart = false; |             options.RequiresRestart = false; | ||||||
|             options.CanModifyCallback = CanModifyIfHost; |  | ||||||
|             return options; |             return options; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue