mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
Nicer filing cabinet (#7210)
This commit is contained in:
190
modular_chomp/code/modules/paperwork/filingcabinet.dm
Normal file
190
modular_chomp/code/modules/paperwork/filingcabinet.dm
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
/* Filing cabinets!
|
||||||
|
* Contains:
|
||||||
|
* Filing Cabinets
|
||||||
|
* Security Record Cabinets
|
||||||
|
* Medical Record Cabinets
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Filing Cabinets
|
||||||
|
*/
|
||||||
|
/obj/structure/filingcabinet
|
||||||
|
name = "filing cabinet"
|
||||||
|
desc = "A large cabinet with drawers."
|
||||||
|
icon = 'icons/obj/bureaucracy.dmi'
|
||||||
|
icon_state = "filingcabinet"
|
||||||
|
density = TRUE
|
||||||
|
anchored = TRUE
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/chestdrawer
|
||||||
|
name = "chest drawer"
|
||||||
|
icon_state = "chestdrawer"
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/filingcabinet //not changing the path to avoid unecessary map issues, but please don't name stuff like this in the future -Pete
|
||||||
|
icon_state = "tallcabinet"
|
||||||
|
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/Initialize()
|
||||||
|
for(var/obj/item/I in loc)
|
||||||
|
if(istype(I, /obj/item/weapon/paper) || istype(I, /obj/item/weapon/folder) || istype(I, /obj/item/weapon/photo) || istype(I, /obj/item/weapon/paper_bundle))
|
||||||
|
I.loc = src
|
||||||
|
. = ..()
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/attackby(obj/item/P as obj, mob/user as mob)
|
||||||
|
if(istype(P, /obj/item/weapon/paper) || istype(P, /obj/item/weapon/folder) || istype(P, /obj/item/weapon/photo) || istype(P, /obj/item/weapon/paper_bundle))
|
||||||
|
to_chat(user, "<span class='notice'>You put [P] in [src].</span>")
|
||||||
|
user.drop_item()
|
||||||
|
P.loc = src
|
||||||
|
open_animation()
|
||||||
|
SStgui.update_uis(src)
|
||||||
|
else if(P.has_tool_quality(TOOL_WRENCH))
|
||||||
|
playsound(src, P.usesound, 50, 1)
|
||||||
|
anchored = !anchored
|
||||||
|
to_chat(user, "<span class='notice'>You [anchored ? "wrench" : "unwrench"] \the [src].</span>")
|
||||||
|
else if(P.has_tool_quality(TOOL_SCREWDRIVER))
|
||||||
|
to_chat(user, "<span class='notice'>You begin taking the [name] apart.</span>")
|
||||||
|
playsound(src, P.usesound, 50, 1)
|
||||||
|
if(do_after(user, 10 * P.toolspeed))
|
||||||
|
playsound(src, P.usesound, 50, 1)
|
||||||
|
to_chat(user, "<span class='notice'>You take the [name] apart.</span>")
|
||||||
|
new /obj/item/stack/material/steel( src.loc, 4 )
|
||||||
|
for(var/obj/item/I in contents)
|
||||||
|
I.forceMove(loc)
|
||||||
|
qdel(src)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
to_chat(user, "<span class='notice'>You can't put [P] in [src]!</span>")
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/attack_hand(mob/user as mob)
|
||||||
|
tgui_interact(user)
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/attack_tk(mob/user)
|
||||||
|
if(anchored)
|
||||||
|
return attack_self_tk(user)
|
||||||
|
return ..()
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/attack_self_tk(mob/user)
|
||||||
|
if(contents.len)
|
||||||
|
if(prob(40 + contents.len * 5))
|
||||||
|
var/obj/item/I = pick(contents)
|
||||||
|
I.loc = loc
|
||||||
|
if(prob(25))
|
||||||
|
step_rand(I)
|
||||||
|
to_chat(user, "<span class='notice'>You pull \a [I] out of [src] at random.</span>")
|
||||||
|
return
|
||||||
|
to_chat(user, "<span class='notice'>You find nothing in [src].</span>")
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/tgui_state(mob/user)
|
||||||
|
return GLOB.tgui_physical_state
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/tgui_interact(mob/user, datum/tgui/ui)
|
||||||
|
ui = SStgui.try_update_ui(user, src, ui)
|
||||||
|
if(!ui)
|
||||||
|
ui = new(user, src, "FilingCabinet", name)
|
||||||
|
ui.set_autoupdate(FALSE)
|
||||||
|
ui.open()
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/tgui_data(mob/user)
|
||||||
|
var/list/data = list()
|
||||||
|
|
||||||
|
data["cabinet_name"] = "[name]"
|
||||||
|
data["contents"] = list()
|
||||||
|
data["contents_ref"] = list()
|
||||||
|
for(var/obj/item/content in src)
|
||||||
|
data["contents"] += "[content]"
|
||||||
|
data["contents_ref"] += "[REF(content)]"
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/tgui_act(action, params)
|
||||||
|
. = ..()
|
||||||
|
if(.)
|
||||||
|
return
|
||||||
|
|
||||||
|
switch(action)
|
||||||
|
if("remove_object")
|
||||||
|
var/obj/item/content = locate(params["ref"]) in src
|
||||||
|
if(istype(content) && (content.loc == src) && usr.Adjacent(src))
|
||||||
|
usr.put_in_hands(content)
|
||||||
|
open_animation()
|
||||||
|
SStgui.update_uis(src)
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/proc/open_animation()
|
||||||
|
flick("[initial(icon_state)]-open",src)
|
||||||
|
playsound(src, 'sound/bureaucracy/filingcabinet.ogg', 50, 1)
|
||||||
|
spawn(0)
|
||||||
|
sleep(20)
|
||||||
|
icon_state = initial(icon_state)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Security Record Cabinets
|
||||||
|
*/
|
||||||
|
/obj/structure/filingcabinet/security
|
||||||
|
var/virgin = 1
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/security/proc/populate()
|
||||||
|
if(virgin)
|
||||||
|
for(var/datum/data/record/G in data_core.general)
|
||||||
|
var/datum/data/record/S
|
||||||
|
for(var/datum/data/record/R in data_core.security)
|
||||||
|
if((R.fields["name"] == G.fields["name"] || R.fields["id"] == G.fields["id"]))
|
||||||
|
S = R
|
||||||
|
break
|
||||||
|
var/obj/item/weapon/paper/P = new /obj/item/weapon/paper(src)
|
||||||
|
P.info = "<CENTER><B>Security Record</B></CENTER><BR>"
|
||||||
|
P.info += "Name: [G.fields["name"]] ID: [G.fields["id"]]<BR>\nSex: [G.fields["sex"]]<BR>\nAge: [G.fields["age"]]<BR>\nFingerprint: [G.fields["fingerprint"]]<BR>\nPhysical Status: [G.fields["p_stat"]]<BR>\nMental Status: [G.fields["m_stat"]]<BR>"
|
||||||
|
P.info += "<BR>\n<CENTER><B>Security Data</B></CENTER><BR>\nCriminal Status: [S.fields["criminal"]]<BR>\n<BR>\nMinor Crimes: [S.fields["mi_crim"]]<BR>\nDetails: [S.fields["mi_crim_d"]]<BR>\n<BR>\nMajor Crimes: [S.fields["ma_crim"]]<BR>\nDetails: [S.fields["ma_crim_d"]]<BR>\n<BR>\nImportant Notes:<BR>\n\t[S.fields["notes"]]<BR>\n<BR>\n<CENTER><B>Comments/Log</B></CENTER><BR>"
|
||||||
|
var/counter = 1
|
||||||
|
while(S.fields["com_[counter]"])
|
||||||
|
P.info += "[S.fields["com_[counter]"]]<BR>"
|
||||||
|
counter++
|
||||||
|
P.info += "</TT>"
|
||||||
|
P.name = "Security Record ([G.fields["name"]])"
|
||||||
|
virgin = 0 //tabbing here is correct- it's possible for people to try and use it
|
||||||
|
//before the records have been generated, so we do this inside the loop.
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/security/attack_hand()
|
||||||
|
populate()
|
||||||
|
..()
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/security/attack_tk()
|
||||||
|
populate()
|
||||||
|
..()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Medical Record Cabinets
|
||||||
|
*/
|
||||||
|
/obj/structure/filingcabinet/medical
|
||||||
|
var/virgin = 1
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/medical/proc/populate()
|
||||||
|
if(virgin)
|
||||||
|
for(var/datum/data/record/G in data_core.general)
|
||||||
|
var/datum/data/record/M
|
||||||
|
for(var/datum/data/record/R in data_core.medical)
|
||||||
|
if((R.fields["name"] == G.fields["name"] || R.fields["id"] == G.fields["id"]))
|
||||||
|
M = R
|
||||||
|
break
|
||||||
|
if(M)
|
||||||
|
var/obj/item/weapon/paper/P = new /obj/item/weapon/paper(src)
|
||||||
|
P.info = "<CENTER><B>Medical Record</B></CENTER><BR>"
|
||||||
|
P.info += "Name: [G.fields["name"]] ID: [G.fields["id"]]<BR>\nSex: [G.fields["sex"]]<BR>\nAge: [G.fields["age"]]<BR>\nFingerprint: [G.fields["fingerprint"]]<BR>\nPhysical Status: [G.fields["p_stat"]]<BR>\nMental Status: [G.fields["m_stat"]]<BR>"
|
||||||
|
|
||||||
|
P.info += "<BR>\n<CENTER><B>Medical Data</B></CENTER><BR>\nBlood Type: [M.fields["b_type"]]<BR>\nDNA: [M.fields["b_dna"]]<BR>\n<BR>\nMinor Disabilities: [M.fields["mi_dis"]]<BR>\nDetails: [M.fields["mi_dis_d"]]<BR>\n<BR>\nMajor Disabilities: [M.fields["ma_dis"]]<BR>\nDetails: [M.fields["ma_dis_d"]]<BR>\n<BR>\nAllergies: [M.fields["alg"]]<BR>\nDetails: [M.fields["alg_d"]]<BR>\n<BR>\nCurrent Diseases: [M.fields["cdi"]] (per disease info placed in log/comment section)<BR>\nDetails: [M.fields["cdi_d"]]<BR>\n<BR>\nImportant Notes:<BR>\n\t[M.fields["notes"]]<BR>\n<BR>\n<CENTER><B>Comments/Log</B></CENTER><BR>"
|
||||||
|
var/counter = 1
|
||||||
|
while(M.fields["com_[counter]"])
|
||||||
|
P.info += "[M.fields["com_[counter]"]]<BR>"
|
||||||
|
counter++
|
||||||
|
P.info += "</TT>"
|
||||||
|
P.name = "Medical Record ([G.fields["name"]])"
|
||||||
|
virgin = 0 //tabbing here is correct- it's possible for people to try and use it
|
||||||
|
//before the records have been generated, so we do this inside the loop.
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/medical/attack_hand()
|
||||||
|
populate()
|
||||||
|
..()
|
||||||
|
|
||||||
|
/obj/structure/filingcabinet/medical/attack_tk()
|
||||||
|
populate()
|
||||||
|
..()
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
import { sortBy } from 'common/collections';
|
|
||||||
import { useBackend } from '../backend';
|
|
||||||
import { Button, Section } from '../components';
|
|
||||||
import { Window } from '../layouts';
|
|
||||||
|
|
||||||
export const FileCabinet = (props, context) => {
|
|
||||||
const { act, data } = useBackend(context);
|
|
||||||
|
|
||||||
const { contents } = data;
|
|
||||||
|
|
||||||
// Wow, the filing cabinets sort themselves in 2320.
|
|
||||||
const sortedContents = sortBy((val) => val.name)(contents || []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Window width={350} height={300} resizable>
|
|
||||||
<Window.Content scrollable>
|
|
||||||
<Section>
|
|
||||||
{sortedContents.map((item) => (
|
|
||||||
<Button
|
|
||||||
key={item.ref}
|
|
||||||
fluid
|
|
||||||
icon="file"
|
|
||||||
content={item.name}
|
|
||||||
onClick={() => act('retrieve', { ref: item.ref })}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Section>
|
|
||||||
</Window.Content>
|
|
||||||
</Window>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
41
tgui/packages/tgui_ch/interfaces/FilingCabinet.js
Normal file
41
tgui/packages/tgui_ch/interfaces/FilingCabinet.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { useBackend } from '../backend';
|
||||||
|
import { Box, Button, Flex, Section } from '../components';
|
||||||
|
import { Window } from '../layouts';
|
||||||
|
|
||||||
|
export const FilingCabinet = (props, context) => {
|
||||||
|
const { act, data } = useBackend(context);
|
||||||
|
const { cabinet_name, contents, contents_ref } = data;
|
||||||
|
return (
|
||||||
|
<Window title={cabinet_name || 'Filing Cabinet'} width={350} height={300}>
|
||||||
|
<Window.Content backgroundColor="#B88F3D" scrollable>
|
||||||
|
{contents.map((object, index) => (
|
||||||
|
<Flex
|
||||||
|
key={contents_ref[index]}
|
||||||
|
color="black"
|
||||||
|
backgroundColor="white"
|
||||||
|
style={{ padding: '2px' }}
|
||||||
|
mb={0.5}>
|
||||||
|
<Flex.Item align="center" grow={1}>
|
||||||
|
<Box align="center">{object}</Box>
|
||||||
|
</Flex.Item>
|
||||||
|
<Flex.Item>
|
||||||
|
<Button
|
||||||
|
icon="eject"
|
||||||
|
onClick={() =>
|
||||||
|
act('remove_object', { ref: contents_ref[index] })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Flex.Item>
|
||||||
|
</Flex>
|
||||||
|
))}
|
||||||
|
{contents.length === 0 && (
|
||||||
|
<Section>
|
||||||
|
<Box color="white" align="center">
|
||||||
|
The {cabinet_name} is empty!
|
||||||
|
</Box>
|
||||||
|
</Section>
|
||||||
|
)}
|
||||||
|
</Window.Content>
|
||||||
|
</Window>
|
||||||
|
);
|
||||||
|
};
|
||||||
File diff suppressed because one or more lines are too long
@@ -3738,7 +3738,6 @@
|
|||||||
#include "code\modules\paperwork\carbonpaper.dm"
|
#include "code\modules\paperwork\carbonpaper.dm"
|
||||||
#include "code\modules\paperwork\clipboard.dm"
|
#include "code\modules\paperwork\clipboard.dm"
|
||||||
#include "code\modules\paperwork\faxmachine.dm"
|
#include "code\modules\paperwork\faxmachine.dm"
|
||||||
#include "code\modules\paperwork\filingcabinet.dm"
|
|
||||||
#include "code\modules\paperwork\folders.dm"
|
#include "code\modules\paperwork\folders.dm"
|
||||||
#include "code\modules\paperwork\handlabeler.dm"
|
#include "code\modules\paperwork\handlabeler.dm"
|
||||||
#include "code\modules\paperwork\paper.dm"
|
#include "code\modules\paperwork\paper.dm"
|
||||||
@@ -4801,6 +4800,7 @@
|
|||||||
#include "modular_chomp\code\modules\mob\new_player\sprite_accessories_wing.dm"
|
#include "modular_chomp\code\modules\mob\new_player\sprite_accessories_wing.dm"
|
||||||
#include "modular_chomp\code\modules\organs\organ_icon.dm"
|
#include "modular_chomp\code\modules\organs\organ_icon.dm"
|
||||||
#include "modular_chomp\code\modules\overmap\dynamic_sector.dm"
|
#include "modular_chomp\code\modules\overmap\dynamic_sector.dm"
|
||||||
|
#include "modular_chomp\code\modules\paperwork\filingcabinet.dm"
|
||||||
#include "modular_chomp\code\modules\planet\sif.dm"
|
#include "modular_chomp\code\modules\planet\sif.dm"
|
||||||
#include "modular_chomp\code\modules\player_tips\player_tips_list.dm"
|
#include "modular_chomp\code\modules\player_tips\player_tips_list.dm"
|
||||||
#include "modular_chomp\code\modules\power\cells\device_cells.dm"
|
#include "modular_chomp\code\modules\power\cells\device_cells.dm"
|
||||||
|
|||||||
Reference in New Issue
Block a user