Update byond code to support TGUI frontend for RND Console

This commit is contained in:
nicetoolbox
2020-09-28 22:23:15 -07:00
parent 99f5144a95
commit d8dce9da36
2 changed files with 399 additions and 661 deletions
+399 -392
View File
@@ -186,7 +186,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
to_chat(user, "<span class='notice'>You add the disk to the machine!</span>")
else if(!(linked_destroy && linked_destroy.busy) && !(linked_lathe && linked_lathe.busy) && !(linked_imprinter && linked_imprinter.busy))
..()
SSnanoui.update_uis(src)
SStgui.update_uis(src)
return
/obj/machinery/computer/rdconsole/emag_act(user as mob)
@@ -196,438 +196,445 @@ won't update every console in existence) but it's more of a hassle to do. Also,
emagged = 1
to_chat(user, "<span class='notice'>You disable the security protocols</span>")
/obj/machinery/computer/rdconsole/Topic(href, href_list)
/obj/machinery/computer/rdconsole/tgui_act(action, list/params)
if(..())
return 1
return FALSE
if(!allowed(usr) && !isobserver(usr))
return 1
return FALSE
add_fingerprint(usr)
usr.set_machine(src)
if(href_list["menu"]) //Switches menu screens. Converts a sent text string into a number. Saves a LOT of code.
var/temp_screen = text2num(href_list["menu"])
menu = temp_screen
if(href_list["submenu"]) //Switches menu screens. Converts a sent text string into a number. Saves a LOT of code.
var/temp_screen = text2num(href_list["submenu"])
submenu = temp_screen
if(href_list["category"])
var/compare
switch(action)
if("nav") //Switches menu screens. Converts a sent text string into a number. Saves a LOT of code.
var/next_menu = text2num(params["menu"])
var/next_submenu = text2num(params["submenu"])
menu = next_menu
submenu = next_submenu
matching_designs.Cut()
if("setCategory")
var/next_category = params["category"]
var/compare
if(menu == 4)
compare = PROTOLATHE
else
compare = IMPRINTER
matching_designs.Cut()
for(var/v in files.known_designs)
var/datum/design/D = files.known_designs[v]
if(!(D.build_type & compare))
continue
if(href_list["category"] in D.category)
matching_designs.Add(D)
submenu = 1
if(menu == 4)
compare = PROTOLATHE
else
compare = IMPRINTER
selected_category = "Viewing Category [href_list["category"]]"
for(var/v in files.known_designs)
var/datum/design/D = files.known_designs[v]
if(!(D.build_type & compare))
continue
if(next_category in D.category)
matching_designs.Add(D)
submenu = 1
else if(href_list["updt_tech"]) //Update the research holder with information from the technology disk.
add_wait_message("Updating Database...", TECH_UPDATE_DELAY)
spawn(TECH_UPDATE_DELAY)
clear_wait_message()
files.AddTech2Known(t_disk.stored)
SSnanoui.update_uis(src)
griefProtection() //Update centcom too
selected_category = "Viewing Category [next_category]"
else if(href_list["clear_tech"]) //Erase data on the technology disk.
if(t_disk)
t_disk.wipe_tech()
if("updt_tech") //Update the research holder with information from the technology disk.
add_wait_message("Updating Database...", TECH_UPDATE_DELAY)
spawn(TECH_UPDATE_DELAY)
clear_wait_message()
files.AddTech2Known(t_disk.stored)
SStgui.update_uis(src)
griefProtection() //Update centcom too
else if(href_list["eject_tech"]) //Eject the technology disk.
if(t_disk)
t_disk.loc = src.loc
t_disk = null
menu = 0
submenu = 0
if("clear_tech") //Erase data on the technology disk.
if(t_disk)
t_disk.wipe_tech()
else if(href_list["copy_tech"]) //Copy some technology data from the research holder to the disk.
// Somehow this href makes me very nervous
t_disk.stored = files.known_tech[href_list["copy_tech_ID"]]
menu = 2
submenu = 0
if("eject_tech") //Eject the technology disk.
if(t_disk)
t_disk.loc = src.loc
t_disk = null
menu = 0
submenu = 0
else if(href_list["updt_design"]) //Updates the research holder with design data from the design disk.
add_wait_message("Updating Database...", DESIGN_UPDATE_DELAY)
spawn(DESIGN_UPDATE_DELAY)
clear_wait_message()
files.AddDesign2Known(d_disk.blueprint)
SSnanoui.update_uis(src)
griefProtection() //Update centcom too
if("copy_tech") //Copy some technology data from the research holder to the disk.
// Somehow this href makes me very nervous
t_disk.stored = files.known_tech[params["id"]]
menu = 2
submenu = 0
else if(href_list["clear_design"]) //Erases data on the design disk.
if(d_disk)
d_disk.wipe_blueprint()
if("updt_design") //Updates the research holder with design data from the design disk.
add_wait_message("Updating Database...", DESIGN_UPDATE_DELAY)
spawn(DESIGN_UPDATE_DELAY)
clear_wait_message()
files.AddDesign2Known(d_disk.blueprint)
SStgui.update_uis(src)
griefProtection() //Update centcom too
else if(href_list["eject_design"]) //Eject the design disk.
if(d_disk)
d_disk.loc = src.loc
d_disk = null
menu = 0
submenu = 0
if("clear_design") //Erases data on the design disk.
if(d_disk)
d_disk.wipe_blueprint()
else if(href_list["copy_design"]) //Copy design data from the research holder to the design disk.
// This href ALSO makes me very nervous
var/datum/design/D = files.known_designs[href_list["copy_design_ID"]]
if(D)
// eeeeeep design datums are global be careful!
var/autolathe_friendly = 1
for(var/x in D.materials)
if( !(x in list(MAT_METAL, MAT_GLASS)))
if("eject_design") //Eject the design disk.
if(d_disk)
d_disk.loc = src.loc
d_disk = null
menu = 0
submenu = 0
if("copy_design") //Copy design data from the research holder to the design disk.
// This href ALSO makes me very nervous
var/datum/design/D = files.known_designs[params["id"]]
if(D)
// eeeeeep design datums are global be careful!
var/autolathe_friendly = 1
for(var/x in D.materials)
if( !(x in list(MAT_METAL, MAT_GLASS)))
autolathe_friendly = 0
D.category -= "Imported"
if(D.locked)
autolathe_friendly = 0
D.category -= "Imported"
if(D.locked)
autolathe_friendly = 0
D.category -= "Imported"
if(D.build_type & (AUTOLATHE|PROTOLATHE|CRAFTLATHE)) // Specifically excludes circuit imprinter and mechfab
D.build_type = autolathe_friendly ? (D.build_type | AUTOLATHE) : D.build_type
D.category |= "Imported"
d_disk.blueprint = D
menu = 2
submenu = 0
if(D.build_type & (AUTOLATHE|PROTOLATHE|CRAFTLATHE)) // Specifically excludes circuit imprinter and mechfab
D.build_type = autolathe_friendly ? (D.build_type | AUTOLATHE) : D.build_type
D.category |= "Imported"
d_disk.blueprint = D
menu = 2
submenu = 0
else if(href_list["eject_item"]) //Eject the item inside the destructive analyzer.
if(linked_destroy)
if(linked_destroy.busy)
to_chat(usr, "<span class='danger'> The destructive analyzer is busy at the moment.</span>")
if("eject_item") //Eject the item inside the destructive analyzer.
if(linked_destroy)
if(linked_destroy.busy)
to_chat(usr, "<span class='danger'> The destructive analyzer is busy at the moment.</span>")
else if(linked_destroy.loaded_item)
linked_destroy.loaded_item.loc = linked_destroy.loc
linked_destroy.loaded_item = null
linked_destroy.icon_state = "d_analyzer"
menu = 3
else if(linked_destroy.loaded_item)
linked_destroy.loaded_item.loc = linked_destroy.loc
linked_destroy.loaded_item = null
linked_destroy.icon_state = "d_analyzer"
menu = 3
else if(href_list["maxresearch"]) //Eject the item inside the destructive analyzer.
if(!check_rights(R_ADMIN))
return
if(alert("Are you sure you want to maximize research levels?","Confirmation","Yes","No")=="No")
return
log_admin("[key_name(usr)] has maximized the research levels.")
message_admins("[key_name_admin(usr)] has maximized the research levels.")
Maximize()
SSnanoui.update_uis(src)
griefProtection() //Update centcomm too
else if(href_list["deconstruct"]) //Deconstruct the item in the destructive analyzer and update the research holder.
if(linked_destroy)
if(linked_destroy.busy)
to_chat(usr, "<span class='danger'>The destructive analyzer is busy at the moment.</span>")
if("maxresearch") //Eject the item inside the destructive analyzer.
if(!check_rights(R_ADMIN))
return
var/list/temp_tech = linked_destroy.ConvertReqString2List(linked_destroy.loaded_item.origin_tech)
var/cancontinue = FALSE
for(var/T in temp_tech)
if(files.IsTechHigher(T, temp_tech[T]))
cancontinue = TRUE
break
if(!cancontinue)
var/choice = input("This item does not raise tech levels. Proceed destroying loaded item anyway?") in list("Proceed", "Cancel")
if(choice == "Cancel" || !linked_destroy)
if(alert("Are you sure you want to maximize research levels?","Confirmation","Yes","No")=="No")
return
log_admin("[key_name(usr)] has maximized the research levels.")
message_admins("[key_name_admin(usr)] has maximized the research levels.")
Maximize()
SStgui.update_uis(src)
griefProtection() //Update centcomm too
if("deconstruct") //Deconstruct the item in the destructive analyzer and update the research holder.
if(linked_destroy)
if(linked_destroy.busy)
to_chat(usr, "<span class='danger'>The destructive analyzer is busy at the moment.</span>")
return
linked_destroy.busy = 1
add_wait_message("Processing and Updating Database...", DECONSTRUCT_DELAY)
SSnanoui.update_uis(src)
flick("d_analyzer_process", linked_destroy)
spawn(DECONSTRUCT_DELAY)
clear_wait_message()
if(linked_destroy)
linked_destroy.busy = 0
if(!linked_destroy.hacked)
if(!linked_destroy.loaded_item)
to_chat(usr, "<span class='danger'>The destructive analyzer appears to be empty.</span>")
menu = 0
submenu = 0
return
for(var/T in temp_tech)
var/datum/tech/KT = files.known_tech[T] //For stat logging of high levels
if(files.IsTechHigher(T, temp_tech[T]) && KT.level >= 5) //For stat logging of high levels
feedback_add_details("high_research_level","[KT][KT.level + 1]") //+1 to show the level which we're about to get
files.UpdateTech(T, temp_tech[T])
menu = 0
submenu = 0
if(linked_lathe) //Also sends salvaged materials to a linked protolathe, if any.
for(var/material in linked_destroy.loaded_item.materials)
var/can_insert = min(linked_lathe.materials.max_amount - linked_lathe.materials.total_amount, linked_destroy.loaded_item.materials[material] * (linked_destroy.decon_mod / 10), linked_destroy.loaded_item.materials[material])
linked_lathe.materials.insert_amount(can_insert, material)
linked_destroy.loaded_item = null
else
menu = 0
submenu = 0
for(var/obj/I in linked_destroy.contents)
for(var/mob/M in I.contents)
M.death()
if(istype(I,/obj/item/stack/sheet))//Only deconsturcts one sheet at a time instead of the entire stack
var/obj/item/stack/sheet/S = I
if(S.amount > 1)
S.amount--
linked_destroy.loaded_item = S
else
qdel(S)
linked_destroy.icon_state = "d_analyzer"
var/list/temp_tech = linked_destroy.ConvertReqString2List(linked_destroy.loaded_item.origin_tech)
var/cancontinue = FALSE
for(var/T in temp_tech)
if(files.IsTechHigher(T, temp_tech[T]))
cancontinue = TRUE
break
if(!cancontinue)
var/choice = input("This item does not raise tech levels. Proceed destroying loaded item anyway?") in list("Proceed", "Cancel")
if(choice == "Cancel" || !linked_destroy)
return
linked_destroy.busy = 1
add_wait_message("Processing and Updating Database...", DECONSTRUCT_DELAY)
SStgui.update_uis(src)
flick("d_analyzer_process", linked_destroy)
spawn(DECONSTRUCT_DELAY)
clear_wait_message()
if(linked_destroy)
linked_destroy.busy = 0
if(!linked_destroy.hacked)
if(!linked_destroy.loaded_item)
to_chat(usr, "<span class='danger'>The destructive analyzer appears to be empty.</span>")
menu = 0
submenu = 0
return
for(var/T in temp_tech)
var/datum/tech/KT = files.known_tech[T] //For stat logging of high levels
if(files.IsTechHigher(T, temp_tech[T]) && KT.level >= 5) //For stat logging of high levels
feedback_add_details("high_research_level","[KT][KT.level + 1]") //+1 to show the level which we're about to get
files.UpdateTech(T, temp_tech[T])
menu = 0
submenu = 0
if(linked_lathe) //Also sends salvaged materials to a linked protolathe, if any.
for(var/material in linked_destroy.loaded_item.materials)
var/can_insert = min(linked_lathe.materials.max_amount - linked_lathe.materials.total_amount, linked_destroy.loaded_item.materials[material] * (linked_destroy.decon_mod / 10), linked_destroy.loaded_item.materials[material])
linked_lathe.materials.insert_amount(can_insert, material)
linked_destroy.loaded_item = null
else
if(!(I in linked_destroy.component_parts))
qdel(I)
linked_destroy.icon_state = "d_analyzer"
use_power(250)
SSnanoui.update_uis(src)
else if(href_list["sync"]) //Sync the research holder with all the R&D consoles in the game that aren't sync protected.
if(!sync)
to_chat(usr, "<span class='danger'>You must connect to the network first!</span>")
else
add_wait_message("Updating Database...", SYNC_RESEARCH_DELAY)
griefProtection() //Putting this here because I dont trust the sync process
spawn(SYNC_RESEARCH_DELAY)
clear_wait_message()
if(src)
for(var/obj/machinery/r_n_d/server/S in GLOB.machines)
var/server_processed = 0
if(S.disabled)
continue
if((id in S.id_with_upload) || istype(S, /obj/machinery/r_n_d/server/centcom))
files.push_data(S.files)
server_processed = 1
if(((id in S.id_with_download) && !istype(S, /obj/machinery/r_n_d/server/centcom)) || S.hacked)
S.files.push_data(files)
server_processed = 1
if(!istype(S, /obj/machinery/r_n_d/server/centcom) && server_processed)
S.produce_heat(100)
SSnanoui.update_uis(src)
else if(href_list["togglesync"]) //Prevents the console from being synced by other consoles. Can still send data.
sync = !sync
else if(href_list["build"]) //Causes the Protolathe to build something.
if(linked_lathe)
if(linked_lathe.busy)
to_chat(usr, "<span class='danger'>Protolathe is busy at the moment.</span>")
return
var/coeff = linked_lathe.efficiency_coeff
var/g2g = 1
var/datum/design/being_built = files.known_designs[href_list["build"]]
if(being_built)
var/power = 2000
var/amount=text2num(href_list["amount"])
if(being_built.make_reagents.len)
return 0
amount = max(1, min(10, amount))
for(var/M in being_built.materials)
power += round(being_built.materials[M] * amount / 5)
power = max(2000, power)
var/key = usr.key //so we don't lose the info during the spawn delay
if(!(being_built.build_type & PROTOLATHE))
g2g = 0
message_admins("Protolathe exploit attempted by [key_name(usr, TRUE)]!")
if(g2g) //If input is incorrect, nothing happens
var/new_coeff = coeff * being_built.lathe_time_factor
var/time_to_construct = PROTOLATHE_CONSTRUCT_DELAY * new_coeff * amount ** 0.8
var/enough_materials = 1
add_wait_message("Constructing Prototype. Please Wait...", time_to_construct)
linked_lathe.busy = 1
flick("protolathe_n",linked_lathe)
use_power(power)
var/list/efficient_mats = list()
for(var/MAT in being_built.materials)
efficient_mats[MAT] = being_built.materials[MAT]*coeff
if(!linked_lathe.materials.has_materials(efficient_mats, amount))
src.visible_message("<span class='notice'>The [src.name] beeps, \"Not enough materials to complete prototype.\"</span>")
enough_materials = 0
g2g = 0
else
for(var/R in being_built.reagents_list)
if(!linked_lathe.reagents.has_reagent(R, being_built.reagents_list[R])*coeff)
src.visible_message("<span class='notice'>The [src.name] beeps, \"Not enough reagents to complete prototype.\"</span>")
enough_materials = 0
g2g = 0
if(enough_materials)
linked_lathe.materials.use_amount(efficient_mats, amount)
for(var/R in being_built.reagents_list)
linked_lathe.reagents.remove_reagent(R, being_built.reagents_list[R]*coeff)
var/P = being_built.build_path //lets save these values before the spawn() just in case. Nobody likes runtimes.
var/O = being_built.locked
spawn(time_to_construct)
if(g2g) //And if we only fail the material requirements, we still spend time and power
for(var/i = 0, i<amount, i++)
var/obj/item/new_item = new P(src)
if( new_item.type == /obj/item/storage/backpack/holding )
new_item.investigate_log("built by [key]","singulo")
if(!istype(new_item, /obj/item/stack/sheet)) // To avoid materials dupe glitches
new_item.materials = efficient_mats.Copy()
if(O)
var/obj/item/storage/lockbox/research/L = new/obj/item/storage/lockbox/research(linked_lathe.loc)
new_item.forceMove(L)
L.name += " ([new_item.name])"
L.origin_tech = new_item.origin_tech
L.req_access = being_built.access_requirement
var/list/lockbox_access
for(var/A in L.req_access)
lockbox_access += "[get_access_desc(A)] "
L.desc = "A locked box. It is locked to [lockbox_access]access."
menu = 0
submenu = 0
for(var/obj/I in linked_destroy.contents)
for(var/mob/M in I.contents)
M.death()
if(istype(I,/obj/item/stack/sheet))//Only deconsturcts one sheet at a time instead of the entire stack
var/obj/item/stack/sheet/S = I
if(S.amount > 1)
S.amount--
linked_destroy.loaded_item = S
else
new_item.loc = linked_lathe.loc
clear_wait_message()
linked_lathe.busy = 0
SSnanoui.update_uis(src)
qdel(S)
linked_destroy.icon_state = "d_analyzer"
else
if(!(I in linked_destroy.component_parts))
qdel(I)
linked_destroy.icon_state = "d_analyzer"
use_power(250)
SStgui.update_uis(src)
else if(href_list["imprint"]) //Causes the Circuit Imprinter to build something.
var/coeff = linked_imprinter.efficiency_coeff
var/g2g = 1
var/enough_materials = 1
if(linked_imprinter)
if(linked_imprinter.busy)
to_chat(usr, "<span class='danger'>Circuit Imprinter is busy at the moment.</span>")
return
var/datum/design/being_built = null
being_built = files.known_designs[href_list["imprint"]]
if(being_built)
var/power = 2000
for(var/M in being_built.materials)
power += round(being_built.materials[M] / 5)
power = max(2000, power)
if(!(being_built.build_type & IMPRINTER))
g2g = 0
message_admins("Circuit imprinter exploit attempted by [key_name(usr, TRUE)]!")
if("sync") //Sync the research holder with all the R&D consoles in the game that aren't sync protected.
if(!sync)
to_chat(usr, "<span class='danger'>You must connect to the network first!</span>")
else
add_wait_message("Updating Database...", SYNC_RESEARCH_DELAY)
griefProtection() //Putting this here because I dont trust the sync process
spawn(SYNC_RESEARCH_DELAY)
clear_wait_message()
if(src)
for(var/obj/machinery/r_n_d/server/S in GLOB.machines)
var/server_processed = 0
if(S.disabled)
continue
if((id in S.id_with_upload) || istype(S, /obj/machinery/r_n_d/server/centcom))
files.push_data(S.files)
server_processed = 1
if(((id in S.id_with_download) && !istype(S, /obj/machinery/r_n_d/server/centcom)) || S.hacked)
S.files.push_data(files)
server_processed = 1
if(!istype(S, /obj/machinery/r_n_d/server/centcom) && server_processed)
S.produce_heat(100)
SStgui.update_uis(src)
if(g2g) //Again, if input is wrong, do nothing
add_wait_message("Imprinting Circuit. Please Wait...", IMPRINTER_DELAY)
linked_imprinter.busy = 1
flick("circuit_imprinter_ani",linked_imprinter)
use_power(power)
if("togglesync") //Prevents the console from being synced by other consoles. Can still send data.
sync = !sync
var/list/efficient_mats = list()
for(var/MAT in being_built.materials)
efficient_mats[MAT] = being_built.materials[MAT]/coeff
if(!linked_imprinter.materials.has_materials(efficient_mats))
visible_message("<span class='notice'>The [src.name] beeps, \"Not enough materials to complete prototype.\"</span>")
enough_materials = 0
if("build") //Causes the Protolathe to build something.
if(linked_lathe)
if(linked_lathe.busy)
to_chat(usr, "<span class='danger'>Protolathe is busy at the moment.</span>")
return TRUE
var/coeff = linked_lathe.efficiency_coeff
var/g2g = 1
var/datum/design/being_built = files.known_designs[params["id"]]
if(being_built)
var/power = 2000
var/amount=text2num(params["amount"])
if(being_built.make_reagents.len)
return 0
amount = max(1, min(10, amount))
for(var/M in being_built.materials)
power += round(being_built.materials[M] * amount / 5)
power = max(2000, power)
var/key = usr.key //so we don't lose the info during the spawn delay
if(!(being_built.build_type & PROTOLATHE))
g2g = 0
else
for(var/R in being_built.reagents_list)
if(!linked_imprinter.reagents.has_reagent(R, being_built.reagents_list[R]/coeff))
visible_message("<span class='notice'>The [name] beeps, \"Not enough reagents to complete prototype.\"</span>")
enough_materials = 0
g2g = 0
message_admins("Protolathe exploit attempted by [key_name(usr, TRUE)]!")
if(enough_materials)
linked_imprinter.materials.use_amount(efficient_mats)
for(var/R in being_built.reagents_list)
linked_imprinter.reagents.remove_reagent(R, being_built.reagents_list[R]/coeff)
if(g2g) //If input is incorrect, nothing happens
var/new_coeff = coeff * being_built.lathe_time_factor
var/time_to_construct = PROTOLATHE_CONSTRUCT_DELAY * new_coeff * amount ** 0.8
var/enough_materials = 1
var/P = being_built.build_path //lets save these values before the spawn() just in case. Nobody likes runtimes.
spawn(IMPRINTER_DELAY)
if(g2g)
var/obj/item/new_item = new P(src)
new_item.loc = linked_imprinter.loc
linked_imprinter.busy = 0
clear_wait_message()
SSnanoui.update_uis(src)
add_wait_message("Constructing Prototype. Please Wait...", time_to_construct)
linked_lathe.busy = 1
flick("protolathe_n",linked_lathe)
use_power(power)
else if(href_list["disposeI"] && linked_imprinter) //Causes the circuit imprinter to dispose of a single reagent (all of it)
linked_imprinter.reagents.del_reagent(href_list["disposeI"])
var/list/efficient_mats = list()
for(var/MAT in being_built.materials)
efficient_mats[MAT] = being_built.materials[MAT]*coeff
else if(href_list["disposeallI"] && linked_imprinter) //Causes the circuit imprinter to dispose of all it's reagents.
linked_imprinter.reagents.clear_reagents()
if(!linked_lathe.materials.has_materials(efficient_mats, amount))
src.visible_message("<span class='notice'>The [src.name] beeps, \"Not enough materials to complete prototype.\"</span>")
enough_materials = 0
g2g = 0
else
for(var/R in being_built.reagents_list)
if(!linked_lathe.reagents.has_reagent(R, being_built.reagents_list[R])*coeff)
src.visible_message("<span class='notice'>The [src.name] beeps, \"Not enough reagents to complete prototype.\"</span>")
enough_materials = 0
g2g = 0
else if(href_list["disposeP"] && linked_lathe) //Causes the protolathe to dispose of a single reagent (all of it)
linked_lathe.reagents.del_reagent(href_list["disposeP"])
if(enough_materials)
linked_lathe.materials.use_amount(efficient_mats, amount)
for(var/R in being_built.reagents_list)
linked_lathe.reagents.remove_reagent(R, being_built.reagents_list[R]*coeff)
else if(href_list["disposeallP"] && linked_lathe) //Causes the protolathe to dispose of all it's reagents.
linked_lathe.reagents.clear_reagents()
var/P = being_built.build_path //lets save these values before the spawn() just in case. Nobody likes runtimes.
var/O = being_built.locked
else if(href_list["lathe_ejectsheet"] && linked_lathe) //Causes the protolathe to eject a sheet of material
var/desired_num_sheets
if(href_list["lathe_ejectsheet_amt"] == "custom")
desired_num_sheets = input("How many sheets would you like to eject from the machine?", "How much?", 1) as null|num
desired_num_sheets = max(0,desired_num_sheets) // If you input too high of a number, the mineral datum will take care of it either way
if(!desired_num_sheets)
return
desired_num_sheets = round(desired_num_sheets) // No partial-sheet goofery
else
desired_num_sheets = text2num(href_list["lathe_ejectsheet_amt"])
linked_lathe.materials.retrieve_sheets(desired_num_sheets, href_list["lathe_ejectsheet"])
spawn(time_to_construct)
if(g2g) //And if we only fail the material requirements, we still spend time and power
for(var/i = 0, i<amount, i++)
var/obj/item/new_item = new P(src)
if( new_item.type == /obj/item/storage/backpack/holding )
new_item.investigate_log("built by [key]","singulo")
if(!istype(new_item, /obj/item/stack/sheet)) // To avoid materials dupe glitches
new_item.materials = efficient_mats.Copy()
if(O)
var/obj/item/storage/lockbox/research/L = new/obj/item/storage/lockbox/research(linked_lathe.loc)
new_item.forceMove(L)
L.name += " ([new_item.name])"
L.origin_tech = new_item.origin_tech
L.req_access = being_built.access_requirement
var/list/lockbox_access
for(var/A in L.req_access)
lockbox_access += "[get_access_desc(A)] "
L.desc = "A locked box. It is locked to [lockbox_access]access."
else
new_item.loc = linked_lathe.loc
clear_wait_message()
linked_lathe.busy = 0
SStgui.update_uis(src)
else if(href_list["imprinter_ejectsheet"] && linked_imprinter) //Causes the protolathe to eject a sheet of material
var/desired_num_sheets = text2num(href_list["imprinter_ejectsheet_amt"])
if(href_list["imprinter_ejectsheet_amt"] == "custom")
desired_num_sheets = input("How many sheets would you like to eject from the machine?", "How much?", 1) as null|num
desired_num_sheets = max(0,desired_num_sheets) // for the imprinter they have something hacky, that still will guard against shenanigans. eh
if(!desired_num_sheets)
return
desired_num_sheets = round(desired_num_sheets) // No partial-sheet goofery
else
desired_num_sheets = text2num(href_list["imprinter_ejectsheet_amt"])
linked_imprinter.materials.retrieve_sheets(desired_num_sheets, href_list["imprinter_ejectsheet"])
if("imprint") //Causes the Circuit Imprinter to build something.
var/coeff = linked_imprinter.efficiency_coeff
var/g2g = 1
var/enough_materials = 1
if(linked_imprinter)
if(linked_imprinter.busy)
to_chat(usr, "<span class='danger'>Circuit Imprinter is busy at the moment.</span>")
return
var/datum/design/being_built = null
being_built = files.known_designs[params["id"]]
if(being_built)
var/power = 2000
for(var/M in being_built.materials)
power += round(being_built.materials[M] / 5)
power = max(2000, power)
if(!(being_built.build_type & IMPRINTER))
g2g = 0
message_admins("Circuit imprinter exploit attempted by [key_name(usr, TRUE)]!")
else if(href_list["find_device"]) //The R&D console looks for devices nearby to link up with.
add_wait_message("Updating Database...", SYNC_DEVICE_DELAY)
spawn(SYNC_DEVICE_DELAY)
SyncRDevices()
clear_wait_message()
SSnanoui.update_uis(src)
if(g2g) //Again, if input is wrong, do nothing
add_wait_message("Imprinting Circuit. Please Wait...", IMPRINTER_DELAY)
linked_imprinter.busy = 1
flick("circuit_imprinter_ani",linked_imprinter)
use_power(power)
else if(href_list["disconnect"]) //The R&D console disconnects with a specific device.
switch(href_list["disconnect"])
if("destroy")
linked_destroy.linked_console = null
linked_destroy = null
if("lathe")
linked_lathe.linked_console = null
linked_lathe = null
if("imprinter")
linked_imprinter.linked_console = null
linked_imprinter = null
var/list/efficient_mats = list()
for(var/MAT in being_built.materials)
efficient_mats[MAT] = being_built.materials[MAT]/coeff
else if(href_list["reset"]) //Reset the R&D console's database.
griefProtection()
var/choice = alert("Are you sure you want to reset the R&D console's database? Data lost cannot be recovered.", "R&D Console Database Reset", "Continue", "Cancel")
if(choice == "Continue")
add_wait_message("Updating Database...", RESET_RESEARCH_DELAY)
qdel(files)
files = new /datum/research(src)
spawn(RESET_RESEARCH_DELAY)
if(!linked_imprinter.materials.has_materials(efficient_mats))
visible_message("<span class='notice'>The [src.name] beeps, \"Not enough materials to complete prototype.\"</span>")
enough_materials = 0
g2g = 0
else
for(var/R in being_built.reagents_list)
if(!linked_imprinter.reagents.has_reagent(R, being_built.reagents_list[R]/coeff))
visible_message("<span class='notice'>The [name] beeps, \"Not enough reagents to complete prototype.\"</span>")
enough_materials = 0
g2g = 0
if(enough_materials)
linked_imprinter.materials.use_amount(efficient_mats)
for(var/R in being_built.reagents_list)
linked_imprinter.reagents.remove_reagent(R, being_built.reagents_list[R]/coeff)
var/P = being_built.build_path //lets save these values before the spawn() just in case. Nobody likes runtimes.
spawn(IMPRINTER_DELAY)
if(g2g)
var/obj/item/new_item = new P(src)
new_item.loc = linked_imprinter.loc
linked_imprinter.busy = 0
clear_wait_message()
SStgui.update_uis(src)
if("disposeI") //Causes the circuit imprinter to dispose of a single reagent (all of it)
if(linked_imprinter)
linked_imprinter.reagents.del_reagent(params["id"])
if("disposeallI") //Causes the circuit imprinter to dispose of all it's reagents.
if(linked_imprinter)
linked_imprinter.reagents.clear_reagents()
if("disposeP") //Causes the protolathe to dispose of a single reagent (all of it)
if(linked_lathe)
linked_lathe.reagents.del_reagent(params["id"])
if("disposeallP") //Causes the protolathe to dispose of all it's reagents.
if(linked_lathe)
linked_lathe.reagents.clear_reagents()
if("lathe_ejectsheet") //Causes the protolathe to eject a sheet of material
if(linked_lathe)
var/desired_num_sheets
if(params["amount"] == "custom")
desired_num_sheets = input("How many sheets would you like to eject from the machine?", "How much?", 1) as null|num
desired_num_sheets = max(0,desired_num_sheets) // If you input too high of a number, the mineral datum will take care of it either way
if(!desired_num_sheets)
return TRUE
desired_num_sheets = round(desired_num_sheets) // No partial-sheet goofery
else
desired_num_sheets = text2num(params["amount"])
linked_lathe.materials.retrieve_sheets(desired_num_sheets, params["id"])
if("imprinter_ejectsheet") //Causes the protolathe to eject a sheet of material
if(linked_imprinter)
var/desired_num_sheets = text2num(params["amount"])
if(params["amount"] == "custom")
desired_num_sheets = input("How many sheets would you like to eject from the machine?", "How much?", 1) as null|num
desired_num_sheets = max(0,desired_num_sheets) // for the imprinter they have something hacky, that still will guard against shenanigans. eh
if(!desired_num_sheets)
return
desired_num_sheets = round(desired_num_sheets) // No partial-sheet goofery
else
desired_num_sheets = text2num(params["amount"])
linked_imprinter.materials.retrieve_sheets(desired_num_sheets, params["id"])
if("find_device") //The R&D console looks for devices nearby to link up with.
add_wait_message("Updating Database...", SYNC_DEVICE_DELAY)
spawn(SYNC_DEVICE_DELAY)
SyncRDevices()
clear_wait_message()
SSnanoui.update_uis(src)
SStgui.update_uis(src)
else if(href_list["search"]) //Search for designs with name matching pattern
var/compare
if("disconnect") //The R&D console disconnects with a specific device.
switch(params["item"])
if("destroy")
linked_destroy.linked_console = null
linked_destroy = null
if("lathe")
linked_lathe.linked_console = null
linked_lathe = null
if("imprinter")
linked_imprinter.linked_console = null
linked_imprinter = null
matching_designs.Cut()
if("reset") //Reset the R&D console's database.
griefProtection()
var/choice = alert("Are you sure you want to reset the R&D console's database? Data lost cannot be recovered.", "R&D Console Database Reset", "Continue", "Cancel")
if(choice == "Continue")
add_wait_message("Updating Database...", RESET_RESEARCH_DELAY)
qdel(files)
files = new /datum/research(src)
spawn(RESET_RESEARCH_DELAY)
clear_wait_message()
SStgui.update_uis(src)
if(menu == 4)
compare = PROTOLATHE
else
compare = IMPRINTER
if("search") //Search for designs with name matching pattern
var/compare
for(var/v in files.known_designs)
var/datum/design/D = files.known_designs[v]
if(!(D.build_type & compare))
continue
if(findtext(D.name,href_list["to_search"]))
matching_designs.Add(D)
submenu = 1
matching_designs.Cut()
selected_category = "Search Results for '[href_list["to_search"]]'"
if(menu == 4)
compare = PROTOLATHE
else
compare = IMPRINTER
SSnanoui.update_uis(src)
return
for(var/v in files.known_designs)
var/datum/design/D = files.known_designs[v]
if(!(D.build_type & compare))
continue
if(findtext(D.name,params["to_search"]))
matching_designs.Add(D)
submenu = 1
selected_category = "Search Results for '[params["to_search"]]'"
return TRUE // update uis
/obj/machinery/computer/rdconsole/attack_hand(mob/user as mob)
@@ -636,17 +643,17 @@ won't update every console in existence) but it's more of a hassle to do. Also,
if(!allowed(user) && !isobserver(user))
to_chat(user, "<span class='warning'>Access denied.</span>")
return 1
ui_interact(user)
tgui_interact(user)
/obj/machinery/computer/rdconsole/ui_interact(mob/user, ui_key="main", var/datum/nanoui/ui = null, var/force_open = 1)
/obj/machinery/computer/rdconsole/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = TRUE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_default_state)
user.set_machine(src)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "r_n_d.tmpl", src.name, 800, 550)
ui = new(user, src, ui_key, "RndConsole", src.name, 800, 550, master_ui, state)
ui.open()
/obj/machinery/computer/rdconsole/ui_data(mob/user, ui_key = "main", datum/topic_state/state = GLOB.default_state)
var/data[0]
/obj/machinery/computer/rdconsole/tgui_data(mob/user, ui_key = "main", datum/topic_state/state = GLOB.default_state)
var/list/data = list()
files.RefreshResearch()
@@ -659,7 +666,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
data["linked_lathe"] = linked_lathe ? 1 : 0
data["linked_imprinter"] = linked_imprinter ? 1 : 0
data["sync"] = sync
data["admin"] = check_rights(R_ADMIN,0)
data["admin"] = check_rights(R_ADMIN,0,user)
data["disk_type"] = d_disk ? 2 : (t_disk ? 1 : 0)
data["category"] = selected_category
@@ -764,7 +771,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
var/list/materials_list = list()
design_list["materials"] = materials_list
design_list["id"] = D.id
design_list["name"] = sanitize(D.name)
design_list["name"] = D.name
var/c = 50
for(var/M in D.materials)
var/list/material_list = list()
@@ -833,7 +840,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
var/list/materials_list = list()
design_list["materials"] = materials_list
design_list["id"] = D.id
design_list["name"] = sanitize(D.name)
design_list["name"] = D.name
var/check_materials = 1
for(var/M in D.materials)
var/list/material_list = list()
@@ -903,7 +910,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
// if the timer calls this function
deltimer(wait_message_timer)
wait_message_timer = 0
SSnanoui.update_uis(src)
SStgui.update_uis(src)
/obj/machinery/computer/rdconsole/core
-269
View File
@@ -1,269 +0,0 @@
{{if data.menu > 0}}
<div class='item'>
{{:helper.link('Main Menu', 'reply', {'menu': 0, 'submenu': 0})}}
{{if data.submenu > 0}}
{{if data.menu == 2}}
{{:helper.link('Disk Operations Menu', 'reply', {'submenu': 0})}}
{{else data.menu == 4}}
{{:helper.link('Protolathe Menu', 'reply', {'submenu': 0})}}
{{else data.menu == 5}}
{{:helper.link('Circuit Imprinter Menu', 'reply', {'submenu': 0})}}
{{else data.menu == 6}}
{{:helper.link('Settings Menu', 'reply', {'submenu': 0})}}
{{/if}}
{{else data.menu == 4 || data.menu == 5}}
{{:helper.link('Material Storage', 'arrow-up', {'submenu': 2})}}
{{:helper.link('Chemical Storage', 'arrow-up', {'submenu': 3})}}
{{/if}}
</div>
{{/if}}
<div class='statusDisplay'>
{{if data.menu == 0}}
<h3>Main Menu:</h3>
<div class='line'>{{:helper.link('Disk Operations', 'save', {'menu': 2, 'submenu': 0}, data.disk_type ? null : 'disabled')}}</div>
<div class='line'>{{:helper.link('Destructive Analyzer Menu', 'chain-broken', {'menu': 3, 'submenu': 0}, data.linked_destroy ? null : 'disabled')}}</div>
<div class='line'>{{:helper.link('Protolathe Menu', 'print', {'menu': 4, 'submenu': 0}, data.linked_lathe ? null : 'disabled')}}</div>
<div class='line'>{{:helper.link('Circuit Imprinter Menu', 'print', {'menu': 5, 'submenu': 0}, data.linked_imprinter ? null : 'disabled')}}</div>
<div class='line'>{{:helper.link('Settings', 'gear', {'menu': 6, 'submenu': 0})}}</div>
<br>
<br>
Current Research Levels:
{{for data.tech_levels}}
<div class='line'><div class='itemLabel'>{{:value.name}}:</div>{{:value.level}}</div>
{{/for}}
{{else data.menu == 1}}
<h3>Current Research Levels:</h3>
{{for data.tech_levels}}
{{if index > 0}}
<hr>
{{/if}}
<div class='line'>{{:value.name}}</div>
<div class='line'>* Level: {{:value.level}}</div>
<div class='line'>* Summary: {{:value.desc}}</div>
{{/for}}
{{else data.menu == 2 && data.disk_type}}
{{if data.submenu == 0}}
<h3>Data Disk Contents:</h3>
{{if data.disk_data}}
{{if data.disk_type == 1}}
<div class='line'>Name: {{:data.disk_data.name}}</div>
<div class='line'>Level: {{:data.disk_data.level}}</div>
<div class='line'>Description: {{:data.disk_data.desc}}</div>
{{:helper.link('Upload to Database', 'arrow-up', {'updt_tech': 1})}}
{{:helper.link('Clear Disk', 'trash', {'clear_tech': 1})}}
{{else}}
<div class='line'>Name: {{:data.disk_data.name}}</div>
<div class='line'>
{{for data.disk_data.lathe_types}}
{{if index == 0}}
Lathe Types:
{{else}}
,
{{/if}}
{{:value}}
{{/for}}
</div>
<div class'line'>Required Materials:</div>
{{for data.disk_data.materials}}
<div class='line'>{{:value.name}} x {{:value.amount}}</div>
{{/for}}
{{:helper.link('Upload to Database', 'arrow-up', {'updt_design': 1})}}
{{:helper.link('Clear Disk', 'trash', {'clear_design': 1})}}
{{/if}}
{{else}}
<div class='line'>This disk is empty.</div>
{{:helper.link(data.disk_type == 1 ? 'Load Tech to Disk' : 'Load Design to Disk', 'arrow-down', {'submenu': 1})}}
{{/if}}
{{:helper.link('Eject Disk', 'eject', data.disk_type == 1 ? {'eject_tech': 1} : {'eject_design': 1})}}
{{else data.submenu == 1}}
{{for data.to_copy}}
<div class='line'>
<div class='itemLabel'>{{:value.name}}</div>
{{:helper.link('Copy to Disk', 'arrow-down', data.disk_type == 1 ? {'copy_tech': 1, 'copy_tech_ID': value.id} : {'copy_design': 1, 'copy_design_ID': value.id})}}
</div>
{{/for}}
{{/if}}
{{else data.menu == 3 && !data.linked_destroy}}
NO DESTRUCTIVE ANALYZER LINKED TO CONSOLE
{{else data.menu == 4 && !data.linked_lathe}}
NO PROTOLATHE LINKED TO CONSOLE
{{else data.menu == 5 && !data.linked_imprinter}}
NO CIRCUIT IMPRITER LINKED TO CONSOLE
{{else data.menu == 3}}
{{if !data.loaded_item}}
No item loaded. Standing by...
{{else}}
<h3>Deconstruction Menu:</h3>
<div class='line'>Name: {{:data.loaded_item.name}}</div>
<h3>Origin Tech:</h3>
{{for data.loaded_item.origin_tech}}
<div class='item'>
<div class='itemLabelWide'>* {{:value.name}}:</div>
<div class='itemLabelNarrow'>
{{:value.object_level}}
{{if value.current_level}}
(Current: {{:value.current_level}})
{{/if}}
</div>
</div>
{{/for}}
<h3>Options:</h3>
{{:helper.link('Deconstruct Item', 'chain-broken', {'deconstruct': 1})}}
{{:helper.link('Eject Item', 'eject', {'eject_item': 1})}}
{{/if}}
{{else data.menu == 4 || data.menu == 5}}
{{if data.submenu == 0}}
<h3>{{:(data.menu == 4 ? 'Protolathe' : 'Circuit Imprinter')}} Menu:</h3>
{{else data.submenu == 1}}
<h3>{{:data.category}}:</h3>
{{else data.submenu == 2}}
<h3>Material Storage:</h3>
{{else data.submenu == 3}}
<h3>Chemical Storage:</h3>
{{/if}}
{{if data.submenu < 2}}
<div class='itemLabelWidest'><table>
<tr>
<td><b>Material Amount:</b></td><td>{{:data.total_materials}}</td>
{{if data.max_materials}}
<td> / {{:data.max_materials}}</td>
{{/if}}
</tr>
<tr>
<td><b>Chemical Amount:</b></td><td>{{:data.total_chemicals}}</td>
{{if data.max_chemicals}}
<td> / {{:data.max_chemicals}}</td>
{{/if}}
</tr>
</table></div>
{{/if}}
{{if data.submenu == 0}}
<form action='byond://'>
<input type='hidden' name='src' value='{{:data.src_ref}}'>
<input type='hidden' name='search' value='1'>
<input type='text' name='to_search'>
<input type='submit' value='Search'>
</form>
<hr>
<table class='item'><tr>
{{for data.categories}}
{{if (index & 1) == 0 && index != 0}}
</tr><tr>
{{/if}}
<td>{{:helper.link(value, 'arrow-right', {'category': value})}}</td>
{{/for}}
</tr></table>
{{else data.submenu == 1}}
<table>
{{for data.matching_designs}}
<tr>
<td>{{:helper.link(value.name, 'print', data.menu == 4 ? {'build': value.id, 'amount': 1} : {'imprint': value.id}, value.can_build ? null : 'disabled')}}</td>
<td>{{if value.can_build >= 5}}
{{:helper.link('x5', null, data.menu == 4 ? {'build': value.id, 'amount': 5} : {'imprint': value.id})}}
{{/if}}</td>
<td>{{if value.can_build >= 10}}
{{:helper.link('x10', null, data.menu == 4 ? {'build': value.id, 'amount': 10} : {'imprint': value.id})}}
{{/if}}</td>
<td>
{{for value.materials : material : i}}
|
{{if material.is_red}}
<span class='bad'>
{{/if}}
{{:material.amount}} {{:material.name}}
{{if material.is_red}}
</span>
{{/if}}
{{/for}}
</td>
</tr>
{{/for}}
</table>
{{else data.submenu == 2}}
{{for data.loaded_materials}}
<div class='item'>
<div class='itemLabel'>* {{:value.amount}} of {{:value.name}}</div> <div class='itemLabelNarrow'>({{:Math.round((value.amount / 2000) * 10) / 10}} sheets)</div>
{{if value.amount >= 2000}}
{{if data.menu == 4}}
{{:helper.link('1x', 'eject', {'lathe_ejectsheet': value.id, 'lathe_ejectsheet_amt': 1})}}
{{:helper.link('C', 'eject', {'lathe_ejectsheet': value.id, 'lathe_ejectsheet_amt': 'custom'})}}
{{if value.amount >= 2000*5}}
{{:helper.link('5x', 'eject', {'lathe_ejectsheet': value.id, 'lathe_ejectsheet_amt': 5})}}
{{/if}}
{{:helper.link('All', 'eject', {'lathe_ejectsheet': value.id, 'lathe_ejectsheet_amt': 50})}}
{{else}}
{{:helper.link('1x', 'eject', {'imprinter_ejectsheet': value.id, 'imprinter_ejectsheet_amt': 1})}}
{{:helper.link('C', 'eject', {'imprinter_ejectsheet': value.id, 'imprinter_ejectsheet_amt': 'custom'})}}
{{if value.amount >= 2000*5}}
{{:helper.link('5x', 'eject', {'imprinter_ejectsheet': value.id, 'imprinter_ejectsheet_amt': 5})}}
{{/if}}
{{:helper.link('All', 'eject', {'imprinter_ejectsheet': value.id, 'imprinter_ejectsheet_amt': 50})}}
{{/if}}
{{/if}}
</div>
{{/for}}
{{else data.submenu == 3}}
<div class='item'>
{{:helper.link('Purge All', 'trash', data.menu == 4 ? {'disposeallP': 1} : {'disposeallI' : 1})}}
</div>
{{for data.loaded_chemicals}}
<div class='item'>
<div class='itemLabel'>* {{:value.volume}} of {{:value.name}}</div>
{{:helper.link('Purge', 'trash', data.menu == 4 ? {'disposeP': value.id} : {'disposeI': value.id})}}
</div>
{{/for}}
{{/if}}
{{else data.menu == 6}}
{{if data.submenu == 0}}
<h3>Settings:</h3>
<div class='line'>{{:helper.link('Sync Database with Network', 'refresh', {'sync': 1}, data.sync ? null : 'disabled')}}</div>
<div class='line'>{{:helper.link('Connect to Research Network', 'plug', {'togglesync': 1}, data.sync ? 'selected' : null)}}</div>
<div class='line'>{{:helper.link('Disconnect from Research Network', 'chain-broken', {'togglesync': 1}, data.sync ? null : 'selected')}}</div>
<div class='line'>{{:helper.link('Device Linkage Menu', 'chain', {'menu': 6, 'submenu': 1})}}</div>
{{if data.admin}}
<div class='line'>{{:helper.link('[ADMIN] Maximize Research Levels', 'exclamation', {'maxresearch': 1})}}</div>
{{/if}}
<div class='line'>{{:helper.link('Reset Database', 'trash-o', {'reset': 1})}}</div>
{{else data.submenu == 1}}
<h3>Device Linkage Menu:</h3>
<div class='item'>{{:helper.link('Re-sync with Nearby Devices', 'chain', {'find_device': 1})}}</div>
<h3>Linked Devices:</h3>
<div class='item'>
{{if data.linked_destroy}}
<div class='itemLabel'>* Destructive Analyzer</div>
{{:helper.link('Unlink', 'chain-broken', {'disconnect': 'destroy'})}}
{{else}}
<div class='itemLabel'>* No Destructive Analyzer Linked</div>
{{/if}}
</div>
<div class='item'>
{{if data.linked_lathe}}
<div class='itemLabel'>* Protolathe</div>
{{:helper.link('Unlink', 'chain-broken', {'disconnect': 'lathe'})}}
{{else}}
<div class='itemLabel'>* No Protolathe Linked</div>
{{/if}}
</div>
<div class='item'>
{{if data.linked_imprinter}}
<div class='itemLabel'>* Circuit Imprinter</div>
{{:helper.link('Unlink', 'chain-broken', {'disconnect': 'imprinter'})}}
{{else}}
<div class='itemLabel'>* No Circuit Imprinter Linked</div>
{{/if}}
</div>
{{/if}}
{{/if}}
</div>
{{if data.wait_message}}
<div class="mask">
<div class="maskContent">
<h1>{{:data.wait_message}}</h1>
</div>
</div>
{{/if}}