From 11b83c5c2fa6004ae8e28b5b2d92374132f0fd65 Mon Sep 17 00:00:00 2001
From: SkyratBot <59378654+SkyratBot@users.noreply.github.com>
Date: Fri, 26 Jan 2024 05:01:58 +0100
Subject: [PATCH] [MIRROR] Newspapers now use TGUI (#26243)
* Newspapers now use TGUI (#80991)
## About The Pull Request
Newspapers work as a static newscaster that is not affected by things
like D-notices and changing wanted issues after its been printed. It
doesn't store comments or get any updates after its been printed.
You can also scribble on the paper to leave notes on a specific page,
which is a feature I have never seen in my life but it is still here I
guess.
Minor things I've added:
- Sound effect when printing the newspaper in the first place
- 2 second do-after when scribbling just for some player feedback and
consistency
- Balloon alerts
- Context tips for scribbling and burning
I also fixed an issue with wanted issues on newscasters when there isn't
an image.
As a minor note, I replaced the instances of ``content`` in Buttons I
saw in newscaster's UI because it's marked as deprecated.
Too lazy to take a video sorry



## Why It's Good For The Game
Fixes an issue with newscasters and makes newspapers use a nice TGUI
that feels more responsive than before.
Helps further https://hackmd.io/XLt5MoRvRxuhFbwtk4VAUA even more.
## Changelog
:cl:
refactor: Newspapers now use TGUI.
fix: Fixed the newscaster's wanted section showing a non-existent photo.
/:cl:
* Newspapers now use TGUI
---------
Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
---
.../newscaster/newscaster_machine.dm | 24 +-
code/game/machinery/newscaster/newspaper.dm | 295 +++++++++---------
code/modules/admin/verbs/admin_newscaster.dm | 6 +-
code/modules/mob/living/silicon/ai/ai.dm | 4 -
code/modules/mob/mob.dm | 12 -
tgui/packages/tgui/interfaces/Newscaster.jsx | 113 +++----
tgui/packages/tgui/interfaces/Newspaper.tsx | 166 ++++++++++
tgui/packages/tgui/process.ts | 17 +
8 files changed, 406 insertions(+), 231 deletions(-)
create mode 100644 tgui/packages/tgui/interfaces/Newspaper.tsx
create mode 100644 tgui/packages/tgui/process.ts
diff --git a/code/game/machinery/newscaster/newscaster_machine.dm b/code/game/machinery/newscaster/newscaster_machine.dm
index 99ea0d31620..e667fe5b96f 100644
--- a/code/game/machinery/newscaster/newscaster_machine.dm
+++ b/code/game/machinery/newscaster/newscaster_machine.dm
@@ -176,14 +176,15 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/newscaster, 30)
data["crime_description"] = crime_description
var/list/wanted_info = list()
if(GLOB.news_network.wanted_issue)
- if(GLOB.news_network.wanted_issue.img)
+ var/has_wanted_issue = !isnull(GLOB.news_network.wanted_issue.img)
+ if(has_wanted_issue)
user << browse_rsc(GLOB.news_network.wanted_issue.img, "wanted_photo.png")
wanted_info = list(list(
"active" = GLOB.news_network.wanted_issue.active,
"criminal" = GLOB.news_network.wanted_issue.criminal,
"crime" = GLOB.news_network.wanted_issue.body,
"author" = GLOB.news_network.wanted_issue.scanned_user,
- "image" = "wanted_photo.png"
+ "image" = (has_wanted_issue ? "wanted_photo.png" : null)
))
//Code breaking down the channels that have been made on-station thus far. ha
@@ -431,7 +432,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/newscaster, 30)
return TRUE
if("printNewspaper")
- print_paper()
+ print_paper(usr)
return TRUE
if("createBounty")
@@ -600,22 +601,14 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/newscaster, 30)
* This takes all current feed stories and messages, and prints them onto a newspaper, after checking that the newscaster has been loaded with paper.
* The newscaster then prints the paper to the floor.
*/
-/obj/machinery/newscaster/proc/print_paper()
+/obj/machinery/newscaster/proc/print_paper(mob/user)
if(paper_remaining <= 0)
balloon_alert_to_viewers("out of paper!")
return TRUE
SSblackbox.record_feedback("amount", "newspapers_printed", 1)
- var/obj/item/newspaper/new_newspaper = new /obj/item/newspaper
- for(var/datum/feed_channel/iterated_feed_channel in GLOB.news_network.network_channels)
- new_newspaper.news_content += iterated_feed_channel
- if(GLOB.news_network.wanted_issue.active)
- new_newspaper.wantedAuthor = GLOB.news_network.wanted_issue.scanned_user
- new_newspaper.wantedCriminal = GLOB.news_network.wanted_issue.criminal
- new_newspaper.wantedBody = GLOB.news_network.wanted_issue.body
- if(GLOB.news_network.wanted_issue.img)
- new_newspaper.wantedPhoto = GLOB.news_network.wanted_issue.img
- new_newspaper.forceMove(drop_location())
- new_newspaper.creation_time = GLOB.news_network.last_action
+ var/obj/item/newspaper/new_newspaper = new(loc)
+ playsound(loc, SFX_PAGE_TURN, 50, TRUE)
+ try_put_in_hand(new_newspaper, user)
paper_remaining--
/**
@@ -677,6 +670,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/newscaster, 30)
new_feed_comment.author = newscaster_username
new_feed_comment.body = comment_text
new_feed_comment.time_stamp = station_time_timestamp()
+ GLOB.news_network.last_action ++
current_message.comments += new_feed_comment
usr.log_message("(as [newscaster_username]) commented on message [current_message.return_body(-1)] -- [current_message.body]", LOG_COMMENT)
creating_comment = FALSE
diff --git a/code/game/machinery/newscaster/newspaper.dm b/code/game/machinery/newscaster/newspaper.dm
index d605d6257c3..e67910974a6 100644
--- a/code/game/machinery/newscaster/newspaper.dm
+++ b/code/game/machinery/newscaster/newspaper.dm
@@ -1,3 +1,8 @@
+/**
+ * Newspapers
+ * A static version of the newscaster, that won't update as new stories are added.
+ * Can be scribbed upon to add extra text for future readers.
+ */
/obj/item/newspaper
name = "newspaper"
desc = "An issue of The Griffon, the newspaper circulating aboard Nanotrasen Space Stations."
@@ -10,167 +15,171 @@
attack_verb_continuous = list("baps")
attack_verb_simple = list("bap")
resistance_flags = FLAMMABLE
- var/screen = 0
- var/pages = 0
- var/curr_page = 0
+
+ ///List of news feeed channels the newspaper can see.
var/list/datum/feed_channel/news_content = list()
- var/scribble=""
- var/scribble_page = null
- var/wantedAuthor
- var/wantedCriminal
- var/wantedBody
- var/wantedPhoto
+ ///The time the newspaper was made in terms of newscaster's last action, used to tell the newspaper whether a story should be in it.
var/creation_time
+ ///The page in the newspaper currently being read. 0 is the title screen while the last is the security screen.
+ var/current_page = 0
+ ///The currently scribbled text written in scribble_page
+ var/scribble_text
+ ///The page with something scribbled on it, can only have one at a time.
+ var/scribble_page
+
+ ///Stored information of the wanted criminal's name, if one existed at the time of creation.
+ var/saved_wanted_criminal
+ ///Stored information of the wanted criminal's description, if one existed at the time of creation.
+ var/saved_wanted_body
+ ///Stored icon of the wanted criminal, if one existed at the time of creation.
+ var/icon/saved_wanted_icon
+
+/obj/item/newspaper/Initialize(mapload)
+ . = ..()
+ register_context()
+ creation_time = GLOB.news_network.last_action
+ for(var/datum/feed_channel/iterated_feed_channel in GLOB.news_network.network_channels)
+ news_content += iterated_feed_channel
+
+ if(!GLOB.news_network.wanted_issue.active)
+ return
+ saved_wanted_criminal = GLOB.news_network.wanted_issue.criminal
+ saved_wanted_body = GLOB.news_network.wanted_issue.body
+ if(GLOB.news_network.wanted_issue.img)
+ saved_wanted_icon = GLOB.news_network.wanted_issue.img
+
+/obj/item/newspaper/add_context(atom/source, list/context, obj/item/held_item, mob/living/user)
+ if(held_item)
+ if(istype(held_item, /obj/item/pen))
+ context[SCREENTIP_CONTEXT_LMB] = "Scribble"
+ return CONTEXTUAL_SCREENTIP_SET
+ if(held_item.get_temperature())
+ context[SCREENTIP_CONTEXT_LMB] = "Burn"
+ return CONTEXTUAL_SCREENTIP_SET
/obj/item/newspaper/suicide_act(mob/living/user)
- user.visible_message(span_suicide("[user] is focusing intently on [src]! It looks like [user.p_theyre()] trying to commit sudoku... until [user.p_their()] eyes light up with realization!"))
- user.say(";JOURNALISM IS MY CALLING! EVERYBODY APPRECIATES UNBIASED REPORTI-GLORF", forced="newspaper suicide")
- var/mob/living/carbon/human/H = user
- var/obj/W = new /obj/item/reagent_containers/cup/glass/bottle/whiskey(H.loc)
- playsound(H.loc, 'sound/items/drink.ogg', rand(10,50), TRUE)
- W.reagents.trans_to(H, W.reagents.total_volume, transferred_by = user)
- user.visible_message(span_suicide("[user] downs the contents of [W.name] in one gulp! Shoulda stuck to sudoku!"))
+ user.visible_message(span_suicide(\
+ "[user] is focusing intently on [src]! It looks like [user.p_theyre()] trying to commit sudoku... \
+ until [user.p_their()] eyes light up with realization!"\
+ ))
+ user.say(";JOURNALISM IS MY CALLING! EVERYBODY APPRECIATES UNBIASED REPORTI-GLORF", forced = "newspaper suicide")
+ var/obj/item/reagent_containers/cup/glass/bottle/whiskey/last_drink = new(user.loc)
+ playsound(user, 'sound/items/drink.ogg', vol = rand(10, 50), vary = TRUE)
+ last_drink.reagents.trans_to(user, last_drink.reagents.total_volume, transferred_by = user)
+ user.visible_message(span_suicide("[user] downs the contents of [last_drink.name] in one gulp! Shoulda stuck to sudoku!"))
return TOXLOSS
-/obj/item/newspaper/attack_self(mob/user)
- if(!istype(user) || !user.can_read(src))
+/obj/item/newspaper/attackby(obj/item/attacking_item, mob/user, params)
+ if(burn_paper_product_attackby_check(attacking_item, user))
+ SStgui.close_uis(src)
return
- var/dat
- pages = 0
- switch(screen)
- if(0) //Cover
- dat+="
The Griffon
"
- dat+="
Nanotrasen-standard newspaper, for use on Nanotrasen? Space Facilities
"
- if(1) // X channel pages inbetween.
- for(var/datum/feed_channel/NP in news_content)
- pages++
- var/datum/feed_channel/C = news_content[curr_page]
- dat += "[C.channel_name] \[created by: [C.return_author(notContent(C.author_censor_time))]\]
"
- if(notContent(C.D_class_censor_time))
- dat+="This channel was deemed dangerous to the general welfare of the station and therefore marked with a D-Notice. Its contents were not transferred to the newspaper at the time of printing."
- else
- if(!length(C.messages))
- dat+="No Feed stories stem from this channel..."
- else
- var/i = 0
- for(var/datum/feed_message/MESSAGE in C.messages)
- if(MESSAGE.creation_time > creation_time)
- if(i == 0)
- dat+="No Feed stories stem from this channel..."
- break
- if(i == 0)
- dat+="
"
- i++
- dat+="-[MESSAGE.return_body(notContent(MESSAGE.body_censor_time))] "
- if(MESSAGE.img)
- user << browse_rsc(MESSAGE.img, "tmp_photo[i].png")
- dat+=" "
- dat+="\[Story by [MESSAGE.return_author(notContent(MESSAGE.author_censor_time))]\]
"
- dat+="
"
- if(scribble_page == curr_page)
- dat+=" There is a small scribble near the end of this page... It reads: \"[scribble]\""
- dat+= "
"
- dat+="Criminal name: [wantedCriminal] "
- dat+="Description: [wantedBody] "
- dat+="Photo:: "
- if(wantedPhoto)
- user << browse_rsc(wantedPhoto, "tmp_photow.png")
- dat+=" "
- else
- dat+="None"
- else
- dat+="Apart from some uninteresting classified ads, there's nothing on this page..."
- if(scribble_page == curr_page)
- dat+=" There is a small scribble near the end of this page... It reads: \"[scribble]\""
- dat+= "