SCROLLABLE EVENTS SCREEN !!!
This commit is contained in:
@@ -5,6 +5,11 @@ import funkin.backend.chart.EventsData;
|
||||
class CharterEventTypeSelection extends UISubstateWindow {
|
||||
var callback:String->Void;
|
||||
|
||||
var buttons:Array<UIButton> = [];
|
||||
|
||||
var buttonsBG:UISliceSprite;
|
||||
var buttonCameras:FlxCamera;
|
||||
|
||||
public function new(callback:String->Void) {
|
||||
super();
|
||||
this.callback = callback;
|
||||
@@ -13,15 +18,24 @@ class CharterEventTypeSelection extends UISubstateWindow {
|
||||
public override function create() {
|
||||
winTitle = "Choose an event type...";
|
||||
super.create();
|
||||
|
||||
var w:Int = winWidth - 20;
|
||||
var lastIndex:Int = 0;
|
||||
|
||||
buttonCameras = new FlxCamera(Std.int(windowSpr.x+41), Std.int(windowSpr.y), w, (32 * 16));
|
||||
FlxG.cameras.add(buttonCameras, false);
|
||||
buttonCameras.bgColor = 0;
|
||||
|
||||
buttonsBG = new UIWindow(10, 41, buttonCameras.width, buttonCameras.height, "");
|
||||
buttonsBG.frames = Paths.getFrames('editors/ui/inputbox');
|
||||
add(buttonsBG);
|
||||
|
||||
for(k=>eventName in EventsData.eventsList) {
|
||||
var button = new UIButton(10, 41 + (32 * k), eventName, function() {
|
||||
var button = new UIButton(0, (32 * k), eventName, function() {
|
||||
close();
|
||||
callback(eventName);
|
||||
}, w);
|
||||
add(button);
|
||||
button.cameras = [buttonCameras];
|
||||
buttons.push(cast add(button));
|
||||
|
||||
var icon = CharterEvent.generateEventIcon({
|
||||
name: eventName,
|
||||
@@ -30,17 +44,38 @@ class CharterEventTypeSelection extends UISubstateWindow {
|
||||
});
|
||||
icon.setGraphicSize(20, 20); // Std.int(button.bHeight - 12)
|
||||
icon.updateHitbox();
|
||||
icon.cameras = [buttonCameras];
|
||||
icon.x = button.x + 8;
|
||||
icon.y = button.y + Math.abs(button.bHeight - icon.height) / 2;
|
||||
add(icon);
|
||||
|
||||
lastIndex = k;
|
||||
}
|
||||
|
||||
add(new UIButton(10, 51 + (32 * (lastIndex+1)), "Cancel", function() {
|
||||
windowSpr.bHeight = 61 + (32 * (17));
|
||||
|
||||
add(new UIButton(10, windowSpr.bHeight-42, "Cancel", function() {
|
||||
close();
|
||||
}, w));
|
||||
|
||||
windowSpr.bHeight = 61 + (32 * (lastIndex+2));
|
||||
}
|
||||
|
||||
override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
buttonCameras.zoom = subCam.zoom;
|
||||
|
||||
buttonCameras.x = -subCam.scroll.x + Std.int(windowSpr.x+10);
|
||||
buttonCameras.y = -subCam.scroll.y + Std.int(windowSpr.y+41);
|
||||
|
||||
buttonCameras.scroll.y = FlxMath.bound(buttonCameras.scroll.y - (buttonsBG.hovered ? FlxG.mouse.wheel : 0) * 12, 0,
|
||||
(buttons[buttons.length-1].y + buttons[buttons.length-1].bHeight) - buttonCameras.height);
|
||||
}
|
||||
|
||||
override function destroy() {
|
||||
super.destroy();
|
||||
|
||||
if(buttonCameras != null) {
|
||||
if (FlxG.cameras.list.contains(buttonCameras))
|
||||
FlxG.cameras.remove(buttonCameras);
|
||||
buttonCameras = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user