Add starting cash option.

This commit is contained in:
Paul Chote
2013-08-17 12:59:27 +12:00
parent 3fd64dfe52
commit 271ce5275c
28 changed files with 100 additions and 17 deletions

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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 =>
{

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View File

@@ -26,6 +26,7 @@ Options:
Shroud: true
AllyBuildRadius: false
FragileAlliances: false
StartingCash: 0
ConfigurableStartingUnits: false
Players:

View File

@@ -24,6 +24,7 @@ Options:
Crates: true
AllyBuildRadius: false
FragileAlliances: false
StartingCash: 5000
ConfigurableStartingUnits: false
Players:

View File

@@ -6,7 +6,6 @@ Player:
PowerManager:
AllyRepair:
PlayerResources:
InitialCash: 5000
ActorGroupProxy:
DeveloperMode:
HackyAI@Default:

View File

@@ -39,7 +39,6 @@ Player:
AdviceInterval: 650
AllyRepair:
PlayerResources:
InitialCash: 5000
AdviceInterval: 650
ActorGroupProxy:
DeveloperMode:

View File

@@ -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

View File

@@ -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

View File

@@ -23,6 +23,7 @@ Options:
Shroud: true
AllyBuildRadius: false
FragileAlliances: false
StartingCash: 5000
ConfigurableStartingUnits: false
Difficulties: Easy,Normal,Hard

View File

@@ -23,6 +23,7 @@ Options:
Shroud: true
AllyBuildRadius: false
FragileAlliances: false
StartingCash: 5000
ConfigurableStartingUnits: false
Players:

View File

@@ -25,6 +25,7 @@ Options:
Shroud: true
AllyBuildRadius: false
FragileAlliances: false
StartingCash: 5000
ConfigurableStartingUnits: false
Difficulties: Easy, Normal

View File

@@ -25,6 +25,7 @@ Options:
Shroud: true
AllyBuildRadius: false
FragileAlliances: false
StartingCash: 5000
ConfigurableStartingUnits: false
Players:

View File

@@ -25,6 +25,7 @@ Options:
Shroud: true
AllyBuildRadius: false
FragileAlliances: false
StartingCash: 5000
ConfigurableStartingUnits: false
Difficulties: Easy, Normal, Hard

View File

@@ -17,6 +17,7 @@ Options:
Shroud: true
AllyBuildRadius: false
FragileAlliances: false
StartingCash: 5000
ConfigurableStartingUnits: false
Difficulties: Easy,Normal,Hard

View File

@@ -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

View File

@@ -24,6 +24,7 @@ Options:
Crates: true
AllyBuildRadius: false
FragileAlliances: false
StartingCash: 5000
ConfigurableStartingUnits: false
Players:

View File

@@ -24,6 +24,7 @@ Options:
Crates: true
AllyBuildRadius: false
FragileAlliances: false
StartingCash: 5000
ConfigurableStartingUnits: false
Players:

View File

@@ -24,6 +24,7 @@ Options:
Crates: true
AllyBuildRadius: false
FragileAlliances: false
StartingCash: 5000
ConfigurableStartingUnits: false
Players:

View File

@@ -25,6 +25,7 @@ Options:
Shroud: true
AllyBuildRadius: false
FragileAlliances: false
StartingCash: 5000
ConfigurableStartingUnits: false
Players:

View File

@@ -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:

View File

@@ -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

View File

@@ -38,7 +38,6 @@ Player:
PowerManager:
AllyRepair:
PlayerResources:
InitialCash: 5000
ActorGroupProxy:
DeveloperMode:
HackyAI@EasyAI:

View File

@@ -30,7 +30,6 @@ Player:
PowerManager:
AllyRepair:
PlayerResources:
InitialCash: 5000
ActorGroupProxy:
DeveloperMode:
PlayerColorPalette: