menubar progress
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 306 B |
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextureAtlas imagePath="button.png">
|
||||
<!-- Created without animate lol i wrote this-->
|
||||
<SubTexture name="topleft" x="0" y="0" width="1" height="1"/>
|
||||
<SubTexture name="top" x="1" y="0" width="94" height="1"/>
|
||||
<SubTexture name="topright" x="95" y="0" width="1" height="1"/>
|
||||
|
||||
<SubTexture name="middleleft" x="0" y="1" width="1" height="21"/>
|
||||
<SubTexture name="middle" x="1" y="1" width="94" height="21"/>
|
||||
<SubTexture name="middleright" x="95" y="1" width="1" height="21"/>
|
||||
|
||||
<SubTexture name="bottomleft" x="0" y="22" width="1" height="1"/>
|
||||
<SubTexture name="bottom" x="1" y="22" width="94" height="1"/>
|
||||
<SubTexture name="bottomright" x="95" y="22" width="1" height="1"/>
|
||||
</TextureAtlas>
|
||||
+1
-1
@@ -1 +1 @@
|
||||
2611
|
||||
2615
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<UIContextMenuOptionSpr> = [];
|
||||
public var separators:Array<FlxSprite> = [];
|
||||
|
||||
public function new(options:Array<UIContextMenuOption>, 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<UIContextMenuOption>;
|
||||
}
|
||||
|
||||
class UIContextMenuOptionSpr extends UISpliceSprite {
|
||||
class UIContextMenuOptionSpr extends UISliceSprite {
|
||||
public var label:UIText;
|
||||
public var option:UIContextMenuOption;
|
||||
|
||||
|
||||
+1
-1
@@ -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;
|
||||
@@ -0,0 +1,28 @@
|
||||
package funkin.editors.ui;
|
||||
|
||||
import funkin.editors.ui.UIContextMenu.UIContextMenuOption;
|
||||
|
||||
class UITopMenu extends UISliceSprite {
|
||||
var options:Array<UIContextMenuOption>;
|
||||
public function new(options:Array<UIContextMenuOption>) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user