diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
index 87187989c5..3d55428839 100644
--- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
+++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
@@ -89,6 +89,7 @@
+
diff --git a/OpenRA.Mods.Cnc/Widgets/CncDiplomacyLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncDiplomacyLogic.cs
new file mode 100755
index 0000000000..99a7e06647
--- /dev/null
+++ b/OpenRA.Mods.Cnc/Widgets/CncDiplomacyLogic.cs
@@ -0,0 +1,90 @@
+#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 OpenRA.Mods.RA;
+using OpenRA.Widgets;
+using OpenRA.Mods.RA.Activities;
+using OpenRA.Traits;
+using System.Linq;
+using System.Collections.Generic;
+
+namespace OpenRA.Mods.Cnc.Widgets
+{
+ public class CncDiplomacyLogic : IWidgetDelegate
+ {
+ World world;
+
+ [ObjectCreator.UseCtor]
+ public CncDiplomacyLogic([ObjectCreator.Param] Widget widget,
+ [ObjectCreator.Param] World world)
+ {
+ this.world = world;
+ var panel = widget.GetWidget("DIPLOMACY_PANEL");
+ panel.GetWidget("BACK_BUTTON").OnClick = Widget.CloseWindow;
+
+ var scrollpanel = panel.GetWidget("PLAYER_LIST");
+ var itemTemplate = scrollpanel.GetWidget("PLAYER_TEMPLATE");
+ scrollpanel.RemoveChildren();
+
+ foreach (var p in world.players.Values.Where(a => a != world.LocalPlayer && !a.NonCombatant))
+ {
+ Player pp = p;
+ 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 stance = item.GetWidget("STANCE");
+ stance.GetText = () => world.LocalPlayer.Stances[ pp ].ToString();
+ stance.OnMouseDown = _ => ShowStanceDropDown(stance, pp);
+ stance.IsDisabled = () => pp.IsBot || world.LobbyInfo.GlobalSettings.LockTeams;
+ scrollpanel.AddChild(item);
+ }
+ }
+
+ bool ShowStanceDropDown(DropDownButtonWidget dropdown, Player pp)
+ {
+ if (dropdown.IsDisabled())
+ return true;
+
+ var substitutions = new Dictionary() {{ "DROPDOWN_WIDTH", dropdown.Bounds.Width }};
+ var panel = (ScrollPanelWidget)Widget.LoadWidget("LABEL_DROPDOWN_TEMPLATE", null, new WidgetArgs()
+ {
+ { "substitutions", substitutions }
+ });
+
+ var itemTemplate = panel.GetWidget("TEMPLATE");
+
+ foreach (var option in Enum.GetValues(typeof(Stance)).OfType())
+ {
+ var o = option;
+ var item = ScrollItemWidget.Setup(itemTemplate, () => o == world.LocalPlayer.Stances[ pp ],
+ () => {
+ world.IssueOrder(new Order("SetStance", world.LocalPlayer.PlayerActor,
+ false) { TargetLocation = new int2(pp.Index, (int)o) });
+ dropdown.RemovePanel();
+ });
+ item.GetWidget("LABEL").GetText = () => o.ToString();
+ panel.AddChild(item);
+ }
+
+ panel.Bounds.Height = Math.Min(150, panel.ContentHeight);
+ dropdown.AttachPanel(panel);
+ return true;
+ }
+ }
+}
diff --git a/OpenRA.Mods.Cnc/Widgets/CncIngameChromeLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncIngameChromeLogic.cs
index 96dd70ab88..c9e5529a2a 100755
--- a/OpenRA.Mods.Cnc/Widgets/CncIngameChromeLogic.cs
+++ b/OpenRA.Mods.Cnc/Widgets/CncIngameChromeLogic.cs
@@ -13,6 +13,7 @@ using System.Drawing;
using OpenRA.Mods.RA;
using OpenRA.Widgets;
using OpenRA.Mods.RA.Activities;
+using System.Linq;
namespace OpenRA.Mods.Cnc.Widgets
{
@@ -57,7 +58,11 @@ namespace OpenRA.Mods.Cnc.Widgets
if (world.LocalPlayer != null)
widget.GetWidget("PLAYER_WIDGETS").IsVisible = () => true;
- ingameRoot.GetWidget("DIPLOMACY_BUTTON").IsDisabled = () => true;
+ var diplomacyButton = ingameRoot.GetWidget("DIPLOMACY_BUTTON");
+ var diplomacyAvailable = world.players.Values.Any(a => a != world.LocalPlayer && !a.NonCombatant);
+ diplomacyButton.IsDisabled = () => !diplomacyAvailable;
+ diplomacyButton.OnClick = () => Game.OpenWindow("DIPLOMACY_PANEL", new WidgetArgs());
+
ingameRoot.GetWidget("OPTIONS_BUTTON").OnClick = () =>
{
ingameRoot.IsVisible = () => false;
diff --git a/mods/cnc/chrome/diplomacy.yaml b/mods/cnc/chrome/diplomacy.yaml
new file mode 100644
index 0000000000..41bc582a59
--- /dev/null
+++ b/mods/cnc/chrome/diplomacy.yaml
@@ -0,0 +1,88 @@
+Container@DIPLOMACY_PANEL:
+ Id:DIPLOMACY_PANEL
+ Delegate:CncDiplomacyLogic
+ X:(WINDOW_RIGHT - WIDTH)/2
+ Y:(WINDOW_BOTTOM - 400)/2
+ Width:450
+ Height:335
+ Children:
+ Label@TITLE:
+ Width:PARENT_RIGHT
+ Y:0-25
+ Font:BigBold
+ Contrast:true
+ Align:Center
+ Text:Diplomacy
+ Background@bg:
+ Width:450
+ Height:300
+ Background:panel-black
+ Children:
+ ScrollPanel@PLAYER_LIST:
+ Id:PLAYER_LIST
+ X:15
+ Y:30
+ Width:420
+ Height:255
+ 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:PARENT_RIGHT-210
+ Y:5
+ Width:30
+ Height:15
+ Label@FACTION:
+ Id:FACTION
+ X:PARENT_RIGHT-170
+ Width:40
+ Height:25
+ DropDownButton@STANCE:
+ Id:STANCE
+ X:PARENT_RIGHT-110
+ Width:100
+ Height:25
+ Container@LABEL_CONTAINER:
+ X:17
+ Y:5
+ Width:393
+ Children:
+ Label@NAME:
+ X:10
+ Width:150
+ Height:25
+ Text:Player
+ Align:Center
+ Font:Bold
+ Label@RACE:
+ X:PARENT_RIGHT-220
+ Width:100
+ Height:25
+ Text:Faction
+ Font:Bold
+ Align:Center
+ Label@STANCE:
+ X:PARENT_RIGHT-110
+ Width:100
+ Height:25
+ Text:Stance
+ Font:Bold
+ Align:Center
+ Button@BACK_BUTTON:
+ Id:BACK_BUTTON
+ Y:299
+ Width:140
+ Height:35
+ Text:Back
\ No newline at end of file
diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml
index 3b883331db..7db6fc68f8 100644
--- a/mods/cnc/mod.yaml
+++ b/mods/cnc/mod.yaml
@@ -78,6 +78,7 @@ ChromeLayout:
mods/cnc/chrome/modchooser.yaml
mods/cnc/chrome/preferences.yaml
mods/cnc/chrome/cheats.yaml
+ mods/cnc/chrome/diplomacy.yaml
mods/cnc/chrome/dropdowns.yaml
Weapons: