diff --git a/Project.xml b/Project.xml index 46ba7f155..4c0ffdce7 100644 --- a/Project.xml +++ b/Project.xml @@ -162,10 +162,13 @@ - + + + +
diff --git a/assets b/assets index 4ed2b3084..2dd4ab0eb 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 4ed2b3084d54899e10d10a97eaafe210158768be +Subproject commit 2dd4ab0eb9979422c1c4cb849ebe899b7bf1758a diff --git a/docs/style-guide.md b/docs/style-guide.md index 1131cca2b..4c4e01492 100644 --- a/docs/style-guide.md +++ b/docs/style-guide.md @@ -32,6 +32,10 @@ Example: public function checkSyncError(?targetTime:Float):Float ``` +## Commenting Unused Code + +Do not comment out sections of code that are unused. Keep these snippets elsewhere or remove them. Older chunks of code can be retrieved by referring to the older Git commits, and having large chunks of commented code makes files longer and more confusing to navigate. + ## License Headers Do not include headers specifying code license on individual files in the repo, since the main `LICENSE.md` file covers all of them. diff --git a/source/funkin/play/PauseSubState.hx b/source/funkin/play/PauseSubState.hx index f5555b66e..c9039ce40 100644 --- a/source/funkin/play/PauseSubState.hx +++ b/source/funkin/play/PauseSubState.hx @@ -233,6 +233,7 @@ class PauseSubState extends MusicBeatSubState if (PlayStatePlaylist.isStoryMode) { + PlayStatePlaylist.reset(); openSubState(new funkin.ui.transition.StickerSubState(null, STORY)); } else diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index c9512aa93..7d20f4697 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1354,8 +1354,7 @@ class PlayState extends MusicBeatSubState else { // lolol - lime.app.Application.current.window.alert('Nice job, you ignoramus. $id isn\'t a real stage.\nI\'m falling back to the default so the game doesn\'t shit itself.', - 'Stage Error'); + lime.app.Application.current.window.alert('Unable to load stage ${id}, is its data corrupted?.', 'Stage Error'); } } diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index efb3ee623..db1f2b69a 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -177,6 +177,23 @@ abstract Save(RawSaveData) return this.optionsChartEditor.previousFiles; } + public var chartEditorHasBackup(get, set):Bool; + + function get_chartEditorHasBackup():Bool + { + if (this.optionsChartEditor.hasBackup == null) this.optionsChartEditor.hasBackup = false; + + return this.optionsChartEditor.hasBackup; + } + + function set_chartEditorHasBackup(value:Bool):Bool + { + // Set and apply. + this.optionsChartEditor.hasBackup = value; + flush(); + return this.optionsChartEditor.hasBackup; + } + public var chartEditorNoteQuant(get, set):Int; function get_chartEditorNoteQuant():Int @@ -926,6 +943,13 @@ typedef SaveControlsData = */ typedef SaveDataChartEditorOptions = { + /** + * Whether the Chart Editor created a backup the last time it closed. + * Prompt the user to load it, then set this back to `false`. + * @default `false` + */ + var ?hasBackup:Bool; + /** * Previous files opened in the Chart Editor. * @default `[]` diff --git a/source/funkin/ui/debug/DebugMenuSubState.hx b/source/funkin/ui/debug/DebugMenuSubState.hx index ef02a802e..404bf6f67 100644 --- a/source/funkin/ui/debug/DebugMenuSubState.hx +++ b/source/funkin/ui/debug/DebugMenuSubState.hx @@ -7,6 +7,8 @@ import funkin.ui.MusicBeatSubState; import funkin.ui.TextMenuList; import funkin.ui.debug.charting.ChartEditorState; import funkin.ui.MusicBeatSubState; +import funkin.util.logging.CrashHandler; +import flixel.addons.transition.FlxTransitionableState; class DebugMenuSubState extends MusicBeatSubState { @@ -50,7 +52,9 @@ class DebugMenuSubState extends MusicBeatSubState createItem("ANIMATION EDITOR", openAnimationEditor); createItem("STAGE EDITOR", openStageEditor); createItem("TEST STICKERS", testStickers); - + #if sys + createItem("OPEN CRASH LOG FOLDER", openLogFolder); + #end FlxG.camera.focusOn(new FlxPoint(camFocusPoint.x, camFocusPoint.y)); FlxG.camera.focusOn(new FlxPoint(camFocusPoint.x, camFocusPoint.y + 500)); } @@ -81,6 +85,8 @@ class DebugMenuSubState extends MusicBeatSubState function openChartEditor() { + FlxTransitionableState.skipNextTransIn = true; + FlxG.switchState(new ChartEditorState()); } @@ -101,6 +107,22 @@ class DebugMenuSubState extends MusicBeatSubState trace('Stage Editor'); } + #if sys + function openLogFolder() + { + #if windows + Sys.command('explorer', [CrashHandler.LOG_FOLDER]); + #elseif mac + // mac could be fuckie with where the log folder is relative to the game file... + // if this comment is still here... it means it has NOT been verified on mac yet! + Sys.command('open', [CrashHandler.LOG_FOLDER]); + #end + + // TODO: implement linux + // some shit with xdg-open :thinking: emoji... + } + #end + function exitDebugMenu() { // TODO: Add a transition? diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index a3aeccc02..72cd2d0d6 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -1,5 +1,6 @@ package funkin.ui.debug.charting; +import funkin.util.logging.CrashHandler; import haxe.ui.containers.menus.MenuBar; import flixel.addons.display.FlxSliceSprite; import flixel.addons.display.FlxTiledSprite; @@ -18,17 +19,18 @@ import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.tweens.misc.VarTween; import flixel.util.FlxColor; -import funkin.ui.mainmenu.MainMenuState; import flixel.util.FlxSort; import flixel.util.FlxTimer; import funkin.audio.visualize.PolygonSpectogram; import funkin.audio.VoicesGroup; import funkin.data.notestyle.NoteStyleRegistry; +import funkin.data.song.SongData.SongCharacterData; import funkin.data.song.SongData.SongChartData; import funkin.data.song.SongData.SongEventData; import funkin.data.song.SongData.SongMetadata; import funkin.data.song.SongData.SongNoteData; import funkin.data.song.SongDataUtils; +import funkin.data.song.SongRegistry; import funkin.input.Cursor; import funkin.input.TurboKeyHandler; import funkin.modding.events.ScriptEvent; @@ -47,12 +49,12 @@ import funkin.data.song.SongData.SongNoteData; import funkin.data.song.SongData.SongCharacterData; import funkin.data.song.SongDataUtils; import funkin.ui.debug.charting.commands.ChartEditorCommand; -import funkin.ui.debug.charting.handlers.ChartEditorShortcutHandler; import funkin.play.stage.StageData; import funkin.save.Save; import funkin.ui.debug.charting.commands.AddEventsCommand; import funkin.ui.debug.charting.commands.AddNotesCommand; import funkin.ui.debug.charting.commands.ChartEditorCommand; +import funkin.ui.debug.charting.commands.ChartEditorCommand; import funkin.ui.debug.charting.commands.CutItemsCommand; import funkin.ui.debug.charting.commands.DeselectAllItemsCommand; import funkin.ui.debug.charting.commands.DeselectItemsCommand; @@ -73,15 +75,21 @@ import funkin.ui.debug.charting.components.ChartEditorEventSprite; import funkin.ui.debug.charting.components.ChartEditorHoldNoteSprite; import funkin.ui.debug.charting.components.ChartEditorNotePreview; import funkin.ui.debug.charting.components.ChartEditorNoteSprite; +import funkin.ui.debug.charting.components.ChartEditorPlaybarHead; import funkin.ui.debug.charting.components.ChartEditorSelectionSquareSprite; +import funkin.ui.debug.charting.handlers.ChartEditorShortcutHandler; import funkin.ui.haxeui.components.CharacterPlayer; import funkin.ui.haxeui.HaxeUIState; +import funkin.ui.mainmenu.MainMenuState; import funkin.util.Constants; +import funkin.util.FileUtil; import funkin.util.SortUtil; import funkin.util.WindowUtil; import haxe.DynamicAccess; import haxe.io.Bytes; import haxe.io.Path; +import haxe.ui.backend.flixel.UIRuntimeState; +import haxe.ui.backend.flixel.UIState; import haxe.ui.components.DropDown; import haxe.ui.components.Label; import haxe.ui.components.NumberStepper; @@ -90,18 +98,18 @@ import haxe.ui.components.TextField; import haxe.ui.containers.dialogs.CollapsibleDialog; import haxe.ui.containers.Frame; import haxe.ui.containers.menus.Menu; +import haxe.ui.containers.menus.MenuBar; import haxe.ui.containers.menus.MenuItem; import haxe.ui.containers.TreeView; import haxe.ui.containers.TreeViewNode; import haxe.ui.core.Component; import haxe.ui.core.Screen; import haxe.ui.events.DragEvent; +import haxe.ui.events.MouseEvent; +import haxe.ui.events.UIEvent; import haxe.ui.events.UIEvent; import haxe.ui.focus.FocusManager; -import haxe.ui.notifications.NotificationManager; -import haxe.ui.notifications.NotificationType; import openfl.display.BitmapData; -import funkin.util.FileUtil; using Lambda; @@ -109,24 +117,22 @@ using Lambda; * A state dedicated to allowing the user to create and edit song charts. * Built with HaxeUI for use by both developers and modders. * - * Some functionality is moved to other classes to help maintain my sanity. + * Some functionality is split into handler classes to help maintain my sanity. * * @author MasterEric */ -@:nullSafety -class ChartEditorState extends HaxeUIState +// @:nullSafety + +@:build(haxe.ui.ComponentBuilder.build("assets/exclude/data/ui/chart-editor/main-view.xml")) +class ChartEditorState extends UIState // UIState derives from MusicBeatState { /** * CONSTANTS */ // ============================== - // XML Layouts - public static final CHART_EDITOR_LAYOUT:String = Paths.ui('chart-editor/main-view'); - - public static final CHART_EDITOR_NOTIFBAR_LAYOUT:String = Paths.ui('chart-editor/components/notifbar'); - public static final CHART_EDITOR_PLAYBARHEAD_LAYOUT:String = Paths.ui('chart-editor/components/playbar-head'); - + // Layouts public static final CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/notedata'); + public static final CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/eventdata'); public static final CHART_EDITOR_TOOLBOX_METADATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/metadata'); public static final CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT:String = Paths.ui('chart-editor/toolbox/difficulty'); @@ -779,6 +785,18 @@ class ChartEditorState extends HaxeUIState return saveDataDirty; } + var shouldShowBackupAvailableDialog(get, set):Bool; + + function get_shouldShowBackupAvailableDialog():Bool + { + return Save.get().chartEditorHasBackup; + } + + function set_shouldShowBackupAvailableDialog(value:Bool):Bool + { + return Save.get().chartEditorHasBackup = value; + } + /** * Whether the difficulty tree view in the toolbox has been modified and needs to be updated. * This happens when we add/remove difficulties. @@ -1199,6 +1217,110 @@ class ChartEditorState extends HaxeUIState return currentSongMetadata.playData.characters.instrumental = value; } + /** + * HAXEUI COMPONENTS + */ + // ============================== + + /** + * The layout containing the playbar. + * Constructed manually and added to the layout so we can control its position. + */ + var playbarHeadLayout:Null = null; + + // NOTE: All the components below are automatically assigned via HaxeUI macros. + /** + * The menubar at the top of the screen. + */ + // var menubar:MenuBar; + /** + * The `File -> New Chart` menu item. + */ + // var menubarItemNewChart:MenuItem; + /** + * The `File -> Open Chart` menu item. + */ + // var menubarItemOpenChart:MenuItem; + /** + * The `File -> Open Recent` menu. + */ + // var menubarOpenRecent:Menu; + /** + * The `File -> Save Chart` menu item. + */ + // var menubarItemSaveChart:MenuItem; + /** + * The `File -> Save Chart As` menu item. + */ + // var menubarItemSaveChartAs:MenuItem; + /** + * The `File -> Preferences` menu item. + */ + // var menubarItemPreferences:MenuItem; + /** + * The `File -> Exit` menu item. + */ + // var menubarItemExit:MenuItem; + /** + * The `Edit -> Undo` menu item. + */ + // var menubarItemUndo:MenuItem; + /** + * The `Edit -> Redo` menu item. + */ + // var menubarItemRedo:MenuItem; + /** + * The `Edit -> Cut` menu item. + */ + // var menubarItemCut:MenuItem; + /** + * The `Edit -> Copy` menu item. + */ + // var menubarItemCopy:MenuItem; + /** + * The `Edit -> Paste` menu item. + */ + // var menubarItemPaste:MenuItem; + /** + * The `Edit -> Paste Unsnapped` menu item. + */ + // var menubarItemPasteUnsnapped:MenuItem; + /** + * The `Edit -> Delete` menu item. + */ + // var menubarItemDelete:MenuItem; + /** + * The label by the playbar telling the song position. + */ + // var playbarSongPos:Label; + /** + * The label by the playbar telling the song time remaining. + */ + // var playbarSongRemaining:Label; + /** + * The label by the playbar telling the note snap. + */ + // var playbarNoteSnap:Label; + /** + * The button by the playbar to jump to the start of the song. + */ + // var playbarStart:Button; + /** + * The button by the playbar to jump backwards in the song. + */ + // var playbarBack:Button; + /** + * The button by the playbar to play or pause the song. + */ + // var playbarPlay:Button; + /** + * The button by the playbar to jump forwards in the song. + */ + // var playbarForward:Button; + /** + * The button by the playbar to jump to the end of the song. + */ + // var playbarEnd:Button; /** * RENDER OBJECTS */ @@ -1288,41 +1410,6 @@ class ChartEditorState extends HaxeUIState */ var menuBG:Null = null; - /** - * The layout containing the playbar head slider. - */ - var playbarHeadLayout:Null = null; - - /** - * The submenu in the menubar containing recently opened files. - */ - var menubarOpenRecent:Null = null; - - /** - * The item in the menubar to save the currently opened chart. - */ - var menubarItemSaveChart:Null = null; - - /** - * The playbar head slider. - */ - var playbarHead:Null = null; - - /** - * The label by the playbar telling the song position. - */ - var playbarSongPos:Null