Update HaxeUI cursor handling, and remove Funkin components

This commit is contained in:
EliteMasterEric 2023-10-31 14:43:01 -04:00
parent b2dd58b904
commit 73107dbc07
19 changed files with 66 additions and 360 deletions

2
assets

@ -1 +1 @@
Subproject commit 6b6f2462afb099a7301a782ae521a0175fb7c71b
Subproject commit 3f8299aba4e308a6c86ce8f499b697de04909ad2

View file

@ -49,14 +49,14 @@
"name": "haxeui-core",
"type": "git",
"dir": null,
"ref": "e92d5cfac847943fac84696b103670d55c2c774f",
"ref": "815e94dd5aa6cf09c5ddcef1666a54449ffde8dc",
"url": "https://github.com/haxeui/haxeui-core"
},
{
"name": "haxeui-flixel",
"type": "git",
"dir": null,
"ref": "be0b18553189a55fd42821026618a18615b070e3",
"ref": "bc706d67efc093cd3b1623d0e9d599b326bbd330",
"url": "https://github.com/haxeui/haxeui-flixel"
},
{

View file

@ -110,5 +110,6 @@ class Main extends Sprite
Toolkit.init();
Toolkit.theme = 'dark'; // don't be cringe
Toolkit.autoScale = false;
funkin.input.Cursor.registerHaxeUICursors();
}
}

View file

@ -5,6 +5,7 @@ import flixel.util.FlxSignal;
import flixel.math.FlxMath;
import funkin.play.song.Song.SongDifficulty;
import funkin.data.song.SongData.SongTimeChange;
import funkin.data.song.SongDataUtils;
/**
* A core class which handles musical timing throughout the game,
@ -257,6 +258,9 @@ class Conductor
{
timeChanges = [];
// Sort in place just in case it's out of order.
SongDataUtils.sortTimeChanges(songTimeChanges);
for (currentTimeChange in songTimeChanges)
{
// TODO: Maybe handle this different?

View file

@ -3,6 +3,7 @@ package funkin.data.song;
import flixel.util.FlxSort;
import funkin.data.song.SongData.SongEventData;
import funkin.data.song.SongData.SongNoteData;
import funkin.data.song.SongData.SongTimeChange;
import funkin.util.ClipboardUtil;
import funkin.util.SerializerUtil;
@ -157,6 +158,18 @@ class SongDataUtils
return events;
}
/**
* Sort an array of notes by strum time.
*/
public static function sortTimeChanges(timeChanges:Array<SongTimeChange>, desc:Bool = false):Array<SongTimeChange>
{
// TODO: Modifies the array in place. Is this okay?
timeChanges.sort(function(a:SongTimeChange, b:SongTimeChange):Int {
return FlxSort.byValues(desc ? FlxSort.DESCENDING : FlxSort.ASCENDING, a.timeStamp, b.timeStamp);
});
return timeChanges;
}
/**
* Serialize note and event data and write it to the clipboard.
*/

View file

