Remove diplomacy menu, lock teams option (Feature #950).
This commit is contained in:
@@ -89,7 +89,6 @@
|
|||||||
<Compile Include="Widgets\Logic\CncDownloadPackagesLogic.cs" />
|
<Compile Include="Widgets\Logic\CncDownloadPackagesLogic.cs" />
|
||||||
<Compile Include="CncMenuPaletteEffect.cs" />
|
<Compile Include="CncMenuPaletteEffect.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncIngameMenuLogic.cs" />
|
<Compile Include="Widgets\Logic\CncIngameMenuLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncDiplomacyLogic.cs" />
|
|
||||||
<Compile Include="Widgets\Logic\CncConquestObjectivesLogic.cs" />
|
<Compile Include="Widgets\Logic\CncConquestObjectivesLogic.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
#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.Linq;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|
||||||
{
|
|
||||||
public class CncDiplomacyLogic
|
|
||||||
{
|
|
||||||
World world;
|
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
|
||||||
public CncDiplomacyLogic([ObjectCreator.Param] Widget widget,
|
|
||||||
[ObjectCreator.Param] Action onExit,
|
|
||||||
[ObjectCreator.Param] World world)
|
|
||||||
{
|
|
||||||
this.world = world;
|
|
||||||
var panel = widget.GetWidget("DIPLOMACY_PANEL");
|
|
||||||
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
|
|
||||||
|
|
||||||
var scrollpanel = panel.GetWidget<ScrollPanelWidget>("PLAYER_LIST");
|
|
||||||
var itemTemplate = scrollpanel.GetWidget("PLAYER_TEMPLATE");
|
|
||||||
scrollpanel.RemoveChildren();
|
|
||||||
|
|
||||||
foreach (var p in world.Players.Where(a => a != world.LocalPlayer && !a.NonCombatant))
|
|
||||||
{
|
|
||||||
Player pp = p;
|
|
||||||
var item = itemTemplate.Clone();
|
|
||||||
var nameLabel = item.GetWidget<LabelWidget>("NAME");
|
|
||||||
nameLabel.GetText = () => pp.PlayerName;
|
|
||||||
nameLabel.Color = pp.ColorRamp.GetColor(0);
|
|
||||||
|
|
||||||
var flag = item.GetWidget<ImageWidget>("FACTIONFLAG");
|
|
||||||
flag.GetImageName = () => pp.Country.Race;
|
|
||||||
flag.GetImageCollection = () => "flags";
|
|
||||||
item.GetWidget<LabelWidget>("FACTION").GetText = () => pp.Country.Name;
|
|
||||||
|
|
||||||
var stance = item.GetWidget<DropDownButtonWidget>("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 stances = Enum.GetValues(typeof(Stance)).OfType<Stance>().ToList();
|
|
||||||
Func<Stance, ScrollItemWidget, ScrollItemWidget> setupItem = (s, template) =>
|
|
||||||
{
|
|
||||||
var item = ScrollItemWidget.Setup(template,
|
|
||||||
() => s == world.LocalPlayer.Stances[ pp ],
|
|
||||||
() => world.IssueOrder(new Order("SetStance", world.LocalPlayer.PlayerActor, false)
|
|
||||||
{ TargetLocation = new int2((int)s, 0), TargetString = pp.InternalName }));
|
|
||||||
|
|
||||||
item.GetWidget<LabelWidget>("LABEL").GetText = () => s.ToString();
|
|
||||||
return item;
|
|
||||||
};
|
|
||||||
|
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 150, stances, setupItem);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
{
|
{
|
||||||
public class CncIngameChromeLogic
|
public class CncIngameChromeLogic
|
||||||
{
|
{
|
||||||
enum MenuType { None, Diplomacy, Cheats }
|
enum MenuType { None, Cheats }
|
||||||
MenuType menu = MenuType.None;
|
MenuType menu = MenuType.None;
|
||||||
|
|
||||||
Widget ingameRoot;
|
Widget ingameRoot;
|
||||||
@@ -48,18 +48,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
if (world.LocalPlayer != null)
|
if (world.LocalPlayer != null)
|
||||||
widget.GetWidget("PLAYER_WIDGETS").IsVisible = () => true;
|
widget.GetWidget("PLAYER_WIDGETS").IsVisible = () => true;
|
||||||
|
|
||||||
var diplomacyButton = ingameRoot.GetWidget<ButtonWidget>("DIPLOMACY_BUTTON");
|
|
||||||
var diplomacyAvailable = world.LocalPlayer != null && world.Players.Any(a => a != world.LocalPlayer && !a.NonCombatant);
|
|
||||||
diplomacyButton.IsDisabled = () => !diplomacyAvailable;
|
|
||||||
diplomacyButton.OnClick = () =>
|
|
||||||
{
|
|
||||||
if (menu != MenuType.None)
|
|
||||||
Widget.CloseWindow();
|
|
||||||
|
|
||||||
menu = MenuType.Diplomacy;
|
|
||||||
Game.OpenWindow("DIPLOMACY_PANEL", new WidgetArgs() {{"onExit", () => menu = MenuType.None }});
|
|
||||||
};
|
|
||||||
|
|
||||||
ingameRoot.GetWidget<ButtonWidget>("OPTIONS_BUTTON").OnClick = () =>
|
ingameRoot.GetWidget<ButtonWidget>("OPTIONS_BUTTON").OnClick = () =>
|
||||||
{
|
{
|
||||||
if (menu != MenuType.None)
|
if (menu != MenuType.None)
|
||||||
@@ -81,7 +69,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
if (menu != MenuType.None)
|
if (menu != MenuType.None)
|
||||||
Widget.CloseWindow();
|
Widget.CloseWindow();
|
||||||
|
|
||||||
menu = MenuType.Diplomacy;
|
menu = MenuType.Cheats;
|
||||||
Game.OpenWindow("CHEATS_PANEL", new WidgetArgs() {{"onExit", () => menu = MenuType.None }});
|
Game.OpenWindow("CHEATS_PANEL", new WidgetArgs() {{"onExit", () => menu = MenuType.None }});
|
||||||
};
|
};
|
||||||
cheatsButton.IsVisible = () => world.LocalPlayer != null && world.LobbyInfo.GlobalSettings.AllowCheats;
|
cheatsButton.IsVisible = () => world.LocalPlayer != null && world.LobbyInfo.GlobalSettings.AllowCheats;
|
||||||
|
|||||||
@@ -176,12 +176,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
disconnectButton.OnClick = () => { CloseWindow(); onExit(); };
|
disconnectButton.OnClick = () => { CloseWindow(); onExit(); };
|
||||||
|
|
||||||
var gameStarting = false;
|
var gameStarting = false;
|
||||||
var lockTeamsCheckbox = lobby.GetWidget<CheckboxWidget>("LOCKTEAMS_CHECKBOX");
|
|
||||||
lockTeamsCheckbox.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.LockTeams;
|
|
||||||
lockTeamsCheckbox.IsDisabled = () => !Game.IsHost || gameStarting || orderManager.LocalClient == null
|
|
||||||
|| orderManager.LocalClient.State == Session.ClientState.Ready;
|
|
||||||
lockTeamsCheckbox.OnClick = () => orderManager.IssueOrder(Order.Command(
|
|
||||||
"lockteams {0}".F(!orderManager.LobbyInfo.GlobalSettings.LockTeams)));
|
|
||||||
|
|
||||||
var allowCheats = lobby.GetWidget<CheckboxWidget>("ALLOWCHEATS_CHECKBOX");
|
var allowCheats = lobby.GetWidget<CheckboxWidget>("ALLOWCHEATS_CHECKBOX");
|
||||||
allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats;
|
allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats;
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
Container@DIPLOMACY_PANEL:
|
|
||||||
Id:DIPLOMACY_PANEL
|
|
||||||
Logic: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
|
|
||||||
Key:escape
|
|
||||||
Y:299
|
|
||||||
Width:140
|
|
||||||
Height:35
|
|
||||||
Text:Back
|
|
||||||
@@ -25,16 +25,9 @@ Container@INGAME_ROOT:
|
|||||||
Width:140
|
Width:140
|
||||||
Height:35
|
Height:35
|
||||||
Text:Options
|
Text:Options
|
||||||
Button@DIPLOMACY_BUTTON:
|
|
||||||
Id:DIPLOMACY_BUTTON
|
|
||||||
X:150
|
|
||||||
Y:5
|
|
||||||
Width:140
|
|
||||||
Height:35
|
|
||||||
Text:Diplomacy
|
|
||||||
Button@CHEATS_BUTTON:
|
Button@CHEATS_BUTTON:
|
||||||
Id:CHEATS_BUTTON
|
Id:CHEATS_BUTTON
|
||||||
X:295
|
X:150
|
||||||
Y:5
|
Y:5
|
||||||
Width:140
|
Width:140
|
||||||
Height:35
|
Height:35
|
||||||
|
|||||||
@@ -31,13 +31,6 @@ Container@SERVER_LOBBY:
|
|||||||
Y:1
|
Y:1
|
||||||
Width:192
|
Width:192
|
||||||
Height:192
|
Height:192
|
||||||
Checkbox@LOCKTEAMS_CHECKBOX:
|
|
||||||
Id:LOCKTEAMS_CHECKBOX
|
|
||||||
X:PARENT_RIGHT-209
|
|
||||||
Y:230
|
|
||||||
Width:130
|
|
||||||
Height:20
|
|
||||||
Text: Lock Teams
|
|
||||||
Checkbox@ALLOWCHEATS_CHECKBOX:
|
Checkbox@ALLOWCHEATS_CHECKBOX:
|
||||||
Id:ALLOWCHEATS_CHECKBOX
|
Id:ALLOWCHEATS_CHECKBOX
|
||||||
X:PARENT_RIGHT-209
|
X:PARENT_RIGHT-209
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ ChromeLayout:
|
|||||||
mods/cnc/chrome/modchooser.yaml
|
mods/cnc/chrome/modchooser.yaml
|
||||||
mods/cnc/chrome/preferences.yaml
|
mods/cnc/chrome/preferences.yaml
|
||||||
mods/cnc/chrome/cheats.yaml
|
mods/cnc/chrome/cheats.yaml
|
||||||
mods/cnc/chrome/diplomacy.yaml
|
|
||||||
mods/cnc/chrome/dropdowns.yaml
|
mods/cnc/chrome/dropdowns.yaml
|
||||||
mods/cnc/chrome/objectives.yaml
|
mods/cnc/chrome/objectives.yaml
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user