diff --git a/OpenRA.Mods.Common/Traits/Buildings/BaseProvider.cs b/OpenRA.Mods.Common/Traits/Buildings/BaseProvider.cs index 894505f736..0fdecca6a6 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/BaseProvider.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/BaseProvider.cs @@ -32,12 +32,13 @@ namespace OpenRA.Mods.Common.Traits public readonly BaseProviderInfo Info; readonly DeveloperMode devMode; readonly Actor self; + readonly bool allyBuildEnabled; + readonly bool buildRadiusEnabled; Building building; int total; int progress; - bool allyBuildEnabled; public BaseProvider(Actor self, BaseProviderInfo info) { @@ -45,7 +46,9 @@ namespace OpenRA.Mods.Common.Traits this.self = self; devMode = self.Owner.PlayerActor.Trait(); progress = total = info.InitialDelay; - allyBuildEnabled = self.World.WorldActor.Trait().AllyBuildRadiusEnabled; + var mapBuildRadius = self.World.WorldActor.Trait(); + allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled; + buildRadiusEnabled = mapBuildRadius.BuildRadiusEnabled; } void INotifyCreated.Created(Actor self) @@ -74,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits bool ValidRenderPlayer() { - return self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer)); + return buildRadiusEnabled && (self.Owner == self.World.RenderPlayer || (allyBuildEnabled && self.Owner.IsAlliedWith(self.World.RenderPlayer))); } public IEnumerable RangeCircleRenderables(WorldRenderer wr) diff --git a/OpenRA.Mods.Common/Traits/Buildings/Building.cs b/OpenRA.Mods.Common/Traits/Buildings/Building.cs index 82170b2116..d099b8a155 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Building.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Building.cs @@ -154,7 +154,11 @@ namespace OpenRA.Mods.Common.Traits public Actor FindBaseProvider(World world, Player p, CPos topLeft) { var center = world.Map.CenterOfCell(topLeft) + CenterOffset(world); - var allyBuildEnabled = world.WorldActor.Trait().AllyBuildRadiusEnabled; + var mapBuildRadius = world.WorldActor.Trait(); + var allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled; + + if (!mapBuildRadius.BuildRadiusEnabled) + return null; foreach (var bp in world.ActorsWithTrait()) { @@ -173,10 +177,11 @@ namespace OpenRA.Mods.Common.Traits public virtual bool IsCloseEnoughToBase(World world, Player p, string buildingName, CPos topLeft) { + var mapBuildRadius = world.WorldActor.Trait(); if (Adjacent < 0 || p.PlayerActor.Trait().BuildAnywhere) return true; - if (RequiresBaseProvider && FindBaseProvider(world, p, topLeft) == null) + if (mapBuildRadius.BuildRadiusEnabled && RequiresBaseProvider && FindBaseProvider(world, p, topLeft) == null) return false; var buildingMaxBounds = Dimensions; @@ -186,7 +191,7 @@ namespace OpenRA.Mods.Common.Traits var nearnessCandidates = new List(); var bi = world.WorldActor.Trait(); - var allyBuildEnabled = world.WorldActor.Trait().AllyBuildRadiusEnabled; + var allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled; for (var y = scanStart.Y; y < scanEnd.Y; y++) { diff --git a/OpenRA.Mods.Common/Traits/World/MapBuildRadius.cs b/OpenRA.Mods.Common/Traits/World/MapBuildRadius.cs index 4bdde69ff1..b70b1cf917 100644 --- a/OpenRA.Mods.Common/Traits/World/MapBuildRadius.cs +++ b/OpenRA.Mods.Common/Traits/World/MapBuildRadius.cs @@ -23,9 +23,17 @@ namespace OpenRA.Mods.Common.Traits [Desc("Prevent the ally build radius state from being changed in the lobby.")] public readonly bool AllyBuildRadiusLocked = false; + [Desc("Default value of the build radius checkbox in the lobby.")] + public readonly bool BuildRadiusEnabled = true; + + [Desc("Prevent the build radius state from being changed in the lobby.")] + public readonly bool BuildRadiusLocked = false; + IEnumerable ILobbyOptions.LobbyOptions(Ruleset rules) { yield return new LobbyBooleanOption("allybuild", "Build off Allies' ConYards", AllyBuildRadiusEnabled, AllyBuildRadiusLocked); + + yield return new LobbyBooleanOption("buildradius", "Limit ConYard Area", BuildRadiusEnabled, BuildRadiusLocked); } public object Create(ActorInitializer init) { return new MapBuildRadius(this); } @@ -35,6 +43,7 @@ namespace OpenRA.Mods.Common.Traits { readonly MapBuildRadiusInfo info; public bool AllyBuildRadiusEnabled { get; private set; } + public bool BuildRadiusEnabled { get; private set; } public MapBuildRadius(MapBuildRadiusInfo info) { @@ -45,6 +54,8 @@ namespace OpenRA.Mods.Common.Traits { AllyBuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings .OptionOrDefault("allybuild", info.AllyBuildRadiusEnabled); + BuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings + .OptionOrDefault("buildradius", info.BuildRadiusEnabled); } } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index 0c07926e05..8de81daac6 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -350,6 +350,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { "ALLYBUILDRADIUS_CHECKBOX", "allybuild" }, { "ALLOWCHEATS_CHECKBOX", "cheats" }, { "CREEPS_CHECKBOX", "creeps" }, + { "BUILDRADIUS_CHECKBOX", "buildradius" }, }; foreach (var kv in optionCheckboxes) diff --git a/mods/cnc/chrome/lobby-options.yaml b/mods/cnc/chrome/lobby-options.yaml index 35af18e339..d4feee2354 100644 --- a/mods/cnc/chrome/lobby-options.yaml +++ b/mods/cnc/chrome/lobby-options.yaml @@ -53,6 +53,12 @@ Background@LOBBY_OPTIONS_BIN: Height: 20 Font: Regular Text: Debug Menu + Checkbox@BUILDRADIUS_CHECKBOX: + Y: 70 + Width: 150 + Height: 20 + Font: Regular + Text: Limit ConYard Area Label@DIFFICULTY_DESC: X: PARENT_RIGHT - WIDTH - 165 Y: 70 diff --git a/mods/ra/chrome/lobby-options.yaml b/mods/ra/chrome/lobby-options.yaml new file mode 100644 index 0000000000..dbbf091ec8 --- /dev/null +++ b/mods/ra/chrome/lobby-options.yaml @@ -0,0 +1,120 @@ +Background@LOBBY_OPTIONS_BIN: + Width: PARENT_RIGHT + Height: PARENT_BOTTOM + Background: dialog3 + Children: + Label@TITLE: + X: 0 + Y: 0 - 27 + Width: PARENT_RIGHT + Height: 25 + Font: Bold + Align: Center + Text: Map Options + Container: + X: 30 + Y: 30 + Width: PARENT_RIGHT - 60 + Height: PARENT_BOTTOM - 75 + Children: + Checkbox@EXPLORED_MAP_CHECKBOX: + Width: 150 + Height: 20 + Text: Explored Map + Checkbox@FOG_CHECKBOX: + Y: 35 + Width: 150 + Height: 20 + Text: Fog of War + Checkbox@CRATES_CHECKBOX: + X: 170 + Width: 225 + Height: 20 + Text: Crates + Checkbox@ALLYBUILDRADIUS_CHECKBOX: + X: 170 + Y: 35 + Width: 225 + Height: 20 + Text: Build off Allies' ConYards + Checkbox@SHORTGAME_CHECKBOX: + X: 400 + Width: 150 + Height: 20 + Text: Short Game + Checkbox@ALLOWCHEATS_CHECKBOX: + X: 400 + Y: 35 + Width: 150 + Height: 20 + Text: Debug Menu + Checkbox@BUILDRADIUS_CHECKBOX: + Y: 70 + Width: 225 + Height: 20 + Text: Limit ConYard Area + Label@DIFFICULTY_DESC: + X: PARENT_RIGHT - WIDTH - 165 + Y: 70 + Width: 160 + Height: 25 + Text: Mission Difficulty: + Align: Right + DropDownButton@DIFFICULTY_DROPDOWNBUTTON: + X: PARENT_RIGHT - WIDTH + Y: 70 + Width: 160 + Height: 25 + Font: Regular + Label@STARTINGCASH_DESC: + Y: 110 + Width: 80 + Height: 25 + Text: Starting Cash: + Align: Right + DropDownButton@STARTINGCASH_DROPDOWNBUTTON: + X: 85 + Y: 110 + Width: 160 + Height: 25 + Font: Regular + Text: $5000 + Label@STARTINGUNITS_DESC: + X: PARENT_RIGHT - WIDTH - 165 + Y: 110 + Width: 120 + Height: 25 + Text: Starting Units: + Align: Right + DropDownButton@STARTINGUNITS_DROPDOWNBUTTON: + X: PARENT_RIGHT - WIDTH + Y: 110 + Width: 160 + Height: 25 + Font: Regular + DropDownButton@TECHLEVEL_DROPDOWNBUTTON: + X: 85 + Y: 150 + Width: 160 + Height: 25 + Font: Regular + Text: 10 + Label@TECHLEVEL_DESC: + Y: 150 + Width: 80 + Height: 25 + Text: Tech Level: + Align: Right + Label@GAMESPEED_DESC: + X: PARENT_RIGHT - WIDTH - 165 + Y: 150 + Width: 120 + Height: 25 + Text: Game Speed: + Align: Right + DropDownButton@GAMESPEED_DROPDOWNBUTTON: + X: PARENT_RIGHT - WIDTH + Y: 150 + Width: 160 + Height: 25 + Font: Regular diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index aaa167672e..73fbba4e3a 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -100,7 +100,7 @@ ChromeLayout: common|chrome/lobby.yaml common|chrome/lobby-mappreview.yaml common|chrome/lobby-players.yaml - common|chrome/lobby-options.yaml + ra|chrome/lobby-options.yaml common|chrome/lobby-music.yaml common|chrome/lobby-kickdialogs.yaml common|chrome/lobby-globalchat.yaml