mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
[MIRROR] Makes the GAS system only update the icon when it has changed (#4924)
* Makes the GAS system only update the icon when it has changed (#58337) * Makes the GAS system only update the icon when it has changed Co-authored-by: Emmett Gaines <ninjanomnom@gmail.com>
This commit is contained in:
co-authored by
Emmett Gaines
parent
e7dd23768e
commit
acdbc8a6c4
@@ -118,8 +118,6 @@
|
||||
#define COMSIG_ATOM_UPDATE_ICON_STATE "atom_update_icon_state"
|
||||
///from base of [/atom/update_overlays]: (list/new_overlays)
|
||||
#define COMSIG_ATOM_UPDATE_OVERLAYS "atom_update_overlays"
|
||||
///from base of [/atom/update_greyscale]: (list/colors)
|
||||
#define COMSIG_ATOM_UPDATE_GREYSCALE "atom_update_greyscale"
|
||||
///from base of [/atom/update_icon]: (signalOut, did_anything)
|
||||
#define COMSIG_ATOM_UPDATED_ICON "atom_updated_icon"
|
||||
///from base of atom/Entered(): (atom/movable/entering, /atom/oldLoc)
|
||||
|
||||
@@ -22,13 +22,6 @@ SUBSYSTEM_DEF(greyscale)
|
||||
|
||||
/datum/controller/subsystem/greyscale/proc/GetColoredIconByType(type, list/colors)
|
||||
type = "[type]"
|
||||
if(istext(colors)) // It's the color string format for map edits/type values etc
|
||||
colors = ParseColorString(colors)
|
||||
if(istype(colors)) // It's the color list format
|
||||
colors = colors.Join()
|
||||
return configurations[type].Generate(colors)
|
||||
|
||||
/datum/controller/subsystem/greyscale/proc/ParseColorString(colors)
|
||||
var/list/split_colors = splittext(colors, "#")
|
||||
var/list/output = list()
|
||||
for(var/i in 2 to length(split_colors))
|
||||
output += "#[split_colors[i]]"
|
||||
return output
|
||||
|
||||
@@ -91,15 +91,21 @@
|
||||
expected_colors = length(color_groups)
|
||||
|
||||
/// Actually create the icon and color it in, handles caching
|
||||
/datum/greyscale_config/proc/Generate(list/colors)
|
||||
if(length(colors) != expected_colors)
|
||||
CRASH("[DebugName()] expected [expected_colors] color arguments but only received [length(colors)]")
|
||||
var/key = colors.Join("&")
|
||||
/datum/greyscale_config/proc/Generate(color_string)
|
||||
var/key = color_string
|
||||
var/icon/new_icon = icon_cache[key]
|
||||
if(new_icon)
|
||||
return new_icon
|
||||
new_icon = icon_cache[key] = GenerateLayerGroup(colors, layers)
|
||||
return new_icon
|
||||
return icon(new_icon)
|
||||
var/list/colors = ParseColorString(color_string)
|
||||
if(length(colors) != expected_colors)
|
||||
CRASH("[DebugName()] expected [expected_colors] color arguments but only received [length(colors)]")
|
||||
new_icon = GenerateLayerGroup(colors, layers)
|
||||
// We read a pixel to force the icon to be fully generated before we let it loose into the world
|
||||
// I hate this
|
||||
new_icon.GetPixel(1, 1)
|
||||
new_icon = fcopy_rsc(new_icon)
|
||||
icon_cache[key] = new_icon
|
||||
return icon(new_icon)
|
||||
|
||||
/// Internal recursive proc to handle nested layer groups
|
||||
/datum/greyscale_config/proc/GenerateLayerGroup(list/colors, list/group, list/render_steps)
|
||||
@@ -134,3 +140,9 @@
|
||||
|
||||
output["icon"] = GenerateLayerGroup(colors, layers, debug_steps)
|
||||
return output
|
||||
|
||||
/datum/greyscale_config/proc/ParseColorString(color_string)
|
||||
. = list()
|
||||
var/list/split_colors = splittext(color_string, "#")
|
||||
for(var/color in 2 to length(split_colors))
|
||||
. += "#[split_colors[color]]"
|
||||
|
||||
@@ -71,4 +71,4 @@
|
||||
var/list/debug_data = reference_config.GenerateDebug(colors)
|
||||
render_steps += debug_data["steps"]
|
||||
return debug_data["icon"]
|
||||
return reference_config.Generate(colors)
|
||||
return reference_config.Generate(colors.Join())
|
||||
|
||||
+25
-15
@@ -223,6 +223,8 @@
|
||||
if(loc)
|
||||
SEND_SIGNAL(loc, COMSIG_ATOM_CREATED, src) /// Sends a signal that the new atom `src`, has been created at `loc`
|
||||
|
||||
update_greyscale()
|
||||
|
||||
//atom color stuff
|
||||
if(color)
|
||||
add_atom_colour(color, FIXED_COLOUR_PRIORITY)
|
||||
@@ -697,13 +699,6 @@
|
||||
update_icon_state()
|
||||
. |= UPDATE_ICON_STATE
|
||||
|
||||
if(updates & UPDATE_GREYSCALE)
|
||||
var/list/colors = update_greyscale()
|
||||
// Updating the greyscale config in update_greyscale() is fine or we would check this earlier
|
||||
if(greyscale_config)
|
||||
icon = SSgreyscale.GetColoredIconByType(greyscale_config, colors)
|
||||
. |= UPDATE_GREYSCALE
|
||||
|
||||
if(updates & UPDATE_OVERLAYS)
|
||||
if(LAZYLEN(managed_vis_overlays))
|
||||
SSvis_overlays.remove_vis_overlay(src, managed_vis_overlays)
|
||||
@@ -724,20 +719,35 @@
|
||||
SHOULD_CALL_PARENT(TRUE)
|
||||
return SEND_SIGNAL(src, COMSIG_ATOM_UPDATE_ICON_STATE)
|
||||
|
||||
/atom/proc/update_greyscale()
|
||||
SHOULD_CALL_PARENT(TRUE)
|
||||
. = list()
|
||||
var/list/raw_rgb = splittext(greyscale_colors, "#")
|
||||
for(var/i in 2 to length(raw_rgb))
|
||||
. += "#[raw_rgb[i]]"
|
||||
SEND_SIGNAL(src, COMSIG_ATOM_UPDATE_GREYSCALE, .)
|
||||
|
||||
/// Updates the overlays of the atom
|
||||
/atom/proc/update_overlays()
|
||||
SHOULD_CALL_PARENT(TRUE)
|
||||
. = list()
|
||||
SEND_SIGNAL(src, COMSIG_ATOM_UPDATE_OVERLAYS, .)
|
||||
|
||||
/// Checks if the colors given are different and if so causes a greyscale icon update
|
||||
/atom/proc/set_greyscale_colors(list/colors)
|
||||
SHOULD_CALL_PARENT(TRUE)
|
||||
var/new_colors = colors.Join("")
|
||||
if(greyscale_colors == new_colors)
|
||||
return
|
||||
greyscale_colors = new_colors
|
||||
if(!greyscale_config)
|
||||
return
|
||||
update_greyscale()
|
||||
|
||||
/// Checks if the greyscale config given is different and if so causes a greyscale icon update
|
||||
/atom/proc/set_greyscale_config(new_config)
|
||||
if(greyscale_config == new_config)
|
||||
return
|
||||
greyscale_config = new_config
|
||||
update_greyscale()
|
||||
|
||||
/// Checks if this atom uses the GAS system and if so updates the icon
|
||||
/atom/proc/update_greyscale()
|
||||
if(greyscale_config && greyscale_colors)
|
||||
icon = SSgreyscale.GetColoredIconByType(greyscale_config, greyscale_colors)
|
||||
|
||||
/**
|
||||
* An atom we are buckled or is contained within us has tried to move
|
||||
*
|
||||
|
||||
@@ -70,8 +70,8 @@
|
||||
split_colors[group] = new_color
|
||||
refresh_preview()
|
||||
if("apply")
|
||||
target.greyscale_colors = split_colors.Join()
|
||||
target.update_appearance()
|
||||
target.greyscale_colors = "" // We do this to force an update, in some cases it will think nothing changed when it should be refreshing
|
||||
target.set_greyscale_colors(split_colors)
|
||||
if("refresh_file")
|
||||
SSgreyscale.RefreshConfigsFromFile()
|
||||
refresh_preview()
|
||||
|
||||
@@ -394,23 +394,23 @@ GLOBAL_LIST_INIT(gas_id_to_canister, init_gas_id_to_canister())
|
||||
var/isBroken = machine_stat & BROKEN
|
||||
///Function is used to actually set the overlays
|
||||
if(mode)
|
||||
. += icon(canister_overlay_file, "tier[mode]")
|
||||
. += mutable_appearance(canister_overlay_file, "tier[mode]")
|
||||
if(isBroken)
|
||||
. += icon(canister_overlay_file, "broken")
|
||||
. += mutable_appearance(canister_overlay_file, "broken")
|
||||
if(holding)
|
||||
. += icon(canister_overlay_file, "can-open")
|
||||
. += mutable_appearance(canister_overlay_file, "can-open")
|
||||
if(connected_port)
|
||||
. += icon(canister_overlay_file, "can-connector")
|
||||
. += mutable_appearance(canister_overlay_file, "can-connector")
|
||||
|
||||
switch(air_contents.return_pressure())
|
||||
if((40 * ONE_ATMOSPHERE) to INFINITY)
|
||||
. += icon(canister_overlay_file, "can-3")
|
||||
. += mutable_appearance(canister_overlay_file, "can-3")
|
||||
if((10 * ONE_ATMOSPHERE) to (40 * ONE_ATMOSPHERE))
|
||||
. += icon(canister_overlay_file, "can-2")
|
||||
. += mutable_appearance(canister_overlay_file, "can-2")
|
||||
if((5 * ONE_ATMOSPHERE) to (10 * ONE_ATMOSPHERE))
|
||||
. += icon(canister_overlay_file, "can-1")
|
||||
. += mutable_appearance(canister_overlay_file, "can-1")
|
||||
if((10) to (5 * ONE_ATMOSPHERE))
|
||||
. += icon(canister_overlay_file, "can-0")
|
||||
. += mutable_appearance(canister_overlay_file, "can-0")
|
||||
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/should_atmos_process(datum/gas_mixture/air, exposed_temperature)
|
||||
|
||||
Reference in New Issue
Block a user