Files
FalloutFalcon cd8deef686 Admin Jukebox Moderation and Sound File code improvments (#93610)
## About The Pull Request
The primary feature of this pr is two admin verbs:
Both locked behind `R_SERVER` at present. Also both can be removed from
this pr if we arent interested in giving admins easy control over this.
Changes will not take effect untill the next round unless someone has
yet to touch/spawn a jukebox.
please ignore the "#. " in the titles, thats just how my spotify scraper
formats the titles and I am lazy.
### Jukebox Upload Music
Allows for the upload of any music to the jukebox (currently restricted
to `.ogg` file types for being the better format but I can release that
restriction). Adding Beats is optional but not required as it does not
do a ton tbh.


https://github.com/user-attachments/assets/859cdba8-c1dd-4ce4-bfce-40727a0a30b8

### Jukebox Browse Music
Allows you to delete any of them, this noticeably catches ANY sound
format stored within the list.
Also play and download


https://github.com/user-attachments/assets/cffca3dc-d7f2-4926-bda9-2bf3fef80adb


### Refactors
In order to add both of these verbs seemisly i made a bunch of
improvments,
Sound length for music is now gotten via the rust_g call instead of
being baked into the title, this means you only need two args for
jukebox titles. (This will mess up the bpm of old music tracks
unfortunately.)

Standerized the behavoir for validating the file type of a file, this is
not full proof from what im aware and there is no checks for if the file
ACCTALLY exists.
## Why It's Good For The Game
Atleast on a downstream, R_SERVER is alot more commonly handed out then
direct access to the tgs configs. And TGS kinda blows bubbles for doing
large scale file managment.
## Changelog
🆑
code: generic helpers and defines for validating file extenstion
refactor: the jukebox has had some improvements in how it validates the
sound file. hopefully none of your funny songs disappear.
admin: command_report_menu will let you set ANY sound file type for the
sound it plays.
admin: Admins can now manage jukebox songs in game
server: Jukebox songs length are now set automatically, update your
jukebox configs!
/🆑

---------

Co-authored-by: san7890 <the@san7890.com>
2025-11-24 13:57:46 -07:00

58 lines
2.3 KiB
Plaintext

ADMIN_VERB(upload_jukebox_music, R_SERVER, "Jukebox Upload Music", "Upload a valid .ogg file to be accessed via the jukebox.", ADMIN_CATEGORY_SERVER)
var/file = input(user, "Select a .ogg file to upload to the jukebox.") as sound|null
if(!file)
return
// we could theorticly support other sound types but OGG is the better format from what I am aware and I am 100% sure its length is properly fetched.
if(!IS_OGG_FILE(file))
tgui_alert(user, "Invalid file type. Please select an OGG file.", "Loading error", list("Ok"))
return
var/list/track_data = splittext(file, "+")
if(track_data.len < 2)
if(tgui_alert(user, "Your song currently does not have a beat in deciseconds added to its title, e.g: SS13+5.ogg. Continue?", "Confirmation", list("Yes", "No")) != "Yes")
return
if(track_data.len > 2)
tgui_alert(user, "Titles should only have its title and beat in deciseconds, e.g: SS13+5.ogg", "Loading error", list("Ok"))
return
var/clean_name = SANITIZE_FILENAME("[file]")
var/save_path = "[CONFIG_JUKEBOX_SOUNDS][clean_name]"
// Copy uploaded file to the server
fcopy(file, save_path)
message_admins("[key_name_admin(user)] uploaded [clean_name] to the jukebox!")
to_chat(user, span_notice("Successfully uploaded [clean_name]!"))
ADMIN_VERB(browse_jukebox_music, R_SERVER, "Jukebox Browse Music", "Browse music files for moderation.", ADMIN_CATEGORY_SERVER)
var/list/files = flist(CONFIG_JUKEBOX_SOUNDS)
// Filter out things that are not sound files, like the exclude
for(var/thing in files)
if(!IS_SOUND_FILE(thing))
files -= thing
if(!files.len)
to_chat(user, span_warning("No uploaded tracks found."))
return
var/choice = tgui_input_list(user, "Select a track:", "Select Jukebox Music", files)
if(!choice)
return
var/path = "[CONFIG_JUKEBOX_SOUNDS][choice]"
switch(tgui_alert(user, "Play, Delete, or Download?", choice, list("Play", "Delete", "Download")))
if ("Play")
SEND_SOUND(user, sound(path))
if ("Delete")
fdel(path)
var/msg = "[key_name_admin(user)] deleted [choice] from the jukebox!"
message_admins(msg)
log_admin(msg)
SSblackbox.record_feedback("associative", "jukebox_deletion", 1, list("round_id" = "[GLOB.round_id]", "deletor" = "[key_name_admin(user)]", "deleted" = "[choice]"))
if ("Download")
user << ftp(file(path))
else
return