From a1da5a57585a6266e8d3eea3c93eb54bd2f3ed71 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 20 Nov 2023 11:26:58 -0500 Subject: [PATCH] Bugfix/chart editor fixins (#222) * Rewrite crash log file to contain more information * Detect host platform. * Suppress shouldHandleCursor spam * Fix bug where previous song's vocals are kept on new songs * Fix an issue where note snapping could go negative. --------- Co-authored-by: Cameron Taylor --- .../ui/debug/charting/ChartEditorState.hx | 24 ++++++++----- .../handlers/ChartEditorDialogHandler.hx | 2 +- source/funkin/util/PlatformUtil.hx | 35 +++++++++++++++++++ source/funkin/util/logging/CrashHandler.hx | 29 ++++++++++++++- 4 files changed, 80 insertions(+), 10 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 6e529d6a0..ee8af9191 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -1982,14 +1982,14 @@ class ChartEditorState extends HaxeUIState addUIClickListener('playbarEnd', _ -> playbarButtonPressed = 'playbarEnd'); // Cycle note snap quant. - addUIClickListener('playbarNoteSnap', function(_) { - noteSnapQuantIndex++; - if (noteSnapQuantIndex >= SNAP_QUANTS.length) noteSnapQuantIndex = 0; - }); addUIRightClickListener('playbarNoteSnap', function(_) { noteSnapQuantIndex--; if (noteSnapQuantIndex < 0) noteSnapQuantIndex = SNAP_QUANTS.length - 1; }); + addUIClickListener('playbarNoteSnap', function(_) { + noteSnapQuantIndex++; + if (noteSnapQuantIndex >= SNAP_QUANTS.length) noteSnapQuantIndex = 0; + }); // Add functionality to the menu items. @@ -2079,8 +2079,14 @@ class ChartEditorState extends HaxeUIState addUIClickListener('menubarItemPlaytestFull', _ -> testSongInPlayState(false)); addUIClickListener('menubarItemPlaytestMinimal', _ -> testSongInPlayState(true)); - addUIClickListener('menuBarItemNoteSnapDecrease', _ -> noteSnapQuantIndex--); - addUIClickListener('menuBarItemNoteSnapIncrease', _ -> noteSnapQuantIndex++); + addUIClickListener('menuBarItemNoteSnapDecrease', _ -> { + noteSnapQuantIndex--; + if (noteSnapQuantIndex < 0) noteSnapQuantIndex = SNAP_QUANTS.length - 1; + }); + addUIClickListener('menuBarItemNoteSnapIncrease', _ -> { + noteSnapQuantIndex++; + if (noteSnapQuantIndex >= SNAP_QUANTS.length) noteSnapQuantIndex = 0; + }); addUIChangeListener('menuBarItemInputStyleNone', function(event:UIEvent) { currentLiveInputStyle = None; @@ -2898,11 +2904,13 @@ class ChartEditorState extends HaxeUIState if (FlxG.keys.justPressed.LEFT && !FlxG.keys.pressed.CONTROL) { noteSnapQuantIndex--; + if (noteSnapQuantIndex < 0) noteSnapQuantIndex = SNAP_QUANTS.length - 1; } if (FlxG.keys.justPressed.RIGHT && !FlxG.keys.pressed.CONTROL) { noteSnapQuantIndex++; + if (noteSnapQuantIndex >= SNAP_QUANTS.length) noteSnapQuantIndex = 0; } } } @@ -2922,7 +2930,7 @@ class ChartEditorState extends HaxeUIState || (dragTargetNote != null || dragTargetEvent != null); var eventColumn:Int = (STRUMLINE_SIZE * 2 + 1) - 1; - trace('shouldHandleCursor: $shouldHandleCursor'); + // trace('shouldHandleCursor: $shouldHandleCursor'); if (shouldHandleCursor) { @@ -3811,7 +3819,7 @@ class ChartEditorState extends HaxeUIState && playbarSongRemaining.value != songRemainingString) playbarSongRemaining.value = songRemainingString; if (playbarNoteSnap == null) playbarNoteSnap = findComponent('playbarNoteSnap', Label); - if (playbarNoteSnap != null && playbarNoteSnap.value != '1/${noteSnapQuant}') playbarNoteSnap.value = '1/${noteSnapQuant}'; + if (playbarNoteSnap != null) playbarNoteSnap.text = '1/${noteSnapQuant}'; } function handlePlayhead():Void diff --git a/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx b/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx index a048bdbbe..e27db6e87 100644 --- a/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx +++ b/source/funkin/ui/debug/charting/handlers/ChartEditorDialogHandler.hx @@ -875,7 +875,7 @@ class ChartEditorDialogHandler if (dialogNoVocals == null) throw 'Could not locate dialogNoVocals button in Upload Vocals dialog'; dialogNoVocals.onClick = function(_event) { // Dismiss - state.stopExistingVocals(); + state.wipeVocalData(); dialog.hideDialog(DialogButton.APPLY); }; diff --git a/source/funkin/util/PlatformUtil.hx b/source/funkin/util/PlatformUtil.hx index e11a21c9f..eecf6a7ea 100644 --- a/source/funkin/util/PlatformUtil.hx +++ b/source/funkin/util/PlatformUtil.hx @@ -23,4 +23,39 @@ class PlatformUtil return false; #end } + + /** + * Detects and returns the current host platform. + * Always returns `HTML5` on web, regardless of the computer running that browser. + * Returns `null` if the platform could not be detected. + */ + public static function detectHostPlatform():Null + { + #if html5 + return HTML5; + #else + switch (Sys.systemName()) + { + case ~/window/i.match(_) => true: + return WINDOWS; + case ~/linux/i.match(_) => true: + return LINUX; + case ~/mac/i.match(_) => true: + return MAC; + default: + return null; + } + #end + } +} + +/** + * Represents a host platform. + */ +enum HostPlatform +{ + WINDOWS; + LINUX; + MAC; + HTML5; } diff --git a/source/funkin/util/logging/CrashHandler.hx b/source/funkin/util/logging/CrashHandler.hx index a295f9bf1..9d1d3f1b9 100644 --- a/source/funkin/util/logging/CrashHandler.hx +++ b/source/funkin/util/logging/CrashHandler.hx @@ -84,7 +84,34 @@ class CrashHandler { FileUtil.createDirIfNotExists(LOG_FOLDER); - sys.io.File.saveContent('$LOG_FOLDER/crash${critical ? '-critical' : ''}-${DateUtil.generateTimestamp()}.log', message); + sys.io.File.saveContent('$LOG_FOLDER/crash${critical ? '-critical' : ''}-${DateUtil.generateTimestamp()}.log', buildCrashReport(message)); + } + + static function buildCrashReport(message:String):String + { + var fullContents:String = '=====================\n'; + fullContents += ' Funkin Crash Report\n'; + fullContents += '=====================\n'; + + fullContents += '\n'; + + fullContents += 'Generated by: ${Constants.GENERATED_BY}\n'; + fullContents += 'System timestamp: ${DateUtil.generateTimestamp()}\n'; + var driverInfo = FlxG?.stage?.context3D?.driverInfo ?? 'N/A'; + fullContents += 'Driver info: ${driverInfo}\n'; + fullContents += 'Platform: ${Sys.systemName()}\n'; + + fullContents += '\n'; + + fullContents += '=====================\n'; + + fullContents += '\n'; + + fullContents += message; + + fullContents += '\n'; + + return fullContents; } #end