diff --git a/assets/images/editors/ui/topmenu.png b/assets/images/editors/ui/topmenu.png new file mode 100644 index 00000000..e45f18c1 Binary files /dev/null and b/assets/images/editors/ui/topmenu.png differ diff --git a/assets/images/editors/ui/topmenu.xml b/assets/images/editors/ui/topmenu.xml new file mode 100644 index 00000000..416300cf --- /dev/null +++ b/assets/images/editors/ui/topmenu.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/buildnumber.txt b/buildnumber.txt index 43e249ec..a51f76e9 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -2611 \ No newline at end of file +2615 \ No newline at end of file diff --git a/source/funkin/editors/UIDebugState.hx b/source/funkin/editors/UIDebugState.hx index 8efc97ed..a5b2b36c 100644 --- a/source/funkin/editors/UIDebugState.hx +++ b/source/funkin/editors/UIDebugState.hx @@ -14,12 +14,45 @@ class UIDebugState extends UIState { bg.scrollFactor.set(); add(bg); - add(new UICheckbox(10, 10, "Test unchecked", false)); - add(new UICheckbox(10, 40, "Test checked", true)); - add(new UIButton(10, 70, "Test button", function() { + add(new UITopMenu([ + { + label: "Chart", + childs: [ + { + label: "New" + }, + { + label: "Open" + }, + { + label: "Save" + }, + { + label: "Save As..." + }, + null, + { + label: "Exit" + } + ] + }, + { + label: "Edit" + }, + { + label: "View" + }, + { + label: "Help" + } + ])); + + add(new UICheckbox(10, 40, "Test unchecked", false)); + add(new UICheckbox(10, 70, "Test checked", true)); + add(new UIButton(10, 100, "Test button", function() { trace("Hello, World!"); }, 130, 32)); - add(new UIButton(10, 110, "Warning test", function() { + add(new UIButton(10, 140, "Warning test", function() { openSubState(new UIWarningSubstate("Test", "This is a test message", [ { label: "Alt. Choice", @@ -35,7 +68,7 @@ class UIDebugState extends UIState { } ])); }, 130, 32)); - add(new UIButton(10, 150, "Warning test (Overflowing)", function() { + add(new UIButton(10, 180, "Warning test (Overflowing)", function() { openSubState(new UIWarningSubstate("Test", "This is a test message", [ { label: "Alt. Choice", diff --git a/source/funkin/editors/ui/UIButton.hx b/source/funkin/editors/ui/UIButton.hx index e8d52d58..8c159bd2 100644 --- a/source/funkin/editors/ui/UIButton.hx +++ b/source/funkin/editors/ui/UIButton.hx @@ -2,7 +2,7 @@ package funkin.editors.ui; import flixel.graphics.frames.FlxFrame; -class UIButton extends UISpliceSprite { +class UIButton extends UISliceSprite { public var callback:Void->Void = null; public var field:UIText; diff --git a/source/funkin/editors/ui/UIContextMenu.hx b/source/funkin/editors/ui/UIContextMenu.hx index 9ae9eeab..d692f036 100644 --- a/source/funkin/editors/ui/UIContextMenu.hx +++ b/source/funkin/editors/ui/UIContextMenu.hx @@ -6,10 +6,11 @@ class UIContextMenu extends MusicBeatSubstate { var y:Float; var contextCam:FlxCamera; - var bg:UISpliceSprite; + var bg:UISliceSprite; var callback:UIContextMenuCallback; public var contextMenuOptions:Array = []; + public var separators:Array = []; public function new(options:Array, callback:UIContextMenuCallback, x:Float, y:Float) { super(); @@ -26,11 +27,19 @@ class UIContextMenu extends MusicBeatSubstate { contextCam.alpha = 0; FlxG.cameras.add(contextCam, false); - bg = new UISpliceSprite(x, y, 100, 100, 'editors/ui/context-bg'); + bg = new UISliceSprite(x, y, 100, 100, 'editors/ui/context-bg'); add(bg); var lastY:Float = bg.y + 4; for(o in options) { + if (o == null) { + var spr = new FlxSprite(bg.x + 8, lastY + 2).makeGraphic(1, 1, -1); + spr.alpha = 0.3; + separators.push(spr); + add(spr); + lastY += 5; + continue; + } var spr = new UIContextMenuOptionSpr(bg.x + 4, lastY, o, this); lastY = spr.y + spr.bHeight; contextMenuOptions.push(spr); @@ -45,6 +54,10 @@ class UIContextMenu extends MusicBeatSubstate { for(o in contextMenuOptions) o.bWidth = maxW; + for(o in separators) { + o.scale.set(maxW - 8, 1); + o.updateHitbox(); + } bg.bWidth = maxW + 8; bg.bHeight = Std.int(lastY - bg.y + 4); } @@ -81,7 +94,7 @@ typedef UIContextMenuOption = { var ?childs:Array; } -class UIContextMenuOptionSpr extends UISpliceSprite { +class UIContextMenuOptionSpr extends UISliceSprite { public var label:UIText; public var option:UIContextMenuOption; diff --git a/source/funkin/editors/ui/UISpliceSprite.hx b/source/funkin/editors/ui/UISliceSprite.hx similarity index 99% rename from source/funkin/editors/ui/UISpliceSprite.hx rename to source/funkin/editors/ui/UISliceSprite.hx index 9c31a8f1..ec6afc27 100644 --- a/source/funkin/editors/ui/UISpliceSprite.hx +++ b/source/funkin/editors/ui/UISliceSprite.hx @@ -2,7 +2,7 @@ package funkin.editors.ui; import flixel.graphics.frames.FlxFrame; -class UISpliceSprite extends UISprite { +class UISliceSprite extends UISprite { public var bWidth:Int = 120; public var bHeight:Int = 20; public var framesOffset:Int = 0; diff --git a/source/funkin/editors/ui/UITopMenu.hx b/source/funkin/editors/ui/UITopMenu.hx new file mode 100644 index 00000000..9cb4e17e --- /dev/null +++ b/source/funkin/editors/ui/UITopMenu.hx @@ -0,0 +1,28 @@ +package funkin.editors.ui; + +import funkin.editors.ui.UIContextMenu.UIContextMenuOption; + +class UITopMenu extends UISliceSprite { + var options:Array; + public function new(options:Array) { + this.options = options; + super(0, 0, FlxG.width, 25, 'editors/ui/topmenu'); + scrollFactor.set(0, 0); + + var x:Int = 0; + for(o in options) { + var b:UIButton = null; + b = new UIButton(x, 0, o.label, function() { + UIState.state.openContextMenu(o.childs, null, b.x, b.y + b.bHeight); + }, 0, 23); + b.resize(b.field.frameWidth + 8, b.bHeight); + x += b.bWidth; + members.push(b); + } + } + + public override function update(elapsed:Float) { + super.update(elapsed); + bWidth = FlxG.width; + } +} \ No newline at end of file diff --git a/source/funkin/editors/ui/UIWarningSubstate.hx b/source/funkin/editors/ui/UIWarningSubstate.hx index b6eb1dbe..db6f185a 100644 --- a/source/funkin/editors/ui/UIWarningSubstate.hx +++ b/source/funkin/editors/ui/UIWarningSubstate.hx @@ -35,7 +35,7 @@ class UIWarningSubstate extends MusicBeatSubstate { warnCam.zoom = 0.1; FlxG.cameras.add(warnCam, false); - var spr = new UISpliceSprite(0, 0, CoolUtil.maxInt(560, 30 + (170 * buttons.length)), 280, "editors/ui/warning-popup"); + var spr = new UISliceSprite(0, 0, CoolUtil.maxInt(560, 30 + (170 * buttons.length)), 280, "editors/ui/warning-popup"); spr.x = (FlxG.width - spr.bWidth) / 2; spr.y = (FlxG.height - spr.bHeight) / 2; add(spr);