mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
NanoUI Optimizations.
We won't regenerate the list for Manifests every tick while viewing the manifest, instead we have a global variable for it PDA_Manifest that we Cut() if there is a change to the manifest then when the next player goes to view the manifest on their PDA it will recreate the list that one time. Some sections of the PDA will no longer auto-refresh every tick because...well that's dumb. Modes that will no longer autoupdate at all: Viewing medical/sec records, viewing notes (will update when you change them of course), and the station alert menu. Modes that will only autoupdate every 5 ticks: APC list (Because it's a huge fuck off list), the manifest, mulebots and secbots screens, supply requests/orders, and janitor supply locator) Some other things that I just can't remember right now.
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
return
|
||||
|
||||
/obj/effect/datacore/proc/manifest_modify(var/name, var/assignment)
|
||||
if(PDA_Manifest.len)
|
||||
PDA_Manifest.Cut()
|
||||
var/datum/data/record/foundrecord
|
||||
var/real_title = assignment
|
||||
|
||||
@@ -34,6 +36,9 @@
|
||||
foundrecord.fields["real_rank"] = real_title
|
||||
|
||||
/obj/effect/datacore/proc/manifest_inject(var/mob/living/carbon/human/H)
|
||||
if(PDA_Manifest.len)
|
||||
PDA_Manifest.Cut()
|
||||
|
||||
if(H.mind && (H.mind.assigned_role != "MODE"))
|
||||
var/assignment
|
||||
if(H.mind.role_alt_title)
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
//This list tracks characters spawned in the world and cannot be modified in-game. Currently referenced by respawn_character().
|
||||
var/locked[] = list()
|
||||
|
||||
|
||||
|
||||
/obj/effect/datacore/proc/get_manifest(monochrome, OOC)
|
||||
var/list/heads = new()
|
||||
var/list/sec = new()
|
||||
@@ -165,9 +167,16 @@
|
||||
|
||||
/*
|
||||
We can't just insert in HTML into the nanoUI so we need the raw data to play with.
|
||||
Instead of creating this list over and over when someone leaves their PDA open to the page
|
||||
we'll only update it when it changes. The PDA_Manifest global list is zeroed out upon any change
|
||||
using /obj/effect/datacore/proc/manifest_inject( ), or manifest_insert( )
|
||||
*/
|
||||
|
||||
var/global/list/PDA_Manifest = list()
|
||||
|
||||
/obj/effect/datacore/proc/get_manifest_json()
|
||||
if(PDA_Manifest.len)
|
||||
return PDA_Manifest
|
||||
var/heads[0]
|
||||
var/sec[0]
|
||||
var/eng[0]
|
||||
@@ -227,7 +236,8 @@ We can't just insert in HTML into the nanoUI so we need the raw data to play wit
|
||||
if(!department && !(name in heads))
|
||||
misc[++misc.len] = list("name" = name, "rank" = rank, "active" = isactive)
|
||||
|
||||
return list(\
|
||||
|
||||
PDA_Manifest = list(\
|
||||
"heads" = heads,\
|
||||
"sec" = sec,\
|
||||
"eng" = eng,\
|
||||
@@ -237,6 +247,7 @@ We can't just insert in HTML into the nanoUI so we need the raw data to play wit
|
||||
"bot" = bot,\
|
||||
"misc" = misc\
|
||||
)
|
||||
return PDA_Manifest
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -289,6 +289,8 @@ What a mess.*/
|
||||
temp += "<a href='?src=\ref[src];choice=Clear Screen'>No</a>"
|
||||
|
||||
if ("Purge All Records")
|
||||
if(PDA_Manifest.len)
|
||||
PDA_Manifest.Cut()
|
||||
for(var/datum/data/record/R in data_core.security)
|
||||
del(R)
|
||||
temp = "All Employment records deleted."
|
||||
@@ -300,6 +302,9 @@ What a mess.*/
|
||||
temp += "<a href='?src=\ref[src];choice=Clear Screen'>No</a>"
|
||||
//RECORD CREATE
|
||||
if ("New Record (General)")
|
||||
|
||||
if(PDA_Manifest.len)
|
||||
PDA_Manifest.Cut()
|
||||
var/datum/data/record/G = new /datum/data/record()
|
||||
G.fields["name"] = "New Record"
|
||||
G.fields["id"] = text("[]", add_zero(num2hex(rand(1, 1.6777215E7)), 6))
|
||||
@@ -372,12 +377,16 @@ What a mess.*/
|
||||
switch(href_list["choice"])
|
||||
if ("Change Rank")
|
||||
if (active1)
|
||||
if(PDA_Manifest.len)
|
||||
PDA_Manifest.Cut()
|
||||
active1.fields["rank"] = href_list["rank"]
|
||||
if(href_list["rank"] in get_all_jobs())
|
||||
active1.fields["real_rank"] = href_list["real_rank"]
|
||||
|
||||
if ("Delete Record (ALL) Execute")
|
||||
if (active1)
|
||||
if(PDA_Manifest.len)
|
||||
PDA_Manifest.Cut()
|
||||
for(var/datum/data/record/R in data_core.medical)
|
||||
if ((R.fields["name"] == active1.fields["name"] || R.fields["id"] == active1.fields["id"]))
|
||||
del(R)
|
||||
|
||||
@@ -240,6 +240,9 @@ obj/machinery/computer/cryopod/Topic(href, href_list)
|
||||
current_mode.possible_traitors.Remove(occupant)
|
||||
|
||||
// Delete them from datacore.
|
||||
|
||||
if(PDA_Manifest.len)
|
||||
PDA_Manifest.Cut()
|
||||
for(var/datum/data/record/R in data_core.medical)
|
||||
if ((R.fields["name"] == occupant.real_name))
|
||||
del(R)
|
||||
|
||||
@@ -20,6 +20,9 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
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
|
||||
|
||||
//Secondary variables
|
||||
var/scanmode = 0 //1 is medical scanner, 2 is forensics, 3 is reagent scanner.
|
||||
var/fon = 0 //Is the flashlight function on?
|
||||
@@ -42,6 +45,10 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
var/list/conversations = list() // For keeping up with who we have PDA messsages from.
|
||||
var/newmessage = 0 //To remove hackish overlay check
|
||||
|
||||
var/list/cartmodes = list(40, 42, 43, 433, 44, 441, 45, 451, 46, 48, 47, 49) // If you add more cartridge modes add them to this list as well.
|
||||
var/list/no_auto_update = list(1, 40, 43, 44, 441, 45, 451) // These modes we turn off autoupdate
|
||||
var/list/update_every_five = list(3, 41, 433, 46, 47, 48, 49) // These we update every 5 ticks
|
||||
|
||||
var/obj/item/weapon/card/id/id = null //Making it possible to slot an ID card into the PDA so it can function as both.
|
||||
var/ownjob = null //related to above
|
||||
|
||||
@@ -287,6 +294,7 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
/obj/item/device/pda/New()
|
||||
..()
|
||||
PDAs += src
|
||||
PDAs = sortAtom(PDAs)
|
||||
if(default_cartridge)
|
||||
cartridge = new default_cartridge(src)
|
||||
new /obj/item/weapon/pen(src)
|
||||
@@ -319,7 +327,17 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
return attack_self(M)
|
||||
return
|
||||
|
||||
|
||||
/obj/item/device/pda/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
|
||||
ui_tick++
|
||||
var/auto_update = 1
|
||||
if(mode in no_auto_update)
|
||||
auto_update = 0
|
||||
if(mode == lastmode && ui_tick % 5 && mode in update_every_five)
|
||||
return
|
||||
|
||||
lastmode = mode
|
||||
|
||||
var/title = "Personal Data Assistant"
|
||||
|
||||
var/data[0] // This is the data that will be sent to the PDA
|
||||
@@ -345,35 +363,38 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
if(cartridge)
|
||||
var/cartdata[0]
|
||||
|
||||
data["records"] = cartridge.create_NanoUI_values()
|
||||
if(mode in cartmodes)
|
||||
data["records"] = cartridge.create_NanoUI_values()
|
||||
|
||||
cartdata["name"] = cartridge.name
|
||||
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\
|
||||
)
|
||||
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
|
||||
if(mode == 0)
|
||||
cartdata["name"] = cartridge.name
|
||||
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\
|
||||
)
|
||||
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
|
||||
|
||||
cartdata["type"] = cartridge.type
|
||||
cartdata["charges"] = cartridge.charges ? cartridge.charges : 0
|
||||
if(mode == 2)
|
||||
cartdata["type"] = cartridge.type
|
||||
cartdata["charges"] = cartridge.charges ? cartridge.charges : 0
|
||||
data["cartridge"] = cartdata
|
||||
|
||||
data["stationTime"] = worldtime2text()
|
||||
@@ -383,7 +404,7 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
var/convopdas[0]
|
||||
var/pdas[0]
|
||||
var/count = 0
|
||||
for (var/obj/item/device/pda/P in sortAtom(PDAs))
|
||||
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")))
|
||||
@@ -413,8 +434,8 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
|
||||
|
||||
if(mode==3)
|
||||
var/turf/T = get_turf_or_move(user.loc)
|
||||
if(!isnull(T) || mode!=3)
|
||||
var/turf/T = get_turf(user.loc)
|
||||
if(!isnull(T))
|
||||
var/datum/gas_mixture/environment = T.return_air()
|
||||
|
||||
var/pressure = environment.return_pressure()
|
||||
@@ -449,8 +470,8 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
ui.set_initial_data(data)
|
||||
// open the new ui window
|
||||
ui.open()
|
||||
// auto update every Master Controller tick
|
||||
ui.set_auto_update(1)
|
||||
// auto update every Master Controller tick
|
||||
ui.set_auto_update(auto_update)
|
||||
|
||||
//NOTE: graphic resources are loaded on client login
|
||||
/obj/item/device/pda/attack_self(mob/user as mob)
|
||||
|
||||
@@ -676,6 +676,8 @@
|
||||
if(setmedical != "Cancel")
|
||||
R.fields["p_stat"] = setmedical
|
||||
modified = 1
|
||||
if(PDA_Manifest.len)
|
||||
PDA_Manifest.Cut()
|
||||
|
||||
spawn()
|
||||
if(istype(usr,/mob/living/carbon/human))
|
||||
|
||||
Reference in New Issue
Block a user