forked from DarkPack13/SecondCity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjukebox_moderation.dm
More file actions
69 lines (57 loc) · 2.71 KB
/
Copy pathjukebox_moderation.dm
File metadata and controls
69 lines (57 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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]!"))
refresh_jukebox_songs()
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]"))
refresh_jukebox_songs()
if ("Download")
user << ftp(file(path))
else
return
/// Recache the songs from config then force replace all the songs.
/proc/refresh_jukebox_songs()
var/refreshed = FALSE
for(var/obj/machinery/jukebox/jukebox in SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/jukebox))
if(!refreshed)
jukebox.music_player.load_songs_from_config(TRUE)
refreshed = TRUE
jukebox.music_player.songs = jukebox.music_player.init_songs()