Files
Bubberstation/code/modules/admin/outfit_manager.dm
SkyratBot a0a2280f68 [MIRROR] Fixes outfit manager harddel (#28845)
* Fixes outfit manager harddel (#84930)

<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
Closing outfit manager UI qdeled its static instance. Pretty bad. No
reason to delete it either, datum doesn't store anything and is used
purely for UI functionality.
Closes #84856

## Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and it's effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

🆑
admin: Outfit manager UI no longer harddels after closing and thus is
usable more than once
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->

* Fixes outfit manager harddel

---------

Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com>
2024-07-15 10:05:22 +05:30

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 GLOB.admin_state
/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)