Merge pull request #9129 from Mailaender/ts-build-palette

Fixed black dots on Tiberian Sun build palette icons
This commit is contained in:
reaperrr
2015-08-24 17:46:02 +02:00
5 changed files with 47 additions and 9 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -14,6 +14,7 @@ Container@PLAYER_WIDGETS:
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER
ReadyText: READY ReadyText: READY
HoldText: ON HOLD HoldText: ON HOLD
ClockPalette: iconclock
Container@PALETTE_FOREGROUND: Container@PALETTE_FOREGROUND:
Children: Children:
Image@ICON_TEMPLATE: Image@ICON_TEMPLATE:
@@ -254,6 +255,9 @@ Container@PLAYER_WIDGETS:
TooltipContainer: TOOLTIP_CONTAINER TooltipContainer: TOOLTIP_CONTAINER
ReadyText: READY ReadyText: READY
HoldText: ON HOLD HoldText: ON HOLD
ClockPalette: iconclock
NotBuildableAnimation: darken
NotBuildablePalette: chromewithshadow
IconSize: 64, 48 IconSize: 64, 48
IconMargin: 3, 4 IconMargin: 3, 4
IconSpriteOffset: 0, 0 IconSpriteOffset: 0, 0

View File

@@ -24,6 +24,10 @@
Name: chrome Name: chrome
Filename: cameo.pal Filename: cameo.pal
AllowModifiers: false AllowModifiers: false
PaletteFromFile@chromewithshadow:
Name: chromewithshadow
Filename: cameo.pal
AllowModifiers: false
ShadowIndex: 242 ShadowIndex: 242
PaletteFromFile@pips: PaletteFromFile@pips:
Name: pips Name: pips
@@ -37,6 +41,14 @@
PaletteFromFile@effect: PaletteFromFile@effect:
Name: effect Name: effect
Filename: anim.pal Filename: anim.pal
PaletteFromFile@sidebar:
Name: sidebar
Filename: sidec02.mix:sidebar.pal
PaletteFromPaletteWithAlpha@clock:
Name: iconclock
BasePalette: sidebar
Alpha: 0.5
AllowModifiers: false
PaletteFromFile@colorpicker: PaletteFromFile@colorpicker:
Name: colorpicker Name: colorpicker
Filename: unittem.pal Filename: unittem.pal

View File

@@ -67,6 +67,10 @@ clock:
idle: gclock2 idle: gclock2
Length: * Length: *
darken:
idle: gclock2
Length: 1
pips: pips:
medic: medic:
Start: 6 Start: 6