package funkin.ui.debug.charting.toolboxes; import flixel.addons.display.FlxTiledSprite; import flixel.math.FlxMath; import funkin.audio.SoundGroup; import funkin.audio.waveform.WaveformDataParser; import funkin.ui.debug.charting.commands.SetFreeplayPreviewCommand; import funkin.ui.haxeui.components.WaveformPlayer; import funkin.ui.freeplay.FreeplayState; import funkin.util.tools.TimerTools; import haxe.ui.backend.flixel.components.SpriteWrapper; import haxe.ui.components.Button; import haxe.ui.components.HorizontalSlider; import haxe.ui.components.Label; import haxe.ui.components.NumberStepper; import haxe.ui.components.Slider; import haxe.ui.containers.VBox; import haxe.ui.containers.Absolute; import haxe.ui.containers.ScrollView; import haxe.ui.containers.Frame; import haxe.ui.core.Screen; import haxe.ui.events.DragEvent; import haxe.ui.events.MouseEvent; import haxe.ui.events.UIEvent; /** * The toolbox which allows modifying information like Song Title, Scroll Speed, Characters/Stages, and starting BPM. */ // @:nullSafety // TODO: Fix null safety when used with HaxeUI build macros. @:access(funkin.ui.debug.charting.ChartEditorState) @:build(haxe.ui.ComponentBuilder.build("assets/exclude/data/ui/chart-editor/toolboxes/freeplay.xml")) class ChartEditorFreeplayToolbox extends ChartEditorBaseToolbox { var waveformContainer:Absolute; var waveformScrollview:ScrollView; var waveformMusic:WaveformPlayer; var freeplayButtonZoomIn:Button; var freeplayButtonZoomOut:Button; var freeplayButtonPause:Button; var freeplayButtonPlay:Button; var freeplayButtonStop:Button; var freeplayPreviewStart:NumberStepper; var freeplayPreviewEnd:NumberStepper; var freeplayTicksContainer:Absolute; var playheadSprite:SpriteWrapper; var previewSelectionSprite:SpriteWrapper; static final TICK_LABEL_X_OFFSET:Float = 4.0; static final PLAYHEAD_RIGHT_PAD:Float = 10.0; static final BASE_SCALE:Float = 64.0; static final STARTING_SCALE:Float = 1024.0; static final MIN_SCALE:Float = 4.0; static final WAVEFORM_ZOOM_MULT:Float = 1.5; static final MAGIC_SCALE_BASE_TIME:Float = 5.0; var waveformScale:Float = STARTING_SCALE; var playheadAbsolutePos(get, set):Float; function get_playheadAbsolutePos():Float { return playheadSprite.left; } function set_playheadAbsolutePos(value:Float):Float { return playheadSprite.left = value; } var playheadRelativePos(get, set):Float; function get_playheadRelativePos():Float { return playheadSprite.left - waveformScrollview.hscrollPos; } function set_playheadRelativePos(value:Float):Float { return playheadSprite.left = waveformScrollview.hscrollPos + value; } var previewBoxStartPosAbsolute(get, set):Float; function get_previewBoxStartPosAbsolute():Float { return previewSelectionSprite.left; } function set_previewBoxStartPosAbsolute(value:Float):Float { return previewSelectionSprite.left = value; } var previewBoxEndPosAbsolute(get, set):Float; function get_previewBoxEndPosAbsolute():Float { return previewSelectionSprite.left + previewSelectionSprite.width; } function set_previewBoxEndPosAbsolute(value:Float):Float { if (value < previewBoxStartPosAbsolute) return previewSelectionSprite.left = previewBoxStartPosAbsolute; return previewSelectionSprite.width = value - previewBoxStartPosAbsolute; } var previewBoxStartPosRelative(get, set):Float; function get_previewBoxStartPosRelative():Float { return previewSelectionSprite.left - waveformScrollview.hscrollPos; } function set_previewBoxStartPosRelative(value:Float):Float { return previewSelectionSprite.left = waveformScrollview.hscrollPos + value; } var previewBoxEndPosRelative(get, set):Float; function get_previewBoxEndPosRelative():Float { return previewSelectionSprite.left + previewSelectionSprite.width - waveformScrollview.hscrollPos; } function set_previewBoxEndPosRelative(value:Float):Float { if (value < previewBoxStartPosRelative) return previewSelectionSprite.left = previewBoxStartPosRelative; return previewSelectionSprite.width = value - previewBoxStartPosRelative; } /** * The amount you need to multiply the zoom by such that, at the base zoom level, one tick is equal to `MAGIC_SCALE_BASE_TIME` seconds. */ var waveformMagicFactor:Float = 1.0; var audioPreviewTracks:SoundGroup; var tickTiledSprite:FlxTiledSprite; var freeplayPreviewVolume(get, null):Float; function get_freeplayPreviewVolume():Float { return freeplayMusicVolume.value * 2 / 100; } var tickLabels:Array