From 8f2ab5c74d75e0d29e0a9910701cce8b0d7a335b Mon Sep 17 00:00:00 2001 From: Zyflx <100444522+Zyflx@users.noreply.github.com> Date: Wed, 24 May 2023 19:31:08 -0400 Subject: [PATCH] Update Paths.hx --- source/Paths.hx | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/source/Paths.hx b/source/Paths.hx index dcd1477aa..7377a33cb 100644 --- a/source/Paths.hx +++ b/source/Paths.hx @@ -5,6 +5,13 @@ import flixel.graphics.frames.FlxAtlasFrames; import openfl.utils.AssetType; import openfl.utils.Assets as OpenFlAssets; +#if sys +import sys.io.File; +import sys.FileSystem; +#end + +import openfl.utils.Assets; + class Paths { inline public static var SOUND_EXT = #if web "mp3" #else "ogg" #end; @@ -16,7 +23,7 @@ class Paths currentLevel = name.toLowerCase(); } - static function getPath(file:String, type:AssetType, library:Null) + public static function getPath(file:String, ?type:AssetType, ?library:Null) { if (library != null) return getLibraryPath(file, library); @@ -45,7 +52,7 @@ class Paths return '$library:assets/$library/$file'; } - inline static function getPreloadPath(file:String) + inline public static function getPreloadPath(file:String) { return 'assets/$file'; } @@ -85,6 +92,11 @@ class Paths return getPath('music/$key.$SOUND_EXT', MUSIC, library); } + inline static public function video(key:String) + { + return 'assets/videos/$key.mp4'; + } + inline static public function voices(song:String) { return 'songs:assets/songs/${song.toLowerCase()}/Voices.$SOUND_EXT'; @@ -114,4 +126,27 @@ class Paths { return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library)); } + + public static function fileExists(key:String) + { + if (FileSystem.exists(key)) + { + return true; + } + return false; + } + + public static function getContent(key:String) + { + #if sys + if (FileSystem.exists(key)) + { + return File.getContent(key); + } + #else + return Assets.getText(key); + #end + else + return null; + } }