diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index 2e9179aeb6..cd7e369c89 100644 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -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; } diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs index 6c6483239a..2dc549a270 100644 --- a/OpenRA.Game/Network/Session.cs +++ b/OpenRA.Game/Network/Session.cs @@ -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; } diff --git a/OpenRA.Game/Traits/Player/PlayerResources.cs b/OpenRA.Game/Traits/Player/PlayerResources.cs index 77fdbc4857..9a71313ab2 100644 --- a/OpenRA.Game/Traits/Player/PlayerResources.cs +++ b/OpenRA.Game/Traits/Player/PlayerResources.cs @@ -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; } diff --git a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs index cfdbe97cb8..a2d627d602 100644 --- a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs @@ -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 => { diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs index b239589c82..5b182bafb7 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs @@ -368,6 +368,31 @@ namespace OpenRA.Mods.RA.Widgets.Logic optionsBin.Get("STARTINGUNITS_DESC").IsVisible = startingUnits.IsVisible; } + var startingCash = optionsBin.GetOrNull("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().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 setupItem = (option, template) => + { + var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); + item.Get("LABEL").GetText = () => option.Title; + return item; + }; + + startingCash.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem); + }; + } + var enableShroud = optionsBin.GetOrNull("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(); + if (!Map.Options.StartingCash.HasValue && !pri.SelectableCash.Contains(orderManager.LobbyInfo.GlobalSettings.StartingCash)) + orderManager.IssueOrder(Order.Command("startingcash {0}".F(pri.DefaultCash))); } void UpdatePlayerList() diff --git a/mods/cnc/chrome/dialogs.yaml b/mods/cnc/chrome/dialogs.yaml index ac7c407a96..71453c9ae2 100644 --- a/mods/cnc/chrome/dialogs.yaml +++ b/mods/cnc/chrome/dialogs.yaml @@ -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 diff --git a/mods/cnc/maps/gdi01/map.yaml b/mods/cnc/maps/gdi01/map.yaml index 9393004b4d..adedb36355 100644 --- a/mods/cnc/maps/gdi01/map.yaml +++ b/mods/cnc/maps/gdi01/map.yaml @@ -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 diff --git a/mods/cnc/maps/nod01/map.yaml b/mods/cnc/maps/nod01/map.yaml index 6a2cc30589..74ab1bc400 100644 --- a/mods/cnc/maps/nod01/map.yaml +++ b/mods/cnc/maps/nod01/map.yaml @@ -26,6 +26,7 @@ Options: Shroud: true AllyBuildRadius: false FragileAlliances: false + StartingCash: 0 ConfigurableStartingUnits: false Players: diff --git a/mods/cnc/maps/the-hot-box/map.yaml b/mods/cnc/maps/the-hot-box/map.yaml index 1a1f5df620..ba7f89d08e 100755 --- a/mods/cnc/maps/the-hot-box/map.yaml +++ b/mods/cnc/maps/the-hot-box/map.yaml @@ -24,6 +24,7 @@ Options: Crates: true AllyBuildRadius: false FragileAlliances: false + StartingCash: 5000 ConfigurableStartingUnits: false Players: diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index 01ba2734af..f3a5eabfbb 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -6,7 +6,6 @@ Player: PowerManager: AllyRepair: PlayerResources: - InitialCash: 5000 ActorGroupProxy: DeveloperMode: HackyAI@Default: diff --git a/mods/d2k/rules/system.yaml b/mods/d2k/rules/system.yaml index 2341f94806..2f9c28583f 100644 --- a/mods/d2k/rules/system.yaml +++ b/mods/d2k/rules/system.yaml @@ -39,7 +39,6 @@ Player: AdviceInterval: 650 AllyRepair: PlayerResources: - InitialCash: 5000 AdviceInterval: 650 ActorGroupProxy: DeveloperMode: diff --git a/mods/ra/chrome/lobby-dialogs.yaml b/mods/ra/chrome/lobby-dialogs.yaml index 63c5eda0de..712b1f15a0 100644 --- a/mods/ra/chrome/lobby-dialogs.yaml +++ b/mods/ra/chrome/lobby-dialogs.yaml @@ -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 diff --git a/mods/ra/maps/Fort-Lonestar/map.yaml b/mods/ra/maps/Fort-Lonestar/map.yaml index dd91037eb0..b275fc36ad 100644 --- a/mods/ra/maps/Fort-Lonestar/map.yaml +++ b/mods/ra/maps/Fort-Lonestar/map.yaml @@ -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 diff --git a/mods/ra/maps/Survival01/map.yaml b/mods/ra/maps/Survival01/map.yaml index 3a889eae56..5a2e3fc2ef 100644 --- a/mods/ra/maps/Survival01/map.yaml +++ b/mods/ra/maps/Survival01/map.yaml @@ -23,6 +23,7 @@ Options: Shroud: true AllyBuildRadius: false FragileAlliances: false + StartingCash: 5000 ConfigurableStartingUnits: false Difficulties: Easy,Normal,Hard diff --git a/mods/ra/maps/Survival02/map.yaml b/mods/ra/maps/Survival02/map.yaml index a5be8dd06f..da2b871934 100644 --- a/mods/ra/maps/Survival02/map.yaml +++ b/mods/ra/maps/Survival02/map.yaml @@ -23,6 +23,7 @@ Options: Shroud: true AllyBuildRadius: false FragileAlliances: false + StartingCash: 5000 ConfigurableStartingUnits: false Players: diff --git a/mods/ra/maps/allies-01/map.yaml b/mods/ra/maps/allies-01/map.yaml index 7d95ac6010..d9ebc642df 100644 --- a/mods/ra/maps/allies-01/map.yaml +++ b/mods/ra/maps/allies-01/map.yaml @@ -25,6 +25,7 @@ Options: Shroud: true AllyBuildRadius: false FragileAlliances: false + StartingCash: 5000 ConfigurableStartingUnits: false Difficulties: Easy, Normal diff --git a/mods/ra/maps/allies-02/map.yaml b/mods/ra/maps/allies-02/map.yaml index 1ad0acc4ca..eae5ed271f 100644 --- a/mods/ra/maps/allies-02/map.yaml +++ b/mods/ra/maps/allies-02/map.yaml @@ -25,6 +25,7 @@ Options: Shroud: true AllyBuildRadius: false FragileAlliances: false + StartingCash: 5000 ConfigurableStartingUnits: false Players: diff --git a/mods/ra/maps/allies-03/map.yaml b/mods/ra/maps/allies-03/map.yaml index 57d343749f..f3467a1e15 100644 --- a/mods/ra/maps/allies-03/map.yaml +++ b/mods/ra/maps/allies-03/map.yaml @@ -25,6 +25,7 @@ Options: Shroud: true AllyBuildRadius: false FragileAlliances: false + StartingCash: 5000 ConfigurableStartingUnits: false Difficulties: Easy, Normal, Hard diff --git a/mods/ra/maps/allies-04/map.yaml b/mods/ra/maps/allies-04/map.yaml index 656436bbe4..8adf5608db 100644 --- a/mods/ra/maps/allies-04/map.yaml +++ b/mods/ra/maps/allies-04/map.yaml @@ -17,6 +17,7 @@ Options: Shroud: true AllyBuildRadius: false FragileAlliances: false + StartingCash: 5000 ConfigurableStartingUnits: false Difficulties: Easy,Normal,Hard diff --git a/mods/ra/maps/bomber-john/map.yaml b/mods/ra/maps/bomber-john/map.yaml index 0727ba62b4..171b5fca73 100644 --- a/mods/ra/maps/bomber-john/map.yaml +++ b/mods/ra/maps/bomber-john/map.yaml @@ -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 diff --git a/mods/ra/maps/drop-zone-battle-of-tikiaki/map.yaml b/mods/ra/maps/drop-zone-battle-of-tikiaki/map.yaml index bcbd44f5b0..095bd8d62d 100644 --- a/mods/ra/maps/drop-zone-battle-of-tikiaki/map.yaml +++ b/mods/ra/maps/drop-zone-battle-of-tikiaki/map.yaml @@ -24,6 +24,7 @@ Options: Crates: true AllyBuildRadius: false FragileAlliances: false + StartingCash: 5000 ConfigurableStartingUnits: false Players: diff --git a/mods/ra/maps/drop-zone-w/map.yaml b/mods/ra/maps/drop-zone-w/map.yaml index a2fa753a33..4557a2d984 100644 --- a/mods/ra/maps/drop-zone-w/map.yaml +++ b/mods/ra/maps/drop-zone-w/map.yaml @@ -24,6 +24,7 @@ Options: Crates: true AllyBuildRadius: false FragileAlliances: false + StartingCash: 5000 ConfigurableStartingUnits: false Players: diff --git a/mods/ra/maps/drop-zone/map.yaml b/mods/ra/maps/drop-zone/map.yaml index 1e2cb864ac..2c64f94b57 100644 --- a/mods/ra/maps/drop-zone/map.yaml +++ b/mods/ra/maps/drop-zone/map.yaml @@ -24,6 +24,7 @@ Options: Crates: true AllyBuildRadius: false FragileAlliances: false + StartingCash: 5000 ConfigurableStartingUnits: false Players: diff --git a/mods/ra/maps/monster-tank-madness/map.yaml b/mods/ra/maps/monster-tank-madness/map.yaml index c4c609744b..5fcde1a85d 100644 --- a/mods/ra/maps/monster-tank-madness/map.yaml +++ b/mods/ra/maps/monster-tank-madness/map.yaml @@ -25,6 +25,7 @@ Options: Shroud: true AllyBuildRadius: false FragileAlliances: false + StartingCash: 5000 ConfigurableStartingUnits: false Players: diff --git a/mods/ra/maps/soviet-01-classic/map.yaml b/mods/ra/maps/soviet-01-classic/map.yaml index b945c15766..fc0fbbbec8 100644 --- a/mods/ra/maps/soviet-01-classic/map.yaml +++ b/mods/ra/maps/soviet-01-classic/map.yaml @@ -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: diff --git a/mods/ra/maps/training-camp/map.yaml b/mods/ra/maps/training-camp/map.yaml index 961a08e641..bb2606f8c2 100644 --- a/mods/ra/maps/training-camp/map.yaml +++ b/mods/ra/maps/training-camp/map.yaml @@ -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 diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index 6be1a8d901..ad40e94225 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -38,7 +38,6 @@ Player: PowerManager: AllyRepair: PlayerResources: - InitialCash: 5000 ActorGroupProxy: DeveloperMode: HackyAI@EasyAI: diff --git a/mods/ts/rules/system.yaml b/mods/ts/rules/system.yaml index 9900500350..cc8d895f22 100644 --- a/mods/ts/rules/system.yaml +++ b/mods/ts/rules/system.yaml @@ -30,7 +30,6 @@ Player: PowerManager: AllyRepair: PlayerResources: - InitialCash: 5000 ActorGroupProxy: DeveloperMode: PlayerColorPalette: