mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-22 19:47:22 +01:00
Headphones, fix unreachable dropoff threshold, etc.
This commit is contained in:
@@ -115,7 +115,7 @@
|
||||
/// The kind of sustain we're using
|
||||
var/sustain_mode = SUSTAIN_LINEAR
|
||||
/// When a note is considered dead if it is below this in volume
|
||||
var/sustain_dropoff_volume = 0
|
||||
var/sustain_dropoff_volume = INSTRUMENT_MIN_SUSTAIN_DROPOFF
|
||||
/// Total duration of linear sustain for 100 volume note to get to SUSTAIN_DROPOFF
|
||||
var/sustain_linear_duration = 5
|
||||
/// Exponential sustain dropoff rate per decisecond
|
||||
@@ -168,7 +168,9 @@
|
||||
var/turf/source = get_turf(parent)
|
||||
for(var/mob/M in GLOB.player_list)
|
||||
var/dist = get_dist(M, source)
|
||||
if(dist > instrument_range)
|
||||
if(dist > instrument_range) // Distance check
|
||||
continue
|
||||
if(!isInSight(M, source)) // Visibility check (direct line of sight)
|
||||
continue
|
||||
hearing_mobs[M] = dist
|
||||
var/list/exited = old - hearing_mobs
|
||||
@@ -251,7 +253,7 @@
|
||||
* Processes our song.
|
||||
*/
|
||||
/datum/song/proc/process_song(wait)
|
||||
if(!length(compiled_chords) || should_stop_playing(user_playing))
|
||||
if(!length(compiled_chords) || current_chord > length(compiled_chords) || should_stop_playing(user_playing))
|
||||
stop_playing()
|
||||
return
|
||||
var/list/chord = compiled_chords[current_chord]
|
||||
@@ -349,26 +351,29 @@
|
||||
/**
|
||||
* Setter for setting how low the volume has to get before a note is considered "dead" and dropped
|
||||
*/
|
||||
/datum/song/proc/set_dropoff_volume(volume)
|
||||
/datum/song/proc/set_dropoff_volume(volume, no_refresh = FALSE)
|
||||
sustain_dropoff_volume = clamp(volume, INSTRUMENT_MIN_SUSTAIN_DROPOFF, 100)
|
||||
update_sustain()
|
||||
SStgui.update_uis(parent)
|
||||
if(!no_refresh)
|
||||
SStgui.update_uis(parent)
|
||||
|
||||
/**
|
||||
* Setter for setting exponential falloff factor.
|
||||
*/
|
||||
/datum/song/proc/set_exponential_drop_rate(drop)
|
||||
/datum/song/proc/set_exponential_drop_rate(drop, no_refresh = FALSE)
|
||||
sustain_exponential_dropoff = clamp(drop, INSTRUMENT_EXP_FALLOFF_MIN, INSTRUMENT_EXP_FALLOFF_MAX)
|
||||
update_sustain()
|
||||
SStgui.update_uis(parent)
|
||||
if(!no_refresh)
|
||||
SStgui.update_uis(parent)
|
||||
|
||||
/**
|
||||
* Setter for setting linear falloff duration.
|
||||
*/
|
||||
/datum/song/proc/set_linear_falloff_duration(duration)
|
||||
/datum/song/proc/set_linear_falloff_duration(duration, no_refresh = FALSE)
|
||||
sustain_linear_duration = clamp(duration, 0.1, INSTRUMENT_MAX_TOTAL_SUSTAIN)
|
||||
update_sustain()
|
||||
SStgui.update_uis(parent)
|
||||
if(!no_refresh)
|
||||
SStgui.update_uis(parent)
|
||||
|
||||
/datum/song/vv_edit_var(var_name, var_value)
|
||||
. = ..()
|
||||
|
||||
@@ -52,12 +52,12 @@
|
||||
ui.set_autoupdate(FALSE) // NO!!! Don't auto-update this!!
|
||||
|
||||
/datum/song/tgui_act(action, params)
|
||||
. = TRUE
|
||||
switch(action)
|
||||
if("newsong")
|
||||
lines = new()
|
||||
tempo = sanitize_tempo(5) // default 120 BPM
|
||||
name = ""
|
||||
return TRUE
|
||||
if("import")
|
||||
var/t = ""
|
||||
do
|
||||
@@ -71,20 +71,17 @@
|
||||
break
|
||||
while(length_char(t) > MUSIC_MAXLINES * MUSIC_MAXLINECHARS)
|
||||
parse_song(t)
|
||||
return FALSE
|
||||
if("help")
|
||||
help = !help
|
||||
return TRUE
|
||||
if("edit")
|
||||
editing = !editing
|
||||
return TRUE
|
||||
if("repeat") //Changing this from a toggle to a number of repeats to avoid infinite loops.
|
||||
if(playing)
|
||||
return //So that people cant keep adding to repeat. If the do it intentionally, it could result in the server crashing.
|
||||
repeat = clamp(round(text2num(params["new"])), 0, max_repeats)
|
||||
return TRUE
|
||||
if("tempo")
|
||||
tempo = sanitize_tempo(text2num(params["new"]))
|
||||
return TRUE
|
||||
if("play")
|
||||
INVOKE_ASYNC(src, .proc/start_playing, usr)
|
||||
if("newline")
|
||||
@@ -96,13 +93,11 @@
|
||||
if(length(newline) > MUSIC_MAXLINECHARS)
|
||||
newline = copytext(newline, 1, MUSIC_MAXLINECHARS)
|
||||
lines.Add(newline)
|
||||
return TRUE
|
||||
if("deleteline")
|
||||
var/num = round(text2num(params["line"]))
|
||||
if(num > length(lines) || num < 1)
|
||||
return
|
||||
lines.Cut(num, num + 1)
|
||||
return TRUE
|
||||
if("modifyline")
|
||||
var/num = round(text2num(params["line"]))
|
||||
var/content = stripped_input(usr, "Enter your line: ", parent.name, lines[num], MUSIC_MAXLINECHARS)
|
||||
@@ -111,20 +106,16 @@
|
||||
if(num > length(lines) || num < 1)
|
||||
return
|
||||
lines[num] = content
|
||||
return TRUE
|
||||
if("stop")
|
||||
stop_playing()
|
||||
if("setlinearfalloff")
|
||||
set_linear_falloff_duration(round(text2num(params["new"]) * 10, world.tick_lag))
|
||||
return TRUE
|
||||
set_linear_falloff_duration(round(text2num(params["new"]) * 10, world.tick_lag), TRUE)
|
||||
if("setexpfalloff")
|
||||
set_exponential_drop_rate(round(text2num(params["new"]), 0.00001))
|
||||
return TRUE
|
||||
set_exponential_drop_rate(round(text2num(params["new"]), 0.00001), TRUE)
|
||||
if("setvolume")
|
||||
set_volume(round(text2num(params["new"]), 1))
|
||||
if("setdropoffvolume")
|
||||
set_dropoff_volume(round(text2num(params["new"]), 0.01))
|
||||
return TRUE
|
||||
set_dropoff_volume(round(text2num(params["new"]), 0.01), TRUE)
|
||||
if("switchinstrument")
|
||||
if(!length(allowed_instrument_ids))
|
||||
return
|
||||
@@ -136,20 +127,25 @@
|
||||
var/datum/instrument/I = SSinstruments.get_instrument(i)
|
||||
if(I && I.name == choice)
|
||||
set_instrument(I)
|
||||
return TRUE
|
||||
if("setnoteshift")
|
||||
note_shift = clamp(round(text2num(params["new"])), note_shift_min, note_shift_max)
|
||||
return TRUE
|
||||
if("setsustainmode")
|
||||
var/static/list/sustain_modes
|
||||
if(!length(sustain_modes))
|
||||
sustain_modes = list("Linear" = SUSTAIN_LINEAR, "Exponential" = SUSTAIN_EXPONENTIAL)
|
||||
var/choice = params["new"]
|
||||
sustain_mode = sustain_modes[choice] || sustain_mode
|
||||
return TRUE
|
||||
if("togglesustainhold")
|
||||
full_sustain_held_note = !full_sustain_held_note
|
||||
return TRUE
|
||||
if("reset")
|
||||
var/default_instrument = allowed_instrument_ids[1]
|
||||
if(using_instrument != SSinstruments.instrument_data[default_instrument])
|
||||
set_instrument(default_instrument)
|
||||
note_shift = initial(note_shift)
|
||||
sustain_mode = initial(sustain_mode)
|
||||
set_linear_falloff_duration(initial(sustain_linear_duration), TRUE)
|
||||
set_exponential_drop_rate(initial(sustain_exponential_dropoff), TRUE)
|
||||
set_dropoff_volume(initial(sustain_dropoff_volume), TRUE)
|
||||
else
|
||||
return FALSE
|
||||
parent.add_fingerprint(usr)
|
||||
@@ -160,6 +156,7 @@
|
||||
/datum/song/proc/parse_song(text)
|
||||
set waitfor = FALSE
|
||||
//split into lines
|
||||
stop_playing()
|
||||
lines = splittext(text, "\n")
|
||||
if(length(lines))
|
||||
var/bpm_string = "BPM: "
|
||||
|
||||
Reference in New Issue
Block a user