Skip to content

Ports tgui ticket panel from yogs #5906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/modules/admin/sql_message_system.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@
VALUES (:type, :target_ckey, :admin_ckey, :text, [timestamp? ":timestamp" : "Now()"], :server, INET_ATON(:internet_address), :port, :round_id, :secret, :expiry, :note_severity, (SELECT `minutes` FROM [format_table_name("role_time")] WHERE `ckey` = :target_ckey AND `job` = 'Living'))
"}, parameters)
var/pm = "[key_name(usr)] has created a [type][(type == "note" || type == "message" || type == "watchlist entry") ? " for [target_key]" : ""]: [text]"
var/header = "[key_name_admin(usr)] has created a [type][(type == "note" || type == "message" || type == "watchlist entry") ? " for [target_key]" : ""]"
var/header = "[key_name(usr)] has created a [type][(type == "note" || type == "message" || type == "watchlist entry") ? " for [target_key]" : ""]"
if(!query_create_message.warn_execute())
qdel(query_create_message)
return
qdel(query_create_message)
if(logged)
log_admin_private(pm)
message_admins("[header]:<br>[text]")
admin_ticket_log(target_ckey, "<font color='blue'>[header]</font><br>[text]")
admin_ticket_log(target_ckey, "[header]: [text]")
// Monkestation edit start - plexora
var/datum/client_interface/mock_player = new(target_ckey)
mock_player.prefs = new /datum/preferences(mock_player)
Expand Down
6 changes: 6 additions & 0 deletions code/modules/admin/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,10 @@

else if(href_list["adminmoreinfo"])
var/mob/subject = locate(href_list["adminmoreinfo"]) in GLOB.mob_list
// MONKESTATION START
// Moved to monkestation/code/modules/admin/admin.dm
adminmoreinfo(subject)
/*
if(!ismob(subject))
to_chat(usr, "This can only be used on instances of type /mob.", confidential = TRUE)
return
Expand Down Expand Up @@ -860,6 +864,8 @@
exportable_text += ADMIN_FULLMONTY_NONAME(subject)

to_chat(src.owner, boxed_message(exportable_text), confidential = TRUE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would highly recommend commenting out these lines of code, instead of removing them. It makes porting efforts easier.

*/
// MONKESTATION END

else if(href_list["addjobslot"])
if(!check_rights(R_ADMIN))
Expand Down
8 changes: 5 additions & 3 deletions code/modules/admin/verbs/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,12 @@ monkestation end */
qdel(W)
M.regenerate_icons()

log_admin("[key_name(usr)] made [key_name(M)] drop everything!")
var/msg = "[key_name_admin(usr)] made [ADMIN_LOOKUPFLW(M)] drop everything!"
message_admins(msg)
// MONKESTATION EDIT START - tgui tickets
var/msg = "[key_name(usr)] made [key_name(M)] drop everything!"
log_admin(msg)
message_admins("[key_name_admin(usr)] made [ADMIN_LOOKUPFLW(M)] drop everything!")
Copy link
Collaborator

@LikeLakers2 LikeLakers2 Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you reordering lines here, and in so many other places too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes the code a bit better, log_admin and admin_ticket_log getting the same message, w/o html tags, and then message_admins gets the tags, so I needed to move the definition of msg above the log_admin

admin_ticket_log(M, msg)
// MONKESTATION EDIT END
SSblackbox.record_feedback("tally", "admin_verb", 1, "Drop Everything") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

/proc/cmd_admin_mute(whom, mute_type, automute = 0)
Expand Down
14 changes: 10 additions & 4 deletions code/modules/admin/verbs/adminevents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
M.balloon_alert(M, "you hear a voice")
to_chat(M, "<i>You hear a voice in your head... <b>[msg]</i></b>", confidential = TRUE)

