From de0a62eb422fe156c6a42b8e0ab15ae14195e785 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Sun, 28 Dec 2014 17:39:26 +0100 Subject: [PATCH] Add a lobby option to control spawning creeps (viceroids/worms) The lobby option is only exposed in d2k currently, not in TD or TS. --- OpenRA.Game/Map/Map.cs | 3 + OpenRA.Game/Network/Session.cs | 1 + OpenRA.Mods.Cnc/Traits/SpawnViceroid.cs | 1 + .../ServerTraits/LobbyCommands.cs | 23 ++ .../ServerTraits/LobbySettingsNotification.cs | 3 + OpenRA.Mods.D2k/Traits/World/WormManager.cs | 3 +- OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs | 9 + mods/d2k/chrome/lobby-dialogs.yaml | 271 ++++++++++++++++++ mods/d2k/mod.yaml | 2 +- 9 files changed, 314 insertions(+), 2 deletions(-) create mode 100644 mods/d2k/chrome/lobby-dialogs.yaml diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index 76a40e0f1f..70b3461117 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -60,6 +60,7 @@ namespace OpenRA { public bool? Cheats; public bool? Crates; + public bool? Creeps; public bool? Fog; public bool? Shroud; public bool? AllyBuildRadius; @@ -76,6 +77,8 @@ namespace OpenRA settings.AllowCheats = Cheats.Value; if (Crates.HasValue) settings.Crates = Crates.Value; + if (Creeps.HasValue) + settings.Creeps = Creeps.Value; if (Fog.HasValue) settings.Fog = Fog.Value; if (Shroud.HasValue) diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs index bcb0d2dcd6..8887cc00c6 100644 --- a/OpenRA.Game/Network/Session.cs +++ b/OpenRA.Game/Network/Session.cs @@ -180,6 +180,7 @@ namespace OpenRA.Network public bool Dedicated; public string Difficulty; public bool Crates = true; + public bool Creeps = true; public bool Shroud = true; public bool Fog = true; public bool AllyBuildRadius = true; diff --git a/OpenRA.Mods.Cnc/Traits/SpawnViceroid.cs b/OpenRA.Mods.Cnc/Traits/SpawnViceroid.cs index 3c2e252c6a..203fbfc4af 100644 --- a/OpenRA.Mods.Cnc/Traits/SpawnViceroid.cs +++ b/OpenRA.Mods.Cnc/Traits/SpawnViceroid.cs @@ -32,6 +32,7 @@ namespace OpenRA.Mods.Cnc.Traits public void Killed(Actor self, AttackInfo e) { + if (!self.World.LobbyInfo.GlobalSettings.Creeps) return; if (e.Warhead == null || e.Warhead.DeathType != spawnViceroidInfo.DeathType) return; if (self.World.SharedRandom.Next(100) > spawnViceroidInfo.Probability) return; diff --git a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs index 6d6fbcc975..a761f918f1 100644 --- a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs @@ -523,6 +523,29 @@ namespace OpenRA.Mods.Common.Server return true; } }, + { "creeps", + s => + { + if (!client.IsAdmin) + { + server.SendOrderTo(conn, "Message", "Only the host can set that option."); + return true; + } + + if (server.Map.Options.Creeps.HasValue) + { + server.SendOrderTo(conn, "Message", "Map has disabled Creeps spawning configuration."); + return true; + } + + bool.TryParse(s, out server.LobbyInfo.GlobalSettings.Creeps); + server.SyncLobbyGlobalSettings(); + server.SendMessage("{0} {1} Creeps spawning." + .F(client.Name, server.LobbyInfo.GlobalSettings.Creeps ? "enabled" : "disabled")); + + return true; + } + }, { "allybuildradius", s => { diff --git a/OpenRA.Mods.Common/ServerTraits/LobbySettingsNotification.cs b/OpenRA.Mods.Common/ServerTraits/LobbySettingsNotification.cs index dc73c7cf5c..89c10f0b32 100644 --- a/OpenRA.Mods.Common/ServerTraits/LobbySettingsNotification.cs +++ b/OpenRA.Mods.Common/ServerTraits/LobbySettingsNotification.cs @@ -40,6 +40,9 @@ namespace OpenRA.Mods.Common.Server if (server.LobbyInfo.GlobalSettings.Crates != defaults.Crates) server.SendOrderTo(conn, "Message", "Crates Appear: {0}".F(server.LobbyInfo.GlobalSettings.Crates)); + if (server.LobbyInfo.GlobalSettings.Creeps != defaults.Creeps) + server.SendOrderTo(conn, "Message", "Creeps Spawn: {0}".F(server.LobbyInfo.GlobalSettings.Creeps)); + if (server.LobbyInfo.GlobalSettings.AllyBuildRadius != defaults.AllyBuildRadius) server.SendOrderTo(conn, "Message", "Build off Ally ConYards: {0}".F(server.LobbyInfo.GlobalSettings.AllyBuildRadius)); diff --git a/OpenRA.Mods.D2k/Traits/World/WormManager.cs b/OpenRA.Mods.D2k/Traits/World/WormManager.cs index 40ba93871c..b42b56891b 100644 --- a/OpenRA.Mods.D2k/Traits/World/WormManager.cs +++ b/OpenRA.Mods.D2k/Traits/World/WormManager.cs @@ -56,7 +56,8 @@ namespace OpenRA.Mods.D2k.Traits public void Tick(Actor self) { - // TODO: Add a lobby option to disable worms just like crates + if (!self.World.LobbyInfo.GlobalSettings.Creeps) + return; // TODO: It would be even better to stop if (!spawnPoints.Value.Any()) diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs index a36b4da6f6..f3928801d8 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs @@ -335,6 +335,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic "crates {0}".F(!orderManager.LobbyInfo.GlobalSettings.Crates))); } + var creeps = optionsBin.GetOrNull("CREEPS_CHECKBOX"); + if (creeps != null) + { + creeps.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Creeps; + creeps.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Creeps.HasValue || configurationDisabled(); + creeps.OnClick = () => orderManager.IssueOrder(Order.Command( + "creeps {0}".F(!orderManager.LobbyInfo.GlobalSettings.Creeps))); + } + var allybuildradius = optionsBin.GetOrNull("ALLYBUILDRADIUS_CHECKBOX"); if (allybuildradius != null) { diff --git a/mods/d2k/chrome/lobby-dialogs.yaml b/mods/d2k/chrome/lobby-dialogs.yaml new file mode 100644 index 0000000000..006aed2464 --- /dev/null +++ b/mods/d2k/chrome/lobby-dialogs.yaml @@ -0,0 +1,271 @@ +Background@KICK_CLIENT_DIALOG: + X: 20 + Y: 67 + Width: 535 + Height: 235 + Logic: KickClientLogic + Background: dialog3 + Children: + Label@TITLE: + X: 0 + Y: 40 + Width: PARENT_RIGHT + Height: 25 + Font: Bold + Align: Center + Label@TEXTA: + X: 0 + Y: 67 + Width: PARENT_RIGHT + Height: 25 + Font: Regular + Align: Center + Text: You may also apply a temporary ban, preventing + Label@TEXTB: + X: 0 + Y: 85 + Width: PARENT_RIGHT + Height: 25 + Font: Regular + Align: Center + Text: them from joining for the remainder of this game. + Checkbox@PREVENT_REJOINING_CHECKBOX: + X: (PARENT_RIGHT - WIDTH)/2 + Y: 120 + Width: 150 + Height: 20 + Text: Temporarily Ban + Button@OK_BUTTON: + X: (PARENT_RIGHT - WIDTH)/2 + 75 + Y: 155 + Width: 120 + Height: 25 + Text: Kick + Font: Bold + Button@CANCEL_BUTTON: + X: (PARENT_RIGHT - WIDTH)/2 - 75 + Y: 155 + Width: 120 + Height: 25 + Text: Cancel + Font: Bold + +Background@KICK_SPECTATORS_DIALOG: + X: 20 + Y: 67 + Width: 535 + Height: 235 + Logic: KickSpectatorsLogic + Background: dialog3 + Children: + Label@TITLE: + X: 0 + Y: 40 + Width: PARENT_RIGHT + Height: 25 + Font: Bold + Align: Center + Text: Kick Spectators + Label@TEXT: + X: 0 + Y: 85 + Width: PARENT_RIGHT + Height: 25 + Font: Regular + Align: Center + Button@OK_BUTTON: + X: (PARENT_RIGHT - WIDTH)/2 + 75 + Y: 155 + Width: 120 + Height: 25 + Text: Ok + Font: Bold + Button@CANCEL_BUTTON: + X: (PARENT_RIGHT - WIDTH)/2 - 75 + Y: 155 + Width: 120 + Height: 25 + Text: Cancel + Font: Bold + +Background@LOBBY_OPTIONS_BIN: + X: 20 + Y: 67 + Width: 593 + Height: 235 + Background: dialog3 + Children: + Label@TITLE: + X: 0 + Y: 5 + Width: PARENT_RIGHT + Height: 25 + Font: Bold + Align: Center + Text: Map Options + Container: + X: 30 + Y: 50 + Width: PARENT_RIGHT-60 + Height: PARENT_BOTTOM-75 + Children: + Checkbox@SHROUD_CHECKBOX: + Width: 140 + Height: 20 + Text: Shroud + Checkbox@FOG_CHECKBOX: + Y: 35 + Width: 140 + Height: 20 + Text: Fog of War + Checkbox@SHORTGAME_CHECKBOX: + X: 150 + Width: 140 + Height: 20 + Text: Short Game + Checkbox@CRATES_CHECKBOX: + X: 150 + Y: 35 + Width: 140 + Height: 20 + Text: Crates + Checkbox@ALLYBUILDRADIUS_CHECKBOX: + X: 290 + Width: 140 + Height: 20 + Text: Build off Allies' ConYards + Checkbox@FRAGILEALLIANCES_CHECKBOX: + X: 290 + Y: 35 + Width: 140 + Height: 20 + Text: Diplomacy Changes + Checkbox@CREEPS_CHECKBOX: + Y: 70 + Width: 140 + Height: 20 + Text: Worms + Checkbox@ALLOWCHEATS_CHECKBOX: + X: 150 + Y: 70 + Width: 140 + Height: 20 + Text: Debug Menu + Label@STARTINGCASH_DESC: + Y: 110 + Width: 80 + Height: 25 + Text: Starting Cash: + Align: Right + DropDownButton@STARTINGCASH_DROPDOWNBUTTON: + X: 85 + Y: 110 + Width: 130 + Height: 25 + Font: Regular + Text: $5000 + Label@STARTINGUNITS_DESC: + X: PARENT_RIGHT - WIDTH - 145 + Y: 110 + Width: 120 + Height: 25 + Text: Starting Units: + Align: Right + DropDownButton@STARTINGUNITS_DROPDOWNBUTTON: + X: PARENT_RIGHT - WIDTH + Y: 110 + Width: 140 + Height: 25 + Font: Regular + Label@DIFFICULTY_DESC: + X: PARENT_RIGHT - WIDTH - 145 + Y: 150 + Width: 120 + Height: 25 + Text: Mission Difficulty: + Align: Right + DropDownButton@DIFFICULTY_DROPDOWNBUTTON: + X: PARENT_RIGHT - WIDTH + Y: 150 + Width: 140 + Height: 25 + Font: Regular + DropDownButton@TECHLEVEL_DROPDOWNBUTTON: + X: 85 + Y: 150 + Width: 130 + Height: 25 + Font: Regular + Text: 10 + Label@TECHLEVEL_DESC: + Y: 150 + Width: 80 + Height: 25 + Text: Tech Level: + Align: Right + +Background@FORCE_START_DIALOG: + X: 20 + Y: 67 + Width: 593 + Height: 235 + Background: dialog3 + Children: + Label@TITLE: + X: 0 + Y: 40 + Width: PARENT_RIGHT + Height: 25 + Font: Bold + Align: Center + Text: Start Game? + Label@TEXTA: + X: 0 + Y: 67 + Width: PARENT_RIGHT + Height: 25 + Font: Regular + Align: Center + Text: One or more players are not yet ready. + Label@TEXTB: + X: 0 + Y: 85 + Width: PARENT_RIGHT + Height: 25 + Font: Regular + Align: Center + Text: Are you sure that you want to force start the game? + Container@KICK_WARNING: + Width: PARENT_RIGHT + Children: + Label@KICK_WARNING_A: + X: 0 + Y: 106 + Width: PARENT_RIGHT + Height: 25 + Font: Bold + Align: Center + Text: One or more clients are missing the selected + Label@KICK_WARNING_B: + X: 0 + Y: 123 + Width: PARENT_RIGHT + Height: 25 + Font: Bold + Align: Center + Text: map, and will be kicked from the server. + Button@OK_BUTTON: + X: (PARENT_RIGHT - WIDTH)/2 + 75 + Y: 155 + Width: 120 + Height: 25 + Text: Start + Font: Bold + Button@CANCEL_BUTTON: + X: (PARENT_RIGHT - WIDTH)/2 - 75 + Y: 155 + Width: 120 + Height: 25 + Text: Cancel + Font: Bold + diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml index fa729a95e3..d990db8fa5 100644 --- a/mods/d2k/mod.yaml +++ b/mods/d2k/mod.yaml @@ -80,7 +80,7 @@ ChromeLayout: ./mods/ra/chrome/lobby.yaml ./mods/ra/chrome/lobby-mappreview.yaml ./mods/d2k/chrome/lobby-playerbin.yaml - ./mods/ra/chrome/lobby-dialogs.yaml + ./mods/d2k/chrome/lobby-dialogs.yaml ./mods/d2k/chrome/color-picker.yaml ./mods/ra/chrome/map-chooser.yaml ./mods/ra/chrome/create-server.yaml