@ -1,5 +1,6 @@
package funkin.input;
import haxe.ui.backend.flixel.CursorHelper;
import openfl.utils.Assets;
import lime.app.Future;
import openfl.display.BitmapData;
@ -33,7 +34,7 @@ class Cursor
Cursor.cursorMode = null;
}
static final CURSOR_DEFAULT_PARAMS:CursorParams =
public static final CURSOR_DEFAULT_PARAMS:CursorParams =
{
graphic: "assets/images/cursor/cursor-default.png",
scale: 1.0,
@ -42,7 +43,7 @@ class Cursor
};
static var assetCursorDefault:Null<BitmapData> = null;
static final CURSOR_CROSS_PARAMS:CursorParams =
public static final CURSOR_CROSS_PARAMS:CursorParams =
{
graphic: "assets/images/cursor/cursor-cross.png",
scale: 1.0,
@ -51,7 +52,7 @@ class Cursor
};
static var assetCursorCross:Null<BitmapData> = null;
static final CURSOR_ERASER_PARAMS:CursorParams =
public static final CURSOR_ERASER_PARAMS:CursorParams =
{
graphic: "assets/images/cursor/cursor-eraser.png",
scale: 1.0,
@ -60,7 +61,7 @@ class Cursor
};
static var assetCursorEraser:Null<BitmapData> = null;
static final CURSOR_GRABBING_PARAMS:CursorParams =
public static final CURSOR_GRABBING_PARAMS:CursorParams =
{
graphic: "assets/images/cursor/cursor-grabbing.png",
scale: 1.0,
@ -69,7 +70,7 @@ class Cursor
};
static var assetCursorGrabbing:Null<BitmapData> = null;
static final CURSOR_HOURGLASS_PARAMS:CursorParams =
public static final CURSOR_HOURGLASS_PARAMS:CursorParams =
{
graphic: "assets/images/cursor/cursor-hourglass.png",
scale: 1.0,
@ -78,7 +79,7 @@ class Cursor
};
static var assetCursorHourglass:Null<BitmapData> = null;
static final CURSOR_POINTER_PARAMS:CursorParams =
public static final CURSOR_POINTER_PARAMS:CursorParams =
{
graphic: "assets/images/cursor/cursor-pointer.png",
scale: 1.0,
@ -87,7 +88,7 @@ class Cursor
};
static var assetCursorPointer:Null<BitmapData> = null;
static final CURSOR_TEXT_PARAMS:CursorParams =
public static final CURSOR_TEXT_PARAMS:CursorParams =
{
graphic: "assets/images/cursor/cursor-text.png",
scale: 0.2,
@ -96,7 +97,7 @@ class Cursor
};
static var assetCursorText:Null<BitmapData> = null;
static final CURSOR_TEXT_VERTICAL_PARAMS:CursorParams =
public static final CURSOR_TEXT_VERTICAL_PARAMS:CursorParams =
{
graphic: "assets/images/cursor/cursor-text-vertical.png",
scale: 0.2,
@ -105,7 +106,7 @@ class Cursor
};
static var assetCursorTextVertical:Null<BitmapData> = null;
static final CURSOR_ZOOM_IN_PARAMS:CursorParams =
public static final CURSOR_ZOOM_IN_PARAMS:CursorParams =
{
graphic: "assets/images/cursor/cursor-zoom-in.png",
scale: 1.0,
@ -114,7 +115,7 @@ class Cursor
};
static var assetCursorZoomIn:Null<BitmapData> = null;
static final CURSOR_ZOOM_OUT_PARAMS:CursorParams =
public static final CURSOR_ZOOM_OUT_PARAMS:CursorParams =
{
graphic: "assets/images/cursor/cursor-zoom-out.png",
scale: 1.0,
@ -123,7 +124,7 @@ class Cursor
};
static var assetCursorZoomOut:Null<BitmapData> = null;
static final CURSOR_CROSSHAIR_PARAMS:CursorParams =
public static final CURSOR_CROSSHAIR_PARAMS:CursorParams =
{
graphic: "assets/images/cursor/cursor-crosshair.png",
scale: 1.0,
@ -132,7 +133,7 @@ class Cursor
};
static var assetCursorCrosshair:Null<BitmapData> = null;
static final CURSOR_CELL_PARAMS:CursorParams =
public static final CURSOR_CELL_PARAMS:CursorParams =
{
graphic: "assets/images/cursor/cursor-cell.png",
scale: 1.0,
@ -500,6 +501,28 @@ class Cursor
{
trace("Failed to load cursor graphic for cursor mode " + cursorMode + ": " + error);
}
public static function registerHaxeUICursors():Void
{
CursorHelper.useCustomCursors = true;
registerHaxeUICursor('default', CURSOR_DEFAULT_PARAMS);
registerHaxeUICursor('cross', CURSOR_CROSS_PARAMS);
registerHaxeUICursor('eraser', CURSOR_ERASER_PARAMS);
registerHaxeUICursor('grabbing', CURSOR_GRABBING_PARAMS);
registerHaxeUICursor('hourglass', CURSOR_HOURGLASS_PARAMS);
registerHaxeUICursor('pointer', CURSOR_POINTER_PARAMS);
registerHaxeUICursor('text', CURSOR_TEXT_PARAMS);
registerHaxeUICursor('text-vertical', CURSOR_TEXT_VERTICAL_PARAMS);
registerHaxeUICursor('zoom-in', CURSOR_ZOOM_IN_PARAMS);
registerHaxeUICursor('zoom-out', CURSOR_ZOOM_OUT_PARAMS);
registerHaxeUICursor('crosshair', CURSOR_CROSSHAIR_PARAMS);
registerHaxeUICursor('cell', CURSOR_CELL_PARAMS);
}
public static function registerHaxeUICursor(id:String, params:CursorParams):Void
{
CursorHelper.registerCursor(id, params.graphic, params.scale, params.offsetX, params.offsetY);
}
}
// https://developer.mozilla.org/en-US/docs/Web/CSS/cursor

