NanoUI PDAs made Modular (lazy commit)

This commit is contained in:
ShadowLarkens
2020-09-15 20:08:25 -07:00
parent 411486f7b4
commit 8c338ed9da
36 changed files with 2751 additions and 1395 deletions

View File

@@ -18,14 +18,10 @@ var/global/list/obj/item/device/pda/PDAs = list()
var/owner = null
var/default_cartridge = 0 // Access level defined by cartridge
var/obj/item/weapon/cartridge/cartridge = null //current cartridge
var/mode = 0 //Controls what menu the PDA will display. 0 is hub; the rest are either built in or based on cartridge.
var/lastmode = 0
var/ui_tick = 0
var/nanoUI[0]
//Secondary variables
var/scanmode = 0 //1 is medical scanner, 2 is forensics, 3 is reagent scanner.
// var/scanmode = 0 //1 is medical scanner, 2 is forensics, 3 is reagent scanner.
var/fon = 0 //Is the flashlight function on?
var/f_lum = 2 //Luminosity for the flashlight function
var/message_silent = 0 //To beep or not to beep, that is the question
@@ -34,7 +30,14 @@ var/global/list/obj/item/device/pda/PDAs = list()
var/tnote[0] //Current Texts
var/last_text //No text spamming
var/last_honk //Also no honk spamming that's bad too
var/ttone = "beep" //The PDA ringtone!
var/ttone = "beep" //The ringtone!
var/list/ttone_sound = list("beep" = 'sound/machines/twobeep.ogg',
"boom" = 'sound/effects/explosionfar.ogg',
"slip" = 'sound/misc/slip.ogg',
"honk" = 'sound/items/bikehorn.ogg',
"SKREE" = 'sound/voice/shriek1.ogg',
// "holy" = 'sound/items/PDA/ambicha4-short.ogg',
"xeno" = 'sound/voice/hiss1.ogg')
var/newstone = "beep, beep" //The news ringtone!
var/lock_code = "" // Lockcode to unlock uplink
var/honkamt = 0 //How many honks left when infected with honk.exe
@@ -67,6 +70,24 @@ var/global/list/obj/item/device/pda/PDAs = list()
var/spam_proof = FALSE // If true, it can't be spammed by random events.
// App-based PDAs
var/model_name = "Thinktronic 5230 Personal Data Assistant"
var/datum/data/pda/utility/scanmode/scanmode = null
var/datum/data/pda/app/current_app = null
var/datum/data/pda/app/lastapp = null
var/list/programs = list(
new/datum/data/pda/app/main_menu,
new/datum/data/pda/app/notekeeper,
new/datum/data/pda/app/messenger,
new/datum/data/pda/app/manifest,
new/datum/data/pda/app/atmos_scanner,
new/datum/data/pda/utility/scanmode/notes,
new/datum/data/pda/utility/flashlight)
var/list/shortcut_cache = list()
var/list/shortcut_cat_order = list()
var/list/notifying_programs = list()
var/retro_mode = 0
/obj/item/device/pda/examine(mob/user)
. = ..()
if(Adjacent(user))
@@ -97,6 +118,32 @@ var/global/list/obj/item/device/pda/PDAs = list()
if(iscarbon(user) && !touch_silent)
playsound(src, 'sound/machines/pda_click.ogg', 20)
/obj/item/device/pda/proc/play_ringtone()
var/S
if(ttone in ttone_sound)
S = ttone_sound[ttone]
else
S = 'sound/machines/twobeep.ogg'
playsound(loc, S, 50, 1)
for(var/mob/O in hearers(3, loc))
O.show_message(text("[bicon(src)] *[ttone]*"))
/obj/item/device/pda/proc/set_ringtone()
var/t = input("Please enter new ringtone", name, ttone) as text
if(in_range(src, usr) && loc == usr)
if(t)
if(hidden_uplink && hidden_uplink.check_trigger(usr, lowertext(t), lowertext(lock_code)))
to_chat(usr, "The PDA softly beeps.")
close(usr)
else
t = sanitize(copytext(t, 1, 20))
ttone = t
return 1
else
close(usr)
return 0
/obj/item/device/pda/medical
default_cartridge = /obj/item/weapon/cartridge/medical
icon_state = "pda-m"
@@ -442,6 +489,7 @@ var/global/list/obj/item/device/pda/PDAs = list()
..()
PDAs += src
PDAs = sortAtom(PDAs)
update_programs()
if(default_cartridge)
cartridge = new default_cartridge(src)
new /obj/item/weapon/pen(src)
@@ -469,6 +517,7 @@ var/global/list/obj/item/device/pda/PDAs = list()
else
icon = 'icons/obj/pda_old.dmi'
log_debug("Invalid switch for PDA, defaulting to old PDA icons. [pdachoice] chosen.")
start_program(find_program(/datum/data/pda/app/main_menu))
/obj/item/device/pda/proc/can_use()
@@ -499,17 +548,25 @@ var/global/list/obj/item/device/pda/PDAs = list()
return attack_self(M)
return
/obj/item/device/pda/proc/close(mob/user)
var/datum/nanoui/ui = SSnanoui.get_open_ui(user, src, "main")
ui.close()
SStgui.close_uis(src)
/obj/item/device/pda/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
ui_tick++
var/datum/nanoui/old_ui = SSnanoui.get_open_ui(user, src, "main")
var/auto_update = 1
if(mode in no_auto_update)
auto_update = 0
if(old_ui && (mode == lastmode && ui_tick % 5 && mode in update_every_five))
if(!current_app)
return
lastmode = mode
if(current_app.update == PDA_APP_NOUPDATE && current_app == lastapp)
auto_update = 0
if(old_ui && (current_app == lastapp && ui_tick % 5 && current_app.update == PDA_APP_UPDATE_SLOW))
return
lastapp = current_app
var/title = "Personal Data Assistant"
@@ -518,156 +575,57 @@ var/global/list/obj/item/device/pda/PDAs = list()
data["owner"] = owner // Who is your daddy...
data["ownjob"] = ownjob // ...and what does he do?
data["mode"] = mode // The current view
data["scanmode"] = scanmode // Scanners
data["fon"] = fon // Flashlight on?
data["pai"] = (isnull(pai) ? 0 : 1) // pAI inserted?
data["note"] = note // current pda notes
data["message_silent"] = message_silent // does the pda make noise when it receives a message?
data["news_silent"] = news_silent // does the pda make noise when it receives news?
data["touch_silent"] = touch_silent // does the pda make noise when it receives news?
data["toff"] = toff // is the messenger function turned off?
data["active_conversation"] = active_conversation // Which conversation are we following right now?
// update list of shortcuts, only if they changed
if(!shortcut_cache.len)
shortcut_cache = list()
shortcut_cat_order = list()
var/prog_list = programs.Copy()
if(cartridge)
prog_list |= cartridge.programs
for(var/A in prog_list)
var/datum/data/pda/P = A
if(P.hidden)
continue
var/list/cat
if(P.category in shortcut_cache)
cat = shortcut_cache[P.category]
else
cat = list()
shortcut_cache[P.category] = cat
shortcut_cat_order += P.category
cat |= list(list(name = P.name, icon = P.icon, notify_icon = P.notify_icon, ref = "\ref[P]"))
// force the order of a few core categories
shortcut_cat_order = list("General") \
+ sortList(shortcut_cat_order - list("General", "Scanners", "Utilities")) \
+ list("Scanners", "Utilities")
data["idInserted"] = (id ? 1 : 0)
data["idLink"] = (id ? text("[id.registered_name], [id.assignment]") : "--------")
data["cart_loaded"] = cartridge ? 1:0
if(cartridge)
var/cartdata[0]
cartdata["access"] = list(\
"access_security" = cartridge.access_security,\
"access_engine" = cartridge.access_engine,\
"access_atmos" = cartridge.access_atmos,\
"access_medical" = cartridge.access_medical,\
"access_clown" = cartridge.access_clown,\
"access_mime" = cartridge.access_mime,\
"access_janitor" = cartridge.access_janitor,\
"access_quartermaster" = cartridge.access_quartermaster,\
"access_hydroponics" = cartridge.access_hydroponics,\
"access_reagent_scanner" = cartridge.access_reagent_scanner,\
"access_remote_door" = cartridge.access_remote_door,\
"access_status_display" = cartridge.access_status_display,\
"access_detonate_pda" = cartridge.access_detonate_pda\
)
data["useRetro"] = retro_mode
if(mode in cartmodes)
data["records"] = cartridge.create_NanoUI_values()
data["cartridge_name"] = cartridge ? cartridge.name : ""
data["stationTime"] = worldtime2stationtime(world.time)
if(mode == 0)
cartdata["name"] = cartridge.name
if(isnull(cartridge.radio))
cartdata["radio"] = 0
else
if(istype(cartridge.radio, /obj/item/radio/integrated/beepsky))
cartdata["radio"] = 1
if(istype(cartridge.radio, /obj/item/radio/integrated/signal))
cartdata["radio"] = 2
//if(istype(cartridge.radio, /obj/item/radio/integrated/mule))
// cartdata["radio"] = 3
data["app"] = list()
current_app.update_ui(user, data)
data["app"] |= list(
"name" = current_app.title,
"icon" = current_app.icon,
"template" = current_app.template,
"has_back" = current_app.has_back)
if(mode == 2)
cartdata["charges"] = cartridge.charges ? cartridge.charges : 0
data["cartridge"] = cartdata
data["stationTime"] = stationtime2text()
data["new_Message"] = new_message
data["new_News"] = new_news
var/datum/reception/reception = get_reception(src, do_sleep = 0)
var/has_reception = reception.telecomms_reception & TELECOMMS_RECEPTION_SENDER
data["reception"] = has_reception
if(mode==2)
var/convopdas[0]
var/pdas[0]
var/count = 0
for (var/obj/item/device/pda/P in PDAs)
if (!P.owner||P.toff||P == src||P.hidden) continue
if(conversations.Find("\ref[P]"))
convopdas.Add(list(list("Name" = "[P]", "Reference" = "\ref[P]", "Detonate" = "[P.detonate]", "inconvo" = "1")))
else
pdas.Add(list(list("Name" = "[P]", "Reference" = "\ref[P]", "Detonate" = "[P.detonate]", "inconvo" = "0")))
count++
data["convopdas"] = convopdas
data["pdas"] = pdas
data["pda_count"] = count
if(mode==21)
data["messagescount"] = tnote.len
data["messages"] = tnote
else
data["messagescount"] = null
data["messages"] = null
if(active_conversation)
for(var/c in tnote)
if(c["target"] == active_conversation)
data["convo_name"] = sanitize(c["owner"])
data["convo_job"] = sanitize(c["job"])
break
if(mode==41)
data_core.get_manifest_list()
if(mode==3)
data["aircontents"] = src.analyze_air()
if(mode==6)
if(has_reception)
feeds.Cut()
for(var/datum/feed_channel/channel in news_network.network_channels)
feeds[++feeds.len] = list("name" = channel.channel_name, "censored" = channel.censored)
data["feedChannels"] = feeds
if(mode==61)
var/datum/feed_channel/FC
for(FC in news_network.network_channels)
if(FC.channel_name == active_feed["name"])
break
var/list/feed = feed_info[active_feed]
if(!feed)
feed = list()
feed["channel"] = FC.channel_name
feed["author"] = "Unknown"
feed["censored"]= 0
feed["updated"] = -1
feed_info[active_feed] = feed
if(FC.updated > feed["updated"] && has_reception)
feed["author"] = FC.author
feed["updated"] = FC.updated
feed["censored"] = FC.censored
var/list/messages = list()
if(!FC.censored)
var/index = 0
for(var/datum/feed_message/FM in FC.messages)
index++
if(FM.img)
usr << browse_rsc(FM.img, "pda_news_tmp_photo_[feed["channel"]]_[index].png")
// News stories are HTML-stripped but require newline replacement to be properly displayed in NanoUI
var/body = replacetext(FM.body, "\n", "<br>")
messages[++messages.len] = list("author" = FM.author, "body" = body, "message_type" = FM.message_type, "time_stamp" = FM.time_stamp, "has_image" = (FM.img != null), "caption" = FM.caption, "index" = index)
feed["messages"] = messages
data["feed"] = feed
data["manifest"] = PDA_Manifest
nanoUI = data
// update the ui if it exists, returns null if no ui is passed/found
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
if(!ui)
// the ui does not exist, so we'll create a new() one
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
ui = new(user, src, ui_key, "pda.tmpl", title, 520, 400, state = inventory_state)
// add templates for screens in common with communicator.
ui.add_template("atmosphericScan", "atmospheric_scan.tmpl")
ui.add_template("crewManifest", "crew_manifest.tmpl")
ui.set_state_key("pda")
// when the ui is first opened this is the data it will use
ui.set_initial_data(data)
// open the new ui window
@@ -682,24 +640,42 @@ var/global/list/obj/item/device/pda/PDAs = list()
return
ui_interact(user) //NanoUI requires this proc
tgui_interact(user)
return
/obj/item/device/pda/proc/start_program(datum/data/pda/P)
if(P && ((P in programs) || (cartridge && (P in cartridge.programs))))
return P.start()
return 0
/obj/item/device/pda/proc/find_program(type)
var/datum/data/pda/A = locate(type) in programs
if(A)
return A
if(cartridge)
A = locate(type) in cartridge.programs
if(A)
return A
return null
// force the cache to rebuild on update_ui
/obj/item/device/pda/proc/update_shortcuts()
shortcut_cache.Cut()
/obj/item/device/pda/proc/update_programs()
for(var/A in programs)
var/datum/data/pda/P = A
P.pda = src
/obj/item/device/pda/Topic(href, href_list)
if(href_list["cartmenu"] && !isnull(cartridge))
cartridge.Topic(href, href_list)
return 1
if(href_list["radiomenu"] && !isnull(cartridge) && !isnull(cartridge.radio))
cartridge.radio.Topic(href, href_list)
return 1
. = ..()
if(.)
return
..()
var/mob/user = usr
var/datum/nanoui/ui = SSnanoui.get_open_ui(user, src, "main")
var/mob/living/U = usr
//Looking for master was kind of pointless since PDAs don't appear to have one.
//if ((src in U.contents) || ( istype(loc, /turf) && in_range(src, U) ) )
if (usr.stat == DEAD)
if(usr.stat == DEAD)
return 0
if(!can_use()) //Why reinvent the wheel? There's a proc that does exactly that.
U.unset_machine()
@@ -710,293 +686,56 @@ var/global/list/obj/item/device/pda/PDAs = list()
add_fingerprint(U)
U.set_machine(src)
if(href_list["radiomenu"] && !isnull(cartridge) && !isnull(cartridge.radio))
cartridge.radio.Topic(href, href_list)
return 1
. = 1
switch(href_list["choice"])
//BASIC FUNCTIONS===================================
if("Close")//Self explanatory
U.unset_machine()
ui.close()
return 0
if("Refresh")//Refresh, goes to the end of the proc.
if("Return")//Return
if(mode<=9)
mode = 0
else
mode = round(mode/10)
if(mode==2)
active_conversation = null
if(mode==4)//Fix for cartridges. Redirects to hub.
mode = 0
else if(mode >= 40 && mode <= 49)//Fix for cartridges. Redirects to refresh the menu.
cartridge.mode = mode
if ("Authenticate")//Checks for ID
id_check(U, 1)
if("UpdateInfo")
ownjob = id.assignment
ownrank = id.rank
name = "PDA-[owner] ([ownjob])"
if("Home")//Go home, largely replaces the old Return
var/datum/data/pda/app/main_menu/A = find_program(/datum/data/pda/app/main_menu)
if(A)
start_program(A)
if("StartProgram")
if(href_list["program"])
var/datum/data/pda/app/A = locate(href_list["program"])
if(A)
start_program(A)
if("Eject")//Ejects the cart, only done from hub.
verb_remove_cartridge()
//MENU FUNCTIONS===================================
if("0")//Hub
mode = 0
if("1")//Notes
mode = 1
if("2")//Messenger
mode = 2
if("21")//Read messages
mode = 21
if("3")//Atmos scan
mode = 3
if("4")//Redirects to hub
mode = 0
if("chatroom") // chatroom hub
mode = 5
if("41") //Manifest
mode = 41
//MAIN FUNCTIONS===================================
if("Light")
if(fon)
fon = 0
set_light(0)
else
fon = 1
set_light(f_lum)
if("Medical Scan")
if(scanmode == 1)
scanmode = 0
else if((!isnull(cartridge)) && (cartridge.access_medical))
scanmode = 1
if("Reagent Scan")
if(scanmode == 3)
scanmode = 0
else if((!isnull(cartridge)) && (cartridge.access_reagent_scanner))
scanmode = 3
if("Halogen Counter")
if(scanmode == 4)
scanmode = 0
else if((!isnull(cartridge)) && (cartridge.access_engine))
scanmode = 4
if("Honk")
if ( !(last_honk && world.time < last_honk + 20) )
playsound(src, 'sound/items/bikehorn.ogg', 50, 1)
last_honk = world.time
if("Gas Scan")
if(scanmode == 5)
scanmode = 0
else if((!isnull(cartridge)) && (cartridge.access_atmos))
scanmode = 5
if("Toggle Beeping")
touch_silent = !touch_silent
//MESSENGER/NOTE FUNCTIONS===================================
if ("Edit")
var/n = input(U, "Please enter message", name, notehtml) as message
if (in_range(src, U) && loc == U)
n = sanitizeSafe(n, extra = 0)
if (mode == 1)
note = html_decode(n)
notehtml = note
note = replacetext(note, "\n", "<br>")
else
ui.close()
if("Toggle Messenger")
toff = !toff
if("Toggle Ringer")//If viewing texts then erase them, if not then toggle silent status
message_silent = !message_silent
if("Toggle News")
news_silent = !news_silent
if("Clear")//Clears messages
if(href_list["option"] == "All")
tnote.Cut()
conversations.Cut()
if(href_list["option"] == "Convo")
var/new_tnote[0]
for(var/i in tnote)
if(i["target"] != active_conversation)
new_tnote[++new_tnote.len] = i
tnote = new_tnote
conversations.Remove(active_conversation)
active_conversation = null
if(mode==21)
mode=2
if(!isnull(cartridge))
var/turf/T = loc
if(ismob(T))
T = T.loc
var/obj/item/weapon/cartridge/C = cartridge
C.forceMove(T)
if(scanmode in C.programs)
scanmode = null
if(current_app in C.programs)
start_program(find_program(/datum/data/pda/app/main_menu))
if(C.radio)
C.radio.hostpda = null
for(var/datum/data/pda/P in notifying_programs)
if(P in C.programs)
P.unnotify()
cartridge = null
update_shortcuts()
if("Authenticate")//Checks for ID
id_check(usr, 1)
if("Retro")
retro_mode = !retro_mode
if("Ringtone")
var/t = input(U, "Please enter new ringtone", name, ttone) as text
if (in_range(src, U) && loc == U)
if (t)
if(src.hidden_uplink && hidden_uplink.check_trigger(U, lowertext(t), lowertext(lock_code)))
to_chat(U, "The PDA softly beeps.")
ui.close()
else
t = sanitize(t, 20)
ttone = t
else
ui.close()
return 0
if("Newstone")
var/t = input(U, "Please enter new news tone", name, newstone) as text
if (in_range(src, U) && loc == U)
if (t)
t = sanitize(t, 20)
newstone = t
else
ui.close()
return 0
if("Message")
var/obj/item/device/pda/P = locate(href_list["target"])
src.create_message(U, P, !href_list["notap"])
if(mode == 2)
if(href_list["target"] in conversations) // Need to make sure the message went through, if not welp.
active_conversation = href_list["target"]
mode = 21
if("Select Conversation")
var/P = href_list["convo"]
for(var/n in conversations)
if(P == n)
active_conversation=P
mode=21
if("Select Feed")
var/n = href_list["name"]
for(var/f in feeds)
if(f["name"] == n)
active_feed = f
mode=61
if("Send Honk")//Honk virus
if(cartridge && cartridge.access_clown)//Cartridge checks are kind of unnecessary since everything is done through switch.
var/obj/item/device/pda/P = locate(href_list["target"])//Leaving it alone in case it may do something useful, I guess.
if(!isnull(P))
if (!P.toff && cartridge.charges > 0)
cartridge.charges--
U.show_message("<span class='notice'>Virus sent!</span>", 1)
P.honkamt = (rand(15,20))
else
to_chat(U, "PDA not found.")
else
ui.close()
return 0
if("Send Silence")//Silent virus
if(cartridge && cartridge.access_mime)
var/obj/item/device/pda/P = locate(href_list["target"])
if(!isnull(P))
if (!P.toff && cartridge.charges > 0)
cartridge.charges--
U.show_message("<span class='notice'>Virus sent!</span>", 1)
P.message_silent = 1
P.news_silent = 1
P.ttone = "silence"
P.newstone = "silence"
else
to_chat(U, "PDA not found.")
else
ui.close()
return 0
//SYNDICATE FUNCTIONS===================================
if("Toggle Door")
if(cartridge && cartridge.access_remote_door)
for(var/obj/machinery/door/blast/M in machines)
if(M.id == cartridge.remote_door_id)
if(M.density)
M.open()
else
M.close()
if("Detonate")//Detonate PDA... maybe
if(cartridge && cartridge.access_detonate_pda)
var/obj/item/device/pda/P = locate(href_list["target"])
var/datum/reception/reception = get_reception(src, P, "", do_sleep = 0)
if(!(reception.message_server && reception.telecomms_reception & TELECOMMS_RECEPTION_SENDER))
U.show_message("<span class='warning'>An error flashes on your [src]: Connection unavailable</span>", 1)
return
if(reception.telecomms_reception & TELECOMMS_RECEPTION_RECEIVER == 0) // Does our recepient have a broadcaster on their level?
U.show_message("<span class='warning'>An error flashes on your [src]: Recipient unavailable</span>", 1)
return
if(!isnull(P))
if (!P.toff && cartridge.charges > 0)
cartridge.charges--
var/difficulty = 2
if(P.cartridge)
difficulty += P.cartridge.access_medical
difficulty += P.cartridge.access_security
difficulty += P.cartridge.access_engine
difficulty += P.cartridge.access_clown
difficulty += P.cartridge.access_janitor
if(P.hidden_uplink)
difficulty += 3
if(prob(difficulty))
U.show_message("<span class='warning'>An error flashes on your [src].</span>", 1)
else if (prob(difficulty * 7))
U.show_message("<span class='warning'>Energy feeds back into your [src]!</span>", 1)
ui.close()
detonate_act(src)
log_admin("[key_name(U)] just attempted to blow up [P] with the Detomatix cartridge but failed, blowing themselves up")
message_admins("[key_name_admin(U)] just attempted to blow up [P] with the Detomatix cartridge but failed.", 1)
else
U.show_message("<span class='notice'>Success!</span>", 1)
log_admin("[key_name(U)] just attempted to blow up [P] with the Detomatix cartridge and succeeded")
message_admins("[key_name_admin(U)] just attempted to blow up [P] with the Detomatix cartridge and succeeded.", 1)
detonate_act(P)
else
to_chat(U, "No charges left.")
else
to_chat(U, "PDA not found.")
else
U.unset_machine()
ui.close()
return 0
//pAI FUNCTIONS===================================
if("pai")
if(pai)
if(pai.loc != src)
pai = null
else
switch(href_list["option"])
if("1") // Configure pAI device
pai.attack_self(U)
if("2") // Eject pAI device
var/turf/T = get_turf_or_move(src.loc)
if(T)
pai.loc = T
pai = null
return set_ringtone()
else
mode = text2num(href_list["choice"])
if(cartridge)
cartridge.mode = mode
if(current_app)
. = current_app.Topic(href, href_list)
//EXTRA FUNCTIONS===================================
if (mode == 2||mode == 21)//To clear message overlays.
new_message = 0
update_icon()
if (mode == 6||mode == 61)//To clear news overlays.
new_news = 0
update_icon()
if ((honkamt > 0) && (prob(60)))//For clown virus.
if((honkamt > 0) && (prob(60)))//For clown virus.
honkamt--
playsound(src, 'sound/items/bikehorn.ogg', 30, 1)
playsound(loc, 'sound/items/bikehorn.ogg', 30, 1)
return 1 // return 1 tells it to refresh the UI in NanoUI
return // return 1 tells it to refresh the UI in NanoUI
/obj/item/device/pda/update_icon()
..()
@@ -1230,8 +969,9 @@ var/global/list/obj/item/device/pda/PDAs = list()
return
if(can_use(usr))
mode = 0
SSnanoui.update_uis(src)
start_program(find_program(/datum/data/pda/app/main_menu))
notifying_programs.Cut()
overlays -= image('icons/obj/pda.dmi', "pda-r")
to_chat(usr, "<span class='notice'>You press the reset button on \the [src].</span>")
else
to_chat(usr, "<span class='notice'>You cannot do this while restrained.</span>")
@@ -1286,8 +1026,8 @@ var/global/list/obj/item/device/pda/PDAs = list()
if(ismob(loc))
var/mob/M = loc
M.put_in_hands(cartridge)
mode = 0
scanmode = 0
// mode = 0
// scanmode = 0
if (cartridge.radio)
cartridge.radio.hostpda = null
to_chat(usr, "<span class='notice'>You remove \the [cartridge] from the [name].</span>")
@@ -1363,128 +1103,132 @@ var/global/list/obj/item/device/pda/PDAs = list()
return
/obj/item/device/pda/attack(mob/living/C as mob, mob/living/user as mob)
if (istype(C, /mob/living/carbon))
switch(scanmode)
if(1)
if (istype(C, /mob/living/carbon) && scanmode)
scanmode.scan_mob(C, user)
for (var/mob/O in viewers(C, null))
O.show_message("<span class='warning'>\The [user] has analyzed [C]'s vitals!</span>", 1)
// switch(scanmode)
// if(1)
user.show_message("<span class='notice'>Analyzing Results for [C]:</span>")
user.show_message("<span class='notice'> Overall Status: [C.stat > 1 ? "dead" : "[C.health - C.halloss]% healthy"]</span>", 1)
user.show_message(text("<span class='notice'> Damage Specifics:</span> <span class='[]'>[]</span>-<span class='[]'>[]</span>-<span class='[]'>[]</span>-<span class='[]'>[]</span>",
(C.getOxyLoss() > 50) ? "warning" : "", C.getOxyLoss(),
(C.getToxLoss() > 50) ? "warning" : "", C.getToxLoss(),
(C.getFireLoss() > 50) ? "warning" : "", C.getFireLoss(),
(C.getBruteLoss() > 50) ? "warning" : "", C.getBruteLoss()
), 1)
user.show_message("<span class='notice'> Key: Suffocation/Toxin/Burns/Brute</span>", 1)
user.show_message("<span class='notice'> Body Temperature: [C.bodytemperature-T0C]&deg;C ([C.bodytemperature*1.8-459.67]&deg;F)</span>", 1)
if(C.tod && (C.stat == DEAD || (C.status_flags & FAKEDEATH)))
user.show_message("<span class='notice'> Time of Death: [C.tod]</span>")
if(istype(C, /mob/living/carbon/human))
var/mob/living/carbon/human/H = C
var/list/damaged = H.get_damaged_organs(1,1)
user.show_message("<span class='notice'>Localized Damage, Brute/Burn:</span>",1)
if(length(damaged)>0)
for(var/obj/item/organ/external/org in damaged)
user.show_message(text("<span class='notice'> []: <span class='[]'>[]</span>-<span class='[]'>[]</span></span>",
capitalize(org.name), (org.brute_dam > 0) ? "warning" : "notice", org.brute_dam, (org.burn_dam > 0) ? "warning" : "notice", org.burn_dam),1)
else
user.show_message("<span class='notice'> Limbs are OK.</span>",1)
// for (var/mob/O in viewers(C, null))
// O.show_message("<span class='warning'>\The [user] has analyzed [C]'s vitals!</span>", 1)
if(2)
if (!istype(C:dna, /datum/dna))
to_chat(user, "<span class='notice'>No fingerprints found on [C]</span>")
else
to_chat(user, text("<span class='notice'>\The [C]'s Fingerprints: [md5(C:dna.uni_identity)]</span>"))
if ( !(C:blood_DNA) )
to_chat(user, "<span class='notice'>No blood found on [C]</span>")
if(C:blood_DNA)
qdel(C:blood_DNA)
else
to_chat(user, "<span class='notice'>Blood found on [C]. Analysing...</span>")
spawn(15)
for(var/blood in C:blood_DNA)
to_chat(user, "<span class='notice'>Blood type: [C:blood_DNA[blood]]\nDNA: [blood]</span>")
// user.show_message("<span class='notice'>Analyzing Results for [C]:</span>")
// user.show_message("<span class='notice'> Overall Status: [C.stat > 1 ? "dead" : "[C.health - C.halloss]% healthy"]</span>", 1)
// user.show_message(text("<span class='notice'> Damage Specifics:</span> <span class='[]'>[]</span>-<span class='[]'>[]</span>-<span class='[]'>[]</span>-<span class='[]'>[]</span>",
// (C.getOxyLoss() > 50) ? "warning" : "", C.getOxyLoss(),
// (C.getToxLoss() > 50) ? "warning" : "", C.getToxLoss(),
// (C.getFireLoss() > 50) ? "warning" : "", C.getFireLoss(),
// (C.getBruteLoss() > 50) ? "warning" : "", C.getBruteLoss()
// ), 1)
// user.show_message("<span class='notice'> Key: Suffocation/Toxin/Burns/Brute</span>", 1)
// user.show_message("<span class='notice'> Body Temperature: [C.bodytemperature-T0C]&deg;C ([C.bodytemperature*1.8-459.67]&deg;F)</span>", 1)
// if(C.tod && (C.stat == DEAD || (C.status_flags & FAKEDEATH)))
// user.show_message("<span class='notice'> Time of Death: [C.tod]</span>")
// if(istype(C, /mob/living/carbon/human))
// var/mob/living/carbon/human/H = C
// var/list/damaged = H.get_damaged_organs(1,1)
// user.show_message("<span class='notice'>Localized Damage, Brute/Burn:</span>",1)
// if(length(damaged)>0)
// for(var/obj/item/organ/external/org in damaged)
// user.show_message(text("<span class='notice'> []: <span class='[]'>[]</span>-<span class='[]'>[]</span></span>",
// capitalize(org.name), (org.brute_dam > 0) ? "warning" : "notice", org.brute_dam, (org.burn_dam > 0) ? "warning" : "notice", org.burn_dam),1)
// else
// user.show_message("<span class='notice'> Limbs are OK.</span>",1)
if(4)
user.visible_message("<span class='warning'>\The [user] has analyzed [C]'s radiation levels!</span>", "<span class='notice'>You have analyzed [C]'s radiation levels!</span>")
to_chat(user, "<span class='notice'>Analyzing Results for [C]:</span>")
if(C.radiation)
to_chat(user, "<span class='notice'>Radiation Level: [C.radiation]</span>")
else
to_chat(user, "<span class='notice'>No radiation detected.</span>")
// if(2)
// if (!istype(C:dna, /datum/dna))
// to_chat(user, "<span class='notice'>No fingerprints found on [C]</span>")
// else
// to_chat(user, text("<span class='notice'>\The [C]'s Fingerprints: [md5(C:dna.uni_identity)]</span>"))
// if ( !(C:blood_DNA) )
// to_chat(user, "<span class='notice'>No blood found on [C]</span>")
// if(C:blood_DNA)
// qdel(C:blood_DNA)
// else
// to_chat(user, "<span class='notice'>Blood found on [C]. Analysing...</span>")
// spawn(15)
// for(var/blood in C:blood_DNA)
// to_chat(user, "<span class='notice'>Blood type: [C:blood_DNA[blood]]\nDNA: [blood]</span>")
// if(4)
// user.visible_message("<span class='warning'>\The [user] has analyzed [C]'s radiation levels!</span>", "<span class='notice'>You have analyzed [C]'s radiation levels!</span>")
// to_chat(user, "<span class='notice'>Analyzing Results for [C]:</span>")
// if(C.radiation)
// to_chat(user, "<span class='notice'>Radiation Level: [C.radiation]</span>")
// else
// to_chat(user, "<span class='notice'>No radiation detected.</span>")
/obj/item/device/pda/afterattack(atom/A as mob|obj|turf|area, mob/user as mob, proximity)
if(!proximity) return
switch(scanmode)
if(proximity && scanmode)
scanmode.scan_atom(A, user)
// if(!proximity) return
// switch(scanmode)
if(3)
if(!isobj(A))
return
if(!isnull(A.reagents))
if(A.reagents.reagent_list.len > 0)
var/reagents_length = A.reagents.reagent_list.len
to_chat(user, "<span class='notice'>[reagents_length] chemical agent[reagents_length > 1 ? "s" : ""] found.</span>")
for (var/re in A.reagents.reagent_list)
to_chat(user, "<span class='notice'> [re]</span>")
else
to_chat(user, "<span class='notice'>No active chemical agents found in [A].</span>")
else
to_chat(user, "<span class='notice'>No significantchemical agents found in [A].</span>")
// if(3)
// if(!isobj(A))
// return
// if(!isnull(A.reagents))
// if(A.reagents.reagent_list.len > 0)
// var/reagents_length = A.reagents.reagent_list.len
// to_chat(user, "<span class='notice'>[reagents_length] chemical agent[reagents_length > 1 ? "s" : ""] found.</span>")
// for (var/re in A.reagents.reagent_list)
// to_chat(user, "<span class='notice'> [re]</span>")
// else
// to_chat(user, "<span class='notice'>No active chemical agents found in [A].</span>")
// else
// to_chat(user, "<span class='notice'>No significantchemical agents found in [A].</span>")
if(5)
analyze_gases(A, user)
// if(5)
// analyze_gases(A, user)
if (!scanmode && istype(A, /obj/item/weapon/paper) && owner)
// JMO 20140705: Makes scanned document show up properly in the notes. Not pretty for formatted documents,
// as this will clobber the HTML, but at least it lets you scan a document. You can restore the original
// notes by editing the note again. (Was going to allow you to edit, but scanned documents are too long.)
var/raw_scan = (A:info)
var/formatted_scan = ""
// Scrub out the tags (replacing a few formatting ones along the way)
// if (!scanmode && istype(A, /obj/item/weapon/paper) && owner)
// // JMO 20140705: Makes scanned document show up properly in the notes. Not pretty for formatted documents,
// // as this will clobber the HTML, but at least it lets you scan a document. You can restore the original
// // notes by editing the note again. (Was going to allow you to edit, but scanned documents are too long.)
// var/raw_scan = (A:info)
// var/formatted_scan = ""
// // Scrub out the tags (replacing a few formatting ones along the way)
// Find the beginning and end of the first tag.
var/tag_start = findtext(raw_scan,"<")
var/tag_stop = findtext(raw_scan,">")
// // Find the beginning and end of the first tag.
// var/tag_start = findtext(raw_scan,"<")
// var/tag_stop = findtext(raw_scan,">")
// Until we run out of complete tags...
while(tag_start&&tag_stop)
var/pre = copytext(raw_scan,1,tag_start) // Get the stuff that comes before the tag
var/tag = lowertext(copytext(raw_scan,tag_start+1,tag_stop)) // Get the tag so we can do intellegent replacement
var/tagend = findtext(tag," ") // Find the first space in the tag if there is one.
// // Until we run out of complete tags...
// while(tag_start&&tag_stop)
// var/pre = copytext(raw_scan,1,tag_start) // Get the stuff that comes before the tag
// var/tag = lowertext(copytext(raw_scan,tag_start+1,tag_stop)) // Get the tag so we can do intellegent replacement
// var/tagend = findtext(tag," ") // Find the first space in the tag if there is one.
// Anything that's before the tag can just be added as is.
formatted_scan = formatted_scan+pre
// // Anything that's before the tag can just be added as is.
// formatted_scan = formatted_scan+pre
// If we have a space after the tag (and presumably attributes) just crop that off.
if (tagend)
tag=copytext(tag,1,tagend)
// // If we have a space after the tag (and presumably attributes) just crop that off.
// if (tagend)
// tag=copytext(tag,1,tagend)
if (tag=="p"||tag=="/p"||tag=="br") // Check if it's I vertical space tag.
formatted_scan=formatted_scan+"<br>" // If so, add some padding in.
// if (tag=="p"||tag=="/p"||tag=="br") // Check if it's I vertical space tag.
// formatted_scan=formatted_scan+"<br>" // If so, add some padding in.
raw_scan = copytext(raw_scan,tag_stop+1) // continue on with the stuff after the tag
// raw_scan = copytext(raw_scan,tag_stop+1) // continue on with the stuff after the tag
// Look for the next tag in what's left
tag_start = findtext(raw_scan,"<")
tag_stop = findtext(raw_scan,">")
// // Look for the next tag in what's left
// tag_start = findtext(raw_scan,"<")
// tag_stop = findtext(raw_scan,">")
// Anything that is left in the page. just tack it on to the end as is
formatted_scan=formatted_scan+raw_scan
// // Anything that is left in the page. just tack it on to the end as is
// formatted_scan=formatted_scan+raw_scan
// If there is something in there already, pad it out.
if (length(note)>0)
note = note + "<br><br>"
// // If there is something in there already, pad it out.
// if (length(note)>0)
// note = note + "<br><br>"
// Store the scanned document to the notes
note = "Scanned Document. Edit to restore previous notes/delete scan.<br>----------<br>" + formatted_scan + "<br>"
// notehtml ISN'T set to allow user to get their old notes back. A better implementation would add a "scanned documents"
// feature to the PDA, which would better convey the availability of the feature, but this will work for now.
// // Store the scanned document to the notes
// note = "Scanned Document. Edit to restore previous notes/delete scan.<br>----------<br>" + formatted_scan + "<br>"
// // notehtml ISN'T set to allow user to get their old notes back. A better implementation would add a "scanned documents"
// // feature to the PDA, which would better convey the availability of the feature, but this will work for now.
// Inform the user
to_chat(user, "<span class='notice'>Paper scanned and OCRed to notekeeper.</span>") //concept of scanning paper copyright brainoblivion 2009
// // Inform the user
// to_chat(user, "<span class='notice'>Paper scanned and OCRed to notekeeper.</span>") //concept of scanning paper copyright brainoblivion 2009
/obj/item/device/pda/proc/explode() //This needs tuning. //Sure did.
@@ -1501,8 +1245,12 @@ var/global/list/obj/item/device/pda/PDAs = list()
src.id.forceMove(get_turf(src.loc))
else
QDEL_NULL(src.id)
QDEL_NULL(src.cartridge)
QDEL_NULL(src.pai)
current_app = null
scanmode = null
QDEL_NULL(pai)
QDEL_LIST(programs)
QDEL_NULL(cartridge)
return ..()
/obj/item/device/pda/clown/Crossed(atom/movable/AM as mob|obj) //Clown PDA is slippery.