Skip to content

Commit

Permalink
jukebox Saved from Mid
Browse files Browse the repository at this point in the history
  • Loading branch information
linnpap committed Jan 13, 2023
1 parent d1f9685 commit 2a0a6ee
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 9 deletions.
3 changes: 3 additions & 0 deletions code/datums/audio/_audio.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*
// FLIPPER REMOVAL - see modular_flipper/code/datums/audio/
/decl/music_track
var/artist
var/title
Expand All @@ -23,3 +25,4 @@
// No VV editing anything about music tracks
/decl/music_track/VV_static()
return ..() + vars
*/
3 changes: 3 additions & 0 deletions code/datums/audio/_tracks.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*
// FLIPPER REMOVAL - see modular_flipper/code/datums/audio/
/datum/track
var/title
var/track
Expand Down Expand Up @@ -293,3 +295,4 @@
title = "Russkiy rep Diskoteka"
song = 'sound/music/russianrapdisco.ogg'
license = /decl/license/grandfathered
*/
7 changes: 4 additions & 3 deletions code/datums/audio/jukebox.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@


/*
// FLIPPER REMOVAL - see modular_flipper/code/datums/audio/
GLOBAL_LIST_INIT(music_tracks, list(
"Beyond" = /decl/music_track/ambispace,
"Clouds of Fire" = /decl/music_track/clouds_of_fire,
Expand Down Expand Up @@ -51,4 +51,5 @@ GLOBAL_LIST_INIT(jukebox_secret_tracks, list(
var/track_list = LAZYLEN(tracks) ? tracks : GLOB.jukebox_secret_tracks
for(var/track_name in track_list)
var/track_path = track_list[track_name]
. += new/datum/track(track_name, track_path)
. += new/datum/track(track_name, track_path)
*/
6 changes: 4 additions & 2 deletions code/game/machinery/jukebox.dm
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,13 @@

var/area/main_area = get_area(src)
if(freq)
var/sound/new_song = sound(current_track.GetTrack(), channel = 1, repeat = 1, volume = 25)
//var/sound/new_song = sound(current_track.GetTrack(), channel = 1, repeat = 1, volume = 25) // FLIPPER EDIT - config/jukebox_tracks/
var/sound/new_song = sound(current_track.path, channel = 1, repeat = 1, volume = 25)
new_song.frequency = freq
main_area.forced_ambience = list(new_song)
else
main_area.forced_ambience = list(current_track.GetTrack())
//main_area.forced_ambience = list(current_track.GetTrack()) // FLIPPER EDIT - config/jukebox_tracks/
main_area.forced_ambience = list(current_track.path)

for(var/mob/living/M in mobs_in_area(main_area))
if(M.mind)
Expand Down
22 changes: 21 additions & 1 deletion code/modules/clothing/ears/headphones.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
var/sound_channel
var/current_track
var/music_volume = 50
var/list/datum/track/tracks //FLIPPER ADDITION - config/jukebox_tracks/

/obj/item/clothing/head/headphones/Initialize()
. = ..()
Expand Down Expand Up @@ -60,10 +61,19 @@
/obj/item/clothing/head/headphones/proc/play_music(mob/user)
if(!user || !user.client)
return
/*
// FLIPPER EDIT - config/jukebox_tracks/
if(current_track)
var/decl/music_track/track = GET_DECL(GLOB.music_tracks[current_track])
user << sound(null, channel = sound_channel)
user << sound(track.song, repeat = 1, wait = 0, volume = music_volume, channel = sound_channel)
*/

if(current_track)
var/datum/track/track = tracks[current_track]
user << sound(null, channel = sound_channel)
user << sound(track.path, repeat = 1, wait = 0, volume = music_volume, channel = sound_channel)
// FLIPPER EDIT END

/obj/item/clothing/head/headphones/proc/stop_music(mob/user)
if(!user || !user.client)
Expand All @@ -77,11 +87,21 @@
dat += "<A href='?src=\ref[src];toggle=1;'>Switch [headphones_on ? "off" : "on"]</a>"
dat += "Volume: [music_volume] <A href='?src=\ref[src];vol=-10;'>-</a><A href='?src=\ref[src];vol=10;'>+</a>"
dat += "Tracks:"
/*
// FLIPPER EDIT - config/jukebox_tracks/
for(var/track in GLOB.music_tracks)
if(track == current_track)
dat += "<span class='linkOn'>[track]</span>"
else
dat += "<A href='?src=\ref[src];track=[track];'>[track]</a>"
*/

for(var/track in tracks)
if(track == current_track)
dat += "<span class='linkOn'>[track]</span>"
else
dat += "<A href='?src=\ref[src];track=[track];'>[track]</a>"
// FLIPPER EDIT END

