1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-27 15:37:49 +00:00

proper dialog fading

This commit is contained in:
Cameron Taylor 2023-12-13 18:24:55 -05:00
parent 028e90474c
commit 4193cd4ee2
4 changed files with 28 additions and 15 deletions

View file

@ -49,14 +49,14 @@
"name": "haxeui-core", "name": "haxeui-core",
"type": "git", "type": "git",
"dir": null, "dir": null,
"ref": "5d4ac180f85b39e72624f4b8d17925d91ebe4278", "ref": "032192e849cdb7d1070c0a3241c58ee555ffaccc",
"url": "https://github.com/haxeui/haxeui-core" "url": "https://github.com/haxeui/haxeui-core"
}, },
{ {
"name": "haxeui-flixel", "name": "haxeui-flixel",
"type": "git", "type": "git",
"dir": null, "dir": null,
"ref": "89a4cf621e5c204922f7a12fbde5d1d84f8b47f5", "ref": "d90758b229d05206400df867d333c79d9fdbd478",
"url": "https://github.com/haxeui/haxeui-flixel" "url": "https://github.com/haxeui/haxeui-flixel"
}, },
{ {

View file

@ -2643,7 +2643,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
* Open the backups folder in the file explorer. * Open the backups folder in the file explorer.
* Don't call this on HTML5. * Don't call this on HTML5.
*/ */
function openBackupsFolder():Void function openBackupsFolder(?_):Void
{ {
#if sys #if sys
// TODO: Is there a way to open a folder and highlight a file in it? // TODO: Is there a way to open a folder and highlight a file in it?

View file

@ -29,6 +29,12 @@ class ChartEditorBaseDialog extends Dialog
this.onDialogClosed = event -> onClose(event); this.onDialogClosed = event -> onClose(event);
} }
public override function showDialog(modal:Bool = true):Void
{
super.showDialog(modal);
fadeInComponent(this, 1);
}
private override function onReady():Void private override function onReady():Void
{ {
_overlay.opacity = 0; _overlay.opacity = 0;
@ -65,8 +71,8 @@ class ChartEditorBaseDialog extends Dialog
this.closable = params.closable ?? false; this.closable = params.closable ?? false;
} }
static final OVERLAY_EASE_DURATION:Float = 5.0; static final OVERLAY_EASE_DURATION:Float = 0.2;
static final OVERLAY_EASE_TYPE:String = "linear"; static final OVERLAY_EASE_TYPE:String = "easeOut";
function fadeInDialogOverlay():Void function fadeInDialogOverlay():Void
{ {
@ -82,11 +88,16 @@ class ChartEditorBaseDialog extends Dialog
return; return;
} }
var builder = new AnimationBuilder(_overlay, OVERLAY_EASE_DURATION, "linear"); fadeInComponent(_overlay, 0.5);
builder.setPosition(0, "opacity", 0, true); // 0% absolute }
builder.setPosition(100, "opacity", 1, true);
trace('Fading in dialog overlay...'); function fadeInComponent(component:Component, fadeTo:Float = 1):Void
{
var builder = new AnimationBuilder(component, OVERLAY_EASE_DURATION, OVERLAY_EASE_TYPE);
builder.setPosition(0, "opacity", 0, true); // 0% absolute
builder.setPosition(100, "opacity", fadeTo, true);
trace('Fading in dialog component...');
builder.play(); builder.play();
} }
} }

View file

@ -5,6 +5,7 @@ import haxe.ui.containers.HBox;
import haxe.ui.notifications.Notification; import haxe.ui.notifications.Notification;
import haxe.ui.notifications.NotificationManager; import haxe.ui.notifications.NotificationManager;
import haxe.ui.notifications.NotificationType; import haxe.ui.notifications.NotificationType;
import haxe.ui.notifications.NotificationData.NotificationActionData;
class ChartEditorNotificationHandler class ChartEditorNotificationHandler
{ {
@ -77,7 +78,7 @@ class ChartEditorNotificationHandler
* @param actions The actions to add to the notification. * @param actions The actions to add to the notification.
* @return The notification that was sent. * @return The notification that was sent.
*/ */
public static function infoWithActions(state:ChartEditorState, title:String, body:String, actions:Array<NotificationAction>):Notification public static function infoWithActions(state:ChartEditorState, title:String, body:String, actions:Array<NotificationActionData>):Notification
{ {
return sendNotification(state, title, body, NotificationType.Info, actions); return sendNotification(state, title, body, NotificationType.Info, actions);
} }
@ -101,7 +102,8 @@ class ChartEditorNotificationHandler
NotificationManager.instance.removeNotification(notif); NotificationManager.instance.removeNotification(notif);
} }
static function sendNotification(state:ChartEditorState, title:String, body:String, ?type:NotificationType, ?actions:Array<NotificationAction>):Notification static function sendNotification(state:ChartEditorState, title:String, body:String, ?type:NotificationType,
?actions:Array<NotificationActionData>):Notification
{ {
var actionNames:Array<String> = actions == null ? [] : actions.map(action -> action.text); var actionNames:Array<String> = actions == null ? [] : actions.map(action -> action.text);
@ -111,10 +113,10 @@ class ChartEditorNotificationHandler
body: body, body: body,
type: type ?? NotificationType.Default, type: type ?? NotificationType.Default,
expiryMs: Constants.NOTIFICATION_DISMISS_TIME, expiryMs: Constants.NOTIFICATION_DISMISS_TIME,
actions: actionNames actions: actions
}); });
if (actionNames.length > 0) if (actions != null && actions.length > 0)
{ {
// TODO: Tell Ian that this is REALLY dumb. // TODO: Tell Ian that this is REALLY dumb.
var actionsContainer:HBox = notif.findComponent('actionsContainer', HBox); var actionsContainer:HBox = notif.findComponent('actionsContainer', HBox);
@ -122,13 +124,13 @@ class ChartEditorNotificationHandler
if (Std.isOfType(component, Button)) if (Std.isOfType(component, Button))
{ {
var button:Button = cast component; var button:Button = cast component;
var action:Null<NotificationAction> = actions.find(action -> action.text == button.text); var action:Null<NotificationActionData> = actions.find(action -> action.text == button.text);
if (action != null && action.callback != null) if (action != null && action.callback != null)
{ {
button.onClick = function(_) { button.onClick = function(_) {
// Don't allow actions to be clicked while the playtest is open. // Don't allow actions to be clicked while the playtest is open.
if (state.subState != null) return; if (state.subState != null) return;
action.callback(); action.callback(action);
}; };
} }
} }