Skip to content

Commit 12f4d35

Browse files
committed
remove refs to statusAnimations for flixel > 5.9
1 parent 5215033 commit 12f4d35

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

flixel/addons/ui/FlxUITypedButton.hx

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,28 +170,39 @@ class FlxUITypedButton<T:FlxSprite> extends FlxTypedButton<T> implements IFlxUIB
170170

171171
_centerLabelOffset = FlxPoint.get(0, 0);
172172

173-
statusAnimations[3] = "normal_toggled";
174-
statusAnimations[4] = "highlight_toggled";
175-
statusAnimations[5] = "pressed_toggled";
176-
177173
labelAlphas = [for (i in 0...3) 1];
178174

179175
inputOver = new FlxInput(0);
180176
}
181-
177+
182178
override public function graphicLoaded():Void
183179
{
184180
super.graphicLoaded();
185-
186-
setupAnimation("normal_toggled", 3);
187-
setupAnimation("highlight_toggled", 4);
188-
setupAnimation("pressed_toggled", 5);
181+
182+
setupAnimation(getToggleStatusAnimation(NORMAL, 3));
183+
setupAnimation(getToggleStatusAnimation(HIGHLIGHT, #if FLX_MOUSE 4 #else 3 #end));
184+
setupAnimation(getToggleStatusAnimation(PRESSED, 5));
189185

190186
if (_autoCleanup)
191187
{
192188
cleanup();
193189
}
194190
}
191+
192+
function getToggleStatusAnimation(status:FlxButtonState)
193+
{
194+
#if (flixel <= "5.9.0")
195+
return switch(status)
196+
{
197+
case NORMAL: "normal_toggled";
198+
case PRESSED: "pressed_toggled";
199+
case HIGHLIGHT: "highlight_toggled";
200+
case DISABLED: "disabled_toggled";
201+
}
202+
#else
203+
return status.toString() + "_toggled";
204+
#end
205+
}
195206

196207
@:access(flixel.addons.ui.FlxUITypedButton)
197208
public function copyGraphic(other:FlxUITypedButton<FlxSprite>):Void
@@ -311,14 +322,11 @@ class FlxUITypedButton<T:FlxSprite> extends FlxTypedButton<T> implements IFlxUIB
311322
}
312323
}
313324

314-
/**
315-
* Offset the statusAnimations-index by 3 when toggled.
316-
*/
317-
override public function updateStatusAnimation():Void
325+
override function updateStatusAnimation():Void
318326
{
319327
if (has_toggle && toggled)
320328
{
321-
animation.play(statusAnimations[status + 3]);
329+
animation.play(getToggleStatusAnimation(status));
322330
}
323331
else
324332
{

0 commit comments

Comments
 (0)