buttons!
This commit is contained in:
@@ -20,6 +20,6 @@ void main() {
|
||||
}
|
||||
}
|
||||
*/
|
||||
color /= steps * stepsInside * 1.25;
|
||||
color /= steps * stepsInside;
|
||||
gl_FragColor = color;
|
||||
}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
2536
|
||||
2547
|
||||
@@ -21,7 +21,7 @@ class UIDebugState extends UIState {
|
||||
{
|
||||
label: "Alt. Choice",
|
||||
onClick: function(t) {
|
||||
|
||||
trace("Alt. Choice clicked!");
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -32,5 +32,51 @@ class UIDebugState extends UIState {
|
||||
}
|
||||
]));
|
||||
}, 120, 32));
|
||||
add(new UIButton(10, 150, "Warning test (Overflowing)", function() {
|
||||
openSubState(new UIWarningSubstate("Test", "This is a test message", [
|
||||
{
|
||||
label: "Alt. Choice",
|
||||
onClick: function(t) {
|
||||
trace("Alt. Choice clicked!");
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "OK",
|
||||
onClick: function(t) {}
|
||||
},
|
||||
{
|
||||
label: "1",
|
||||
onClick: function(t) {}
|
||||
},
|
||||
{
|
||||
label: "2",
|
||||
onClick: function(t) {}
|
||||
},
|
||||
{
|
||||
label: "3",
|
||||
onClick: function(t) {}
|
||||
},
|
||||
{
|
||||
label: "4",
|
||||
onClick: function(t) {}
|
||||
},
|
||||
{
|
||||
label: "5",
|
||||
onClick: function(t) {}
|
||||
},
|
||||
{
|
||||
label: "6",
|
||||
onClick: function(t) {}
|
||||
},
|
||||
{
|
||||
label: "7",
|
||||
onClick: function(t) {}
|
||||
},
|
||||
{
|
||||
label: "8",
|
||||
onClick: function(t) {}
|
||||
}
|
||||
]));
|
||||
}, 120, 64));
|
||||
}
|
||||
}
|
||||
@@ -30,9 +30,13 @@ class UIButton extends UISpliceSprite {
|
||||
callback();
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
field.follow(this, 0, (bHeight - field.height) / 2);
|
||||
}
|
||||
|
||||
public override function draw() {
|
||||
framesOffset = hovered ? (pressed ? 18 : 9) : 0;
|
||||
field.follow(this, x, (bHeight - field.height) / 2);
|
||||
super.draw();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import flixel.util.FlxDestroyUtil;
|
||||
import flixel.math.FlxRect;
|
||||
|
||||
@:allow(funkin.editors.ui.UIState)
|
||||
@:allow(funkin.editors.ui.UIUtil)
|
||||
class UISprite extends FlxSprite {
|
||||
public var members:Array<FlxBasic> = [];
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ class UIState extends MusicBeatState {
|
||||
}
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
public override function tryUpdate(elapsed:Float) {
|
||||
super.tryUpdate(elapsed);
|
||||
|
||||
if (buttonHandler != null) {
|
||||
buttonHandler();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package funkin.editors.ui;
|
||||
|
||||
class UIUtil {
|
||||
public static inline function follow(spr:FlxSprite, target:FlxSprite, x:Float = 0, y:Float = 0) {
|
||||
spr.cameras = target.cameras;
|
||||
public static function follow(spr:FlxSprite, target:FlxSprite, x:Float = 0, y:Float = 0) {
|
||||
spr.cameras = target is UISprite ? cast(target, UISprite).__lastDrawCameras : target.cameras;
|
||||
spr.setPosition(target.x + x, target.y + y);
|
||||
spr.scrollFactor.set(target.scrollFactor.x, target.scrollFactor.y);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ class UIWarningSubstate extends MusicBeatSubstate {
|
||||
var titleSpr:UIText;
|
||||
var messageSpr:UIText;
|
||||
|
||||
var warnCam:FlxCamera;
|
||||
|
||||
public override function onSubstateOpen() {
|
||||
super.onSubstateOpen();
|
||||
parent.persistentUpdate = false;
|
||||
@@ -27,13 +29,13 @@ class UIWarningSubstate extends MusicBeatSubstate {
|
||||
c.addShader(blurShader);
|
||||
}
|
||||
|
||||
camera = new FlxCamera();
|
||||
camera.bgColor = 0;
|
||||
camera.alpha = 0;
|
||||
camera.zoom = 0.1;
|
||||
FlxG.cameras.add(camera, false);
|
||||
camera = warnCam = new FlxCamera();
|
||||
warnCam.bgColor = 0;
|
||||
warnCam.alpha = 0;
|
||||
warnCam.zoom = 0.1;
|
||||
FlxG.cameras.add(warnCam, false);
|
||||
|
||||
var spr = new UISpliceSprite(0, 0, 560, 280, "editors/ui/warning-popup");
|
||||
var spr = new UISpliceSprite(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);
|
||||
@@ -44,6 +46,15 @@ class UIWarningSubstate extends MusicBeatSubstate {
|
||||
|
||||
add(messageSpr = new UIText(spr.x + 10, spr.y + 40, spr.bWidth - 20, message, 15, 0xFF000000));
|
||||
|
||||
var xPos = (FlxG.width - (30 + (170 * buttons.length))) / 2;
|
||||
for(k=>b in buttons) {
|
||||
var button = new UIButton(xPos + 20 + (170 * k), spr.y + spr.bHeight - 40, b.label, function() {
|
||||
b.onClick(this);
|
||||
close();
|
||||
}, 160, 30);
|
||||
add(button);
|
||||
}
|
||||
|
||||
FlxTween.tween(camera, {alpha: 1}, 0.25, {ease: FlxEase.cubeOut});
|
||||
FlxTween.tween(camera, {zoom: 1}, 0.66, {ease: FlxEase.elasticOut});
|
||||
|
||||
@@ -55,7 +66,7 @@ class UIWarningSubstate extends MusicBeatSubstate {
|
||||
for(e in camShaders)
|
||||
e.removeShader(blurShader);
|
||||
|
||||
FlxG.cameras.remove(camera);
|
||||
FlxG.cameras.remove(warnCam);
|
||||
}
|
||||
|
||||
public function new(title:String, message:String, buttons:Array<WarningButton>) {
|
||||
|
||||
@@ -410,6 +410,9 @@ class CoolUtil
|
||||
FlxG.openURL(url);
|
||||
#end
|
||||
}
|
||||
|
||||
public static inline function maxInt(p1:Int, p2:Int)
|
||||
return p1 < p2 ? p2 : p1;
|
||||
}
|
||||
|
||||
enum abstract CoolSfx(Int) from Int {
|
||||
|
||||
Reference in New Issue
Block a user