View file

@ -1,6 +1,5 @@
package funkin.ui.debug.charting;
import funkin.ui.haxeui.components.FunkinDropDown;
import flixel.util.FlxTimer;
import funkin.data.song.importer.FNFLegacyData;
import funkin.data.song.importer.FNFLegacyImporter;
@ -15,7 +14,6 @@ import funkin.play.character.CharacterData;
import funkin.play.character.CharacterData.CharacterDataParser;
import funkin.play.song.Song;
import funkin.play.stage.StageData;
import funkin.ui.haxeui.components.FunkinLink;
import funkin.util.Constants;
import funkin.util.FileUtil;
import funkin.util.SerializerUtil;
@ -151,7 +149,7 @@ class ChartEditorDialogHandler
continue;
}
var linkTemplateSong:Link = new FunkinLink();
var linkTemplateSong:Link = new Link();
linkTemplateSong.text = songName;
linkTemplateSong.onClick = function(_event) {
dialog.hideDialog(DialogButton.CANCEL);
@ -618,7 +616,7 @@ class ChartEditorDialogHandler
var startingValueStage = ChartEditorDropdowns.populateDropdownWithStages(inputStage, newSongMetadata.playData.stage);
inputStage.value = startingValueStage;
var inputNoteStyle:Null<FunkinDropDown> = dialog.findComponent('inputNoteStyle', FunkinDropDown);
var inputNoteStyle:Null<DropDown> = dialog.findComponent('inputNoteStyle', DropDown);
if (inputNoteStyle == null) throw 'Could not locate inputNoteStyle DropDown in Song Metadata dialog';
inputNoteStyle.onChange = function(event:UIEvent) {
if (event.data.id == null) return;
@ -627,7 +625,7 @@ class ChartEditorDialogHandler
var startingValueNoteStyle = ChartEditorDropdowns.populateDropdownWithNoteStyles(inputNoteStyle, newSongMetadata.playData.noteSkin);
inputNoteStyle.value = startingValueNoteStyle;
var inputCharacterPlayer:Null<FunkinDropDown> = dialog.findComponent('inputCharacterPlayer', FunkinDropDown);
var inputCharacterPlayer:Null<DropDown> = dialog.findComponent('inputCharacterPlayer', DropDown);
if (inputCharacterPlayer == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputCharacterPlayer component.';
inputCharacterPlayer.onChange = function(event:UIEvent) {
if (event.data?.id == null) return;
@ -637,7 +635,7 @@ class ChartEditorDialogHandler
newSongMetadata.playData.characters.player);
inputCharacterPlayer.value = startingValuePlayer;
var inputCharacterOpponent:Null<FunkinDropDown> = dialog.findComponent('inputCharacterOpponent', FunkinDropDown);
var inputCharacterOpponent:Null<DropDown> = dialog.findComponent('inputCharacterOpponent', DropDown);
if (inputCharacterOpponent == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputCharacterOpponent component.';
inputCharacterOpponent.onChange = function(event:UIEvent) {
if (event.data?.id == null) return;
@ -647,7 +645,7 @@ class ChartEditorDialogHandler
newSongMetadata.playData.characters.opponent);
inputCharacterOpponent.value = startingValueOpponent;
var inputCharacterGirlfriend:Null<FunkinDropDown> = dialog.findComponent('inputCharacterGirlfriend', FunkinDropDown);
var inputCharacterGirlfriend:Null<DropDown> = dialog.findComponent('inputCharacterGirlfriend', DropDown);
if (inputCharacterGirlfriend == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputCharacterGirlfriend component.';
inputCharacterGirlfriend.onChange = function(event:UIEvent) {
if (event.data?.id == null) return;

View file

@ -1,6 +1,5 @@
package funkin.ui.debug.charting;
import funkin.ui.haxeui.components.FunkinDropDown;
import funkin.play.stage.StageData.StageDataParser;
import funkin.play.stage.StageData;
import funkin.play.character.CharacterData;
@ -596,7 +595,7 @@ class ChartEditorToolboxHandler
};
inputSongArtist.value = state.currentSongMetadata.artist;
var inputStage:Null<FunkinDropDown> = toolbox.findComponent('inputStage', FunkinDropDown);
var inputStage:Null<DropDown> = toolbox.findComponent('inputStage', DropDown);
if (inputStage == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputStage component.';
inputStage.onChange = function(event:UIEvent) {
var valid:Bool = event.data != null && event.data.id != null;
@ -609,7 +608,7 @@ class ChartEditorToolboxHandler
var startingValueStage = ChartEditorDropdowns.populateDropdownWithStages(inputStage, state.currentSongMetadata.playData.stage);
inputStage.value = startingValueStage;
var inputNoteStyle:Null<FunkinDropDown> = toolbox.findComponent('inputNoteStyle', FunkinDropDown);
var inputNoteStyle:Null<DropDown> = toolbox.findComponent('inputNoteStyle', DropDown);
if (inputNoteStyle == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputNoteStyle component.';
inputNoteStyle.onChange = function(event:UIEvent) {
if (event.data?.id == null) return;
@ -619,7 +618,7 @@ class ChartEditorToolboxHandler
// By using this flag, we prevent the dropdown value from changing while it is being populated.
var inputCharacterPlayer:Null<FunkinDropDown> = toolbox.findComponent('inputCharacterPlayer', FunkinDropDown);
var inputCharacterPlayer:Null<DropDown> = toolbox.findComponent('inputCharacterPlayer', DropDown);
if (inputCharacterPlayer == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputCharacterPlayer component.';
inputCharacterPlayer.onChange = function(event:UIEvent) {
if (event.data?.id == null) return;
@ -629,7 +628,7 @@ class ChartEditorToolboxHandler
state.currentSongMetadata.playData.characters.player);
inputCharacterPlayer.value = startingValuePlayer;
var inputCharacterOpponent:Null<FunkinDropDown> = toolbox.findComponent('inputCharacterOpponent', FunkinDropDown);
var inputCharacterOpponent:Null<DropDown> = toolbox.findComponent('inputCharacterOpponent', DropDown);
if (inputCharacterOpponent == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputCharacterOpponent component.';
inputCharacterOpponent.onChange = function(event:UIEvent) {
if (event.data?.id == null) return;
@ -639,7 +638,7 @@ class ChartEditorToolboxHandler
state.currentSongMetadata.playData.characters.opponent);
inputCharacterOpponent.value = startingValueOpponent;
var inputCharacterGirlfriend:Null<FunkinDropDown> = toolbox.findComponent('inputCharacterGirlfriend', FunkinDropDown);
var inputCharacterGirlfriend:Null<DropDown> = toolbox.findComponent('inputCharacterGirlfriend', DropDown);
if (inputCharacterGirlfriend == null) throw 'ChartEditorToolboxHandler.buildToolboxMetadataLayout() - Could not find inputCharacterGirlfriend component.';
inputCharacterGirlfriend.onChange = function(event:UIEvent) {
if (event.data?.id == null) return;

View file

@ -1,30 +0,0 @@
package funkin.ui.haxeui.components;
import funkin.input.Cursor;
import haxe.ui.events.MouseEvent;
import haxe.ui.components.Button;
/**
* A HaxeUI button which:
* - Changes the current cursor when hovered over.
*/
class FunkinButton extends Button
{
public function new()
{
super();
this.onMouseOver = handleMouseOver;
this.onMouseOut = handleMouseOut;
}
private function handleMouseOver(event:MouseEvent)
{
Cursor.cursorMode = Pointer;
}
private function handleMouseOut(event:MouseEvent)
{
Cursor.cursorMode = Default;
}
}

View file

@ -1,30 +0,0 @@
package funkin.ui.haxeui.components;
import haxe.ui.components.Label;
import funkin.input.Cursor;
import haxe.ui.events.MouseEvent;
/**
* A HaxeUI label which:
* - Changes the current cursor when hovered over (assume an onClick handler will be added!).
*/
class FunkinClickLabel extends Label
{
public function new()
{
super();
this.onMouseOver = handleMouseOver;
this.onMouseOut = handleMouseOut;
}
private function handleMouseOver(event:MouseEvent)
{
Cursor.cursorMode = Pointer;
}
private function handleMouseOut(event:MouseEvent)
{
Cursor.cursorMode = Default;
}
}

View file

@ -1,30 +0,0 @@
package funkin.ui.haxeui.components;
import haxe.ui.components.DropDown;
import funkin.input.Cursor;
import haxe.ui.events.MouseEvent;
/**
* A HaxeUI dropdown which:
* - Changes the current cursor when hovered over.
*/
class FunkinDropDown extends DropDown
{
public function new()
{
super();
this.onMouseOver = handleMouseOver;
this.onMouseOut = handleMouseOut;
}
private function handleMouseOver(event:MouseEvent)
{
Cursor.cursorMode = Pointer;
}
private function handleMouseOut(event:MouseEvent)
{
Cursor.cursorMode = Default;
}
}

View file

@ -1,30 +0,0 @@
package funkin.ui.haxeui.components;
import haxe.ui.components.HorizontalSlider;
import funkin.input.Cursor;
import haxe.ui.events.MouseEvent;
/**
* A HaxeUI horizontal slider which:
* - Changes the current cursor when hovered over.
*/
class FunkinHorizontalSlider extends HorizontalSlider
{
public function new()
{
super();
this.onMouseOver = handleMouseOver;
this.onMouseOut = handleMouseOut;
}
private function handleMouseOver(event:MouseEvent)
{
Cursor.cursorMode = Pointer;
}
private function handleMouseOut(event:MouseEvent)
{
Cursor.cursorMode = Default;
}
}

View file

@ -1,30 +0,0 @@
package funkin.ui.haxeui.components;
import funkin.input.Cursor;
import haxe.ui.events.MouseEvent;
import haxe.ui.components.Link;
/**
* A HaxeUI link which:
* - Changes the current cursor when hovered over.
*/
class FunkinLink extends Link
{
public function new()
{
super();
this.onMouseOver = handleMouseOver;
this.onMouseOut = handleMouseOut;
}
private function handleMouseOver(event:MouseEvent)
{
Cursor.cursorMode = Pointer;
}
private function handleMouseOut(event:MouseEvent)
{
Cursor.cursorMode = Default;
}
}

View file

@ -1,32 +0,0 @@
package funkin.ui.haxeui.components;
import funkin.input.Cursor;
import haxe.ui.events.MouseEvent;
import haxe.ui.containers.menus.MenuBar;
import haxe.ui.core.CompositeBuilder;
/**
* A HaxeUI menu bar which:
* - Changes the current cursor when each button is hovered over.
*/
class FunkinMenuBar extends MenuBar
{
public function new()
{
super();
registerListeners();
}
private function registerListeners():Void {}
private function handleMouseOver(event:MouseEvent)
{
Cursor.cursorMode = Pointer;
}
private function handleMouseOut(event:MouseEvent)
{
Cursor.cursorMode = Default;
}
}

View file

@ -1,30 +0,0 @@
package funkin.ui.haxeui.components;
import funkin.input.Cursor;
import haxe.ui.events.MouseEvent;
import haxe.ui.containers.menus.MenuCheckBox;
/**
* A HaxeUI menu checkbox which:
* - Changes the current cursor when hovered over.
*/
class FunkinMenuCheckBox extends MenuCheckBox
{
public function new()
{
super();
this.onMouseOver = handleMouseOver;
this.onMouseOut = handleMouseOut;
}
private function handleMouseOver(event:MouseEvent)
{
Cursor.cursorMode = Pointer;
}
private function handleMouseOut(event:MouseEvent)
{
Cursor.cursorMode = Default;
}
}

View file

@ -1,30 +0,0 @@
package funkin.ui.haxeui.components;
import funkin.input.Cursor;
import haxe.ui.events.MouseEvent;
import haxe.ui.containers.menus.MenuItem;
/**
* A HaxeUI menu item which:
* - Changes the current cursor when hovered over.
*/
class FunkinMenuItem extends MenuItem
{
public function new()
{
super();
this.onMouseOver = handleMouseOver;
this.onMouseOut = handleMouseOut;
}
private function handleMouseOver(event:MouseEvent)
{
Cursor.cursorMode = Pointer;
}
private function handleMouseOut(event:MouseEvent)
{
Cursor.cursorMode = Default;
}
}

View file

@ -1,30 +0,0 @@
package funkin.ui.haxeui.components;
import haxe.ui.containers.menus.MenuOptionBox;
import funkin.input.Cursor;
import haxe.ui.events.MouseEvent;
/**
* A HaxeUI menu option box which:
* - Changes the current cursor when hovered over.
*/
class FunkinMenuOptionBox extends MenuOptionBox
{
public function new()
{
super();
this.onMouseOver = handleMouseOver;
this.onMouseOut = handleMouseOut;
}
private function handleMouseOver(event:MouseEvent)
{
Cursor.cursorMode = Pointer;
}
private function handleMouseOut(event:MouseEvent)
{
Cursor.cursorMode = Default;
}
}

View file

@ -1,30 +0,0 @@
package funkin.ui.haxeui.components;
import haxe.ui.components.NumberStepper;
import funkin.input.Cursor;
import haxe.ui.events.MouseEvent;
/**
* A HaxeUI number stepper which:
* - Changes the current cursor when hovered over.
*/
class FunkinNumberStepper extends NumberStepper
{
public function new()
{
super();
this.onMouseOver = handleMouseOver;
this.onMouseOut = handleMouseOut;
}
private function handleMouseOver(event:MouseEvent)
{
Cursor.cursorMode = Pointer;
}
private function handleMouseOut(event:MouseEvent)
{
Cursor.cursorMode = Default;
}
}

View file

@ -1,30 +0,0 @@
package funkin.ui.haxeui.components;
import haxe.ui.components.TextField;
import funkin.input.Cursor;
import haxe.ui.events.MouseEvent;
/**
* A HaxeUI text field which:
* - Changes the current cursor when hovered over.
*/
class FunkinTextField extends TextField
{
public function new()
{
super();
this.onMouseOver = handleMouseOver;
this.onMouseOut = handleMouseOut;
}
private function handleMouseOver(event:MouseEvent)
{
Cursor.cursorMode = Text;
}
private function handleMouseOut(event:MouseEvent)
{
Cursor.cursorMode = Default;
}
}