mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
TGUI NIFs
This commit is contained in:
@@ -101,6 +101,9 @@ You can also set the stat of a NIF to NIF_TEMPFAIL without any issues to disable
|
||||
//Draw me yo.
|
||||
update_icon()
|
||||
|
||||
if(!our_statclick)
|
||||
our_statclick = new(null, "Open", src)
|
||||
|
||||
//Destructor cleans up references
|
||||
/obj/item/device/nif/Destroy()
|
||||
human = null
|
||||
@@ -356,6 +359,8 @@ You can also set the stat of a NIF to NIF_TEMPFAIL without any issues to disable
|
||||
/obj/item/device/nif/proc/notify(var/message,var/alert = 0)
|
||||
if(!human || stat == NIF_TEMPFAIL) return
|
||||
|
||||
last_notification = message // TGUI Hook
|
||||
|
||||
to_chat(human,"<b>\[[bicon(src.big_icon)]NIF\]</b> displays, \"<span class='[alert ? "danger" : "notice"]'>[message]</span>\"")
|
||||
if(prob(1)) human.visible_message("<span class='notice'>\The [human] [pick(look_messages)].</span>")
|
||||
if(alert)
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
nif_status = "Unknown - Error"
|
||||
nif_status += " (Condition: [nif_percent]%)"
|
||||
stat("NIF Status", nif_status)
|
||||
stat("UI", nif.our_statclick) // TGUI Hook
|
||||
|
||||
if(nif.stat == NIF_WORKING)
|
||||
stat("- Modules -", "LMB: Toggle, Shift+LMB: Info/Uninstall")
|
||||
|
||||
114
code/modules/nifsoft/nif_tgui.dm
Normal file
114
code/modules/nifsoft/nif_tgui.dm
Normal file
@@ -0,0 +1,114 @@
|
||||
/************************************************************************\
|
||||
* This module controls everything to do with the NIF's tgui interface. *
|
||||
\************************************************************************/
|
||||
/**
|
||||
* Etc variables on the NIF to keep this self contained
|
||||
*/
|
||||
/obj/item/device/nif
|
||||
var/static/list/valid_ui_themes = list(
|
||||
"abductor",
|
||||
"cardtable",
|
||||
"hackerman",
|
||||
"malfunction",
|
||||
"ntos",
|
||||
"paper",
|
||||
"retro",
|
||||
"syndicate"
|
||||
)
|
||||
var/tmp/obj/effect/statclick/nif_open/our_statclick
|
||||
var/tmp/last_notification
|
||||
|
||||
/**
|
||||
* Special stat button for the interface
|
||||
*/
|
||||
/obj/effect/statclick/nif_open
|
||||
/obj/effect/statclick/nif_open/Click(location, control, params)
|
||||
var/obj/item/device/nif/N = target
|
||||
if(istype(N))
|
||||
N.tgui_interact(usr)
|
||||
|
||||
/**
|
||||
* The NIF State ensures that only our authorized implanted user can touch us.
|
||||
*/
|
||||
/obj/item/device/nif/tgui_state(mob/user)
|
||||
return GLOB.tgui_nif_main_state
|
||||
|
||||
/**
|
||||
* Standard TGUI stub to open the NIF.js template.
|
||||
*/
|
||||
/obj/item/device/nif/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, "NIF", name)
|
||||
ui.open()
|
||||
|
||||
/**
|
||||
* tgui_data gives the UI any relevant data it needs.
|
||||
* In our case, that's basically everything from our statpanel.
|
||||
*/
|
||||
/obj/item/device/nif/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state)
|
||||
var/list/data = ..()
|
||||
|
||||
data["theme"] = save_data["ui_theme"]
|
||||
data["last_notification"] = last_notification
|
||||
|
||||
// Random biometric information
|
||||
data["nutrition"] = human.nutrition
|
||||
data["isSynthetic"] = human.isSynthetic()
|
||||
|
||||
data["nif_percent"] = round((durability/initial(durability))*100)
|
||||
data["nif_stat"] = stat
|
||||
|
||||
data["modules"] = list()
|
||||
if(stat == NIF_WORKING)
|
||||
for(var/nifsoft in nifsofts)
|
||||
if(!nifsoft)
|
||||
continue
|
||||
var/datum/nifsoft/NS = nifsoft
|
||||
data["modules"].Add(list(list(
|
||||
"name" = NS.name,
|
||||
"desc" = NS.desc,
|
||||
"p_drain" = NS.p_drain,
|
||||
"a_drain" = NS.a_drain,
|
||||
"illegal" = NS.illegal,
|
||||
"wear" = NS.wear,
|
||||
"cost" = NS.cost,
|
||||
"activates" = NS.activates,
|
||||
"active" = NS.active,
|
||||
"stat_text" = NS.stat_text(),
|
||||
"ref" = REF(NS),
|
||||
)))
|
||||
|
||||
return data
|
||||
|
||||
/**
|
||||
* tgui_act handles all user input in the UI.
|
||||
*/
|
||||
/obj/item/device/nif/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
|
||||
if(..())
|
||||
return TRUE
|
||||
|
||||
switch(action)
|
||||
if("setTheme")
|
||||
if((params["theme"] in valid_ui_themes) || params["theme"] == null)
|
||||
save_data["ui_theme"] = params["theme"]
|
||||
return TRUE
|
||||
if("toggle_module")
|
||||
var/datum/nifsoft/NS = locate(params["module"]) in nifsofts
|
||||
if(!istype(NS))
|
||||
return
|
||||
if(NS.activates)
|
||||
if(NS.active)
|
||||
NS.deactivate()
|
||||
else
|
||||
NS.activate()
|
||||
return TRUE
|
||||
if("uninstall")
|
||||
var/datum/nifsoft/NS = locate(params["module"]) in nifsofts
|
||||
if(!istype(NS))
|
||||
return
|
||||
NS.uninstall()
|
||||
return TRUE
|
||||
if("dismissNotification")
|
||||
last_notification = null
|
||||
return TRUE
|
||||
@@ -106,7 +106,7 @@
|
||||
vision_flags = (NIF_V_MESONS)
|
||||
incompatible_with = list(NIF_MATERIAL,NIF_THERMALS,NIF_NIGHTVIS)
|
||||
|
||||
life()
|
||||
/datum/nifsoft/mesons/life()
|
||||
if((. = ..()))
|
||||
var/mob/living/carbon/human/H = nif.human
|
||||
H.sight |= SEE_TURFS
|
||||
@@ -125,7 +125,7 @@
|
||||
vision_flags = (NIF_V_MATERIAL)
|
||||
incompatible_with = list(NIF_MESONS,NIF_THERMALS,NIF_NIGHTVIS)
|
||||
|
||||
life()
|
||||
/datum/nifsoft/material/life()
|
||||
if((. = ..()))
|
||||
var/mob/living/carbon/human/H = nif.human
|
||||
H.sight |= SEE_OBJS
|
||||
@@ -145,7 +145,7 @@
|
||||
vision_flags = (NIF_V_THERMALS)
|
||||
incompatible_with = list(NIF_MESONS,NIF_MATERIAL,NIF_NIGHTVIS)
|
||||
|
||||
life()
|
||||
/datum/nifsoft/thermals/life()
|
||||
if((. = ..()))
|
||||
var/mob/living/carbon/human/H = nif.human
|
||||
H.sight |= SEE_MOBS
|
||||
@@ -164,7 +164,7 @@
|
||||
vision_flags = (NIF_V_NIGHTVIS)
|
||||
incompatible_with = list(NIF_MESONS,NIF_MATERIAL,NIF_THERMALS)
|
||||
|
||||
life()
|
||||
/datum/nifsoft/nightvis/life()
|
||||
if((. = ..()))
|
||||
var/mob/living/carbon/human/H = nif.human
|
||||
H.see_in_dark += 7
|
||||
|
||||
@@ -13,17 +13,17 @@
|
||||
health_flags = (NIF_H_ORGREPAIR)
|
||||
|
||||
//These self-activate on their own, these aren't user-settable to on/off.
|
||||
activate()
|
||||
/datum/nifsoft/medichines_org/activate()
|
||||
if((. = ..()))
|
||||
mode = 1
|
||||
|
||||
deactivate()
|
||||
/datum/nifsoft/medichines_org/deactivate()
|
||||
if((. = ..()))
|
||||
a_drain = initial(a_drain)
|
||||
mode = initial(mode)
|
||||
nif.human.Stasis(0)
|
||||
|
||||
life()
|
||||
/datum/nifsoft/medichines_org/life()
|
||||
if((. = ..()))
|
||||
var/mob/living/carbon/human/H = nif.human
|
||||
var/HP_percent = H.health/H.getMaxHealth()
|
||||
@@ -86,15 +86,15 @@
|
||||
health_flags = (NIF_H_SYNTHREPAIR)
|
||||
|
||||
//These self-activate on their own, these aren't user-settable to on/off.
|
||||
activate()
|
||||
/datum/nifsoft/medichines_syn/activate()
|
||||
if((. = ..()))
|
||||
mode = 1
|
||||
|
||||
deactivate()
|
||||
/datum/nifsoft/medichines_syn/deactivate()
|
||||
if((. = ..()))
|
||||
mode = 0
|
||||
|
||||
life()
|
||||
/datum/nifsoft/medichines_syn/life()
|
||||
if((. = ..()))
|
||||
//We're good!
|
||||
if(!nif.human.bad_external_organs.len)
|
||||
@@ -137,18 +137,18 @@
|
||||
var/filled = 100 //Tracks the internal tank 'refilling', which still uses power
|
||||
health_flags = (NIF_H_SPAREBREATH)
|
||||
|
||||
activate()
|
||||
/datum/nifsoft/spare_breath/activate()
|
||||
if(!(filled > 50))
|
||||
nif.notify("Respirocytes not saturated!",TRUE)
|
||||
return FALSE
|
||||
if((. = ..()))
|
||||
nif.notify("Now taking air from reserves.")
|
||||
|
||||
deactivate()
|
||||
/datum/nifsoft/spare_breath/deactivate()
|
||||
if((. = ..()))
|
||||
nif.notify("Now taking air from environment and refilling reserves.")
|
||||
|
||||
life()
|
||||
/datum/nifsoft/spare_breath/life()
|
||||
if((. = ..()))
|
||||
if(active) //Supplying air, not recharging it
|
||||
switch(filled) //Text warnings
|
||||
@@ -172,7 +172,7 @@
|
||||
else if(nif.use_charge(0.1) && ++filled == 100)
|
||||
nif.notify("Respirocytes now fully saturated.")
|
||||
|
||||
proc/resp_breath()
|
||||
/datum/nifsoft/spare_breath/proc/resp_breath()
|
||||
if(!active) return null
|
||||
var/datum/gas_mixture/breath = new(BREATH_VOLUME)
|
||||
breath.adjust_gas("oxygen", BREATH_MOLES)
|
||||
@@ -185,7 +185,7 @@
|
||||
list_pos = NIF_BACKUP
|
||||
cost = 125
|
||||
|
||||
activate()
|
||||
/datum/nifsoft/mindbackup/activate()
|
||||
if((. = ..()))
|
||||
var/mob/living/carbon/human/H = nif.human
|
||||
SStranscore.m_backup(H.mind,H.nif,one_time = TRUE)
|
||||
@@ -195,9 +195,9 @@
|
||||
deactivate()
|
||||
return TRUE
|
||||
|
||||
deactivate()
|
||||
/datum/nifsoft/mindbackup/deactivate()
|
||||
if((. = ..()))
|
||||
return TRUE
|
||||
|
||||
stat_text()
|
||||
/datum/nifsoft/mindbackup/stat_text()
|
||||
return "Store Backup"
|
||||
|
||||
@@ -7,24 +7,24 @@
|
||||
p_drain = 0.025
|
||||
var/datum/tgui_module/crew_monitor/nif/arscreen
|
||||
|
||||
New()
|
||||
/datum/nifsoft/crewmonitor/New()
|
||||
..()
|
||||
arscreen = new(nif)
|
||||
|
||||
Destroy()
|
||||
/datum/nifsoft/crewmonitor/Destroy()
|
||||
QDEL_NULL(arscreen)
|
||||
return ..()
|
||||
|
||||
activate()
|
||||
/datum/nifsoft/crewmonitor/activate()
|
||||
if((. = ..()))
|
||||
arscreen.tgui_interact(nif.human)
|
||||
return TRUE
|
||||
|
||||
deactivate()
|
||||
/datum/nifsoft/crewmonitor/deactivate()
|
||||
if((. = ..()))
|
||||
return TRUE
|
||||
|
||||
stat_text()
|
||||
/datum/nifsoft/crewmonitor/stat_text()
|
||||
return "Show Monitor"
|
||||
|
||||
/datum/nifsoft/alarmmonitor
|
||||
@@ -36,22 +36,22 @@
|
||||
p_drain = 0.025
|
||||
var/datum/tgui_module/alarm_monitor/engineering/nif/tgarscreen
|
||||
|
||||
New()
|
||||
/datum/nifsoft/alarmmonitor/New()
|
||||
..()
|
||||
tgarscreen = new(nif)
|
||||
|
||||
Destroy()
|
||||
/datum/nifsoft/alarmmonitor/Destroy()
|
||||
QDEL_NULL(tgarscreen)
|
||||
return ..()
|
||||
|
||||
activate()
|
||||
/datum/nifsoft/alarmmonitor/activate()
|
||||
if((. = ..()))
|
||||
tgarscreen.tgui_interact(nif.human)
|
||||
return TRUE
|
||||
|
||||
deactivate()
|
||||
/datum/nifsoft/alarmmonitor/deactivate()
|
||||
if((. = ..()))
|
||||
return TRUE
|
||||
|
||||
stat_text()
|
||||
/datum/nifsoft/alarmmonitor/stat_text()
|
||||
return "Show Monitor"
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
tick_flags = NIF_ACTIVETICK
|
||||
combat_flags = (NIF_C_PAINKILLERS)
|
||||
|
||||
life()
|
||||
/datum/nifsoft/painkillers/life()
|
||||
if((. = ..()))
|
||||
var/mob/living/carbon/human/H = nif.human
|
||||
H.bloodstr.add_reagent("numbenzyme",0.5)
|
||||
@@ -74,7 +74,7 @@ var/global/datum/unarmed_attack/hardclaws/unarmed_hardclaws = new()
|
||||
var/used = FALSE
|
||||
combat_flags = (NIF_C_HIDELASER)
|
||||
|
||||
activate()
|
||||
/datum/nifsoft/hidelaser/activate()
|
||||
if((. = ..()))
|
||||
if(used)
|
||||
nif.notify("You do not have a hidden weapon to deploy anymore!",TRUE)
|
||||
|
||||
@@ -21,46 +21,46 @@
|
||||
var/list/brainmobs = list()
|
||||
var/inside_flavor = "A small completely white room with a couch, and a window to what seems to be the outside world. A small sign in the corner says 'Configure Me'."
|
||||
|
||||
New()
|
||||
/datum/nifsoft/soulcatcher/New()
|
||||
..()
|
||||
load_settings()
|
||||
|
||||
Destroy()
|
||||
/datum/nifsoft/soulcatcher/Destroy()
|
||||
QDEL_LIST_NULL(brainmobs)
|
||||
return ..()
|
||||
|
||||
activate()
|
||||
/datum/nifsoft/soulcatcher/activate()
|
||||
if((. = ..()))
|
||||
show_settings(nif.human)
|
||||
spawn(0)
|
||||
deactivate()
|
||||
|
||||
deactivate()
|
||||
/datum/nifsoft/soulcatcher/deactivate()
|
||||
if((. = ..()))
|
||||
return TRUE
|
||||
|
||||
stat_text()
|
||||
/datum/nifsoft/soulcatcher/stat_text()
|
||||
return "Change Settings ([brainmobs.len] minds)"
|
||||
|
||||
install()
|
||||
/datum/nifsoft/soulcatcher/install()
|
||||
if((. = ..()))
|
||||
nif.set_flag(NIF_O_SCOTHERS,NIF_FLAGS_OTHER) //Required on install, because other_flags aren't sufficient for our complicated settings.
|
||||
nif.human.verbs |= /mob/living/carbon/human/proc/nsay
|
||||
nif.human.verbs |= /mob/living/carbon/human/proc/nme
|
||||
|
||||
uninstall()
|
||||
/datum/nifsoft/soulcatcher/uninstall()
|
||||
QDEL_LIST_NULL(brainmobs)
|
||||
if((. = ..()) && nif && nif.human) //Sometimes NIFs are deleted outside of a human
|
||||
nif.human.verbs -= /mob/living/carbon/human/proc/nsay
|
||||
nif.human.verbs -= /mob/living/carbon/human/proc/nme
|
||||
|
||||
proc/save_settings()
|
||||
/datum/nifsoft/soulcatcher/proc/save_settings()
|
||||
if(!nif)
|
||||
return
|
||||
nif.save_data["[list_pos]"] = inside_flavor
|
||||
return TRUE
|
||||
|
||||
proc/load_settings()
|
||||
/datum/nifsoft/soulcatcher/proc/load_settings()
|
||||
if(!nif)
|
||||
return
|
||||
var/load = nif.save_data["[list_pos]"]
|
||||
@@ -68,7 +68,7 @@
|
||||
inside_flavor = load
|
||||
return TRUE
|
||||
|
||||
proc/notify_into(var/message)
|
||||
/datum/nifsoft/soulcatcher/proc/notify_into(var/message)
|
||||
var/sound = nif.good_sound
|
||||
|
||||
to_chat(nif.human,"<b>\[[bicon(nif.big_icon)]NIF\]</b> <b>Soulcatcher</b> displays, \"<span class='notice nif'>[message]</span>\"")
|
||||
@@ -79,7 +79,7 @@
|
||||
to_chat(CS,"<b>\[[bicon(nif.big_icon)]NIF\]</b> <b>Soulcatcher</b> displays, \"<span class='notice nif'>[message]</span>\"")
|
||||
brainmob << sound
|
||||
|
||||
proc/say_into(var/message, var/mob/living/sender, var/mob/eyeobj)
|
||||
/datum/nifsoft/soulcatcher/proc/say_into(var/message, var/mob/living/sender, var/mob/eyeobj)
|
||||
var/sender_name = eyeobj ? eyeobj.name : sender.name
|
||||
|
||||
//AR Projecting
|
||||
@@ -95,7 +95,7 @@
|
||||
|
||||
log_nsay(message,nif.human.real_name,sender)
|
||||
|
||||
proc/emote_into(var/message, var/mob/living/sender, var/mob/eyeobj)
|
||||
/datum/nifsoft/soulcatcher/proc/emote_into(var/message, var/mob/living/sender, var/mob/eyeobj)
|
||||
var/sender_name = eyeobj ? eyeobj.name : sender.name
|
||||
|
||||
//AR Projecting
|
||||
@@ -111,7 +111,7 @@
|
||||
|
||||
log_nme(message,nif.human.real_name,sender)
|
||||
|
||||
proc/show_settings(var/mob/living/carbon/human/H)
|
||||
/datum/nifsoft/soulcatcher/proc/show_settings(var/mob/living/carbon/human/H)
|
||||
set waitfor = FALSE
|
||||
var/settings_list = list(
|
||||
"Catching You \[[setting_flags & NIF_SC_CATCHING_ME ? "Enabled" : "Disabled"]\]" = NIF_SC_CATCHING_ME,
|
||||
@@ -154,7 +154,7 @@
|
||||
var/flag = settings_list[choice]
|
||||
return toggle_setting(flag)
|
||||
|
||||
proc/toggle_setting(var/flag)
|
||||
/datum/nifsoft/soulcatcher/proc/toggle_setting(var/flag)
|
||||
setting_flags ^= flag
|
||||
|
||||
var/notify_message
|
||||
@@ -204,8 +204,8 @@
|
||||
|
||||
return TRUE
|
||||
|
||||
//Complex version for catching in-round characters
|
||||
proc/catch_mob(var/mob/M)
|
||||
//Complex version for catching in-round characters
|
||||
/datum/nifsoft/soulcatcher/proc/catch_mob(var/mob/M)
|
||||
if(!M.mind) return
|
||||
|
||||
//Create a new brain mob
|
||||
|
||||
@@ -9,23 +9,23 @@
|
||||
p_drain = 0.01
|
||||
other_flags = (NIF_O_COMMLINK)
|
||||
|
||||
install()
|
||||
/datum/nifsoft/commlink/install()
|
||||
if((. = ..()))
|
||||
nif.comm = new(nif,src)
|
||||
|
||||
uninstall()
|
||||
/datum/nifsoft/commlink/uninstall()
|
||||
var/obj/item/device/nif/lnif = nif //Awkward. Parent clears it in an attempt to clean up.
|
||||
if((. = ..()) && lnif)
|
||||
QDEL_NULL(lnif.comm)
|
||||
|
||||
activate()
|
||||
/datum/nifsoft/commlink/activate()
|
||||
if((. = ..()))
|
||||
nif.comm.initialize_exonet(nif.human)
|
||||
nif.comm.ui_interact(nif.human,key_state = commlink_state)
|
||||
spawn(0)
|
||||
deactivate()
|
||||
|
||||
stat_text()
|
||||
/datum/nifsoft/commlink/stat_text()
|
||||
return "Show Commlink"
|
||||
|
||||
/datum/nifsoft/commlink/Topic(href, href_list)
|
||||
@@ -39,13 +39,13 @@
|
||||
var/obj/item/device/nif/nif
|
||||
var/datum/nifsoft/commlink/nifsoft
|
||||
|
||||
New(var/newloc,var/soft)
|
||||
/obj/item/device/communicator/commlink/New(var/newloc,var/soft)
|
||||
..()
|
||||
nif = newloc
|
||||
nifsoft = soft
|
||||
QDEL_NULL(camera) //Not supported on internal one.
|
||||
|
||||
Destroy()
|
||||
/obj/item/device/communicator/commlink/Destroy()
|
||||
if(nif)
|
||||
nif.comm = null
|
||||
nif = null
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
var/obj/machinery/power/apc/apc
|
||||
other_flags = (NIF_O_APCCHARGE)
|
||||
|
||||
activate()
|
||||
/datum/nifsoft/apc_recharge/activate()
|
||||
if((. = ..()))
|
||||
var/mob/living/carbon/human/H = nif.human
|
||||
apc = locate(/obj/machinery/power/apc) in get_step(H,H.dir)
|
||||
@@ -23,11 +23,11 @@
|
||||
|
||||
H.visible_message("<span class='warning'>Thin snakelike tendrils grow from [H] and connect to \the [apc].</span>","<span class='notice'>Thin snakelike tendrils grow from you and connect to \the [apc].</span>")
|
||||
|
||||
deactivate()
|
||||
/datum/nifsoft/apc_recharge/deactivate()
|
||||
if((. = ..()))
|
||||
apc = null
|
||||
|
||||
life()
|
||||
/datum/nifsoft/apc_recharge/life()
|
||||
if((. = ..()))
|
||||
var/mob/living/carbon/human/H = nif.human
|
||||
if(apc && (get_dist(H,apc) <= 1) && H.nutrition < 440) // 440 vs 450, life() happens before we get here so it'll never be EXACTLY 450
|
||||
@@ -62,7 +62,7 @@
|
||||
applies_to = NIF_SYNTHETIC
|
||||
other_flags = (NIF_O_HEATSINKS)
|
||||
|
||||
activate()
|
||||
/datum/nifsoft/heatsinks/activate()
|
||||
if((. = ..()))
|
||||
if(used >= 1500)
|
||||
nif.notify("Heat sinks not safe to operate again yet! Max 75% on activation.",TRUE)
|
||||
@@ -70,10 +70,10 @@
|
||||
deactivate()
|
||||
return FALSE
|
||||
|
||||
stat_text()
|
||||
/datum/nifsoft/heatsinks/stat_text()
|
||||
return "[active ? "Active" : "Disabled"] (Stored Heat: [FLOOR((used/20), 1)]%)"
|
||||
|
||||
life()
|
||||
/datum/nifsoft/heatsinks/life()
|
||||
if((. = ..()))
|
||||
//Not being used, all clean.
|
||||
if(!active && !used)
|
||||
@@ -99,23 +99,23 @@
|
||||
access = 999 //Prevents anyone from buying it without an emag.
|
||||
var/laws = "Be nice to people!"
|
||||
|
||||
New(var/newloc,var/newlaws)
|
||||
/datum/nifsoft/compliance/New(var/newloc,var/newlaws)
|
||||
laws = newlaws //Sanitize before this (the disk does)
|
||||
..(newloc)
|
||||
|
||||
activate()
|
||||
/datum/nifsoft/compliance/activate()
|
||||
if((. = ..()))
|
||||
to_chat(nif.human,"<span class='danger'>You are compelled to follow these rules: </span>\n<span class='notify'>[laws]</span>")
|
||||
|
||||
install()
|
||||
/datum/nifsoft/compliance/install()
|
||||
if((. = ..()))
|
||||
to_chat(nif.human,"<span class='danger'>You feel suddenly compelled to follow these rules: </span>\n<span class='notify'>[laws]</span>")
|
||||
|
||||
uninstall()
|
||||
/datum/nifsoft/compliance/uninstall()
|
||||
nif.notify("ERROR! Unable to comply!",TRUE)
|
||||
return FALSE //NOPE.
|
||||
|
||||
stat_text()
|
||||
/datum/nifsoft/compliance/stat_text()
|
||||
return "Show Laws"
|
||||
|
||||
/datum/nifsoft/sizechange
|
||||
@@ -125,7 +125,7 @@
|
||||
cost = 375
|
||||
wear = 6
|
||||
|
||||
activate()
|
||||
/datum/nifsoft/sizechange/activate()
|
||||
if((. = ..()))
|
||||
var/new_size = input("Put the desired size (25-200%)", "Set Size", 200) as num
|
||||
|
||||
@@ -141,11 +141,11 @@
|
||||
spawn(0)
|
||||
deactivate()
|
||||
|
||||
deactivate()
|
||||
/datum/nifsoft/sizechange/deactivate()
|
||||
if((. = ..()))
|
||||
return TRUE
|
||||
|
||||
stat_text()
|
||||
/datum/nifsoft/sizechange/stat_text()
|
||||
return "Change Size"
|
||||
|
||||
/datum/nifsoft/worldbend
|
||||
@@ -155,7 +155,7 @@
|
||||
cost = 100
|
||||
a_drain = 0.01
|
||||
|
||||
activate()
|
||||
/datum/nifsoft/worldbend/activate()
|
||||
if((. = ..()))
|
||||
var/list/justme = list(nif.human)
|
||||
for(var/human in human_mob_list)
|
||||
@@ -165,7 +165,7 @@
|
||||
H.display_alt_appearance("animals", justme)
|
||||
alt_farmanimals += nif.human
|
||||
|
||||
deactivate()
|
||||
/datum/nifsoft/worldbend/deactivate()
|
||||
if((. = ..()))
|
||||
var/list/justme = list(nif.human)
|
||||
for(var/human in human_mob_list)
|
||||
|
||||
@@ -16,6 +16,21 @@ GLOBAL_DATUM_INIT(tgui_nif_state, /datum/tgui_state/nif_state, new)
|
||||
|
||||
return STATUS_CLOSE
|
||||
|
||||
// This is slightly distinct from the module state, as it wants to update if not working
|
||||
GLOBAL_DATUM_INIT(tgui_nif_main_state, /datum/tgui_state/nif_main_state, new)
|
||||
/datum/tgui_state/nif_main_state/can_use_topic(var/src_object, var/mob/user)
|
||||
if(ishuman(user))
|
||||
var/mob/living/carbon/human/H = user
|
||||
if(!H.nif || src_object != H.nif)
|
||||
return STATUS_CLOSE
|
||||
|
||||
if(H.nif.stat == NIF_WORKING)
|
||||
return user.shared_tgui_interaction()
|
||||
else
|
||||
return min(user.shared_tgui_interaction(), STATUS_UPDATE)
|
||||
|
||||
return STATUS_CLOSE
|
||||
|
||||
GLOBAL_DATUM_INIT(tgui_commlink_state, /datum/tgui_state/commlink_state, new)
|
||||
/datum/tgui_state/commlink_state/can_use_topic(var/src_object, var/mob/user)
|
||||
if(ishuman(user))
|
||||
|
||||
255
tgui/packages/tgui/interfaces/NIF.js
Normal file
255
tgui/packages/tgui/interfaces/NIF.js
Normal file
@@ -0,0 +1,255 @@
|
||||
import { round } from 'common/math';
|
||||
import { Fragment } from 'inferno';
|
||||
import { useBackend, useLocalState } from "../backend";
|
||||
import { Box, Button, Flex, Icon, LabeledList, ProgressBar, Modal, Section, Dropdown, AnimatedNumber, NoticeBox, Table } from "../components";
|
||||
import { Window } from "../layouts";
|
||||
|
||||
const NIF_WORKING = 0;
|
||||
const NIF_POWFAIL = 1;
|
||||
const NIF_TEMPFAIL = 2;
|
||||
const NIF_INSTALLING = 3;
|
||||
const NIF_PREINSTALL = 4;
|
||||
|
||||
const validThemes = [
|
||||
"abductor",
|
||||
"cardtable",
|
||||
"hackerman",
|
||||
"malfunction",
|
||||
"ntos",
|
||||
"paper",
|
||||
"retro",
|
||||
"syndicate",
|
||||
];
|
||||
|
||||
export const NIF = (props, context) => {
|
||||
const { act, config, data } = useBackend(context);
|
||||
|
||||
const {
|
||||
theme,
|
||||
last_notification,
|
||||
} = data;
|
||||
|
||||
const [settingsOpen, setSettingsOpen] = useLocalState(context, "settingsOpen", false);
|
||||
const [viewingModule, setViewing] = useLocalState(context, "viewingModule", null);
|
||||
|
||||
return (
|
||||
<Window theme={theme} width={500} height={400} resizable>
|
||||
<Window.Content scrollable>
|
||||
{!!last_notification && (
|
||||
<NoticeBox info>
|
||||
<Table verticalAlign="middle">
|
||||
<Table.Row verticalAlign="middle">
|
||||
<Table.Cell verticalAlign="middle">{last_notification}</Table.Cell>
|
||||
<Table.Cell verticalAlign="middle" collapsing>
|
||||
<Button
|
||||
color="red"
|
||||
icon="times"
|
||||
tooltip="Dismiss"
|
||||
tooltipPosition="left"
|
||||
onClick={() => act("dismissNotification")} />
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
</Table>
|
||||
</NoticeBox>
|
||||
)}
|
||||
{!!viewingModule && (
|
||||
<Modal m={1} p={0} color="label">
|
||||
<Section m={0} title={viewingModule.name} buttons={
|
||||
<Fragment>
|
||||
<Button.Confirm
|
||||
icon="ban"
|
||||
color="bad"
|
||||
content="Uninstall"
|
||||
confirmIcon="ban"
|
||||
confirmContent={"Uninstall " + viewingModule.name + "?"}
|
||||
onClick={() => {
|
||||
act("uninstall", { module: viewingModule.ref });
|
||||
setViewing(null);
|
||||
}} />
|
||||
<Button
|
||||
icon="window-close"
|
||||
onClick={() => setViewing(null)} />
|
||||
</Fragment>
|
||||
}>
|
||||
<Box>{viewingModule.desc}</Box>
|
||||
<Box>
|
||||
It consumes <Box color="good" inline>{viewingModule.p_drain}</Box> energy units while installed,
|
||||
and <Box color="average" inline>{viewingModule.a_drain}</Box> additionally while active.
|
||||
</Box>
|
||||
<Box color={viewingModule.illegal ? "bad" : "good"}>
|
||||
It is {viewingModule.illegal ? "NOT " : ""}
|
||||
a legal software package.
|
||||
</Box>
|
||||
<Box>
|
||||
The MSRP of the package is <Box color="good" inline>{viewingModule.cost}₮.</Box>
|
||||
</Box>
|
||||
<Box>
|
||||
The difficulty to construct the associated implant is
|
||||
<Box color="good" inline>Rating {viewingModule.wear}</Box>.
|
||||
</Box>
|
||||
</Section>
|
||||
</Modal>
|
||||
)}
|
||||
<Section title={"Welcome to your NIF, " + config.user.name} buttons={
|
||||
<Button
|
||||
icon="cogs"
|
||||
tooltip="Settings"
|
||||
tooltipPosition="bottom-left"
|
||||
selected={settingsOpen}
|
||||
onClick={() => setSettingsOpen(!settingsOpen)} />
|
||||
}>
|
||||
{settingsOpen && <NIFSettings /> || <NIFMain setViewing={setViewing} />}
|
||||
</Section>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
|
||||
const getNifCondition = (nif_stat, nif_percent) => {
|
||||
switch (nif_stat) {
|
||||
case NIF_WORKING:
|
||||
if (nif_percent < 25) {
|
||||
return "Service Needed Soon";
|
||||
} else {
|
||||
return "Operating Normally";
|
||||
}
|
||||
break;
|
||||
case NIF_POWFAIL:
|
||||
return "Insufficient Energy!";
|
||||
break;
|
||||
case NIF_TEMPFAIL:
|
||||
return "System Failure!";
|
||||
break;
|
||||
case NIF_INSTALLING:
|
||||
return "Adapting To User";
|
||||
break;
|
||||
}
|
||||
return "Unknown";
|
||||
};
|
||||
|
||||
const getNutritionText = (nutrition, isSynthetic) => {
|
||||
if (isSynthetic) {
|
||||
if (nutrition >= 450) {
|
||||
return "Overcharged";
|
||||
} else if (nutrition >= 250) {
|
||||
return "Good Charge";
|
||||
}
|
||||
return "Low Charge";
|
||||
}
|
||||
|
||||
if (nutrition >= 250) {
|
||||
return "NIF Power Requirement met.";
|
||||
} else if (nutrition >= 150) {
|
||||
return "Fluctuations in available power.";
|
||||
}
|
||||
return "Power failure imminent.";
|
||||
};
|
||||
|
||||
const NIFMain = (props, context) => {
|
||||
const { act, config, data } = useBackend(context);
|
||||
|
||||
const {
|
||||
nif_percent,
|
||||
nif_stat,
|
||||
last_notification,
|
||||
nutrition,
|
||||
isSynthetic,
|
||||
modules,
|
||||
} = data;
|
||||
|
||||
const {
|
||||
setViewing,
|
||||
} = props;
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="NIF Condition">
|
||||
<ProgressBar
|
||||
value={nif_percent}
|
||||
minValue={0}
|
||||
maxValue={100}
|
||||
ranges={{
|
||||
good: [50, Infinity],
|
||||
average: [25, 50],
|
||||
bad: [-Infinity, 0],
|
||||
}}>
|
||||
{getNifCondition(nif_stat, nif_percent)} (<AnimatedNumber value={nif_percent} />%)
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label={"NIF Power"}>
|
||||
<ProgressBar
|
||||
value={nutrition}
|
||||
minValue={0}
|
||||
maxValue={700}
|
||||
ranges={{
|
||||
good: [250, Infinity],
|
||||
average: [150, 250],
|
||||
bad: [0, 150],
|
||||
}}>
|
||||
{getNutritionText(nutrition, isSynthetic)}
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
<Section level={2} title="NIFSoft Modules" mt={1}>
|
||||
<LabeledList>
|
||||
{modules.map(module => (
|
||||
<LabeledList.Item
|
||||
label={module.name}
|
||||
key={module.ref}
|
||||
buttons={
|
||||
<Fragment>
|
||||
<Button.Confirm
|
||||
icon="trash"
|
||||
color="bad"
|
||||
confirmContent="UNINSTALL?"
|
||||
confirmIcon="trash"
|
||||
tooltip="Uninstall Module"
|
||||
tooltipPosition="left"
|
||||
onClick={() => act("uninstall", { module: module.ref })} />
|
||||
<Button
|
||||
icon="search"
|
||||
onClick={() => setViewing(module)}
|
||||
tooltip="View Information"
|
||||
tooltipPosition="left" />
|
||||
</Fragment>
|
||||
}>
|
||||
{module.activates && (
|
||||
<Button
|
||||
fluid
|
||||
selected={module.active}
|
||||
content={module.stat_text}
|
||||
onClick={() => act("toggle_module", { module: module.ref })} />
|
||||
) || (
|
||||
<Box>
|
||||
{module.stat_text}
|
||||
</Box>
|
||||
)}
|
||||
</LabeledList.Item>
|
||||
))}
|
||||
</LabeledList>
|
||||
</Section>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
const NIFSettings = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
|
||||
const {
|
||||
theme,
|
||||
} = data;
|
||||
|
||||
return (
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="NIF Theme" verticalAlign="top">
|
||||
<Dropdown
|
||||
width="100%"
|
||||
placeholder="Default"
|
||||
selected={theme}
|
||||
options={validThemes}
|
||||
onSelected={val => act("setTheme", { theme: val })} />
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
);
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -2963,6 +2963,7 @@
|
||||
#include "code\modules\nifsoft\nif.dm"
|
||||
#include "code\modules\nifsoft\nif_softshop.dm"
|
||||
#include "code\modules\nifsoft\nif_statpanel.dm"
|
||||
#include "code\modules\nifsoft\nif_tgui.dm"
|
||||
#include "code\modules\nifsoft\nifsoft.dm"
|
||||
#include "code\modules\nifsoft\software\01_vision.dm"
|
||||
#include "code\modules\nifsoft\software\05_health.dm"
|
||||
|
||||
Reference in New Issue
Block a user