Skip to content

Commit

Permalink
fix notestyles & other shit
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesisfeline committed May 21, 2024
1 parent 8d02bb4 commit f824a49
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 76 deletions.
2 changes: 1 addition & 1 deletion assets
120 changes: 61 additions & 59 deletions source/funkin/FunkinWrapper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,78 @@ using StringTools;

class FunkinWrapper
{
inline public static function callMethod(o:Dynamic, func:Function, args:Array<Dynamic>):Dynamic
{
return Reflect.callMethod(o, func, args);
}
inline public static function compare<T>(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<T>(o:Null<T>):Null<T>
{
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<T>(o:T):Class<T>
{
return Type.getClass(o);
}
{
return Type.getClass(o);
}

inline public static function getClassName(c:Class<Dynamic>):String
{
return Type.getClassName(c);
}
{
return Type.getClassName(c);
}

inline public static function getEnum(o:EnumValue):Enum<Dynamic>
{
return Type.getEnum(o);
}
inline public static function getEnumName(e:Enum<Dynamic>):String
{
return Type.getEnumName(e);
}
inline public static function resolveClass(name:String):Class<Dynamic>
{
return Type.resolveClass(name);
}
inline public static function resolveEnum(name:String):Enum<Dynamic>
{
return Type.resolveEnum(name);
}
{
return Type.getEnum(o);
}

inline public static function getEnumName(e:Enum<Dynamic>):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);
}
}
1 change: 1 addition & 0 deletions source/funkin/import.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 5 additions & 4 deletions source/funkin/modding/PolymodErrorHandler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions source/funkin/modding/PolymodHandler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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, */
}
}

Expand Down
16 changes: 6 additions & 10 deletions source/funkin/play/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions source/funkin/util/WindowUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -95,6 +96,7 @@ class WindowUtil
}
}
});
#end
}

/**
Expand Down

0 comments on commit f824a49

Please sign in to comment.