log_admin("SubtlePM: [key_name(usr)] -> [key_name(M)] : [msg]")
// MONKESTATION EDIT START - tgui tickets
var/log_message = "SubtlePM: [key_name(usr)] -> [key_name(M)] : [msg]"
log_admin(log_message)
// MONKESTATION EDIT END
msg = span_adminnotice("<b> SubtleMessage: [key_name_admin(usr)] -> [key_name_admin(M)] :</b> [msg]")
message_admins(msg)
admin_ticket_log(M, msg)
admin_ticket_log(M, log_message) // MONKESTATION EDIT - tgui tickets
SSblackbox.record_feedback("tally", "admin_verb", 1, "Subtle Message") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

/client/proc/cmd_admin_headset_message(mob/M in GLOB.mob_list)
Expand Down Expand Up @@ -129,10 +132,13 @@
return

to_chat(M, msg, confidential = TRUE)
log_admin("DirectNarrate: [key_name(usr)] to ([M.name]/[M.key]): [msg]")
// MONKESTATION EDIT START - tgui tickets
var/log_msg = "DirectNarrate: [key_name(usr)] to ([M.name]/[M.key]): [msg]"
log_admin(log_msg)
// MONKESTATION EDIT END
msg = span_adminnotice("<b> DirectNarrate: [key_name(usr)] to ([M.name]/[M.key]):</b> [msg]<BR>")
message_admins(msg)
admin_ticket_log(M, msg)
admin_ticket_log(M, log_msg) // MONKESTATION EDIT - tgui tickets
SSblackbox.record_feedback("tally", "admin_verb", 1, "Direct Narrate") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

/client/proc/cmd_admin_add_freeform_ai_law()
Expand Down
8 changes: 5 additions & 3 deletions code/modules/admin/verbs/adminfun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@
divine_wrath.fire()

/client/proc/punish_log(whom, punishment)
var/msg = "[key_name_admin(src)] punished [key_name_admin(whom)] with [punishment]."
message_admins(msg)
// MONKESTATION EDIT START - tgui tickets
var/msg = "[key_name(src)] punished [key_name(whom)] with [punishment]."
message_admins("[key_name_admin(src)] punished [key_name_admin(whom)] with [punishment].")
log_admin(msg)
admin_ticket_log(whom, msg)
log_admin("[key_name(src)] punished [key_name(whom)] with [punishment].")
// MONKESTATION EDIT END
9 changes: 6 additions & 3 deletions code/modules/admin/verbs/admingame.dm
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,13 @@
ADD_TRAIT(mob, TRAIT_GODMODE, ADMIN_TRAIT)
to_chat(usr, span_adminnotice("Toggled [had_trait ? "OFF" : "ON"]"), confidential = TRUE)

log_admin("[key_name(usr)] has toggled [key_name(mob)]'s nodamage to [had_trait ? "Off" : "On"]")
// MONKESTATION EDIT START - tgui tickets
var/log_msg = "[key_name(usr)] has toggled [key_name(mob)]'s nodamage to [had_trait ? "Off" : "On"]"
log_admin()
var/msg = "[key_name_admin(usr)] has toggled [ADMIN_LOOKUPFLW(mob)]'s nodamage to [had_trait ? "Off" : "On"]"
message_admins(msg)
admin_ticket_log(mob, msg)
admin_ticket_log(mob, log_msg)
// MONKESTATION EDIT END
SSblackbox.record_feedback("nested tally", "admin_toggle", 1, list("Godmode", "[had_trait ? "Disabled" : "Enabled"]")) // If you are copy-pasting this, ensure the 4th parameter is unique to the new proc!

