From 9ffea799c76e68040ea2e2356c63524fcf76c575 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Fri, 23 Dec 2022 03:50:41 +0100 Subject: [PATCH] working on the context menu --- source/funkin/desktop/windows/ContextMenu.hx | 51 ++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 source/funkin/desktop/windows/ContextMenu.hx diff --git a/source/funkin/desktop/windows/ContextMenu.hx b/source/funkin/desktop/windows/ContextMenu.hx new file mode 100644 index 00000000..d66fb7ef --- /dev/null +++ b/source/funkin/desktop/windows/ContextMenu.hx @@ -0,0 +1,51 @@ +package funkin.desktop.windows; + +import flixel.FlxSprite; +import funkin.desktop.sprites.*; +import flixel.FlxObject; +import flixel.FlxG; + +class ContextMenu extends WindowGroup { + public var bg:SpliceSprite; + public var texts:Array = []; + public var selectionBGs:Array = []; + + public override function new(x:Float, y:Float, options:Array, callback:Int->Void) { + super(); + + var bgTheme = DesktopMain.theme.contextBackground; + var optionTheme = DesktopMain.theme.contextOption; + + bg = new SpliceSprite(Paths.image(bgTheme.sprite), 0, 0, 75, 24, bgTheme.left, bgTheme.top, bgTheme.bottom, bgTheme.right); + add(bg); + + var lastOption:FlxSprite = null; + var w:Float = 80; + for(k=>o in options) { + var selectSpr = new FlxSprite(bgTheme.left, bgTheme.top + (k * optionTheme.height)); + selectSpr.loadGraphic(Paths.image(bgTheme.sprite)); + selectSpr.setGraphicSize(10, Std.int(optionTheme.height)); + selectionBGs.push(selectSpr); + add(selectSpr); + + var text = new WindowText(4, 4, 0, o.name); + text.y = selectSpr.y + ((selectSpr.height - text.height) / 2); + texts.push(text); + add(text); + if (w < text.width) + w = text.width; + } + } + + public override function destroy() { + super.destroy(); + FlxG.cameras.remove(camera, true); + } +} + +typedef ContextOption = { + var name:String; + @:optional var callback:Void->Void; + @:optional var iconPath:String; + @:optional var iconId:Int; +} \ No newline at end of file