/******************** Requests Console ********************/
/** Originally written by errorage, updated by: Carn, needs more work though. I just added some security fixes */
//Request Console Screens
#define RCS_MAINMENU 0 // Main menu
#define RCS_RQASSIST 1 // Request supplies
#define RCS_RQSUPPLY 2 // Request assistance
#define RCS_SENDINFO 3 // Relay information
#define RCS_SENTPASS 4 // Message sent successfully
#define RCS_SENTFAIL 5 // Message sent unsuccessfully
#define RCS_VIEWMSGS 6 // View messages
#define RCS_MESSAUTH 7 // Authentication before sending
#define RCS_ANNOUNCE 8 // Send announcement
GLOBAL_LIST_EMPTY(req_console_assistance)
GLOBAL_LIST_EMPTY(req_console_supplies)
GLOBAL_LIST_EMPTY(req_console_information)
GLOBAL_LIST_EMPTY_TYPED(allConsoles, /obj/machinery/requests_console)
/obj/machinery/requests_console
name = "requests console"
desc = "A console intended to send requests to different departments on the station."
anchored = TRUE
icon = 'icons/obj/terminals_vr.dmi' //VOREStation Edit
icon_state = "req_comp_0"
layer = ABOVE_WINDOW_LAYER
circuit = /obj/item/circuitboard/request
blocks_emissive = NONE
light_power = 0.25
light_color = "#00ff00"
vis_flags = VIS_HIDE // They have an emissive that looks bad in openspace due to their wall-mounted nature
var/department = "Unknown" //The list of all departments on the station (Determined from this variable on each unit) Set this to the same thing if you want several consoles in one department
var/list/message_log = list() //List of all messages
var/departmentType = 0 //Bitflag. Zero is reply-only. Map currently uses raw numbers instead of defines.
var/newmessagepriority = 0
// 0 = no new message
// 1 = normal priority
// 2 = high priority
var/screen = RCS_VIEWMSGS
var/silent = 0 // set to 1 for it not to beep all the time
// var/hackState = 0
// 0 = not hacked
// 1 = hacked
var/announcementConsole = 0
// 0 = This console cannot be used to send department announcements
// 1 = This console can send department announcementsf
var/open = 0 // 1 if open
var/announceAuth = 0 //Will be set to 1 when you authenticate yourself for announcements
var/msgVerified = "" //Will contain the name of the person who varified it
var/msgStamped = "" //If a message is stamped, this will contain the stamp name
var/message = "";
var/recipient = ""; //the department which will be receiving the message
var/priority = -1 ; //Priority of the message being sent
light_range = 0
var/datum/announcement/announcement
/obj/machinery/requests_console/Initialize(mapload)
. = ..()
announcement = new
announcement.title = "[department] announcement"
announcement.newscast = 1
name = "[department] requests console"
GLOB.allConsoles += src
if(departmentType & RC_ASSIST)
GLOB.req_console_assistance |= department
if(departmentType & RC_SUPPLY)
GLOB.req_console_supplies |= department
if(departmentType & RC_INFO)
GLOB.req_console_information |= department
update_icon()
/obj/machinery/requests_console/Destroy()
GLOB.allConsoles -= src
var/lastDeptRC = 1
for (var/obj/machinery/requests_console/Console in GLOB.allConsoles)
if(Console.department == department)
lastDeptRC = 0
break
if(lastDeptRC)
if(departmentType & RC_ASSIST)
GLOB.req_console_assistance -= department
if(departmentType & RC_SUPPLY)
GLOB.req_console_supplies -= department
if(departmentType & RC_INFO)
GLOB.req_console_information -= department
return ..()
/obj/machinery/requests_console/power_change()
..()
update_icon()
/obj/machinery/requests_console/update_icon()
cut_overlays()
if(stat & NOPOWER)
set_light(0)
set_light_on(FALSE)
icon_state = "req_comp_off"
else
icon_state = "req_comp_[newmessagepriority]"
add_overlay(mutable_appearance(icon, "req_comp_ov[newmessagepriority]"))
add_overlay(emissive_appearance(icon, "req_comp_ov[newmessagepriority]"))
set_light(2)
set_light_on(TRUE)
/obj/machinery/requests_console/attack_hand(user as mob)
if(..(user))
return
tgui_interact(user)
/obj/machinery/requests_console/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "RequestConsole", "[department] Request Console")
ui.open()
/obj/machinery/requests_console/tgui_data(mob/user)
var/list/data = ..()
data["department"] = department
data["screen"] = screen
data["message_log"] = message_log
data["newmessagepriority"] = newmessagepriority
data["silent"] = silent
data["announcementConsole"] = announcementConsole
data["assist_dept"] = GLOB.req_console_assistance
data["supply_dept"] = GLOB.req_console_supplies
data["info_dept"] = GLOB.req_console_information
data["message"] = message
data["recipient"] = recipient
data["priority"] = priority
data["msgStamped"] = msgStamped
data["msgVerified"] = msgVerified
data["announceAuth"] = announceAuth
return data
/obj/machinery/requests_console/tgui_act(action, list/params, datum/tgui/ui)
if(..())
return TRUE
add_fingerprint(ui.user)
switch(action)
if("write")
if(reject_bad_text(params["write"]))
recipient = params["write"] //write contains the string of the receiving department's name
var/new_message = tgui_input_text(ui.user, "Write your message:", "Awaiting Input", "", MAX_MESSAGE_LEN)
if(new_message)
message = new_message
screen = RCS_MESSAUTH
switch(params["priority"])
if(1)
priority = 1
if(2)
priority = 2
else
priority = 0
else
reset_message(1)
. = TRUE
if("writeAnnouncement")
var/new_message = tgui_input_text(ui.user, "Write your message:", "Awaiting Input", "", MAX_MESSAGE_LEN)
if(new_message)
message = new_message
else
reset_message(1)
. = TRUE
if("sendAnnouncement")
if(!announcementConsole)
return FALSE
announcement.Announce(message, msg_sanitized = 1)
reset_message(1)
. = TRUE
if("department")
if(!message)
return FALSE
var/log_msg = message
var/pass = 0
screen = RCS_SENTFAIL
for(var/obj/machinery/message_server/MS in GLOB.machines)
if(!MS.active)
continue
MS.send_rc_message(ckey(params["department"]), department, log_msg, msgStamped, msgVerified, priority)
pass = 1
if(pass)
screen = RCS_SENTPASS
message_log += list(list("Message sent to [recipient]", "[message]"))
else
audible_message(text("[icon2html(src,viewers(src))] *The Requests Console beeps: 'NOTICE: No server detected!'"),,4)
. = TRUE
//Handle printing
if("print")
var/msg = message_log[text2num(params["print"])];
if(msg)
msg = span_bold("[msg[1]]:") + "
[msg[2]]"
msg = replacetext(msg, "
", "\n")
msg = strip_html_properly(msg)
var/obj/item/paper/R = new(src.loc)
R.name = "[department] Message"
R.info = "