mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-09-03 20:28:04 +00:00
Compare commits
20 commits
92788e3ef5
...
0cf464cc0e
Author | SHA1 | Date | |
---|---|---|---|
|
0cf464cc0e | ||
|
d0f0974d1e | ||
|
369b936056 | ||
|
c40e1e3958 | ||
|
0ade24bac4 | ||
|
7370ef3249 | ||
|
b2f162a8ae | ||
|
11fa9b4050 | ||
|
89bd7a3f43 | ||
|
942fb5efc9 | ||
|
9894a5351e | ||
|
c2eff142bd | ||
|
2784fa18c0 | ||
|
ad07fddf89 | ||
|
4768eedd5b | ||
|
f1c3e99a11 | ||
|
eefe8927c4 | ||
|
3ff4f14510 | ||
|
955b0db542 | ||
|
d2df4f0832 |
2
.github/ISSUE_TEMPLATE/bug.yml
vendored
2
.github/ISSUE_TEMPLATE/bug.yml
vendored
|
@ -59,7 +59,7 @@ body:
|
|||
attributes:
|
||||
label: Version
|
||||
description: Which version are you playing on? The game version is in the bottom left corner of the main menu.
|
||||
placeholder: ex. 0.7.3
|
||||
placeholder: ex. 0.7.4
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
|
2
.github/ISSUE_TEMPLATE/charting.yml
vendored
2
.github/ISSUE_TEMPLATE/charting.yml
vendored
|
@ -36,7 +36,7 @@ body:
|
|||
attributes:
|
||||
label: Version
|
||||
description: Which version are you playing on? The game version is in the bottom left corner of the main menu.
|
||||
placeholder: ex. 0.7.3
|
||||
placeholder: ex. 0.7.4
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
|
2
.github/ISSUE_TEMPLATE/compiling.yml
vendored
2
.github/ISSUE_TEMPLATE/compiling.yml
vendored
|
@ -36,7 +36,7 @@ body:
|
|||
attributes:
|
||||
label: Version
|
||||
description: Which version are you compiling? The game version is in the bottom left corner of the main menu or in the project.hxp file.
|
||||
placeholder: ex. 0.7.3
|
||||
placeholder: ex. 0.7.4
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
|
2
.github/ISSUE_TEMPLATE/crash.yml
vendored
2
.github/ISSUE_TEMPLATE/crash.yml
vendored
|
@ -60,7 +60,7 @@ body:
|
|||
attributes:
|
||||
label: Version
|
||||
description: Which version are you playing on? The game version is in the bottom left corner of the main menu.
|
||||
placeholder: ex. 0.7.3
|
||||
placeholder: ex. 0.7.4
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ This section provides guidelines to follow when [opening an issue](https://githu
|
|||
|
||||
## Requirements
|
||||
Make sure you're playing:
|
||||
- the latest version of the game (currently v0.7.3)
|
||||
- the latest version of the game (currently v0.7.4)
|
||||
- without any mods
|
||||
- on [Newgrounds](https://www.newgrounds.com/portal/view/770371) or downloaded from [itch.io](https://ninja-muffin24.itch.io/funkin)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"name": "EliteMasterEric"
|
||||
}
|
||||
],
|
||||
"api_version": "0.5.0",
|
||||
"api_version": "0.7.0",
|
||||
"mod_version": "1.0.0",
|
||||
"license": "Apache-2.0"
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"name": "EliteMasterEric"
|
||||
}
|
||||
],
|
||||
"api_version": "0.5.0",
|
||||
"api_version": "0.7.0",
|
||||
"mod_version": "1.0.0",
|
||||
"license": "Apache-2.0"
|
||||
}
|
||||
|
|
156
source/funkin/api/newgrounds/NGSaveSlot.hx
Normal file
156
source/funkin/api/newgrounds/NGSaveSlot.hx
Normal file
|
@ -0,0 +1,156 @@
|
|||
package funkin.api.newgrounds;
|
||||
|
||||
#if FEATURE_NEWGROUNDS
|
||||
import io.newgrounds.utils.SaveSlotList;
|
||||
import io.newgrounds.objects.SaveSlot;
|
||||
import io.newgrounds.Call.CallError;
|
||||
import io.newgrounds.objects.events.Outcome;
|
||||
import funkin.save.Save;
|
||||
|
||||
@:nullSafety
|
||||
@:access(funkin.save.Save)
|
||||
class NGSaveSlot
|
||||
{
|
||||
public static var instance(get, never):NGSaveSlot;
|
||||
static var _instance:Null<NGSaveSlot> = null;
|
||||
|
||||
static function get_instance():NGSaveSlot
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
return loadInstance();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public static function loadInstance():NGSaveSlot
|
||||
{
|
||||
var loadedSave:NGSaveSlot = loadSlot(Save.BASE_SAVE_SLOT);
|
||||
if (_instance == null) _instance = loadedSave;
|
||||
|
||||
return loadedSave;
|
||||
}
|
||||
|
||||
static function loadSlot(slot:Int):NGSaveSlot
|
||||
{
|
||||
trace('[NEWGROUNDS] Getting save slot from ID $slot');
|
||||
|
||||
var saveSlot:Null<SaveSlot> = NewgroundsClient.instance.saveSlots?.getById(slot);
|
||||
|
||||
var saveSlotObj:NGSaveSlot = new NGSaveSlot(saveSlot);
|
||||
return saveSlotObj;
|
||||
}
|
||||
|
||||
public var ngSaveSlot:Null<SaveSlot> = null;
|
||||
|
||||
public function new(?ngSaveSlot:Null<SaveSlot>)
|
||||
{
|
||||
this.ngSaveSlot = ngSaveSlot;
|
||||
|
||||
#if FLX_DEBUG
|
||||
FlxG.console.registerClass(NGSaveSlot);
|
||||
FlxG.console.registerClass(Save);
|
||||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves `data` to the newgrounds save slot.
|
||||
* @param data The raw save data.
|
||||
*/
|
||||
public function save(data:RawSaveData):Void
|
||||
{
|
||||
var encodedData:String = haxe.Serializer.run(data);
|
||||
|
||||
try
|
||||
{
|
||||
ngSaveSlot?.save(encodedData, function(outcome:Outcome<CallError>) {
|
||||
switch (outcome)
|
||||
{
|
||||
case SUCCESS:
|
||||
trace('[NEWGROUNDS] Successfully saved save data to save slot!');
|
||||
case FAIL(error):
|
||||
trace('[NEWGROUNDS] Failed to save data to save slot!');
|
||||
trace(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error:String)
|
||||
{
|
||||
trace('[NEWGROUNDS] Failed to save data to save slot!');
|
||||
trace(error);
|
||||
}
|
||||
}
|
||||
|
||||
public function load(?onComplete:Null<Dynamic->Void>, ?onError:Null<CallError->Void>):Void
|
||||
{
|
||||
try
|
||||
{
|
||||
ngSaveSlot?.load(function(outcome:SaveSlotOutcome):Void {
|
||||
switch (outcome)
|
||||
{
|
||||
case SUCCESS(value):
|
||||
trace('[NEWGROUNDS] Loaded save slot with the ID of ${ngSaveSlot?.id}!');
|
||||
#if FEATURE_DEBUG_FUNCTIONS
|
||||
trace('Save Slot Data:');
|
||||
trace(value);
|
||||
#end
|
||||
|
||||
if (onComplete != null && value != null)
|
||||
{
|
||||
var decodedData:Dynamic = haxe.Unserializer.run(value);
|
||||
onComplete(decodedData);
|
||||
}
|
||||
case FAIL(error):
|
||||
trace('[NEWGROUNDS] Failed to load save slot with the ID of ${ngSaveSlot?.id}!');
|
||||
trace(error);
|
||||
|
||||
if (onError != null)
|
||||
{
|
||||
onError(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error:String)
|
||||
{
|
||||
trace('[NEWGROUNDS] Failed to load save slot with the ID of ${ngSaveSlot?.id}!');
|
||||
trace(error);
|
||||
|
||||
if (onError != null)
|
||||
{
|
||||
onError(RESPONSE({message: error, code: 500}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function clear():Void
|
||||
{
|
||||
try
|
||||
{
|
||||
ngSaveSlot?.clear(function(outcome:Outcome<CallError>) {
|
||||
switch (outcome)
|
||||
{
|
||||
case SUCCESS:
|
||||
trace('[NEWGROUNDS] Successfully cleared save slot!');
|
||||
case FAIL(error):
|
||||
trace('[NEWGROUNDS] Failed to clear save slot!');
|
||||
trace(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error:String)
|
||||
{
|
||||
trace('[NEWGROUNDS] Failed to clear save slot!');
|
||||
trace(error);
|
||||
}
|
||||
}
|
||||
|
||||
public function checkSlot():Void
|
||||
{
|
||||
trace('[NEWGROUNDS] Checking save slot with the ID of ${ngSaveSlot?.id}...');
|
||||
|
||||
trace(' Is null? ${ngSaveSlot == null}');
|
||||
trace(' Is empty? ${ngSaveSlot?.isEmpty() ?? false}');
|
||||
}
|
||||
}
|
||||
#end
|
|
@ -10,6 +10,7 @@ import io.newgrounds.NGLite.LoginOutcome;
|
|||
import io.newgrounds.NGLite.LoginFail;
|
||||
import io.newgrounds.objects.events.Outcome;
|
||||
import io.newgrounds.utils.MedalList;
|
||||
import io.newgrounds.utils.SaveSlotList;
|
||||
import io.newgrounds.utils.ScoreBoardList;
|
||||
import io.newgrounds.objects.User;
|
||||
|
||||
|
@ -29,6 +30,7 @@ class NewgroundsClient
|
|||
public var user(get, never):Null<User>;
|
||||
public var medals(get, never):Null<MedalList>;
|
||||
public var leaderboards(get, never):Null<ScoreBoardList>;
|
||||
public var saveSlots(get, never):Null<SaveSlotList>;
|
||||
|
||||
private function new()
|
||||
{
|
||||
|
@ -236,6 +238,8 @@ class NewgroundsClient
|
|||
|
||||
trace('[NEWGROUNDS] Submitting leaderboard request...');
|
||||
NG.core.scoreBoards.loadList(onFetchedLeaderboards);
|
||||
trace('[NEWGROUNDS] Submitting save slot request...');
|
||||
NG.core.saveSlots.loadList(onFetchedSaveSlots);
|
||||
}
|
||||
|
||||
function onLoginFailed(result:LoginFail):Void
|
||||
|
@ -301,6 +305,13 @@ class NewgroundsClient
|
|||
// trace(funkin.api.newgrounds.Leaderboards.listLeaderboardData());
|
||||
}
|
||||
|
||||
function onFetchedSaveSlots(outcome:Outcome<CallError>):Void
|
||||
{
|
||||
trace('[NEWGROUNDS] Fetched save slots!');
|
||||
|
||||
NGSaveSlot.instance.checkSlot();
|
||||
}
|
||||
|
||||
function get_user():Null<User>
|
||||
{
|
||||
if (NG.core == null || !this.isLoggedIn()) return null;
|
||||
|
@ -319,6 +330,12 @@ class NewgroundsClient
|
|||
return NG.core.scoreBoards;
|
||||
}
|
||||
|
||||
function get_saveSlots():Null<SaveSlotList>
|
||||
{
|
||||
if (NG.core == null || !this.isLoggedIn()) return null;
|
||||
return NG.core.saveSlots;
|
||||
}
|
||||
|
||||
static function getSessionId():Null<String>
|
||||
{
|
||||
#if js
|
||||
|
|
|
@ -249,198 +249,171 @@ class PolymodHandler
|
|||
static function buildImports():Void
|
||||
{
|
||||
// Add default imports for common classes.
|
||||
Polymod.addDefaultImport(funkin.Assets);
|
||||
Polymod.addDefaultImport(funkin.Paths);
|
||||
final IMPORT_DEFAULTS:Array<Class<Dynamic>> = [
|
||||
funkin.Assets,
|
||||
funkin.Conductor,
|
||||
funkin.Paths,
|
||||
funkin.modding.module.ModuleHandler,
|
||||
funkin.play.PlayState
|
||||
];
|
||||
|
||||
for (cls in IMPORT_DEFAULTS) Polymod.addDefaultImport(cls);
|
||||
|
||||
// Add import aliases for certain classes.
|
||||
// NOTE: Scripted classes are automatically aliased to their parent class.
|
||||
Polymod.addImportAlias('flixel.math.FlxPoint', flixel.math.FlxPoint.FlxBasePoint);
|
||||
final IMPORT_ALIASES:Map<String, Class<Dynamic>> = [
|
||||
'flixel.math.FlxPoint' => flixel.math.FlxPoint.FlxBasePoint,
|
||||
|
||||
Polymod.addImportAlias('funkin.data.event.SongEventSchema', funkin.data.event.SongEventSchema.SongEventSchemaRaw);
|
||||
'funkin.data.event.SongEventSchema' => funkin.data.event.SongEventSchema.SongEventSchemaRaw,
|
||||
|
||||
// `lime.utils.Assets` literally just has a private `resolveClass` function for some reason? so we replace it with our own.
|
||||
Polymod.addImportAlias('lime.utils.Assets', funkin.Assets);
|
||||
Polymod.addImportAlias('openfl.utils.Assets', funkin.Assets);
|
||||
// `lime.utils.Assets` literally just has a private `resolveClass` function for some reason? so we replace it with our own.
|
||||
'lime.utils.Assets' => funkin.Assets,
|
||||
'openfl.utils.Assets' => funkin.Assets,
|
||||
|
||||
// Backward compatibility for certain scripted classes outside `funkin.modding.base`.
|
||||
Polymod.addImportAlias('funkin.modding.base.ScriptedFunkinSprite', funkin.graphics.ScriptedFunkinSprite);
|
||||
Polymod.addImportAlias('funkin.modding.base.ScriptedMusicBeatState', funkin.ui.ScriptedMusicBeatState);
|
||||
Polymod.addImportAlias('funkin.modding.base.ScriptedMusicBeatSubState', funkin.ui.ScriptedMusicBeatSubState);
|
||||
// Backward compatibility for certain scripted classes outside `funkin.modding.base`.
|
||||
'funkin.modding.base.ScriptedFunkinSprite' => funkin.graphics.ScriptedFunkinSprite,
|
||||
'funkin.modding.base.ScriptedMusicBeatState' => funkin.ui.ScriptedMusicBeatState,
|
||||
'funkin.modding.base.ScriptedMusicBeatSubState' => funkin.ui.ScriptedMusicBeatSubState,
|
||||
|
||||
// `funkin.util.FileUtil` has unrestricted access to the file system.
|
||||
Polymod.addImportAlias('funkin.util.FileUtil', funkin.util.FileUtilSandboxed);
|
||||
// `funkin.util.FileUtil` has unrestricted access to the file system.
|
||||
'funkin.util.FileUtil' => funkin.util.FileUtilSandboxed,
|
||||
|
||||
#if FEATURE_NEWGROUNDS
|
||||
// `funkin.api.newgrounds.Leaderboards` allows for submitting cheated scores.
|
||||
// We still grant read-only access.
|
||||
Polymod.addImportAlias('funkin.api.newgrounds.Leaderboards', funkin.api.newgrounds.Leaderboards.LeaderboardsSandboxed);
|
||||
#if FEATURE_NEWGROUNDS
|
||||
// `funkin.api.newgrounds.Leaderboards` allows for submitting cheated scores.
|
||||
// We still grant read-only access.
|
||||
'funkin.api.newgrounds.Leaderboards' => funkin.api.newgrounds.Leaderboards.LeaderboardsSandboxed,
|
||||
|
||||
// `funkin.api.newgrounds.Medals` allows for unfair granting of medals.
|
||||
// We still grant read-only access.
|
||||
Polymod.addImportAlias('funkin.api.newgrounds.Medals', funkin.api.newgrounds.Medals.MedalsSandboxed);
|
||||
// `funkin.api.newgrounds.Medals` allows for unfair granting of medals.
|
||||
// We still grant read-only access.
|
||||
'funkin.api.newgrounds.Medals' => funkin.api.newgrounds.Medals.MedalsSandboxed,
|
||||
|
||||
// `funkin.api.newgrounds.NewgroundsClientSandboxed` allows for submitting cheated data.
|
||||
// We still grant read-only access.
|
||||
Polymod.addImportAlias('funkin.api.newgrounds.NewgroundsClient', funkin.api.newgrounds.NewgroundsClient.NewgroundsClientSandboxed);
|
||||
#end
|
||||
// `funkin.api.newgrounds.NewgroundsClientSandboxed` allows for submitting cheated data.
|
||||
// We still grant read-only access.
|
||||
'funkin.api.newgrounds.NewgroundsClient' => funkin.api.newgrounds.NewgroundsClient.NewgroundsClientSandboxed,
|
||||
#end
|
||||
|
||||
Polymod.addImportAlias('funkin.api.discord.DiscordClient', funkin.api.discord.DiscordClient.DiscordClientSandboxed);
|
||||
'funkin.api.discord.DiscordClient' => funkin.api.discord.DiscordClient.DiscordClientSandboxed,
|
||||
|
||||
// `Reflect`
|
||||
// Reflect.callMethod() can access blacklisted packages, but some functions are whitelisted
|
||||
'Reflect' => funkin.util.ReflectUtil,
|
||||
|
||||
// `Type`
|
||||
// Type.createInstance(Type.resolveClass()) can access blacklisted packages, but some functions are whitelisted
|
||||
'Type' => funkin.util.ReflectUtil
|
||||
];
|
||||
|
||||
for (className => cls in IMPORT_ALIASES) Polymod.addImportAlias(className, cls);
|
||||
|
||||
// Add blacklisting for prohibited classes and packages.
|
||||
final IMPORT_BLACKLIST:Array<String> = [
|
||||
// `Sys`
|
||||
// Sys.command() can run malicious processes
|
||||
'Sys',
|
||||
|
||||
// `Sys`
|
||||
// Sys.command() can run malicious processes
|
||||
Polymod.blacklistImport('Sys');
|
||||
// `cpp.Lib`
|
||||
// Lib.load() can load malicious DLLs
|
||||
'cpp.Lib',
|
||||
|
||||
// `Reflect`
|
||||
// Reflect.callMethod() can access blacklisted packages, but some functions are whitelisted
|
||||
Polymod.addImportAlias('Reflect', funkin.util.ReflectUtil);
|
||||
// `haxe.Unserializer`
|
||||
// Unserializer.DEFAULT_RESOLVER.resolveClass() can access blacklisted packages
|
||||
'haxe.Unserializer',
|
||||
|
||||
// `Type`
|
||||
// Type.createInstance(Type.resolveClass()) can access blacklisted packages, but some functions are whitelisted
|
||||
Polymod.addImportAlias('Type', funkin.util.ReflectUtil);
|
||||
// `flixel.util.FlxSave`
|
||||
// FlxSave.resolveFlixelClasses() can access blacklisted packages
|
||||
'flixel.util.FlxSave',
|
||||
|
||||
// `cpp.Lib`
|
||||
// Lib.load() can load malicious DLLs
|
||||
Polymod.blacklistImport('cpp.Lib');
|
||||
// Disable access to AdMob Util
|
||||
'funkin.mobile.util.AdMobUtil',
|
||||
|
||||
// `haxe.Unserializer`
|
||||
// Unserializer.DEFAULT_RESOLVER.resolveClass() can access blacklisted packages
|
||||
Polymod.blacklistImport('haxe.Unserializer');
|
||||
// Disable access to In-App Purchases Util
|
||||
'funkin.mobile.util.InAppPurchasesUtil',
|
||||
|
||||
// `flixel.util.FlxSave`
|
||||
// FlxSave.resolveFlixelClasses() can access blacklisted packages
|
||||
Polymod.blacklistImport('flixel.util.FlxSave');
|
||||
// `lime.system.CFFI`
|
||||
// Can load and execute compiled binaries.
|
||||
'lime.system.CFFI',
|
||||
|
||||
// Disable access to AdMob Util
|
||||
Polymod.blacklistImport('funkin.mobile.util.AdMobUtil');
|
||||
// `lime.system.JNI`
|
||||
// Can load and execute compiled binaries.
|
||||
'lime.system.JNI',
|
||||
|
||||
// Disable access to In-App Purchases Util
|
||||
Polymod.blacklistImport('funkin.mobile.util.InAppPurchasesUtil');
|
||||
// `lime.system.System`
|
||||
// System.load() can load malicious DLLs
|
||||
'lime.system.System',
|
||||
|
||||
// Disable access to Admob Extension
|
||||
for (cls in ClassMacro.listClassesInPackage('extension.admob'))
|
||||
// `lime.utils.Assets`
|
||||
// Literally just has a private `resolveClass` function for some reason?
|
||||
'lime.utils.Assets',
|
||||
'openfl.utils.Assets',
|
||||
'openfl.Lib',
|
||||
'openfl.system.ApplicationDomain',
|
||||
'openfl.net.SharedObject',
|
||||
|
||||
// `openfl.desktop.NativeProcess`
|
||||
// Can load native processes on the host operating system.
|
||||
'openfl.desktop.NativeProcess',
|
||||
|
||||
// Contains critical private environment variables.
|
||||
'funkin.util.macro.EnvironmentConfigMacro',
|
||||
|
||||
// `sys.FileSystem`
|
||||
// Access to the file system.
|
||||
'sys.FileSystem'
|
||||
];
|
||||
|
||||
final IMPORT_BLACKLIST_PACKAGES:Array<List<Class<Dynamic>>> = [
|
||||
// Disable access to Admob Extension
|
||||
ClassMacro.listClassesInPackage('extension.admob'),
|
||||
|
||||
// Disable access to AndroidTools Extension
|
||||
ClassMacro.listClassesInPackage('extension.androidtools'),
|
||||
|
||||
// Disable access to IAPCore Extension
|
||||
ClassMacro.listClassesInPackage('extension.iapcore'),
|
||||
|
||||
// Disable access to Haptics Extension
|
||||
ClassMacro.listClassesInPackage('extension.haptics'),
|
||||
|
||||
// `funkin.api.*`
|
||||
// Contains functions which may allow for cheating and such.
|
||||
ClassMacro.listClassesInPackage('funkin.api'),
|
||||
|
||||
// `polymod.*`
|
||||
// Contains functions which may allow for un-blacklisting other modules.
|
||||
ClassMacro.listClassesInPackage('polymod'),
|
||||
|
||||
// `hscript.*`
|
||||
// Contains functions which may allow for interpreting unsanitized strings.
|
||||
ClassMacro.listClassesInPackage('hscript'),
|
||||
|
||||
// `funkin.api.newgrounds.*`
|
||||
// Contains functions which allow for cheating medals and leaderboards.
|
||||
ClassMacro.listClassesInPackage('funkin.api.newgrounds'),
|
||||
|
||||
// `io.newgrounds.*`
|
||||
// Contains functions which allow for cheating medals and leaderboards.
|
||||
ClassMacro.listClassesInPackage('io.newgrounds'),
|
||||
|
||||
// `sys.io.*`
|
||||
// Access to the file system as well as `Process` which can run malicious processes.
|
||||
ClassMacro.listClassesInPackage('sys.io'),
|
||||
|
||||
// `funkin.util.macro.*`
|
||||
// CompiledClassList's get function allows access to sys and Newgrounds classes
|
||||
// None of the classes are suitable for mods anyway
|
||||
ClassMacro.listClassesInPackage('funkin.util.macro')
|
||||
];
|
||||
|
||||
for (packageClasses in IMPORT_BLACKLIST_PACKAGES)
|
||||
{
|
||||
if (cls == null) continue;
|
||||
var className:String = Type.getClassName(cls);
|
||||
Polymod.blacklistImport(className);
|
||||
for (cls in packageClasses)
|
||||
{
|
||||
if (cls == null) continue;
|
||||
Polymod.blacklistImport(Type.getClassName(cls));
|
||||
}
|
||||
}
|
||||
|
||||
// Disable access to AndroidTools Extension
|
||||
for (cls in ClassMacro.listClassesInPackage('extension.androidtools'))
|
||||
{
|
||||
if (cls == null) continue;
|
||||
var className:String = Type.getClassName(cls);
|
||||
Polymod.blacklistImport(className);
|
||||
}
|
||||
|
||||
// Disable access to IAPCore Extension
|
||||
for (cls in ClassMacro.listClassesInPackage('extension.iapcore'))
|
||||
{
|
||||
if (cls == null) continue;
|
||||
var className:String = Type.getClassName(cls);
|
||||
Polymod.blacklistImport(className);
|
||||
}
|
||||
|
||||
// Disable access to Haptics Extension
|
||||
for (cls in ClassMacro.listClassesInPackage('extension.haptics'))
|
||||
{
|
||||
if (cls == null) continue;
|
||||
var className:String = Type.getClassName(cls);
|
||||
Polymod.blacklistImport(className);
|
||||
}
|
||||
|
||||
// `lime.system.CFFI`
|
||||
// Can load and execute compiled binaries.
|
||||
Polymod.blacklistImport('lime.system.CFFI');
|
||||
|
||||
// `lime.system.JNI`
|
||||
// Can load and execute compiled binaries.
|
||||
Polymod.blacklistImport('lime.system.JNI');
|
||||
|
||||
// `lime.system.System`
|
||||
// System.load() can load malicious DLLs
|
||||
Polymod.blacklistImport('lime.system.System');
|
||||
|
||||
// `lime.utils.Assets`
|
||||
// Literally just has a private `resolveClass` function for some reason?
|
||||
Polymod.blacklistImport('lime.utils.Assets');
|
||||
Polymod.blacklistImport('openfl.utils.Assets');
|
||||
Polymod.blacklistImport('openfl.Lib');
|
||||
Polymod.blacklistImport('openfl.system.ApplicationDomain');
|
||||
Polymod.blacklistImport('openfl.net.SharedObject');
|
||||
|
||||
// `openfl.desktop.NativeProcess`
|
||||
// Can load native processes on the host operating system.
|
||||
Polymod.blacklistImport('openfl.desktop.NativeProcess');
|
||||
|
||||
// Contains critical private environment variables.
|
||||
Polymod.blacklistImport('funkin.util.macro.EnvironmentConfigMacro');
|
||||
|
||||
// `funkin.api.*`
|
||||
// Contains functions which may allow for cheating and such.
|
||||
for (cls in ClassMacro.listClassesInPackage('funkin.api'))
|
||||
{
|
||||
if (cls == null) continue;
|
||||
var className:String = Type.getClassName(cls);
|
||||
if (polymod.hscript._internal.PolymodScriptClass.importOverrides.exists(className)) continue;
|
||||
Polymod.blacklistImport(className);
|
||||
}
|
||||
|
||||
// `polymod.*`
|
||||
// Contains functions which may allow for un-blacklisting other modules.
|
||||
for (cls in ClassMacro.listClassesInPackage('polymod'))
|
||||
{
|
||||
if (cls == null) continue;
|
||||
var className:String = Type.getClassName(cls);
|
||||
Polymod.blacklistImport(className);
|
||||
}
|
||||
|
||||
// `hscript.*
|
||||
// Contains functions which may allow for interpreting unsanitized strings.
|
||||
for (cls in ClassMacro.listClassesInPackage('hscript'))
|
||||
{
|
||||
if (cls == null) continue;
|
||||
var className:String = Type.getClassName(cls);
|
||||
Polymod.blacklistImport(className);
|
||||
}
|
||||
|
||||
// `funkin.api.newgrounds.*`
|
||||
// Contains functions which allow for cheating medals and leaderboards.
|
||||
for (cls in ClassMacro.listClassesInPackage('funkin.api.newgrounds'))
|
||||
{
|
||||
if (cls == null) continue;
|
||||
var className:String = Type.getClassName(cls);
|
||||
Polymod.blacklistImport(className);
|
||||
}
|
||||
|
||||
// `io.newgrounds.*`
|
||||
// Contains functions which allow for cheating medals and leaderboards.
|
||||
for (cls in ClassMacro.listClassesInPackage('io.newgrounds'))
|
||||
{
|
||||
if (cls == null) continue;
|
||||
var className:String = Type.getClassName(cls);
|
||||
Polymod.blacklistImport(className);
|
||||
}
|
||||
|
||||
// `sys.*`
|
||||
// Access to system utilities such as the file system.
|
||||
for (cls in ClassMacro.listClassesInPackage('sys'))
|
||||
{
|
||||
if (cls == null) continue;
|
||||
var className:String = Type.getClassName(cls);
|
||||
Polymod.blacklistImport(className);
|
||||
}
|
||||
|
||||
// `funkin.util.macro.*`
|
||||
// CompiledClassList's get function allows access to sys and Newgrounds classes
|
||||
// None of the classes are suitable for mods anyway
|
||||
for (cls in ClassMacro.listClassesInPackage('funkin.util.macro'))
|
||||
{
|
||||
if (cls == null) continue;
|
||||
var className:String = Type.getClassName(cls);
|
||||
Polymod.blacklistImport(className);
|
||||
}
|
||||
for (className in IMPORT_BLACKLIST) Polymod.blacklistImport(className);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1356,6 +1356,45 @@ class Save
|
|||
{
|
||||
FileUtil.saveFile(haxe.io.Bytes.ofString(this.serialize()), [FileUtil.FILE_FILTER_JSON], null, null, './save.json', 'Write save data as JSON...');
|
||||
}
|
||||
|
||||
#if FEATURE_NEWGROUNDS
|
||||
public static function saveToNewgrounds():Void
|
||||
{
|
||||
if (_instance == null) return;
|
||||
trace('[SAVE] Saving Save Data to Newgrounds...');
|
||||
funkin.api.newgrounds.NGSaveSlot.instance.save(_instance.data);
|
||||
}
|
||||
|
||||
public static function loadFromNewgrounds(onFinish:Void->Void):Void
|
||||
{
|
||||
trace('[SAVE] Loading Save Data from Newgrounds...');
|
||||
funkin.api.newgrounds.NGSaveSlot.instance.load(function(data:Dynamic) {
|
||||
FlxG.save.bind('$SAVE_NAME${BASE_SAVE_SLOT}', SAVE_PATH);
|
||||
|
||||
if (FlxG.save.status != EMPTY)
|
||||
{
|
||||
// best i can do in case the NG file is corrupted or something along those lines
|
||||
var backupSlot:Int = Save.archiveBadSaveData(FlxG.save.data);
|
||||
trace('[SAVE] Backed up current save data in case of emergency to $backupSlot!');
|
||||
}
|
||||
|
||||
FlxG.save.erase();
|
||||
FlxG.save.bind('$SAVE_NAME${BASE_SAVE_SLOT}', SAVE_PATH); // forces regeneration of the file as erase deletes it
|
||||
|
||||
var gameSave = SaveDataMigrator.migrate(data);
|
||||
FlxG.save.mergeData(gameSave.data, true);
|
||||
_instance = gameSave;
|
||||
onFinish();
|
||||
}, function(error:io.newgrounds.Call.CallError) {
|
||||
var errorMsg:String = io.newgrounds.Call.CallErrorTools.toString(error);
|
||||
|
||||
var msg = 'There was an error loading your save data from Newgrounds.';
|
||||
msg += '\n${errorMsg}';
|
||||
msg += '\nAre you sure you are connected to the internet?';
|
||||
lime.app.Application.current.window.alert(msg, "Newgrounds Save Slot Failure");
|
||||
});
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,7 +69,8 @@ class OptionsState extends MusicBeatState
|
|||
optionsCodex = new Codex<OptionsMenuPageName>(Options);
|
||||
add(optionsCodex);
|
||||
|
||||
var options:OptionsMenu = optionsCodex.addPage(Options, new OptionsMenu());
|
||||
var saveData:SaveDataMenu = optionsCodex.addPage(SaveData, new SaveDataMenu());
|
||||
var options:OptionsMenu = optionsCodex.addPage(Options, new OptionsMenu(saveData));
|
||||
var preferences:PreferencesMenu = optionsCodex.addPage(Preferences, new PreferencesMenu());
|
||||
var controls:ControlsMenu = optionsCodex.addPage(Controls, new ControlsMenu());
|
||||
#if FEATURE_INPUT_OFFSETS
|
||||
|
@ -84,6 +85,7 @@ class OptionsState extends MusicBeatState
|
|||
#if FEATURE_INPUT_OFFSETS
|
||||
offsets.onExit.add(exitOffsets);
|
||||
#end
|
||||
saveData.onExit.add(optionsCodex.switchPage.bind(Options));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -159,7 +161,7 @@ class OptionsMenu extends Page<OptionsMenuPageName>
|
|||
|
||||
final CAMERA_MARGIN:Int = 150;
|
||||
|
||||
public function new()
|
||||
public function new(saveDataMenu:SaveDataMenu)
|
||||
{
|
||||
super();
|
||||
add(items = new TextMenuList());
|
||||
|
@ -227,9 +229,19 @@ class OptionsMenu extends Page<OptionsMenuPageName>
|
|||
});
|
||||
}
|
||||
#end
|
||||
createItem("CLEAR SAVE DATA", function() {
|
||||
promptClearSaveData();
|
||||
});
|
||||
|
||||
// no need to show an entire new menu for just one option
|
||||
if (saveDataMenu.hasMultipleOptions())
|
||||
{
|
||||
createItem("SAVE DATA OPTIONS", function() {
|
||||
codex.switchPage(SaveData);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
createItem("CLEAR SAVE DATA", saveDataMenu.openSaveDataPrompt);
|
||||
}
|
||||
|
||||
#if NO_FEATURE_TOUCH_CONTROLS
|
||||
createItem("EXIT", exit);
|
||||
#else
|
||||
|
@ -277,7 +289,6 @@ class OptionsMenu extends Page<OptionsMenuPageName>
|
|||
|
||||
override function update(elapsed:Float):Void
|
||||
{
|
||||
enabled = (prompt == null);
|
||||
#if FEATURE_TOUCH_CONTROLS
|
||||
backButton.active = (!goingBack) ? !items.busy : true;
|
||||
#end
|
||||
|
@ -298,31 +309,6 @@ class OptionsMenu extends Page<OptionsMenuPageName>
|
|||
{
|
||||
return items.length > 2;
|
||||
}
|
||||
|
||||
var prompt:Prompt;
|
||||
|
||||
function promptClearSaveData():Void
|
||||
{
|
||||
if (prompt != null) return;
|
||||
prompt = new Prompt("This will delete
|
||||
\nALL your save data.
|
||||
\nAre you sure?
|
||||
", Custom("Delete", "Cancel"));
|
||||
prompt.create();
|
||||
prompt.createBgFromMargin(100, 0xFFFAFD6D);
|
||||
prompt.back.scrollFactor.set(0, 0);
|
||||
add(prompt);
|
||||
prompt.onYes = function() {
|
||||
// Clear the save data.
|
||||
funkin.save.Save.clearData();
|
||||
FlxG.switchState(() -> new funkin.InitState());
|
||||
};
|
||||
prompt.onNo = function() {
|
||||
prompt.close();
|
||||
prompt.destroy();
|
||||
prompt = null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
enum abstract OptionsMenuPageName(String) to PageName
|
||||
|
@ -333,4 +319,5 @@ enum abstract OptionsMenuPageName(String) to PageName
|
|||
var Mods = "mods";
|
||||
var Preferences = "preferences";
|
||||
var Offsets = "offsets";
|
||||
var SaveData = "saveData";
|
||||
}
|
||||
|
|
125
source/funkin/ui/options/SaveDataMenu.hx
Normal file
125
source/funkin/ui/options/SaveDataMenu.hx
Normal file
|
@ -0,0 +1,125 @@
|
|||
package funkin.ui.options;
|
||||
|
||||
#if FEATURE_NEWGROUNDS
|
||||
import funkin.api.newgrounds.NewgroundsClient;
|
||||
#end
|
||||
import funkin.save.Save;
|
||||
|
||||
class SaveDataMenu extends Page<OptionsState.OptionsMenuPageName>
|
||||
{
|
||||
var items:TextMenuList;
|
||||
|
||||
public function new()
|
||||
{
|
||||
super();
|
||||
|
||||
add(items = new TextMenuList());
|
||||
|
||||
createItem("CLEAR SAVE DATA", openSaveDataPrompt);
|
||||
|
||||
#if FEATURE_NEWGROUNDS
|
||||
if (NewgroundsClient.instance.isLoggedIn())
|
||||
{
|
||||
createItem("LOAD FROM NG", function() {
|
||||
openConfirmPrompt("This will overwrite
|
||||
\nALL your save data.
|
||||
\nAre you sure?
|
||||
", "Overwrite", function() {
|
||||
Save.loadFromNewgrounds(function() {
|
||||
FlxG.switchState(() -> new funkin.InitState());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
createItem("SAVE TO NG", function() {
|
||||
openConfirmPrompt("This will overwrite
|
||||
\nALL save data saved
|
||||
\non NG. Are you sure?", "Overwrite", function() {
|
||||
Save.saveToNewgrounds();
|
||||
});
|
||||
});
|
||||
|
||||
createItem("CLEAR NG SAVE DATA", function() {
|
||||
openConfirmPrompt("This will delete
|
||||
\nALL save data saved
|
||||
\non NG. Are you sure?", "Delete", function() {
|
||||
funkin.api.newgrounds.NGSaveSlot.instance.clear();
|
||||
});
|
||||
});
|
||||
}
|
||||
#end
|
||||
|
||||
createItem("EXIT", exit);
|
||||
}
|
||||
|
||||
function createItem(name:String, callback:Void->Void, fireInstantly = false)
|
||||
{
|
||||
var item = items.createItem(0, 100 + items.length * 100, name, BOLD, callback);
|
||||
item.fireInstantly = fireInstantly;
|
||||
item.screenCenter(X);
|
||||
return item;
|
||||
}
|
||||
|
||||
override function update(elapsed:Float)
|
||||
{
|
||||
enabled = (prompt == null);
|
||||
super.update(elapsed);
|
||||
}
|
||||
|
||||
override function set_enabled(value:Bool)
|
||||
{
|
||||
items.enabled = value;
|
||||
return super.set_enabled(value);
|
||||
}
|
||||
|
||||
var prompt:Prompt;
|
||||
|
||||
function openConfirmPrompt(text:String, yesText:String, onYes:Void->Void, ?groupToOpenOn:Null<flixel.group.FlxGroup>):Void
|
||||
{
|
||||
if (prompt != null) return;
|
||||
|
||||
prompt = new Prompt(text, Custom(yesText, "Cancel"));
|
||||
prompt.create();
|
||||
prompt.createBgFromMargin(100, 0xFFFAFD6D);
|
||||
prompt.back.scrollFactor.set(0, 0);
|
||||
FlxG.state.add(prompt);
|
||||
|
||||
prompt.onYes = function() {
|
||||
onYes();
|
||||
|
||||
if (prompt != null)
|
||||
{
|
||||
prompt.close();
|
||||
prompt.destroy();
|
||||
prompt = null;
|
||||
}
|
||||
};
|
||||
|
||||
prompt.onNo = function() {
|
||||
prompt.close();
|
||||
prompt.destroy();
|
||||
prompt = null;
|
||||
}
|
||||
}
|
||||
public function openSaveDataPrompt()
|
||||
{
|
||||
openConfirmPrompt("This will delete
|
||||
\nALL your save data.
|
||||
\nAre you sure?
|
||||
", "Delete", function() {
|
||||
// Clear the save data.
|
||||
Save.clearData();
|
||||
|
||||
FlxG.switchState(() -> new funkin.InitState());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* True if this page has multiple options, excluding the exit option.
|
||||
* If false, there's no reason to ever show this page.
|
||||
*/
|
||||
public function hasMultipleOptions():Bool
|
||||
{
|
||||
return items.length > 2;
|
||||
}
|
||||
}
|
|
@ -102,12 +102,19 @@ class WindowUtil
|
|||
*/
|
||||
public static final windowExit:FlxTypedSignal<Int->Void> = new FlxTypedSignal<Int->Void>();
|
||||
|
||||
/**
|
||||
* Has `initWindowEvents()` been called already?
|
||||
* This is to prevent multiple instances of the same function.
|
||||
*/
|
||||
private static var _initializedWindowEvents:Bool = false;
|
||||
|
||||
/**
|
||||
* Wires up FlxSignals that happen based on window activity.
|
||||
* For example, we can run a callback when the window is closed.
|
||||
*/
|
||||
public static function initWindowEvents():Void
|
||||
{
|
||||
if (_initializedWindowEvents) return; // Fix that annoying
|
||||
// onUpdate is called every frame just before rendering.
|
||||
|
||||
// onExit is called when the game window is closed.
|
||||
|
@ -137,6 +144,7 @@ class WindowUtil
|
|||
}
|
||||
});
|
||||
#end
|
||||
_initializedWindowEvents = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue