Skip to content

Commit

Permalink
tweak(overlights): adds overlights for APCs and SMESes, refactors som…
Browse files Browse the repository at this point in the history
…e thingss

PR #10916
  • Loading branch information
TobyThorne authored Nov 8, 2023
1 parent 25f9ba7 commit 9aa3a50
Show file tree
Hide file tree
Showing 18 changed files with 257 additions and 131 deletions.
1 change: 1 addition & 0 deletions code/datums/repositories/images.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
var/image/I = image(icon = icon, icon_state = icon_state, dir = dir)
I.alpha = alpha
I.appearance_flags = DEFAULT_APPEARANCE_FLAGS | appearance_flags
I.color = color
I.plane = plane
I.layer = layer
image_cache_for_overlays[cache_key] = I
Expand Down
25 changes: 16 additions & 9 deletions code/game/machinery/alarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@

var/report_danger_level = 1

var/image/alarm_overlay
var/global/status_overlays = FALSE
var/global/list/alarm_overlays

/obj/machinery/alarm/cold
target_temperature = 4 CELSIUS
Expand All @@ -110,7 +111,6 @@
alarm_area.master_air_alarm = null
elect_master(exclude_self = TRUE)
overlays.Cut()
QDEL_NULL(alarm_overlay)
return ..()

/obj/machinery/alarm/New(loc, dir, atom/frame)
Expand Down Expand Up @@ -304,11 +304,9 @@
return 0

/obj/machinery/alarm/update_icon()
if(!alarm_overlay)
alarm_overlay = image(icon, "alarm_over0")
alarm_overlay.plane = EFFECTS_ABOVE_LIGHTING_PLANE
alarm_overlay.layer = ABOVE_LIGHTING_LAYER
alarm_overlay.alpha = 200
if(!status_overlays)
status_overlays = TRUE
generate_overlays()

overlays.Cut()

Expand All @@ -334,11 +332,20 @@
new_color = COLOR_SUN
if(2)
new_color = COLOR_RED_LIGHT
alarm_overlay.icon_state = "alarm_over[icon_level]"
overlays += alarm_overlay

overlays += alarm_overlays[icon_level+1]

set_light(0.25, 0.1, 1, 2, new_color)

/obj/machinery/alarm/proc/generate_overlays()
alarm_overlays = new
alarm_overlays.len = 3
#define OVERLIGHT_IMAGE(a, b) a=image(icon, b); a.alpha=192; a.plane = EFFECTS_ABOVE_LIGHTING_PLANE; a.layer = ABOVE_LIGHTING_LAYER;
OVERLIGHT_IMAGE(alarm_overlays[1], "alarm_over0")
OVERLIGHT_IMAGE(alarm_overlays[2], "alarm_over1")
OVERLIGHT_IMAGE(alarm_overlays[3], "alarm_over2")
#undef OVERLIGHT_IMAGE

/obj/machinery/alarm/receive_signal(datum/signal/signal)
if(stat & (NOPOWER|BROKEN))
return
Expand Down
26 changes: 16 additions & 10 deletions code/game/machinery/fire_alarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
layer = ABOVE_WINDOW_LAYER
var/wiresexposed = FALSE
var/buildstage = FIREALARM_COMPLETE
var/image/alarm_overlay
var/image/seclevel_overlay

var/global/status_overlays = FALSE
var/global/list/alarm_overlays
var/image/seclevel_overlay // There's a whole system for different seclevels across different maps so let's just leave it like this until I figure out what the fuck

/obj/machinery/firealarm/New(loc, dir, atom/frame)
..(loc)
Expand All @@ -46,7 +48,6 @@
/obj/machinery/firealarm/Destroy()
GLOB.firealarm_list -= src
overlays.Cut()
QDEL_NULL(alarm_overlay)
QDEL_NULL(seclevel_overlay)
return ..()

Expand All @@ -57,11 +58,9 @@
. += "\nThe current alert level is <span style='color:[security_state.current_security_level.light_color_alarm];'>[security_state.current_security_level.name]</span>."

