Add indication of what players are building
This commit is contained in:
@@ -34,6 +34,11 @@ namespace OpenRA.Widgets
|
|||||||
Game.Renderer.SpriteRenderer.DrawSprite(s,pos, wr, "chrome");
|
Game.Renderer.SpriteRenderer.DrawSprite(s,pos, wr, "chrome");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void DrawSHP(Sprite s, float2 pos, WorldRenderer wr, float2 size)
|
||||||
|
{
|
||||||
|
Game.Renderer.SpriteRenderer.DrawSprite(s, pos, wr, "chrome", size);
|
||||||
|
}
|
||||||
|
|
||||||
public static void DrawPanel(string collection, Rectangle Bounds)
|
public static void DrawPanel(string collection, Rectangle Bounds)
|
||||||
{
|
{
|
||||||
DrawPanelPartial(collection, Bounds, PanelSides.All);
|
DrawPanelPartial(collection, Bounds, PanelSides.All);
|
||||||
|
|||||||
@@ -382,6 +382,7 @@
|
|||||||
<Compile Include="Widgets\Logic\ServerCreationLogic.cs" />
|
<Compile Include="Widgets\Logic\ServerCreationLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\SettingsMenuLogic.cs" />
|
<Compile Include="Widgets\Logic\SettingsMenuLogic.cs" />
|
||||||
<Compile Include="Widgets\MoneyBinWidget.cs" />
|
<Compile Include="Widgets\MoneyBinWidget.cs" />
|
||||||
|
<Compile Include="Widgets\ObserverBuildIconWidget.cs" />
|
||||||
<Compile Include="Widgets\OrderButtonWidget.cs" />
|
<Compile Include="Widgets\OrderButtonWidget.cs" />
|
||||||
<Compile Include="Widgets\PowerBinWidget.cs" />
|
<Compile Include="Widgets\PowerBinWidget.cs" />
|
||||||
<Compile Include="Widgets\RadarBinWidget.cs" />
|
<Compile Include="Widgets\RadarBinWidget.cs" />
|
||||||
|
|||||||
@@ -80,6 +80,30 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
template.Get<LabelWidget>("KILLS").GetText = () => player.Kills.ToString();
|
template.Get<LabelWidget>("KILLS").GetText = () => player.Kills.ToString();
|
||||||
template.Get<LabelWidget>("DEATHS").GetText = () => player.Deaths.ToString();
|
template.Get<LabelWidget>("DEATHS").GetText = () => player.Deaths.ToString();
|
||||||
|
|
||||||
|
var building = template.Get<ObserverBuildIconWidget>("BUILDING_ICON");
|
||||||
|
building.GetPlayer = () => player;
|
||||||
|
building.GetQueue = () => "Building";
|
||||||
|
|
||||||
|
var defense = template.Get<ObserverBuildIconWidget>("DEFENSE_ICON");
|
||||||
|
defense.GetPlayer = () => player;
|
||||||
|
defense.GetQueue = () => "Defense";
|
||||||
|
|
||||||
|
var vehicle = template.Get<ObserverBuildIconWidget>("VEHICLE_ICON");
|
||||||
|
vehicle.GetPlayer = () => player;
|
||||||
|
vehicle.GetQueue = () => "Vehicle";
|
||||||
|
|
||||||
|
var infantry = template.Get<ObserverBuildIconWidget>("INFANTRY_ICON");
|
||||||
|
infantry.GetPlayer = () => player;
|
||||||
|
infantry.GetQueue = () => "Infantry";
|
||||||
|
|
||||||
|
var ship = template.Get<ObserverBuildIconWidget>("SHIP_ICON");
|
||||||
|
ship.GetPlayer = () => player;
|
||||||
|
ship.GetQueue = () => "Ship";
|
||||||
|
|
||||||
|
var plane = template.Get<ObserverBuildIconWidget>("PLANE_ICON");
|
||||||
|
plane.GetPlayer = () => player;
|
||||||
|
plane.GetQueue = () => "Plane";
|
||||||
|
|
||||||
playersPanel.AddChild(template);
|
playersPanel.AddChild(template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
80
OpenRA.Mods.RA/Widgets/ObserverBuildIconWidget.cs
Normal file
80
OpenRA.Mods.RA/Widgets/ObserverBuildIconWidget.cs
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2012 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation. For more information,
|
||||||
|
* see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA.Widgets
|
||||||
|
{
|
||||||
|
public class ObserverBuildIconWidget : Widget
|
||||||
|
{
|
||||||
|
public Func<Player> GetPlayer;
|
||||||
|
public Func<string> GetQueue;
|
||||||
|
Dictionary<string, Sprite> iconSprites;
|
||||||
|
World world;
|
||||||
|
WorldRenderer worldRenderer;
|
||||||
|
|
||||||
|
[ObjectCreator.UseCtor]
|
||||||
|
public ObserverBuildIconWidget(World world, WorldRenderer worldRenderer)
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
iconSprites = Rules.Info.Values.Where(u => u.Traits.Contains<BuildableInfo>() && u.Name[0] != '^')
|
||||||
|
.ToDictionary(
|
||||||
|
u => u.Name,
|
||||||
|
u => Game.modData.SpriteLoader.LoadAllSprites(u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]);
|
||||||
|
this.world = world;
|
||||||
|
this.worldRenderer = worldRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ObserverBuildIconWidget(ObserverBuildIconWidget other)
|
||||||
|
: base(other)
|
||||||
|
{
|
||||||
|
GetPlayer = other.GetPlayer;
|
||||||
|
GetQueue = other.GetQueue;
|
||||||
|
iconSprites = other.iconSprites;
|
||||||
|
world = other.world;
|
||||||
|
worldRenderer = other.worldRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Draw()
|
||||||
|
{
|
||||||
|
var player = GetPlayer();
|
||||||
|
var queue = GetQueue();
|
||||||
|
if (player == null || queue == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var production = world.ActorsWithTrait<ProductionQueue>()
|
||||||
|
.Where(a => a.Actor.Owner == player && a.Trait.Info.Type == queue)
|
||||||
|
.Select(a => a.Trait)
|
||||||
|
.FirstOrDefault();
|
||||||
|
if (production == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var item = production.CurrentItem();
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var location = new float2(RenderBounds.Location);
|
||||||
|
var sprite = iconSprites[item.Item];
|
||||||
|
WidgetUtils.DrawSHP(sprite, location, worldRenderer, sprite.size / new float2(2, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Widget Clone()
|
||||||
|
{
|
||||||
|
return new ObserverBuildIconWidget(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -395,7 +395,7 @@ Container@OBSERVER_ROOT:
|
|||||||
Logic:ObserverStatsLogic
|
Logic:ObserverStatsLogic
|
||||||
X:25
|
X:25
|
||||||
Y:50
|
Y:50
|
||||||
Width:565
|
Width:805
|
||||||
Height:400
|
Height:400
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
@@ -434,7 +434,7 @@ Container@OBSERVER_ROOT:
|
|||||||
Font:Bold
|
Font:Bold
|
||||||
Text:Power
|
Text:Power
|
||||||
Label@KILLS_HEADER:
|
Label@KILLS_HEADER:
|
||||||
X:405
|
X:385
|
||||||
Y:40
|
Y:40
|
||||||
Width:40
|
Width:40
|
||||||
Height:25
|
Height:25
|
||||||
@@ -442,13 +442,21 @@ Container@OBSERVER_ROOT:
|
|||||||
Text:Kills
|
Text:Kills
|
||||||
Align:Right
|
Align:Right
|
||||||
Label@DEATHS_HEADER:
|
Label@DEATHS_HEADER:
|
||||||
X:465
|
X:445
|
||||||
Y:40
|
Y:40
|
||||||
Width:40
|
Width:40
|
||||||
Height:25
|
Height:25
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Text:Deaths
|
Text:Deaths
|
||||||
Align:Right
|
Align:Right
|
||||||
|
Label@PRODUCTION_HEADER
|
||||||
|
X:485
|
||||||
|
Y:40
|
||||||
|
Width:PARENT_RIGHT-525
|
||||||
|
Height:25
|
||||||
|
Font:Bold
|
||||||
|
Text:Production
|
||||||
|
Align:Center
|
||||||
ScrollPanel@PLAYERS:
|
ScrollPanel@PLAYERS:
|
||||||
X:25
|
X:25
|
||||||
Y:70
|
Y:70
|
||||||
@@ -498,7 +506,7 @@ Container@OBSERVER_ROOT:
|
|||||||
Width:80
|
Width:80
|
||||||
Height:PARENT_BOTTOM
|
Height:PARENT_BOTTOM
|
||||||
Label@KILLS:
|
Label@KILLS:
|
||||||
X:375
|
X:355
|
||||||
Y:0
|
Y:0
|
||||||
Width:40
|
Width:40
|
||||||
Height:PARENT_BOTTOM
|
Height:PARENT_BOTTOM
|
||||||
@@ -509,6 +517,36 @@ Container@OBSERVER_ROOT:
|
|||||||
Width:40
|
Width:40
|
||||||
Height:PARENT_BOTTOM
|
Height:PARENT_BOTTOM
|
||||||
Align:Right
|
Align:Right
|
||||||
|
ObserverBuildIcon@BUILDING_ICON:
|
||||||
|
X:480
|
||||||
|
Y:0
|
||||||
|
Width:40
|
||||||
|
Height:PARENT_BOTTOM
|
||||||
|
ObserverBuildIcon@DEFENSE_ICON:
|
||||||
|
X:520
|
||||||
|
Y:0
|
||||||
|
Width:40
|
||||||
|
Height:PARENT_BOTTOM
|
||||||
|
ObserverBuildIcon@VEHICLE_ICON:
|
||||||
|
X:560
|
||||||
|
Y:0
|
||||||
|
Width:40
|
||||||
|
Height:PARENT_BOTTOM
|
||||||
|
ObserverBuildIcon@INFANTRY_ICON:
|
||||||
|
X:600
|
||||||
|
Y:0
|
||||||
|
Width:40
|
||||||
|
Height:PARENT_BOTTOM
|
||||||
|
ObserverBuildIcon@SHIP_ICON:
|
||||||
|
X:640
|
||||||
|
Y:0
|
||||||
|
Width:40
|
||||||
|
Height:PARENT_BOTTOM
|
||||||
|
ObserverBuildIcon@PLANE_ICON:
|
||||||
|
X:680
|
||||||
|
Y:0
|
||||||
|
Width:40
|
||||||
|
Height:PARENT_BOTTOM
|
||||||
Background@FMVPLAYER:
|
Background@FMVPLAYER:
|
||||||
Width:WINDOW_RIGHT
|
Width:WINDOW_RIGHT
|
||||||
Height:WINDOW_BOTTOM
|
Height:WINDOW_BOTTOM
|
||||||
|
|||||||
Reference in New Issue
Block a user