Add 'Crates' lobby checkbox and setting for enabling/disabling crate drops

This commit is contained in:
Scott_NZ
2013-02-16 15:14:37 +13:00
parent a083554218
commit 026a86ba75
5 changed files with 33 additions and 1 deletions

View File

@@ -79,6 +79,7 @@ namespace OpenRA.Network
public bool AllowCheats = false; public bool AllowCheats = false;
public bool Dedicated; public bool Dedicated;
public string Difficulty; public string Difficulty;
public bool Crates = true;
} }
public Session(string[] mods) public Session(string[] mods)

View File

@@ -40,6 +40,8 @@ namespace OpenRA.Mods.RA
public void Tick(Actor self) public void Tick(Actor self)
{ {
if (!self.World.LobbyInfo.GlobalSettings.Crates) return;
if (--ticks <= 0) if (--ticks <= 0)
{ {
ticks = Info.SpawnInterval * 25; // todo: randomize ticks = Info.SpawnInterval * 25; // todo: randomize

View File

@@ -318,6 +318,19 @@ namespace OpenRA.Mods.RA.Server
server.SyncLobbyInfo(); server.SyncLobbyInfo();
return true; return true;
}}, }},
{ "crates",
s =>
{
if (!client.IsAdmin)
{
server.SendChatTo(conn, "Only the host can set that option");
return true;
}
bool.TryParse(s, out server.lobbyInfo.GlobalSettings.Crates);
server.SyncLobbyInfo();
return true;
}},
{ "difficulty", { "difficulty",
s => s =>
{ {

View File

@@ -169,6 +169,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic
allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command( allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command(
"allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats))); "allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats)));
var crates = lobby.GetOrNull<CheckboxWidget>("CRATES_CHECKBOX");
if (crates != null)
{
crates.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Crates;
crates.IsDisabled = () => !Game.IsHost || gameStarting || orderManager.LocalClient == null
|| orderManager.LocalClient.IsReady; // maybe disable the checkbox if a map forcefully removes CrateDrop?
crates.OnClick = () => orderManager.IssueOrder(Order.Command(
"crates {0}".F(!orderManager.LobbyInfo.GlobalSettings.Crates)));
}
var difficulty = lobby.GetOrNull<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON"); var difficulty = lobby.GetOrNull<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
if (difficulty != null) if (difficulty != null)
{ {

View File

@@ -432,9 +432,15 @@ Background@SERVER_LOBBY:
Width: 80 Width: 80
Height: 20 Height: 20
Text: Allow Cheats Text: Allow Cheats
Checkbox@CRATES_CHECKBOX:
X: PARENT_RIGHT-154
Y: PARENT_BOTTOM-154
Width: 80
Height: 20
Text: Crates
Button@DISCONNECT_BUTTON: Button@DISCONNECT_BUTTON:
X:PARENT_RIGHT-154 X:PARENT_RIGHT-154
Y:PARENT_BOTTOM-129 Y:PARENT_BOTTOM-99
Width:120 Width:120
Height:25 Height:25
Text:Disconnect Text:Disconnect