Merge pull request #8590 from obrakmann/objectives-polish

Objectives polish
This commit is contained in:
abcdefg30
2015-06-29 18:52:34 +02:00
6 changed files with 21 additions and 10 deletions

View File

@@ -16,7 +16,10 @@ namespace OpenRA.Mods.Common.Traits
public class ConquestVictoryConditionsInfo : ITraitInfo, Requires<MissionObjectivesInfo>
{
[Desc("Delay for the end game notification in milliseconds.")]
public int NotificationDelay = 1500;
public readonly int NotificationDelay = 1500;
[Desc("Description of the objective.")]
[Translate] public readonly string Objective = "Destroy all opposition!";
public object Create(ActorInitializer init) { return new ConquestVictoryConditions(init.Self, this); }
}
@@ -38,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
if (self.Owner.WinState != WinState.Undefined || self.Owner.NonCombatant) return;
if (objectiveID < 0)
objectiveID = mo.Add(self.Owner, "Destroy all opposition!");
objectiveID = mo.Add(self.Owner, info.Objective, ObjectiveType.Primary, true);
if (!self.Owner.NonCombatant && self.Owner.HasNoRequiredUnits())
mo.MarkFailed(self.Owner, objectiveID);

View File

@@ -72,13 +72,13 @@ namespace OpenRA.Mods.Common.Traits
world.ObserveAfterWinOrLose = !info.EarlyGameOver;
}
public int Add(Player player, string description, ObjectiveType type = ObjectiveType.Primary)
public int Add(Player player, string description, ObjectiveType type = ObjectiveType.Primary, bool inhibitAnnouncement = false)
{
var newID = objectives.Count;
objectives.Insert(newID, new MissionObjective(type, description));
ObjectiveAdded(player);
ObjectiveAdded(player, inhibitAnnouncement);
foreach (var inou in player.PlayerActor.TraitsImplementing<INotifyObjectivesUpdated>())
inou.OnObjectiveAdded(player, newID);
@@ -231,7 +231,7 @@ namespace OpenRA.Mods.Common.Traits
MarkFailed(player, id);
}
public event Action<Player> ObjectiveAdded = player => { player.HasObjectives = true; };
public event Action<Player, bool> ObjectiveAdded = (player, inhibitAnnouncement) => { player.HasObjectives = true; };
public void OnObjectiveAdded(Player player, int id) { }
public void OnObjectiveCompleted(Player player, int id) { }

View File

@@ -31,7 +31,10 @@ namespace OpenRA.Mods.Common.Traits
public readonly float RatioRequired = 0.5f;
[Desc("Delay for the end game notification in milliseconds.")]
public int NotificationDelay = 1500;
public readonly int NotificationDelay = 1500;
[Desc("Description of the objective")]
[Translate] public readonly string Objective = "Hold all the strategic positions!";
public object Create(ActorInitializer init) { return new StrategicVictoryConditions(init.Self, this); }
}
@@ -68,7 +71,7 @@ namespace OpenRA.Mods.Common.Traits
if (player.WinState != WinState.Undefined || player.NonCombatant) return;
if (objectiveID < 0)
objectiveID = mo.Add(player, "Hold all the strategic positions for a specified time!");
objectiveID = mo.Add(player, info.Objective, ObjectiveType.Primary, true);
if (!self.Owner.NonCombatant && self.Owner.HasNoRequiredUnits())
mo.MarkFailed(self.Owner, objectiveID);

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
PopulateObjectivesList(mo, objectivesPanel, template);
Action<Player> redrawObjectives = player =>
Action<Player, bool> redrawObjectives = (player, _) =>
{
if (player == lp)
PopulateObjectivesList(mo, objectivesPanel, template);

View File

@@ -27,6 +27,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
checkbox.IsChecked = () => lp.WinState != WinState.Undefined;
checkbox.GetCheckType = () => lp.WinState == WinState.Won ?
"checked" : "crossed";
if (lp.HasObjectives)
{
var mo = lp.PlayerActor.Trait<MissionObjectives>();
checkbox.GetText = () => mo.Objectives.First().Description;
}
var statusLabel = widget.Get<LabelWidget>("STATS_STATUS");

View File

@@ -55,9 +55,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (lp != null)
{
Action<Player> startBlinking = player =>
Action<Player, bool> startBlinking = (player, inhibitAnnouncement) =>
{
if (player == world.LocalPlayer)
if (!inhibitAnnouncement && player == world.LocalPlayer)
blinking = true;
};