mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-14 19:51:59 +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. /🆑
64 lines
1.8 KiB
Plaintext
64 lines
1.8 KiB
Plaintext
ADMIN_VERB(outfit_manager, R_DEBUG|R_ADMIN, "Outfit Manager", "View and edit outfits.", ADMIN_CATEGORY_DEBUG)
|
|
var/static/datum/outfit_manager/ui = new
|
|
ui.ui_interact(user.mob)
|
|
|
|
/datum/outfit_manager
|
|
|
|
/datum/outfit_manager/ui_state(mob/user)
|
|
return ADMIN_STATE(R_DEBUG | R_ADMIN)
|
|
|
|
/datum/outfit_manager/ui_interact(mob/user, datum/tgui/ui)
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "OutfitManager")
|
|
ui.open()
|
|
|
|
/datum/outfit_manager/proc/entry(datum/outfit/outfit)
|
|
var/vv = FALSE
|
|
var/datum/outfit/varedit/varoutfit = outfit
|
|
if(istype(varoutfit))
|
|
vv = length(varoutfit.vv_values)
|
|
return list(
|
|
"name" = "[outfit.name] [vv ? "(VV)" : ""]",
|
|
"ref" = REF(outfit),
|
|
)
|
|
|
|
/datum/outfit_manager/ui_data(mob/user)
|
|
var/list/data = list()
|
|
|
|
var/list/outfits = list()
|
|
for(var/datum/outfit/custom_outfit in GLOB.custom_outfits)
|
|
outfits += list(entry(custom_outfit))
|
|
data["outfits"] = outfits
|
|
|
|
return data
|
|
|
|
/datum/outfit_manager/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
|
if(..())
|
|
return
|
|
. = TRUE
|
|
|
|
switch(action)
|
|
if("new")
|
|
ui.user.client.open_outfit_editor(new /datum/outfit)
|
|
if("load")
|
|
ui.user.client.holder.load_outfit(ui.user)
|
|
if("copy")
|
|
var/datum/outfit/outfit = tgui_input_list(ui.user, "Pick an outfit to copy from", "Outfit Manager", subtypesof(/datum/outfit))
|
|
if(isnull(outfit))
|
|
return
|
|
if(!ispath(outfit))
|
|
return
|
|
ui.user.client.open_outfit_editor(new outfit)
|
|
|
|
var/datum/outfit/target_outfit = locate(params["outfit"])
|
|
if(!istype(target_outfit))
|
|
return
|
|
switch(action) //wow we're switching through action again this is horrible optimization smh
|
|
if("edit")
|
|
ui.user.client.open_outfit_editor(target_outfit)
|
|
if("save")
|
|
ui.user.client.holder.save_outfit(ui.user, target_outfit)
|
|
if("delete")
|
|
ui.user.client.holder.delete_outfit(ui.user, target_outfit)
|