unhardcode palettes and sequences
This commit is contained in:
committed by
Matthias Mailänder
parent
e057a97217
commit
8e9da7f897
@@ -27,6 +27,8 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public Hotkey Hotkey;
|
public Hotkey Hotkey;
|
||||||
public Sprite Sprite;
|
public Sprite Sprite;
|
||||||
public PaletteReference Palette;
|
public PaletteReference Palette;
|
||||||
|
public PaletteReference IconClockPalette;
|
||||||
|
public PaletteReference IconDarkenPalette;
|
||||||
public float2 Pos;
|
public float2 Pos;
|
||||||
public List<ProductionItem> Queued;
|
public List<ProductionItem> Queued;
|
||||||
}
|
}
|
||||||
@@ -46,6 +48,14 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public readonly string TooltipContainer;
|
public readonly string TooltipContainer;
|
||||||
public readonly string TooltipTemplate = "PRODUCTION_TOOLTIP";
|
public readonly string TooltipTemplate = "PRODUCTION_TOOLTIP";
|
||||||
|
|
||||||
|
public readonly string ClockAnimation = "clock";
|
||||||
|
public readonly string ClockSequence = "idle";
|
||||||
|
public readonly string ClockPalette = "chrome";
|
||||||
|
|
||||||
|
public readonly string NotBuildableAnimation = "clock";
|
||||||
|
public readonly string NotBuildableSequence = "idle";
|
||||||
|
public readonly string NotBuildablePalette = "chrome";
|
||||||
|
|
||||||
[Translate] public readonly string ReadyText = "";
|
[Translate] public readonly string ReadyText = "";
|
||||||
[Translate] public readonly string HoldText = "";
|
[Translate] public readonly string HoldText = "";
|
||||||
|
|
||||||
@@ -89,9 +99,9 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
tooltipContainer = Exts.Lazy(() =>
|
tooltipContainer = Exts.Lazy(() =>
|
||||||
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
|
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
|
||||||
|
|
||||||
cantBuild = new Animation(world, "clock");
|
cantBuild = new Animation(world, NotBuildableAnimation);
|
||||||
cantBuild.PlayFetchIndex("idle", () => 0);
|
cantBuild.PlayFetchIndex(NotBuildableSequence, () => 0);
|
||||||
clock = new Animation(world, "clock");
|
clock = new Animation(world, ClockAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScrollDown()
|
public void ScrollDown()
|
||||||
@@ -322,6 +332,8 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
Hotkey = ks.GetProductionHotkey(DisplayedIconCount),
|
Hotkey = ks.GetProductionHotkey(DisplayedIconCount),
|
||||||
Sprite = icon.Image,
|
Sprite = icon.Image,
|
||||||
Palette = worldRenderer.Palette(bi.IconPalette),
|
Palette = worldRenderer.Palette(bi.IconPalette),
|
||||||
|
IconClockPalette = worldRenderer.Palette(ClockPalette),
|
||||||
|
IconDarkenPalette = worldRenderer.Palette(NotBuildablePalette),
|
||||||
Pos = new float2(rect.Location),
|
Pos = new float2(rect.Location),
|
||||||
Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList()
|
Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList()
|
||||||
};
|
};
|
||||||
@@ -367,15 +379,15 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
if (icon.Queued.Count > 0)
|
if (icon.Queued.Count > 0)
|
||||||
{
|
{
|
||||||
var first = icon.Queued[0];
|
var first = icon.Queued[0];
|
||||||
clock.PlayFetchIndex("idle",
|
clock.PlayFetchIndex(ClockSequence,
|
||||||
() => (first.TotalTime - first.RemainingTime)
|
() => (first.TotalTime - first.RemainingTime)
|
||||||
* (clock.CurrentSequence.Length - 1) / first.TotalTime);
|
* (clock.CurrentSequence.Length - 1) / first.TotalTime);
|
||||||
clock.Tick();
|
clock.Tick();
|
||||||
|
|
||||||
WidgetUtils.DrawSHPCentered(clock.Image, icon.Pos + iconOffset, icon.Palette);
|
WidgetUtils.DrawSHPCentered(clock.Image, icon.Pos + iconOffset, icon.IconClockPalette);
|
||||||
}
|
}
|
||||||
else if (!buildableItems.Any(a => a.Name == icon.Name))
|
else if (!buildableItems.Any(a => a.Name == icon.Name))
|
||||||
WidgetUtils.DrawSHPCentered(cantBuild.Image, icon.Pos + iconOffset, icon.Palette);
|
WidgetUtils.DrawSHPCentered(cantBuild.Image, icon.Pos + iconOffset, icon.IconDarkenPalette);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overlays
|
// Overlays
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public readonly string TooltipContainer;
|
public readonly string TooltipContainer;
|
||||||
public readonly string TooltipTemplate = "SUPPORT_POWER_TOOLTIP";
|
public readonly string TooltipTemplate = "SUPPORT_POWER_TOOLTIP";
|
||||||
|
|
||||||
|
public readonly string ClockAnimation = "clock";
|
||||||
|
public readonly string ClockSequence = "idle";
|
||||||
|
public readonly string ClockPalette = "chrome";
|
||||||
|
|
||||||
public int IconCount { get; private set; }
|
public int IconCount { get; private set; }
|
||||||
public event Action<int, int> OnIconCountChanged = (a, b) => { };
|
public event Action<int, int> OnIconCountChanged = (a, b) => { };
|
||||||
|
|
||||||
@@ -57,7 +61,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
|
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
|
||||||
|
|
||||||
icon = new Animation(world, "icon");
|
icon = new Animation(world, "icon");
|
||||||
clock = new Animation(world, "clock");
|
clock = new Animation(world, ClockAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SupportPowerIcon
|
public class SupportPowerIcon
|
||||||
@@ -66,6 +70,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public float2 Pos;
|
public float2 Pos;
|
||||||
public Sprite Sprite;
|
public Sprite Sprite;
|
||||||
public PaletteReference Palette;
|
public PaletteReference Palette;
|
||||||
|
public PaletteReference IconClockPalette;
|
||||||
public Hotkey Hotkey;
|
public Hotkey Hotkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +96,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
Pos = new float2(rect.Location),
|
Pos = new float2(rect.Location),
|
||||||
Sprite = icon.Image,
|
Sprite = icon.Image,
|
||||||
Palette = worldRenderer.Palette(p.Info.IconPalette),
|
Palette = worldRenderer.Palette(p.Info.IconPalette),
|
||||||
|
IconClockPalette = worldRenderer.Palette(ClockPalette),
|
||||||
Hotkey = ks.GetSupportPowerHotkey(IconCount)
|
Hotkey = ks.GetSupportPowerHotkey(IconCount)
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -145,12 +151,12 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
|
|
||||||
// Charge progress
|
// Charge progress
|
||||||
var sp = p.Power;
|
var sp = p.Power;
|
||||||
clock.PlayFetchIndex("idle",
|
clock.PlayFetchIndex(ClockSequence,
|
||||||
() => sp.TotalTime == 0 ? clock.CurrentSequence.Length - 1 : (sp.TotalTime - sp.RemainingTime)
|
() => sp.TotalTime == 0 ? clock.CurrentSequence.Length - 1 : (sp.TotalTime - sp.RemainingTime)
|
||||||
* (clock.CurrentSequence.Length - 1) / sp.TotalTime);
|
* (clock.CurrentSequence.Length - 1) / sp.TotalTime);
|
||||||
|
|
||||||
clock.Tick();
|
clock.Tick();
|
||||||
WidgetUtils.DrawSHPCentered(clock.Image, p.Pos + iconOffset, p.Palette);
|
WidgetUtils.DrawSHPCentered(clock.Image, p.Pos + iconOffset, p.IconClockPalette);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overlay
|
// Overlay
|
||||||
|
|||||||
Reference in New Issue
Block a user