Merge pull request #12643 from pchote/battlefield-control

Replace "Debug" prefix with "Battlefield Control" for gameplay notifications.
This commit is contained in:
RoosterDragon
2017-02-01 19:18:47 +00:00
committed by GitHub
4 changed files with 29 additions and 13 deletions

View File

@@ -9,6 +9,7 @@
*/ */
#endregion #endregion
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Traits; using OpenRA.Traits;
@@ -22,6 +23,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Description of the objective.")] [Desc("Description of the objective.")]
[Translate] public readonly string Objective = "Destroy all opposition!"; [Translate] public readonly string Objective = "Destroy all opposition!";
[Desc("Disable the win/loss messages and audio notifications?")]
public readonly bool SuppressNotifications = false;
public object Create(ActorInitializer init) { return new ConquestVictoryConditions(init.Self, this); } public object Create(ActorInitializer init) { return new ConquestVictoryConditions(init.Self, this); }
} }
@@ -58,11 +62,13 @@ namespace OpenRA.Mods.Common.Traits
public void OnPlayerLost(Player player) public void OnPlayerLost(Player player)
{ {
Game.Debug("{0} is defeated.", player.PlayerName);
foreach (var a in player.World.Actors.Where(a => a.Owner == player)) foreach (var a in player.World.Actors.Where(a => a.Owner == player))
a.Kill(a); a.Kill(a);
if (info.SuppressNotifications)
return;
Game.AddChatLine(Color.White, "Battlefield Control", player.PlayerName + " is defeated.");
Game.RunAfterDelay(info.NotificationDelay, () => Game.RunAfterDelay(info.NotificationDelay, () =>
{ {
if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer) if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer)
@@ -72,8 +78,10 @@ namespace OpenRA.Mods.Common.Traits
public void OnPlayerWon(Player player) public void OnPlayerWon(Player player)
{ {
Game.Debug("{0} is victorious.", player.PlayerName); if (info.SuppressNotifications)
return;
Game.AddChatLine(Color.White, "Battlefield Control", player.PlayerName + " is victorious.");
Game.RunAfterDelay(info.NotificationDelay, () => Game.RunAfterDelay(info.NotificationDelay, () =>
{ {
if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer) if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer)

View File

@@ -10,6 +10,7 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Traits; using OpenRA.Traits;
@@ -37,6 +38,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Description of the objective")] [Desc("Description of the objective")]
[Translate] public readonly string Objective = "Hold all the strategic positions!"; [Translate] public readonly string Objective = "Hold all the strategic positions!";
[Desc("Disable the win/loss messages and audio notifications?")]
public readonly bool SuppressNotifications = false;
public object Create(ActorInitializer init) { return new StrategicVictoryConditions(init.Self, this); } public object Create(ActorInitializer init) { return new StrategicVictoryConditions(init.Self, this); }
} }
@@ -103,11 +107,13 @@ namespace OpenRA.Mods.Common.Traits
public void OnPlayerLost(Player player) public void OnPlayerLost(Player player)
{ {
Game.Debug("{0} is defeated.", player.PlayerName);
foreach (var a in player.World.Actors.Where(a => a.Owner == player)) foreach (var a in player.World.Actors.Where(a => a.Owner == player))
a.Kill(a); a.Kill(a);
if (info.SuppressNotifications)
return;
Game.AddChatLine(Color.White, "Battlefield Control", player.PlayerName + " is defeated.");
Game.RunAfterDelay(info.NotificationDelay, () => Game.RunAfterDelay(info.NotificationDelay, () =>
{ {
if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer) if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer)
@@ -117,8 +123,10 @@ namespace OpenRA.Mods.Common.Traits
public void OnPlayerWon(Player player) public void OnPlayerWon(Player player)
{ {
Game.Debug("{0} is victorious.", player.PlayerName); if (info.SuppressNotifications)
return;
Game.AddChatLine(Color.White, "Battlefield Control", player.PlayerName + " is victorious.");
Game.RunAfterDelay(info.NotificationDelay, () => Game.RunAfterDelay(info.NotificationDelay, () =>
{ {
if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer) if (Game.IsCurrentWorld(player.World) && player == player.World.LocalPlayer)

View File

@@ -158,7 +158,7 @@ namespace OpenRA.Mods.Common.Widgets
return new Order("SetUnitStance", a, false) { ExtraData = (uint)nextStance }; return new Order("SetUnitStance", a, false) { ExtraData = (uint)nextStance };
}); });
Game.Debug("Unit stance set to: {0}".F(nextStance)); Game.AddChatLine(Color.White, "Battlefield Control", "Unit stance set to: {0}".F(nextStance));
return true; return true;
} }

View File

@@ -250,12 +250,12 @@ namespace OpenRA.Mods.Common.Widgets
// Check if selecting actors on the screen has selected new units // Check if selecting actors on the screen has selected new units
if (ownUnitsOnScreen.Count > World.Selection.Actors.Count()) if (ownUnitsOnScreen.Count > World.Selection.Actors.Count())
Game.Debug("Selected across screen"); Game.AddChatLine(Color.White, "Battlefield Control", "Selected across screen");
else else
{ {
// Select actors in the world that have highest selection priority // Select actors in the world that have highest selection priority
ownUnitsOnScreen = SelectActorsInWorld(World, null, player).SubsetWithHighestSelectionPriority().ToList(); ownUnitsOnScreen = SelectActorsInWorld(World, null, player).SubsetWithHighestSelectionPriority().ToList();
Game.Debug("Selected across map"); Game.AddChatLine(Color.White, "Battlefield Control", "Selected across map");
} }
World.Selection.Combine(World, ownUnitsOnScreen, false, false); World.Selection.Combine(World, ownUnitsOnScreen, false, false);
@@ -276,12 +276,12 @@ namespace OpenRA.Mods.Common.Widgets
// Check if selecting actors on the screen has selected new units // Check if selecting actors on the screen has selected new units
if (newSelection.Count > World.Selection.Actors.Count()) if (newSelection.Count > World.Selection.Actors.Count())
Game.Debug("Selected across screen"); Game.AddChatLine(Color.White, "Battlefield Control", "Selected across screen");
else else
{ {
// Select actors in the world that have the same selection class as one of the already selected actors // Select actors in the world that have the same selection class as one of the already selected actors
newSelection = SelectActorsInWorld(World, selectedClasses, player).ToList(); newSelection = SelectActorsInWorld(World, selectedClasses, player).ToList();
Game.Debug("Selected across map"); Game.AddChatLine(Color.White, "Battlefield Control", "Selected across map");
} }
World.Selection.Combine(World, newSelection, true, false); World.Selection.Combine(World, newSelection, true, false);
@@ -369,12 +369,12 @@ namespace OpenRA.Mods.Common.Widgets
if (Game.Settings.Sound.Mute) if (Game.Settings.Sound.Mute)
{ {
Game.Sound.MuteAudio(); Game.Sound.MuteAudio();
Game.Debug("Audio muted"); Game.AddChatLine(Color.White, "Battlefield Control", "Audio muted");
} }
else else
{ {
Game.Sound.UnmuteAudio(); Game.Sound.UnmuteAudio();
Game.Debug("Audio unmuted"); Game.AddChatLine(Color.White, "Battlefield Control", "Audio unmuted");
} }
return true; return true;