Skip to content

Commit

Permalink
Merge pull request #3407 from X0-11/chatupdate
Browse files Browse the repository at this point in the history
Goonchat, finally
  • Loading branch information
BDpuffy420 authored Jun 22, 2023
2 parents 3ee11d8 + b673f1e commit d5961d1
Show file tree
Hide file tree
Showing 108 changed files with 3,581 additions and 516 deletions.
4 changes: 4 additions & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
#include "code\controllers\ProcessScheduler\core\process.dm"
#include "code\controllers\ProcessScheduler\core\processScheduler.dm"
#include "code\controllers\subsystems\atoms.dm"
#include "code\controllers\subsystems\chat.dm"
#include "code\controllers\subsystems\event.dm"
#include "code\controllers\subsystems\garbage.dm"
#include "code\controllers\subsystems\inactivity.dm"
Expand Down Expand Up @@ -1195,6 +1196,7 @@
#include "code\modules\client\client_defines.dm"
#include "code\modules\client\client_helpers.dm"
#include "code\modules\client\client_procs.dm"
#include "code\modules\client\darkmode.dm"
#include "code\modules\client\movement.dm"
#include "code\modules\client\preferences.dm"
#include "code\modules\client\preferences_factions.dm"
Expand Down Expand Up @@ -1426,6 +1428,8 @@
#include "code\modules\games\tarot.dm"
#include "code\modules\genetics\side_effects.dm"
#include "code\modules\ghosttrap\trap.dm"
#include "code\modules\goonchat\_helpers.dm"
#include "code\modules\goonchat\browserOutput.dm"
#include "code\modules\halo\_defs_radio_speech_sizes.dm"
#include "code\modules\halo\difficulty_setting.dm"
#include "code\modules\halo\languages.dm"
Expand Down
7 changes: 6 additions & 1 deletion code/__defines/colors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,9 @@
#define CODEX_COLOR_MECHANICS "#9ebcd8"
#define CODEX_COLOR_ANTAG "#e5a2a2"

#define COLOR_WEBHOOK_DEFAULT 0x8bbbd5

#define COLOR_WEBHOOK_DEFAULT 0x8bbbd5

#define COLOR_DARKMODE_BACKGROUND "#202020"
#define COLOR_DARKMODE_DARKBACKGROUND "#171717"
#define COLOR_DARKMODE_TEXT "#a4bad6"
9 changes: 8 additions & 1 deletion code/__defines/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,11 @@
#define REQUEST_LIBRARY_LOCATION (world.system_type == MS_WINDOWS ? "lib/gotbyond.dll" : "lib/gotbyond.so")

//Elevation Defines//
#define BASE_ELEVATION 0
#define BASE_ELEVATION 0
#ifndef HTTP_POST_DLL_LOCATION
#define HTTP_POST_DLL_LOCATION (world.system_type == MS_WINDOWS ? WINDOWS_HTTP_POST_DLL_LOCATION : UNIX_HTTP_POST_DLL_LOCATION)
#endif

//Misc text define. Does 4 spaces. Used as a makeshift tabulator.
#define FOURSPACES "    "
#define CLIENT_FROM_VAR(I) (ismob(I) ? I:client : (isclient(I) ? I : (istype(I, /datum/mind) ? I:current?:client : null)))
2 changes: 2 additions & 0 deletions code/__defines/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
#define SS_INIT_TICKER -20
#define SS_INIT_AI -21
#define SS_INIT_AIFAST -22


#define SS_INIT_CHAT -90 // Should be lower to ensure chat remains smooth during init.
#define SS_INIT_UNIT_TESTS -100

Expand Down
13 changes: 13 additions & 0 deletions code/_helpers/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -573,3 +573,16 @@ datum/projectile_data

/proc/round_is_spooky(var/spookiness_threshold = config.cult_ghostwriter_req_cultists)
return (cult.current_antagonists.len > spookiness_threshold)

