Move shroud options to rules.

This commit is contained in:
Paul Chote
2016-02-29 18:43:01 +00:00
parent f44993e4f7
commit 62f28d2909
8 changed files with 29 additions and 18 deletions

View File

@@ -59,8 +59,6 @@ namespace OpenRA
public class MapOptions public class MapOptions
{ {
public bool? Creeps; public bool? Creeps;
public bool? Fog;
public bool? Shroud;
public bool? AllyBuildRadius; public bool? AllyBuildRadius;
public int? StartingCash; public int? StartingCash;
public string TechLevel; public string TechLevel;
@@ -72,10 +70,6 @@ namespace OpenRA
{ {
if (Creeps.HasValue) if (Creeps.HasValue)
settings.Creeps = Creeps.Value; settings.Creeps = Creeps.Value;
if (Fog.HasValue)
settings.Fog = Fog.Value;
if (Shroud.HasValue)
settings.Shroud = Shroud.Value;
if (AllyBuildRadius.HasValue) if (AllyBuildRadius.HasValue)
settings.AllyBuildRadius = AllyBuildRadius.Value; settings.AllyBuildRadius = AllyBuildRadius.Value;
if (StartingCash.HasValue) if (StartingCash.HasValue)

View File

@@ -18,6 +18,18 @@ namespace OpenRA.Traits
[Desc("Required for shroud and fog visibility checks. Add this to the player actor.")] [Desc("Required for shroud and fog visibility checks. Add this to the player actor.")]
public class ShroudInfo : ITraitInfo public class ShroudInfo : ITraitInfo
{ {
[Desc("Default value of the fog checkbox in the lobby.")]
public bool FogEnabled = true;
[Desc("Prevent the fog enabled state from being changed in the lobby.")]
public bool FogLocked = false;
[Desc("Default value of the explore map checkbox in the lobby.")]
public bool ExploredMapEnabled = false;
[Desc("Prevent the explore map enabled state from being changed in the lobby.")]
public bool ExploredMapLocked = false;
public object Create(ActorInitializer init) { return new Shroud(init.Self); } public object Create(ActorInitializer init) { return new Shroud(init.Self); }
} }

View File

@@ -432,7 +432,8 @@ namespace OpenRA.Mods.Common.Server
return true; return true;
} }
if (server.Map.Options.Shroud.HasValue) var shroud = server.Map.Rules.Actors["player"].TraitInfo<ShroudInfo>();
if (shroud.ExploredMapLocked)
{ {
server.SendOrderTo(conn, "Message", "Map has disabled shroud configuration."); server.SendOrderTo(conn, "Message", "Map has disabled shroud configuration.");
return true; return true;
@@ -455,7 +456,8 @@ namespace OpenRA.Mods.Common.Server
return true; return true;
} }
if (server.Map.Options.Fog.HasValue) var shroud = server.Map.Rules.Actors["player"].TraitInfo<ShroudInfo>();
if (shroud.FogLocked)
{ {
server.SendOrderTo(conn, "Message", "Map has disabled fog configuration."); server.SendOrderTo(conn, "Message", "Map has disabled fog configuration.");
return true; return true;
@@ -1019,6 +1021,11 @@ namespace OpenRA.Mods.Common.Server
var crateSpawner = server.Map.Rules.Actors["world"].TraitInfoOrDefault<CrateSpawnerInfo>(); var crateSpawner = server.Map.Rules.Actors["world"].TraitInfoOrDefault<CrateSpawnerInfo>();
gs.Crates = crateSpawner != null && crateSpawner.Enabled; gs.Crates = crateSpawner != null && crateSpawner.Enabled;
var shroud = server.Map.Rules.Actors["player"].TraitInfo<ShroudInfo>();
gs.Fog = shroud.FogEnabled;
gs.Shroud = !shroud.ExploredMapEnabled;
server.Map.Options.UpdateServerSettings(server.LobbyInfo.GlobalSettings); server.Map.Options.UpdateServerSettings(server.LobbyInfo.GlobalSettings);
} }

View File

@@ -562,8 +562,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var exploredMap = optionsBin.GetOrNull<CheckboxWidget>("EXPLORED_MAP_CHECKBOX"); var exploredMap = optionsBin.GetOrNull<CheckboxWidget>("EXPLORED_MAP_CHECKBOX");
if (exploredMap != null) if (exploredMap != null)
{ {
var exploredMapLocked = new CachedTransform<Map, bool>(
map => map.Rules.Actors["player"].TraitInfo<ShroudInfo>().ExploredMapLocked);
exploredMap.IsChecked = () => !orderManager.LobbyInfo.GlobalSettings.Shroud; exploredMap.IsChecked = () => !orderManager.LobbyInfo.GlobalSettings.Shroud;
exploredMap.IsDisabled = () => configurationDisabled() || Map.Options.Shroud.HasValue; exploredMap.IsDisabled = () => configurationDisabled() || exploredMapLocked.Update(Map);
exploredMap.OnClick = () => orderManager.IssueOrder(Order.Command( exploredMap.OnClick = () => orderManager.IssueOrder(Order.Command(
"shroud {0}".F(!orderManager.LobbyInfo.GlobalSettings.Shroud))); "shroud {0}".F(!orderManager.LobbyInfo.GlobalSettings.Shroud)));
} }
@@ -571,8 +574,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var enableFog = optionsBin.GetOrNull<CheckboxWidget>("FOG_CHECKBOX"); var enableFog = optionsBin.GetOrNull<CheckboxWidget>("FOG_CHECKBOX");
if (enableFog != null) if (enableFog != null)
{ {
var fogLocked = new CachedTransform<Map, bool>(
map => map.Rules.Actors["player"].TraitInfo<ShroudInfo>().FogLocked);
enableFog.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Fog; enableFog.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Fog;
enableFog.IsDisabled = () => configurationDisabled() || Map.Options.Fog.HasValue; enableFog.IsDisabled = () => configurationDisabled() || fogLocked.Update(Map);
enableFog.OnClick = () => orderManager.IssueOrder(Order.Command( enableFog.OnClick = () => orderManager.IssueOrder(Order.Command(
"fog {0}".F(!orderManager.LobbyInfo.GlobalSettings.Fog))); "fog {0}".F(!orderManager.LobbyInfo.GlobalSettings.Fog)));
} }

View File

@@ -165,8 +165,6 @@ ServerTraits:
LobbyDefaults: LobbyDefaults:
StartingUnitsClass: light StartingUnitsClass: light
FragileAlliances: false FragileAlliances: false
Shroud: true
Fog: true
TechLevel: Unrestricted TechLevel: Unrestricted
ChromeMetrics: ChromeMetrics:

View File

@@ -158,8 +158,6 @@ ServerTraits:
LobbyDefaults: LobbyDefaults:
StartingUnitsClass: none StartingUnitsClass: none
FragileAlliances: false FragileAlliances: false
Shroud: true
Fog: true
TechLevel: Unrestricted TechLevel: Unrestricted
ChromeMetrics: ChromeMetrics:

View File

@@ -168,8 +168,6 @@ ServerTraits:
LobbyDefaults: LobbyDefaults:
StartingUnitsClass: none StartingUnitsClass: none
FragileAlliances: false FragileAlliances: false
Shroud: true
Fog: true
TechLevel: Unrestricted TechLevel: Unrestricted
ChromeMetrics: ChromeMetrics:

View File

@@ -217,8 +217,6 @@ ServerTraits:
LobbyDefaults: LobbyDefaults:
StartingUnitsClass: none StartingUnitsClass: none
FragileAlliances: false FragileAlliances: false
Shroud: true
Fog: true
ChromeMetrics: ChromeMetrics:
common|metrics.yaml common|metrics.yaml