#region Copyright & License Information /* * Copyright 2007-2011 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.Traits; using OpenRA.Widgets; namespace OpenRA.Mods.Cnc.Widgets.Logic { public class CncConquestObjectivesLogic { [ObjectCreator.UseCtor] public CncConquestObjectivesLogic([ObjectCreator.Param] Widget widget, [ObjectCreator.Param] World world) { var panel = widget.GetWidget("CONQUEST_OBJECTIVES"); panel.GetWidget("TITLE").GetText = () => "Conquest: " + world.Map.Title; var objectiveCheckbox = panel.GetWidget("OBJECTIVE_CHECKBOX"); objectiveCheckbox.IsDisabled = () => true; var statusLabel = panel.GetWidget("STATUS_LABEL"); statusLabel.IsVisible = () => world.LocalPlayer != null; if (world.LocalPlayer != null) { var lp = world.LocalPlayer; objectiveCheckbox.IsChecked = () => lp.WinState != WinState.Undefined; objectiveCheckbox.GetCheckType = () => lp.WinState == WinState.Won ? "checked" : "crossed"; statusLabel.GetText = () => lp.WinState == WinState.Won ? "Complete" : lp.WinState == WinState.Lost ? "Failed" : "Incomplete"; statusLabel.GetColor = () => lp.WinState == WinState.Won ? Color.Green : lp.WinState == WinState.Lost ? Color.Red : Color.White; } var scrollpanel = panel.GetWidget("PLAYER_LIST"); var itemTemplate = scrollpanel.GetWidget("PLAYER_TEMPLATE"); scrollpanel.RemoveChildren(); foreach (var p in world.Players.Where(a => !a.NonCombatant)) { Player pp = p; var c = world.LobbyInfo.ClientWithIndex(pp.ClientIndex); var item = itemTemplate.Clone(); var nameLabel = item.GetWidget("NAME"); nameLabel.GetText = () => pp.PlayerName; nameLabel.Color = pp.ColorRamp.GetColor(0); var flag = item.GetWidget("FACTIONFLAG"); flag.GetImageName = () => pp.Country.Race; flag.GetImageCollection = () => "flags"; item.GetWidget("FACTION").GetText = () => pp.Country.Name; var team = item.GetWidget("TEAM"); team.GetText = () => c.Team.ToString(); scrollpanel.AddChild(item); item.GetWidget("KILLS").GetText = () => pp.Kills.ToString(); item.GetWidget("DEATHS").GetText = () => pp.Deaths.ToString(); } } } }