Files
Aurora.3/code/modules/library/lib_public_computer.dm
Batrachophreno 4ecb0bc21c Repath obj/machinery to obj/structure/machinery [MDB Ignore] (#22500)
Repaths obj/machinery to obj/structure/machinery. **Note for
reviewers:** the only meaningful changed code exists within
**code/game/objects/structures.dm** and
**code/game/objects/structures/_machinery.dm**, largely concerning
damage procs. With the exception of moving airlock defines to their own
file, ALL OTHER CHANGES ARE STRICTLY PATH CHANGES.

Objects, _categorically_, are largely divided between those you can hold
in your hand/inventory and those you can't. Machinery objects are
already subtypes of Structures behaviorally, this PR just makes their
pathing reflect that, and allows for future work (tool actions, more
health/destruction functionality) to be developed without unnecessary
code duplication.

I have tested this PR by loading up the Horizon and dismantling various
machines and structures with tools, shooting guns of various types
throughout the ship, and detonating a bunch of explosions throughout the
ship.
2026-05-26 19:35:48 +00:00

98 lines
2.6 KiB
Plaintext

/*
* Library Public Computer
*/
/obj/structure/machinery/librarypubliccomp
name = "public library computer"
desc = "A computer."
icon = 'icons/obj/library.dmi'
icon_state = "computer"
anchored = TRUE
density = TRUE
var/list/search_results = list()
var/search_title = ""
var/search_author = ""
var/search_category = "Any"
var/db_loading = FALSE
var/db_error = FALSE
/obj/structure/machinery/librarypubliccomp/attack_hand(var/mob/user)
. = ..()
if(.)
return TRUE
ui_interact(user)
/obj/structure/machinery/librarypubliccomp/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "LibraryPublicComputer", "Public Library Terminal", 650, 500)
ui.open()
/obj/structure/machinery/librarypubliccomp/ui_data(mob/user)
var/list/data = list()
data["search_title"] = search_title
data["search_author"] = search_author
data["search_category"] = search_category
data["db_loading"] = db_loading
data["db_error"] = db_error
data["search_results"] = search_results
return data
/obj/structure/machinery/librarypubliccomp/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
add_fingerprint(usr)
switch(action)
if("search")
if(!db_loading)
search_title = sanitize(params["title"])
search_author = sanitize(params["author"])
var/new_category = params["category"]
if(new_category in list("Any", "Fiction", "Non-Fiction", "Reference", "Religion"))
search_category = new_category
INVOKE_ASYNC(src, PROC_REF(async_search))
. = TRUE
/obj/structure/machinery/librarypubliccomp/proc/async_search()
db_loading = TRUE
db_error = FALSE
search_results = list()
SStgui.update_uis(src)
var/sql
var/list/query_args
if(search_category != "Any")
sql = "SELECT author, title, category, id FROM ss13_library WHERE author LIKE :author AND title LIKE :title AND category = :category"
query_args = list(
"title" = "%[search_title]%",
"author" = "%[search_author]%",
"category" = search_category
)
else
sql = "SELECT author, title, category, id FROM ss13_library WHERE author LIKE :author AND title LIKE :title"
query_args = list(
"title" = "%[search_title]%",
"author" = "%[search_author]%"
)
var/datum/db_query/query = SSdbcore.NewQuery(sql, query_args)
if(!query.Execute())
db_error = TRUE
qdel(query)
db_loading = FALSE
SStgui.update_uis(src)
return
var/list/results = list()
while(query.NextRow())
results += list(list(
"author" = query.item[1],
"title" = query.item[2],
"category" = query.item[3],
"id" = text2num(query.item[4])
))
qdel(query)
search_results = results
db_loading = FALSE
SStgui.update_uis(src)