// Status display
// (formerly Countdown timer display)
#define CHARS_PER_LINE 5
#define FONT_SIZE "5pt"
#define FONT_COLOR "#09f"
#define FONT_STYLE "Small Fonts"
#define SCROLL_RATE (0.04 SECONDS) // time per pixel
#define LINE1_Y -8
#define LINE2_Y -15
#define SD_BLANK 0 // 0 = Blank
#define SD_EMERGENCY 1 // 1 = Emergency Shuttle timer
#define SD_MESSAGE 2 // 2 = Arbitrary message(s)
#define SD_PICTURE 3 // 3 = alert picture
/// Status display which can show images and scrolling text.
/obj/machinery/status_display
name = "status display"
desc = null
icon = 'icons/obj/status_display.dmi'
icon_state = "frame"
base_icon_state = "unanchoredstatusdisplay"
verb_say = "beeps"
verb_ask = "beeps"
verb_exclaim = "beeps"
density = FALSE
layer = ABOVE_WINDOW_LAYER
var/obj/effect/overlay/status_display_text/message1_overlay
var/obj/effect/overlay/status_display_text/message2_overlay
var/current_picture = ""
var/current_mode = SD_BLANK
var/message1 = ""
var/message2 = ""
/obj/item/wallframe/status_display
name = "status display frame"
desc = "Used to build status displays, just secure to the wall."
icon_state = "unanchoredstatusdisplay"
custom_materials = list(/datum/material/iron=14000, /datum/material/glass=8000)
result_path = /obj/machinery/status_display/evac
pixel_shift = -32
/obj/machinery/status_display/wrench_act(mob/living/user, obj/item/tool)
. = ..()
balloon_alert(user, "[anchored ? "un" : ""]securing...")
tool.play_tool_sound(src)
if(tool.use_tool(src, user, 6 SECONDS))
playsound(loc, 'sound/items/deconstruct.ogg', 50, TRUE)
balloon_alert(user, "[anchored ? "un" : ""]secured")
deconstruct()
return TRUE
/obj/machinery/status_display/welder_act(mob/living/user, obj/item/tool)
if(user.a_intent == INTENT_HARM)
return
if(obj_integrity >= max_integrity)
balloon_alert(user, "it doesn't need repairs!")
return TRUE
user.balloon_alert_to_viewers("repairing display...", "repairing...")
if(!tool.use_tool(src, user, 4 SECONDS, amount = 0, volume=50))
return TRUE
balloon_alert(user, "repaired")
obj_integrity = max_integrity
set_machine_stat(stat & ~BROKEN)
update_appearance()
return TRUE
/obj/machinery/status_display/deconstruct(disassembled = TRUE)
if(flags_1 & NODECONSTRUCT_1)
return
if(!disassembled)
new /obj/item/stack/sheet/metal(drop_location(), 2)
new /obj/item/shard(drop_location())
new /obj/item/shard(drop_location())
else
new /obj/item/wallframe/status_display(drop_location())
qdel(src)
/// Immediately change the display to the given picture.
/obj/machinery/status_display/proc/set_picture(state)
if(state != current_picture)
current_picture = state
update_appearance()
/// Immediately change the display to the given two lines.
/obj/machinery/status_display/proc/set_messages(line1, line2)
line1 = uppertext(line1)
line2 = uppertext(line2)
if(line1 != message1)
message1 = line1
if(line2 != message2)
message2 = line2
update_appearance()
/**
* Remove both message objs and null the fields.
* Don't call this in subclasses.
*/
/obj/machinery/status_display/proc/remove_messages()
if(message1_overlay)
QDEL_NULL(message1_overlay)
if(message2_overlay)
QDEL_NULL(message2_overlay)
/**
* Create/update message overlay.
* They must be handled as real objects for the animation to run.
* Don't call this in subclasses.
* Arguments:
* * overlay - the current /obj/effect/overlay/status_display_text instance
* * line_y - The Y offset to render the text.
* * message - the new message text.
* Returns new /obj/effect/overlay/status_display_text or null if unchanged.
*/
/obj/machinery/status_display/proc/update_message(obj/effect/overlay/status_display_text/overlay, line_y, message)
if(overlay && message == overlay.message)
return null
if(overlay)
qdel(overlay)
var/obj/effect/overlay/status_display_text/new_status_display_text = new(src, line_y, message)
vis_contents += new_status_display_text
return new_status_display_text
/obj/machinery/status_display/update_appearance(updates=ALL)
. = ..()
if( \
(stat & (NOPOWER|BROKEN)) || \
(current_mode == SD_BLANK) || \
(current_mode != SD_PICTURE && message1 == "" && message2 == "") \
)
set_light(0)
return
set_light(1.4, 0.7, LIGHT_COLOR_BLUE) // blue light
/obj/machinery/status_display/update_overlays()
. = ..()
if(stat & (NOPOWER|BROKEN))
remove_messages()
return
switch(current_mode)
if(SD_BLANK)
remove_messages()
// Turn off backlight.
return
if(SD_PICTURE)
remove_messages()
. += mutable_appearance(icon, current_picture)
else
var/overlay = update_message(message1_overlay, LINE1_Y, message1)
if(overlay)
message1_overlay = overlay
overlay = update_message(message2_overlay, LINE2_Y, message2)
if(overlay)
message2_overlay = overlay
// Turn off backlight if message is blank
if(message1 == "" && message2 == "")
return
. += emissive_appearance(icon, "outline", alpha = src.alpha)
// Timed process - performs nothing in the base class
/obj/machinery/status_display/process()
if(stat & NOPOWER)
// No power, no processing.
update_appearance()
return PROCESS_KILL
/// Update the display and, if necessary, re-enable processing.
/obj/machinery/status_display/proc/update()
if (process(SSMACHINES_DT) != PROCESS_KILL)
START_PROCESSING(SSmachines, src)
/obj/machinery/status_display/power_change()
. = ..()
update()
/obj/machinery/status_display/emp_act(severity)
. = ..()
if(stat & (NOPOWER|BROKEN) || . & EMP_PROTECT_SELF)
return
current_mode = SD_PICTURE
set_picture("ai_bsod")
/obj/machinery/status_display/examine(mob/user)
. = ..()
if (current_mode == SD_MESSAGE && (message1_overlay?.message || message2_overlay?.message))
. += "The display says:"
if (message1_overlay.message)
. += "\t[html_encode(message1_overlay.message)]"
if (message2_overlay.message)
. += "\t[html_encode(message2_overlay.message)]"
// Helper procs for child display types.
/obj/machinery/status_display/proc/display_shuttle_status(obj/docking_port/mobile/shuttle)
if(!shuttle)
// the shuttle is missing - no processing
set_messages("shutl?","")
return PROCESS_KILL
else if(shuttle.timer)
var/line1 = "-[shuttle.getModeStr()]-"
var/line2 = shuttle.getTimerStr()
if(length_char(line2) > CHARS_PER_LINE)
line2 = "error"
set_messages(line1, line2)
else
// don't kill processing, the timer might turn back on
set_messages("", "")
/obj/machinery/status_display/proc/examine_shuttle(mob/user, obj/docking_port/mobile/shuttle)
if (shuttle)
var/modestr = shuttle.getModeStr()
if (modestr)
if (shuttle.timer)
modestr = "
\t[modestr]: [shuttle.getTimerStr()]"
else
modestr = "
\t[modestr]"
return "The display says:
\t[shuttle.name][modestr]"
else
return "The display says:
\tShuttle missing!"
/obj/machinery/status_display/Destroy()
remove_messages()
return ..()
/**
* Nice overlay to make text smoothly scroll with no client updates after setup.
*/
/obj/effect/overlay/status_display_text
icon = 'icons/obj/status_display.dmi'
vis_flags = VIS_INHERIT_LAYER | VIS_INHERIT_PLANE | VIS_INHERIT_ID
var/message
/obj/effect/overlay/status_display_text/Initialize(mapload, yoffset, line)
. = ..()
maptext_y = yoffset
message = line
var/line_length = length_char(line)
if(line_length > CHARS_PER_LINE)
// Marquee text
var/marquee_message = "[line] • [line] • [line]"
var/marquee_length = line_length * 3 + 6
maptext = generate_text(marquee_message, center = FALSE)
maptext_width = 6 * marquee_length
maptext_x = 32
// Mask off to fit in screen.
add_filter("mask", 1, alpha_mask_filter(icon = icon(icon, "outline")))
// Scroll.
var/width = 4 * marquee_length
var/time = (width + 32) * SCROLL_RATE
animate(src, maptext_x = -width, time = time, loop = -1)
animate(maptext_x = 32, time = 0)
else
// Centered text
maptext = generate_text(line, center = TRUE)
maptext_x = 0
/obj/effect/overlay/status_display_text/proc/generate_text(text, center)
return {"