Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2d86b87
WIP Android AAsets_Manager IO
KarimAkra Jan 14, 2026
37b9121
remove useless lines
KarimAkra Jan 14, 2026
23067bf
rewrite some comments
HomuHomu833 Jan 15, 2026
e0662f8
oops
HomuHomu833 Jan 15, 2026
6747665
move all c++ functions to cppNamespaceCode
KarimAkra Jan 16, 2026
4a59019
remove useless includes
KarimAkra Jan 16, 2026
5600c9d
Added getBytes and getContent (fuck you GC)
KarimAkra Jan 16, 2026
dc23e3a
`USE_OPENFL_FILESYSTEM` and move the Mobile IO class into `mobile.bac…
HomuHomu833 Jan 16, 2026
d15b15f
dum
HomuHomu833 Jan 16, 2026
0354ecc
love vscode
HomuHomu833 Jan 16, 2026
4684146
Merge branch 'main' into mobile/native-io
HomuHomu833 Jan 17, 2026
328b8d3
add final dir
HomuHomu833 Jan 18, 2026
58c5cd0
some implements to Shadow FS
HomuHomu833 Jan 18, 2026
c8ad1f0
b
HomuHomu833 Jan 18, 2026
a06c6c1
we don't need a Dynamic as last resort.
HomuHomu833 Jan 18, 2026
2ac3f11
Merge branch 'main' into mobile/native-io
HomuHomu833 Jan 18, 2026
74416b8
directory stuff and optimize getBytes
HomuHomu833 Jan 19, 2026
bef9b6f
doing old shi
HomuHomu833 Jan 19, 2026
fc09d48
alternative name for MobileData
HomuHomu833 Jan 19, 2026
9d6f7d7
Merge branch 'main' into mobile/native-io
HomuHomu833 Jan 20, 2026
d27272f
downgrade some runner versions to future proof
HomuHomu833 Jan 20, 2026
fef4e52
right
HomuHomu833 Jan 20, 2026
d93ae14
Merge branch 'main' into mobile/native-io
HomuHomu833 Jan 28, 2026
92f9ffc
use file descriptor for bytes
KarimAkra Jan 30, 2026
8cdf636
fix cresh & use file system for audio and bitmaps
KarimAkra Jan 30, 2026
52fb395
add more missing closes and gc stuff
KarimAkra Jan 30, 2026
64ff9df
Merge branch 'main' into mobile/native-io
HomuHomu833 Feb 3, 2026
42198a3
revert final dir as it's useless
HomuHomu833 Feb 3, 2026
a086e3d
Merge branch 'main' into mobile/native-io
HomuHomu833 Feb 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions project.hxp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Project extends HXProject
static final VIDEOS_ALLOWED:CompileFlag = CompileFlag.get("VIDEOS_ALLOWED");
static final DISCORD_ALLOWED:CompileFlag = CompileFlag.get("DISCORD_ALLOWED");
static final DCEBUILD:CompileFlag = CompileFlag.get("DCEBUILD");
static final USE_OPENFL_FILESYSTEM:CompileFlag = CompileFlag.get("USE_OPENFL_FILESYSTEM");

static final ENABLE_ASCII_ART:Bool = true;

Expand Down Expand Up @@ -215,6 +216,7 @@ class Project extends HXProject
VIDEOS_ALLOWED.integrate((isDesktop() && !isHashLink()) || (isMobile() && !isIOSSimulator()));
DISCORD_ALLOWED.integrate((isDesktop() && !isHashLink()));
DCEBUILD.integrate(false);
USE_OPENFL_FILESYSTEM.integrate(MODS_ALLOWED.isDisabled() && !isMobile());

setHaxedef("FLX_NO_FOCUS_LOST_SCREEN");
if (!isDebug())
Expand Down
1 change: 1 addition & 0 deletions source/engine/backend/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Main extends Sprite
#if android
StorageUtil.requestPermissions();
#end
mobile.backend.io.Assets.init();
#end
super();

Expand Down
28 changes: 20 additions & 8 deletions source/engine/backend/Paths.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package backend;

import haxe.io.Path;
import lime.media.AudioBuffer;
import flixel.graphics.frames.FlxFrame.FlxFrameAngle;
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.graphics.FlxGraphic;
Expand Down Expand Up @@ -252,18 +254,18 @@ class Paths
localTrackedAssets.push(file);
return currentTrackedAssets.get(file);
}
else if (Assets.exists(file, getImageAssetType(GPU_IMAGE_EXT)))
bitmap = Assets.getBitmapData(file);
else if (FileSystem.exists(file))
bitmap = getBitmapData(file);

if (Assets.exists(getPath('images/$key.$IMAGE_EXT', getImageAssetType(IMAGE_EXT), library), getImageAssetType(IMAGE_EXT)))
if (FileSystem.exists(getPath('images/$key.$IMAGE_EXT', getImageAssetType(IMAGE_EXT), library)))
{
file = getPath('images/$key.$IMAGE_EXT', getImageAssetType(IMAGE_EXT), library);
if (currentTrackedAssets.exists(file))
{
localTrackedAssets.push(file);
return currentTrackedAssets.get(file);
}
bitmap = Assets.getBitmapData(file);
bitmap = getBitmapData(file);
}
}

Expand All @@ -278,12 +280,22 @@ class Paths
return null;
}

static public function getBitmapData(file:String):BitmapData
{
var bytes = File.getBytes(file);
return switch (Path.extension(file)) {
case 'astc': BitmapData.fromTexture(FlxG.stage.context3D.createASTCTexture(bytes));
case 'dds': BitmapData.fromTexture(FlxG.stage.context3D.createS3TCTexture(bytes));
default: BitmapData.fromBytes(bytes);
}
}

static public function cacheBitmap(file:String, ?bitmap:BitmapData = null)
{
if (bitmap == null)
{
if (FileSystem.exists(file))
bitmap = BitmapData.fromFile(file);
bitmap = getBitmapData(file);
else
{
if (Assets.exists(file, getImageAssetType(GPU_IMAGE_EXT)))
Expand Down Expand Up @@ -478,7 +490,7 @@ class Paths
{
if (!currentTrackedSounds.exists(file))
{
currentTrackedSounds.set(file, Sound.fromFile(file));
currentTrackedSounds.set(file, Sound.fromAudioBuffer(AudioBuffer.fromBytes(File.getBytes(file))));
// trace('precached mod sound: $file');
}
localTrackedAssets.push(file);
Expand All @@ -496,8 +508,8 @@ class Paths
{
var retKey:String = (path != null) ? '$path/$key' : key;
retKey = getPath('$retKey.ogg', SOUND, library);
if (Assets.exists(retKey, SOUND))
currentTrackedSounds.set(gottenPath, Assets.getSound(retKey));
if (FileSystem.exists(retKey))
currentTrackedSounds.set(gottenPath, Sound.fromAudioBuffer(AudioBuffer.fromBytes(File.getBytes(retKey))));
}
localTrackedAssets.push(gottenPath);
return currentTrackedSounds.get(gottenPath);
Expand Down
44 changes: 34 additions & 10 deletions source/engine/backend/io/File.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package backend.io;

import openfl.Assets;
#if sys
#if USE_OPENFL_FILESYSTEM
import lime.utils.Assets as LimeAssets;
import openfl.Assets as OpenFLAssets;
#end
#if mobile
import mobile.backend.io.Assets as MobileAssets;
#end
#if (sys && MODS_ALLOWED)
import sys.FileSystem as SysFileSystem;
import sys.FileStat;
import sys.io.File as SysFile;
Expand All @@ -24,15 +30,17 @@ class File
return path;
}

#if USE_OPENFL_FILESYSTEM
static function openflcwd(path:String):String
{
@:privateAccess
for (library in lime.utils.Assets.libraries.keys())
if (Assets.exists('$library:$path') && !path.startsWith('$library:'))
for (library in LimeAssets.libraries.keys())
if (OpenFLAssets.exists('$library:$path') && !path.startsWith('$library:'))
return '$library:$path';

return path;
}
#end

public static function getContent(path:String):Null<String>
{
Expand All @@ -50,8 +58,15 @@ class File
#end
#end

if (Assets.exists(openflcwd(path)))
return Assets.getText(openflcwd(path));
#if USE_OPENFL_FILESYSTEM
if (OpenFLAssets.exists(openflcwd(path)))
return OpenFLAssets.getText(openflcwd(path));
#end

#if mobile
if (MobileAssets.exists(path))
return MobileAssets.getContent(path);
#end

return null;
}
Expand All @@ -72,14 +87,21 @@ class File
#end
#end

if (Assets.exists(openflcwd(path)))
#if USE_OPENFL_FILESYSTEM
if (OpenFLAssets.exists(openflcwd(path)))
switch (haxe.io.Path.extension(path).toLowerCase())
{
case 'otf' | 'ttf':
return openfl.utils.ByteArray.fromFile(openflcwd(path));
default:
return Assets.getBytes(openflcwd(path));
return OpenFLAssets.getBytes(openflcwd(path));
}
#end

#if mobile
if (MobileAssets.exists(path))
return MobileAssets.getBytes(path);
#end

return null;
}
Expand Down Expand Up @@ -110,9 +132,11 @@ class File
#else
return SysFile.read(cwd(path), binary);
#end
#else
return null;
#end
#if mobile
// SHADOW TODO
#end
return null;
}

public static function write(path:String, binary:Bool = true):Null<FileOutput>
Expand Down
75 changes: 61 additions & 14 deletions source/engine/backend/io/FileSystem.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package backend.io;

import openfl.Assets;
#if sys
#if USE_OPENFL_FILESYSTEM
import lime.utils.Assets as LimeAssets;
import openfl.Assets as OpenFLAssets;
#end
#if mobile
import mobile.backend.io.Assets as MobileAssets;
#end
#if (sys && MODS_ALLOWED)
import sys.FileSystem as SysFileSystem;
import sys.FileStat;
#end
Expand All @@ -23,15 +29,17 @@ class FileSystem
return path;
}

#if USE_OPENFL_FILESYSTEM
static function openflcwd(path:String):String
{
@:privateAccess
for (library in lime.utils.Assets.libraries.keys())
if (Assets.exists('$library:$path') && !path.startsWith('$library:'))
for (library in LimeAssets.libraries.keys())
if (OpenFLAssets.exists('$library:$path') && !path.startsWith('$library:'))
return '$library:$path';

return path;
}
#end

public static function exists(path:String):Bool
{
Expand All @@ -49,10 +57,17 @@ class FileSystem
#end
#end

if (Assets.exists(openflcwd(path)))
#if USE_OPENFL_FILESYSTEM
if (OpenFLAssets.exists(openflcwd(path)) || OpenFLAssets.list().filter(asset -> asset.startsWith(path) && asset != path).length > 0)
return true;
#end

#if mobile
if (MobileAssets.exists(path))
return true;
#end

return Assets.list().filter(asset -> asset.startsWith(path) && asset != path).length > 0;
return false;
}

public static function rename(path:String, newPath:String):Void
Expand Down Expand Up @@ -80,13 +95,18 @@ class FileSystem
actualPath = getCaseInsensitivePath(path);
if (actualPath == null)
actualPath = path;
return SysFileSystem.stat(actualPath);
if (SysFileSystem.exists(actualPath))
return SysFileSystem.stat(actualPath);
#else
return SysFileSystem.stat(cwd(path));
if (SysFileSystem.exists(cwd(path)))
return SysFileSystem.stat(cwd(path));
#end
#else
return null;
#end
#if mobile
if (MobileAssets.exists(path))
return MobileAssets.stat(path);
#end
return null;
}

public static function fullPath(path:String):String
Expand Down Expand Up @@ -139,7 +159,17 @@ class FileSystem
#end
#end

return Assets.list().filter(asset -> asset.startsWith(path) && asset != path).length > 0;
#if USE_OPENFL_FILESYSTEM
if (OpenFLAssets.list().filter(asset -> asset.startsWith(path) && asset != path).length > 0)
return true;
#end

#if mobile
if (MobileAssets.isDirectory(path))
return true;
#end

return false;
}

public static function createDirectory(path:String):Void
Expand Down Expand Up @@ -200,7 +230,23 @@ class FileSystem
#end
#end

var filteredList:Array<String> = Assets.list().filter(f -> f.startsWith(path));
#if USE_OPENFL_FILESYSTEM
if (OpenFLAssets.list().filter(asset -> asset.startsWith(path) && asset != path).length > 0)
return openflReadDirectory(path);
#end

#if mobile
if (MobileAssets.exists(path) && MobileAssets.isDirectory(path))
return MobileAssets.readDirectory(path);
#end

return null;
}

#if USE_OPENFL_FILESYSTEM
static function openflReadDirectory(path:String):Array<String>
{
var filteredList:Array<String> = OpenFLAssets.list().filter(f -> f.startsWith(path));
var results:Array<String> = [];
for (i in filteredList.copy())
{
Expand All @@ -214,17 +260,18 @@ class FileSystem
for (item in filteredList)
{
@:privateAccess
for (library in lime.utils.Assets.libraries.keys())
for (library in LimeAssets.libraries.keys())
{
var libPath:String = '$library:$item';
if (library != 'default' && Assets.exists(libPath) && !results.contains(libPath))
results.push(libPath);
else if (Assets.exists(item) && !results.contains(item))
else if (OpenFLAssets.exists(item) && !results.contains(item))
results.push(item);
}
}
return results.map(f -> f.substr(f.lastIndexOf("/") + 1));
}
#end

#if (linux && MODS_ALLOWED)
static function getCaseInsensitivePath(path:String):String
Expand Down
10 changes: 5 additions & 5 deletions source/engine/mobile/backend/MobileData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ class MobileData
save = new FlxSave();
save.bind('MobileControls', CoolUtil.getSavePath());

readDirectory(Paths.getSharedPath('mobile/DPadModes'), dpadModes);
readDirectory(Paths.getSharedPath('mobile/ActionModes'), actionModes);
readFilesFromDirectory(Paths.getSharedPath('mobile/DPadModes'), dpadModes);
readFilesFromDirectory(Paths.getSharedPath('mobile/ActionModes'), actionModes);
#if MODS_ALLOWED
for (folder in Mods.directoriesWithFile(Paths.getSharedPath(), 'mobile/'))
{
readDirectory(Path.join([folder, 'DPadModes']), dpadModes);
readDirectory(Path.join([folder, 'ActionModes']), actionModes);
readFilesFromDirectory(Path.join([folder, 'DPadModes']), dpadModes);
readFilesFromDirectory(Path.join([folder, 'ActionModes']), actionModes);
}
#end

Expand Down Expand Up @@ -96,7 +96,7 @@ class MobileData
return buttonsInstance;
}

public static function readDirectory(folder:String, map:Dynamic)
public static function readFilesFromDirectory(folder:String, map:Dynamic)
{
folder = folder.contains(':') ? folder.split(':')[1] : folder;

Expand Down
7 changes: 7 additions & 0 deletions source/engine/mobile/backend/io/Assets.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package mobile.backend.io;

#if android
typedef Assets = mobile.backend.io.android.Assets;
// #elseif ios
// typedef Assets = mobile.backend.io.ios.Assets;
#end
Loading