mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-21 20:14:31 +01:00
Split jukebox into two files, commit one
This commit is contained in:
@@ -36,21 +36,36 @@ var/global/list/all_lobby_tracks = list()
|
||||
// Read the jukebox configuration file on system startup.
|
||||
/hook/startup/proc/load_jukebox_tracks()
|
||||
var/jukebox_track_file = "config/jukebox.json"
|
||||
var/jukebox_track_file_private = "config/jukebox_private.json" // Uncommitted
|
||||
|
||||
if(!fexists(jukebox_track_file))
|
||||
warning("File not found: [jukebox_track_file]")
|
||||
return 1
|
||||
|
||||
var/list/jsonData = json_decode(file2text(jukebox_track_file))
|
||||
|
||||
if(!istype(jsonData))
|
||||
warning("Failed to read tracks from [jukebox_track_file], json_decode failed.")
|
||||
return 1
|
||||
|
||||
// Optional
|
||||
if(fexists(jukebox_track_file_private))
|
||||
var/list/jsonData_private = json_decode(file2text(jukebox_track_file_private))
|
||||
if(istype(jsonData_private))
|
||||
jsonData += jsonData_private // Pack more tracks in
|
||||
else
|
||||
warning("Failed to read tracks from [jukebox_track_file_private], json_decode failed.")
|
||||
//return 1 // Not worth failing over, as this file is optional
|
||||
|
||||
for(var/entry in jsonData)
|
||||
if(!istext(entry["url"]))
|
||||
warning("[jukebox_track_file] entry [entry]: bad or missing 'url'")
|
||||
warning("Jukebox entry [entry]: bad or missing 'url'")
|
||||
continue
|
||||
if(!istext(entry["title"]))
|
||||
warning("[jukebox_track_file] entry [entry]: bad or missingg 'title'")
|
||||
warning("Jukebox entry [entry]: bad or missing 'title'")
|
||||
continue
|
||||
if(!isnum(entry["duration"]))
|
||||
warning("[jukebox_track_file] entry [entry]: bad or missing 'duration'")
|
||||
warning("Jukebox entry [entry]: bad or missing 'duration'")
|
||||
continue
|
||||
var/datum/track/T = new(entry["url"], entry["title"], entry["duration"])
|
||||
if(istext(entry["artist"]))
|
||||
|
||||
Reference in New Issue
Block a user