mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-13 19:22:20 +00:00
## About The Pull Request So, some admin verbs/tools that used tguis, i.e edit/debug planes, were available to admins with +DEBUG... but the ui_state used `GLOB.admin_state`, which checks for +ADMIN - meaning that if they _only_ had +DEBUG, they would have the verb... but it would do nothing when they used it. I've refactored `GLOB.admin_state`, `GLOB.debug_state`, and `GLOB.fun_state` into a merged `/datum/ui_state/admin_state`, with a var for which specific permissions are being checked for. You now use the `ADMIN_STATE(perms)` macro to get the UI state for those specific perms, i.e `admin_state(R_ADMIN)` or `admin_state(R_DEBUG)`, and the resulting UI state will check for _those specific perms_. These are initialized and cached in `GLOB.admin_states` (which should never be directly accessed). So, I've went thru every single usage of `GLOB.admin_state`, `GLOB.fun_state`, and `GLOB.debug_state`, and made them all use `ADMIN_STATE()` with the actual permission flags needed to use said UI in the first place. ## Why It's Good For The Game Kinda dumb for specific admin permissions to be granted verbs that don't let them use it anyways. ## Changelog 🆑 admin: Certain UI-based tools (plane debugger, filter editor, etc) that were given to admins with only +VAREDIT or +DEBUG, but refused to open without +ADMIN, now actually work for admins that have the needed permission. /🆑
59 lines
2.0 KiB
Plaintext
59 lines
2.0 KiB
Plaintext
ADMIN_VERB(trophy_manager, R_ADMIN, "Trophy Manager", "View all trophies.", ADMIN_CATEGORY_MAIN)
|
|
var/static/datum/trophy_manager/ui = new
|
|
ui.ui_interact(user.mob)
|
|
|
|
/// Trophy Admin Management Panel
|
|
/datum/trophy_manager
|
|
|
|
/datum/trophy_manager/ui_state(mob/user)
|
|
return ADMIN_STATE(R_ADMIN)
|
|
|
|
/datum/trophy_manager/ui_close(mob/user)
|
|
qdel(src)
|
|
|
|
/datum/trophy_manager/ui_interact(mob/user, datum/tgui/ui)
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "TrophyAdminPanel")
|
|
ui.open()
|
|
|
|
/datum/trophy_manager/ui_data(mob/user)
|
|
var/list/data = list()
|
|
data["trophies"] = SSpersistence.trophy_ui_data()
|
|
return data
|
|
|
|
/datum/trophy_manager/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
|
if(..())
|
|
return
|
|
if (!check_rights(R_ADMIN))
|
|
return
|
|
var/mob/user = usr
|
|
var/datum/trophy_data/trophy = locate(params["ref"]) in SSpersistence.saved_trophies
|
|
if(!trophy)
|
|
return
|
|
switch(action)
|
|
if("delete")
|
|
SSpersistence.saved_trophies -= trophy
|
|
log_admin("[key_name(user)] has deleted a trophy made by [trophy.placer_key].")
|
|
message_admins(span_notice("[key_name_admin(user)] has deleted trophy made by [trophy.placer_key]."))
|
|
return TRUE
|
|
if("edit_message")
|
|
var/old_message = trophy.message
|
|
var/new_message = tgui_input_text(user, "New trophy message?", "Message Editing", trophy.message, max_length = MAX_PLAQUE_LEN)
|
|
if(!new_message)
|
|
return
|
|
trophy.message = new_message
|
|
log_admin("[key_name(user)] has edited the message of trophy made by [trophy.placer_key] from \"[old_message]\" to \"[new_message]\".")
|
|
return TRUE
|
|
if("edit_path")
|
|
var/old_path = trophy.path
|
|
var/new_path = tgui_input_text(user, "New trophy path?", "Path Editing", trophy.path)
|
|
if(!new_path)
|
|
return
|
|
if(!text2path(new_path))
|
|
to_chat(user, span_warning("Invalid path selected"))
|
|
return
|
|
trophy.path = new_path
|
|
log_admin("[key_name(user)] has edited the item path of trophy made by [trophy.placer_key] from \"[old_path]\" to \"[new_path]\".")
|
|
return TRUE
|