Files
Bubberstation/code/modules/admin/trophy_manager.dm
Profakos bf582cb833 Trophy case update (#71015)
## About The Pull Request

I have been chipping away/procrastinating at this since May, but after
several years, I have finally updated how Trophy Cases work.

So, what this PR does is the following:

- Standardized everything in persistence.dm to use snake case, and added
basic autodocs
- Automatically moves trophies from data/npc_saves/TrophyItems.json to
data/trophy_items.json. Removed legacy .sav conversion by request, it
has been a long time.
- Trophy cases are opened and loaded the same way you would open a
regular ID locked display case (used curator access, relevant access
autodoc has been updated)
- Instead of cheap plastic replicas that turn to dust anyways, trophy
cases use holograms, which can be dispelled by hand
- Trophy data gets saved if an item stays in the trophy case when the
shuttle arrives to centcom, and the item has a description set. This is
in line with paintings, which has to still hang on the wall at round
end.
- You can edit the description of new trophies by using the librarian's
key to unlock History Mode
- When you click on a closed trophy case, it will open a tgui, and will
not display the case description. It will still do for open cases.
Vendatrays have been updated to do the same.
- The UI's icon uses icon2base64(getFlatIcon(showpiece, no_anim=TRUE)).
Vendatrays have been updated similarly, so items with directions and
animations are displayed properly. The base64 strings are updated in
update_static_data.
- Fixes vendatrays from displaying some characters in strange ways, such
as displaying /improper.
- Renames some one letter, or nonindicate argument and var names in
trophy case code
- Adds a trophy management admin panel, where admins can finally delete
all the curator ID cards swallowed over the years. Or, they can replace
the paths with funny new paths.
- If an entry has an incorrect, no longer existing path, it will be
marked red in the management panel
- Adds MAX_PLAQUE_LEN define, which 144 characters
- Removes start_showpieces from trophy cases, as it was completely
unused. The start_showpiece_type var is still around.
- Moves trophy_message var to trophy cases. Only a dice collector
display case used them in the Snowdin map.

What this PR does not do

- Sadly, it still only saves the base image of an item, and no layers or
altered image states. This has to come in the future.

<details>
<summary>Click here to see various states of the trophy tgUI</summary>
 

![kép](https://user-images.githubusercontent.com/2676196/199545412-e5b7e7a8-59fb-41e6-aca5-6b07ba33501c.png)
Locked history mode, existing item.


![kép](https://user-images.githubusercontent.com/2676196/199545574-9e705603-9b7a-457d-9575-2d4145ad940d.png)
Unlocked history mode, but holographic trophy is present.


![kép](https://user-images.githubusercontent.com/2676196/199545883-45c3916b-011f-462a-8296-6eb13db32158.png)
Locked history mode, no item.


![kép](https://user-images.githubusercontent.com/2676196/199545967-a33e2501-aa5f-473b-b79f-ebd950df2afc.png)
Unlocked history mode, no item.


![kép](https://user-images.githubusercontent.com/2676196/199546100-718bd639-3199-4df7-ad77-ed3dbf27b290.png)
Unlocked history mode, item placed, default text. (Note: this picture is
out of date. The typo has been fixed, and "record a message" is now
"record a description" for consistency)
 

![kép](https://user-images.githubusercontent.com/2676196/199546202-5ebbbd28-907c-4f2d-b7cd-29d2ef21c7f3.png)
Unlocked history mode, item placed, new text.

</details>

<details>
<summary>Click here to see the admin panel</summary>


![kép](https://user-images.githubusercontent.com/2676196/199553349-8684f23f-4699-42f2-a27e-15cccad29d0b.png)


</details>

## Why It's Good For The Game

Less curator ID's stuck in the Trophy Cases, and the existing ones can
be cleaned up. A more immersive Trophy Case user experience, in general.

## Changelog


🆑
refactor: refactored trophy cases, to be more user friendly
admin: created a trophy managment admin panel
/🆑
2022-11-20 23:18:30 -08:00

64 lines
2.0 KiB
Plaintext

/datum/admins/proc/trophy_manager()
set name = "Trophy Manager"
set category = "Admin"
if(!check_rights(R_ADMIN))
return
var/datum/trophy_manager/ui = new(usr)
ui.ui_interact(usr)
/// Trophy Admin Management Panel
/datum/trophy_manager
/datum/trophy_manager/ui_state(mob/user)
return GLOB.admin_state
/datum/trophy_manager/ui_close(mob/user)
qdel(src)
/datum/trophy_manager/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "TrophyAdminPanel")
ui.open()
/datum/trophy_manager/ui_data(mob/user)
var/list/data = list()
data["trophies"] = SSpersistence.trophy_ui_data()
return data
/datum/trophy_manager/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
if(..())
return
if (!check_rights(R_ADMIN))
return
var/mob/user = usr
var/datum/trophy_data/trophy = locate(params["ref"]) in SSpersistence.saved_trophies
if(!trophy)
return
switch(action)
if("delete")
SSpersistence.saved_trophies -= trophy
log_admin("[key_name(user)] has deleted a trophy made by [trophy.placer_key].")
message_admins(span_notice("[key_name_admin(user)] has deleted trophy made by [trophy.placer_key]."))
return TRUE
if("edit_message")
var/old_message = trophy.message
var/new_message = tgui_input_text(user, "New trophy message?", "Message Editing", trophy.message, max_length = MAX_PLAQUE_LEN)
if(!new_message)
return
trophy.message = new_message
log_admin("[key_name(user)] has edited the message of trophy made by [trophy.placer_key] from \"[old_message]\" to \"[new_message]\".")
return TRUE
if("edit_path")
var/old_path = trophy.path
var/new_path = tgui_input_text(user, "New trophy path?", "Path Editing", trophy.path)
if(!new_path)
return
if(!text2path(new_path))
to_chat(user, span_warning("Invalid path selected"))
return
trophy.path = new_path
log_admin("[key_name(user)] has edited the item path of trophy made by [trophy.placer_key] from \"[old_path]\" to \"[new_path]\".")
return TRUE