Skip to content

Commit

Permalink
fix custom asset path, add _abs
Browse files Browse the repository at this point in the history
  • Loading branch information
Geokureli committed Nov 28, 2024
1 parent 2cca263 commit 71613db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
7 changes: 3 additions & 4 deletions flixel/system/frontEnds/AssetFrontEnd.hx
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ class AssetFrontEnd
public function new ()
{
final rawPath = '${haxe.macro.Compiler.getDefine("FLX_CUSTOM_ASSETS_DIRECTORY")}';
// Remove final slash and accepts backslashes and removes redundancies
directory = Path.normalize(rawPath);
directory = '${haxe.macro.Compiler.getDefine("FLX_CUSTOM_ASSETS_DIRECTORY_ABS")}';
// Verify valid directory
if (sys.FileSystem.exists(directory) == false)
throw 'Invalid value:"$directory" of FLX_CUSTOM_ASSETS_DIRECTORY, expecting relative or absolute path';
throw 'Error finding custom asset directory:"$directory" from given path: $rawPath';
// remove final "/assets" since the id typically contains it
final split = sys.FileSystem.absolutePath(directory).split("/");
final split = directory.split("/");
split.pop();
parentDirectory = split.join("/");
}
Expand Down
11 changes: 7 additions & 4 deletions flixel/system/macros/FlxDefines.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package flixel.system.macros;

import haxe.io.Path;
import haxe.macro.Compiler;
import haxe.macro.Context;
import haxe.macro.Expr.Position;
import haxe.io.Path;
#if (flixel_addons >= "3.2.2")
import flixel.addons.system.macros.FlxAddonDefines;
#end
Expand Down Expand Up @@ -98,6 +98,8 @@ private enum HelperDefines
FLX_OPENGL_AVAILABLE;
/** Defined to `1`(or `true`) if `FLX_CUSTOM_ASSETS_DIRECTORY` is not defined */
FLX_STANDARD_ASSETS_DIRECTORY;
/** The normalized, absolute path of `FLX_CUSTOM_ASSETS_DIRECTORY`, used internally */
FLX_CUSTOM_ASSETS_DIRECTORY_ABS;
}

class FlxDefines
Expand Down Expand Up @@ -283,12 +285,13 @@ class FlxDefines
// Todo: check sys targets
final rawDirectory = Path.normalize(definedValue(FLX_CUSTOM_ASSETS_DIRECTORY));
final directory = Path.normalize(rawDirectory);
final absPath = sys.FileSystem.absolutePath(directory);
if (!sys.FileSystem.isDirectory(directory) || directory == "1")
{
final absPath = sys.FileSystem.absolutePath(directory);
abort('FLX_CUSTOM_ASSETS_DIRECTORY must be a path to a directory, got "$rawDirectory"'
+ '\nabsolute path: $absPath', (macro null).pos);
}
define(FLX_CUSTOM_ASSETS_DIRECTORY_ABS, absPath);
}
}
else // define boolean inversion
Expand Down Expand Up @@ -330,9 +333,9 @@ class FlxDefines
return Context.defined(Std.string(define));
}

static inline function define(define:Dynamic)
static inline function define(define:Dynamic, ?value:String)
{
Compiler.define(Std.string(define));
Compiler.define(Std.string(define), value);
}

static function abort(message:String, pos:Position)
Expand Down

0 comments on commit 71613db

Please sign in to comment.