From f824a4963a965d9c0bb28a07f49cb19dfeb1bb6d Mon Sep 17 00:00:00 2001 From: CharlesCatYT Date: Tue, 21 May 2024 17:18:22 -0400 Subject: [PATCH] fix notestyles & other shit --- assets | 2 +- source/funkin/FunkinWrapper.hx | 120 +++++++++--------- source/funkin/import.hx | 1 + source/funkin/modding/PolymodErrorHandler.hx | 9 +- source/funkin/modding/PolymodHandler.hx | 8 +- source/funkin/play/PlayState.hx | 16 +-- .../toolboxes/ChartEditorMetadataToolbox.hx | 2 + source/funkin/util/WindowUtil.hx | 2 + 8 files changed, 84 insertions(+), 76 deletions(-) diff --git a/assets b/assets index 952b3927e6..b22aca0c52 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 952b3927e69351d7cc8ebf68110ddd85a9dc6b7b +Subproject commit b22aca0c52f6d60b6cb6bcf4142132b08d7e615a diff --git a/source/funkin/FunkinWrapper.hx b/source/funkin/FunkinWrapper.hx index 8550f4df42..081af74620 100644 --- a/source/funkin/FunkinWrapper.hx +++ b/source/funkin/FunkinWrapper.hx @@ -4,76 +4,78 @@ using StringTools; class FunkinWrapper { - inline public static function callMethod(o:Dynamic, func:Function, args:Array):Dynamic - { - return Reflect.callMethod(o, func, args); - } inline public static function compare(a:T, b:T):Int - { - return Reflect.compare(a, b); - } + { + return Reflect.compare(a, b); + } + inline public static function compareMethods(f1:Dynamic, f2:Dynamic):Bool - { - return Reflect.compareMethods(a, b); - } + { + return Reflect.compareMethods(a, b); + } + inline public static function copy(o:Null):Null - { - return Reflect.copy(o); - } + { + return Reflect.copy(o); + } + inline public static function getProperty(o:Dynamic, field:String):Dynamic - { - return Reflect.getProperty(o, field); - } -public static function setProperty(o:Dynamic, field:String, value:Dynamic):Void - { - Reflect.setProperty(o, field, value); - } + { + return Reflect.getProperty(o, field); + } + + public static function setProperty(o:Dynamic, field:String, value:Dynamic):Void + { + Reflect.setProperty(o, field, value); + } + inline public static function getOsName():String - { - return Sys.systemName(); - } + { + return Sys.systemName(); + } + inline public static function printToOutput(hi:String):String - { - return Sys.println(hi); - } + { + return Sys.println(hi); + } + inline public static function isFunction(f:Dynamic):Bool - { - return Reflect.isFunction(f); - } + { + return Reflect.isFunction(f); + } + inline public static function fileExists(path:String):Bool - { - return Sys.FileSystem.exists(path); - } + { + return Sys.FileSystem.exists(path); + } + inline public static function getClass(o:T):Class - { - return Type.getClass(o); - } + { + return Type.getClass(o); + } + inline public static function getClassName(c:Class):String - { - return Type.getClassName(c); - } + { + return Type.getClassName(c); + } + inline public static function getEnum(o:EnumValue):Enum - { - return Type.getEnum(o); - } -inline public static function getEnumName(e:Enum):String - { - return Type.getEnumName(e); - } -inline public static function resolveClass(name:String):Class - { - return Type.resolveClass(name); - } - inline public static function resolveEnum(name:String):Enum - { - return Type.resolveEnum(name); - } + { + return Type.getEnum(o); + } + + inline public static function getEnumName(e:Enum):String + { + return Type.getEnumName(e); + } + inline public static function isObject(v:Dynamic):Bool - { - return Reflect.isObject(v); - } + { + return Reflect.isObject(v); + } + inline public static function isEnumValue(v:Dynamic):Bool - { - return Reflect.isEnumValue(v); - } + { + return Reflect.isEnumValue(v); + } } diff --git a/source/funkin/import.hx b/source/funkin/import.hx index 250de99cb2..7fca50752f 100644 --- a/source/funkin/import.hx +++ b/source/funkin/import.hx @@ -3,6 +3,7 @@ package; #if !macro // Only import these when we aren't in a macro. import funkin.util.Constants; +import funkin.FunkinWrapper; // Use for useful functions from blacklisted pacakges, wrapped in a singular class. import funkin.Paths; import funkin.Preferences; import flixel.FlxG; // This one in particular causes a compile error if you're using macros. diff --git a/source/funkin/modding/PolymodErrorHandler.hx b/source/funkin/modding/PolymodErrorHandler.hx index dc387900b4..310096bcd2 100644 --- a/source/funkin/modding/PolymodErrorHandler.hx +++ b/source/funkin/modding/PolymodErrorHandler.hx @@ -36,12 +36,12 @@ class PolymodErrorHandler // A syntax error when parsing a script. logError(error.message); // Notify the user via popup. - showAlert('Polymod Script Parsing Error', error.message); + showAlert('Polymod - Parsing Error', error.message); case SCRIPT_RUNTIME_EXCEPTION: // A runtime error when running a script. logError(error.message); // Notify the user via popup. - showAlert('Polymod Script Exception', error.message); + showAlert('Polymod - Exception', error.message); case SCRIPT_CLASS_MODULE_NOT_FOUND: // A scripted class tried to reference an unknown class or module. logError(error.message); @@ -53,12 +53,13 @@ class PolymodErrorHandler msg += '\nCheck to ensure the class exists and is spelled correctly.'; // Notify the user via popup. - showAlert('Polymod Script Import Error', msg); + showAlert('Polymod - Import Error', msg); case SCRIPT_CLASS_MODULE_BLACKLISTED: // A scripted class tried to reference a blacklisted class or module. logError(error.message); // Notify the user via popup. - showAlert('Polymod Script Blacklist Violation', error.message); + showAlert('Polymod - Blacklist Violation', + "Dude, this function is blacklisted.\n(Reflect, Sys, and Type functions are blacklisted by the way!)\n\n" + error.message); default: // Log the message based on its severity. diff --git a/source/funkin/modding/PolymodHandler.hx b/source/funkin/modding/PolymodHandler.hx index 2189808a54..b595aef2d5 100644 --- a/source/funkin/modding/PolymodHandler.hx +++ b/source/funkin/modding/PolymodHandler.hx @@ -234,6 +234,9 @@ class PolymodHandler // Add blacklisting for prohibited classes and packages. + // UPDATE: You can use FunkinWrapper to use functions from these packages that I checked to make sure they're safe (Type.getClass() is one of them) + // Functions from them that are deemed unsafe aren't included in the wrapper. + // `Sys` // Sys.command() can run malicious processes Polymod.blacklistImport('Sys'); @@ -290,8 +293,9 @@ class PolymodHandler assetLibraryPaths: [ 'default' => 'preload', 'shared' => 'shared', 'songs' => 'songs', 'videos' => 'videos', 'tutorial' => 'tutorial', 'week1' => 'week1', 'week2' => 'week2', 'week3' => 'week3', 'week4' => 'week4', 'week5' => 'week5', 'week6' => 'week6', 'week7' => 'week7', 'weekend1' => 'weekend1', - ]/*, - coreAssetRedirect: CORE_FOLDER,*/ + ] + /*, + coreAssetRedirect: CORE_FOLDER, */ } } diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 044de9d775..b00ba63624 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1526,10 +1526,11 @@ class PlayState extends MusicBeatSubState if (!startingSong && FlxG.sound.music != null - && (Math.abs(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 200 * playbackRate - || Math.abs(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > 200 * playbackRate)) + && (Math.abs(FlxG.sound.music.time + - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > #if ios 75 #else 200 #end * playbackRate + || Math.abs(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)) > #if ios 75 #else 200 #end * playbackRate)) { - trace("VOCALS NEED RESYNC"); + trace("attempting to resync voices, oops"); if (vocals != null) trace(vocals.checkSyncError(Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)); trace(FlxG.sound.music.time - (Conductor.instance.songPosition + Conductor.instance.instrumentalOffset)); resyncVocals(); @@ -1698,7 +1699,7 @@ class PlayState extends MusicBeatSubState scoreText = new FlxText(0, healthBarBG.y + 41, FlxG.width, "", 20); scoreText.setFormat(Paths.font('vcr.ttf'), 16, FlxColor.WHITE, CENTER, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); scoreText.scrollFactor.set(); - scoreText.zIndex = 802; + scoreText.zIndex = 851; add(scoreText); // Move the health bar to the HUD camera. @@ -1894,12 +1895,7 @@ class PlayState extends MusicBeatSubState */ function initStrumlines():Void { - var noteStyleId:String = switch (currentStageId) - { - case 'school': 'pixel'; - case 'schoolEvil': 'pixel'; - default: Constants.DEFAULT_NOTE_STYLE; - } + var noteStyleId:String = currentChart.noteStyle; var noteStyle:NoteStyle = NoteStyleRegistry.instance.fetchEntry(noteStyleId); if (noteStyle == null) noteStyle = NoteStyleRegistry.instance.fetchDefault(); diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx index 287bf5bf49..82428e46af 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorMetadataToolbox.hx @@ -104,6 +104,8 @@ class ChartEditorMetadataToolbox extends ChartEditorBaseToolbox if (event.data?.id == null) return; chartEditorState.currentSongNoteStyle = event.data.id; }; + var startingValueNoteStyle = ChartEditorDropdowns.populateDropdownWithNoteStyles(inputNoteStyle, chartEditorState.currentSongMetadata.playData.noteStyle); + inputNoteStyle.value = startingValueNoteStyle; inputBPM.onChange = function(event:UIEvent) { if (event.value == null || event.value <= 0) return; diff --git a/source/funkin/util/WindowUtil.hx b/source/funkin/util/WindowUtil.hx index 44922f4e8d..4b7406e839 100644 --- a/source/funkin/util/WindowUtil.hx +++ b/source/funkin/util/WindowUtil.hx @@ -86,6 +86,7 @@ class WindowUtil windowExit.dispatch(exitCode); }); + #if !mobile openfl.Lib.current.stage.addEventListener(openfl.events.KeyboardEvent.KEY_DOWN, (e:openfl.events.KeyboardEvent) -> { for (key in PlayerSettings.player1.controls.getKeysForAction(FULLSCREEN)) { @@ -95,6 +96,7 @@ class WindowUtil } } }); + #end } /**