Skip to content

Commit

Permalink
Innitial commit (#1760)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertNanotracen authored May 27, 2024
1 parent 6e72412 commit 8246d36
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
2 changes: 0 additions & 2 deletions code/__DEFINES/~monkestation/span.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@
#define span_clockgray(str) ("<span class='clockgray'>" + str + "</span>")
#define span_clockred(str) ("<span class='clockred'>" + str + "</span>")
#define span_ratvar(str) ("<span class='ratvar'>" + str + "</span>")

#define REQUEST_MENTORHELP "request_mentorhelp"
4 changes: 2 additions & 2 deletions monkestation/code/modules/mentor/client.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
if(ckey in cdatums)
mentor_datum.is_contributor = TRUE

/// Admins are Mentors, too
///Verifies if the client is considered a Mentor, AKA has a Mentor datum or is an Admin.
/client/proc/is_mentor()
if(mentor_datum || check_rights_for(src, R_ADMIN,0))
if(mentor_datum || check_rights_for(src, R_ADMIN, 0))
return TRUE

/proc/dementor(client/owner)
Expand Down
33 changes: 23 additions & 10 deletions monkestation/code/modules/mentor/mentor_manager.dm
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
///Requests from Mentorhelps
#define REQUEST_MENTORHELP "request_mentorhelp"

/// Verb for opening the requests manager panel
/client/proc/mentor_requests()
set name = "Mentor Manager"
set desc = "Open the mentor manager panel to view all requests during this round"
set category = "Mentor"

SSblackbox.record_feedback("tally", "mentor_verb", 1, "Mentor Manager") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
GLOB.mentor_requests.ui_interact(usr)

Expand All @@ -23,9 +27,15 @@ GLOBAL_DATUM_INIT(mentor_requests, /datum/request_manager/mentor, new)
/datum/request_manager/mentor/nuke_request(client/C, message)
return

/datum/request_manager/mentor/proc/mentorhelp(client/C, message)
var/msg = copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN)
request_for_client(C, REQUEST_MENTORHELP, msg)
/datum/request_manager/mentor/fax_request(client/requester, message, additional_info)
return

/datum/request_manager/mentor/music_request(client/requester, message)
return

/datum/request_manager/mentor/proc/mentorhelp(client/requester, message)
var/sanitizied_message = copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN)
request_for_client(requester, REQUEST_MENTORHELP, sanitizied_message)

/datum/request_manager/mentor/ui_interact(mob/user, datum/tgui/ui = null)
ui = SStgui.try_update_ui(user, src, ui)
Expand All @@ -35,14 +45,14 @@ GLOBAL_DATUM_INIT(mentor_requests, /datum/request_manager/mentor, new)

/datum/request_manager/mentor/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
// Only admins should be sending actions
if (!(usr.client in GLOB.mentors))
to_chat(usr, "You do not have permission to do this.", confidential = TRUE)
return
var/client/mentor_client = usr.client
if(!mentor_client || !mentor_client.is_mentor())
to_chat(mentor_client, "You are not allowed to be using this mentor-only proc. Please report it.", confidential = TRUE)

// Get the request this relates to
var/id = params["id"] != null ? num2text(params["id"]) : null
if (!id)
to_chat(usr, "Failed to find a request ID in your action, please report this", confidential = TRUE)
to_chat(mentor_client, "Failed to find a request ID in your action, please report this.", confidential = TRUE)
CRASH("Received an action without a request ID, this shouldn't happen!")
var/datum/request/request = !id ? null : requests_by_id[id]
if(isnull(request))
Expand All @@ -51,17 +61,17 @@ GLOBAL_DATUM_INIT(mentor_requests, /datum/request_manager/mentor, new)
switch(action)
if ("reply")
var/mob/M = request.owner?.mob
usr.client.cmd_mentor_pm(M)
mentor_client.cmd_mentor_pm(M)
return TRUE
if ("follow")
var/mob/M = request.owner?.mob
usr.client.mentor_follow(M)
mentor_client.mentor_follow(M)
return TRUE
return ..()

/datum/request_manager/mentor/ui_data(mob/user)
. = list(
"requests" = list()
"requests" = list(),
)
for (var/ckey in requests)
for (var/datum/request/request as anything in requests[ckey])
Expand All @@ -74,7 +84,10 @@ GLOBAL_DATUM_INIT(mentor_requests, /datum/request_manager/mentor, new)
"owner_ckey" = request.owner_ckey,
"owner_name" = request.owner_name,
"message" = request.message,
"additional_info" = request.additional_information,
"timestamp" = request.timestamp,
"timestamp_str" = gameTimestamp(wtime = request.timestamp)
)
.["requests"] += list(data)

#undef REQUEST_MENTORHELP

0 comments on commit 8246d36

Please sign in to comment.