Allow support powers to override the icon overlay/tooltip labels.
This commit is contained in:
@@ -105,13 +105,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Powers[order.OrderString].Activate(order);
|
Powers[order.OrderString].Activate(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated. Remove after SupportPowerBinWidget is removed.
|
|
||||||
public void Target(string key)
|
|
||||||
{
|
|
||||||
if (Powers.ContainsKey(key))
|
|
||||||
Powers[key].Target();
|
|
||||||
}
|
|
||||||
|
|
||||||
static readonly SupportPowerInstance[] NoInstances = { };
|
static readonly SupportPowerInstance[] NoInstances = { };
|
||||||
|
|
||||||
public IEnumerable<SupportPowerInstance> GetPowersForActor(Actor a)
|
public IEnumerable<SupportPowerInstance> GetPowersForActor(Actor a)
|
||||||
@@ -260,6 +253,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
oneShotFired = true;
|
oneShotFired = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual string IconOverlayTextOverride()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual string TooltipTimeTextOverride()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SelectGenericPowerTarget : OrderGenerator
|
public class SelectGenericPowerTarget : OrderGenerator
|
||||||
|
|||||||
@@ -59,11 +59,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
descLabel.Text = sp.Info.LongDesc.Replace("\\n", "\n");
|
descLabel.Text = sp.Info.LongDesc.Replace("\\n", "\n");
|
||||||
var descSize = descFont.Measure(descLabel.Text);
|
var descSize = descFont.Measure(descLabel.Text);
|
||||||
|
|
||||||
var remaining = WidgetUtils.FormatTime(sp.RemainingTicks, world.Timestep);
|
var customLabel = sp.TooltipTimeTextOverride();
|
||||||
var total = WidgetUtils.FormatTime(sp.Info.ChargeInterval, world.Timestep);
|
if (customLabel == null)
|
||||||
timeLabel.Text = "{0} / {1}".F(remaining, total);
|
{
|
||||||
var timeSize = timeFont.Measure(timeLabel.Text);
|
var remaining = WidgetUtils.FormatTime(sp.RemainingTicks, world.Timestep);
|
||||||
|
var total = WidgetUtils.FormatTime(sp.Info.ChargeInterval, world.Timestep);
|
||||||
|
timeLabel.Text = "{0} / {1}".F(remaining, total);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
timeLabel.Text = customLabel;
|
||||||
|
|
||||||
|
var timeSize = timeFont.Measure(timeLabel.Text);
|
||||||
var hotkeyWidth = 0;
|
var hotkeyWidth = 0;
|
||||||
hotkeyLabel.Visible = hotkey.IsValid();
|
hotkeyLabel.Visible = hotkey.IsValid();
|
||||||
if (hotkeyLabel.Visible)
|
if (hotkeyLabel.Visible)
|
||||||
|
|||||||
@@ -215,7 +215,15 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
// Overlay
|
// Overlay
|
||||||
foreach (var p in icons.Values)
|
foreach (var p in icons.Values)
|
||||||
{
|
{
|
||||||
if (p.Power.Ready)
|
var customText = p.Power.IconOverlayTextOverride();
|
||||||
|
if (customText != null)
|
||||||
|
{
|
||||||
|
var customOffset = iconOffset - overlayFont.Measure(customText) / 2;
|
||||||
|
overlayFont.DrawTextWithContrast(customText,
|
||||||
|
p.Pos + customOffset,
|
||||||
|
Color.White, Color.Black, 1);
|
||||||
|
}
|
||||||
|
else if (p.Power.Ready)
|
||||||
overlayFont.DrawTextWithContrast(ReadyText,
|
overlayFont.DrawTextWithContrast(ReadyText,
|
||||||
p.Pos + readyOffset,
|
p.Pos + readyOffset,
|
||||||
Color.White, Color.Black, 1);
|
Color.White, Color.Black, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user