From 3e2c0a0ed159dcad075189367e9a7cc1829c1463 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Sun, 19 Mar 2023 14:28:32 +0100 Subject: [PATCH] menubar progress --- assets/images/editors/ui/topmenu.png | Bin 0 -> 306 bytes assets/images/editors/ui/topmenu.xml | 15 ++++++ buildnumber.txt | 2 +- source/funkin/editors/UIDebugState.hx | 43 ++++++++++++++++-- source/funkin/editors/ui/UIButton.hx | 2 +- source/funkin/editors/ui/UIContextMenu.hx | 19 ++++++-- .../{UISpliceSprite.hx => UISliceSprite.hx} | 2 +- source/funkin/editors/ui/UITopMenu.hx | 28 ++++++++++++ source/funkin/editors/ui/UIWarningSubstate.hx | 2 +- 9 files changed, 101 insertions(+), 12 deletions(-) create mode 100644 assets/images/editors/ui/topmenu.png create mode 100644 assets/images/editors/ui/topmenu.xml rename source/funkin/editors/ui/{UISpliceSprite.hx => UISliceSprite.hx} (99%) create mode 100644 source/funkin/editors/ui/UITopMenu.hx diff --git a/assets/images/editors/ui/topmenu.png b/assets/images/editors/ui/topmenu.png new file mode 100644 index 0000000000000000000000000000000000000000..e45f18c115e12e8614cbf1142af0dd1aff6e2c88 GIT binary patch literal 306 zcmeAS@N?(olHy`uVBq!ia0vp^2|z5)!3HG1?Duj6Qk(@Ik;M!Qe1}1p@p%4<6rkV} zPZ!6Kid%0d9^^e_AmaSlnBRK?qqYHuvqIW~a}hd?K>__5Pj3n}HQ!fFu-_UOd;IXz zxW!wuv|p{X`Xb3|clhuAspn&^Du%En%zP|h#BfHYeF9^`Gm91;2IJ$3DGW0#`4pKC zoGIjxWJv3CKEYs6EaSx108<+9`|itJhELUH=j`6SNxqyoWnRhrKWlqRrtm0OZCRYc zaB-omDsu^VM!ucr?TM**>Aut{ct)`j^4e)z4*}Q$iB}v + + + + + + + + + + + + + + \ 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);