TGUI Notice Board

This commit is contained in:
ShadowLarkens
2020-08-13 06:16:14 -07:00
parent 78d1d2e9a1
commit 0231088057
3 changed files with 141 additions and 97 deletions

View File

@@ -444,8 +444,12 @@
// 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 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/weapon/clipboard) || istype(src.loc, /obj/item/weapon/folder)) && (src.loc.loc == usr || src.loc.Adjacent(usr)) ) ) if(istype(loc, /obj/item/weapon/clipboard) || istype(loc, /obj/structure/noticeboard) || istype(loc, /obj/item/weapon/folder))
if(loc.loc != usr && !in_range(loc, usr))
return return
else if(loc != usr && !Adjacent(usr))
return
/* /*
t = checkhtml(t) t = checkhtml(t)

View File

@@ -20,36 +20,6 @@
if(LAZYLEN(notices) >= max_notices) if(LAZYLEN(notices) >= max_notices)
break break
// Automatically place noticeboards that aren't mapped to specific positions.
if(pixel_x == 0 && pixel_y == 0)
var/turf/here = get_turf(src)
var/placing = 0
for(var/checkdir in GLOB.cardinal)
var/turf/T = get_step(here, checkdir)
if(T.density)
placing = checkdir
break
for(var/thing in T)
var/atom/A = thing
if(A.simulated && !A.CanPass(src, T))
placing = checkdir
break
switch(placing)
if(NORTH)
pixel_x = 0
pixel_y = 32
if(SOUTH)
pixel_x = 0
pixel_y = -32
if(EAST)
pixel_x = 32
pixel_y = 0
if(WEST)
pixel_x = -32
pixel_y = 0
update_icon() update_icon()
/obj/structure/noticeboard/proc/add_paper(var/atom/movable/paper, var/skip_icon_update) /obj/structure/noticeboard/proc/add_paper(var/atom/movable/paper, var/skip_icon_update)
@@ -77,16 +47,16 @@
QDEL_NULL_LIST(notices) QDEL_NULL_LIST(notices)
. = ..() . = ..()
/obj/structure/noticeboard/ex_act(var/severity) /obj/structure/noticeboard/ex_act(severity)
dismantle() dismantle()
/obj/structure/noticeboard/update_icon() /obj/structure/noticeboard/update_icon()
icon_state = "[base_icon_state][LAZYLEN(notices)]" icon_state = "[base_icon_state][LAZYLEN(notices)]"
/obj/structure/noticeboard/attackby(var/obj/item/weapon/thing, var/mob/user) /obj/structure/noticeboard/attackby(obj/item/I, mob/user)
if(thing.is_screwdriver()) if(I.is_screwdriver())
var/choice = input("Which direction do you wish to place the noticeboard?", "Noticeboard Offset") as null|anything in list("North", "South", "East", "West") var/choice = input("Which direction do you wish to place the noticeboard?", "Noticeboard Offset") as null|anything in list("North", "South", "East", "West", "No Offset")
if(choice && Adjacent(user) && thing.loc == user && !user.incapacitated()) if(choice && Adjacent(user) && I.loc == user && !user.incapacitated())
playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1) playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1)
switch(choice) switch(choice)
if("North") if("North")
@@ -101,27 +71,29 @@
if("West") if("West")
pixel_x = -32 pixel_x = -32
pixel_y = 0 pixel_y = 0
if("No Offset")
return return
else if(thing.is_wrench()) return
visible_message(SPAN_WARNING("\The [user] begins dismantling \the [src].")) else if(I.is_wrench())
visible_message("<span class='warning'>[user] begins dismantling [src].</span>")
playsound(loc, 'sound/items/Ratchet.ogg', 50, 1) playsound(loc, 'sound/items/Ratchet.ogg', 50, 1)
if(do_after(user, 50, src)) if(do_after(user, 50, src))
visible_message(SPAN_DANGER("\The [user] has dismantled \the [src]!")) visible_message("<span class='danger'>[user] has dismantled [src]!</span>")
dismantle() dismantle()
return return
else if(istype(thing, /obj/item/weapon/paper) || istype(thing, /obj/item/weapon/photo)) else if(istype(I, /obj/item/weapon/paper) || istype(I, /obj/item/weapon/photo))
if(jobban_isbanned(user, "Graffiti")) if(jobban_isbanned(user, "Graffiti"))
to_chat(user, SPAN_WARNING("You are banned from leaving persistent information across rounds.")) to_chat(user, "<span class='warning'>You are banned from leaving persistent information across rounds.</span>")
else else
if(LAZYLEN(notices) < max_notices && user.unEquip(thing, src)) if(LAZYLEN(notices) < max_notices && user.unEquip(I, src))
add_fingerprint(user) add_fingerprint(user)
add_paper(thing) add_paper(I)
to_chat(user, SPAN_NOTICE("You pin \the [thing] to \the [src].")) to_chat(user, "<span class='notice'>You pin [I] to [src].</span>")
SSpersistence.track_value(thing, /datum/persistent/paper) SSpersistence.track_value(I, /datum/persistent/paper)
else else
to_chat(user, SPAN_WARNING("You hesitate, certain \the [thing] will not be seen among the many others already attached to \the [src].")) to_chat(user, "<span class='warning'>You hesitate, certain [I] will not be seen among the many others already attached to \the [src].</span>")
return return
..() return ..()
/obj/structure/noticeboard/attack_ai(var/mob/user) /obj/structure/noticeboard/attack_ai(var/mob/user)
examine(user) examine(user)
@@ -129,43 +101,61 @@
/obj/structure/noticeboard/attack_hand(var/mob/user) /obj/structure/noticeboard/attack_hand(var/mob/user)
examine(user) examine(user)
/obj/structure/noticeboard/examine(var/mob/user) /obj/structure/noticeboard/examine(mob/user)
. = ..() tgui_interact(user)
if(.) return list()
var/list/dat = list("<table>")
for(var/thing in notices)
LAZYADD(dat, "<tr><td>[thing]</td><td>")
if(istype(thing, /obj/item/weapon/paper))
LAZYADD(dat, "<a href='?src=\ref[src];read=\ref[thing]'>Read</a><a href='?src=\ref[src];write=\ref[thing]'>Write</a>")
else if(istype(thing, /obj/item/weapon/photo))
LAZYADD(dat, "<a href='?src=\ref[src];look=\ref[thing]'>Look</a>")
LAZYADD(dat, "<a href='?src=\ref[src];remove=\ref[thing]'>Remove</a></td></tr>")
var/datum/browser/popup = new(user, "noticeboard-\ref[src]", "Noticeboard")
popup.set_content(jointext(dat, null))
popup.open()
/obj/structure/noticeboard/Topic(var/mob/user, var/list/href_list) /obj/structure/noticeboard/tgui_interact(mob/user, datum/tgui/ui)
if(href_list["read"]) ui = SStgui.try_update_ui(user, src, ui)
var/obj/item/weapon/paper/P = locate(href_list["read"]) if(!ui)
ui = new(user, src, "NoticeBoard", name)
ui.open()
/obj/structure/noticeboard/tgui_data(mob/user)
var/list/data = ..()
data["notices"] = list()
for(var/obj/item/I in notices)
data["notices"].Add(list(list(
"ispaper" = istype(I, /obj/item/weapon/paper),
"isphoto" = istype(I, /obj/item/weapon/photo),
"name" = I.name,
"ref" = "\ref[I]",
)))
return data
/obj/structure/noticeboard/tgui_act(action, params)
if(..())
return TRUE
switch(action)
if("read")
var/obj/item/weapon/paper/P = locate(params["ref"])
if(P && P.loc == src) if(P && P.loc == src)
P.show_content(user) P.show_content(usr)
. = TOPIC_HANDLED . = TRUE
if(href_list["look"]) if("look")
var/obj/item/weapon/photo/P = locate(href_list["look"]) var/obj/item/weapon/photo/P = locate(params["ref"])
if(P && P.loc == src) if(P && P.loc == src)
P.show(user) P.show(usr)
. = TOPIC_HANDLED . = TRUE
if(href_list["remove"]) if("remove")
remove_paper(locate(href_list["remove"])) if(!in_range(src, usr))
add_fingerprint(user) return FALSE
. = TOPIC_REFRESH var/obj/item/I = locate(params["ref"])
remove_paper(I)
if(istype(I))
usr.put_in_hands(I)
add_fingerprint(usr)
. = TRUE
if(href_list["write"]) if("write")
if((usr.stat || usr.restrained())) //For when a player is handcuffed while they have the notice window open if(!in_range(src, usr))
return return FALSE
var/obj/item/P = locate(href_list["write"]) var/obj/item/P = locate(params["ref"])
if((P && P.loc == src)) //if the paper's on the board if((P && P.loc == src)) //if the paper's on the board
var/mob/living/M = usr var/mob/living/M = usr
if(istype(M)) if(istype(M))
@@ -175,10 +165,7 @@
P.attackby(E, usr) P.attackby(E, usr)
else else
to_chat(M, "<span class='notice'>You'll need something to write with!</span>") to_chat(M, "<span class='notice'>You'll need something to write with!</span>")
. = TOPIC_REFRESH . = TRUE
if(. == TOPIC_REFRESH)
interact(user)
/obj/structure/noticeboard/anomaly /obj/structure/noticeboard/anomaly
notices = 5 notices = 5
@@ -190,32 +177,32 @@
P.info = "<br>We keep test dummies in pens here for a reason, so standard procedure should be to activate newfound alien artifacts and place the two in close proximity. Promising items I might even approve monkey testing on." P.info = "<br>We keep test dummies in pens here for a reason, so standard procedure should be to activate newfound alien artifacts and place the two in close proximity. Promising items I might even approve monkey testing on."
P.stamped = list(/obj/item/weapon/stamp/rd) P.stamped = list(/obj/item/weapon/stamp/rd)
P.overlays = list("paper_stamped_rd") P.overlays = list("paper_stamped_rd")
src.contents += P contents += P
P = new() P = new()
P.name = "Memo RE: materials gathering" P.name = "Memo RE: materials gathering"
P.info = "Corasang,<br>the hands-on approach to gathering our samples may very well be slow at times, but it's safer than allowing the blundering miners to roll willy-nilly over our dig sites in their mechs, destroying everything in the process. And don't forget the escavation tools on your way out there!<br>- R.W" P.info = "Corasang,<br>the hands-on approach to gathering our samples may very well be slow at times, but it's safer than allowing the blundering miners to roll willy-nilly over our dig sites in their mechs, destroying everything in the process. And don't forget the escavation tools on your way out there!<br>- R.W"
P.stamped = list(/obj/item/weapon/stamp/rd) P.stamped = list(/obj/item/weapon/stamp/rd)
P.overlays = list("paper_stamped_rd") P.overlays = list("paper_stamped_rd")
src.contents += P contents += P
P = new() P = new()
P.name = "Memo RE: ethical quandaries" P.name = "Memo RE: ethical quandaries"
P.info = "Darion-<br><br>I don't care what his rank is, our business is that of science and knowledge - questions of moral application do not come into this. Sure, so there are those who would employ the energy-wave particles my modified device has managed to abscond for their own personal gain, but I can hardly see the practical benefits of some of these artifacts our benefactors left behind. Ward--" P.info = "Darion-<br><br>I don't care what his rank is, our business is that of science and knowledge - questions of moral application do not come into this. Sure, so there are those who would employ the energy-wave particles my modified device has managed to abscond for their own personal gain, but I can hardly see the practical benefits of some of these artifacts our benefactors left behind. Ward--"
P.stamped = list(/obj/item/weapon/stamp/rd) P.stamped = list(/obj/item/weapon/stamp/rd)
P.overlays = list("paper_stamped_rd") P.overlays = list("paper_stamped_rd")
src.contents += P contents += P
P = new() P = new()
P.name = "READ ME! Before you people destroy any more samples" P.name = "READ ME! Before you people destroy any more samples"
P.info = "how many times do i have to tell you people, these xeno-arch samples are del-i-cate, and should be handled so! careful application of a focussed, concentrated heat or some corrosive liquids should clear away the extraneous carbon matter, while application of an energy beam will most decidedly destroy it entirely - like someone did to the chemical dispenser! W, <b>the one who signs your paychecks</b>" P.info = "how many times do i have to tell you people, these xeno-arch samples are del-i-cate, and should be handled so! careful application of a focussed, concentrated heat or some corrosive liquids should clear away the extraneous carbon matter, while application of an energy beam will most decidedly destroy it entirely - like someone did to the chemical dispenser! W, <b>the one who signs your paychecks</b>"
P.stamped = list(/obj/item/weapon/stamp/rd) P.stamped = list(/obj/item/weapon/stamp/rd)
P.overlays = list("paper_stamped_rd") P.overlays = list("paper_stamped_rd")
src.contents += P contents += P
P = new() P = new()
P.name = "Reminder regarding the anomalous material suits" P.name = "Reminder regarding the anomalous material suits"
P.info = "Do you people think the anomaly suits are cheap to come by? I'm about a hair trigger away from instituting a log book for the damn things. Only wear them if you're going out for a dig, and for god's sake don't go tramping around in them unless you're field testing something, R" P.info = "Do you people think the anomaly suits are cheap to come by? I'm about a hair trigger away from instituting a log book for the damn things. Only wear them if you're going out for a dig, and for god's sake don't go tramping around in them unless you're field testing something, R"
P.stamped = list(/obj/item/weapon/stamp/rd) P.stamped = list(/obj/item/weapon/stamp/rd)
P.overlays = list("paper_stamped_rd") P.overlays = list("paper_stamped_rd")
src.contents += P contents += P

View File

@@ -0,0 +1,53 @@
import { round } from 'common/math';
import { Fragment } from 'inferno';
import { useBackend } from "../backend";
import { Box, Button, Flex, Icon, LabeledList, ProgressBar, Section } from "../components";
import { Window } from "../layouts";
export const NoticeBoard = (props, context) => {
const { act, data } = useBackend(context);
const {
notices,
} = data;
return (
<Window width={330} height={300}>
<Window.Content>
<Section>
{notices.length ? (
<LabeledList>
{notices.map((notice, i) => (
<LabeledList.Item key={i} label={notice.name}>
{notice.isphoto && (
<Button
icon="image"
content="Look"
onClick={() => act("look", { ref: notice.ref })} />
) || notice.ispaper && (
<Fragment>
<Button
icon="sticky-note"
content="Read"
onClick={() => act("read", { ref: notice.ref })} />
<Button
icon="pen"
content="Write"
onClick={() => act("write", { ref: notice.ref })} />
</Fragment>
) || "Unknown Entity"}
<Button
icon="minus-circle"
content="Remove"
onClick={() => act("remove", { ref: notice.ref })} />
</LabeledList.Item>
))}
</LabeledList>
) : (
<Box color="average">No notices posted here.</Box>
)}
</Section>
</Window.Content>
</Window>
);
};