2024-07-01 11:42:50 +00:00
|
|
|
package funkin.ui.options.items;
|
|
|
|
|
|
|
|
import flixel.FlxSprite.FlxSprite;
|
|
|
|
|
|
|
|
class CheckboxPreferenceItem extends FlxSprite
|
|
|
|
{
|
|
|
|
public var currentValue(default, set):Bool;
|
|
|
|
|
2025-05-04 12:33:30 +00:00
|
|
|
public function new(x:Float, y:Float, defaultValue:Bool = false, available:Bool = true)
|
2024-07-01 11:42:50 +00:00
|
|
|
{
|
|
|
|
super(x, y);
|
|
|
|
|
|
|
|
frames = Paths.getSparrowAtlas('checkboxThingie');
|
|
|
|
animation.addByPrefix('static', 'Check Box unselected', 24, false);
|
|
|
|
animation.addByPrefix('checked', 'Check Box selecting animation', 24, false);
|
|
|
|
|
|
|
|
setGraphicSize(Std.int(width * 0.7));
|
|
|
|
updateHitbox();
|
|
|
|
|
2025-05-04 12:33:30 +00:00
|
|
|
if (!available) this.alpha = 0.5;
|
|
|
|
|
2024-07-01 11:42:50 +00:00
|
|
|
this.currentValue = defaultValue;
|
|
|
|
}
|
|
|
|
|
2025-03-21 22:56:11 +00:00
|
|
|
override function update(elapsed:Float):Void
|
2024-07-01 11:42:50 +00:00
|
|
|
{
|
|
|
|
super.update(elapsed);
|
|
|
|
|
|
|
|
switch (animation.curAnim.name)
|
|
|
|
{
|
|
|
|
case 'static':
|
|
|
|
offset.set();
|
|
|
|
case 'checked':
|
|
|
|
offset.set(17, 70);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_currentValue(value:Bool):Bool
|
|
|
|
{
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
animation.play('checked', true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
animation.play('static');
|
|
|
|
}
|
|
|
|
|
|
|
|
return currentValue = value;
|
|
|
|
}
|
|
|
|
}
|