The options button starts blinking when a new objective is added, which happens in all game modes, even skirmish and koth. This change prevents the button from blinking in the latter two cases. This prevents 1) confusion on part of the players, and 2) an unnecessary announcement of the objective since in skirmish and koth it is always the same.
73 lines
2.3 KiB
C#
73 lines
2.3 KiB
C#
#region Copyright & License Information
|
|
/*
|
|
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
|
* This file is part of OpenRA, which is free software. It is made
|
|
* available to you under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation. For more information,
|
|
* see COPYING.
|
|
*/
|
|
#endregion
|
|
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using OpenRA.Mods.Common.Traits;
|
|
using OpenRA.Traits;
|
|
using OpenRA.Widgets;
|
|
|
|
namespace OpenRA.Mods.Common.Widgets.Logic
|
|
{
|
|
class GameInfoObjectivesLogic
|
|
{
|
|
readonly ContainerWidget template;
|
|
|
|
[ObjectCreator.UseCtor]
|
|
public GameInfoObjectivesLogic(Widget widget, World world)
|
|
{
|
|
var lp = world.LocalPlayer;
|
|
|
|
var missionStatus = widget.Get<LabelWidget>("MISSION_STATUS");
|
|
missionStatus.GetText = () => lp.WinState == WinState.Undefined ? "In progress" :
|
|
lp.WinState == WinState.Won ? "Accomplished" : "Failed";
|
|
missionStatus.GetColor = () => lp.WinState == WinState.Undefined ? Color.White :
|
|
lp.WinState == WinState.Won ? Color.LimeGreen : Color.Red;
|
|
|
|
var mo = lp.PlayerActor.TraitOrDefault<MissionObjectives>();
|
|
if (mo == null)
|
|
return;
|
|
|
|
var objectivesPanel = widget.Get<ScrollPanelWidget>("OBJECTIVES_PANEL");
|
|
template = objectivesPanel.Get<ContainerWidget>("OBJECTIVE_TEMPLATE");
|
|
|
|
PopulateObjectivesList(mo, objectivesPanel, template);
|
|
|
|
Action<Player, bool> redrawObjectives = (player, _) =>
|
|
{
|
|
if (player == lp)
|
|
PopulateObjectivesList(mo, objectivesPanel, template);
|
|
};
|
|
mo.ObjectiveAdded += redrawObjectives;
|
|
}
|
|
|
|
void PopulateObjectivesList(MissionObjectives mo, ScrollPanelWidget parent, ContainerWidget template)
|
|
{
|
|
parent.RemoveChildren();
|
|
|
|
foreach (var o in mo.Objectives.OrderBy(o => o.Type))
|
|
{
|
|
var objective = o; // Work around the loop closure issue in older versions of C#
|
|
var widget = template.Clone();
|
|
|
|
var label = widget.Get<LabelWidget>("OBJECTIVE_TYPE");
|
|
label.GetText = () => objective.Type == ObjectiveType.Primary ? "Primary" : "Secondary";
|
|
|
|
var checkbox = widget.Get<CheckboxWidget>("OBJECTIVE_STATUS");
|
|
checkbox.IsChecked = () => objective.State != ObjectiveState.Incomplete;
|
|
checkbox.GetCheckType = () => objective.State == ObjectiveState.Completed ? "checked" : "crossed";
|
|
checkbox.GetText = () => objective.Description;
|
|
|
|
parent.AddChild(widget);
|
|
}
|
|
}
|
|
}
|
|
} |