mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 17:52:36 +00:00
## About The Pull Request this gets rid of the `get_messengers_sorted_by_name` and `get_messengers_sorted_by_job` procs, instead replacing them with two new global lists: `GLOB.pda_messengers_by_name` and `GLOB.pda_messengers_by_job` those two lists are updated in the `add_messenger` proc, which uses the binary insert macros to insert it into the properly sorted place. why? bc sorts suck for performance and all inserts/removals to this list go thru a single proc anyways, so we can just ensure it's sorted like this once, instead of re-sorting each time. thanks to @LemonInTheDark for helping me with this <details> <summary><h3>Testing Proof</h3></summary> <img width="1708" height="1349" alt="2025-08-16 (1755391989) ~ dreamseeker" src="https://github.com/user-attachments/assets/1e2dc99a-1863-4a35-8032-8ae64706fdaa" /> <img width="1708" height="1349" alt="2025-08-16 (1755392002) ~ dreamseeker" src="https://github.com/user-attachments/assets/4d9b3bd0-7f3a-410b-a073-1bf2bd69690b" /> </details> ## Why It's Good For The Game because doing a sort repeatedly whenever someone has their PDA messenger open is stupid and sucks ## Changelog no player-facing changes
93 lines
2.7 KiB
Plaintext
93 lines
2.7 KiB
Plaintext
|
|
ADMIN_VERB(message_pda, R_ADMIN, "PDA Message", "Send a message to a user's PDA.", ADMIN_CATEGORY_EVENTS)
|
|
user.holder.message_pda()
|
|
|
|
///Opens up the PDA Message Panel
|
|
/datum/admins/proc/message_pda()
|
|
if(!check_rights(R_ADMIN))
|
|
return
|
|
|
|
if(!length(GLOB.pda_messengers))
|
|
to_chat(usr, span_warning("ERROR: There are no users you can send a message to"))
|
|
return
|
|
|
|
var/datum/admin_pda_panel/ui = new(usr)
|
|
ui.ui_interact(usr)
|
|
|
|
/// Panel
|
|
/datum/admin_pda_panel
|
|
|
|
/datum/admin_pda_panel/ui_interact(mob/user, datum/tgui/ui)
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "AdminPDA")
|
|
ui.open()
|
|
|
|
/datum/admin_pda_panel/ui_state(mob/user)
|
|
return ADMIN_STATE(R_ADMIN)
|
|
|
|
/datum/admin_pda_panel/ui_static_data(mob/user)
|
|
var/list/data = list()
|
|
var/list/available_messengers = list()
|
|
for(var/datum/computer_file/program/messenger/messenger as anything in GLOB.pda_messengers_by_name)
|
|
available_messengers[REF(messenger)] = list(
|
|
ref = REF(messenger),
|
|
username = get_messenger_name(messenger),
|
|
invisible = messenger.invisible,
|
|
)
|
|
data["users"] = available_messengers
|
|
return data
|
|
|
|
/datum/admin_pda_panel/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
|
if(..())
|
|
return
|
|
|
|
if(!check_rights(R_ADMIN))
|
|
return
|
|
|
|
switch(action)
|
|
if("sendMessage")
|
|
var/targets = list()
|
|
var/spam = params["spam"]
|
|
var/ref = params["ref"]
|
|
var/force = params["force"]
|
|
if(!spam && (ref in GLOB.pda_messengers))
|
|
targets += GLOB.pda_messengers[ref]
|
|
else
|
|
for(var/datum/computer_file/program/messenger/messenger as anything in GLOB.pda_messengers_by_name)
|
|
if(messenger.invisible && !params["include_invisible"])
|
|
continue
|
|
targets += messenger
|
|
|
|
if(!length(targets))
|
|
to_chat(usr, span_warning("ERROR: Target is unavailable."))
|
|
return FALSE
|
|
|
|
var/datum/signal/subspace/messaging/tablet_message/signal = new(null, list(
|
|
"fakename" = params["name"],
|
|
"fakejob" = params["job"],
|
|
"message" = params["message"],
|
|
"everyone" = spam,
|
|
"ref" = null,
|
|
"targets" = targets,
|
|
"rigged" = FALSE,
|
|
"automated" = FALSE,
|
|
))
|
|
|
|
if(force)
|
|
signal.broadcast()
|
|
else
|
|
signal.levels = SSmapping.levels_by_trait(ZTRAIT_STATION)
|
|
signal.send_to_receivers()
|
|
|
|
if(!(force || signal.data["reject"]))
|
|
to_chat(usr, span_warning("ERROR: PDA message was rejected by the telecomms setup."))
|
|
return FALSE
|
|
|
|
var/recipient = spam ? "everyone" : get_messenger_name(targets[1])
|
|
|
|
message_admins("[key_name_admin(usr)] sent a custom PDA message to [recipient].")
|
|
log_admin("[key_name(usr)] sent a custom PDA message to [recipient]. Message: [params["message"]].")
|
|
log_pda("[key_name(usr)] sent an admin custom PDA message to [recipient]. Message: [params["message"]]")
|
|
return TRUE
|