Add starting cash option.
This commit is contained in:
@@ -29,6 +29,7 @@ namespace OpenRA
|
||||
public bool? Shroud;
|
||||
public bool? AllyBuildRadius;
|
||||
public bool? FragileAlliances;
|
||||
public int? StartingCash;
|
||||
public bool ConfigurableStartingUnits = true;
|
||||
public string[] Difficulties = { };
|
||||
|
||||
@@ -44,6 +45,8 @@ namespace OpenRA
|
||||
settings.Shroud = Shroud.Value;
|
||||
if (AllyBuildRadius.HasValue)
|
||||
settings.AllyBuildRadius = AllyBuildRadius.Value;
|
||||
if (StartingCash.HasValue)
|
||||
settings.StartingCash = StartingCash.Value;
|
||||
if (FragileAlliances.HasValue)
|
||||
settings.FragileAlliances = FragileAlliances.Value;
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ namespace OpenRA.Network
|
||||
public bool Shroud = true;
|
||||
public bool Fog = true;
|
||||
public bool AllyBuildRadius = true;
|
||||
public int StartingCash = 5000;
|
||||
public string StartingUnitsClass = "none";
|
||||
public bool AllowVersionMismatch;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace OpenRA.Traits
|
||||
{
|
||||
public class PlayerResourcesInfo : ITraitInfo
|
||||
{
|
||||
public readonly int InitialCash = 10000;
|
||||
public readonly int InitialOre = 0;
|
||||
public readonly int[] SelectableCash = { 2500, 5000, 10000, 20000 };
|
||||
public readonly int DefaultCash = 5000;
|
||||
public readonly int AdviceInterval = 250;
|
||||
|
||||
public object Create(ActorInitializer init) { return new PlayerResources(init.self, this); }
|
||||
@@ -34,8 +34,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
Owner = self.Owner;
|
||||
|
||||
Cash = info.InitialCash;
|
||||
Ore = info.InitialOre;
|
||||
Cash = self.World.LobbyInfo.GlobalSettings.StartingCash;
|
||||
AdviceInterval = info.AdviceInterval;
|
||||
}
|
||||
|
||||
|
||||
@@ -495,6 +495,25 @@ namespace OpenRA.Mods.RA.Server
|
||||
server.SyncLobbyInfo();
|
||||
return true;
|
||||
}},
|
||||
{ "startingcash",
|
||||
s =>
|
||||
{
|
||||
if (!client.IsAdmin)
|
||||
{
|
||||
server.SendOrderTo(conn, "Message", "Only the host can set that option");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (server.Map.Options.StartingCash.HasValue)
|
||||
{
|
||||
server.SendOrderTo(conn, "Message", "Map has disabled cash configuration");
|
||||
return true;
|
||||
}
|
||||
|
||||
server.lobbyInfo.GlobalSettings.StartingCash = int.Parse(s);
|
||||
server.SyncLobbyInfo();
|
||||
return true;
|
||||
}},
|
||||
{ "kick",
|
||||
s =>
|
||||
{
|
||||
|
||||
@@ -368,6 +368,31 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
optionsBin.Get<LabelWidget>("STARTINGUNITS_DESC").IsVisible = startingUnits.IsVisible;
|
||||
}
|
||||
|
||||
var startingCash = optionsBin.GetOrNull<DropDownButtonWidget>("STARTINGCASH_DROPDOWNBUTTON");
|
||||
if (startingCash != null)
|
||||
{
|
||||
startingCash.IsDisabled = () => Map.Options.StartingCash.HasValue || configurationDisabled();
|
||||
startingCash.GetText = () => Map.Options.StartingCash.HasValue ? "Not Available" : "${0}".F(orderManager.LobbyInfo.GlobalSettings.StartingCash);
|
||||
startingCash.OnMouseDown = _ =>
|
||||
{
|
||||
var options = Rules.Info["player"].Traits.Get<PlayerResourcesInfo>().SelectableCash.Select(c => new DropDownOption
|
||||
{
|
||||
Title = "${0}".F(c),
|
||||
IsSelected = () => orderManager.LobbyInfo.GlobalSettings.StartingCash == c,
|
||||
OnClick = () => orderManager.IssueOrder(Order.Command("startingcash {0}".F(c)))
|
||||
});
|
||||
|
||||
Func<DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
|
||||
return item;
|
||||
};
|
||||
|
||||
startingCash.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem);
|
||||
};
|
||||
}
|
||||
|
||||
var enableShroud = optionsBin.GetOrNull<CheckboxWidget>("SHROUD_CHECKBOX");
|
||||
if (enableShroud != null)
|
||||
{
|
||||
@@ -481,6 +506,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
else
|
||||
throw new InvalidOperationException("Server's new map doesn't exist on your system and Downloading turned off");
|
||||
Map = new Map(Game.modData.AvailableMaps[MapUid].Path);
|
||||
|
||||
// Restore default starting cash if the last map set it to something invalid
|
||||
var pri = Rules.Info["player"].Traits.Get<PlayerResourcesInfo>();
|
||||
if (!Map.Options.StartingCash.HasValue && !pri.SelectableCash.Contains(orderManager.LobbyInfo.GlobalSettings.StartingCash))
|
||||
orderManager.IssueOrder(Order.Command("startingcash {0}".F(pri.DefaultCash)));
|
||||
}
|
||||
|
||||
void UpdatePlayerList()
|
||||
|
||||
@@ -249,6 +249,20 @@ Background@LOBBY_OPTIONS_BIN:
|
||||
Width:230
|
||||
Height:20
|
||||
Text:Build off Ally ConYards
|
||||
Label@STARTINGCASH_DESC:
|
||||
X:10
|
||||
Y:72
|
||||
Width:80
|
||||
Height:25
|
||||
Text:Starting Cash:
|
||||
Align:Right
|
||||
DropDownButton@STARTINGCASH_DROPDOWNBUTTON:
|
||||
X:95
|
||||
Y:72
|
||||
Width:120
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:$5000
|
||||
Label@STARTINGUNITS_DESC:
|
||||
X:PARENT_RIGHT - WIDTH - 145
|
||||
Y:72
|
||||
|
||||
@@ -26,6 +26,7 @@ Options:
|
||||
Shroud: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 500
|
||||
ConfigurableStartingUnits: false
|
||||
|
||||
Players:
|
||||
@@ -47,7 +48,6 @@ Players:
|
||||
LockSpawn: True
|
||||
Spawn: 0
|
||||
AllowBots: False
|
||||
InitialCash: 20
|
||||
Allies: GoodGuy
|
||||
Enemies: BadGuy,Creeps
|
||||
Required: True
|
||||
|
||||
@@ -26,6 +26,7 @@ Options:
|
||||
Shroud: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 0
|
||||
ConfigurableStartingUnits: false
|
||||
|
||||
Players:
|
||||
|
||||
@@ -24,6 +24,7 @@ Options:
|
||||
Crates: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 5000
|
||||
ConfigurableStartingUnits: false
|
||||
|
||||
Players:
|
||||
|
||||
@@ -6,7 +6,6 @@ Player:
|
||||
PowerManager:
|
||||
AllyRepair:
|
||||
PlayerResources:
|
||||
InitialCash: 5000
|
||||
ActorGroupProxy:
|
||||
DeveloperMode:
|
||||
HackyAI@Default:
|
||||
|
||||
@@ -39,7 +39,6 @@ Player:
|
||||
AdviceInterval: 650
|
||||
AllyRepair:
|
||||
PlayerResources:
|
||||
InitialCash: 5000
|
||||
AdviceInterval: 650
|
||||
ActorGroupProxy:
|
||||
DeveloperMode:
|
||||
|
||||
@@ -102,6 +102,19 @@ Background@LOBBY_OPTIONS_BIN:
|
||||
Width:230
|
||||
Height:20
|
||||
Text:Build off Ally ConYards
|
||||
Label@STARTINGCASH_DESC:
|
||||
Y:87
|
||||
Width:80
|
||||
Height:25
|
||||
Text:Starting Cash:
|
||||
Align:Right
|
||||
DropDownButton@STARTINGCASH_DROPDOWNBUTTON:
|
||||
X:85
|
||||
Y:87
|
||||
Width:130
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:$5000
|
||||
Label@STARTINGUNITS_DESC:
|
||||
X:PARENT_RIGHT - WIDTH - 145
|
||||
Y:87
|
||||
|
||||
@@ -23,6 +23,7 @@ Options:
|
||||
Shroud: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 50
|
||||
ConfigurableStartingUnits: false
|
||||
|
||||
Players:
|
||||
@@ -512,8 +513,6 @@ Rules:
|
||||
Unit: e7
|
||||
SelectionShares: 10
|
||||
Player:
|
||||
PlayerResources:
|
||||
InitialCash: 50
|
||||
ClassicProductionQueue@Infantry:
|
||||
Type: Infantry
|
||||
BuildSpeed: 1
|
||||
|
||||
@@ -23,6 +23,7 @@ Options:
|
||||
Shroud: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 5000
|
||||
ConfigurableStartingUnits: false
|
||||
Difficulties: Easy,Normal,Hard
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ Options:
|
||||
Shroud: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 5000
|
||||
ConfigurableStartingUnits: false
|
||||
|
||||
Players:
|
||||
|
||||
@@ -25,6 +25,7 @@ Options:
|
||||
Shroud: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 5000
|
||||
ConfigurableStartingUnits: false
|
||||
Difficulties: Easy, Normal
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ Options:
|
||||
Shroud: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 5000
|
||||
ConfigurableStartingUnits: false
|
||||
|
||||
Players:
|
||||
|
||||
@@ -25,6 +25,7 @@ Options:
|
||||
Shroud: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 5000
|
||||
ConfigurableStartingUnits: false
|
||||
Difficulties: Easy, Normal, Hard
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ Options:
|
||||
Shroud: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 5000
|
||||
ConfigurableStartingUnits: false
|
||||
Difficulties: Easy,Normal,Hard
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ Options:
|
||||
Shroud: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 60
|
||||
ConfigurableStartingUnits: false
|
||||
|
||||
Players:
|
||||
@@ -805,8 +806,6 @@ Rules:
|
||||
Player:
|
||||
ClassicProductionQueue@Building:
|
||||
BuildSpeed: 0.4
|
||||
PlayerResources:
|
||||
InitialCash: 60
|
||||
|
||||
MNLYR:
|
||||
Inherits: ^Tank
|
||||
|
||||
@@ -24,6 +24,7 @@ Options:
|
||||
Crates: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 5000
|
||||
ConfigurableStartingUnits: false
|
||||
|
||||
Players:
|
||||
|
||||
@@ -24,6 +24,7 @@ Options:
|
||||
Crates: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 5000
|
||||
ConfigurableStartingUnits: false
|
||||
|
||||
Players:
|
||||
|
||||
@@ -24,6 +24,7 @@ Options:
|
||||
Crates: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 5000
|
||||
ConfigurableStartingUnits: false
|
||||
|
||||
Players:
|
||||
|
||||
@@ -25,6 +25,7 @@ Options:
|
||||
Shroud: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 5000
|
||||
ConfigurableStartingUnits: false
|
||||
|
||||
Players:
|
||||
|
||||
@@ -25,6 +25,7 @@ Options:
|
||||
Shroud: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 0
|
||||
ConfigurableStartingUnits: false
|
||||
|
||||
Players:
|
||||
@@ -848,8 +849,6 @@ Smudges:
|
||||
Rules:
|
||||
Player:
|
||||
-ConquestVictoryConditions:
|
||||
PlayerResources:
|
||||
InitialCash: 0
|
||||
World:
|
||||
-CrateDrop:
|
||||
-SpawnMPUnits:
|
||||
|
||||
@@ -23,6 +23,7 @@ Options:
|
||||
Shroud: true
|
||||
AllyBuildRadius: false
|
||||
FragileAlliances: false
|
||||
StartingCash: 100
|
||||
ConfigurableStartingUnits: false
|
||||
|
||||
Players:
|
||||
@@ -807,8 +808,6 @@ Rules:
|
||||
-SpawnMPUnits:
|
||||
-MPStartLocations:
|
||||
Player:
|
||||
PlayerResources:
|
||||
InitialCash: 100
|
||||
ClassicProductionQueue@Infantry:
|
||||
Type: Infantry
|
||||
BuildSpeed: 1
|
||||
|
||||
@@ -38,7 +38,6 @@ Player:
|
||||
PowerManager:
|
||||
AllyRepair:
|
||||
PlayerResources:
|
||||
InitialCash: 5000
|
||||
ActorGroupProxy:
|
||||
DeveloperMode:
|
||||
HackyAI@EasyAI:
|
||||
|
||||
@@ -30,7 +30,6 @@ Player:
|
||||
PowerManager:
|
||||
AllyRepair:
|
||||
PlayerResources:
|
||||
InitialCash: 5000
|
||||
ActorGroupProxy:
|
||||
DeveloperMode:
|
||||
PlayerColorPalette:
|
||||
|
||||
Reference in New Issue
Block a user