@@ -182,11 +182,27 @@ class Paths
182182 }
183183 }
184184
185+ public static function clearStoredWithoutStickers () {
186+ @:privateAccess
187+ var cache = FlxG .bitmap ._cache ;
188+ Paths .currentTrackedAssets .clear ();
189+ for (key => val in cache ){
190+ if ( key .toLowerCase ().contains (" transitionswag" ) ||
191+ key .contains (" bg_graphic_" ) ||
192+ key == " images/justBf.png"
193+ ) Paths .currentTrackedAssets .set (key ,val );
194+ else cache .remove (key );
195+ }
196+ Paths .clearStoredMemory ();
197+ }
198+
199+ // The "If All Else Fails" option
185200 public static function nukeMemory (){
186201 freeGraphicsFromMemory ();
187202 clearUnusedMemory ();
188203 clearStoredMemory ();
189204 currentTrackedSounds .clear ();
205+ backend.util. MemoryUtilBase .collect (true );
190206 }
191207
192208 /** returns a FlxRuntimeShader but with file names lol **/
@@ -967,4 +983,45 @@ class Paths
967983 return false ;
968984 return OpenFlAssets .exists (path , AssetType .IMAGE );
969985 }
986+
987+ public static inline function getContent (path : String ) {
988+ #if sys
989+ return (FileSystem .exists (path )) ? File .getContent (path ) : null ;
990+ #else
991+ return (OpenFlAssets .exists (path , TEXT )) ? Assets .getText (path ) : null ;
992+ #end
993+ }
994+
995+ public static function readDirectory (directory : String ): Array <String >
996+ {
997+ #if MODS_ALLOWED
998+ return FileSystem .readDirectory (directory );
999+ #else
1000+ var dirs : Array <String > = [];
1001+ for (dir in Assets .list ().filter (folder -> folder .startsWith (directory )))
1002+ {
1003+ @:privateAccess
1004+ for (library in lime.utils. Assets .libraries .keys ())
1005+ {
1006+ if (library != ' default' && Assets .exists (' $library : $dir ' ) && (! dirs .contains (' $library : $dir ' ) || ! dirs .contains (dir )))
1007+ dirs .push (' $library : $dir ' );
1008+ else if (Assets .exists (dir ) && ! dirs .contains (dir ))
1009+ dirs .push (dir );
1010+ }
1011+ }
1012+ return dirs ;
1013+ #end
1014+ }
1015+
1016+ public inline static function loadabsoluteGraphic (path : String ): FlxGraphic {
1017+ if (! Paths .currentTrackedAssets .exists (path )) {
1018+ Paths .cacheBitmap (path ,null ,BitmapData .fromFile (path ));
1019+ }
1020+ return Paths .currentTrackedAssets .get (path );
1021+ }
1022+
1023+ public inline static function getSoundChannel (sound : FlxSound ){
1024+ @:privateAccess
1025+ return sound ._channel .__audioSource ;
1026+ }
9701027}
0 commit comments