separate diplomacy
into it's own container and yaml file control IsVisible from IngameChrome
This commit is contained in:
@@ -21,28 +21,19 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
static List<Widget> controls = new List<Widget>();
|
static List<Widget> controls = new List<Widget>();
|
||||||
|
|
||||||
int validPlayers = 0;
|
|
||||||
readonly World world;
|
readonly World world;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public DiplomacyLogic(World world)
|
public DiplomacyLogic(Widget widget, Action onExit, World world)
|
||||||
{
|
{
|
||||||
this.world = world;
|
this.world = world;
|
||||||
var root = Ui.Root.Get("INGAME_ROOT");
|
var root = Ui.Root.Get("DIPLOMACY");
|
||||||
var diplomacyBG = root.Get("DIPLOMACY_BG");
|
var diplomacyBG = root.Get("DIPLOMACY_BG");
|
||||||
var diplomacy = root.Get<ButtonWidget>("INGAME_DIPLOMACY_BUTTON");
|
LayoutDialog(diplomacyBG);
|
||||||
|
|
||||||
diplomacy.OnClick = () =>
|
var close = widget.GetOrNull<ButtonWidget>("CLOSE_DIPLOMACY");
|
||||||
{
|
if (close != null)
|
||||||
diplomacyBG.Visible = !diplomacyBG.Visible;
|
close.OnClick = () => { Ui.CloseWindow(); onExit(); };
|
||||||
if (diplomacyBG.IsVisible())
|
|
||||||
LayoutDialog(diplomacyBG);
|
|
||||||
};
|
|
||||||
|
|
||||||
validPlayers = world.Players.Where(a => a != world.LocalPlayer && !a.NonCombatant).Count();
|
|
||||||
diplomacy.IsVisible = () => (validPlayers > 0);
|
|
||||||
|
|
||||||
diplomacyBG.Get<ButtonWidget>("CLOSE_DIPLOMACY").OnClick = () => { diplomacyBG.Visible = false; };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is shit
|
// This is shit
|
||||||
|
|||||||
@@ -83,6 +83,17 @@ 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;
|
||||||
|
diplomacy = Game.LoadWidget(world, "DIPLOMACY", playerWidgets, new WidgetArgs
|
||||||
|
{
|
||||||
|
{ "onExit", () => diplomacy.Visible = false }
|
||||||
|
});
|
||||||
|
var diplomacyButton = playerWidgets.Get<ButtonWidget>("INGAME_DIPLOMACY_BUTTON");
|
||||||
|
diplomacyButton.OnClick = () => diplomacy.Visible ^= true;
|
||||||
|
int validPlayers = 0;
|
||||||
|
validPlayers = world.Players.Where(a => a != world.LocalPlayer && !a.NonCombatant).Count();
|
||||||
|
diplomacyButton.IsVisible = () => validPlayers > 0;
|
||||||
|
|
||||||
Widget cheats = null;
|
Widget cheats = null;
|
||||||
cheats = Game.LoadWidget(world, "CHEATS_PANEL", playerWidgets, new WidgetArgs
|
cheats = Game.LoadWidget(world, "CHEATS_PANEL", playerWidgets, new WidgetArgs
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -162,30 +162,6 @@ Container@PLAYER_WIDGETS:
|
|||||||
IconHeight: 48
|
IconHeight: 48
|
||||||
Columns: 3
|
Columns: 3
|
||||||
Rows: 4
|
Rows: 4
|
||||||
Background@DIPLOMACY_BG:
|
|
||||||
Logic:DiplomacyLogic
|
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
|
||||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
|
||||||
Width:450
|
|
||||||
Height:400
|
|
||||||
Visible:false
|
|
||||||
Children:
|
|
||||||
Label@LABEL_TITLE:
|
|
||||||
X:(PARENT_RIGHT - WIDTH)/2
|
|
||||||
Y:20
|
|
||||||
Width:250
|
|
||||||
Height:25
|
|
||||||
Text:Diplomacy
|
|
||||||
Align:Center
|
|
||||||
Font:Bold
|
|
||||||
Button@CLOSE_DIPLOMACY:
|
|
||||||
X:(PARENT_RIGHT - WIDTH)/2
|
|
||||||
Y:350
|
|
||||||
Width:160
|
|
||||||
Height:25
|
|
||||||
Text:Close
|
|
||||||
Font:Bold
|
|
||||||
Key:escape
|
|
||||||
|
|
||||||
Container@OBSERVER_WIDGETS:
|
Container@OBSERVER_WIDGETS:
|
||||||
Children:
|
Children:
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ ChromeLayout:
|
|||||||
mods/d2k/chrome/gameinit.yaml
|
mods/d2k/chrome/gameinit.yaml
|
||||||
mods/d2k/chrome/ingame.yaml
|
mods/d2k/chrome/ingame.yaml
|
||||||
mods/ra/chrome/ingame-chat.yaml
|
mods/ra/chrome/ingame-chat.yaml
|
||||||
|
mods/ra/chrome/ingame-diplomacy.yaml
|
||||||
mods/ra/chrome/ingame-fmvplayer.yaml
|
mods/ra/chrome/ingame-fmvplayer.yaml
|
||||||
mods/ra/chrome/ingame-menu.yaml
|
mods/ra/chrome/ingame-menu.yaml
|
||||||
mods/ra/chrome/ingame-observerstats.yaml
|
mods/ra/chrome/ingame-observerstats.yaml
|
||||||
|
|||||||
30
mods/ra/chrome/ingame-diplomacy.yaml
Normal file
30
mods/ra/chrome/ingame-diplomacy.yaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
Container@DIPLOMACY:
|
||||||
|
Logic:DiplomacyLogic
|
||||||
|
X:25
|
||||||
|
Y:50
|
||||||
|
Width:950
|
||||||
|
Height:500
|
||||||
|
Visible:false
|
||||||
|
Children:
|
||||||
|
Background@DIPLOMACY_BG:
|
||||||
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
|
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||||
|
Width:450
|
||||||
|
Height:400
|
||||||
|
Children:
|
||||||
|
Label@LABEL_TITLE:
|
||||||
|
X:(PARENT_RIGHT - WIDTH)/2
|
||||||
|
Y:20
|
||||||
|
Width:250
|
||||||
|
Height:25
|
||||||
|
Text:Diplomacy
|
||||||
|
Align:Center
|
||||||
|
Font:Bold
|
||||||
|
Button@CLOSE_DIPLOMACY:
|
||||||
|
X:(PARENT_RIGHT - WIDTH)/2
|
||||||
|
Y:350
|
||||||
|
Width:160
|
||||||
|
Height:25
|
||||||
|
Text:Close
|
||||||
|
Font:Bold
|
||||||
|
Key:escape
|
||||||
@@ -158,30 +158,6 @@ Container@PLAYER_WIDGETS:
|
|||||||
ReadyText: READY
|
ReadyText: READY
|
||||||
HoldText: ON HOLD
|
HoldText: ON HOLD
|
||||||
RequiresText: Requires
|
RequiresText: Requires
|
||||||
Background@DIPLOMACY_BG:
|
|
||||||
Logic:DiplomacyLogic
|
|
||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
|
||||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
|
||||||
Width:450
|
|
||||||
Height:400
|
|
||||||
Visible:false
|
|
||||||
Children:
|
|
||||||
Label@LABEL_TITLE:
|
|
||||||
X:(PARENT_RIGHT - WIDTH)/2
|
|
||||||
Y:20
|
|
||||||
Width:250
|
|
||||||
Height:25
|
|
||||||
Text:Diplomacy
|
|
||||||
Align:Center
|
|
||||||
Font:Bold
|
|
||||||
Button@CLOSE_DIPLOMACY:
|
|
||||||
X:(PARENT_RIGHT - WIDTH)/2
|
|
||||||
Y:350
|
|
||||||
Width:160
|
|
||||||
Height:25
|
|
||||||
Text:Close
|
|
||||||
Font:Bold
|
|
||||||
Key:escape
|
|
||||||
|
|
||||||
Container@OBSERVER_WIDGETS:
|
Container@OBSERVER_WIDGETS:
|
||||||
Children:
|
Children:
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ ChromeLayout:
|
|||||||
mods/ra/chrome/gameinit.yaml
|
mods/ra/chrome/gameinit.yaml
|
||||||
mods/ra/chrome/ingame.yaml
|
mods/ra/chrome/ingame.yaml
|
||||||
mods/ra/chrome/ingame-chat.yaml
|
mods/ra/chrome/ingame-chat.yaml
|
||||||
|
mods/ra/chrome/ingame-diplomacy.yaml
|
||||||
mods/ra/chrome/ingame-fmvplayer.yaml
|
mods/ra/chrome/ingame-fmvplayer.yaml
|
||||||
mods/ra/chrome/ingame-menu.yaml
|
mods/ra/chrome/ingame-menu.yaml
|
||||||
mods/ra/chrome/ingame-objectives.yaml
|
mods/ra/chrome/ingame-objectives.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user