/*
Expand Down Expand Up @@ -215,7 +218,7 @@ Traitors and the like can also be revived with the previous role mostly intact.
to_chat(new_monkey, "You have been fully respawned. Enjoy the game.", confidential = TRUE)
var/msg = span_adminnotice("[key_name_admin(usr)] has respawned [new_monkey.key] as a filthy monkey.")
message_admins(msg)
admin_ticket_log(new_monkey, msg)
admin_ticket_log(new_monkey, "[key_name(usr)] has respawned [new_monkey.key] as a filthy monkey.") // MONKESTATION EDIT - tgui tickets
return //all done. The ghost is auto-deleted


Expand Down
62 changes: 37 additions & 25 deletions code/modules/admin/verbs/adminhelp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
/// If any admins were online when the ticket was initialized
var/heard_by_no_admins = FALSE
/// The collection of interactions with this ticket. Use AddInteraction() or, preferably, admin_ticket_log()
var/list/ticket_interactions
// var/list/ticket_interactions // MONKESTATION - variable removed in favor of datum _interactions
/// Statclick holder for the ticket
var/obj/effect/statclick/ahelp/statclick
/// Static counter used for generating each ticket ID
Expand All @@ -205,7 +205,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
/// Whether this ahelp has sent a webhook or not, and what type
var/webhook_sent = WEBHOOK_NONE
/// List of player interactions
var/list/player_interactions
// var/list/player_interactions // MONKESTATION - variable removed in favor of datum _interactions
/// List of admin ckeys that are involved, like through responding
var/list/admins_involved = list()
/// Has the player replied to this ticket yet?
Expand Down Expand Up @@ -242,11 +242,12 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
TimeoutVerb()

statclick = new(null, src)
ticket_interactions = list()
player_interactions = list()
// MONKESTATION START
// ticket_interactions = list()
// player_interactions = list()
// MONKESTATION END

if(is_bwoink)
AddInteraction("<font color='blue'>[key_name_admin(usr)] PM'd [LinkedReplyName()]</font>", player_message = "<font color='blue'>[key_name_admin(usr, include_name = FALSE)] PM'd [LinkedReplyName()]</font>")
message_admins("<font color='blue'>Ticket [TicketHref("#[id]")] created</font>")
SSplexora.aticket_new(src, msg_raw, is_bwoink, urgent, usr.ckey) // monkestation edit: PLEXORA
else
Expand Down Expand Up @@ -359,16 +360,21 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
GLOB.ahelp_tickets.resolved_tickets -= src
return ..()

/datum/admin_help/proc/AddInteraction(formatted_message, player_message)
// MONKESTATION START
/datum/admin_help/proc/AddInteraction(message, player_message, for_admins = FALSE, ckey = null)
_interactions += new /datum/ticket_log(src, ckey, message, player_message, for_admins)
// MONKESTATION END
if (!isnull(usr) && usr.ckey != initiator_ckey)
admins_involved |= usr.ckey
if(heard_by_no_admins)
heard_by_no_admins = FALSE
send2adminchat(initiator_ckey, "Ticket #[id]: Answered by [key_name(usr)]")

ticket_interactions += "[time_stamp()]: [formatted_message]"
if (!isnull(player_message))
player_interactions += "[time_stamp()]: [player_message]"
// MONKESTATION EDIT START - tgui tickets
// ticket_interactions += "[time_stamp()]: [formatted_message]"
// if (!isnull(player_message))
// player_interactions += "[time_stamp()]: [player_message]"
// MONKESTATION EDIT END

//Removes the ahelp verb and returns it after 2 minutes
/datum/admin_help/proc/TimeoutVerb()
Expand Down Expand Up @@ -421,7 +427,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
<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>")
AddInteraction(msg) // Monkestation edit: datum ticket interactions
log_admin_private("Ticket #[id]: [key_name(initiator)]: [msg]")

//send this msg to all admins
Expand Down Expand Up @@ -473,7 +479,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
if(initiator)
initiator.current_ticket = src

AddInteraction("<font color='purple'>Reopened by [key_name_admin(usr)]</font>", player_message = "Ticket reopened!")
AddInteraction("Reopened by [key_name(usr)]", "Ticket reopened!") // Monkestation edit: datum ticket interactions
var/msg = span_adminhelp("Ticket [TicketHref("#[id]")] reopened by [key_name_admin(usr)].")
message_admins(msg)
log_admin_private(msg)
Expand Down Expand Up @@ -501,7 +507,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
RemoveActive()
state = AHELP_CLOSED
GLOB.ahelp_tickets.ListInsert(src)
AddInteraction("<font color='red'>Closed by [key_name].</font>", player_message = "<font color='red'>Ticket closed!</font>")
AddInteraction("Closed by [key_name(usr)]", "Ticket closed") // Monkestation edit: datum ticket interactions
if(!silent)
SSblackbox.record_feedback("tally", "ahelp_stats", 1, "closed")
var/msg = "Ticket [TicketHref("#[id]")] closed by [key_name]."
Expand All @@ -519,7 +525,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)

addtimer(CALLBACK(initiator, TYPE_PROC_REF(/client, giveadminhelpverb)), 50)

AddInteraction("<font color='green'>Resolved by [key_name].</font>", player_message = "<font color='green'>Ticket resolved!</font>")
AddInteraction("Resolved by [key_name(usr)].", "Ticket resolved.") // Monkestation edit: datum ticket interactions
to_chat(initiator, span_adminhelp("Your ticket has been resolved by an admin. The Adminhelp verb will be returned to you shortly."), confidential = TRUE)

if(!silent)
Expand Down Expand Up @@ -547,7 +553,7 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
var/msg = "Ticket [TicketHref("#[id]")] rejected by [key_name]"
message_admins(msg)
log_admin_private(msg)
AddInteraction("Rejected by [key_name].", player_message = "Ticket rejected!")
AddInteraction("Rejected by [key_name(usr)].", "Ticket rejected.") // MONKESTATION EDIT - tgui tickets
SSblackbox.LogAhelp(id, "Rejected", "Rejected by [usr.key]", null, usr.ckey)

Close(silent = TRUE)
Expand All @@ -567,12 +573,15 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
msg = "Ticket [TicketHref("#[id]")] marked as IC by [key_name]"
message_admins(msg)
log_admin_private(msg)
AddInteraction("Marked as IC issue by [key_name]", player_message = "Marked as IC issue!")
AddInteraction("Marked as IC issue by [key_name(usr)]", "Marked as IC issue") // MONKESTATION EDIT - tgui tickets
SSblackbox.LogAhelp(id, "IC Issue", "Marked as IC issue by [usr.key]", null, usr.ckey)
Resolve(silent = TRUE)

//Show the ticket panel
/datum/admin_help/proc/TicketPanel()
// MONKESTATION EDIT START
ui_interact(usr)
/*
var/list/dat = list("<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><title>Ticket #[id]</title></head>")
var/ref_src = "[REF(src)]"
dat += "<h4>Admin Help Ticket #[id]: [LinkedReplyName(ref_src)]</h4>"
Expand Down Expand Up @@ -603,6 +612,8 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
dat += "</html>"

usr << browse(dat.Join(), "window=ahelp[id];size=750x480")
*/
// MONKESTATION EDIT END
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little tip: DM supports /* */ for block comments. It's much easier to just use that, than to prepend // onto every line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not that much easier than telling vs code to block comment, but I can see how it would make porting stuff easier, so I'll convert it to a block


