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>
This commit is contained in:
FalloutFalcon
2025-11-24 13:57:46 -07:00
committed by GitHub
co-authored by san7890
parent ca77b68ae7
commit cd8deef686
7 changed files with 90 additions and 14 deletions
+20 -9
View File
@@ -95,16 +95,26 @@
var/static/list/config_songs
if(isnull(config_songs))
config_songs = list()
var/list/tracks = flist("[global.config.directory]/jukebox_music/sounds/")
var/list/tracks = flist(CONFIG_JUKEBOX_SOUNDS)
for(var/track_file in tracks)
var/datum/track/new_track = new()
new_track.song_path = file("[global.config.directory]/jukebox_music/sounds/[track_file]")
new_track.song_path = file("[CONFIG_JUKEBOX_SOUNDS][track_file]")
var/list/track_data = splittext(track_file, "+")
if(length(track_data) < 3 || !IS_SOUND_FILE(new_track.song_path))
if(!length(track_data) || !IS_SOUND_FILE_SAFE(new_track.song_path))
continue
new_track.song_name = track_data[1]
new_track.song_length = text2num(track_data[2])
new_track.song_beat = text2num(track_data[3])
var/track_name = track_data[JUKEBOX_NAME]
track_name = strip_filepath_extension(track_name, SSsounds.safe_formats)
new_track.song_name = track_name
new_track.song_length = SSsounds.get_sound_length(new_track.song_path)
if(track_data.len >= 3) // Bandaid for legacy tracks to not use the length for the bpm rather then the actual beats.
var/static/logged_to_admins = FALSE
log_game("[new_track.song_path] track data seems to be using the legacy format; we will attempt to make it work.")
if(!logged_to_admins)
message_admins("The jukebox has tracks uploaded in a legacy format. Length is now fetched programmatically, with title and beats being the only required fields.")
logged_to_admins = TRUE
new_track.song_beat_deciseconds = text2num(track_data[3])
else if(track_data.len >= 2)
new_track.song_beat_deciseconds = text2num(track_data[JUKEBOX_BEATS])
config_songs[new_track.song_name] = new_track
if(!length(config_songs))
@@ -128,7 +138,7 @@
UNTYPED_LIST_ADD(songs_data, list( \
"name" = song_name, \
"length" = DisplayTimeText(one_song.song_length), \
"beat" = one_song.song_beat, \
"beat" = one_song.song_beat_deciseconds || "Unknown", \
))
data["active"] = !!active_song_sound
@@ -399,11 +409,12 @@
var/song_length = 0
/// How long is a beat of the song in decisconds
/// Used to determine time between effects when played
var/song_beat = 0
/// Do note this is NOT BPM.
var/song_beat_deciseconds = 0
// Default track supplied for testing and also because it's a banger
/datum/track/default
song_path = 'sound/music/lobby_music/title3.ogg'
song_name = "Tintin on the Moon"
song_length = 3 MINUTES + 52 SECONDS
song_beat = 1 SECONDS
song_beat_deciseconds = 1 SECONDS