Move cheats option to rules.

This commit is contained in:
Paul Chote
2016-02-29 17:52:54 +00:00
parent 5e59a9d1c1
commit aed8518e04
9 changed files with 40 additions and 10 deletions

View File

@@ -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<DeveloperModeInfo>();
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<DeveloperModeInfo>();
gs.AllowCheats = devMode.Enabled;
server.Map.Options.UpdateServerSettings(server.LobbyInfo.GlobalSettings);
}

View File

@@ -349,8 +349,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var allowCheats = optionsBin.GetOrNull<CheckboxWidget>("ALLOWCHEATS_CHECKBOX");
if (allowCheats != null)
{
var cheatsLocked = new CachedTransform<Map, bool>(
map => map.Rules.Actors["player"].TraitInfo<DeveloperModeInfo>().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)));
}