mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-22 11:38:12 +01:00
Merge pull request #9062 from ShadowLarkens/tgui_finale
NanoUI Goes To Brazil
This commit is contained in:
@@ -233,7 +233,6 @@ var/global/list/obj/item/device/communicator/all_communicators = list()
|
||||
initialize_exonet(user)
|
||||
alert_called = 0
|
||||
update_icon()
|
||||
ui_interact(user) // TGUITODO: Remove
|
||||
tgui_interact(user)
|
||||
if(video_source)
|
||||
watch_video(user)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
var/in_hack_mode = 0
|
||||
var/list/known_targets
|
||||
var/list/supported_types
|
||||
var/datum/topic_state/default/must_hack/hack_state
|
||||
var/datum/tgui_state/default/must_hack/hack_state
|
||||
|
||||
/obj/item/device/multitool/hacktool/New()
|
||||
..()
|
||||
@@ -39,7 +39,8 @@
|
||||
if(!attempt_hack(user, A))
|
||||
return 0
|
||||
|
||||
A.ui_interact(user, state = hack_state)
|
||||
// Note, if you ever want to expand supported_types, you must manually add the custom state argument to their tgui_interact
|
||||
A.tgui_interact(user, custom_state = hack_state)
|
||||
return 1
|
||||
|
||||
/obj/item/device/multitool/hacktool/proc/attempt_hack(var/mob/user, var/atom/target)
|
||||
@@ -83,18 +84,18 @@
|
||||
/obj/item/device/multitool/hacktool/proc/on_target_destroy(var/target)
|
||||
known_targets -= target
|
||||
|
||||
/datum/topic_state/default/must_hack
|
||||
/datum/tgui_state/default/must_hack
|
||||
var/obj/item/device/multitool/hacktool/hacktool
|
||||
|
||||
/datum/topic_state/default/must_hack/New(var/hacktool)
|
||||
/datum/tgui_state/default/must_hack/New(var/hacktool)
|
||||
src.hacktool = hacktool
|
||||
..()
|
||||
|
||||
/datum/topic_state/default/must_hack/Destroy()
|
||||
/datum/tgui_state/default/must_hack/Destroy()
|
||||
hacktool = null
|
||||
return ..()
|
||||
|
||||
/datum/topic_state/default/must_hack/can_use_topic(var/src_object, var/mob/user)
|
||||
/datum/tgui_state/default/must_hack/can_use_topic(src_object, mob/user)
|
||||
if(!hacktool || !hacktool.in_hack_mode || !(src_object in hacktool.known_targets))
|
||||
return STATUS_CLOSE
|
||||
return ..()
|
||||
|
||||
@@ -151,18 +151,10 @@ var/global/list/default_medbay_channels = list(
|
||||
|
||||
return tgui_interact(user)
|
||||
|
||||
/obj/item/device/radio/ui_interact(mob/user, ui_key, datum/nanoui/ui, force_open, datum/nano_ui/master_ui, datum/topic_state/state)
|
||||
log_runtime(EXCEPTION("Warning: [user] attempted to call ui_interact on radio [src] [type]. This is deprecated. Please update the caller to tgui_interact."))
|
||||
|
||||
/obj/item/device/radio/Topic(href, href_list)
|
||||
if(href_list["track"])
|
||||
log_runtime(EXCEPTION("Warning: Topic() was improperly called on radio [src] [type], with the track href and \[[href] [json_encode(href_list)]]. Please update the caller to use tgui_act."))
|
||||
. = ..()
|
||||
|
||||
/obj/item/device/radio/tgui_interact(mob/user, datum/tgui/ui)
|
||||
/obj/item/device/radio/tgui_interact(mob/user, datum/tgui/ui, datum/tgui/parent_ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, "Radio", name)
|
||||
ui = new(user, src, "Radio", name, parent_ui)
|
||||
ui.open()
|
||||
|
||||
/obj/item/device/radio/tgui_data(mob/user)
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
popup.set_content(jointext(dat,null))
|
||||
popup.open()
|
||||
|
||||
/obj/item/device/tvcamera/Topic(bred, href_list, state = physical_state)
|
||||
/obj/item/device/tvcamera/Topic(bred, href_list, state = GLOB.tgui_physical_state)
|
||||
if(..())
|
||||
return 1
|
||||
if(href_list["channel"])
|
||||
|
||||
@@ -6,8 +6,11 @@
|
||||
var/electronic_warfare = 1
|
||||
var/mob/registered_user = null
|
||||
|
||||
var/datum/tgui_module/agentcard/agentcard_module
|
||||
|
||||
/obj/item/weapon/card/id/syndicate/Initialize()
|
||||
. = ..()
|
||||
agentcard_module = new(src)
|
||||
access = syndicate_access.Copy()
|
||||
|
||||
/obj/item/weapon/card/id/syndicate/station_access/Initialize()
|
||||
@@ -15,6 +18,7 @@
|
||||
access |= get_all_station_access()
|
||||
|
||||
/obj/item/weapon/card/id/syndicate/Destroy()
|
||||
QDEL_NULL(agentcard_module)
|
||||
unset_registered_user(registered_user)
|
||||
return ..()
|
||||
|
||||
@@ -36,33 +40,12 @@
|
||||
if(registered_user == user)
|
||||
switch(alert("Would you like edit the ID, or show it?","Show or Edit?", "Edit","Show"))
|
||||
if("Edit")
|
||||
ui_interact(user)
|
||||
agentcard_module.tgui_interact(user)
|
||||
if("Show")
|
||||
..()
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/weapon/card/id/syndicate/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
var/data[0]
|
||||
var/entries[0]
|
||||
entries[++entries.len] = list("name" = "Age", "value" = age)
|
||||
entries[++entries.len] = list("name" = "Appearance", "value" = "Set")
|
||||
entries[++entries.len] = list("name" = "Assignment", "value" = assignment)
|
||||
entries[++entries.len] = list("name" = "Blood Type", "value" = blood_type)
|
||||
entries[++entries.len] = list("name" = "DNA Hash", "value" = dna_hash)
|
||||
entries[++entries.len] = list("name" = "Fingerprint Hash", "value" = fingerprint_hash)
|
||||
entries[++entries.len] = list("name" = "Name", "value" = registered_name)
|
||||
entries[++entries.len] = list("name" = "Photo", "value" = "Update")
|
||||
entries[++entries.len] = list("name" = "Sex", "value" = sex)
|
||||
entries[++entries.len] = list("name" = "Factory Reset", "value" = "Use With Care")
|
||||
data["electronic_warfare"] = electronic_warfare
|
||||
data["entries"] = entries
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "agent_id_card.tmpl", "Fake ID", 600, 400)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
|
||||
/obj/item/weapon/card/id/syndicate/proc/register_user(var/mob/user)
|
||||
if(!istype(user) || user == registered_user)
|
||||
@@ -79,114 +62,6 @@
|
||||
registered_user.unregister(OBSERVER_EVENT_DESTROY, src)
|
||||
registered_user = null
|
||||
|
||||
/obj/item/weapon/card/id/syndicate/CanUseTopic(mob/user)
|
||||
if(user != registered_user)
|
||||
return STATUS_CLOSE
|
||||
return ..()
|
||||
|
||||
/obj/item/weapon/card/id/syndicate/Topic(href, href_list, var/datum/topic_state/state)
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
var/user = usr
|
||||
if(href_list["electronic_warfare"])
|
||||
electronic_warfare = text2num(href_list["electronic_warfare"])
|
||||
to_chat(user, "<span class='notice'>Electronic warfare [electronic_warfare ? "enabled" : "disabled"].</span>")
|
||||
else if(href_list["set"])
|
||||
switch(href_list["set"])
|
||||
if("Age")
|
||||
var/new_age = input(user,"What age would you like to put on this card?","Agent Card Age", age) as null|num
|
||||
if(!isnull(new_age) && CanUseTopic(user, state))
|
||||
if(new_age < 0)
|
||||
age = initial(age)
|
||||
else
|
||||
age = new_age
|
||||
to_chat(user, "<span class='notice'>Age has been set to '[age]'.</span>")
|
||||
. = 1
|
||||
if("Appearance")
|
||||
var/datum/card_state/choice = input(user, "Select the appearance for this card.", "Agent Card Appearance") as null|anything in id_card_states()
|
||||
if(choice && CanUseTopic(user, state))
|
||||
src.icon_state = choice.icon_state
|
||||
src.item_state = choice.item_state
|
||||
to_chat(usr, "<span class='notice'>Appearance changed to [choice].</span>")
|
||||
. = 1
|
||||
if("Assignment")
|
||||
var/new_job = sanitize(input(user,"What assignment would you like to put on this card?\nChanging assignment will not grant or remove any access levels.","Agent Card Assignment", assignment) as null|text)
|
||||
if(!isnull(new_job) && CanUseTopic(user, state))
|
||||
src.assignment = new_job
|
||||
to_chat(user, "<span class='notice'>Occupation changed to '[new_job]'.</span>")
|
||||
update_name()
|
||||
. = 1
|
||||
if("Blood Type")
|
||||
var/default = blood_type
|
||||
if(default == initial(blood_type) && ishuman(user))
|
||||
var/mob/living/carbon/human/H = user
|
||||
if(H.dna)
|
||||
default = H.dna.b_type
|
||||
var/new_blood_type = sanitize(input(user,"What blood type would you like to be written on this card?","Agent Card Blood Type",default) as null|text)
|
||||
if(!isnull(new_blood_type) && CanUseTopic(user, state))
|
||||
src.blood_type = new_blood_type
|
||||
to_chat(user, "<span class='notice'>Blood type changed to '[new_blood_type]'.</span>")
|
||||
. = 1
|
||||
if("DNA Hash")
|
||||
var/default = dna_hash
|
||||
if(default == initial(dna_hash) && ishuman(user))
|
||||
var/mob/living/carbon/human/H = user
|
||||
if(H.dna)
|
||||
default = H.dna.unique_enzymes
|
||||
var/new_dna_hash = sanitize(input(user,"What DNA hash would you like to be written on this card?","Agent Card DNA Hash",default) as null|text)
|
||||
if(!isnull(new_dna_hash) && CanUseTopic(user, state))
|
||||
src.dna_hash = new_dna_hash
|
||||
to_chat(user, "<span class='notice'>DNA hash changed to '[new_dna_hash]'.</span>")
|
||||
. = 1
|
||||
if("Fingerprint Hash")
|
||||
var/default = fingerprint_hash
|
||||
if(default == initial(fingerprint_hash) && ishuman(user))
|
||||
var/mob/living/carbon/human/H = user
|
||||
if(H.dna)
|
||||
default = md5(H.dna.uni_identity)
|
||||
var/new_fingerprint_hash = sanitize(input(user,"What fingerprint hash would you like to be written on this card?","Agent Card Fingerprint Hash",default) as null|text)
|
||||
if(!isnull(new_fingerprint_hash) && CanUseTopic(user, state))
|
||||
src.fingerprint_hash = new_fingerprint_hash
|
||||
to_chat(user, "<span class='notice'>Fingerprint hash changed to '[new_fingerprint_hash]'.</span>")
|
||||
. = 1
|
||||
if("Name")
|
||||
var/new_name = sanitizeName(input(user,"What name would you like to put on this card?","Agent Card Name", registered_name) as null|text)
|
||||
if(!isnull(new_name) && CanUseTopic(user, state))
|
||||
src.registered_name = new_name
|
||||
update_name()
|
||||
to_chat(user, "<span class='notice'>Name changed to '[new_name]'.</span>")
|
||||
. = 1
|
||||
if("Photo")
|
||||
set_id_photo(user)
|
||||
to_chat(user, "<span class='notice'>Photo changed.</span>")
|
||||
. = 1
|
||||
if("Sex")
|
||||
var/new_sex = sanitize(input(user,"What sex would you like to put on this card?","Agent Card Sex", sex) as null|text)
|
||||
if(!isnull(new_sex) && CanUseTopic(user, state))
|
||||
src.sex = new_sex
|
||||
to_chat(user, "<span class='notice'>Sex changed to '[new_sex]'.</span>")
|
||||
. = 1
|
||||
if("Factory Reset")
|
||||
if(alert("This will factory reset the card, including access and owner. Continue?", "Factory Reset", "No", "Yes") == "Yes" && CanUseTopic(user, state))
|
||||
age = initial(age)
|
||||
access = syndicate_access.Copy()
|
||||
assignment = initial(assignment)
|
||||
blood_type = initial(blood_type)
|
||||
dna_hash = initial(dna_hash)
|
||||
electronic_warfare = initial(electronic_warfare)
|
||||
fingerprint_hash = initial(fingerprint_hash)
|
||||
icon_state = initial(icon_state)
|
||||
name = initial(name)
|
||||
registered_name = initial(registered_name)
|
||||
unset_registered_user()
|
||||
sex = initial(sex)
|
||||
to_chat(user, "<span class='notice'>All information has been deleted from \the [src].</span>")
|
||||
. = 1
|
||||
|
||||
// Always update the UI, or buttons will spin indefinitely
|
||||
SSnanoui.update_uis(src)
|
||||
|
||||
/var/global/list/id_card_states
|
||||
/proc/id_card_states()
|
||||
if(!id_card_states)
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
old_turf.unregister_dangerous_object(src)
|
||||
new_turf.register_dangerous_object(src)
|
||||
|
||||
/obj/Topic(href, href_list, var/datum/topic_state/state = default_state)
|
||||
/obj/Topic(href, href_list, var/datum/tgui_state/state = GLOB.tgui_default_state)
|
||||
if(usr && ..())
|
||||
return 1
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
CouldNotUseTopic(usr)
|
||||
return 1
|
||||
|
||||
/obj/CanUseTopic(var/mob/user, var/datum/topic_state/state = default_state)
|
||||
/obj/CanUseTopic(var/mob/user, var/datum/tgui_state/state = GLOB.tgui_default_state)
|
||||
if(user.CanUseObjTopic(src))
|
||||
return ..()
|
||||
to_chat(user, "<span class='danger'>[bicon(src)]Access Denied!</span>")
|
||||
@@ -69,7 +69,7 @@
|
||||
return 1
|
||||
|
||||
/obj/proc/CouldUseTopic(var/mob/user)
|
||||
var/atom/host = nano_host()
|
||||
var/atom/host = tgui_host()
|
||||
host.add_hiddenprint(user)
|
||||
|
||||
/obj/proc/CouldNotUseTopic(var/mob/user)
|
||||
@@ -135,7 +135,6 @@
|
||||
in_use = 0
|
||||
|
||||
/obj/attack_ghost(mob/user)
|
||||
ui_interact(user)
|
||||
tgui_interact(user)
|
||||
..()
|
||||
|
||||
|
||||
@@ -20,8 +20,90 @@ GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
|
||||
var/has_items = FALSE
|
||||
var/dismantled = TRUE
|
||||
var/signs = 0 //maximum capacity hardcoded below
|
||||
var/list/tgui_icons = list()
|
||||
|
||||
var/static/list/equippable_item_whitelist
|
||||
|
||||
/obj/structure/janitorialcart/proc/equip_janicart_item(mob/user, obj/item/I)
|
||||
if(!equippable_item_whitelist)
|
||||
equippable_item_whitelist = typecacheof(list(
|
||||
/obj/item/weapon/storage/bag/trash,
|
||||
/obj/item/weapon/mop,
|
||||
/obj/item/weapon/reagent_containers/spray,
|
||||
/obj/item/device/lightreplacer,
|
||||
/obj/item/clothing/suit/caution,
|
||||
))
|
||||
|
||||
if(!is_type_in_typecache(I, equippable_item_whitelist))
|
||||
to_chat(user, "<span class='warning'>There's no room in [src] for [I].</span>")
|
||||
return FALSE
|
||||
|
||||
if(!user.unEquip(I, 0, src))
|
||||
to_chat(user, "<span class='warning'>[I] is stuck to your hand.</span>")
|
||||
return FALSE
|
||||
|
||||
if(istype(I, /obj/item/weapon/storage/bag/trash))
|
||||
if(mybag)
|
||||
to_chat(user, "<span class='warning'>[src] already has \an [I].</span>")
|
||||
return FALSE
|
||||
mybag = I
|
||||
setTguiIcon("mybag", mybag)
|
||||
|
||||
else if(istype(I, /obj/item/weapon/mop))
|
||||
if(mymop)
|
||||
to_chat(user, "<span class='warning'>[src] already has \an [I].</span>")
|
||||
return FALSE
|
||||
mymop = I
|
||||
setTguiIcon("mymop", mymop)
|
||||
|
||||
else if(istype(I, /obj/item/weapon/reagent_containers/spray))
|
||||
if(myspray)
|
||||
to_chat(user, "<span class='warning'>[src] already has \an [I].</span>")
|
||||
return FALSE
|
||||
myspray = I
|
||||
setTguiIcon("myspray", myspray)
|
||||
|
||||
else if(istype(I, /obj/item/device/lightreplacer))
|
||||
if(myreplacer)
|
||||
to_chat(user, "<span class='warning'>[src] already has \an [I].</span>")
|
||||
return FALSE
|
||||
myreplacer = I
|
||||
setTguiIcon("myreplacer", myreplacer)
|
||||
|
||||
else if(istype(I, /obj/item/clothing/suit/caution))
|
||||
if(signs < 4)
|
||||
signs++
|
||||
setTguiIcon("signs", I)
|
||||
else
|
||||
to_chat(user, "<span class='notice'>[src] can't hold any more signs.</span>")
|
||||
return FALSE
|
||||
else
|
||||
// This may look like duplicate code, but it's important that we don't call unEquip *and* warn the user if
|
||||
// something horrible goes wrong. (this else is never supposed to happen)
|
||||
to_chat(user, "<span class='warning'>There's no room in [src] for [I].</span>")
|
||||
return FALSE
|
||||
|
||||
update_icon()
|
||||
to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
|
||||
return TRUE
|
||||
|
||||
/obj/structure/janitorialcart/proc/setTguiIcon(key, atom/A)
|
||||
if(!istype(A) || !key)
|
||||
return
|
||||
|
||||
var/icon/F = getFlatIcon(A, defdir = SOUTH, no_anim = TRUE)
|
||||
tgui_icons["[key]"] = "'data:image/png;base64,[icon2base64(F)]'"
|
||||
SStgui.update_uis(src)
|
||||
|
||||
/obj/structure/janitorialcart/proc/nullTguiIcon(key)
|
||||
if(!key)
|
||||
return
|
||||
tgui_icons.Remove(key)
|
||||
SStgui.update_uis(src)
|
||||
|
||||
/obj/structure/janitorialcart/proc/clearTguiIcons()
|
||||
tgui_icons.Cut()
|
||||
SStgui.update_uis(src)
|
||||
|
||||
/obj/structure/janitorialcart/Destroy()
|
||||
QDEL_NULL(mybag)
|
||||
@@ -29,6 +111,7 @@ GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
|
||||
QDEL_NULL(myspray)
|
||||
QDEL_NULL(myreplacer)
|
||||
QDEL_NULL(mybucket)
|
||||
clearTguiIcons()
|
||||
return ..()
|
||||
|
||||
/obj/structure/janitorialcart/examine(mob/user)
|
||||
@@ -43,6 +126,7 @@ GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
|
||||
if (istype(O, /obj/structure/mopbucket) && !mybucket)
|
||||
O.forceMove(src)
|
||||
mybucket = O
|
||||
setTguiIcon("mybucket", mybucket)
|
||||
to_chat(user, "You mount the [O] on the janicart.")
|
||||
update_icon()
|
||||
else
|
||||
@@ -70,38 +154,19 @@ GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
|
||||
return 1
|
||||
|
||||
else if(istype(I, /obj/item/weapon/reagent_containers/spray) && !myspray)
|
||||
user.unEquip(I, 0, src)
|
||||
myspray = I
|
||||
update_icon()
|
||||
updateUsrDialog()
|
||||
to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
|
||||
equip_janicart_item(user, I)
|
||||
return 1
|
||||
|
||||
else if(istype(I, /obj/item/device/lightreplacer) && !myreplacer)
|
||||
user.unEquip(I, 0, src)
|
||||
myreplacer = I
|
||||
update_icon()
|
||||
updateUsrDialog()
|
||||
to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
|
||||
equip_janicart_item(user, I)
|
||||
return 1
|
||||
|
||||
else if(istype(I, /obj/item/weapon/storage/bag/trash) && !mybag)
|
||||
user.unEquip(I, 0, src)
|
||||
mybag = I
|
||||
update_icon()
|
||||
updateUsrDialog()
|
||||
to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
|
||||
equip_janicart_item(user, I)
|
||||
return 1
|
||||
|
||||
else if(istype(I, /obj/item/clothing/suit/caution))
|
||||
if(signs < 4)
|
||||
user.unEquip(I, 0, src)
|
||||
signs++
|
||||
update_icon()
|
||||
updateUsrDialog()
|
||||
to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
|
||||
else
|
||||
to_chat(user, "<span class='notice'>[src] can't hold any more signs.</span>")
|
||||
equip_janicart_item(user, I)
|
||||
return 1
|
||||
|
||||
else if(mybag)
|
||||
@@ -124,16 +189,7 @@ GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
|
||||
if(user.incapacitated() || !Adjacent(user)) return
|
||||
var/obj/I = usr.get_active_hand()
|
||||
if(istype(I, /obj/item/weapon/mop))
|
||||
if(!mymop)
|
||||
usr.drop_from_inventory(I,src)
|
||||
mymop = I
|
||||
update_icon()
|
||||
updateUsrDialog()
|
||||
to_chat(usr, "<span class='notice'>You put [I] into [src].</span>")
|
||||
update_icon()
|
||||
else
|
||||
to_chat(usr, "<span class='notice'>The cart already has a mop attached</span>")
|
||||
return
|
||||
equip_janicart_item(user, I)
|
||||
else if(istype(I, /obj/item/weapon/reagent_containers) && mybucket)
|
||||
var/obj/item/weapon/reagent_containers/C = I
|
||||
C.afterattack(mybucket, usr, 1)
|
||||
@@ -141,75 +197,95 @@ GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
|
||||
|
||||
|
||||
/obj/structure/janitorialcart/attack_hand(mob/user)
|
||||
ui_interact(user)
|
||||
tgui_interact(user)
|
||||
return
|
||||
|
||||
/obj/structure/janitorialcart/ui_interact(var/mob/user, var/ui_key = "main", var/datum/nanoui/ui = null, var/force_open = TRUE)
|
||||
var/data[0]
|
||||
data["name"] = capitalize(name)
|
||||
data["bag"] = mybag ? capitalize(mybag.name) : null
|
||||
data["bucket"] = mybucket ? capitalize(mybucket.name) : null
|
||||
data["mop"] = mymop ? capitalize(mymop.name) : null
|
||||
data["spray"] = myspray ? capitalize(myspray.name) : null
|
||||
data["replacer"] = myreplacer ? capitalize(myreplacer.name) : null
|
||||
data["signs"] = signs ? "[signs] sign\s" : null
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
/obj/structure/janitorialcart/tgui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "janitorcart.tmpl", "Janitorial cart", 240, 160)
|
||||
ui.set_initial_data(data)
|
||||
ui = new(user, src, "JanitorCart", name) // 240, 160
|
||||
ui.set_autoupdate(FALSE)
|
||||
ui.open()
|
||||
|
||||
/obj/structure/janitorialcart/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state)
|
||||
var/list/data = ..()
|
||||
|
||||
/obj/structure/janitorialcart/Topic(href, href_list)
|
||||
if(!in_range(src, usr))
|
||||
return
|
||||
if(!isliving(usr))
|
||||
return
|
||||
var/mob/living/user = usr
|
||||
data["mybag"] = mybag ? capitalize(mybag.name) : null
|
||||
data["mybucket"] = mybucket ? capitalize(mybucket.name) : null
|
||||
data["mymop"] = mymop ? capitalize(mymop.name) : null
|
||||
data["myspray"] = myspray ? capitalize(myspray.name) : null
|
||||
data["myreplacer"] = myreplacer ? capitalize(myreplacer.name) : null
|
||||
data["signs"] = signs ? "[signs] sign\s" : null
|
||||
|
||||
if(href_list["take"])
|
||||
switch(href_list["take"])
|
||||
if("garbage")
|
||||
if(mybag)
|
||||
user.put_in_hands(mybag)
|
||||
to_chat(user, "<span class='notice'>You take [mybag] from [src].</span>")
|
||||
mybag = null
|
||||
if("mop")
|
||||
if(mymop)
|
||||
user.put_in_hands(mymop)
|
||||
to_chat(user, "<span class='notice'>You take [mymop] from [src].</span>")
|
||||
mymop = null
|
||||
if("spray")
|
||||
if(myspray)
|
||||
user.put_in_hands(myspray)
|
||||
to_chat(user, "<span class='notice'>You take [myspray] from [src].</span>")
|
||||
myspray = null
|
||||
if("replacer")
|
||||
if(myreplacer)
|
||||
user.put_in_hands(myreplacer)
|
||||
to_chat(user, "<span class='notice'>You take [myreplacer] from [src].</span>")
|
||||
myreplacer = null
|
||||
if("sign")
|
||||
if(signs)
|
||||
var/obj/item/clothing/suit/caution/Sign = locate() in src
|
||||
if(Sign)
|
||||
user.put_in_hands(Sign)
|
||||
to_chat(user, "<span class='notice'>You take \a [Sign] from [src].</span>")
|
||||
signs--
|
||||
else
|
||||
warning("[src] signs ([signs]) didn't match contents")
|
||||
signs = 0
|
||||
if("bucket")
|
||||
if(mybucket)
|
||||
mybucket.forceMove(get_turf(user))
|
||||
to_chat(user, "<span class='notice'>You unmount [mybucket] from [src].</span>")
|
||||
mybucket = null
|
||||
data["icons"] = tgui_icons
|
||||
return data
|
||||
|
||||
/obj/structure/janitorialcart/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
|
||||
if(..())
|
||||
return TRUE
|
||||
|
||||
var/obj/item/I = usr.get_active_hand()
|
||||
|
||||
switch(action)
|
||||
if("bag")
|
||||
if(mybag)
|
||||
usr.put_in_hands(mybag)
|
||||
to_chat(usr, "<span class='notice'>You take [mybag] from [src].</span>")
|
||||
mybag = null
|
||||
nullTguiIcon("mybag")
|
||||
else if(is_type_in_typecache(I, equippable_item_whitelist))
|
||||
equip_janicart_item(usr, I)
|
||||
if("mop")
|
||||
if(mymop)
|
||||
usr.put_in_hands(mymop)
|
||||
to_chat(usr, "<span class='notice'>You take [mymop] from [src].</span>")
|
||||
mymop = null
|
||||
nullTguiIcon("mymop")
|
||||
else if(is_type_in_typecache(I, equippable_item_whitelist))
|
||||
equip_janicart_item(usr, I)
|
||||
if("spray")
|
||||
if(myspray)
|
||||
usr.put_in_hands(myspray)
|
||||
to_chat(usr, "<span class='notice'>You take [myspray] from [src].</span>")
|
||||
myspray = null
|
||||
nullTguiIcon("myspray")
|
||||
else if(is_type_in_typecache(I, equippable_item_whitelist))
|
||||
equip_janicart_item(usr, I)
|
||||
if("replacer")
|
||||
if(myreplacer)
|
||||
usr.put_in_hands(myreplacer)
|
||||
to_chat(usr, "<span class='notice'>You take [myreplacer] from [src].</span>")
|
||||
myreplacer = null
|
||||
nullTguiIcon("myreplacer")
|
||||
else if(is_type_in_typecache(I, equippable_item_whitelist))
|
||||
equip_janicart_item(usr, I)
|
||||
if("sign")
|
||||
if(istype(I, /obj/item/clothing/suit/caution) && signs < 4)
|
||||
equip_janicart_item(usr, I)
|
||||
else if(signs)
|
||||
var/obj/item/clothing/suit/caution/sign = locate() in src
|
||||
if(sign)
|
||||
usr.put_in_hands(sign)
|
||||
to_chat(usr, "<span class='notice'>You take \a [sign] from [src].</span>")
|
||||
signs--
|
||||
if(!signs)
|
||||
nullTguiIcon("signs")
|
||||
else
|
||||
to_chat(usr, "<span class='notice'>[src] doesn't have any signs left.</span>")
|
||||
if("bucket")
|
||||
if(mybucket)
|
||||
mybucket.forceMove(get_turf(usr))
|
||||
to_chat(usr, "<span class='notice'>You unmount [mybucket] from [src].</span>")
|
||||
mybucket = null
|
||||
nullTguiIcon("mybucket")
|
||||
else
|
||||
to_chat(usr, "<span class='notice'>((Drag and drop a mop bucket onto [src] to equip it.))</span>")
|
||||
return FALSE
|
||||
else
|
||||
return FALSE
|
||||
|
||||
update_icon()
|
||||
updateUsrDialog()
|
||||
|
||||
|
||||
return TRUE
|
||||
|
||||
/obj/structure/janitorialcart/update_icon()
|
||||
overlays.Cut()
|
||||
@@ -229,11 +305,6 @@ GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
|
||||
if(signs)
|
||||
overlays += "cart_sign[signs]"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//This is called if the cart is caught in an explosion, or destroyed by weapon fire
|
||||
/obj/structure/janitorialcart/proc/spill(var/chance = 100)
|
||||
var/turf/dropspot = get_turf(src)
|
||||
@@ -275,6 +346,7 @@ GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
|
||||
mybag = null
|
||||
|
||||
update_icon()
|
||||
clearTguiIcons()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
if(!UWC)
|
||||
return
|
||||
var/datum/category_item/underwear/selected_underwear = input(H, "Choose underwear:", "Choose underwear", H.all_underwear[UWC.name]) as null|anything in UWC.items
|
||||
if(selected_underwear && CanUseTopic(H, default_state))
|
||||
if(selected_underwear && CanUseTopic(H, GLOB.tgui_default_state))
|
||||
H.all_underwear[UWC.name] = selected_underwear
|
||||
H.hide_underwear[UWC.name] = FALSE
|
||||
. = TRUE
|
||||
|
||||
Reference in New Issue
Block a user