var/datum/browser/popup = new(user, "headphones", name, 290, 410)
popup.set_content(jointext(dat,"<br>"))
Expand All @@ -102,4 +122,4 @@
if(headphones_on)
play_music(usr)
interact(usr)
updateUsrDialog()
updateUsrDialog()
5 changes: 4 additions & 1 deletion code/unit_tests/music_test.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*
// FLIPPER EDIT - config/jukebox_tracks/
/datum/unit_test/music_track_validate
name = "MUSIC TRACK: Validate Music Tracks"
Expand Down Expand Up @@ -50,4 +52,5 @@
else
pass("All jukeboxes had valid tracks.")
return 1
return 1
*/
7 changes: 6 additions & 1 deletion config/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
/*
!/*/

#FLIPPER EDIT - title music shit
#FLIPPER EDIT - music shit
/title_music/sounds/*
!/title_music/sounds/exclude

/jukebox_music/sounds/*
!/jukebox_music/sounds/exclude
/jukebox_music/secret_sounds/*
!/jukebox_music/secret_sounds/exclude
4 changes: 4 additions & 0 deletions config/jukebox_music/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Throw any music you want into either /sounds/ or /secret_sounds/. If it's in /sounds/, it'll be able to be listened to with headphones and an unhacked jukebox.
Anything in /secret_sounds/ can only be heard of a hacked jukebox.

IMPORTANT: Make sure filenames DO NOT have any '.' outside of a file extension, otherwise the song title will be fucked up.
File renamed without changes.
Empty file.
7 changes: 7 additions & 0 deletions modular_flipper/code/datums/audio/_tracks.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/datum/track
var/title
var/path

/datum/track/New(_title, _path)
title = _title
path = _path
51 changes: 51 additions & 0 deletions modular_flipper/code/datums/audio/jukebox.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/proc/setup_music_tracks(var/list/tracks)
. = list()
var/list/possible_tracks = flist("config/jukebox_music/sounds/")

var/list/byond_sound_formats = list(
"mid" = TRUE,
"midi" = TRUE,
"mod" = TRUE,
"it" = TRUE,
"s3m" = TRUE,
"xm" = TRUE,
"oxm" = TRUE,
"wav" = TRUE,
"ogg" = TRUE,
"raw" = TRUE,
"wma" = TRUE,
"aiff" = TRUE,
)

for(var/songs in possible_tracks)
var/list/split_name = splittext(songs,".")
if(split_name.len >= 2)
var/ext = lowertext(split_name[split_name.len]) //pick the real extension, no 'honk.ogg.exe' nonsense here
if(byond_sound_formats[ext])
. += new/datum/track(split_name[1], "config/jukebox_music/sounds/[songs]") //if a song is named some shit like "Awesome.FuckingSong.ogg", the title is only gonna be "Awesome"

/proc/setup_secret_music_tracks(var/list/tracks)
. = list()
var/list/possible_tracks = flist("config/jukebox_music/secret_sounds/")

var/list/byond_sound_formats = list(
"mid" = TRUE,
"midi" = TRUE,
"mod" = TRUE,
"it" = TRUE,
"s3m" = TRUE,
"xm" = TRUE,
"oxm" = TRUE,
"wav" = TRUE,
"ogg" = TRUE,
"raw" = TRUE,
"wma" = TRUE,
"aiff" = TRUE,
)

for(var/songs in possible_tracks)
var/list/split_name = splittext(songs,".")
if(split_name.len >= 2)
var/ext = lowertext(split_name[split_name.len]) //pick the real extension, no 'honk.ogg.exe' nonsense here
if(byond_sound_formats[ext])
. += new/datum/track(split_name[1], "config/jukebox_music/secret_sounds/[songs]") //if a song is named some shit like "Awesome.FuckingSong.ogg", the title is only gonna be "Awesome"
3 changes: 2 additions & 1 deletion polaris.dme
Original file line number Diff line number Diff line change
Expand Up @@ -3324,7 +3324,8 @@
#include "maps\submaps\surface_submaps\wilderness\wilderness.dm"
#include "maps\submaps\surface_submaps\wilderness\wilderness_areas.dm"
#include "maps\~map_system\maps.dm"
#include "modular_flipper\code\datums\audio\_audio.dm"
#include "modular_flipper\code\datums\audio\_tracks.dm"
#include "modular_flipper\code\datums\audio\jukebox.dm"
#include "modular_flipper\code\modules\combat_indicator\combat_indicator.dm"
#include "modular_flipper\code\modules\mob\mob.dm"
#include "modular_flipper\code\modules\mob\living\emote_popup.dm"
Expand Down

0 comments on commit 2a0a6ee

Please sign in to comment.