mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-18 19:44:58 +01:00
[MIRROR] Ensures early assets init when expected during unit tests, [MDB IGNORE] (#17259)
* Ensures early assets init when expected during unit tests, (#70753) Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> * Ensures early assets init when expected during unit tests, Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>
This commit is contained in:
@@ -139,6 +139,14 @@ GLOBAL_LIST_EMPTY(asset_datums)
|
||||
/// Defaults to false so we can process this stuff nicely
|
||||
var/load_immediately = FALSE
|
||||
|
||||
/datum/asset/spritesheet/proc/should_load_immediately()
|
||||
#ifdef DO_NOT_DEFER_ASSETS
|
||||
return TRUE
|
||||
#else
|
||||
return load_immediately
|
||||
#endif
|
||||
|
||||
|
||||
/datum/asset/spritesheet/should_refresh()
|
||||
if (..())
|
||||
return TRUE
|
||||
@@ -167,10 +175,10 @@ GLOBAL_LIST_EMPTY(asset_datums)
|
||||
load_immediately = TRUE
|
||||
|
||||
create_spritesheets()
|
||||
if(load_immediately)
|
||||
if(should_load_immediately())
|
||||
realize_spritesheets(yield = FALSE)
|
||||
else
|
||||
SSasset_loading.generate_queue += src
|
||||
SSasset_loading.queue_asset(src)
|
||||
|
||||
/datum/asset/spritesheet/proc/realize_spritesheets(yield)
|
||||
if(fully_generated)
|
||||
@@ -197,7 +205,7 @@ GLOBAL_LIST_EMPTY(asset_datums)
|
||||
write_to_cache()
|
||||
fully_generated = TRUE
|
||||
// If we were ever in there, remove ourselves
|
||||
SSasset_loading.generate_queue -= src
|
||||
SSasset_loading.dequeue_asset(src)
|
||||
|
||||
/datum/asset/spritesheet/queued_generation()
|
||||
realize_spritesheets(yield = TRUE)
|
||||
@@ -328,7 +336,7 @@ GLOBAL_LIST_EMPTY(asset_datums)
|
||||
CRASH("create_spritesheets() not implemented for [type]!")
|
||||
|
||||
/datum/asset/spritesheet/proc/Insert(sprite_name, icon/I, icon_state="", dir=SOUTH, frame=1, moving=FALSE)
|
||||
if(load_immediately)
|
||||
if(should_load_immediately())
|
||||
queuedInsert(sprite_name, I, icon_state, dir, frame, moving)
|
||||
else
|
||||
to_generate += list(args.Copy())
|
||||
|
||||
Reference in New Issue
Block a user