mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-08-30 16:48:12 +01:00
[MIRROR] up ports the TG overlays subsystem update (#12222)
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
co-authored by
Kashargul
parent
6d122622ba
commit
fdfebad7d6
@@ -1,276 +1,156 @@
|
||||
//CHOMPEDIT -- this file is no longer ticked. See overlays_ch.dm for the new overlays subsystem.
|
||||
|
||||
SUBSYSTEM_DEF(overlays)
|
||||
name = "Overlay"
|
||||
flags = SS_TICKER
|
||||
wait = 1 // SS_TICKER - Ticks
|
||||
priority = FIRE_PRIORITY_OVERLAYS
|
||||
dependencies = list(
|
||||
/datum/controller/subsystem/atoms
|
||||
)
|
||||
flags = SS_NO_FIRE|SS_NO_INIT
|
||||
var/list/stats
|
||||
|
||||
/// The queue of atoms that need overlay updates.
|
||||
var/static/tmp/list/queue = list()
|
||||
|
||||
/// A list([icon] = list([state] = [appearance], ...), ...) cache of appearances.
|
||||
var/static/tmp/list/state_cache = list()
|
||||
|
||||
/// A list([icon] = [appearance], ...) cache of appearances.
|
||||
var/static/tmp/list/icon_cache = list()
|
||||
|
||||
/// The number of appearances currently cached.
|
||||
var/static/tmp/cache_size = 0
|
||||
/datum/controller/subsystem/overlays/PreInit()
|
||||
stats = list()
|
||||
|
||||
/datum/controller/subsystem/overlays/Shutdown()
|
||||
WRITE_LOG("[GLOB.log_directory]-overlay.log", render_stats(stats))
|
||||
|
||||
/datum/controller/subsystem/overlays/Recover()
|
||||
queue.Cut()
|
||||
state_cache.Cut()
|
||||
icon_cache.Cut()
|
||||
cache_size = 0
|
||||
for (var/atom/atom)
|
||||
atom.flags &= ~OVERLAY_QUEUED
|
||||
CHECK_TICK
|
||||
stats = SSoverlays.stats
|
||||
|
||||
/datum/controller/subsystem/overlays/Initialize()
|
||||
fire(FALSE, TRUE)
|
||||
return SS_INIT_SUCCESS
|
||||
/// Converts an overlay list into text for debug printing
|
||||
/// Of note: overlays aren't actually mutable appearances, they're just appearances
|
||||
/// Don't have access to that type tho, so this is the best you're gonna get
|
||||
/proc/overlays2text(list/overlays)
|
||||
var/list/unique_overlays = list()
|
||||
// As anything because we're basically doing type coerrsion, rather then actually filtering for mutable apperances
|
||||
for(var/mutable_appearance/overlay as anything in overlays)
|
||||
var/key = "[overlay.icon]-[overlay.icon_state]-[overlay.dir]"
|
||||
unique_overlays[key] += 1
|
||||
var/list/output_text = list()
|
||||
for(var/key in unique_overlays)
|
||||
output_text += "([key]) = [unique_overlays[key]]"
|
||||
return output_text.Join("\n")
|
||||
|
||||
/datum/controller/subsystem/overlays/stat_entry(msg)
|
||||
msg = "Queued Atoms: [queue.len], Cache Size: [cache_size]"
|
||||
return ..()
|
||||
/proc/iconstate2appearance(icon, iconstate)
|
||||
var/static/image/stringbro = new()
|
||||
stringbro.icon = icon
|
||||
stringbro.icon_state = iconstate
|
||||
return stringbro.appearance
|
||||
|
||||
/datum/controller/subsystem/overlays/fire(resumed, no_mc_tick)
|
||||
var/count = 1
|
||||
for (var/atom/atom as anything in queue)
|
||||
++count
|
||||
atom?.UpdateOverlays()
|
||||
if (no_mc_tick)
|
||||
CHECK_TICK
|
||||
else if (MC_TICK_CHECK)
|
||||
queue.Cut(1, count)
|
||||
return
|
||||
queue.Cut()
|
||||
/proc/icon2appearance(icon)
|
||||
var/static/image/iconbro = new()
|
||||
iconbro.icon = icon
|
||||
return iconbro.appearance
|
||||
|
||||
|
||||
/datum/controller/subsystem/overlays/proc/GetStateAppearance(icon, state)
|
||||
var/list/subcache = state_cache[icon]
|
||||
if (!subcache)
|
||||
subcache = list()
|
||||
state_cache[icon] = subcache
|
||||
if (!subcache[state])
|
||||
var/image/image = new (icon, null, state)
|
||||
subcache[state] = image.appearance
|
||||
++cache_size
|
||||
return subcache[state]
|
||||
|
||||
|
||||
/datum/controller/subsystem/overlays/proc/GetIconAppearance(icon)
|
||||
if (!icon_cache[icon])
|
||||
var/image/image = new (icon)
|
||||
icon_cache[icon] = image.appearance
|
||||
++cache_size
|
||||
return icon_cache[icon]
|
||||
|
||||
|
||||
/datum/controller/subsystem/overlays/proc/GetAppearanceList(atom/subject, list/sources)
|
||||
if (!sources)
|
||||
return list()
|
||||
if (!islist(sources))
|
||||
sources = list(sources)
|
||||
var/list/result = list()
|
||||
var/icon/icon = subject.icon
|
||||
for (var/atom/entry as anything in sources)
|
||||
AppearanceListEntry(entry, result, icon)
|
||||
return result
|
||||
|
||||
//Fixes runtime with overlays present in 515
|
||||
/datum/controller/subsystem/overlays/proc/AppearanceListEntry(var/atom/entry,var/list/result,var/icon/icon)
|
||||
if (!entry)
|
||||
return
|
||||
else if(islist(entry))
|
||||
var/list/entry_list = entry
|
||||
for(var/entry_item in entry_list)
|
||||
AppearanceListEntry(entry_item)
|
||||
else if (istext(entry))
|
||||
result += GetStateAppearance(icon, entry)
|
||||
else if (isicon(entry))
|
||||
result += GetIconAppearance(entry)
|
||||
else
|
||||
if (isloc(entry))
|
||||
if (entry.flags & OVERLAY_QUEUED)
|
||||
entry.ImmediateOverlayUpdate()
|
||||
if (!ispath(entry))
|
||||
if(entry.appearance)
|
||||
result += entry.appearance
|
||||
/atom/proc/build_appearance_list(list/build_overlays)
|
||||
if (!islist(build_overlays))
|
||||
build_overlays = list(build_overlays)
|
||||
if(priority_overlays)
|
||||
var/list/prio_overlay_temp
|
||||
if(!islist(priority_overlays))
|
||||
prio_overlay_temp = list(priority_overlays)
|
||||
else
|
||||
var/image/image = entry
|
||||
result += image.appearance
|
||||
prio_overlay_temp = priority_overlays.Copy()
|
||||
prio_overlay_temp |= build_overlays
|
||||
build_overlays = prio_overlay_temp
|
||||
for (var/overlay in build_overlays)
|
||||
if(!overlay)
|
||||
build_overlays -= overlay
|
||||
continue
|
||||
if (istext(overlay))
|
||||
// This is too expensive to run normally but running it during CI is a good test
|
||||
/*if (PERFORM_ALL_TESTS(focus_only/invalid_overlays))
|
||||
var/list/icon_states_available = icon_states(icon)
|
||||
if(!(overlay in icon_states_available))
|
||||
var/icon_file = "[icon]" || "Unknown Generated Icon"
|
||||
stack_trace("Invalid overlay: Icon object '[icon_file]' [REF(icon)] used in '[src]' [type] is missing icon state [overlay].")
|
||||
continue*/
|
||||
|
||||
/// Enqueues the atom for an overlay update if not already queued
|
||||
/atom/proc/QueueOverlayUpdate()
|
||||
if (flags & OVERLAY_QUEUED)
|
||||
return
|
||||
SSoverlays.queue += src
|
||||
flags |= OVERLAY_QUEUED
|
||||
var/index = build_overlays.Find(overlay)
|
||||
build_overlays[index] = iconstate2appearance(icon, overlay)
|
||||
else if(isicon(overlay))
|
||||
var/index = build_overlays.Find(overlay)
|
||||
build_overlays[index] = icon2appearance(overlay)
|
||||
return build_overlays
|
||||
|
||||
|
||||
/// Builds the atom's overlay state from caches
|
||||
/atom/proc/UpdateOverlays()
|
||||
if (gc_destroyed)
|
||||
if (length(overlays))
|
||||
overlays.Cut()
|
||||
return
|
||||
flags &= ~OVERLAY_QUEUED
|
||||
if (length(priority_overlays))
|
||||
if (length(our_overlays))
|
||||
overlays = priority_overlays + our_overlays
|
||||
else
|
||||
overlays = priority_overlays
|
||||
else if (length(our_overlays))
|
||||
overlays = our_overlays
|
||||
else
|
||||
overlays.Cut()
|
||||
|
||||
|
||||
/// Immediately runs an overlay update and dequeues the atom
|
||||
/atom/proc/ImmediateOverlayUpdate()
|
||||
SSoverlays.queue -= src
|
||||
UpdateOverlays()
|
||||
|
||||
|
||||
/// Clears the atom's overlay cache(s) and queues an update if needed
|
||||
/atom/proc/cut_overlays(priority)
|
||||
if (priority)
|
||||
if (!length(priority_overlays))
|
||||
return
|
||||
priority_overlays.Cut()
|
||||
QueueOverlayUpdate()
|
||||
else if (length(our_overlays))
|
||||
our_overlays.Cut()
|
||||
QueueOverlayUpdate()
|
||||
STAT_START_STOPWATCH
|
||||
if(priority)
|
||||
priority_overlays = null
|
||||
overlays = null
|
||||
//POST_OVERLAY_CHANGE(src)
|
||||
STAT_STOP_STOPWATCH
|
||||
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
||||
|
||||
/atom/proc/cut_overlay(list/remove_overlays, priority)
|
||||
if(!overlays)
|
||||
return
|
||||
STAT_START_STOPWATCH
|
||||
if(priority)
|
||||
priority_overlays -= remove_overlays
|
||||
if(islist(remove_overlays))
|
||||
remove_overlays = remove_overlays.Copy() //May not be ideal to copy, but as build_appearance_list modifies lists in place which breaks certain things
|
||||
overlays -= build_appearance_list(remove_overlays)
|
||||
//POST_OVERLAY_CHANGE(src)
|
||||
STAT_STOP_STOPWATCH
|
||||
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
||||
|
||||
/**
|
||||
* Adds specific overlay(s) to the atom.
|
||||
* It is designed so any of the types allowed to be added to /atom/overlays can be added here too. More details below.
|
||||
*
|
||||
* @param add The overlay(s) to add. These may be
|
||||
* - A string: In which case it is treated as an icon_state of the atom's icon.
|
||||
* - An icon: It is treated as an icon.
|
||||
* - An atom: Its own overlays are compiled and then it's appearance is added. (Meaning its current apperance is frozen).
|
||||
* - An image: Image's apperance is added (i.e. subsequently editing the image will not edit the overlay)
|
||||
* - A type path: Added to overlays as is. Does whatever it is BYOND does when you add paths to overlays.
|
||||
* - Or a list containing any of the above.
|
||||
* @param priority The overlays are added to the "priority" list istead of the normal one.
|
||||
*/
|
||||
/atom/proc/add_overlay(list/add, priority)
|
||||
if (!add)
|
||||
/atom/proc/add_overlay(list/add_overlays, priority)
|
||||
if(!overlays)
|
||||
return
|
||||
add = SSoverlays.GetAppearanceList(src, add)
|
||||
if (!length(add))
|
||||
STAT_START_STOPWATCH
|
||||
if(islist(add_overlays))
|
||||
if(priority)
|
||||
if (priority_overlays)
|
||||
priority_overlays += add_overlays
|
||||
else
|
||||
priority_overlays = add_overlays
|
||||
add_overlays = add_overlays.Copy() //May not be ideal to copy, but as build_appearance_list modifies lists in place which breaks certain things
|
||||
overlays += build_appearance_list(add_overlays) //May not be ideal to copy, but as build_appearance_list modifies lists in place which breaks certain things
|
||||
VALIDATE_OVERLAY_LIMIT(src)
|
||||
//POST_OVERLAY_CHANGE(src)
|
||||
STAT_STOP_STOPWATCH
|
||||
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
||||
|
||||
/atom/proc/copy_overlays(atom/other, cut_old) //copys our_overlays from another atom
|
||||
if(!other)
|
||||
if(cut_old)
|
||||
cut_overlays()
|
||||
return
|
||||
if (priority)
|
||||
if (priority_overlays)
|
||||
priority_overlays += add
|
||||
|
||||
STAT_START_STOPWATCH
|
||||
var/list/cached_other = other.overlays.Copy()
|
||||
if(cut_old)
|
||||
if(cached_other)
|
||||
overlays = cached_other
|
||||
else
|
||||
priority_overlays = add
|
||||
else if (our_overlays)
|
||||
our_overlays += add
|
||||
else
|
||||
our_overlays = add
|
||||
QueueOverlayUpdate()
|
||||
|
||||
|
||||
/**
|
||||
* Removes specific overlay(s) from the atom. Usually does not remove them from "priority" overlays.
|
||||
*
|
||||
* @param overlays The overlays to removed, type can be anything that is allowed for add_overlay().
|
||||
* @param priority If true, also will remove them from the "priority" overlays.
|
||||
*/
|
||||
/atom/proc/cut_overlay(list/cut, priority)
|
||||
if (!cut)
|
||||
return
|
||||
cut = SSoverlays.GetAppearanceList(src, cut)
|
||||
if (!length(cut))
|
||||
return
|
||||
var/update
|
||||
if (priority && length(priority_overlays))
|
||||
priority_overlays -= cut
|
||||
update = TRUE
|
||||
if (length(our_overlays))
|
||||
our_overlays -= cut
|
||||
update = TRUE
|
||||
if (update)
|
||||
QueueOverlayUpdate()
|
||||
|
||||
|
||||
/**
|
||||
* Copy the overlays from another atom, either replacing all of ours or appending to our existing overlays.
|
||||
* Note: This copies only the normal overlays, not the "priority" overlays.
|
||||
*
|
||||
* @param other The atom to copy overlays from.
|
||||
* @param cut_old If true, all of our overlays will be *replaced* by the other's. If other is null, that means cutting all ours.
|
||||
*/
|
||||
/atom/proc/copy_overlays(atom/other, cut)
|
||||
if (!other)
|
||||
if (cut)
|
||||
cut_overlays()
|
||||
return
|
||||
if (!length(other.our_overlays))
|
||||
if (cut)
|
||||
cut_overlays()
|
||||
return
|
||||
if (cut || !length(our_overlays))
|
||||
our_overlays = other.our_overlays.Copy()
|
||||
else
|
||||
our_overlays |= other.our_overlays
|
||||
QueueOverlayUpdate()
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of overlays that the target atom has
|
||||
*
|
||||
* @param priority If true, returns priority overlays as well
|
||||
* @param special If true, returns special overlays like emissives and em_blockers
|
||||
*/
|
||||
/proc/get_overlays(atom/other, priority, special)
|
||||
var/list/including = list()
|
||||
if (!other)
|
||||
return including
|
||||
for (var/image/I as anything in other.our_overlays)
|
||||
if (!special && I.plane > 0)
|
||||
continue
|
||||
including += I
|
||||
if (!priority)
|
||||
return including
|
||||
for (var/image/I as anything in other.priority_overlays)
|
||||
if (!special && I.plane > 0)
|
||||
continue
|
||||
including += I
|
||||
return including
|
||||
overlays = null
|
||||
VALIDATE_OVERLAY_LIMIT(src)
|
||||
//POST_OVERLAY_CHANGE(src)
|
||||
STAT_STOP_STOPWATCH
|
||||
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
||||
else if(cached_other)
|
||||
overlays += cached_other
|
||||
VALIDATE_OVERLAY_LIMIT(src)
|
||||
//POST_OVERLAY_CHANGE(src)
|
||||
STAT_STOP_STOPWATCH
|
||||
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
||||
|
||||
//TODO: Better solution for these?
|
||||
/image/proc/add_overlay(x)
|
||||
overlays += x
|
||||
|
||||
overlays |= x
|
||||
|
||||
/image/proc/cut_overlay(x)
|
||||
overlays -= x
|
||||
|
||||
|
||||
/image/proc/cut_overlays(x)
|
||||
overlays.Cut()
|
||||
|
||||
|
||||
/image/proc/copy_overlays(atom/other, cut_old)
|
||||
if(!other)
|
||||
if(cut_old)
|
||||
cut_overlays()
|
||||
return
|
||||
|
||||
var/list/cached_other = other.our_overlays
|
||||
var/list/cached_other = other.overlays.Copy()
|
||||
if(cached_other)
|
||||
if(cut_old || !overlays.len)
|
||||
overlays = cached_other.Copy()
|
||||
overlays = cached_other
|
||||
else
|
||||
overlays |= cached_other
|
||||
else if(cut_old)
|
||||
@@ -372,3 +252,10 @@ SUBSYSTEM_DEF(overlays)
|
||||
message_admins(text)
|
||||
log_world(text)
|
||||
return diff_found
|
||||
|
||||
//Legacy, does basically nothing
|
||||
/atom/proc/ImmediateOverlayUpdate()
|
||||
if (gc_destroyed)
|
||||
if (length(overlays))
|
||||
overlays.Cut()
|
||||
return
|
||||
|
||||
@@ -1,244 +0,0 @@
|
||||
SUBSYSTEM_DEF(overlays)
|
||||
name = "Overlay"
|
||||
flags = SS_NO_FIRE|SS_NO_INIT
|
||||
var/list/stats
|
||||
|
||||
/datum/controller/subsystem/overlays/PreInit()
|
||||
stats = list()
|
||||
|
||||
/datum/controller/subsystem/overlays/Shutdown()
|
||||
WRITE_LOG("[GLOB.log_directory]-overlay.log", render_stats(stats))
|
||||
|
||||
/datum/controller/subsystem/overlays/Recover()
|
||||
stats = SSoverlays.stats
|
||||
|
||||
/// Converts an overlay list into text for debug printing
|
||||
/// Of note: overlays aren't actually mutable appearances, they're just appearances
|
||||
/// Don't have access to that type tho, so this is the best you're gonna get
|
||||
/proc/overlays2text(list/overlays)
|
||||
var/list/unique_overlays = list()
|
||||
// As anything because we're basically doing type coerrsion, rather then actually filtering for mutable apperances
|
||||
for(var/mutable_appearance/overlay as anything in overlays)
|
||||
var/key = "[overlay.icon]-[overlay.icon_state]-[overlay.dir]"
|
||||
unique_overlays[key] += 1
|
||||
var/list/output_text = list()
|
||||
for(var/key in unique_overlays)
|
||||
output_text += "([key]) = [unique_overlays[key]]"
|
||||
return output_text.Join("\n")
|
||||
|
||||
/proc/iconstate2appearance(icon, iconstate)
|
||||
var/static/image/stringbro = new()
|
||||
stringbro.icon = icon
|
||||
stringbro.icon_state = iconstate
|
||||
return stringbro.appearance
|
||||
|
||||
/proc/icon2appearance(icon)
|
||||
var/static/image/iconbro = new()
|
||||
iconbro.icon = icon
|
||||
return iconbro.appearance
|
||||
|
||||
/atom/proc/build_appearance_list(list/build_overlays)
|
||||
if (!islist(build_overlays))
|
||||
build_overlays = list(build_overlays)
|
||||
for (var/overlay in build_overlays)
|
||||
if(!overlay)
|
||||
build_overlays -= overlay
|
||||
continue
|
||||
if (istext(overlay))
|
||||
// This is too expensive to run normally but running it during CI is a good test
|
||||
/*if (PERFORM_ALL_TESTS(focus_only/invalid_overlays))
|
||||
var/list/icon_states_available = icon_states(icon)
|
||||
if(!(overlay in icon_states_available))
|
||||
var/icon_file = "[icon]" || "Unknown Generated Icon"
|
||||
stack_trace("Invalid overlay: Icon object '[icon_file]' [REF(icon)] used in '[src]' [type] is missing icon state [overlay].")
|
||||
continue*/
|
||||
|
||||
var/index = build_overlays.Find(overlay)
|
||||
build_overlays[index] = iconstate2appearance(icon, overlay)
|
||||
else if(isicon(overlay))
|
||||
var/index = build_overlays.Find(overlay)
|
||||
build_overlays[index] = icon2appearance(overlay)
|
||||
return build_overlays
|
||||
|
||||
/atom/proc/cut_overlays()
|
||||
STAT_START_STOPWATCH
|
||||
overlays = null
|
||||
//POST_OVERLAY_CHANGE(src)
|
||||
STAT_STOP_STOPWATCH
|
||||
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
||||
|
||||
/atom/proc/cut_overlay(list/remove_overlays)
|
||||
if(!overlays)
|
||||
return
|
||||
STAT_START_STOPWATCH
|
||||
if(islist(remove_overlays))
|
||||
remove_overlays = remove_overlays.Copy() //May not be ideal to copy, but as build_appearance_list modifies lists in place which breaks certain things
|
||||
overlays -= build_appearance_list(remove_overlays)
|
||||
//POST_OVERLAY_CHANGE(src)
|
||||
STAT_STOP_STOPWATCH
|
||||
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
||||
|
||||
/atom/proc/add_overlay(list/add_overlays)
|
||||
if(!overlays)
|
||||
return
|
||||
STAT_START_STOPWATCH
|
||||
if(islist(add_overlays))
|
||||
add_overlays = add_overlays.Copy() //May not be ideal to copy, but as build_appearance_list modifies lists in place which breaks certain things
|
||||
overlays += build_appearance_list(add_overlays) //May not be ideal to copy, but as build_appearance_list modifies lists in place which breaks certain things
|
||||
VALIDATE_OVERLAY_LIMIT(src)
|
||||
//POST_OVERLAY_CHANGE(src)
|
||||
STAT_STOP_STOPWATCH
|
||||
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
||||
|
||||
/atom/proc/copy_overlays(atom/other, cut_old) //copys our_overlays from another atom
|
||||
if(!other)
|
||||
if(cut_old)
|
||||
cut_overlays()
|
||||
return
|
||||
|
||||
STAT_START_STOPWATCH
|
||||
var/list/cached_other = other.overlays.Copy()
|
||||
if(cut_old)
|
||||
if(cached_other)
|
||||
overlays = cached_other
|
||||
else
|
||||
overlays = null
|
||||
VALIDATE_OVERLAY_LIMIT(src)
|
||||
//POST_OVERLAY_CHANGE(src)
|
||||
STAT_STOP_STOPWATCH
|
||||
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
||||
else if(cached_other)
|
||||
overlays += cached_other
|
||||
VALIDATE_OVERLAY_LIMIT(src)
|
||||
//POST_OVERLAY_CHANGE(src)
|
||||
STAT_STOP_STOPWATCH
|
||||
STAT_LOG_ENTRY(SSoverlays.stats, type)
|
||||
|
||||
//TODO: Better solution for these?
|
||||
/image/proc/add_overlay(x)
|
||||
overlays |= x
|
||||
|
||||
/image/proc/cut_overlay(x)
|
||||
overlays -= x
|
||||
|
||||
/image/proc/cut_overlays(x)
|
||||
overlays.Cut()
|
||||
|
||||
/image/proc/copy_overlays(atom/other, cut_old)
|
||||
if(!other)
|
||||
if(cut_old)
|
||||
cut_overlays()
|
||||
return
|
||||
|
||||
var/list/cached_other = other.overlays.Copy()
|
||||
if(cached_other)
|
||||
if(cut_old || !overlays.len)
|
||||
overlays = cached_other
|
||||
else
|
||||
overlays |= cached_other
|
||||
else if(cut_old)
|
||||
cut_overlays()
|
||||
|
||||
// Debug procs
|
||||
|
||||
/atom
|
||||
/// List of overlay "keys" (info about the appearance) -> mutable versions of static appearances
|
||||
/// Drawn from the overlays list
|
||||
var/list/realized_overlays
|
||||
/// List of underlay "keys" (info about the appearance) -> mutable versions of static appearances
|
||||
/// Drawn from the underlays list
|
||||
var/list/realized_underlays
|
||||
|
||||
/image
|
||||
/// List of overlay "keys" (info about the appearance) -> mutable versions of static appearances
|
||||
/// Drawn from the overlays list
|
||||
var/list/realized_overlays
|
||||
/// List of underlay "keys" (info about the appearance) -> mutable versions of static appearances
|
||||
/// Drawn from the underlays list
|
||||
var/list/realized_underlays
|
||||
|
||||
/// Takes the atoms's existing overlays and underlays, and makes them mutable so they can be properly vv'd in the realized_overlays/underlays list
|
||||
/atom/proc/realize_overlays()
|
||||
realized_overlays = realize_appearance_queue(overlays)
|
||||
realized_underlays = realize_appearance_queue(underlays)
|
||||
|
||||
/// Takes the image's existing overlays, and makes them mutable so they can be properly vv'd in the realized_overlays list
|
||||
/image/proc/realize_overlays()
|
||||
realized_overlays = realize_appearance_queue(overlays)
|
||||
realized_underlays = realize_appearance_queue(underlays)
|
||||
|
||||
/// Takes a list of appearnces, makes them mutable so they can be properly vv'd and inspected
|
||||
/proc/realize_appearance_queue(list/appearances)
|
||||
var/list/real_appearances = list()
|
||||
var/list/queue = appearances.Copy()
|
||||
var/queue_index = 0
|
||||
while(queue_index < length(queue))
|
||||
queue_index++
|
||||
// If it's not a command, we assert that it's an appearance
|
||||
var/mutable_appearance/appearance = queue[queue_index]
|
||||
if(!appearance) // Who fucking adds nulls to their sublists god you people are the worst
|
||||
continue
|
||||
|
||||
var/mutable_appearance/new_appearance = new /mutable_appearance()
|
||||
new_appearance.appearance = appearance
|
||||
var/key = "[appearance.icon]-[appearance.icon_state]-[appearance.plane]-[appearance.layer]-[appearance.dir]-[appearance.color]"
|
||||
var/tmp_key = key
|
||||
var/appearance_indx = 1
|
||||
while(real_appearances[tmp_key])
|
||||
tmp_key = "[key]-[appearance_indx]"
|
||||
appearance_indx++
|
||||
|
||||
real_appearances[tmp_key] = new_appearance
|
||||
var/add_index = queue_index
|
||||
// Now check its children
|
||||
for(var/mutable_appearance/child_appearance as anything in appearance.overlays)
|
||||
add_index++
|
||||
queue.Insert(add_index, child_appearance)
|
||||
for(var/mutable_appearance/child_appearance as anything in appearance.underlays)
|
||||
add_index++
|
||||
queue.Insert(add_index, child_appearance)
|
||||
return real_appearances
|
||||
|
||||
/// Takes two appearances as args, prints out, logs, and returns a text representation of their differences
|
||||
/// Including suboverlays
|
||||
/proc/diff_appearances(mutable_appearance/first, mutable_appearance/second, iter = 0)
|
||||
var/list/diffs = list()
|
||||
var/list/firstdeet = first.vars
|
||||
var/list/seconddeet = second.vars
|
||||
var/diff_found = FALSE
|
||||
for(var/name in first.vars)
|
||||
var/firstv = firstdeet[name]
|
||||
var/secondv = seconddeet[name]
|
||||
if(firstv ~= secondv)
|
||||
continue
|
||||
if((islist(firstv) || islist(secondv)) && length(firstv) == 0 && length(secondv) == 0)
|
||||
continue
|
||||
if(name == "vars") // Go away
|
||||
continue
|
||||
if(name == "_listen_lookup") // This is just gonna happen with marked datums, don't care
|
||||
continue
|
||||
if(name == "overlays")
|
||||
first.realize_overlays()
|
||||
second.realize_overlays()
|
||||
var/overlays_differ = FALSE
|
||||
for(var/i in 1 to length(first.realized_overlays))
|
||||
if(diff_appearances(first.realized_overlays[i], second.realized_overlays[i], iter + 1))
|
||||
overlays_differ = TRUE
|
||||
|
||||
if(!overlays_differ)
|
||||
continue
|
||||
|
||||
diff_found = TRUE
|
||||
diffs += "Diffs detected at [name]: First ([firstv]), Second ([secondv])"
|
||||
|
||||
var/text = "Depth of: [iter]\n\t[diffs.Join("\n\t")]"
|
||||
message_admins(text)
|
||||
log_world(text)
|
||||
return diff_found
|
||||
|
||||
//Legacy, does basically nothing
|
||||
/atom/proc/ImmediateOverlayUpdate()
|
||||
if (gc_destroyed)
|
||||
if (length(overlays))
|
||||
overlays.Cut()
|
||||
return
|
||||
@@ -44,10 +44,12 @@
|
||||
gen_emissive_blocker.color = GLOB.em_block_color
|
||||
gen_emissive_blocker.dir = dir
|
||||
gen_emissive_blocker.appearance_flags |= appearance_flags
|
||||
// Note, this should be refactored to drop priority overlays
|
||||
add_overlay(list(gen_emissive_blocker), TRUE)
|
||||
if(EMISSIVE_BLOCK_UNIQUE)
|
||||
render_target = ref(src)
|
||||
em_block = new(src, render_target)
|
||||
// Note, this should be refactored to drop priority overlays
|
||||
add_overlay(list(em_block), TRUE)
|
||||
RegisterSignal(em_block, COMSIG_QDELETING, PROC_REF(emblocker_gc))
|
||||
if(opacity)
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
var/mob/living/simple_mob/SM = L
|
||||
SM.friends |= src.owner
|
||||
|
||||
// Note, this should be refactored to drop priority overlays
|
||||
L.add_overlay(control_overlay, TRUE)
|
||||
controlled_mobs |= L
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
message_admins("[key_name(user, user.client)](<A href='byond://?_src_=holder;[HrefToken()];adminmoreinfo=\ref[user]'>?</A>) planted [src.name] on [target.name] at ([target.x],[target.y],[target.z] - <A href='byond://?_src_=holder;[HrefToken()];adminplayerobservecoodjump=1;X=[target.x];Y=[target.y];Z=[target.z]'>JMP</a>) with [timer] second fuse",0,1)
|
||||
log_game("[key_name(user)] planted [src.name] on [target.name] at ([target.x],[target.y],[target.z]) with [timer] second fuse")
|
||||
|
||||
target.add_overlay(image_overlay, TRUE)
|
||||
target.add_overlay(image_overlay)
|
||||
to_chat(user, "Bomb has been planted. Timer counting down from [timer].")
|
||||
spawn(timer*10)
|
||||
explode(get_turf(target))
|
||||
@@ -90,7 +90,7 @@
|
||||
else
|
||||
target.ex_act(1)
|
||||
if(target)
|
||||
target.cut_overlay(image_overlay, TRUE)
|
||||
target.cut_overlay(image_overlay)
|
||||
qdel(src)
|
||||
|
||||
/obj/item/plastique/attack(mob/M as mob, mob/user as mob, def_zone)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
var/turf/T = get_turf(target)
|
||||
if((T.z in using_map.station_levels) || (T.z in using_map.admin_levels))
|
||||
target.visible_message(span_danger("\The [src] lets out a loud beep as safeties trigger, before imploding and falling apart."))
|
||||
target.cut_overlay(image_overlay, TRUE)
|
||||
target.cut_overlay(image_overlay)
|
||||
qdel(src)
|
||||
return 0
|
||||
else
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
return mining_overlay_cache["[cache_id]_[direction]"]
|
||||
|
||||
/turf/simulated/wall/solidrock/update_icon(var/update_neighbors)
|
||||
cut_overlays() //ChompEDIT
|
||||
cut_overlays()
|
||||
if(density)
|
||||
var/image/I
|
||||
for(var/i = 1 to 4)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
/obj/landed_holder/proc/land_on(var/turf/T)
|
||||
//Gather destination information
|
||||
var/obj/landed_holder/new_holder = new(null)
|
||||
T.lighting_clear_overlay() //CHOMP Add
|
||||
T.lighting_clear_overlay()
|
||||
new_holder.turf_type = T.type
|
||||
new_holder.dir = T.dir
|
||||
new_holder.icon = T.icon
|
||||
@@ -34,12 +34,12 @@
|
||||
|
||||
//Set the destination to be like us
|
||||
var/turf/simulated/shuttle/new_dest = T.ChangeTurf(my_turf.type,,1)
|
||||
my_turf.lighting_clear_overlay() //CHOMP Add
|
||||
my_turf.lighting_clear_overlay()
|
||||
new_dest.set_dir(my_turf.dir)
|
||||
new_dest.icon_state = my_turf.icon_state
|
||||
new_dest.icon = my_turf.icon
|
||||
new_dest.copy_overlays(my_turf, TRUE)
|
||||
new_dest.underlays = my_turf.underlays.Copy() //CHOMP Edit
|
||||
new_dest.underlays = my_turf.underlays.Copy()
|
||||
new_dest.decals = my_turf.decals
|
||||
//Shuttle specific stuff
|
||||
new_dest.interior_corner = my_turf.interior_corner
|
||||
@@ -47,7 +47,7 @@
|
||||
new_dest.under_turf = my_turf.under_turf
|
||||
new_dest.join_flags = my_turf.join_flags
|
||||
new_dest.join_group = my_turf.join_group
|
||||
new_dest.lighting_build_overlay() //CHOMP Add
|
||||
new_dest.lighting_build_overlay()
|
||||
|
||||
// Associate the holder with the new turf.
|
||||
new_holder.my_turf = new_dest
|
||||
@@ -64,14 +64,14 @@
|
||||
//Change our source to whatever it was before
|
||||
if(turf_type)
|
||||
new_source = my_turf.ChangeTurf(turf_type,,1)
|
||||
new_source.lighting_clear_overlay() //CHOMP Add
|
||||
new_source.lighting_clear_overlay()
|
||||
new_source.set_dir(dir)
|
||||
new_source.icon_state = icon_state
|
||||
new_source.icon = icon
|
||||
new_source.copy_overlays(src, TRUE)
|
||||
new_source.underlays = underlays.Copy() //CHOMP Edit
|
||||
new_source.underlays = underlays.Copy()
|
||||
new_source.decals = decals
|
||||
new_source.lighting_build_overlay() //CHOMP Add
|
||||
new_source.lighting_build_overlay()
|
||||
else
|
||||
new_source = my_turf.ChangeTurf(base_turf ? base_turf : get_base_turf_by_area(my_turf),,1)
|
||||
|
||||
@@ -110,13 +110,13 @@
|
||||
|
||||
// For joined corners touching static lighting turfs, add an overlay to cancel out that part of our lighting overlay.
|
||||
/turf/simulated/shuttle/proc/update_breaklights()
|
||||
cut_overlay(antilight_cache["[join_flags]"], TRUE)
|
||||
cut_overlay(antilight_cache["[join_flags]"])
|
||||
if(!(join_flags in GLOB.cornerdirs)) //We're not joined at an angle
|
||||
return
|
||||
//Dynamic lighting dissolver
|
||||
var/turf/T = get_step(src, turn(join_flags,180))
|
||||
if(!T || !T.dynamic_lighting || !get_area(T).dynamic_lighting)
|
||||
add_overlay(antilight_cache["[join_flags]"], TRUE)
|
||||
add_overlay(antilight_cache["[join_flags]"])
|
||||
|
||||
/turf/simulated/shuttle/proc/underlay_update()
|
||||
if(!takes_underlays)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
//Prime this list if we need it.
|
||||
if(has_huds)
|
||||
// Note, this should be refactored to drop priority overlays
|
||||
add_overlay(backplane,TRUE) //Strap this on here, to block HUDs from appearing in rightclick menus: http://www.byond.com/forum/?post=2336679
|
||||
hud_list = list()
|
||||
hud_list.len = TOTAL_HUDS
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
if(overmind)
|
||||
blob_head_overlay.color = overmind.blob_type.complementary_color
|
||||
color = initial(color)//looks better.
|
||||
add_overlay(blob_head_overlay, TRUE)
|
||||
add_overlay(blob_head_overlay)
|
||||
|
||||
/mob/living/simple_mob/blob/spore/handle_special()
|
||||
..()
|
||||
|
||||
@@ -67,7 +67,7 @@ GLOBAL_DATUM_INIT(openspace_backdrop_one_for_all, /atom/movable/openspace_backdr
|
||||
/turf/simulated/open/Initialize(mapload)
|
||||
. = ..()
|
||||
ASSERT(HasBelow(z))
|
||||
add_overlay(GLOB.openspace_backdrop_one_for_all, TRUE) //Special grey square for projecting backdrop darkness filter on it.
|
||||
add_overlay(GLOB.openspace_backdrop_one_for_all) //Special grey square for projecting backdrop darkness filter on it.
|
||||
return INITIALIZE_HINT_LATELOAD
|
||||
|
||||
/turf/simulated/open/LateInitialize()
|
||||
@@ -99,7 +99,7 @@ GLOBAL_DATUM_INIT(openspace_backdrop_one_for_all, /atom/movable/openspace_backdr
|
||||
/turf/simulated/open/update_icon()
|
||||
cut_overlays()
|
||||
update_icon_edge()
|
||||
add_overlay(GLOB.openspace_backdrop_one_for_all, TRUE) //Special grey square for projecting backdrop darkness filter on it. //ChompEDIT - add this on icon update.
|
||||
add_overlay(GLOB.openspace_backdrop_one_for_all) //Special grey square for projecting backdrop darkness filter on it.
|
||||
|
||||
// Straight copy from space.
|
||||
/turf/simulated/open/attackby(obj/item/C as obj, mob/user as mob)
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
overlays.Cut() // Snowflake handling, avoiding SSoverlays
|
||||
else
|
||||
icon_state = enabled_icon_state
|
||||
//flags |= OVERLAY_QUEUED //Trick SSoverlays //CHOMPEdit
|
||||
//SSoverlays.queue += src //CHOMPEdit
|
||||
//flags |= OVERLAY_QUEUED //Trick SSoverlays
|
||||
//SSoverlays.queue += src
|
||||
|
||||
/obj/effect/shield/proc/update_color()
|
||||
if(disabled_for || diffused_for)
|
||||
|
||||
@@ -661,6 +661,7 @@
|
||||
temp.filters += filter(type = "alpha", icon = icon(I.icon, I.icon_state))
|
||||
I.d_stage_overlay = temp
|
||||
for(var/count in I.d_mult to 1 step 0.25)
|
||||
// Note, this should be refactored to drop priority overlays
|
||||
I.add_overlay(I.d_stage_overlay, TRUE)
|
||||
|
||||
// SEND_SIGNAL(COMSIG_BELLY_UPDATE_VORE_FX) is sometimes used when calling vore_fx() to send belly visuals
|
||||
|
||||
+2
-2
@@ -142,7 +142,7 @@
|
||||
#include "code\__defines\ores.dm"
|
||||
#include "code\__defines\organ_external.dm"
|
||||
#include "code\__defines\organ_internal.dm"
|
||||
#include "code\__defines\overlay_ch.dm"
|
||||
#include "code\__defines\overlay.dm"
|
||||
#include "code\__defines\overmap.dm"
|
||||
#include "code\__defines\paicard.dm"
|
||||
#include "code\__defines\particles.dm"
|
||||
@@ -604,7 +604,7 @@
|
||||
#include "code\controllers\subsystems\motion_tracker.dm"
|
||||
#include "code\controllers\subsystems\nerdle.dm"
|
||||
#include "code\controllers\subsystems\nightshift.dm"
|
||||
#include "code\controllers\subsystems\overlays_ch.dm"
|
||||
#include "code\controllers\subsystems\overlays.dm"
|
||||
#include "code\controllers\subsystems\overmap_renamer_vr.dm"
|
||||
#include "code\controllers\subsystems\pathfinder_ch.dm"
|
||||
#include "code\controllers\subsystems\persist_vr.dm"
|
||||
|
||||
Reference in New Issue
Block a user