/proc/getviewsize(view)
var/viewX
var/viewY
if(isnum(view))
var/totalviewrange = 1 + 2 * view
viewX = totalviewrange
viewY = totalviewrange
else
var/list/viewrangelist = splittext(view,"x")
viewX = text2num(viewrangelist[1])
viewY = text2num(viewrangelist[2])
return list(viewX, viewY)
1 change: 0 additions & 1 deletion code/_helpers/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -920,4 +920,3 @@ proc/generate_image(var/tx as num, var/ty as num, var/tz as num, var/range as nu
cap.Blend(img, blendMode2iconMode(A.blend_mode), A.pixel_x + xoff, A.pixel_y + yoff)

return cap

2 changes: 1 addition & 1 deletion code/_helpers/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ proc/TextPreview(var/string,var/len=40)
/proc/create_text_tag(var/tagname, var/tagdesc = tagname, var/client/C = null)
if(!(C && C.is_preference_enabled(/datum/client_preference/chat_tags)))
return tagdesc
return "<IMG src='\ref[text_tag_icons.icon]' class='text_tag' iconstate='[tagname]'" + (tagdesc ? " alt='[tagdesc]'" : "") + ">"
return icon2html(icon('./icons/chattags.dmi', tagname), world, realsize=TRUE, class="text_tag")

/proc/contains_az09(var/input)
for(var/i=1, i<=length(input), i++)
Expand Down
24 changes: 15 additions & 9 deletions code/_macros.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,21 @@
#define to_target(target, payload) target << (payload)
#define from_target(target, receiver) target >> (receiver)

#define to_chat(target, message) target << message
#define to_world(message) world << message
#define to_world_log(message) world.log << message
#define sound_to(target, sound) target << sound
#define to_file(file_entry, source_var) file_entry << source_var
#define from_file(file_entry, target_var) file_entry >> target_var
#define show_browser(target, browser_content, browser_name) target << browse(browser_content, browser_name)
#define show_image(target, image) target << image
#define send_rsc(target, rsc_content, rsc_name) target << browse_rsc(rsc_content, rsc_name)
/// Common use
#define legacy_chat(target, message) to_target(target, message)
#define to_world(message) to_chat(world, message)
#define to_world_log(message) to_target(world.log, message)
#define sound_to(target, sound) to_target(target, sound)
#define image_to(target, image) to_target(target, image)
#define show_browser(target, content, title) to_target(target, browse(content, title))
#define close_browser(target, title) to_target(target, browse(null, title))
#define send_rsc(target, content, title) to_target(target, browse_rsc(content, title))
#define send_link(target, url) to_target(target, link(url))
#define send_output(target, msg, control) to_target(target, output(msg, control))
#define from_file(file_entry, target_var) file_entry >> target_var
#define to_file(handle, value) to_target(handle, value)
#define to_save(handle, value) to_target(handle, value) //semantics
#define from_save(handle, target_var) from_target(handle, target_var)

#define MAP_IMAGE_PATH "nano/images/[GLOB.using_map.path]/"

Expand Down
84 changes: 84 additions & 0 deletions code/controllers/subsystems/chat.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
SUBSYSTEM_DEF(chat)
name = "Chat"
wait = 1
runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY
priority = SS_PRIORITY_CHAT
init_order = SS_INIT_CHAT
var/list/payload = list()
var/initialized = 0

/datum/controller/subsystem/chat/Initialize(timeofday)
initialized = 1
return ..()


/datum/controller/subsystem/chat/fire()
for(var/i in payload)
var/client/C = i
to_target(C, output(payload[C], "browseroutput:output"))
payload -= C

if(MC_TICK_CHECK)
return

/datum/controller/subsystem/chat/proc/queue(target, message, handle_whitespace = TRUE, trailing_newline = TRUE)
if(!target || !message)
return

if(!istext(message))
CRASH("to_chat called with invalid input type")

if(target == world)
target = GLOB.clients

//Some macros remain in the string even after parsing and fuck up the eventual output
var/original_message = message
message = replacetext(message, "\improper", "")
message = replacetext(message, "\proper", "")
if(handle_whitespace)
message = replacetext(message, "\n", "<br>")
message = replacetext(message, "\t", "[FOURSPACES][FOURSPACES]")
if (trailing_newline)
message += "<br>"


//url_encode it TWICE, this way any UTF-8 characters are able to be decoded by the Javascript.
//Do the double-encoding here to save nanoseconds
var/twiceEncoded = url_encode(url_encode(message))

if(islist(target))
for(var/I in target)
var/client/C = CLIENT_FROM_VAR(I) //Grab us a client if possible

if(!C)
return

//Send it to the old style output window.
legacy_chat(C, original_message)

if(!C?.chatOutput || C.chatOutput.broken) //A player who hasn't updated his skin file.
continue

if(!C.chatOutput.loaded) //Client still loading, put their messages in a queue
C.chatOutput.messageQueue += message
continue

payload[C] += twiceEncoded

else
var/client/C = CLIENT_FROM_VAR(target) //Grab us a client if possible

if(!C)
return

//Send it to the old style output window.
legacy_chat(C, original_message)

if(!C?.chatOutput || C.chatOutput.broken) //A player who hasn't updated his skin file.
return

if(!C.chatOutput.loaded) //Client still loading, put their messages in a queue
C.chatOutput.messageQueue += message
return

payload[C] += twiceEncoded
4 changes: 2 additions & 2 deletions code/datums/communication/aooc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

for(var/client/target in GLOB.clients)
if(target.holder)
receive_communication(C, target, "<span class='ooc'><span class='aooc'>[create_text_tag("aooc", "Antag-OOC:", target)] <EM>[get_options_bar(C, 0, 1, 1)]:</EM> <span class='message'>[message]</span></span></span>")
receive_communication(C, target, "<span class='ooc'><span class='aooc'>[create_text_tag("aooc", "Antag-OOC:", target)] <EM>[get_options_bar(C, 0, 1, 1)]:</EM> <span class='message linkify'>[message]</span></span></span>")
else if(target.mob && target.mob.mind && target.mob.mind.special_role)
var/display_name = C.key
var/player_display = holder ? "[display_name]([usr.client.holder.rank])" : display_name
receive_communication(C, target, "<span class='ooc'><span class='aooc'>[create_text_tag("aooc", "Antag-OOC:", target)] <EM>[player_display]:</EM> <span class='message'>[message]</span></span></span>")
receive_communication(C, target, "<span class='ooc'><span class='aooc'>[create_text_tag("aooc", "Antag-OOC:", target)] <EM>[player_display]:</EM> <span class='message linkify'>[message]</span></span></span>")
6 changes: 3 additions & 3 deletions code/datums/communication/dsay.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@

/decl/dsay_communication/proc/get_message(var/client/C, var/mob/M, var/message)
var say_verb = pick("complains","moans","whines","laments","blubbers","copes","seethes","malds")
return "[get_name(C, M)] [say_verb], <span class='message'>\"[message]\"</span>"
return "[get_name(C, M)] [say_verb], <span class='message linkify'>\"[message]\"</span>"

/decl/dsay_communication/emote/get_message(var/client/C, var/mob/M, var/message)
return "[get_name(C, M)] <span class='message'>[message]</span>"
return "[get_name(C, M)] <span class='message linkify'>[message]</span>"

/decl/dsay_communication/proc/adjust_channel(var/decl/communication_channel/dsay)
dsay.flags |= COMMUNICATION_ADMIN_FOLLOW|COMMUNICATION_GHOST_FOLLOW // Add admin and ghost follow
Expand All @@ -115,7 +115,7 @@

/decl/dsay_communication/admin/get_message(var/client/communicator, var/mob/M, var/message)
var/stafftype = uppertext(communicator.holder.rank)
return "<span class='name'>[stafftype]([communicator.key])</span> says, <span class='message'>\"[message]\"</span>"
return "<span class='name'>[stafftype]([communicator.key])</span> says, <span class='message linkify'>\"[message]\"</span>"

/decl/dsay_communication/admin/adjust_channel(var/decl/communication_channel/dsay)
dsay.log_proc = /proc/log_say
Expand Down
2 changes: 1 addition & 1 deletion code/datums/communication/ooc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
for(var/client/target in GLOB.clients)
if(target.is_key_ignored(C.key)) // If we're ignored by this person, then do nothing.
continue
var/sent_message = "[create_text_tag("ooc", "OOC:", target)] <EM>[C.key]:</EM> <span class='message'>[message]</span>"
var/sent_message = "[create_text_tag("ooc", "OOC:", target)] <EM>[C.key]:</EM> <span class='message linkify'>[message]</span>"
if(can_badmin)
receive_communication(C, target, "<font color='[ooc_color]'><span class='ooc'>[sent_message]</font></span>")
else
Expand Down
6 changes: 3 additions & 3 deletions code/datums/communication/pray.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
var/mob/M = m
if(!M.client)
continue
if(M.client.holder && M.client.is_preference_enabled(/datum/client_preference/admin/show_chat_prayers))
receive_communication(communicator, M, "\[<A HREF='?_src_=holder;adminspawncookie=\ref[communicator]'>SC</a>\] \[<A HREF='?_src_=holder;take_ic=\ref[src]'>TAKE</a>\]<span class='notice'>\icon[cross] <b><font color=purple>PRAY: </font>[key_name(communicator, 1)]: </b>[message]</span>")
if(M.client.holder)
receive_communication(communicator, M, "\[<A HREF='?_src_=holder;adminspawncookie=\ref[communicator]'>SC</a>\] \[<A HREF='?_src_=holder;narrateto=\ref[communicator]'>DN</a>\]<span class='notice'>[icon2html(cross, M)] <b><font color=purple>PRAY: </font>[key_name(communicator, 1)]: </b>[message]</span>")
else if(communicator == M) //Give it to ourselves
receive_communication(communicator, M, "<span class='notice'>\icon[cross] <b>You send the prayer, \"[message]\" out into the heavens.</b></span>")
receive_communication(communicator, M, "<span class='notice'>[icon2html(cross, M)] <b>You send the prayer, \"[message]\" out into the heavens.</b></span>")

/decl/communication_channel/pray/receive_communication(var/mob/communicator, var/mob/receiver, var/message)
..()
Expand Down
2 changes: 1 addition & 1 deletion code/datums/wires/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var/const/CAMERA_WIRE_NOTHING2 = 32
C.light_disabled = !C.light_disabled

if(CAMERA_WIRE_ALARM)
C.visible_message("\icon[C] *beep*", "\icon[C] *beep*")
C.visible_message("[icon2html(C,viewers(C))] *beep*", "[icon2html(C,viewers(C))] *beep*")
return

/datum/wires/camera/proc/CanDeconstruct()
Expand Down
2 changes: 1 addition & 1 deletion code/datums/wires/particle_accelerator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var/const/PARTICLE_LIMIT_POWER_WIRE = 8 // Determines how strong the PA can be.
C.interface_control = !C.interface_control

if(PARTICLE_LIMIT_POWER_WIRE)
C.visible_message("\icon[C]<b>[C]</b> makes a large whirring noise.")
C.visible_message("[icon2html(C,viewers(C))]<b>[C]</b> makes a large whirring noise.")

/datum/wires/particle_acc/control_box/UpdateCut(var/index, var/mended)
var/obj/machinery/particle_accelerator/control_box/C = holder
Expand Down
2 changes: 1 addition & 1 deletion code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ its easier to just keep the beam vertical.
else
f_name += "oil-stained [name][infix]."

to_chat(user, "\icon[src] That's [f_name] [suffix]")
to_chat(user, "[icon2html(src, user)] That's [f_name] [suffix]")
to_chat(user, desc)

return distance == -1 || (get_dist(src, user) <= distance)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/hologram.dm
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/
end_call()
if (caller_id&&sourcepad)
if(caller_id.loc!=sourcepad.loc)
sourcepad.to_chat(caller_id, "Severing connection to distant holopad.")
to_chat(sourcepad.caller_id, "Severing connection to distant holopad.")
end_call()
audible_message("The connection has been terminated by the caller.")
return 1
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/kitchen/icecream.dm
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
var/obj/item/weapon/reagent_containers/food/snacks/icecream/I = O
if(!I.ice_creamed)
if(product_types[dispense_flavour] > 0)
src.visible_message("\icon[src] <span class='info'>[user] scoops delicious [flavour_name] icecream into [I].</span>")
src.visible_message("[icon2html(src, viewers(src))] <span class='info'>[user] scoops delicious [flavour_name] icecream into [I].</span>")
product_types[dispense_flavour] -= 1
I.add_ice_cream(flavour_name)
// if(beaker)
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/requests_console.dm
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ var/list/obj/machinery/requests_console/allConsoles = list()
screen = RCS_SENTPASS
message_log += "<B>Message sent to [recipient]</B><BR>[message]"
else
audible_message(text("\icon[src] *The Requests Console beeps: 'NOTICE: No server detected!'"),,4)
audible_message(text("[icon2html(src, viewers(src))] *The Requests Console beeps: 'NOTICE: No server detected!'"),,4)


//Handle screen switching
if(href_list["setScreen"])
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/vending.dm
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
if(currently_vending.price > cashmoney.worth)
// This is not a status display message, since it's something the character
// themselves is meant to see BEFORE putting the money in
to_chat(usr, "\icon[cashmoney] <span class='warning'>That is not enough money.</span>")
to_chat(usr, "[icon2html(cashmoney, usr)] <span class='warning'>That is not enough money.</span>")
return 0

visible_message("<span class='info'>\The [usr] inserts some cash into \the [src].</span>")
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/mines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

if(istype(M, /mob/living/carbon/human))
for(var/mob/O in viewers(world.view, src.loc))
to_chat(O, "<span class='warning'>\The [M] triggered the \icon[src] [src]</span>")
to_chat(O, "<span class='warning'>\The [M] triggered the [icon2html(src, O)] [src]</span>")
triggered = 1
call(src,triggerproc)(M)

Expand Down
15 changes: 15 additions & 0 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -705,5 +705,20 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
/obj/item/proc/can_use_when_prone()
return (w_class <= ITEM_SIZE_NORMAL)


/obj/item/proc/can_embed()
return 1

/obj/item/proc/get_examine_line()
if(blood_color)
. = "<span class = 'warning'>[icon2html(src, viewers(src))] [gender==PLURAL?"some":"a"] <font color='[blood_color]'>stained</font> [src]</span>"
else
. = "[icon2html(src, viewers(src))] \a [src]"
var/ID = GetIdCard()
if(ID)
. += " <a href='?src=\ref[ID];look_at_id=1'>\[Look at ID\]</a>"

/obj/item/proc/on_active_hand()

/obj/item/proc/has_embedded()
return
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/geiger.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/obj/item/device/geiger/attack_self(var/mob/user)
scanning = !scanning
update_icon()
to_chat(user, "<span class='notice'>\icon[src] You switch [scanning ? "on" : "off"] [src].</span>")
to_chat(user, "<span class='notice'>[icon2html(src, user)] You switch [scanning ? "on" : "off"] [src].</span>")

/obj/item/device/geiger/update_icon()
if(!scanning)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/hacktool.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
to_chat(user, "<span class='warning'>You are already hacking!</span>")
return 1
if(!is_type_in_list(target, supported_types))
to_chat(user, "\icon[src] <span class='warning'>Unable to hack this target.</span>")
to_chat(user, "[icon2html(src, user)] <span class='warning'>Unable to hack this target.</span>")
return 0
var/found = known_targets.Find(target)
if(found)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/radio/radio.dm
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ GLOBAL_LIST_EMPTY(all_radios)

var/image/I = image('icons/effects/effects.dmi', src, "empdisable")
overlays += I
show_image(src.loc, I)
image_to(src.loc, I)
spawn(10)
overlays -= I
qdel(I)
Expand Down
Loading

0 comments on commit d5961d1

Please sign in to comment.