/**
* Renders the current status of the ticket into a displayable string
Expand Down Expand Up @@ -673,6 +684,9 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
Resolve()

/datum/admin_help/proc/player_ticket_panel()
//MONKESTATION EDIT
TicketPanel()
/*
var/list/dat = list("<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><title>Player Ticket</title></head>")
dat += "<b>State: "
switch(state)
Expand All @@ -696,6 +710,8 @@ GLOBAL_DATUM_INIT(ahelp_tickets, /datum/admin_help_tickets, new)
var/datum/browser/player_panel = new(usr, "ahelp[id]", 0, 620, 480)
player_panel.set_content(dat.Join())
player_panel.open()
*/
// MONKESTATION EDIT END


//
Expand Down Expand Up @@ -862,31 +878,27 @@ GLOBAL_DATUM_INIT(admin_help_ui_handler, /datum/admin_help_ui_handler, new)

/// Use this proc when an admin takes action that may be related to an open ticket on what
/// what can be a client, ckey, or mob
/// player_message: If the message should be shown in the player ticket panel, fill this out
/// player_message: If the players should see a different message from admins
/// for_admins: If this message should be displayed only to admins, defaults to true,
/// is false if player_message is set, if player_message is not set and this is false, uses message
/// log_in_blackbox: Whether or not this message with the blackbox system.
/// If disabled, this message should be logged with a different proc call
/proc/admin_ticket_log(what, message, player_message, log_in_blackbox = TRUE)
/proc/admin_ticket_log(what, message, player_message, for_admins = TRUE, log_in_blackbox = TRUE) // MONKESTATION EDIT - tgui tickets
var/client/mob_client
var/mob/Mob = what
if(istype(Mob))
mob_client = Mob.client
else
mob_client = what
if(istype(mob_client) && mob_client.current_ticket)
if (isnull(player_message))
mob_client.current_ticket.AddInteraction(message)
else
mob_client.current_ticket.AddInteraction(message, player_message)
mob_client.current_ticket.AddInteraction(message, player_message, for_admins) // MONKESTATION EDIT - tgui tickets
if(log_in_blackbox)
SSblackbox.LogAhelp(mob_client.current_ticket.id, "Interaction", message, mob_client.ckey, usr.ckey)
return mob_client.current_ticket
if(istext(what)) //ckey
var/datum/admin_help/active_admin_help = GLOB.ahelp_tickets.CKey2ActiveTicket(what)
if(active_admin_help)
if (isnull(player_message))
active_admin_help.AddInteraction(message)
else
active_admin_help.AddInteraction(message, player_message)
active_admin_help.AddInteraction(message, player_message, for_admins) // MONKESTATION EDIT - tgui tickets
if(log_in_blackbox)
SSblackbox.LogAhelp(active_admin_help.id, "Interaction", message, what, usr.ckey)
return active_admin_help
Expand Down
16 changes: 11 additions & 5 deletions code/modules/admin/verbs/adminjump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
var/turf/location = get_turf(new_location)
var/msg = "[key_name_admin(usr)] teleported [ADMIN_LOOKUPFLW(src)] to [isnull(new_location) ? "nullspace" : ADMIN_VERBOSEJMP(location)]"
message_admins(msg)
admin_ticket_log(src, msg)
admin_ticket_log(src, "[key_name(usr)] teleported [src] to [isnull(new_location) ? "nullspace" : location]") // MONKESTATION EDIT - tgui tickets
return ..()


