Make the diplomacy panel consistent with cheats and menu.
This commit is contained in:
@@ -23,13 +23,28 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
ScrollPanelWidget diplomacyPanel;
|
ScrollPanelWidget diplomacyPanel;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public DiplomacyLogic(Widget widget, Action onExit, World world)
|
public DiplomacyLogic(Widget widget, Action onExit, World world, bool transient)
|
||||||
{
|
{
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
|
||||||
diplomacyPanel = widget.Get<ScrollPanelWidget>("DIPLOMACY_PANEL");
|
diplomacyPanel = widget.Get<ScrollPanelWidget>("DIPLOMACY_PANEL");
|
||||||
|
|
||||||
LayoutPlayers();
|
LayoutPlayers();
|
||||||
|
|
||||||
|
var close = widget.GetOrNull<ButtonWidget>("CLOSE");
|
||||||
|
if (close != null)
|
||||||
|
{
|
||||||
|
close.OnClick = () =>
|
||||||
|
{
|
||||||
|
if (transient)
|
||||||
|
{
|
||||||
|
Ui.CloseWindow();
|
||||||
|
Ui.Root.RemoveChild(widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
onExit();
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayoutPlayers()
|
void LayoutPlayers()
|
||||||
|
|||||||
@@ -86,10 +86,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var playerWidgets = Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs());
|
var playerWidgets = Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs());
|
||||||
|
|
||||||
Widget diplomacy = null;
|
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 }
|
{ "onExit", () => diplomacy.Visible = false }
|
||||||
});
|
});
|
||||||
|
diplomacy.Visible = false;
|
||||||
|
|
||||||
var diplomacyButton = playerWidgets.Get<ButtonWidget>("INGAME_DIPLOMACY_BUTTON");
|
var diplomacyButton = playerWidgets.Get<ButtonWidget>("INGAME_DIPLOMACY_BUTTON");
|
||||||
diplomacyButton.OnClick = () => diplomacy.Visible ^= true;
|
diplomacyButton.OnClick = () => diplomacy.Visible ^= true;
|
||||||
var validPlayers = 0;
|
var validPlayers = 0;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Mods.RA.Orders;
|
using OpenRA.Mods.RA.Orders;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
@@ -62,6 +63,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
options.OnClick = () => OpenMenuPanel(options);
|
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");
|
var debug = widget.GetOrNull<MenuButtonWidget>("DEBUG_BUTTON");
|
||||||
if (debug != null)
|
if (debug != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
Background@DIPLOMACY:
|
Background@INGAME_DIPLOMACY_BG:
|
||||||
Logic: DiplomacyLogic
|
Logic: DiplomacyLogic
|
||||||
X: 25
|
X: (WINDOW_RIGHT - WIDTH)/2
|
||||||
Y: 50
|
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
||||||
Width: 490
|
Width: 490
|
||||||
Height: 300
|
Height: 355
|
||||||
Visible: false
|
|
||||||
Children:
|
Children:
|
||||||
Label@LABEL_TITLE:
|
Label@LABEL_TITLE:
|
||||||
X: (PARENT_RIGHT - WIDTH)/2
|
X: (PARENT_RIGHT - WIDTH)/2
|
||||||
@@ -44,7 +43,7 @@ Background@DIPLOMACY:
|
|||||||
X: 20
|
X: 20
|
||||||
Y: 67
|
Y: 67
|
||||||
Width: PARENT_RIGHT-40
|
Width: PARENT_RIGHT-40
|
||||||
Height: PARENT_BOTTOM-87
|
Height: PARENT_BOTTOM-87-35
|
||||||
ItemSpacing: 5
|
ItemSpacing: 5
|
||||||
Children:
|
Children:
|
||||||
ScrollItem@TEAM_TEMPLATE:
|
ScrollItem@TEAM_TEMPLATE:
|
||||||
@@ -82,3 +81,11 @@ Background@DIPLOMACY:
|
|||||||
Width: 100
|
Width: 100
|
||||||
Height: PARENT_BOTTOM
|
Height: PARENT_BOTTOM
|
||||||
|
|
||||||
|
Button@CLOSE:
|
||||||
|
X: PARENT_RIGHT-145
|
||||||
|
Y: PARENT_BOTTOM - 45
|
||||||
|
Width: 120
|
||||||
|
Height: 25
|
||||||
|
Text: Close
|
||||||
|
Key: escape
|
||||||
|
Font: Bold
|
||||||
Reference in New Issue
Block a user