Merge pull request #3574 from ScottNZ/superweapons
Add atom bomb and gps public superweapon timers to RA
This commit is contained in:
@@ -141,21 +141,31 @@ namespace OpenRA.Widgets
|
||||
DrawRGBA(ss[7], new float2(bounds.Right - ss[7].size.X, bounds.Bottom - ss[7].size.Y));
|
||||
}
|
||||
|
||||
|
||||
public static string FormatTime(int ticks)
|
||||
{
|
||||
return FormatTime(ticks, true);
|
||||
}
|
||||
|
||||
public static string FormatTime(int ticks, bool leadingMinuteZero)
|
||||
{
|
||||
var seconds = (int)Math.Ceiling(ticks / 25f);
|
||||
return FormatTimeSeconds( seconds );
|
||||
return FormatTimeSeconds(seconds, leadingMinuteZero);
|
||||
}
|
||||
|
||||
public static string FormatTimeSeconds(int seconds)
|
||||
{
|
||||
return FormatTimeSeconds(seconds, true);
|
||||
}
|
||||
|
||||
public static string FormatTimeSeconds(int seconds, bool leadingMinuteZero)
|
||||
{
|
||||
var minutes = seconds / 60;
|
||||
|
||||
if (minutes >= 60)
|
||||
return "{0:D}:{1:D2}:{2:D2}".F(minutes / 60, minutes % 60, seconds % 60);
|
||||
else
|
||||
if (leadingMinuteZero)
|
||||
return "{0:D2}:{1:D2}".F(minutes, seconds % 60);
|
||||
return "{0:D}:{1:D2}".F(minutes, seconds % 60);
|
||||
}
|
||||
|
||||
public static string WrapText(string text, int width, SpriteFont font)
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
var baseHeight = widget.Bounds.Height;
|
||||
var timeOffset = timeLabel.Bounds.X;
|
||||
|
||||
SupportPowerManager.SupportPowerInstance lastPower = null;
|
||||
SupportPowerInstance lastPower = null;
|
||||
tooltipContainer.BeforeRender = () =>
|
||||
{
|
||||
var sp = palette.TooltipPower;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
|
||||
public readonly string TooltipContainer;
|
||||
public readonly string TooltipTemplate = "SUPPORT_POWER_TOOLTIP";
|
||||
public SupportPowerManager.SupportPowerInstance TooltipPower { get; private set; }
|
||||
public SupportPowerInstance TooltipPower { get; private set; }
|
||||
Lazy<TooltipContainerWidget> tooltipContainer;
|
||||
|
||||
Rectangle eventBounds;
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
|
||||
public class SupportPowerIcon
|
||||
{
|
||||
public SupportPowerManager.SupportPowerInstance Power;
|
||||
public SupportPowerInstance Power;
|
||||
public float2 Pos;
|
||||
public Sprite Sprite;
|
||||
}
|
||||
|
||||
@@ -410,6 +410,7 @@
|
||||
<Compile Include="Widgets\OrderButtonWidget.cs" />
|
||||
<Compile Include="Widgets\RadarWidget.cs" />
|
||||
<Compile Include="Widgets\StrategicProgressWidget.cs" />
|
||||
<Compile Include="Widgets\SupportPowerTimerWidget.cs" />
|
||||
<Compile Include="Widgets\SupportPowerBinWidget.cs" />
|
||||
<Compile Include="Widgets\WorldCommandWidget.cs" />
|
||||
<Compile Include="Widgets\WorldTooltipWidget.cs" />
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace OpenRA.Mods.RA
|
||||
public readonly string SelectTargetSound = null;
|
||||
public readonly string LaunchSound = null;
|
||||
|
||||
public readonly bool DisplayTimer = false;
|
||||
|
||||
public readonly string OrderName;
|
||||
public abstract object Create(ActorInitializer init);
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ namespace OpenRA.Mods.RA
|
||||
return a.TraitsImplementing<SupportPower>()
|
||||
.Select(t => Powers[MakeKey(t)]);
|
||||
}
|
||||
}
|
||||
|
||||
public class SupportPowerInstance
|
||||
{
|
||||
@@ -190,7 +191,6 @@ namespace OpenRA.Mods.RA
|
||||
Disabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SelectGenericPowerTarget : IOrderGenerator
|
||||
{
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
}
|
||||
}
|
||||
|
||||
static string GetOverlayForItem(SupportPowerManager.SupportPowerInstance item)
|
||||
static string GetOverlayForItem(SupportPowerInstance item)
|
||||
{
|
||||
if (item.Disabled) return "ON HOLD";
|
||||
if (item.Ready) return "READY";
|
||||
|
||||
65
OpenRA.Mods.RA/Widgets/SupportPowerTimerWidget.cs
Normal file
65
OpenRA.Mods.RA/Widgets/SupportPowerTimerWidget.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 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.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.RA.Widgets
|
||||
{
|
||||
public class SupportPowerTimerWidget : Widget
|
||||
{
|
||||
public readonly string Font = "Bold";
|
||||
public readonly string Format = "{0}: {1}";
|
||||
public readonly TimerOrder Order = TimerOrder.Descending;
|
||||
|
||||
readonly IEnumerable<SupportPowerInstance> powers;
|
||||
Pair<string, Color>[] texts;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public SupportPowerTimerWidget(World world)
|
||||
{
|
||||
powers = world.ActorsWithTrait<SupportPowerManager>()
|
||||
.Where(p => !p.Actor.IsDead() && !p.Actor.Owner.NonCombatant)
|
||||
.SelectMany(s => s.Trait.Powers.Values)
|
||||
.Where(p => p.Instances.Any() && p.Info.DisplayTimer && !p.Disabled);
|
||||
}
|
||||
|
||||
public override void Tick()
|
||||
{
|
||||
texts = powers.Select(p =>
|
||||
{
|
||||
var time = WidgetUtils.FormatTime(p.RemainingTime, false);
|
||||
var text = Format.F(p.Info.Description, time);
|
||||
var color = !p.Ready || Game.LocalTick % 50 < 25 ? p.Instances[0].self.Owner.Color.RGB : Color.White;
|
||||
return Pair.New(text, color);
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
if (!IsVisible() || texts == null)
|
||||
return;
|
||||
|
||||
var y = 0;
|
||||
foreach (var t in texts)
|
||||
{
|
||||
var font = Game.Renderer.Fonts[Font];
|
||||
font.DrawTextWithContrast(t.First, new float2(Bounds.Location) + new float2(0, y), t.Second, Color.Black, 1);
|
||||
y += (font.Measure(t.First).Y + 5) * (int)Order;
|
||||
}
|
||||
}
|
||||
|
||||
public enum TimerOrder { Ascending = -1, Descending = 1 }
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,10 @@ Container@INGAME_ROOT:
|
||||
Width:170
|
||||
Height:40
|
||||
TooltipContainer@TOOLTIP_CONTAINER:
|
||||
SupportPowerTimer@SUPPORT_POWER_TIMER:
|
||||
X:15
|
||||
Y:WINDOW_BOTTOM-30
|
||||
Order:Ascending
|
||||
|
||||
Container@PLAYER_WIDGETS:
|
||||
Children:
|
||||
|
||||
@@ -35,6 +35,7 @@ MSLO:
|
||||
LaunchSound: alaunch1.aud
|
||||
MissileWeapon: atomic
|
||||
SpawnOffset: 0,427,0
|
||||
DisplayTimer: True
|
||||
CanPowerDown:
|
||||
RequiresPower:
|
||||
SupportPowerChargeBar:
|
||||
@@ -849,9 +850,10 @@ ATEK:
|
||||
OneShot: yes
|
||||
ChargeTime: 480
|
||||
Description: GPS Satellite
|
||||
LongDesc: Reveals the entire map
|
||||
LongDesc: Reveals the entire map.
|
||||
RevealDelay: 15
|
||||
LaunchSound: satlnch1.aud
|
||||
DisplayTimer: True
|
||||
SupportPowerChargeBar:
|
||||
|
||||
WEAP:
|
||||
|
||||
Reference in New Issue
Block a user