mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2026-08-29 08:09:34 +01:00
TGUI v3.0
This ports TGUI, and makes the old nano crew monitor and the disposal bins use it as first examples.
This commit is contained in:
@@ -212,7 +212,6 @@
|
||||
|
||||
// leave the disposal
|
||||
/obj/machinery/disposal/proc/go_out(mob/user)
|
||||
|
||||
if (user.client)
|
||||
user.client.eye = user.client.mob
|
||||
user.client.perspective = MOB_PERSPECTIVE
|
||||
@@ -222,11 +221,11 @@
|
||||
|
||||
// ai as human but can't flush
|
||||
/obj/machinery/disposal/attack_ai(mob/user as mob)
|
||||
interact(user, 1)
|
||||
add_hiddenprint(user)
|
||||
tgui_interact(user)
|
||||
|
||||
// human interact with machine
|
||||
/obj/machinery/disposal/attack_hand(mob/user as mob)
|
||||
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
|
||||
@@ -236,91 +235,147 @@
|
||||
|
||||
// Clumsy folks can only flush it.
|
||||
if(user.IsAdvancedToolUser(1))
|
||||
interact(user, 0)
|
||||
tgui_interact(user)
|
||||
else
|
||||
flush = !flush
|
||||
update()
|
||||
return
|
||||
|
||||
// user interaction
|
||||
/obj/machinery/disposal/interact(mob/user, var/ai=0)
|
||||
/obj/machinery/disposal/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_default_state)
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "DisposalBin", name, 300, 250, master_ui, state)
|
||||
ui.open()
|
||||
|
||||
src.add_fingerprint(user)
|
||||
if(stat & BROKEN)
|
||||
user.unset_machine()
|
||||
/obj/machinery/disposal/tgui_data(mob/user)
|
||||
var/list/data = list()
|
||||
|
||||
data["isAI"] = isAI(user)
|
||||
data["flushing"] = flush
|
||||
data["mode"] = mode
|
||||
data["pressure"] = round(clamp(100* air_contents.return_pressure() / (SEND_PRESSURE), 0, 100),1)
|
||||
|
||||
return data
|
||||
|
||||
/obj/machinery/disposal/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(usr.loc == src)
|
||||
to_chat(usr, "<span class='warning'>You cannot reach the controls from inside.</span>")
|
||||
return
|
||||
|
||||
var/dat = "<head><title>Waste Disposal Unit</title></head><body><TT><B>Waste Disposal Unit</B><HR>"
|
||||
if(mode==-1 && action != "eject") // If the mode is -1, only allow ejection
|
||||
to_chat(usr, "<span class='warning'>The disposal units power is disabled.</span>")
|
||||
return
|
||||
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
|
||||
add_fingerprint(usr)
|
||||
|
||||
if(!ai) // AI can't pull flush handle
|
||||
if(flush)
|
||||
dat += "Disposal handle: <A href='?src=\ref[src];handle=0'>Disengage</A> <B>Engaged</B>"
|
||||
else
|
||||
dat += "Disposal handle: <B>Disengaged</B> <A href='?src=\ref[src];handle=1'>Engage</A>"
|
||||
if(usr.stat || usr.restrained() || flushing)
|
||||
return
|
||||
|
||||
if(isturf(loc))
|
||||
if(action == "pumpOn")
|
||||
mode = 1
|
||||
update()
|
||||
if(action == "pumpOff")
|
||||
mode = 0
|
||||
update()
|
||||
|
||||
dat += "<BR><HR><A href='?src=\ref[src];eject=1'>Eject contents</A><HR>"
|
||||
if(!issilicon(usr))
|
||||
if(action == "engageHandle")
|
||||
flush = 1
|
||||
update()
|
||||
if(action == "disengageHandle")
|
||||
flush = 0
|
||||
update()
|
||||
|
||||
if(mode <= 0)
|
||||
dat += "Pump: <B>Off</B> <A href='?src=\ref[src];pump=1'>On</A><BR>"
|
||||
else if(mode == 1)
|
||||
dat += "Pump: <A href='?src=\ref[src];pump=0'>Off</A> <B>On</B> (pressurizing)<BR>"
|
||||
else
|
||||
dat += "Pump: <A href='?src=\ref[src];pump=0'>Off</A> <B>On</B> (idle)<BR>"
|
||||
if(action == "eject")
|
||||
eject()
|
||||
|
||||
return TRUE
|
||||
|
||||
|
||||
var/per = 100* air_contents.return_pressure() / (SEND_PRESSURE)
|
||||
// src.add_fingerprint(user)
|
||||
// if(stat & BROKEN)
|
||||
// user.unset_machine()
|
||||
// return
|
||||
|
||||
dat += "Pressure: [round(per, 1)]%<BR></body>"
|
||||
// var/dat = "<head><title>Waste Disposal Unit</title></head><body><TT><B>Waste Disposal Unit</B><HR>"
|
||||
|
||||
// if(!ai) // AI can't pull flush handle
|
||||
// if(flush)
|
||||
// dat += "Disposal handle: <A href='?src=\ref[src];handle=0'>Disengage</A> <B>Engaged</B>"
|
||||
// else
|
||||
// dat += "Disposal handle: <B>Disengaged</B> <A href='?src=\ref[src];handle=1'>Engage</A>"
|
||||
|
||||
// dat += "<BR><HR><A href='?src=\ref[src];eject=1'>Eject contents</A><HR>"
|
||||
|
||||
// if(mode <= 0)
|
||||
// dat += "Pump: <B>Off</B> <A href='?src=\ref[src];pump=1'>On</A><BR>"
|
||||
// else if(mode == 1)
|
||||
// dat += "Pump: <A href='?src=\ref[src];pump=0'>Off</A> <B>On</B> (pressurizing)<BR>"
|
||||
// else
|
||||
// dat += "Pump: <A href='?src=\ref[src];pump=0'>Off</A> <B>On</B> (idle)<BR>"
|
||||
|
||||
// var/per = 100* air_contents.return_pressure() / (SEND_PRESSURE)
|
||||
|
||||
// dat += "Pressure: [round(per, 1)]%<BR></body>"
|
||||
|
||||
|
||||
user.set_machine(src)
|
||||
user << browse(dat, "window=disposal;size=360x170")
|
||||
onclose(user, "disposal")
|
||||
// user.set_machine(src)
|
||||
// user << browse(dat, "window=disposal;size=360x170")
|
||||
// onclose(user, "disposal")
|
||||
|
||||
// handle machine interaction
|
||||
|
||||
/obj/machinery/disposal/Topic(href, href_list)
|
||||
if(usr.loc == src)
|
||||
to_chat(usr, "<font color='red'>You cannot reach the controls from inside.</font>")
|
||||
return
|
||||
// /obj/machinery/disposal/Topic(href, href_list)
|
||||
// if(usr.loc == src)
|
||||
// to_chat(usr, "<font color='red'>You cannot reach the controls from inside.</font>")
|
||||
// return
|
||||
|
||||
if(mode==-1 && !href_list["eject"]) // only allow ejecting if mode is -1
|
||||
to_chat(usr, "<font color='red'>The disposal units power is disabled.</font>")
|
||||
return
|
||||
if(..())
|
||||
return
|
||||
// if(mode==-1 && !href_list["eject"]) // only allow ejecting if mode is -1
|
||||
// to_chat(usr, "<font color='red'>The disposal units power is disabled.</font>")
|
||||
// return
|
||||
// if(..())
|
||||
// return
|
||||
|
||||
if(stat & BROKEN)
|
||||
return
|
||||
if(usr.stat || usr.restrained() || src.flushing)
|
||||
return
|
||||
// if(stat & BROKEN)
|
||||
// return
|
||||
// if(usr.stat || usr.restrained() || src.flushing)
|
||||
// return
|
||||
|
||||
if(istype(src.loc, /turf))
|
||||
usr.set_machine(src)
|
||||
// if(istype(src.loc, /turf))
|
||||
// usr.set_machine(src)
|
||||
|
||||
if(href_list["close"])
|
||||
usr.unset_machine()
|
||||
usr << browse(null, "window=disposal")
|
||||
return
|
||||
// if(href_list["close"])
|
||||
// usr.unset_machine()
|
||||
// usr << browse(null, "window=disposal")
|
||||
// return
|
||||
|
||||
if(href_list["pump"])
|
||||
if(text2num(href_list["pump"]))
|
||||
mode = 1
|
||||
else
|
||||
mode = 0
|
||||
update()
|
||||
// if(href_list["pump"])
|
||||
// if(text2num(href_list["pump"]))
|
||||
// mode = 1
|
||||
// else
|
||||
// mode = 0
|
||||
// update()
|
||||
|
||||
if(!isAI(usr))
|
||||
if(href_list["handle"])
|
||||
flush = text2num(href_list["handle"])
|
||||
update()
|
||||
// if(!isAI(usr))
|
||||
// if(href_list["handle"])
|
||||
// flush = text2num(href_list["handle"])
|
||||
// update()
|
||||
|
||||
if(href_list["eject"])
|
||||
eject()
|
||||
else
|
||||
usr << browse(null, "window=disposal")
|
||||
usr.unset_machine()
|
||||
return
|
||||
return
|
||||
// if(href_list["eject"])
|
||||
// eject()
|
||||
// else
|
||||
// usr << browse(null, "window=disposal")
|
||||
// usr.unset_machine()
|
||||
// return
|
||||
// return
|
||||
|
||||
// eject the contents of the disposal unit
|
||||
/obj/machinery/disposal/proc/eject()
|
||||
|
||||
Reference in New Issue
Block a user