/obj/machinery/firealarm/update_icon()
if(!alarm_overlay)
alarm_overlay = image(icon, "fire[activated]")
alarm_overlay.plane = EFFECTS_ABOVE_LIGHTING_PLANE
alarm_overlay.layer = ABOVE_LIGHTING_LAYER
alarm_overlay.alpha = 200
if(!status_overlays)
status_overlays = TRUE
generate_overlays()

if(!seclevel_overlay)
seclevel_overlay = image(icon, "seclevel-null")
Expand Down Expand Up @@ -93,8 +92,7 @@
set_light(0)
return

alarm_overlay.icon_state = "fire[activated]"
overlays += alarm_overlay
overlays += alarm_overlays[activated+1]

if(!detecting)
return
Expand All @@ -108,6 +106,14 @@
seclevel_overlay.icon_state = sl.overlay_alarm
overlays += seclevel_overlay

#define OVERLIGHT_IMAGE(a, b) a=image(icon, b); a.alpha=192; a.plane = EFFECTS_ABOVE_LIGHTING_PLANE; a.layer = ABOVE_LIGHTING_LAYER;
/obj/machinery/firealarm/proc/generate_overlays()
alarm_overlays = new
alarm_overlays.len = 2
OVERLIGHT_IMAGE(alarm_overlays[1], "fire0")
OVERLIGHT_IMAGE(alarm_overlays[2], "fire1")
#undef OVERLIGHT_IMAGE

/obj/machinery/firealarm/fire_act(datum/gas_mixture/air, temperature, volume)
if(!detecting)
return
Expand Down
23 changes: 14 additions & 9 deletions code/game/machinery/lightswitch.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
var/on = 0
var/area/connected_area = null
var/other_area = null
var/image/overlay
var/global/image/on_overlay
var/global/image/off_overlay

/obj/machinery/light_switch/Initialize()
. = ..()
Expand All @@ -31,24 +32,28 @@
connected_area = null
other_area = null
overlays.Cut()
QDEL_NULL(overlay)
return ..()

/obj/machinery/light_switch/update_icon()
if(!overlay)
overlay = image(icon, "light1-overlay")
overlay.plane = EFFECTS_ABOVE_LIGHTING_PLANE
overlay.layer = ABOVE_LIGHTING_LAYER
overlay.alpha = 200
if(!on_overlay)
on_overlay = image(icon, "light1-overlay")
on_overlay.plane = EFFECTS_ABOVE_LIGHTING_PLANE
on_overlay.layer = ABOVE_LIGHTING_LAYER
on_overlay.alpha = 160

if(!off_overlay)
off_overlay = image(icon, "light0-overlay")
off_overlay.plane = EFFECTS_ABOVE_LIGHTING_PLANE
off_overlay.layer = ABOVE_LIGHTING_LAYER
off_overlay.alpha = 160

overlays.Cut()
if(stat & (NOPOWER|BROKEN))
icon_state = "light-p"
set_light(0)
else
icon_state = "light[on]"
overlay.icon_state = "light[on]-overlay"
overlays += overlay
overlays += on ? on_overlay : off_overlay
set_light(0.15, 0.1, 1, 2, (on ? "#82ff4c" : "#f86060"))

/obj/machinery/light_switch/_examine_text(mob/user)
Expand Down
3 changes: 1 addition & 2 deletions code/game/machinery/status_display.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
var/index2
var/image/picture = null
var/image/picture_overlight = null
var/image/static_overlay = null
var/global/image/static_overlay = null

var/frequency = 1435 // radio frequency

Expand Down Expand Up @@ -59,7 +59,6 @@
overlays.Cut()
QDEL_NULL(picture)
QDEL_NULL(picture_overlight)
QDEL_NULL(static_overlay)
return ..()

