Blink the color picker palette tab when the Store button is pressed.

This provides some visual feedback that something
has happened on the hidden tab.
This commit is contained in:
Paul Chote
2018-06-01 17:15:41 +00:00
committed by reaperrr
parent 2cf3c4873d
commit 55d3040a0e

View File

@@ -24,6 +24,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
public class ColorPickerLogic : ChromeLogic public class ColorPickerLogic : ChromeLogic
{ {
static bool paletteTabOpenedLast; static bool paletteTabOpenedLast;
int paletteTabHighlighted = 0;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ColorPickerLogic(Widget widget, ModData modData, World world, HSLColor initialColor, Action<HSLColor> onChange, Dictionary<string, MiniYaml> logicArgs) public ColorPickerLogic(Widget widget, ModData modData, World world, HSLColor initialColor, Action<HSLColor> onChange, Dictionary<string, MiniYaml> logicArgs)
@@ -91,7 +92,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
paletteTab.IsVisible = () => paletteTabOpenedLast; paletteTab.IsVisible = () => paletteTabOpenedLast;
paletteTabButton.OnClick = () => paletteTabOpenedLast = true; paletteTabButton.OnClick = () => paletteTabOpenedLast = true;
paletteTabButton.IsHighlighted = paletteTab.IsVisible; paletteTabButton.IsHighlighted = () => paletteTab.IsVisible() || paletteTabHighlighted > 0;
var paletteCols = 8; var paletteCols = 8;
var palettePresetRows = 2; var palettePresetRows = 2;
@@ -172,6 +173,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
.Reverse().Take(paletteCustomRows * paletteCols).Reverse() .Reverse().Take(paletteCustomRows * paletteCols).Reverse()
.ToArray(); .ToArray();
Game.Settings.Save(); Game.Settings.Save();
// Flash the palette tab to show players that something has happened
if (!paletteTabOpenedLast)
paletteTabHighlighted = 4;
}; };
} }
} }
@@ -196,5 +201,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
color.AttachPanel(colorChooser, onExit); color.AttachPanel(colorChooser, onExit);
} }
public override void Tick()
{
if (paletteTabHighlighted > 0)
paletteTabHighlighted--;
}
} }
} }