diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index c873bf9502..f101d62e41 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -58,7 +58,6 @@ namespace OpenRA public class MapOptions { - public bool? Cheats; public bool? Crates; public bool? Creeps; public bool? Fog; @@ -72,8 +71,6 @@ namespace OpenRA public void UpdateServerSettings(Session.Global settings) { - if (Cheats.HasValue) - settings.AllowCheats = Cheats.Value; if (Crates.HasValue) settings.Crates = Crates.Value; if (Creeps.HasValue) diff --git a/OpenRA.Game/Traits/Player/DeveloperMode.cs b/OpenRA.Game/Traits/Player/DeveloperMode.cs index d74bec2f4f..ac628dc1cb 100644 --- a/OpenRA.Game/Traits/Player/DeveloperMode.cs +++ b/OpenRA.Game/Traits/Player/DeveloperMode.cs @@ -14,17 +14,46 @@ namespace OpenRA.Traits [Desc("Attach this to the player actor.")] public class DeveloperModeInfo : ITraitInfo { + [Desc("Default value of the developer mode checkbox in the lobby.")] + public bool Enabled = false; + + [Desc("Prevent the developer mode state from being changed in the lobby.")] + public bool Locked = false; + + [Desc("Default cash bonus granted by the give cash cheat.")] public int Cash = 20000; + + [Desc("Growth steps triggered by the grow resources button.")] public int ResourceGrowth = 100; + + [Desc("Enable the fast build cheat by default.")] public bool FastBuild; + + [Desc("Enable the fast support powers cheat by default.")] public bool FastCharge; + + [Desc("Enable the disable visibility cheat by default.")] public bool DisableShroud; - public bool PathDebug; + + [Desc("Enable the unlimited power cheat by default.")] public bool UnlimitedPower; + + [Desc("Enable the build anywhere cheat by default.")] public bool BuildAnywhere; + + [Desc("Enable the path debug overlay by default.")] + public bool PathDebug; + + [Desc("Enable the combat geometry overlay by default.")] public bool ShowCombatGeometry; + + [Desc("Enable the debug geometry overlay by default.")] public bool ShowDebugGeometry; + + [Desc("Enable the depth buffer overlay by default.")] public bool ShowDepthPreview; + + [Desc("Enable the actor tags overlay by default.")] public bool ShowActorTags; public object Create(ActorInitializer init) { return new DeveloperMode(this); } diff --git a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs index feb026946f..052fcf2541 100644 --- a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs @@ -408,7 +408,8 @@ namespace OpenRA.Mods.Common.Server return true; } - if (server.Map.Options.Cheats.HasValue) + var devMode = server.Map.Rules.Actors["player"].TraitInfo(); + if (devMode.Locked) { server.SendOrderTo(conn, "Message", "Map has disabled cheat configuration."); return true; @@ -1011,6 +1012,9 @@ namespace OpenRA.Mods.Common.Server .Where(s => s != null) .ToDictionary(s => s.PlayerReference, s => s); + var gs = server.LobbyInfo.GlobalSettings; + var devMode = server.Map.Rules.Actors["player"].TraitInfo(); + gs.AllowCheats = devMode.Enabled; server.Map.Options.UpdateServerSettings(server.LobbyInfo.GlobalSettings); } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index 836b8b4ed4..704f4dd120 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -349,8 +349,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic var allowCheats = optionsBin.GetOrNull("ALLOWCHEATS_CHECKBOX"); if (allowCheats != null) { + var cheatsLocked = new CachedTransform( + map => map.Rules.Actors["player"].TraitInfo().Locked); + allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats; - allowCheats.IsDisabled = () => configurationDisabled() || Map.Options.Cheats.HasValue; + allowCheats.IsDisabled = () => configurationDisabled() || cheatsLocked.Update(Map); allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command( "allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats))); } diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index 6054801125..84257f7d57 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -163,7 +163,6 @@ ServerTraits: LobbySettingsNotification LobbyDefaults: - AllowCheats: false Crates: true StartingUnitsClass: light FragileAlliances: false diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml index 803adf11c9..c68c5a5ea4 100644 --- a/mods/d2k/mod.yaml +++ b/mods/d2k/mod.yaml @@ -156,7 +156,6 @@ ServerTraits: LobbySettingsNotification LobbyDefaults: - AllowCheats: false Crates: true StartingUnitsClass: none FragileAlliances: false diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index ce39ee15a0..d3fcfeb8c0 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -166,7 +166,6 @@ ServerTraits: LobbySettingsNotification LobbyDefaults: - AllowCheats: false Crates: true StartingUnitsClass: none FragileAlliances: false diff --git a/mods/ts/mod.yaml b/mods/ts/mod.yaml index 6684bfda44..54daa296fe 100644 --- a/mods/ts/mod.yaml +++ b/mods/ts/mod.yaml @@ -215,7 +215,6 @@ ServerTraits: LobbySettingsNotification LobbyDefaults: - AllowCheats: true Crates: true StartingUnitsClass: none FragileAlliances: false diff --git a/mods/ts/rules/player.yaml b/mods/ts/rules/player.yaml index 141e5d8617..da243b3670 100644 --- a/mods/ts/rules/player.yaml +++ b/mods/ts/rules/player.yaml @@ -42,6 +42,7 @@ Player: PlayerResources: ActorGroupProxy: DeveloperMode: + Enabled: true Shroud: FrozenActorLayer: BaseAttackNotifier: