-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Noticeboard refactor port + approved stamp (#5283)
# 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
Showing
7 changed files
with
170 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |