Added buildradius checkbox to lobby options
This commit is contained in:
@@ -32,12 +32,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly BaseProviderInfo Info;
|
public readonly BaseProviderInfo Info;
|
||||||
readonly DeveloperMode devMode;
|
readonly DeveloperMode devMode;
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
|
readonly bool allyBuildEnabled;
|
||||||
|
readonly bool buildRadiusEnabled;
|
||||||
|
|
||||||
Building building;
|
Building building;
|
||||||
|
|
||||||
int total;
|
int total;
|
||||||
int progress;
|
int progress;
|
||||||
bool allyBuildEnabled;
|
|
||||||
|
|
||||||
public BaseProvider(Actor self, BaseProviderInfo info)
|
public BaseProvider(Actor self, BaseProviderInfo info)
|
||||||
{
|
{
|
||||||
@@ -45,7 +46,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
this.self = self;
|
this.self = self;
|
||||||
devMode = self.Owner.PlayerActor.Trait<DeveloperMode>();
|
devMode = self.Owner.PlayerActor.Trait<DeveloperMode>();
|
||||||
progress = total = info.InitialDelay;
|
progress = total = info.InitialDelay;
|
||||||
allyBuildEnabled = self.World.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled;
|
var mapBuildRadius = self.World.WorldActor.Trait<MapBuildRadius>();
|
||||||
|
allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled;
|
||||||
|
buildRadiusEnabled = mapBuildRadius.BuildRadiusEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
void INotifyCreated.Created(Actor self)
|
||||||
@@ -74,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
bool ValidRenderPlayer()
|
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<IRenderable> RangeCircleRenderables(WorldRenderer wr)
|
public IEnumerable<IRenderable> RangeCircleRenderables(WorldRenderer wr)
|
||||||
|
|||||||
@@ -154,7 +154,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public Actor FindBaseProvider(World world, Player p, CPos topLeft)
|
public Actor FindBaseProvider(World world, Player p, CPos topLeft)
|
||||||
{
|
{
|
||||||
var center = world.Map.CenterOfCell(topLeft) + CenterOffset(world);
|
var center = world.Map.CenterOfCell(topLeft) + CenterOffset(world);
|
||||||
var allyBuildEnabled = world.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled;
|
var mapBuildRadius = world.WorldActor.Trait<MapBuildRadius>();
|
||||||
|
var allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled;
|
||||||
|
|
||||||
|
if (!mapBuildRadius.BuildRadiusEnabled)
|
||||||
|
return null;
|
||||||
|
|
||||||
foreach (var bp in world.ActorsWithTrait<BaseProvider>())
|
foreach (var bp in world.ActorsWithTrait<BaseProvider>())
|
||||||
{
|
{
|
||||||
@@ -173,10 +177,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public virtual bool IsCloseEnoughToBase(World world, Player p, string buildingName, CPos topLeft)
|
public virtual bool IsCloseEnoughToBase(World world, Player p, string buildingName, CPos topLeft)
|
||||||
{
|
{
|
||||||
|
var mapBuildRadius = world.WorldActor.Trait<MapBuildRadius>();
|
||||||
if (Adjacent < 0 || p.PlayerActor.Trait<DeveloperMode>().BuildAnywhere)
|
if (Adjacent < 0 || p.PlayerActor.Trait<DeveloperMode>().BuildAnywhere)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (RequiresBaseProvider && FindBaseProvider(world, p, topLeft) == null)
|
if (mapBuildRadius.BuildRadiusEnabled && RequiresBaseProvider && FindBaseProvider(world, p, topLeft) == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var buildingMaxBounds = Dimensions;
|
var buildingMaxBounds = Dimensions;
|
||||||
@@ -186,7 +191,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
var nearnessCandidates = new List<CPos>();
|
var nearnessCandidates = new List<CPos>();
|
||||||
var bi = world.WorldActor.Trait<BuildingInfluence>();
|
var bi = world.WorldActor.Trait<BuildingInfluence>();
|
||||||
var allyBuildEnabled = world.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled;
|
var allyBuildEnabled = mapBuildRadius.AllyBuildRadiusEnabled;
|
||||||
|
|
||||||
for (var y = scanStart.Y; y < scanEnd.Y; y++)
|
for (var y = scanStart.Y; y < scanEnd.Y; y++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,9 +23,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Prevent the ally build radius state from being changed in the lobby.")]
|
[Desc("Prevent the ally build radius state from being changed in the lobby.")]
|
||||||
public readonly bool AllyBuildRadiusLocked = false;
|
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<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
||||||
{
|
{
|
||||||
yield return new LobbyBooleanOption("allybuild", "Build off Allies' ConYards", AllyBuildRadiusEnabled, AllyBuildRadiusLocked);
|
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); }
|
public object Create(ActorInitializer init) { return new MapBuildRadius(this); }
|
||||||
@@ -35,6 +43,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
readonly MapBuildRadiusInfo info;
|
readonly MapBuildRadiusInfo info;
|
||||||
public bool AllyBuildRadiusEnabled { get; private set; }
|
public bool AllyBuildRadiusEnabled { get; private set; }
|
||||||
|
public bool BuildRadiusEnabled { get; private set; }
|
||||||
|
|
||||||
public MapBuildRadius(MapBuildRadiusInfo info)
|
public MapBuildRadius(MapBuildRadiusInfo info)
|
||||||
{
|
{
|
||||||
@@ -45,6 +54,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
AllyBuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings
|
AllyBuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings
|
||||||
.OptionOrDefault("allybuild", info.AllyBuildRadiusEnabled);
|
.OptionOrDefault("allybuild", info.AllyBuildRadiusEnabled);
|
||||||
|
BuildRadiusEnabled = self.World.LobbyInfo.GlobalSettings
|
||||||
|
.OptionOrDefault("buildradius", info.BuildRadiusEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -350,6 +350,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{ "ALLYBUILDRADIUS_CHECKBOX", "allybuild" },
|
{ "ALLYBUILDRADIUS_CHECKBOX", "allybuild" },
|
||||||
{ "ALLOWCHEATS_CHECKBOX", "cheats" },
|
{ "ALLOWCHEATS_CHECKBOX", "cheats" },
|
||||||
{ "CREEPS_CHECKBOX", "creeps" },
|
{ "CREEPS_CHECKBOX", "creeps" },
|
||||||
|
{ "BUILDRADIUS_CHECKBOX", "buildradius" },
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var kv in optionCheckboxes)
|
foreach (var kv in optionCheckboxes)
|
||||||
|
|||||||
@@ -53,6 +53,12 @@ Background@LOBBY_OPTIONS_BIN:
|
|||||||
Height: 20
|
Height: 20
|
||||||
Font: Regular
|
Font: Regular
|
||||||
Text: Debug Menu
|
Text: Debug Menu
|
||||||
|
Checkbox@BUILDRADIUS_CHECKBOX:
|
||||||
|
Y: 70
|
||||||
|
Width: 150
|
||||||
|
Height: 20
|
||||||
|
Font: Regular
|
||||||
|
Text: Limit ConYard Area
|
||||||
Label@DIFFICULTY_DESC:
|
Label@DIFFICULTY_DESC:
|
||||||
X: PARENT_RIGHT - WIDTH - 165
|
X: PARENT_RIGHT - WIDTH - 165
|
||||||
Y: 70
|
Y: 70
|
||||||
|
|||||||
120
mods/ra/chrome/lobby-options.yaml
Normal file
120
mods/ra/chrome/lobby-options.yaml
Normal file
@@ -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
|
||||||
@@ -100,7 +100,7 @@ ChromeLayout:
|
|||||||
common|chrome/lobby.yaml
|
common|chrome/lobby.yaml
|
||||||
common|chrome/lobby-mappreview.yaml
|
common|chrome/lobby-mappreview.yaml
|
||||||
common|chrome/lobby-players.yaml
|
common|chrome/lobby-players.yaml
|
||||||
common|chrome/lobby-options.yaml
|
ra|chrome/lobby-options.yaml
|
||||||
common|chrome/lobby-music.yaml
|
common|chrome/lobby-music.yaml
|
||||||
common|chrome/lobby-kickdialogs.yaml
|
common|chrome/lobby-kickdialogs.yaml
|
||||||
common|chrome/lobby-globalchat.yaml
|
common|chrome/lobby-globalchat.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user