mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 21:18:37 +01:00
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:
@@ -29,7 +29,7 @@ ADMIN_VERB(access_news_network, R_ADMIN, "Access Newscaster Network", "Allows yo
|
||||
var/comment_text
|
||||
|
||||
/datum/newspanel/ui_state(mob/user)
|
||||
return GLOB.admin_state
|
||||
return ADMIN_STATE(R_ADMIN)
|
||||
|
||||
/datum/newspanel/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
|
||||
@@ -16,7 +16,7 @@ ADMIN_VERB(borg_panel, R_ADMIN, "Show Borg Panel", ADMIN_VERB_NO_DESCRIPTION, AD
|
||||
borg = to_borg
|
||||
|
||||
/datum/borgpanel/ui_state(mob/user)
|
||||
return GLOB.admin_state
|
||||
return ADMIN_STATE(R_ADMIN)
|
||||
|
||||
/datum/borgpanel/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
var/selected_type = ""
|
||||
|
||||
/datum/colorblind_tester/ui_state(mob/user)
|
||||
return GLOB.admin_state
|
||||
return ADMIN_STATE(R_DEBUG)
|
||||
|
||||
/datum/colorblind_tester/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
|
||||
@@ -51,7 +51,7 @@ ADMIN_VERB(create_command_report, R_ADMIN, "Create Command Report", "Create a co
|
||||
preset_names.Insert(1, command_name())
|
||||
|
||||
/datum/command_report_menu/ui_state(mob/user)
|
||||
return GLOB.admin_state
|
||||
return ADMIN_STATE(R_ADMIN)
|
||||
|
||||
/datum/command_report_menu/ui_close()
|
||||
qdel(src)
|
||||
|
||||
@@ -30,7 +30,7 @@ ADMIN_VERB(ghost_pool_protection, R_ADMIN, "Ghost Pool Protection", "Choose whic
|
||||
new_role_flags = GLOB.ghost_role_flags
|
||||
|
||||
/datum/ghost_pool_menu/ui_state(mob/user)
|
||||
return GLOB.admin_state
|
||||
return ADMIN_STATE(R_ADMIN)
|
||||
|
||||
/datum/ghost_pool_menu/ui_close()
|
||||
qdel(src)
|
||||
|
||||
@@ -14,7 +14,7 @@ ADMIN_VERB(law_panel, R_ADMIN, "Law Panel", "View the AI laws.", ADMIN_CATEGORY_
|
||||
ui.open()
|
||||
|
||||
/datum/law_panel/ui_state(mob/user)
|
||||
return GLOB.admin_state
|
||||
return ADMIN_STATE(R_ADMIN)
|
||||
|
||||
/datum/law_panel/ui_close(mob/user)
|
||||
qdel(src)
|
||||
|
||||
@@ -186,7 +186,7 @@ GLOBAL_LIST_EMPTY(light_debugged_atoms)
|
||||
ui_interact(usr)
|
||||
|
||||
/atom/movable/screen/light_button/edit/ui_state(mob/user)
|
||||
return GLOB.debug_state
|
||||
return ADMIN_STATE(R_DEBUG)
|
||||
|
||||
/atom/movable/screen/light_button/edit/can_interact()
|
||||
return TRUE
|
||||
@@ -362,7 +362,7 @@ GLOBAL_LIST_EMPTY(light_debugged_atoms)
|
||||
ui_interact(usr)
|
||||
|
||||
/datum/action/spawn_light/ui_state(mob/user)
|
||||
return GLOB.debug_state
|
||||
return ADMIN_STATE(R_DEBUG)
|
||||
|
||||
/datum/action/spawn_light/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
LAZYREMOVEASSOC(SSlua.editors, text_ref(current_state), src)
|
||||
|
||||
/datum/lua_editor/ui_state(mob/user)
|
||||
return GLOB.debug_state
|
||||
return ADMIN_STATE(R_DEBUG)
|
||||
|
||||
/datum/lua_editor/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
set_target(get_target())
|
||||
|
||||
/datum/plane_master_debug/ui_state(mob/user)
|
||||
return GLOB.admin_state
|
||||
return ADMIN_STATE(R_DEBUG)
|
||||
|
||||
/datum/plane_master_debug/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
|
||||
@@ -115,7 +115,7 @@ ADMIN_VERB(player_ticket_history, R_ADMIN, "Player Ticket History", "Allows you
|
||||
to_chat(usr, span_adminnotice("Finished caching ticket history for [ckey]!"))
|
||||
|
||||
/datum/ticket_history_holder/ui_state(mob/user)
|
||||
return GLOB.admin_state
|
||||
return ADMIN_STATE(R_ADMIN)
|
||||
|
||||
/datum/ticket_history_holder/ui_static_data(mob/user)
|
||||
if(!check_rights_for(CLIENT_FROM_VAR(user), R_ADMIN))
|
||||
|
||||
@@ -22,7 +22,7 @@ ADMIN_VERB(secrets, R_NONE, "Secrets", "Abuse harder than you ever have before w
|
||||
is_funmin = check_rights(R_FUN)
|
||||
|
||||
/datum/secrets_menu/ui_state(mob/user)
|
||||
return GLOB.admin_state
|
||||
return ADMIN_STATE(R_NONE)
|
||||
|
||||
/datum/secrets_menu/ui_close()
|
||||
qdel(src)
|
||||
|
||||
@@ -45,7 +45,7 @@ ADMIN_VERB_ONLY_CONTEXT_MENU(select_equipment, R_FUN, "Select Equipment", mob/ta
|
||||
ui.set_autoupdate(FALSE)
|
||||
|
||||
/datum/select_equipment/ui_state(mob/user)
|
||||
return GLOB.admin_state
|
||||
return ADMIN_STATE(R_FUN)
|
||||
|
||||
/datum/select_equipment/ui_status(mob/user, datum/ui_state/state)
|
||||
if(QDELETED(target_mob))
|
||||
|
||||
Reference in New Issue
Block a user