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)
{