Skip to content

Commit

Permalink
Merge pull request #3 from mcagabe19-stuff/ios-support
Browse files Browse the repository at this point in the history
iOS Support
  • Loading branch information
MAJigsaw77 authored May 19, 2024
2 parents 2f5636e + bf88401 commit 0c5cec0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<haxelib name="flixel-text-input" /> <!-- Improved text field rendering for HaxeUI -->
<haxelib name="polymod" /> <!-- Modding framework -->
<haxelib name="flxanimate" /> <!-- Texture atlas rendering -->
<haxelib name="hxvlc" if="desktop || android" unless="hl" /> <!-- Video playback -->
<haxelib name="hxvlc" if="desktop || mobile" unless="hl" /> <!-- Video playback -->
<haxelib name="extension-androidtools" if="android" /> <!-- Android Functions -->
<haxelib name="funkin.vis"/>

Expand Down
21 changes: 12 additions & 9 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ class Main extends Sprite

public static function main():Void
{
#if android
// Set the current working directory for Android devices
// Determine the appropriate directory based on Android version
Sys.setCwd(haxe.io.Path.addTrailingSlash(android.os.Build.VERSION.SDK_INT > 30 ? android.content.Context.getObbDir() : // Use Obb directory for Android SDK version > 30
android.content.Context.getExternalFilesDir() // Use External Files directory for Android SDK version < 30
));
#end
#if mobile
// Set the current working directory for Android and iOS devices
// For Android we determine the appropriate directory based on Android version
Sys.setCwd(#if android haxe.io.Path.addTrailingSlash(android.os.Build.VERSION.SDK_INT > 30 ?
android.content.Context.getObbDir() : // Use Obb directory for Android SDK version > 30
android.content.Context.getExternalFilesDir() // Use External Files directory for Android SDK version < 30
) #elseif ios
lime.system.System.documentsDirectory // For iOS we use documents directory and this is only way we can do
#end
);

// We need to make the crash handler LITERALLY FIRST so nothing EVER gets past it.
CrashHandler.initialize();
Expand All @@ -59,10 +62,10 @@ class Main extends Sprite
haxe.Log.trace = funkin.util.logging.AnsiTrace.trace;
funkin.util.logging.AnsiTrace.traceBF();

#if android
#if mobile
funkin.util.StorageUtil.copyNecessaryFiles(['mp4' => 'assets/videos']);
#end

// Load mods to override assets.
// TODO: Replace with loadEnabledMods() once the user can configure the mod list.
funkin.modding.PolymodHandler.loadAllMods();
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/ui/credits/CreditsDataMacro.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CreditsDataMacro
#if macro
static function fetchJSON():Null<String>
{
return sys.io.File.getContent(CreditsDataHandler.CREDITS_DATA_PATH);
return sys.io.File.getContent(#if ios '../../../../../' + #end CreditsDataHandler.CREDITS_DATA_PATH);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/util/macro/HaxelibVersions.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HaxelibVersions
{
var result:Array<String> = [];

var hmmData:Dynamic = haxe.Json.parse(sys.io.File.getContent('hmm.json'));
var hmmData:Dynamic = haxe.Json.parse(sys.io.File.getContent(#if ios '../../../../../' + #end 'hmm.json'));
var dependencies:Array<Dynamic> = cast hmmData.dependencies;
for (library in dependencies)
{
Expand Down

0 comments on commit 0c5cec0

Please sign in to comment.