Added tooltip to support powers in spec ui

This commit is contained in:
teinarss
2019-05-23 18:27:50 +02:00
committed by Paul Chote
parent 12484caf04
commit c89f4b7a76
8 changed files with 113 additions and 6 deletions

View File

@@ -19,9 +19,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
public class SupportPowerTooltipLogic : ChromeLogic
{
[ObjectCreator.UseCtor]
public SupportPowerTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, SupportPowersWidget palette, World world)
public SupportPowerTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, Func<SupportPowersWidget.SupportPowerIcon> getTooltipIcon, World world)
{
widget.IsVisible = () => palette.TooltipIcon != null && palette.TooltipIcon.Power.Info != null;
widget.IsVisible = () => getTooltipIcon() != null && getTooltipIcon().Power.Info != null;
var nameLabel = widget.Get<LabelWidget>("NAME");
var hotkeyLabel = widget.Get<LabelWidget>("HOTKEY");
var timeLabel = widget.Get<LabelWidget>("TIME");
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
tooltipContainer.BeforeRender = () =>
{
var icon = palette.TooltipIcon;
var icon = getTooltipIcon();
if (icon == null || icon.Power == null || icon.Power.Instances.Count == 0)
return;
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
lastRemainingSeconds = remainingSeconds;
};
timeLabel.GetColor = () => palette.TooltipIcon != null && !palette.TooltipIcon.Power.Active
timeLabel.GetColor = () => getTooltipIcon() != null && !getTooltipIcon().Power.Active
? Color.Red : Color.White;
}
}