Skip to content

Commit

Permalink
[PORT] Fancy boxed messages!
Browse files Browse the repository at this point in the history
  • Loading branch information
Absolucy committed Dec 25, 2024
1 parent f24cb08 commit 274b23e
Show file tree
Hide file tree
Showing 50 changed files with 609 additions and 204 deletions.
12 changes: 11 additions & 1 deletion code/__DEFINES/chat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,14 @@
/// Used for debug messages to the server
#define debug_world_log(msg) if (GLOB.Debug2) log_world("DEBUG: [msg]")
/// Adds a generic box around whatever message you're sending in chat. Really makes things stand out.
#define examine_block(str) ("<div class='examine_block'>" + str + "</div>")
#define boxed_message(str) ("<div class='boxed_message'>" + str + "</div>")
/// Adds a box around whatever message you're sending in chat. Can apply color and/or additional classes. Available colors: red, green, blue, purple. Use it like red_box
#define custom_boxed_message(classes, str) ("<div class='boxed_message " + classes + "'>" + str + "</div>")
/// Makes a fieldset with a neaty styled name. Can apply additional classes.
#define fieldset_block(title, content, classes) ("<fieldset class='fieldset " + classes + "'><legend class='fieldset_legend'>" + title + "</legend>" + content + "</fieldset>")
/// Makes a horizontal line with text in the middle
#define separator_hr(str) ("<div class='separator'>" + str + "</div>")
/// Emboldens runechat messages
#define RUNECHAT_BOLD(str) "+[str]+"
/// Helper which creates a chat message which may have a tooltip in some contexts, but not others.
#define conditional_tooltip(normal_text, tooltip_text, condition) ((condition) ? (span_tooltip(tooltip_text, normal_text)) : (normal_text))
8 changes: 4 additions & 4 deletions code/__HELPERS/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,16 @@
* Tips that starts with the @ character won't be html encoded. That's necessary for any tip containing markup tags,
* just make sure they don't also have html characters like <, > and ' which will be garbled.
*/
/proc/send_tip_of_the_round(target, selected_tip)
/proc/send_tip_of_the_round(target, selected_tip, source = "Tip of the round")
var/message
if(selected_tip)
message = selected_tip
else
var/list/randomtips = world.file2list("strings/tips.txt")
var/list/memetips = world.file2list("strings/sillytips.txt")
if(randomtips.len && prob(95))
if(length(randomtips) && prob(95))
message = pick(randomtips)
else if(memetips.len)
else if(length(memetips))
message = pick(memetips)

if(!message)
Expand All @@ -313,4 +313,4 @@
message = html_encode(message)
else
message = copytext(message, 2)
to_chat(target, span_purple(examine_block("<span class='oocplain'><b>Tip of the round: </b>[message]</span>")))
to_chat(target, custom_boxed_message("purple_box", span_purple("<span class='oocplain'><b>[source]: </b>[message]</span>")))
2 changes: 1 addition & 1 deletion code/_onclick/hud/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@
var/server_link = "byond://[server_ip]:[server_port]"
to_chat_immediate(
target = hud.mymob,
html = examine_block(span_info(span_big("Connecting you to [server_name]\nIf nothing happens, try manually connecting to the server ([server_link]), or the server may be down!"))),
html = boxed_message(span_info(span_big("Connecting you to [server_name]\nIf nothing happens, try manually connecting to the server ([server_link]), or the server may be down!"))),
type = MESSAGE_TYPE_INFO,
)
hud.mymob.client << link(server_link)
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
var/msg = "[src] subsystem has likely entered an infinite enqueue loop, restarting MC immediately!"
to_chat_immediate(
GLOB.admins,
examine_block(span_userdanger("ERROR: [msg]")),
boxed_message(span_userdanger("ERROR: [msg]")),
type = MESSAGE_TYPE_DEBUG
)
/* log_enqueue(msg, list("enqueue_log" = enqueue_log.Copy())) */
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/polling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ SUBSYSTEM_DEF(polling)
var/surrounding_icon
if(surrounding_image)
surrounding_icon = icon2html(surrounding_image, candidate_mob, extra_classes = "bigicon")
var/final_message = examine_block("<span style='text-align:center;display:block'>[surrounding_icon] <span style='font-size:1.2em'>[span_ooc(question)]</span> [surrounding_icon]\n[act_jump] [act_signup] [act_never]</span>")
var/final_message = boxed_message("<span style='text-align:center;display:block'>[surrounding_icon] <span style='font-size:1.2em'>[span_ooc(question)]</span> [surrounding_icon]\n[act_jump] [act_signup] [act_never]</span>")
to_chat(candidate_mob, final_message)

