2023-05-17 02:09:53 +00:00
|
|
|
package funkin.ui.story;
|
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
|
|
|
import flixel.graphics.frames.FlxAtlasFrames;
|
|
|
|
import flixel.group.FlxSpriteGroup;
|
2023-05-17 20:42:58 +00:00
|
|
|
import flixel.util.FlxColor;
|
2023-11-07 09:04:22 +00:00
|
|
|
import funkin.util.MathUtil;
|
2023-05-17 02:09:53 +00:00
|
|
|
|
|
|
|
class LevelTitle extends FlxSpriteGroup
|
|
|
|
{
|
|
|
|
static final LOCK_PAD:Int = 4;
|
|
|
|
|
|
|
|
public final level:Level;
|
|
|
|
|
|
|
|
public var targetY:Float;
|
|
|
|
|
|
|
|
var title:FlxSprite;
|
|
|
|
var lock:FlxSprite;
|
|
|
|
|
|
|
|
public function new(x:Int, y:Int, level:Level)
|
|
|
|
{
|
|
|
|
super(x, y);
|
|
|
|
|
|
|
|
this.level = level;
|
|
|
|
|
2023-05-17 20:42:58 +00:00
|
|
|
if (this.level == null) throw "Level cannot be null!";
|
2023-05-17 02:09:53 +00:00
|
|
|
|
|
|
|
buildLevelTitle();
|
|
|
|
buildLevelLock();
|
|
|
|
}
|
|
|
|
|
2023-05-17 20:42:58 +00:00
|
|
|
override function get_width():Float
|
|
|
|
{
|
|
|
|
if (length == 0) return 0;
|
|
|
|
|
|
|
|
if (lock.visible)
|
|
|
|
{
|
|
|
|
return title.width + lock.width + LOCK_PAD;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return title.width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-13 18:23:16 +00:00
|
|
|
public var isFlashing:Bool = false;
|
|
|
|
var flashTick:Float = 0;
|
|
|
|
final flashFramerate:Float = 20;
|
2023-05-17 02:09:53 +00:00
|
|
|
|
|
|
|
public override function update(elapsed:Float):Void
|
|
|
|
{
|
2023-11-07 09:04:22 +00:00
|
|
|
this.y = MathUtil.coolLerp(y, targetY, 0.17);
|
2023-05-17 02:09:53 +00:00
|
|
|
|
2024-05-13 18:23:16 +00:00
|
|
|
if (isFlashing)
|
|
|
|
{
|
|
|
|
flashTick += elapsed;
|
|
|
|
if (flashTick >= 1 / flashFramerate)
|
|
|
|
{
|
|
|
|
flashTick %= 1 / flashFramerate;
|
|
|
|
title.color = (title.color == FlxColor.WHITE) ? 0xFF33ffff : FlxColor.WHITE;
|
|
|
|
}
|
|
|
|
}
|
2023-05-17 02:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function showLock():Void
|
|
|
|
{
|
|
|
|
lock.visible = true;
|
|
|
|
this.x -= (lock.width + LOCK_PAD) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hideLock():Void
|
|
|
|
{
|
|
|
|
lock.visible = false;
|
|
|
|
this.x += (lock.width + LOCK_PAD) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
function buildLevelTitle():Void
|
|
|
|
{
|
|
|
|
title = level.buildTitleGraphic();
|
|
|
|
add(title);
|
|
|
|
}
|
|
|
|
|
|
|
|
function buildLevelLock():Void
|
|
|
|
{
|
|
|
|
lock = new FlxSprite(0, 0).loadGraphic(Paths.image('storymenu/ui/lock'));
|
|
|
|
lock.x = title.x + title.width + LOCK_PAD;
|
|
|
|
lock.visible = false;
|
|
|
|
add(lock);
|
|
|
|
}
|
|
|
|
}
|