Skip to content

Commit

Permalink
Noticeboard refactor port + approved stamp (#5283)
Browse files Browse the repository at this point in the history
# About the pull request

[Ports](tgstation/tgstation#59389) noticeboard
refactor from TG, also i've made a third button to be able to interact
with paper on noticeboard with a pen, in order to write on it, mapped
noticeboard in req, as well as added some pens to req area.

Also added green approved stamp, added it in QM's office.


![dreamseeker_bzDYkxKWNe](https://github.com/cmss13-devs/cmss13/assets/100090741/b17c889b-040d-4d1b-be08-083ca8d4e127)


# Explain why it's good for the game

Just compare these two, i think it says it all.


![dreamseeker_UW8Us7mk5N](https://github.com/cmss13-devs/cmss13/assets/100090741/a30a014d-109f-4e16-b1cd-355b5896d760)

![dreamseeker_6O618EfJny](https://github.com/cmss13-devs/cmss13/assets/100090741/1dd1dc4c-e4d6-473a-abbc-1afcf893a6f2)



# Testing Photographs and Procedure

<details>
<summary>Screenshots & Videos</summary>


![dreamseeker_xzHKpzcgsN](https://github.com/cmss13-devs/cmss13/assets/100090741/2138e0d8-15ad-4769-b6bb-1ad626f14b4c)


![dreamseeker_c4OoVNPpNY](https://github.com/cmss13-devs/cmss13/assets/100090741/a9b22163-fd1a-46a6-b685-9a7497408c97)


![dreamseeker_oiz4iP9GNA](https://github.com/cmss13-devs/cmss13/assets/100090741/8281a228-da65-42b1-a694-d9b6074b91f2)



</details>


# Changelog
:cl:
add: added approved stamp
fix: fixed being unable to write on papers on noticeboard
ui: changed noticeboard UI from scratch
refactor: refactored noticeboard code
maptweak: added noticeboard to req and approved stamp to QM's office, as
well as some pens in req area to interact with noticeboard
/:cl:
  • Loading branch information
Blundir committed Jan 6, 2024
1 parent ba28bfe commit 9ab207c
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 67 deletions.
4 changes: 4 additions & 0 deletions code/game/objects/items/tools/misc_tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,10 @@
name = "\improper DENIED rubber stamp"
icon_state = "stamp-deny"

/obj/item/tool/stamp/approved
name = "\improper APPROVED rubber stamp"
icon_state = "stamp-approve"

/obj/item/tool/stamp/clown
name = "clown's rubber stamp"
icon_state = "stamp-clown"
Expand Down
145 changes: 88 additions & 57 deletions code/game/objects/structures/noticeboard.dm
Original file line number Diff line number Diff line change
@@ -1,80 +1,111 @@
#define MAX_NOTICES 8

/obj/structure/noticeboard
name = "notice board"
desc = "A board for pinning important notices upon."
icon = 'icons/obj/structures/props/stationobjs.dmi'
icon_state = "nboard00"
icon_state = "noticeboard"
density = FALSE
anchored = TRUE
var/notices = 0

/obj/structure/noticeboard/Initialize()
/obj/structure/noticeboard/Initialize(mapload)
. = ..()
if(!mapload)
return

for(var/obj/item/I in loc)
if(notices > 4) break
if(notices >= MAX_NOTICES)
break
if(istype(I, /obj/item/paper))
I.forceMove(src)
notices++
icon_state = "nboard0[notices]"
update_overlays()

//attaching papers!!
/obj/structure/noticeboard/attackby(obj/item/O as obj, mob/user as mob)
if(istype(O, /obj/item/paper))
if(notices < 5)
O.add_fingerprint(user)
add_fingerprint(user)
user.drop_held_item()
O.forceMove(src)
/obj/structure/noticeboard/attackby(obj/item/O, mob/user, params)
if(istype(O, /obj/item/paper) || istype(O, /obj/item/photo))
if(!allowed(user))
to_chat(user, SPAN_WARNING("You are not authorized to add notices!"))
return
if(notices < MAX_NOTICES)
if(!user.drop_inv_item_to_loc(O, src))
return
notices++
icon_state = "nboard0[notices]" //update sprite
to_chat(user, SPAN_NOTICE("You pin the paper to the noticeboard."))
update_overlays()
to_chat(user, SPAN_NOTICE("You pin the [O] to the noticeboard."))
else
to_chat(user, SPAN_NOTICE("You reach to pin your paper to the board but hesitate. You are certain your paper will not be seen among the many others already attached."))
to_chat(user, SPAN_WARNING("The notice board is full!"))
else if(istype(O, /obj/item/tool/pen))
user.set_interaction(src)
tgui_interact(user)
else
return ..()

/obj/structure/noticeboard/attack_hand(user as mob)
var/dat = "<B>Noticeboard</B><BR>"
for(var/obj/item/paper/P in src)
dat += "<A href='?src=\ref[src];read=\ref[P]'>[P.name]</A> <A href='?src=\ref[src];write=\ref[P]'>Write</A> <A href='?src=\ref[src];remove=\ref[P]'>Remove</A><BR>"
user << browse("<HEAD><TITLE>Notices</TITLE></HEAD>[dat]","window=noticeboard")
onclose(user, "noticeboard")
/obj/structure/noticeboard/attack_hand(mob/user)
. = ..()
user.set_interaction(src)
tgui_interact(user)

/obj/structure/noticeboard/ui_state(mob/user)
return GLOB.physical_state

/obj/structure/noticeboard/Topic(href, href_list)
..()
usr.set_interaction(src)
if(href_list["remove"])
if((usr.stat || usr.is_mob_restrained())) //For when a player is handcuffed while they have the notice window open
return
var/obj/item/P = locate(href_list["remove"])
if((P && P.loc == src))
P.forceMove(get_turf(src) )//dump paper on the floor because you're a clumsy fuck
P.add_fingerprint(usr)
add_fingerprint(usr)
notices--
icon_state = "nboard0[notices]"
/obj/structure/noticeboard/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "NoticeBoard", name)
ui.open()

if(href_list["write"])
if((usr.stat || usr.is_mob_restrained())) //For when a player is handcuffed while they have the notice window open
return
var/obj/item/P = locate(href_list["write"])
/obj/structure/noticeboard/ui_data(mob/user)
var/list/data = list()
data["allowed"] = allowed(user)
data["items"] = list()
for(var/obj/item/content in contents)
var/list/content_data = list(
name = content.name,
ref = REF(content)
)
data["items"] += list(content_data)
return data

/obj/structure/noticeboard/ui_act(action, params)
. = ..()
if(.)
return

var/obj/item/item = locate(params["ref"]) in contents
if(!istype(item) || item.loc != src)
return

var/mob/user = usr

switch(action)
if("examine")
user.examinate(item)
return TRUE
if("write")
var/obj/item/writing_tool = user.get_held_item()
if(!istype(writing_tool, /obj/item/tool/pen))
balloon_alert(user, "you need a pen for that!")
return
item.attackby(writing_tool, user)
return TRUE
if("remove")
if(!allowed(user))
return
remove_item(item, user)
return TRUE

/obj/structure/noticeboard/proc/update_overlays()
if(overlays) overlays.Cut()
if(notices)
overlays += image(icon, "notices_[notices]")

if((P && P.loc == src)) //ifthe paper's on the board
if(HAS_TRAIT(usr.r_hand, TRAIT_TOOL_PEN))
add_fingerprint(usr)
P.attackby(usr.r_hand, usr) //then do ittttt
else
if(HAS_TRAIT(usr.l_hand, TRAIT_TOOL_PEN)) //check other hand for pen
add_fingerprint(usr)
P.attackby(usr.l_hand, usr)
else
to_chat(usr, SPAN_NOTICE("You'll need something to write with!"))
/obj/structure/noticeboard/proc/remove_item(obj/item/item, mob/user)
item.forceMove(loc)
if(user)
user.put_in_hands(item)
balloon_alert(user, "removed from board")
notices--
update_overlays()

if(href_list["read"])
var/obj/item/paper/P = locate(href_list["read"])
if((P && P.loc == src))
if(!( istype(usr, /mob/living/carbon/human) ))
usr << browse("<HTML><HEAD><TITLE>[P.name]</TITLE></HEAD><BODY><TT>[stars(P.info)]</TT></BODY></HTML>", "window=[P.name]")
onclose(usr, "[P.name]")
else
usr << browse("<HTML><HEAD><TITLE>[P.name]</TITLE></HEAD><BODY><TT>[P.info]</TT></BODY></HTML>", "window=[P.name]")
onclose(usr, "[P.name]")
return
4 changes: 2 additions & 2 deletions code/modules/paperwork/paper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@
iscrayon = 1


// if paper is not in usr, then it must be near them, or in a clipboard or folder, which must be in or near usr
if(src.loc != usr && !src.Adjacent(usr) && !((istype(src.loc, /obj/item/clipboard) || istype(src.loc, /obj/item/folder)) && (src.loc.loc == usr || src.loc.Adjacent(usr)) ) )
// if paper is not in usr, then it must be near them, or in a clipboard, noticeboard or folder, which must be in or near usr
if(src.loc != usr && !src.Adjacent(usr) && !((istype(src.loc, /obj/item/clipboard) || istype(src.loc, /obj/structure/noticeboard) || istype(src.loc, /obj/item/folder)) && (src.loc.loc == usr || src.loc.Adjacent(usr)) ) )
return

t = replacetext(t, "\n", "<BR>")
Expand Down
Binary file modified icons/obj/items/paper.dmi
Binary file not shown.
Binary file modified icons/obj/structures/props/stationobjs.dmi
Binary file not shown.
28 changes: 20 additions & 8 deletions maps/map_files/USS_Almayer/USS_Almayer.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -17728,11 +17728,9 @@
},
/area/almayer/squads/req)
"bEt" = (
/obj/structure/machinery/light{
dir = 1
},
/obj/structure/sign/safety/commline_connection{
pixel_y = 32
/obj/structure/noticeboard{
pixel_x = -10;
pixel_y = 31
},
/turf/open/floor/almayer{
dir = 5;
Expand Down Expand Up @@ -34812,6 +34810,7 @@
/obj/structure/surface/table/almayer,
/obj/item/storage/firstaid/regular,
/obj/item/clipboard,
/obj/item/tool/pen,
/turf/open/floor/almayer{
icon_state = "plate"
},
Expand Down Expand Up @@ -41169,6 +41168,10 @@
/obj/structure/machinery/prop/almayer/computer/PC{
dir = 4
},
/obj/item/tool/stamp/approved{
pixel_y = -11;
pixel_x = -3
},
/turf/open/floor/almayer,
/area/almayer/squads/req)
"iVo" = (
Expand Down Expand Up @@ -48282,6 +48285,7 @@
/obj/structure/surface/table/almayer,
/obj/effect/spawner/random/toolbox,
/obj/item/clipboard,
/obj/item/tool/pen,
/turf/open/floor/almayer{
dir = 8;
icon_state = "green"
Expand Down Expand Up @@ -59717,8 +59721,8 @@
"pWA" = (
/obj/structure/machinery/disposal,
/obj/structure/disposalpipe/trunk,
/obj/structure/sign/safety/storage{
pixel_x = -17
/obj/structure/machinery/light{
dir = 8
},
/turf/open/floor/almayer{
dir = 8;
Expand Down Expand Up @@ -65337,6 +65341,14 @@
/obj/structure/pipes/vents/scrubber{
dir = 4
},
/obj/structure/sign/safety/storage{
pixel_y = 7;
pixel_x = -17
},
/obj/structure/sign/safety/commline_connection{
pixel_x = -17;
pixel_y = -7
},
/turf/open/floor/almayer{
dir = 8;
icon_state = "green"
Expand Down Expand Up @@ -123609,7 +123621,7 @@ bdl
lOr
lOr
iwI
lOr
bdl
bdl
bEt
bNP
Expand Down
56 changes: 56 additions & 0 deletions tgui/packages/tgui/interfaces/NoticeBoard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { BooleanLike } from 'common/react';

import { useBackend } from '../backend';
import { Box, Button, Section, Stack } from '../components';
import { Window } from '../layouts';

type Data = {
allowed: BooleanLike;
items: { ref: string; name: string }[];
};

export const NoticeBoard = (props, context) => {
const { act, data } = useBackend<Data>(context);
const { allowed, items = [] } = data;

return (
<Window width={425} height={176}>
<Window.Content backgroundColor="#704D25">
{!items.length ? (
<Section>
<Box color="white" align="center">
The notice board is empty!
</Box>
</Section>
) : (
items.map((item) => (
<Stack
key={item.ref}
color="black"
backgroundColor="white"
style={{ padding: '2px 2px 0 2px' }}>
<Stack.Item align="center" grow>
<Box align="center">{item.name}</Box>
</Stack.Item>
<Stack.Item>
<Button
icon="eye"
onClick={() => act('examine', { ref: item.ref })}
/>
<Button
icon="pen"
onClick={() => act('write', { ref: item.ref })}
/>
<Button
icon="eject"
disabled={!allowed}
onClick={() => act('remove', { ref: item.ref })}
/>
</Stack.Item>
</Stack>
))
)}
</Window.Content>
</Window>
);
};

0 comments on commit 9ab207c

Please sign in to comment.