mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-27 17:41:50 +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. /🆑
89 lines
2.7 KiB
Plaintext
89 lines
2.7 KiB
Plaintext
/// Admin adventure manager
|
|
/datum/adventure_browser
|
|
var/datum/adventure/temp_adventure
|
|
var/feedback_message
|
|
|
|
/datum/adventure_browser/ui_interact(mob/user, datum/tgui/ui)
|
|
. = ..()
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "AdventureBrowser")
|
|
ui.open()
|
|
|
|
/datum/adventure_browser/ui_state(mob/user)
|
|
return ADMIN_STATE(R_DEBUG)
|
|
|
|
/// Handles finishing adventure
|
|
/datum/adventure_browser/proc/resolve_adventure(datum/source,result)
|
|
SIGNAL_HANDLER
|
|
feedback_message = "Adventure ended with result : [result]"
|
|
QDEL_NULL(temp_adventure)
|
|
|
|
/datum/adventure_browser/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
feedback_message = ""
|
|
switch(action)
|
|
if("play")
|
|
var/datum/adventure_db_entry/target = locate(params["ref"]) in GLOB.explorer_drone_adventure_db_entries
|
|
if(!target)
|
|
return
|
|
if(temp_adventure)
|
|
QDEL_NULL(temp_adventure)
|
|
temp_adventure = target.create_adventure()
|
|
if(!temp_adventure)
|
|
feedback_message = "Instantiating adventure failed. Check runtime logs for details."
|
|
return TRUE
|
|
RegisterSignal(temp_adventure,COMSIG_ADVENTURE_FINISHED, PROC_REF(resolve_adventure))
|
|
temp_adventure.start_adventure()
|
|
feedback_message = "Adventure started"
|
|
return TRUE
|
|
if("adventure_choice")
|
|
temp_adventure?.select_choice(params["choice"])
|
|
return TRUE
|
|
if("end_play")
|
|
if(temp_adventure)
|
|
QDEL_NULL(temp_adventure)
|
|
feedback_message = "Adventure stopped"
|
|
return TRUE
|
|
|
|
/datum/adventure_browser/ui_data(mob/user)
|
|
. = ..()
|
|
var/list/adventure_data = list()
|
|
for(var/datum/adventure_db_entry/db_entry in GLOB.explorer_drone_adventure_db_entries)
|
|
adventure_data += list(list(
|
|
"ref" = ref(db_entry),
|
|
"filename" = db_entry.filename,
|
|
"name" = db_entry.name,
|
|
"version" = db_entry.version,
|
|
"uploader" = db_entry.uploader,
|
|
"approved" = db_entry.approved,
|
|
"json_status" = db_entry.raw_json ? "Valid JSON" : "Empty"
|
|
))
|
|
.["adventures"] = adventure_data
|
|
.["feedback_message"] = feedback_message
|
|
.["play_mode"] = !!temp_adventure
|
|
.["adventure_data"] = temp_adventure?.ui_data(user)
|
|
if(temp_adventure?.delayed_action)
|
|
.["delay_time"] = temp_adventure.delayed_action[1]
|
|
.["delay_message"] = temp_adventure.delayed_action[2]
|
|
else
|
|
.["delay_time"] = 0
|
|
.["delay_message"] = ""
|
|
|
|
/datum/adventure_browser/ui_close(mob/user)
|
|
. = ..()
|
|
qdel(src)
|
|
|
|
/datum/adventure_browser/ui_assets(mob/user)
|
|
return list(get_asset_datum(/datum/asset/simple/adventure))
|
|
|
|
/datum/adventure_browser/Destroy(force)
|
|
. = ..()
|
|
QDEL_NULL(temp_adventure)
|
|
|
|
ADMIN_VERB(adventure_manager, R_DEBUG, "Adventure Manager", "View and edit adventures.", ADMIN_CATEGORY_DEBUG)
|
|
var/datum/adventure_browser/browser = new()
|
|
browser.ui_interact(user.mob)
|