diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj index f46017fb24..c3a238a942 100644 --- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj +++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj @@ -90,6 +90,7 @@ + diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs new file mode 100644 index 0000000000..1dcf9abeda --- /dev/null +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs @@ -0,0 +1,74 @@ +#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(); + } + } + } +} diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs index dd70b2b0d9..be02ba62ad 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs @@ -88,8 +88,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic onExit(); }; - menu.GetWidget("RECBLOCK").IsVisible = () => world.FrameNumber / 25 % 2 == 0; - // Mission objectives panel var iop = world.WorldActor.TraitsImplementing().FirstOrDefault(); if (iop != null && iop.ObjectivesPanel != null) diff --git a/mods/cnc/chrome/ingamemenu.yaml b/mods/cnc/chrome/ingamemenu.yaml index e05b1854c5..f14781134e 100644 --- a/mods/cnc/chrome/ingamemenu.yaml +++ b/mods/cnc/chrome/ingamemenu.yaml @@ -4,27 +4,6 @@ Container@INGAME_MENU: Height:WINDOW_BOTTOM Logic:CncIngameMenuLogic Children: - Image@RETICLE: - X:(WINDOW_RIGHT-WIDTH)/2 - Y:(WINDOW_BOTTOM-HEIGHT)/2 - Width:512 - Height:512 - ImageCollection:shellmap - ImageName:reticle - Label@REC: - X:(WINDOW_RIGHT-512)/2+10 - Y:(WINDOW_BOTTOM+512)/2-28 - Height:18 - Font:Bold - Text:REC - Image@RECBLOCK: - Id:RECBLOCK - X:(WINDOW_RIGHT-512)/2+40 - Y:(WINDOW_BOTTOM+512)/2-25 - Width:16 - Height:16 - ImageCollection:shellmapbits - ImageName:record Image@EVA: X:WINDOW_RIGHT-128-43 Y:43 diff --git a/mods/cnc/chrome/objectives.yaml b/mods/cnc/chrome/objectives.yaml new file mode 100644 index 0000000000..a34b2d7336 --- /dev/null +++ b/mods/cnc/chrome/objectives.yaml @@ -0,0 +1,132 @@ +Container@CONQUEST_OBJECTIVES: + Id:CONQUEST_OBJECTIVES + Logic:CncConquestObjectivesLogic + X:(WINDOW_RIGHT - WIDTH)/2 + Y:(WINDOW_BOTTOM - HEIGHT)/2 + Width:512 + Height:320 + Children: + Label@TITLE: + Width:PARENT_RIGHT + Id:TITLE + Y:0-25 + Font:BigBold + Contrast:true + Align:Center + Background@bg: + Width:512 + Height:320 + Background:panel-black + Children: + Label@PRIMARY: + X:15 + Y:10 + Width:482 + Height:25 + Font:MediumBold + Text:Primary Objectives: + Label@STATUS: + Id:STATUS_LABEL + X:190 + Y:10 + Width:482 + Height:25 + Font:MediumBold + Text:Incomplete + Checkbox@1: + Id:OBJECTIVE_CHECKBOX + X:25 + Y:45 + Width:482 + Height:20 + Font:Bold + Text:Crush all opposition! + Container@LABEL_CONTAINER: + X:17 + Y:80 + Width:393 + Children: + Label@NAME: + X:10 + Width:150 + Height:25 + Text:Player + Align:Center + Font:Bold + Label@RACE: + X:150 + Width:80 + Height:25 + Text:Faction + Font:Bold + Align:Center + Label@STANCE: + X:240 + Width:70 + Height:25 + Text:Team + Font:Bold + Align:Center + Label@KILLS: + X:310 + Width:70 + Height:25 + Text:Kills + Font:Bold + Align:Center + Label@DEATHS: + X:380 + Width:70 + Height:25 + Text:Deaths + Font:Bold + Align:Center + ScrollPanel@PLAYER_LIST: + Id:PLAYER_LIST + X:15 + Y:105 + Width:482 + Height:200 + ItemSpacing:5 + Children: + Container@PLAYER_TEMPLATE: + Id:PLAYER_TEMPLATE + Width:PARENT_RIGHT-27 + Height:25 + X:2 + Y:0 + Children: + Label@NAME: + Id:NAME + X:10 + Width:150 + Height:25 + Image@FACTIONFLAG: + Id:FACTIONFLAG + X:160 + Y:5 + Width:30 + Height:15 + Label@FACTION: + Id:FACTION + X:195 + Width:40 + Height:25 + Label@TEAM: + Id:TEAM + X:240 + Width:70 + Height:25 + Align:Center + Label@KILLS: + Id:KILLS + X:310 + Width:70 + Height:25 + Align:Center + Label@DEATHS: + Id:DEATHS + X:380 + Width:70 + Height:25 + Align:Center \ No newline at end of file diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index e42bc3f49e..913b78d48b 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -81,6 +81,7 @@ ChromeLayout: mods/cnc/chrome/cheats.yaml mods/cnc/chrome/diplomacy.yaml mods/cnc/chrome/dropdowns.yaml + mods/cnc/chrome/objectives.yaml Weapons: mods/cnc/weapons.yaml @@ -124,6 +125,9 @@ Fonts: Title: Font:titles.ttf Size:48 + MediumBold: + Font:FreeSansBold.ttf + Size:18 BigBold: Font:FreeSansBold.ttf Size:24