// Start processing it so it updates visually the timer
Expand Down
7 changes: 4 additions & 3 deletions code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ SUBSYSTEM_DEF(vote)
var/to_display = current_vote.get_result_text(winners, final_winner, non_voters)

log_vote(to_display)
to_chat(world, "\n" + examine_block(span_infoplain(vote_font("[to_display]"))) + "\n", type = MESSAGE_TYPE_OOC) // monkestation edit: wrap in examine block, use MESSAGE_TYPE_OOC
if(to_display)
to_chat(world, span_infoplain(vote_font("[to_display]")), type = MESSAGE_TYPE_OOC)

// Finally, doing any effects on vote completion
if (final_winner) // if no one voted final_winner will be null
Expand Down Expand Up @@ -235,9 +236,9 @@ SUBSYSTEM_DEF(vote)
var/to_display = current_vote.initiate_vote(vote_initiator_name, duration)

log_vote(to_display)
to_chat(world, "\n" + examine_block(span_infoplain(vote_font("[span_bold(to_display)]\n\
to_chat(world, custom_boxed_message("purple_box center", span_infoplain(vote_font("[span_bold(to_display)]<br>\
Type <b>vote</b> or click <a href='byond://winset?command=vote'>here</a> to place your votes.\n\
You have [DisplayTimeText(duration)] to vote."))) + "\n", type = MESSAGE_TYPE_OOC) // monkestation edit: wrap in examine block, use MESSAGE_TYPE_OOC
You have [DisplayTimeText(duration)] to vote."))), type = MESSAGE_TYPE_OOC)

// And now that it's going, give everyone a voter action
for(var/client/new_voter as anything in GLOB.clients)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/ai_laws/ai_laws.dm
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ GLOBAL_VAR(round_default_lawset)

/datum/ai_laws/proc/show_laws(mob/to_who)
var/list/printable_laws = get_law_list(include_zeroth = TRUE)
to_chat(to_who, examine_block(jointext(printable_laws, "\n")))
to_chat(to_who, boxed_message(jointext(printable_laws, "\n")))

/datum/ai_laws/proc/associate(mob/living/silicon/M)
if(!owner)
Expand Down
4 changes: 2 additions & 2 deletions code/datums/components/trader/trader.dm
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ Can accept both a type path, and an instance of a datum. Type path has priority.
else
buy_info += span_notice("&bull; [initial(thing.name)] for [product_info[TRADER_PRODUCT_INFO_PRICE]] [trader_data.currency_name][product_info[TRADER_PRODUCT_INFO_PRICE_MOD_DESCRIPTION]]; willing to buy [span_green("[tern_op_result]")]")

to_chat(customer, examine_block(buy_info.Join("\n")))
to_chat(customer, boxed_message(buy_info.Join("\n")))

///Displays to the customer what the trader is selling and how much is in stock
/datum/component/trader/proc/trader_sells_what(mob/customer)
Expand All @@ -413,7 +413,7 @@ Can accept both a type path, and an instance of a datum. Type path has priority.
sell_info += span_notice("&bull; [span_red("(OUT OF STOCK)")] [initial(thing.name)] for [product_info[TRADER_PRODUCT_INFO_PRICE]] [trader_data.currency_name]; [span_red("[tern_op_result]")] left in stock")
else
sell_info += span_notice("&bull; [initial(thing.name)] for [product_info[TRADER_PRODUCT_INFO_PRICE]] [trader_data.currency_name]; [span_green("[tern_op_result]")] left in stock")
to_chat(customer, examine_block(sell_info.Join("\n")))
to_chat(customer, boxed_message(sell_info.Join("\n")))

///Sets quantity of all products to initial(quanity); this proc is currently called during initialize
/datum/component/trader/proc/restock_products()
Expand Down
2 changes: 1 addition & 1 deletion code/datums/elements/weapon_description.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
SIGNAL_HANDLER

if(href_list["examine"])
to_chat(user, span_notice(examine_block("[build_label_text(source)]")))
to_chat(user, span_notice(boxed_message("[build_label_text(source)]")))

/**
*
Expand Down
2 changes: 1 addition & 1 deletion code/datums/mind/skills.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@
var/datum/skill/the_skill = i
msg += "[initial(the_skill.name)] - [get_skill_level_name(the_skill)]\n"
msg += "</span>"
to_chat(user, examine_block(msg))
to_chat(user, boxed_message(msg))
2 changes: 1 addition & 1 deletion code/datums/mood.dm
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@

if(LAZYLEN(mob_parent.quirks))
msg += span_notice("You have these quirks: [mob_parent.get_quirk_string(FALSE, CAT_QUIRK_ALL)].")
to_chat(user, examine_block(msg))
to_chat(user, boxed_message(msg))

/// Updates the mob's moodies, if the area provides a mood bonus
/datum/mood/proc/check_area_mood(datum/source, area/new_area)
Expand Down
51 changes: 43 additions & 8 deletions code/datums/votes/_vote_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,57 @@
* Return a formatted string of text to be displayed to everyone.
*/
/datum/vote/proc/get_result_text(list/all_winners, real_winner, list/non_voters)
if(length(all_winners) <= 0 || !real_winner)
return span_bold("Vote Result: Inconclusive - No Votes!")

var/title_text = ""
var/returned_text = ""
if(override_question)
returned_text += span_bold(override_question)
title_text += span_bold(override_question)
else
returned_text += span_bold("[capitalize(name)] Vote")

title_text += span_bold("[capitalize(name)] Vote")

/*
returned_text += "Winner Selection: "
switch(winner_method)
if(VOTE_WINNER_METHOD_NONE)
returned_text += "None"
if(VOTE_WINNER_METHOD_WEIGHTED_RANDOM)
returned_text += "Weighted Random"
else
returned_text += "Simple"
*/

var/total_votes = 0 // for determining percentage of votes
for(var/option in choices)
returned_text += "\n[span_bold(option)]: [choices[option]]"
total_votes += choices[option]

if(total_votes <= 0)
return span_bold("Vote Result: Inconclusive - No Votes!")

/*
if (display_statistics)
returned_text += "\nResults:"
for(var/option in choices)
returned_text += "\n"
var/votes = choices[option]
var/percentage_text = ""
if(votes > 0)
var/actual_percentage = round((votes / total_votes) * 100, 0.1)
var/text = "[actual_percentage]"
var/spaces_needed = 5 - length(text)
for(var/_ in 1 to spaces_needed)
returned_text += " "
percentage_text += "[text]%"
else
percentage_text = " 0%"
returned_text += "[percentage_text] | [span_bold(option)]: [choices[option]]"
*/

if(!real_winner) // vote has no winner or cannot be won, but still had votes
return returned_text

returned_text += "\n"
returned_text += get_winner_text(all_winners, real_winner, non_voters)

return returned_text
return fieldset_block(title_text, returned_text, "boxed_message purple_box")

/**
* Gets the text that displays the winning options within the result text.
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/AI_modules/_AI_modules.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

/obj/item/ai_module/attack_self(mob/user as mob)
..()
to_chat(user, examine_block(display_laws()))
to_chat(user, boxed_message(display_laws()))

/// Returns a text display of the laws for the module.
/obj/item/ai_module/proc/display_laws()
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/devices/flashlight.dm
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
render_list += "<span class='danger ml-1'>[M.p_their(TRUE)] pupils give an eerie glow!</span>\n"//mob has X-ray vision

//display our packaged information in an examine block for easy reading
to_chat(user, examine_block(jointext(render_list, "")), type = MESSAGE_TYPE_INFO)
to_chat(user, boxed_message(jointext(render_list, "")), type = MESSAGE_TYPE_INFO)

if(BODY_ZONE_PRECISE_MOUTH)

Expand Down Expand Up @@ -240,7 +240,7 @@
render_list += "<span class='notice ml-1'>Color returns quickly.</span>\n"//they're okay :D

//display our packaged information in an examine block for easy reading
to_chat(user, examine_block(jointext(render_list, "")), type = MESSAGE_TYPE_INFO)
to_chat(user, boxed_message(jointext(render_list, "")), type = MESSAGE_TYPE_INFO)

else
return ..()
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/scanners/gas_analyzer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
message += span_bold("Large amounts of free neutrons detected in the air indicate that a fusion reaction took place.")
message += span_notice("Power of the last fusion reaction: [fusion_power]\n This power indicates it was a [tier]-tier fusion reaction.")
// we let the join apply newlines so we do need handholding
to_chat(user, examine_block(jointext(message, "\n")), type = MESSAGE_TYPE_INFO)
to_chat(user, boxed_message(jointext(message, "\n")), type = MESSAGE_TYPE_INFO)
return TRUE

/proc/fusionpower2text(power) //used when displaying fusion power on analyzers
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/devices/scanners/health_analyzer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@
// we handled the last <br> so we don't need handholding

if(tochat)
to_chat(user, examine_block(jointext(render_list, "")), trailing_newline = FALSE, type = MESSAGE_TYPE_INFO)
to_chat(user, custom_boxed_message("blue_box", jointext(render_list, "")), trailing_newline = FALSE, type = MESSAGE_TYPE_INFO)
else
return(jointext(render_list, ""))

Expand Down Expand Up @@ -495,7 +495,7 @@
render_list += "<span class='alert ml-2'>[allergies]</span>\n"

// we handled the last <br> so we don't need handholding
to_chat(user, examine_block(jointext(render_list, "")), trailing_newline = FALSE, type = MESSAGE_TYPE_INFO)
to_chat(user, custom_boxed_message("blue_box", jointext(render_list, "")), trailing_newline = FALSE, type = MESSAGE_TYPE_INFO)

/obj/item/healthanalyzer/AltClick(mob/user)
..()
Expand Down Expand Up @@ -548,7 +548,7 @@
simple_scanner.show_emotion(AID_EMOTION_HAPPY)
to_chat(user, "<span class='notice ml-1'>No wounds detected in subject.</span>")
else
to_chat(user, examine_block(jointext(render_list, "")), type = MESSAGE_TYPE_INFO)
to_chat(user, custom_boxed_message("blue_box", jointext(render_list, "")), type = MESSAGE_TYPE_INFO)
if(simple_scan)
var/obj/item/healthanalyzer/simple/simple_scanner = scanner
simple_scanner.show_emotion(AID_EMOTION_WARN)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@
exportable_text += "[special_role_description]<br>"
exportable_text += ADMIN_FULLMONTY_NONAME(subject)

to_chat(src.owner, examine_block(exportable_text), confidential = TRUE)
to_chat(src.owner, boxed_message(exportable_text), confidential = TRUE)

else if(href_list["addjobslot"])
if(!check_rights(R_ADMIN))
Expand Down
7 changes: 6 additions & 1 deletion code/modules/admin/verbs/adminhelp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,12 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
msg = sanitize(copytext_char(msg, 1, MAX_MESSAGE_LEN))
var/ref_src = "[REF(src)]"
//Message to be sent to all admins
var/admin_msg = span_adminnotice(span_adminhelp("Ticket [TicketHref("#[id]", ref_src)]</span><b>: [LinkedReplyName(ref_src)] [FullMonty(ref_src)]:</b> [span_linkify(keywords_lookup(msg))]"))
var/admin_msg = fieldset_block(
span_adminhelp("Ticket [TicketHref("#[id]", ref_src)]"),
"<b>[LinkedReplyName(ref_src)]</b>\n\n\
[span_linkify(keywords_lookup(msg))]\n\n\
<b class='smaller'>[FullMonty(ref_src)]</b>",
"boxed_message red_box")

AddInteraction("<font color='red'>[LinkedReplyName(ref_src)]: [msg]</font>", player_message = "<font color='red'>[LinkedReplyName(ref_src)]: [msg]</font>")
log_admin_private("Ticket #[id]: [key_name(initiator)]: [msg]")
Expand Down
28 changes: 7 additions & 21 deletions code/modules/admin/verbs/adminpm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,6 @@
recipient_ticket_id = recipient_ticket?.id
SSblackbox.LogAhelp(recipient_ticket_id, "Ticket Opened", send_message, recipient.ckey, src.ckey)

to_chat(recipient,
type = MESSAGE_TYPE_ADMINPM,
html = "<font color='red' size='4'><b>-- Administrator private message --</b></font>",
confidential = TRUE)

recipient.receive_ahelp(
link_to_us,
span_linkify(send_message),
Expand All @@ -424,10 +419,6 @@
else
SSplexora.aticket_pm(ticket || recipient_ticket, raw_send_message, src.ckey) // monkestation edit: PLEXORA
// monkestation end: PLEXORA
to_chat(recipient,
type = MESSAGE_TYPE_ADMINPM,
html = span_adminsay("<i>Click on the administrator's name to reply.</i>"),
confidential = TRUE)
to_chat(src,
type = MESSAGE_TYPE_ADMINPM,
html = span_notice("Admin PM to-<b>[their_name_with_link]</b>: [span_linkify(send_message)]"),
Expand Down Expand Up @@ -737,21 +728,11 @@
message_admins("External message from [sender] to [recipient_name_linked] : [message]")
log_admin_private("External PM: [sender] -> [recipient_name] : [message]")

to_chat(recipient,
type = MESSAGE_TYPE_ADMINPM,
html = "<font color='red' size='4'><b>-- Administrator private message --</b></font>",
confidential = TRUE)

recipient.receive_ahelp(
"<a href='?priv_msg=[stealthkey]'>[adminname]</a>",
message,
)

to_chat(recipient,
type = MESSAGE_TYPE_ADMINPM,
html = span_adminsay("<i>Click on the administrator's name to reply.</i>"),
confidential = TRUE)

admin_ticket_log(recipient, "<font color='purple'>PM From [tgs_tagged]: [message]</font>", log_in_blackbox = FALSE)

window_flash(recipient, ignorepref = TRUE)
Expand Down Expand Up @@ -796,8 +777,13 @@
to_chat(
src,
type = MESSAGE_TYPE_ADMINPM,
html = "<span class='[span_class]'>Admin PM from-<b>[reply_to]</b>: [message]</span>",
confidential = TRUE,
html = fieldset_block(
span_adminhelp("Administrator private message"),
"<span class='[span_class]'>Admin PM from-<b>[reply_to]</b></span>\n\n\
<span class='[span_class]'>[message]</span>\n\n\
<i class='adminsay'>Click on the administrator's name to reply.</i>",
"boxed_message red_box"),
confidential = TRUE
)

current_ticket?.player_replied = FALSE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/verbs/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ GLOBAL_VAR_INIT(say_disabled, FALSE)
messages += "<tr><td>[part.Join("</td><td>")]</td></tr>"
messages += "</table>"

to_chat(src, examine_block(messages.Join("")), confidential = TRUE)
to_chat(src, boxed_message(messages.Join("")), confidential = TRUE)

/client/proc/station_food_debug()
set name = "Count Station Food"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/buildmode/submodes/map_export.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
to_chat(builder, "<span class='notice'>[what_to_change] is now [save_flag & options[what_to_change] ? "ENABLED" : "DISABLED"].</span>")

/datum/buildmode_mode/map_export/show_help(client/builder)
to_chat(builder, span_purple(examine_block(
to_chat(builder, span_purple(boxed_message(
"[span_bold("Select corner")] -> Left Mouse Button on obj/turf/mob\n\
[span_bold("Set export options")] -> Right Mouse Button on buildmode button"))
)
Expand Down
Loading

0 comments on commit 274b23e

Please sign in to comment.