// register for radio system
Expand Down
3 changes: 1 addition & 2 deletions code/game/machinery/status_display_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var/list/ai_status_emotions = list(
var/emotion = "Neutral"
var/image/picture = null
var/image/picture_overlight = null
var/image/static_overlay = null
var/global/image/static_overlay = null

/obj/machinery/ai_status_display/Initialize()
. = ..()
Expand All @@ -96,7 +96,6 @@ var/list/ai_status_emotions = list(
overlays.Cut()
QDEL_NULL(picture)
QDEL_NULL(picture_overlight)
QDEL_NULL(static_overlay)
return ..()

/obj/machinery/ai_status_display/attack_ai/(mob/user)
Expand Down
14 changes: 5 additions & 9 deletions code/game/objects/items/devices/flashlight.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@
/obj/item/device/flashlight/Destroy()
activation_sound = null
switch_light(FALSE)
overlays.Cut()
return ..()

/obj/item/device/flashlight/update_icon()
overlays.Cut()
if(on)
icon_state = "[initial(icon_state)]-on"
if(light_overlay)
var/image/LO = overlay_image(icon, "[initial(icon_state)]-overlay", flags=RESET_COLOR)
LO.color = brightness_color
LO.layer = ABOVE_LIGHTING_LAYER
overlays += LO
overlays += image_repository.overlay_image(icon, "[initial(icon_state)]-overlay", alpha, RESET_COLOR, brightness_color, SOUTH, EFFECTS_ABOVE_LIGHTING_PLANE, ABOVE_LIGHTING_LAYER)
else
icon_state = "[initial(icon_state)]"

Expand Down Expand Up @@ -309,9 +307,7 @@
overlays.Cut()
if(on)
icon_state = "[initial(icon_state)]-on"
var/image/LO = overlay_image(icon, "[initial(icon_state)]-overlay", flags=RESET_COLOR)
LO.layer = ABOVE_LIGHTING_LAYER
overlays += LO
overlays += image_repository.overlay_image(icon, "[initial(icon_state)]-overlay", alpha, RESET_COLOR, brightness_color, SOUTH, EFFECTS_ABOVE_LIGHTING_PLANE, ABOVE_LIGHTING_LAYER)
else
icon_state = "[initial(icon_state)][fuel ? "" : "-empty"]"

Expand Down Expand Up @@ -390,8 +386,8 @@
if(!fuel)
icon_state = "glowstick-empty"
set_light(0)
else if (on)
var/image/I = overlay_image(icon, "glowstick-on", brightness_color)
else if(on)
var/image/I = image_repository.overlay_image(icon, "glowstick-on", alpha, RESET_COLOR, brightness_color, SOUTH, EFFECTS_ABOVE_LIGHTING_PLANE, ABOVE_LIGHTING_LAYER)
I.blend_mode = BLEND_ADD
overlays += I
item_state = "glowstick-on"
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/smokables/cigarettes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
var/ratio = round(smoketime / initial(smoketime), 0.25) * 100
icon_state = ever_lit ? "[initial(icon_state)][ratio]" : initial(icon_state)
if(lit)
overlays += overlay_image(icon, "[ember_state][ratio]", flags=RESET_COLOR)
overlays += image_repository.overlay_image(icon, "[ember_state][ratio]", alpha, RESET_COLOR, null, SOUTH)
else if(lit)
overlays += overlay_image(icon, ember_state, flags=RESET_COLOR)
overlays += image_repository.overlay_image(icon, ember_state, alpha, RESET_COLOR, null, SOUTH)

/obj/item/clothing/mask/smokable/cigarette/die(nomessage = FALSE, nodestroy = FALSE)
..()
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/smokables/ecigs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@
if(new_overlay_state != overlay_state)
overlay_state = new_overlay_state
if(overlay_state)
overlays += overlay_image('icons/obj/ecig.dmi', overlay_state, flags=RESET_COLOR)
overlays += image_repository.overlay_image('icons/obj/ecig.dmi', overlay_state, alpha, RESET_COLOR, null, SOUTH)
else
overlay_state = ""
overlays.Cut()
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/smokables/hookah.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
temp.color = HC.color
overlays += temp
if(lit)
overlays += overlay_image(icon, "[HC.icon_state]_over_lit", flags=RESET_COLOR)
overlays += image_repository.overlay_image(icon, "[HC.icon_state]_over_lit", alpha, RESET_COLOR, null, SOUTH)

if(H1?.loc == src)
var/image/temp = image(icon, "[base_icon]_left_0")
Expand Down Expand Up @@ -329,7 +329,7 @@
/obj/item/hookah_coal/update_icon()
overlays.Cut()
if(pulls_left)
overlays += overlay_image(icon, "[icon_state]_fill", flags=RESET_COLOR)
overlays += image_repository.overlay_image(icon, "[icon_state]_fill", alpha, RESET_COLOR, null, SOUTH)

/obj/item/hookah_coal/attack_self(mob/user)
if(smoke_amount)
Expand Down
4 changes: 1 addition & 3 deletions code/game/objects/items/storage/pill_bottle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
/obj/item/storage/pill_bottle/update_icon()
overlays.Cut()
if(label_color)
var/image/label_over = overlay_image(icon, "[icon_state]-overlay")
label_over.color = label_color
overlays += label_over
overlays += image_repository.overlay_image(icon, "[icon_state]-overlay", alpha, RESET_COLOR, label_color, SOUTH)

/obj/item/storage/pill_bottle/attack_self(mob/user)
if(user.get_inactive_hand())
Expand Down
12 changes: 3 additions & 9 deletions code/game/objects/structures/flora.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@
/obj/structure/flora/tree/pine/xmas/update_icon()
overlays.Cut()
if(light_overlay)
var/image/LO = overlay_image(icon, "[initial(icon_state)]-overlay")
LO.layer = ABOVE_LIGHTING_LAYER
overlays.Add(LO)
overlays += image_repository.overlay_image(icon, "[initial(icon_state)]-overlay", alpha, RESET_COLOR, color, SOUTH, EFFECTS_ABOVE_LIGHTING_PLANE, ABOVE_LIGHTING_LAYER)
set_light(l_max_bright, l_inner_range, l_outer_range, l_falloff_curve, l_color)
..()

Expand Down Expand Up @@ -167,9 +165,7 @@
/obj/structure/flora/tree/green/pink/update_icon()
overlays.Cut()
if(light_overlay)
var/image/LO = overlay_image(icon, "[initial(icon_state)]-overlay")
LO.layer = ABOVE_LIGHTING_LAYER
overlays.Add(LO)
overlays += image_repository.overlay_image(icon, "[initial(icon_state)]-overlay", alpha, RESET_COLOR, color, SOUTH, EFFECTS_ABOVE_LIGHTING_PLANE, ABOVE_LIGHTING_LAYER)
set_light(l_max_bright, l_inner_range, l_outer_range, l_falloff_curve, l_color)
..()

Expand Down Expand Up @@ -641,9 +637,7 @@
/obj/structure/flora/jungleplants/update_icon()
overlays.Cut()
if(light_overlay)
var/image/LO = overlay_image(icon, "[icon_state]-overlay")
LO.layer = ABOVE_LIGHTING_LAYER
overlays.Add(LO)
overlays += image_repository.overlay_image(icon, "[initial(icon_state)]-overlay", alpha, RESET_COLOR, color, SOUTH, EFFECTS_ABOVE_LIGHTING_PLANE, ABOVE_LIGHTING_LAYER)
set_light(l_max_bright, l_inner_range, l_outer_range, l_falloff_curve, l_color)
..()

Expand Down
4 changes: 2 additions & 2 deletions code/modules/clothing/glasses/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@
/obj/item/clothing/glasses/hud/update_icon()
overlays.Cut()
if(active && matrix)
overlays += overlay_image(icon, "[hud_icon]_[matrix.matrix_icon]")
overlays += image_repository.overlay_image(icon, "[hud_icon]_[matrix.matrix_icon]", alpha, 0, null, SOUTH)
if(lenses)
overlays += overlay_image(icon, "[hud_icon]_[lenses.icon_state]")
overlays += image_repository.overlay_image(icon, "[hud_icon]_[lenses.icon_state]", alpha, 0, null, SOUTH)

/obj/item/clothing/glasses/hud/attackby(obj/item/W, mob/user)
if(isScrewdriver(W))
Expand Down
Loading

0 comments on commit 9aa3a50

Please sign in to comment.