diff --git a/assets/shaders/editorBlur.frag b/assets/shaders/editorBlur.frag index 929c65cf..212f465c 100644 --- a/assets/shaders/editorBlur.frag +++ b/assets/shaders/editorBlur.frag @@ -20,6 +20,6 @@ void main() { } } */ - color /= steps * stepsInside * 1.25; + color /= steps * stepsInside; gl_FragColor = color; } \ No newline at end of file diff --git a/buildnumber.txt b/buildnumber.txt index c223971b..d85c25f9 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -2536 \ No newline at end of file +2547 \ No newline at end of file diff --git a/source/funkin/editors/UIDebugState.hx b/source/funkin/editors/UIDebugState.hx index cd2377e9..def210a0 100644 --- a/source/funkin/editors/UIDebugState.hx +++ b/source/funkin/editors/UIDebugState.hx @@ -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)); } } \ No newline at end of file diff --git a/source/funkin/editors/ui/UIButton.hx b/source/funkin/editors/ui/UIButton.hx index 2bc140ef..996fc579 100644 --- a/source/funkin/editors/ui/UIButton.hx +++ b/source/funkin/editors/ui/UIButton.hx @@ -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(); } } \ No newline at end of file diff --git a/source/funkin/editors/ui/UISprite.hx b/source/funkin/editors/ui/UISprite.hx index 718cee9a..0397343c 100644 --- a/source/funkin/editors/ui/UISprite.hx +++ b/source/funkin/editors/ui/UISprite.hx @@ -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 = []; diff --git a/source/funkin/editors/ui/UIState.hx b/source/funkin/editors/ui/UIState.hx index ffb1112f..999cce26 100644 --- a/source/funkin/editors/ui/UIState.hx +++ b/source/funkin/editors/ui/UIState.hx @@ -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(); diff --git a/source/funkin/editors/ui/UIUtil.hx b/source/funkin/editors/ui/UIUtil.hx index 6b749b05..764bb30f 100644 --- a/source/funkin/editors/ui/UIUtil.hx +++ b/source/funkin/editors/ui/UIUtil.hx @@ -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); } diff --git a/source/funkin/editors/ui/UIWarningSubstate.hx b/source/funkin/editors/ui/UIWarningSubstate.hx index 38d5e609..6ceb1b54 100644 --- a/source/funkin/editors/ui/UIWarningSubstate.hx +++ b/source/funkin/editors/ui/UIWarningSubstate.hx @@ -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) { diff --git a/source/funkin/utils/CoolUtil.hx b/source/funkin/utils/CoolUtil.hx index 7ed4c2a2..2ca555a6 100644 --- a/source/funkin/utils/CoolUtil.hx +++ b/source/funkin/utils/CoolUtil.hx @@ -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 {