Expand All @@ -146,10 +146,13 @@

if(!M)
return
log_admin("[key_name(usr)] teleported [key_name(M)]")
// MONKESTATION EDIT START - tgui tickets
var/log_msg = "[key_name(usr)] teleported [key_name(M)]"
log_admin(log_msg)
var/msg = "[key_name_admin(usr)] teleported [ADMIN_LOOKUPFLW(M)]"
message_admins(msg)
admin_ticket_log(M, msg)
admin_ticket_log(M, log_msg)
// MONKESTATION EDIT END
if(M)
M.forceMove(get_turf(usr))
usr.forceMove(M.loc)
Expand All @@ -172,10 +175,13 @@
return
var/list/turfs = get_area_turfs(target_area)
if(length(turfs) && jumper.forceMove(pick(turfs)))
log_admin("[key_name(usr)] teleported [key_name(jumper)] to [AREACOORD(jumper)]")
// MONKESTATION EDIT START - tgui tickets
var/log_msg = "[key_name(usr)] teleported [key_name(jumper)] to [AREACOORD(jumper)]"
log_admin(log_msg)
var/msg = "[key_name_admin(usr)] teleported [ADMIN_LOOKUPFLW(jumper)] to [AREACOORD(jumper)]"
message_admins(msg)
admin_ticket_log(jumper, msg)
admin_ticket_log(jumper, log_msg)
// MONKESTATION EDIT END
else
to_chat(src, "Failed to move mob to a valid location.", confidential = TRUE)
SSblackbox.record_feedback("tally", "admin_verb", 1, "Send Mob") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
Loading
Loading