From 692f12d29b5ce7d21c64cc1c656fcd8a1cfcb271 Mon Sep 17 00:00:00 2001 From: nichlas0010 Date: Wed, 31 Oct 2018 23:51:33 +0100 Subject: [PATCH] Revert "Revert "Makes lobby music use youtube-dl and goonchat"" --- code/controllers/subsystem/ticker.dm | 10 ++++---- code/game/sound.dm | 6 ++++- code/modules/client/preferences.dm | 6 ++--- .../browserassets/html/browserOutput.html | 3 ++- .../browserassets/js/browserOutput.js | 15 +++++++++++- config/title_music/yogs_lobby_music.txt | 16 +++++++++++++ yogstation.dme | 3 +++ .../code/controllers/subsystem/ticker.dm | 24 +++++++++++++++++++ yogstation/code/game/sound.dm | 7 ++++++ .../code/modules/goonchat/browserOutput.dm | 8 +++++++ 10 files changed, 88 insertions(+), 10 deletions(-) create mode 100644 config/title_music/yogs_lobby_music.txt create mode 100644 yogstation/code/controllers/subsystem/ticker.dm create mode 100644 yogstation/code/game/sound.dm create mode 100644 yogstation/code/modules/goonchat/browserOutput.dm diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index 234c60f0c8a0..10b3e57e020a 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -60,7 +60,7 @@ SUBSYSTEM_DEF(ticker) /datum/controller/subsystem/ticker/Initialize(timeofday) load_mode() - var/list/byond_sound_formats = list( + /*var/list/byond_sound_formats = list( //yogs start - goonchat lobby music "mid" = TRUE, "midi" = TRUE, "mod" = TRUE, @@ -111,8 +111,10 @@ SUBSYSTEM_DEF(ticker) music = world.file2list(ROUND_START_MUSIC_LIST, "\n") login_music = pick(music) else - login_music = "[global.config.directory]/title_music/sounds/[pick(music)]" - + login_music = "[global.config.directory]/title_music/sounds/[pick(music)]"*/ + login_music = choose_lobby_music() + if(!login_music) + to_chat(world, "Could not load lobby music.") //yogs end if(!GLOB.syndicate_code_phrase) GLOB.syndicate_code_phrase = generate_code_phrase() @@ -573,7 +575,7 @@ SUBSYSTEM_DEF(ticker) round_end_sound_sent = TRUE // yogs start - Mods can reboot when last ticket is closed -/datum/controller/subsystem/ticker/proc/Reboot(reason, end_string, delay, force = FALSE) +/datum/controller/subsystem/ticker/proc/Reboot(reason, end_string, delay, force = FALSE) set waitfor = FALSE if(usr && !force) if(!check_rights(R_SERVER, TRUE)) diff --git a/code/game/sound.dm b/code/game/sound.dm index 6bd53aba7ab0..481e6fca515a 100644 --- a/code/game/sound.dm +++ b/code/game/sound.dm @@ -98,14 +98,18 @@ next_channel = 1 /mob/proc/stop_sound_channel(chan) + if(chan == CHANNEL_LOBBYMUSIC && src.client && src.client.chatOutput) //yogs start + src.client.chatOutput.stopLobbyMusic() + return //yogs end SEND_SOUND(src, sound(null, repeat = 0, wait = 0, channel = chan)) -/client/proc/playtitlemusic(vol = 85) +/*/client/proc/playtitlemusic(vol = 85) //yogs start - moved to yogstation/code/game/sound.dm set waitfor = FALSE UNTIL(SSticker.login_music) //wait for SSticker init to set the login music if(prefs && (prefs.toggles & SOUND_LOBBY)) SEND_SOUND(src, sound(SSticker.login_music, repeat = 0, wait = 0, volume = vol, channel = CHANNEL_LOBBYMUSIC)) // MAD JAMS +*/ //yogs end /proc/get_rand_frequency() return rand(32000, 55000) //Frequency stuff only works with 45kbps oggs. diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index f3e24b42830e..d1cf5664e333 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -638,7 +638,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) dat += "Donate here" dat += "" // yogs end - + // yogs start - Custom keybindings if (4) // Keybindings dat += "
[(hotkeys) ? "Hotkeys" : "Default"]" @@ -653,7 +653,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) BUTTON_KEY_MOVEMENT("Move West (left)", ACTION_MOVEWEST, WEST) BUTTON_KEY_MOVEMENT("Move South (down)", ACTION_MOVESOUTH, SOUTH) BUTTON_KEY_MOVEMENT("Move East (right)", ACTION_MOVEEAST, EAST) - + BUTTON_KEY("OOC", ACTION_OOC) BUTTON_KEY("LOOC", ACTION_LOOC) BUTTON_KEY("Adminhelp", ACTION_AHELP) @@ -689,7 +689,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) BUTTON_KEY("Disarm intent", ACTION_INTENTDISARM) BUTTON_KEY("Grab intent", ACTION_INTENTGRAB) BUTTON_KEY("Harm intent", ACTION_INTENTHARM) - + if(parent) if(parent.mentor_datum) dat += "

Mentor

" diff --git a/code/modules/goonchat/browserassets/html/browserOutput.html b/code/modules/goonchat/browserassets/html/browserOutput.html index fe3be9486c14..2ff600a4ef9d 100644 --- a/code/modules/goonchat/browserassets/html/browserOutput.html +++ b/code/modules/goonchat/browserassets/html/browserOutput.html @@ -50,6 +50,7 @@ + - \ No newline at end of file + diff --git a/code/modules/goonchat/browserassets/js/browserOutput.js b/code/modules/goonchat/browserassets/js/browserOutput.js index 15a023fc859f..060679bf9c18 100644 --- a/code/modules/goonchat/browserassets/js/browserOutput.js +++ b/code/modules/goonchat/browserassets/js/browserOutput.js @@ -507,6 +507,8 @@ function ehjaxCallback(data) { internalOutput('
The connection has been closed because the server is restarting. Please wait while you automatically reconnect.
', 'internal'); } else if (data == 'stopMusic') { $('#adminMusic').prop('src', ''); + } else if (data == 'stopLobbyMusic') { //yogs start - lobby music + $('#lobbyMusic').prop('src', ''); //yogs end } else { //Oh we're actually being sent data instead of an instruction var dataJ; @@ -555,7 +557,15 @@ function ehjaxCallback(data) { $('#adminMusic').prop('src', adminMusic); $('#adminMusic').trigger("play"); } - } + } else if (data.lobbyMusic) { //yogs start - lobby music + if (typeof data.lobbyMusic === 'string') { + var lobbyMusic = byondDecode(data.lobbyMusic); + lobbyMusic = lobbyMusic.match(/https?:\/\/\S+/) || ''; + $('#lobbyMusic').prop('defaultPlaybackRate', 1.0); + $('#lobbyMusic').prop('src', lobbyMusic); + $('#lobbyMusic').trigger("play"); + } + } //yogs end } } @@ -716,6 +726,7 @@ $(function() { if (savedConfig.smusicVolume) { var newVolume = clamp(savedConfig.smusicVolume, 0, 100); $('#adminMusic').prop('volume', newVolume / 100); + $('#lobbyMusic').prop('volume', newVolume / 100); //yogs $('#musicVolume').val(newVolume); opts.updatedVolume = newVolume; sendVolumeUpdate(); @@ -723,6 +734,7 @@ $(function() { } else{ $('#adminMusic').prop('volume', opts.defaultMusicVolume / 100); + $('#lobbyMusic').prop('volume', opts.defaultMusicVolume / 100); //yogs } if (savedConfig.smessagecombining) { @@ -1063,6 +1075,7 @@ $(function() { var newVolume = $('#musicVolume').val(); newVolume = clamp(newVolume, 0, 100); $('#adminMusic').prop('volume', newVolume / 100); + $('#lobbyMusic').prop('volume', newVolume / 100); //yogs setCookie('musicVolume', newVolume, 365); opts.updatedVolume = newVolume; if(!opts.volumeUpdating) { diff --git a/config/title_music/yogs_lobby_music.txt b/config/title_music/yogs_lobby_music.txt new file mode 100644 index 000000000000..141e2d2cf335 --- /dev/null +++ b/config/title_music/yogs_lobby_music.txt @@ -0,0 +1,16 @@ +https://www.youtube.com/watch?v=s7dTBoW5H9k +https://www.youtube.com/watch?v=CfMMlT8Lyns +https://www.youtube.com/watch?v=dLrdSC9MVb4 +https://www.youtube.com/watch?v=eFTLKWw542g +https://www.youtube.com/watch?v=uc6f_2nPSX8 +https://www.youtube.com/watch?v=OXFh-mYh2dQ +https://www.youtube.com/watch?v=pLJ85XExZtQ +https://www.youtube.com/watch?v=At8ao5iABFg +https://www.youtube.com/watch?v=YAXc87bmgLA +https://www.youtube.com/watch?v=UPHmazxB38g +https://www.youtube.com/watch?v=VGQZItOMz6k +https://www.youtube.com/watch?v=YgGzAKP_HuM +https://soundcloud.com/jeffimam/title-plasma-attack +https://www.youtube.com/watch?v=L0VjlFqp47g +https://www.youtube.com/watch?v=KKny_ia8Fvo +https://www.youtube.com/watch?v=KaOC9danxNo diff --git a/yogstation.dme b/yogstation.dme index 22f68071b08d..8a26056efb08 100644 --- a/yogstation.dme +++ b/yogstation.dme @@ -2762,6 +2762,7 @@ #include "yogstation\code\controllers\configuration\entries\yogstation_config.dm" #include "yogstation\code\controllers\subsystem\input.dm" #include "yogstation\code\controllers\subsystem\mapping.dm" +#include "yogstation\code\controllers\subsystem\ticker.dm" #include "yogstation\code\controllers\subsystem\yogs.dm" #include "yogstation\code\datums\mind.dm" #include "yogstation\code\datums\mutations.dm" @@ -2778,6 +2779,7 @@ #include "yogstation\code\datums\mood_events\generic_positive_events.dm" #include "yogstation\code\datums\ruins\free_miners.dm" #include "yogstation\code\datums\ruins\station.dm" +#include "yogstation\code\game\sound.dm" #include "yogstation\code\game\world.dm" #include "yogstation\code\game\area\Space_Station_13_areas.dm" #include "yogstation\code\game\gamemodes\objective.dm" @@ -2896,6 +2898,7 @@ #include "yogstation\code\modules\events\weightless.dm" #include "yogstation\code\modules\food_and_drinks\food\snacks_burger.dm" #include "yogstation\code\modules\food_and_drinks\food\snacks_meat.dm" +#include "yogstation\code\modules\goonchat\browserOutput.dm" #include "yogstation\code\modules\jobs\job_types\captain.dm" #include "yogstation\code\modules\jobs\job_types\cargo_service.dm" #include "yogstation\code\modules\jobs\job_types\job.dm" diff --git a/yogstation/code/controllers/subsystem/ticker.dm b/yogstation/code/controllers/subsystem/ticker.dm new file mode 100644 index 000000000000..7a897927991d --- /dev/null +++ b/yogstation/code/controllers/subsystem/ticker.dm @@ -0,0 +1,24 @@ +/datum/controller/subsystem/ticker/proc/choose_lobby_music() + var/list/songs = world.file2list("config/title_music/yogs_lobby_music.txt") + if(!songs.len) + log_world("There are no songs in config/title_music/yogs_lobby_music.txt, add some!") + return + var/selected = pick(songs) + + var/ytdl = CONFIG_GET(string/invoke_youtubedl) + if(!ytdl) + to_chat(world, "Youtube-dl was not configured.") + log_world("Could not play lobby song because youtube-dl is not configured properly, check the config.") + return + + var/list/output = world.shelleo("[ytdl] --format \"bestaudio\[ext=mp3]/best\[ext=mp4]\[height<=360]/bestaudio\[ext=m4a]/bestaudio\[ext=aac]\" -g --no-playlist -- \"[selected]\"") + var/errorlevel = output[SHELLEO_ERRORLEVEL] + var/stdout = output[SHELLEO_STDOUT] + var/stderr = output[SHELLEO_STDERR] + + if(errorlevel) + to_chat(world, "Youtube-dl failed.") + log_world("Could not play lobby song [selected]: [stderr]") + return + + return stdout diff --git a/yogstation/code/game/sound.dm b/yogstation/code/game/sound.dm new file mode 100644 index 000000000000..e5fc078af5f6 --- /dev/null +++ b/yogstation/code/game/sound.dm @@ -0,0 +1,7 @@ +/client/proc/playtitlemusic(vol = 85) + set waitfor = FALSE + UNTIL(SSticker.login_music) //wait for SSticker init to set the login music + UNTIL(chatOutput.loaded) + + if(prefs && (prefs.toggles & SOUND_LOBBY)) + chatOutput.sendLobbyMusic(SSticker.login_music) \ No newline at end of file diff --git a/yogstation/code/modules/goonchat/browserOutput.dm b/yogstation/code/modules/goonchat/browserOutput.dm new file mode 100644 index 000000000000..cd518600e821 --- /dev/null +++ b/yogstation/code/modules/goonchat/browserOutput.dm @@ -0,0 +1,8 @@ +/datum/chatOutput/proc/sendLobbyMusic(music) + if(!music) + return + var/list/music_data = list("lobbyMusic" = url_encode(url_encode(music))) + ehjax_send(data = music_data) + +/datum/chatOutput/proc/stopLobbyMusic() + ehjax_send(data = "stopLobbyMusic") \ No newline at end of file