Make the diplomacy panel consistent with cheats and menu.

This commit is contained in:
Paul Chote
2014-07-17 16:13:48 +12:00
parent 9e2b3ce0b8
commit fda3ae2fb0
4 changed files with 42 additions and 8 deletions

View File

@@ -23,13 +23,28 @@ namespace OpenRA.Mods.RA.Widgets.Logic
ScrollPanelWidget diplomacyPanel;
[ObjectCreator.UseCtor]
public DiplomacyLogic(Widget widget, Action onExit, World world)
public DiplomacyLogic(Widget widget, Action onExit, World world, bool transient)
{
this.world = world;
diplomacyPanel = widget.Get<ScrollPanelWidget>("DIPLOMACY_PANEL");
LayoutPlayers();
var close = widget.GetOrNull<ButtonWidget>("CLOSE");
if (close != null)
{
close.OnClick = () =>
{
if (transient)
{
Ui.CloseWindow();
Ui.Root.RemoveChild(widget);
}
onExit();
};
}
}
void LayoutPlayers()

View File

@@ -86,10 +86,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var playerWidgets = Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs());
Widget diplomacy = null;
diplomacy = Game.LoadWidget(world, "DIPLOMACY", playerWidgets, new WidgetArgs
diplomacy = Game.LoadWidget(world, "INGAME_DIPLOMACY_BG", playerWidgets, new WidgetArgs
{
{ "transient", true },
{ "onExit", () => diplomacy.Visible = false }
});
diplomacy.Visible = false;
var diplomacyButton = playerWidgets.Get<ButtonWidget>("INGAME_DIPLOMACY_BUTTON");
diplomacyButton.OnClick = () => diplomacy.Visible ^= true;
var validPlayers = 0;

View File

@@ -8,6 +8,7 @@
*/
#endregion
using System.Linq;
using OpenRA.Mods.RA.Orders;
using OpenRA.Widgets;
@@ -62,6 +63,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
options.OnClick = () => OpenMenuPanel(options);
}
var diplomacy = widget.GetOrNull<MenuButtonWidget>("DIPLOMACY_BUTTON");
if (diplomacy != null)
{
diplomacy.Visible = world.Players.Any(a => a != world.LocalPlayer && !a.NonCombatant);
diplomacy.IsDisabled = () => disableSystemButtons;
diplomacy.OnClick = () => OpenMenuPanel(diplomacy);
}
var debug = widget.GetOrNull<MenuButtonWidget>("DEBUG_BUTTON");
if (debug != null)
{

View File

@@ -1,10 +1,9 @@
Background@DIPLOMACY:
Background@INGAME_DIPLOMACY_BG:
Logic: DiplomacyLogic
X: 25
Y: 50
X: (WINDOW_RIGHT - WIDTH)/2
Y: (WINDOW_BOTTOM - HEIGHT)/2
Width: 490
Height: 300
Visible: false
Height: 355
Children:
Label@LABEL_TITLE:
X: (PARENT_RIGHT - WIDTH)/2
@@ -44,7 +43,7 @@ Background@DIPLOMACY:
X: 20
Y: 67
Width: PARENT_RIGHT-40
Height: PARENT_BOTTOM-87
Height: PARENT_BOTTOM-87-35
ItemSpacing: 5
Children:
ScrollItem@TEAM_TEMPLATE:
@@ -82,3 +81,11 @@ Background@DIPLOMACY:
Width: 100
Height: PARENT_BOTTOM
Button@CLOSE:
X: PARENT_RIGHT-145
Y: PARENT_BOTTOM - 45
Width: 120
Height: 25
Text: Close
Key: escape
Font: Bold