Refactor GLOB.admin/debug/fun_state into cached /datum/ui_state/admin_state instances (#89417)

## 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.
/🆑
This commit is contained in:
Lucy
2025-02-17 00:54:00 +01:00
committed by GitHub
parent f3551e03c2
commit d656f0f4ec
40 changed files with 61 additions and 64 deletions
@@ -32,7 +32,7 @@
return ..()
/datum/color_matrix_editor/ui_state(mob/user)
return GLOB.admin_state
return ADMIN_STATE(R_VAREDIT)
/datum/color_matrix_editor/ui_static_data(mob/user)
var/list/data = list()
@@ -5,7 +5,7 @@
src.target = target
/datum/filter_editor/ui_state(mob/user)
return GLOB.admin_state
return ADMIN_STATE(R_VAREDIT)
/datum/filter_editor/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
@@ -20,7 +20,7 @@
return ..()
/datum/nobody_wants_to_learn_matrix_math/ui_state(mob/user)
return GLOB.admin_state
return ADMIN_STATE(R_VAREDIT)
/datum/nobody_wants_to_learn_matrix_math/ui_close(mob/user)
qdel(src)
@@ -6,7 +6,7 @@
src.target = target
/datum/particle_editor/ui_state(mob/user)
return GLOB.admin_state
return ADMIN_STATE(R_VAREDIT)
/datum/particle_editor/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)