Give observers a minimap
This commit is contained in:
@@ -76,10 +76,33 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
Game.BeforeGameStart += UnregisterEvents;
|
||||
|
||||
ingameRoot = widget.GetWidget("INGAME_ROOT");
|
||||
var playerRoot = ingameRoot.GetWidget("PLAYER_ROOT");
|
||||
|
||||
if (world.LocalPlayer != null)
|
||||
Action onOptionsClick = () =>
|
||||
{
|
||||
var playerWidgets = widget.GetWidget("PLAYER_WIDGETS");
|
||||
if (menu != MenuType.None)
|
||||
{
|
||||
Widget.CloseWindow();
|
||||
menu = MenuType.None;
|
||||
}
|
||||
|
||||
ingameRoot.IsVisible = () => false;
|
||||
Game.LoadWidget(world, "INGAME_MENU", Widget.RootWidget, new WidgetArgs()
|
||||
{
|
||||
{ "onExit", () => ingameRoot.IsVisible = () => true }
|
||||
});
|
||||
};
|
||||
|
||||
// Observer
|
||||
if (world.LocalPlayer == null)
|
||||
{
|
||||
var observerWidgets = Game.LoadWidget(world, "OBSERVER_WIDGETS", playerRoot, new WidgetArgs());
|
||||
observerWidgets.GetWidget<ButtonWidget>("OPTIONS_BUTTON").OnClick = onOptionsClick;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Real player
|
||||
var playerWidgets = Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs());
|
||||
playerWidgets.IsVisible = () => true;
|
||||
|
||||
var sidebarRoot = playerWidgets.GetWidget("SIDEBAR_BACKGROUND");
|
||||
@@ -110,46 +133,33 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
SetupProductionGroupButton(queueTypes.GetWidget<ButtonWidget>("INFANTRY"), "Infantry");
|
||||
SetupProductionGroupButton(queueTypes.GetWidget<ButtonWidget>("VEHICLE"), "Vehicle");
|
||||
SetupProductionGroupButton(queueTypes.GetWidget<ButtonWidget>("AIRCRAFT"), "Aircraft");
|
||||
|
||||
playerWidgets.GetWidget<ButtonWidget>("OPTIONS_BUTTON").OnClick = onOptionsClick;
|
||||
|
||||
var cheatsButton = playerWidgets.GetWidget<ButtonWidget>("CHEATS_BUTTON");
|
||||
cheatsButton.OnClick = () =>
|
||||
{
|
||||
if (menu != MenuType.None)
|
||||
Widget.CloseWindow();
|
||||
|
||||
menu = MenuType.Cheats;
|
||||
Game.OpenWindow("CHEATS_PANEL", new WidgetArgs() {{"onExit", () => menu = MenuType.None }});
|
||||
};
|
||||
cheatsButton.IsVisible = () => world.LocalPlayer != null && world.LobbyInfo.GlobalSettings.AllowCheats;
|
||||
|
||||
var postgameBG = ingameRoot.GetWidget("POSTGAME_BG");
|
||||
postgameBG.IsVisible = () =>
|
||||
{
|
||||
return world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined;
|
||||
};
|
||||
|
||||
postgameBG.GetWidget<LabelWidget>("TEXT").GetText = () =>
|
||||
{
|
||||
var state = world.LocalPlayer.WinState;
|
||||
return (state == WinState.Undefined)? "" :
|
||||
((state == WinState.Lost)? "YOU ARE DEFEATED" : "YOU ARE VICTORIOUS");
|
||||
};
|
||||
}
|
||||
|
||||
ingameRoot.GetWidget<ButtonWidget>("OPTIONS_BUTTON").OnClick = () =>
|
||||
{
|
||||
if (menu != MenuType.None)
|
||||
{
|
||||
Widget.CloseWindow();
|
||||
menu = MenuType.None;
|
||||
}
|
||||
|
||||
ingameRoot.IsVisible = () => false;
|
||||
Game.LoadWidget(world, "INGAME_MENU", Widget.RootWidget, new WidgetArgs()
|
||||
{
|
||||
{ "onExit", () => ingameRoot.IsVisible = () => true }
|
||||
});
|
||||
};
|
||||
|
||||
var cheatsButton = ingameRoot.GetWidget<ButtonWidget>("CHEATS_BUTTON");
|
||||
cheatsButton.OnClick = () =>
|
||||
{
|
||||
if (menu != MenuType.None)
|
||||
Widget.CloseWindow();
|
||||
|
||||
menu = MenuType.Cheats;
|
||||
Game.OpenWindow("CHEATS_PANEL", new WidgetArgs() {{"onExit", () => menu = MenuType.None }});
|
||||
};
|
||||
cheatsButton.IsVisible = () => world.LocalPlayer != null && world.LobbyInfo.GlobalSettings.AllowCheats;
|
||||
|
||||
var postgameBG = ingameRoot.GetWidget("POSTGAME_BG");
|
||||
postgameBG.IsVisible = () =>
|
||||
{
|
||||
return world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined;
|
||||
};
|
||||
|
||||
postgameBG.GetWidget<LabelWidget>("TEXT").GetText = () =>
|
||||
{
|
||||
var state = world.LocalPlayer.WinState;
|
||||
return (state == WinState.Undefined)? "" :
|
||||
((state == WinState.Lost)? "YOU ARE DEFEATED" : "YOU ARE VICTORIOUS");
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
if( world == null || world.LocalPlayer == null ) return;
|
||||
if (world == null) return;
|
||||
|
||||
var o = new float2(mapRect.Location.X, mapRect.Location.Y + world.Map.Bounds.Height * previewScale * (1 - radarMinimapHeight)/2);
|
||||
var s = new float2(mapRect.Size.Width, mapRect.Size.Height*radarMinimapHeight);
|
||||
@@ -149,7 +149,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
int updateTicks = 0;
|
||||
public override void Tick()
|
||||
{
|
||||
var hasRadarNew = world
|
||||
var hasRadarNew = world.LocalPlayer == null || world
|
||||
.ActorsWithTrait<ProvidesRadar>()
|
||||
.Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
|
||||
|
||||
|
||||
@@ -48,6 +48,45 @@ Container@INGAME_ROOT:
|
||||
Width:WINDOW_RIGHT
|
||||
Height:WINDOW_BOTTOM
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Container@PLAYER_ROOT:
|
||||
Id:PLAYER_ROOT
|
||||
TooltipContainer:
|
||||
Id:TOOLTIP_CONTAINER
|
||||
Container@OBSERVER_WIDGETS:
|
||||
Id:OBSERVER_WIDGETS
|
||||
Children:
|
||||
TooltipButton@OPTIONS_BUTTON:
|
||||
Id:OPTIONS_BUTTON
|
||||
Key:escape
|
||||
X:WINDOW_RIGHT-202
|
||||
Y:5
|
||||
Width:30
|
||||
Height:25
|
||||
Font:Bold
|
||||
TooltipText: Menu
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:5
|
||||
ImageCollection:order-icons
|
||||
ImageName:options
|
||||
Background@RADAR:
|
||||
X:WINDOW_RIGHT-173
|
||||
Y:5
|
||||
Width:168
|
||||
Height:168
|
||||
Background:panel-gray
|
||||
Children:
|
||||
Radar:
|
||||
X:1
|
||||
Y:1
|
||||
Width:PARENT_RIGHT-2
|
||||
Height:PARENT_BOTTOM-2
|
||||
Container@PLAYER_WIDGETS:
|
||||
Id:PLAYER_WIDGETS
|
||||
Children:
|
||||
Button@CHEATS_BUTTON:
|
||||
Id:CHEATS_BUTTON
|
||||
X:WINDOW_RIGHT-400
|
||||
@@ -55,240 +94,233 @@ Container@INGAME_ROOT:
|
||||
Width:140
|
||||
Height:35
|
||||
Text:Cheats
|
||||
Container@PLAYER_WIDGETS:
|
||||
Id:PLAYER_WIDGETS
|
||||
WorldCommand:
|
||||
Width:WINDOW_RIGHT
|
||||
Height:WINDOW_BOTTOM
|
||||
Background@POSTGAME_BG:
|
||||
Id:POSTGAME_BG
|
||||
X:(WINDOW_RIGHT - WIDTH)/2
|
||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width:400
|
||||
Height:100
|
||||
Background:panel-black
|
||||
Visible:false
|
||||
Children:
|
||||
WorldCommand:
|
||||
Width:WINDOW_RIGHT
|
||||
Height:WINDOW_BOTTOM
|
||||
Background@POSTGAME_BG:
|
||||
Id:POSTGAME_BG
|
||||
X:(WINDOW_RIGHT - WIDTH)/2
|
||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width:400
|
||||
Height:100
|
||||
Background:panel-black
|
||||
Visible:false
|
||||
Children:
|
||||
Label@TEXT:
|
||||
Id:TEXT
|
||||
X:(PARENT_RIGHT - WIDTH)/2
|
||||
Y:(PARENT_BOTTOM - HEIGHT)/2
|
||||
Width:200
|
||||
Height:40
|
||||
Align:Center
|
||||
Font:Bold
|
||||
SupportPowers:
|
||||
Label@TEXT:
|
||||
Id:TEXT
|
||||
X:(PARENT_RIGHT - WIDTH)/2
|
||||
Y:(PARENT_BOTTOM - HEIGHT)/2
|
||||
Width:200
|
||||
Height:40
|
||||
Align:Center
|
||||
Font:Bold
|
||||
SupportPowers:
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
X:10
|
||||
Y:10
|
||||
Background@SIDEBAR_BACKGROUND:
|
||||
Id:SIDEBAR_BACKGROUND
|
||||
X:WINDOW_RIGHT - 204
|
||||
Y:30
|
||||
Width:194
|
||||
Height:240
|
||||
Background:panel-black
|
||||
Children:
|
||||
TooltipButton@OPTIONS_BUTTON:
|
||||
Id:OPTIONS_BUTTON
|
||||
Key:escape
|
||||
X:42
|
||||
Y:0-24
|
||||
Width:30
|
||||
Height:25
|
||||
Font:Bold
|
||||
TooltipText: Menu
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
X:10
|
||||
Y:10
|
||||
Background@SIDEBAR_BACKGROUND:
|
||||
Id:SIDEBAR_BACKGROUND
|
||||
X:WINDOW_RIGHT - 204
|
||||
Y:30
|
||||
Width:194
|
||||
Height:240
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:5
|
||||
ImageCollection:order-icons
|
||||
ImageName:options
|
||||
TooltipButton@SELL_BUTTON:
|
||||
Id:SELL_BUTTON
|
||||
Key: [
|
||||
X:82
|
||||
Y:0-24
|
||||
Width:30
|
||||
Height:25
|
||||
Font:Bold
|
||||
TooltipText: Sell
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:5
|
||||
ImageCollection:order-icons
|
||||
TooltipButton@REPAIR_BUTTON:
|
||||
Id:REPAIR_BUTTON
|
||||
Key: ]
|
||||
X:122
|
||||
Y:0-24
|
||||
Width:30
|
||||
Height:25
|
||||
Font:Bold
|
||||
TooltipText: Repair
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:5
|
||||
ImageCollection:order-icons
|
||||
Background@RADAR:
|
||||
X:13
|
||||
Y:5
|
||||
Width:168
|
||||
Height:168
|
||||
Background:panel-gray
|
||||
Children:
|
||||
Radar:
|
||||
Id:INGAME_RADAR_BIN
|
||||
X:1
|
||||
Y:1
|
||||
Width:PARENT_RIGHT-2
|
||||
Height:PARENT_BOTTOM-2
|
||||
WorldInteractionController:INTERACTION_CONTROLLER
|
||||
Background@POWERBAR:
|
||||
X:4
|
||||
Y:5
|
||||
Width:10
|
||||
Height:168
|
||||
Background:panel-black
|
||||
Children:
|
||||
TooltipButton@OPTIONS_BUTTON:
|
||||
Id:OPTIONS_BUTTON
|
||||
Key:escape
|
||||
X:42
|
||||
Y:0-24
|
||||
Width:30
|
||||
Height:25
|
||||
Font:Bold
|
||||
TooltipText: Menu
|
||||
PowerBar:
|
||||
X:1
|
||||
Y:1
|
||||
Width:PARENT_RIGHT-2
|
||||
Height:PARENT_BOTTOM-2
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:5
|
||||
ImageCollection:order-icons
|
||||
ImageName:options
|
||||
TooltipButton@SELL_BUTTON:
|
||||
Id:SELL_BUTTON
|
||||
Key: [
|
||||
X:82
|
||||
Y:0-24
|
||||
Width:30
|
||||
Height:25
|
||||
Font:Bold
|
||||
TooltipText: Sell
|
||||
Label@POWERICON:
|
||||
X:4
|
||||
Y:180
|
||||
Text:P
|
||||
Font:Bold
|
||||
Background@SILOBAR:
|
||||
X:180
|
||||
Y:5
|
||||
Width:10
|
||||
Height:168
|
||||
Background:panel-black
|
||||
Children:
|
||||
SiloBar:
|
||||
X:1
|
||||
Y:1
|
||||
Width:PARENT_RIGHT-2
|
||||
Height:PARENT_BOTTOM-2
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:5
|
||||
ImageCollection:order-icons
|
||||
TooltipButton@REPAIR_BUTTON:
|
||||
Id:REPAIR_BUTTON
|
||||
Key: ]
|
||||
X:122
|
||||
Y:0-24
|
||||
Label@SILOICON:
|
||||
X:181
|
||||
Y:180
|
||||
Text:T
|
||||
Font:Bold
|
||||
Label@CASH:
|
||||
Id:CASH_DISPLAY
|
||||
Y:170
|
||||
Width:PARENT_RIGHT
|
||||
Height:25
|
||||
Align:Center
|
||||
Font:Bold
|
||||
Container@PRODUCTION_TYPES:
|
||||
Id:PRODUCTION_TYPES
|
||||
X:12
|
||||
Y:197
|
||||
Width:170
|
||||
Height:30
|
||||
Children:
|
||||
TooltipButton@BUILDING:
|
||||
Id:BUILDING
|
||||
Width:30
|
||||
Height:25
|
||||
Font:Bold
|
||||
TooltipText: Repair
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:5
|
||||
ImageCollection:order-icons
|
||||
Background@RADAR:
|
||||
X:13
|
||||
Y:5
|
||||
Width:168
|
||||
Height:168
|
||||
Background:panel-gray
|
||||
Children:
|
||||
Radar:
|
||||
Id:INGAME_RADAR_BIN
|
||||
X:1
|
||||
Y:1
|
||||
Width:PARENT_RIGHT-2
|
||||
Height:PARENT_BOTTOM-2
|
||||
WorldInteractionController:INTERACTION_CONTROLLER
|
||||
Background@POWERBAR:
|
||||
X:4
|
||||
Y:5
|
||||
Width:10
|
||||
Height:168
|
||||
Background:panel-black
|
||||
Children:
|
||||
PowerBar:
|
||||
X:1
|
||||
Y:1
|
||||
Width:PARENT_RIGHT-2
|
||||
Height:PARENT_BOTTOM-2
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Label@POWERICON:
|
||||
X:4
|
||||
Y:180
|
||||
Text:P
|
||||
Font:Bold
|
||||
Background@SILOBAR:
|
||||
X:180
|
||||
Y:5
|
||||
Width:10
|
||||
Height:168
|
||||
Background:panel-black
|
||||
Children:
|
||||
SiloBar:
|
||||
X:1
|
||||
Y:1
|
||||
Width:PARENT_RIGHT-2
|
||||
Height:PARENT_BOTTOM-2
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Label@SILOICON:
|
||||
X:181
|
||||
Y:180
|
||||
Text:T
|
||||
Font:Bold
|
||||
Label@CASH:
|
||||
Id:CASH_DISPLAY
|
||||
Y:170
|
||||
Width:PARENT_RIGHT
|
||||
Height:25
|
||||
Align:Center
|
||||
Font:Bold
|
||||
Container@PRODUCTION_TYPES:
|
||||
Id:PRODUCTION_TYPES
|
||||
X:12
|
||||
Y:197
|
||||
Width:170
|
||||
Height:30
|
||||
Key: y
|
||||
TooltipText: Buildings
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
TooltipButton@BUILDING:
|
||||
Id:BUILDING
|
||||
Width:30
|
||||
Height:30
|
||||
Key: y
|
||||
TooltipText: Buildings
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:7
|
||||
ImageCollection:production-icons
|
||||
TooltipButton@DEFENSE:
|
||||
Id:DEFENSE
|
||||
X:35
|
||||
Width:30
|
||||
Height:30
|
||||
Key: u
|
||||
TooltipText: Defense
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:7
|
||||
ImageCollection:production-icons
|
||||
TooltipButton@INFANTRY:
|
||||
Id:INFANTRY
|
||||
X:70
|
||||
Width:30
|
||||
Height:30
|
||||
Key: i
|
||||
TooltipText: Infantry
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:7
|
||||
ImageCollection:production-icons
|
||||
TooltipButton@VEHICLE:
|
||||
Id:VEHICLE
|
||||
X:105
|
||||
Width:30
|
||||
Height:30
|
||||
Key: o
|
||||
TooltipText: Vehicles
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:7
|
||||
ImageCollection:production-icons
|
||||
TooltipButton@AIRCRAFT:
|
||||
Id:AIRCRAFT
|
||||
X:140
|
||||
Width:30
|
||||
Height:30
|
||||
Key: p
|
||||
TooltipText: Aircraft
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:7
|
||||
ImageCollection:production-icons
|
||||
ProductionTabs:
|
||||
Id:PRODUCTION_TABS
|
||||
PaletteWidget:PRODUCTION_PALETTE
|
||||
X:WINDOW_RIGHT - 204
|
||||
Y:268
|
||||
Width:194
|
||||
Height:20
|
||||
ProductionPalette:
|
||||
Id:PRODUCTION_PALETTE
|
||||
X:WINDOW_RIGHT - 204
|
||||
Y:287
|
||||
TabClick: button.aud
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
TooltipContainer:
|
||||
Id:TOOLTIP_CONTAINER
|
||||
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:7
|
||||
ImageCollection:production-icons
|
||||
TooltipButton@DEFENSE:
|
||||
Id:DEFENSE
|
||||
X:35
|
||||
Width:30
|
||||
Height:30
|
||||
Key: u
|
||||
TooltipText: Defense
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:7
|
||||
ImageCollection:production-icons
|
||||
TooltipButton@INFANTRY:
|
||||
Id:INFANTRY
|
||||
X:70
|
||||
Width:30
|
||||
Height:30
|
||||
Key: i
|
||||
TooltipText: Infantry
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:7
|
||||
ImageCollection:production-icons
|
||||
TooltipButton@VEHICLE:
|
||||
Id:VEHICLE
|
||||
X:105
|
||||
Width:30
|
||||
Height:30
|
||||
Key: o
|
||||
TooltipText: Vehicles
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:7
|
||||
ImageCollection:production-icons
|
||||
TooltipButton@AIRCRAFT:
|
||||
Id:AIRCRAFT
|
||||
X:140
|
||||
Width:30
|
||||
Height:30
|
||||
Key: p
|
||||
TooltipText: Aircraft
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Children:
|
||||
Image:
|
||||
Id:ICON
|
||||
X:7
|
||||
Y:7
|
||||
ImageCollection:production-icons
|
||||
ProductionTabs:
|
||||
Id:PRODUCTION_TABS
|
||||
PaletteWidget:PRODUCTION_PALETTE
|
||||
X:WINDOW_RIGHT - 204
|
||||
Y:268
|
||||
Width:194
|
||||
Height:20
|
||||
ProductionPalette:
|
||||
Id:PRODUCTION_PALETTE
|
||||
X:WINDOW_RIGHT - 204
|
||||
Y:287
|
||||
TabClick: button.aud
|
||||
TooltipContainer:TOOLTIP_CONTAINER
|
||||
Background@FMVPLAYER:
|
||||
Id:FMVPLAYER
|
||||
Width:WINDOW_RIGHT
|
||||
|
||||
Reference in New Issue
Block a user