Skip to content

Commit

Permalink
Рингтоны для КПК (#12713)
Browse files Browse the repository at this point in the history
* Готово

* ф

* Сообщение перестаёт играться если нажать Reply в чате, открыть кпк или если кпк у тебя уже открыт.

* a

* Update music_player.dm

* Update music_player.dm

* Сменил стандартную на культовую. Добавил обычных звонков.

* готово.

* Update global_lists.dm

* Готово

* сделал

* gotovo

* Update pda.dm

* Готово

* Update PDA.dm

* ф

* Жрите

* Добавка

* Десерт

* Update code/controllers/subsystem/jobs.dm

Co-authored-by: LudwigVonChesterfield <[email protected]>

* Update code/game/objects/items/devices/PDA/PDA.dm

Co-authored-by: LudwigVonChesterfield <[email protected]>

* Update music_player.dm

* f

* Update PDA.dm

* очепятка

* a

---------

Co-authored-by: LudwigVonChesterfield <[email protected]>
  • Loading branch information
1 parent 8d73696 commit 61990e9
Show file tree
Hide file tree
Showing 76 changed files with 157 additions and 88 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,5 @@ var/global/list/bitflags = list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204

#define ALCOHOL_TOLERANCE_EPILEPSY (1<<0)
#define WATER_CHOKE_EPILEPSY (1<<1)

#define STANDARD_PDA_RINGTONE (1<<0)
3 changes: 3 additions & 0 deletions code/__DEFINES/pda.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define MAX_CUSTOM_RINGTONE_LENGTH 150

#define CUSTOM_RINGTONE_NAME "My Ringtone"
4 changes: 4 additions & 0 deletions code/__HELPERS/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@
for(var/pool in L)
LAZYADD(virus_types_by_pool[pool], e)

global.ringtones_by_names = list()
for(var/datum/ringtone/Ring as anything in subtypesof(/datum/ringtone))
global.ringtones_by_names["[initial(Ring.name)]"] = new Ring

/proc/init_joblist() // Moved here because we need to load map config to edit jobs, called from SSjobs
//List of job. I can't believe this was calculated multiple times per tick!
for(var/T in (subtypesof(/datum/job) - list(/datum/job/ai,/datum/job/cyborg)))
Expand Down
4 changes: 4 additions & 0 deletions code/controllers/subsystem/jobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,10 @@ SUBSYSTEM_DEF(job)
pda.owner_fingerprints += C.fingerprint_hash //save fingerprints in pda from ID card
MA.owner_PDA = pda //add PDA in /datum/money_account

var/chosen_ringtone = H.client?.prefs.chosen_ringtone
if(chosen_ringtone)
pda.set_ringtone(chosen_ringtone, H.client?.prefs.custom_melody)

return TRUE

/datum/controller/subsystem/job/proc/LoadJobs(jobsfile)
Expand Down
1 change: 0 additions & 1 deletion code/datums/music_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ var/global/datum/notes_storage/note_cache_storage = new
var/sound/S = global.note_cache_storage.instrument_sound_notes["[sound_path]/[current_note]"]
if(!S)
S = global.note_cache_storage.instrument_sound_notes["[sound_path]/[current_note]"] = sound("[sound_path]/[current_note].ogg")

playsound(instrument, S, VOL_EFFECTS_INSTRUMENT, volume, FALSE, null, null, falloff = 5)

var/pause_time = COUNT_PAUSE(song_tempo)
Expand Down
79 changes: 67 additions & 12 deletions code/game/objects/items/devices/PDA/PDA.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@

item_action_types = list(/datum/action/item_action/hands_free/toggle_pda_light)

var/datum/music_player/chiptune_player

/datum/action/item_action/hands_free/toggle_pda_light
name = "Toggle light"

Expand All @@ -97,6 +99,10 @@
if(default_pen)
pen = new default_pen(src)

chiptune_player = new(src, "sound/musical_instruments/pda")

set_ringtone(pick(ringtones_by_names))

/obj/item/device/pda/Destroy()
var/datum/money_account/MA = get_account(owner_account)
if(MA)
Expand All @@ -110,8 +116,14 @@
else
QDEL_NULL(id)
QDEL_NULL(pen)

QDEL_NULL(chiptune_player)

return ..()

/obj/item/device/pda/unable_to_play(mob/living/user)
return FALSE

/obj/item/device/pda/examine(mob/user)
..()
if(src in user)
Expand Down Expand Up @@ -796,6 +808,7 @@
if(mode in safe_pages)
mode = 0 //for safety
ui_interact(user) //NanoUI requires this proc
stop_ringtone()
return

/obj/item/device/pda/Topic(href, href_list)
Expand Down Expand Up @@ -944,6 +957,8 @@
toff = !toff
if("Toggle Ringer")//If viewing texts then erase them, if not then toggle silent status
message_silent = !message_silent
if(message_silent)
stop_ringtone()
if("Clear")//Clears messages
if(href_list["option"] == "All")
tnote.Cut()
Expand All @@ -961,20 +976,27 @@
mode=2

if("Ringtone")
var/t = sanitize(input(U, "Please enter new ringtone", name, input_default(ttone)) as text, 20)
if (t && Adjacent(U))
if(src.hidden_uplink && hidden_uplink.check_trigger(U, lowertext(t), lowertext(lock_code)))
to_chat(U, "The PDA softly beeps.")
ui.close()
else
ttone = t
else
ui.close()
return 0
if("Message")
stop_ringtone()
var/list/chose_ringtone = global.ringtones_by_names + CUSTOM_RINGTONE_NAME
var/Tone = input(U, "Выберите рингтон", name) as null|anything in chose_ringtone
if(Tone && Adjacent(U))
var/t
if(Tone == CUSTOM_RINGTONE_NAME)
t = sanitize(input(U, "Введите новый рингтон") as message|null, MAX_CUSTOM_RINGTONE_LENGTH, extra = FALSE, ascii_only = TRUE)
if (!t || !Adjacent(U))
return
if(src.hidden_uplink && hidden_uplink.check_trigger(U, lowertext(t), lowertext(lock_code)))
to_chat(U, "The PDA softly beeps.")
ui.close()
else

set_ringtone(Tone, t)
play_ringtone(ignore_presence = TRUE)

if("Message")
var/obj/item/device/pda/P = locate(href_list["target"])
create_message(U, P, !href_list["notap"])
stop_ringtone()
if(mode == 2)
if(href_list["target"] in conversations) // Need to make sure the message went through, if not welp.
active_conversation = href_list["target"]
Expand Down Expand Up @@ -1564,7 +1586,7 @@
nanomanager.update_user_uis(U, src) // Update the sending user's PDA UI so that they can see the new message

if (!P.message_silent)
playsound(P, 'sound/machines/twobeep.ogg', VOL_EFFECTS_MASTER)
P.play_ringtone()
P.audible_message("[bicon(P)] *[P.ttone]*", hearing_distance = 3)

//Search for holder of the PDA.
Expand Down Expand Up @@ -1947,4 +1969,37 @@
return FALSE
return TRUE

/obj/item/device/pda/proc/play_ringtone(ignore_presence = FALSE)
if(!ignore_presence)
var/mob/user = usr
if(nanomanager.get_open_ui(user, src, "main"))
return

if(chiptune_player.playing)
return

chiptune_player.playing = TRUE
INVOKE_ASYNC(chiptune_player, TYPE_PROC_REF(/datum/music_player, playsong), null)

/obj/item/device/pda/proc/stop_ringtone()
chiptune_player.playing = FALSE

/obj/item/device/pda/proc/set_ringtone(ringtone, melody = null)
if(!ringtone)
return
stop_ringtone()

if(ringtone == CUSTOM_RINGTONE_NAME)
if(!melody)
return

chiptune_player.repeat = 1
chiptune_player.parse_song_text(melody)
else
var/datum/ringtone/Ring = global.ringtones_by_names[ringtone]
if(!Ring)
return
chiptune_player.repeat = Ring.replays
chiptune_player.parse_song_text(Ring.melody)

#undef TRANSCATION_COOLDOWN
46 changes: 46 additions & 0 deletions code/game/objects/items/devices/PDA/Ringtones.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
var/global/list/datum/ringtone/ringtones_by_names

/datum/ringtone
var/name = "Ringtone"
var/melody = "E7,E7,E7" //Не забудьте заменить отступы на новую строку на \n при вставке своих мелодий!
var/replays = 1

/datum/ringtone/thinktronic
name = "Thinktronic"
melody = "BPM: 188\nE6/2,D6/1.8,F#5,G#5,C#6/2,B5/1.8,D5,E5\nB5/2,A5/1.8,C#5/0.9,E5/0.8,A5/0.7,,,,,,"
replays = 1

/datum/ringtone/thinktronic2
name = "Thinktronic 2"
melody = "BPM: 167\nC6,G5/2,G/2,A5,G, ,B5,C6,"
replays = 0

/datum/ringtone/flipflap
name = "Flip-Flap"
melody = "BPM: 188\nC5,Eb5,F5,G5/2,C6,C/1.8,G,F,E,C5,E,F,G/2,Ab5\nA/1.8,G,F,E"
replays = 0

/datum/ringtone/ring1
name = "Ring 1"
melody = "BPM: 251\nB5/3,G5/3,B/3,G/3,B/3,G/3,B/3,G/3,B/3,G/3"
replays = 1

/datum/ringtone/ring2
name = "Ring 2"
melody = "BPM: 251\nA5/3,G5/3,A/3,G/3,A/3,G/3,A/3,G/3,A/3,G/3"
replays = 1

/datum/ringtone/ring3
name = "Ring 3"
melody = "BPM: 251\nD5/3,C5/3,D/3,C/3,D/3,C/3,D/3,C/3,D/3,C/3"
replays = 1

/datum/ringtone/ring4
name = "Ring 4"
melody = "BPM: 251\nE5/3,G5/3,E/3,G/3,E/3,G/3,E/3,G/3,E/3,G/3"
replays = 1

/datum/ringtone/ring5
name = "Ring 5"
melody = "BPM: 251\nF5/3,B#5/3,F/3,B/3,F/3,B/3,F/3,B/3,F/3,B/3"
replays = 1
2 changes: 1 addition & 1 deletion code/game/sound.dm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ voluminosity = if FALSE, removes the difference between left and right ear.

S.volume -= max(distance - world.view, 0) * 2 //multiplicative falloff to add on top of natural audio falloff.

if (S.volume <= 0) // no volume means no sound, early check to save on atmos calls
if (S.volume <= 0) // no volume means no sound, early check to save on atmos calls
return

//sound volume falloff with pressure
Expand Down
18 changes: 17 additions & 1 deletion code/modules/client/character_menu/general.dm
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@
. += "Undershirt: <a href='?_src_=prefs;preference=undershirt;task=input'>[undershirt_t[undershirt]]</a><br>"
. += "Socks: <a href='?_src_=prefs;preference=socks;task=input'>[socks_t[socks]]</a><br>"
. += "Backpack Type: <a href ='?_src_=prefs;preference=bag;task=input'>[backbaglist[backbag]]</a><br>"
. += "Using skirt uniform: <a href ='?_src_=prefs;preference=use_skirt;task=input'>[use_skirt ? "Yes" : "No"]</a>"
. += "Using skirt uniform: <a href ='?_src_=prefs;preference=use_skirt;task=input'>[use_skirt ? "Yes" : "No"]</a><br>"
. += "PDA Ringtone: <a href ='?_src_=prefs;preference=ringtone;task=input'>[chosen_ringtone]</a>"

. += "</td>"
. += "</tr>"
Expand Down Expand Up @@ -256,6 +257,8 @@
backbag = rand(1, backbaglist.len)
if("use_skirt")
use_skirt = pick(TRUE, FALSE)
if("ringtone")
chosen_ringtone = pick(global.ringtones_by_names)
if("all")
randomize_appearance_for() //no params needed
if("input")
Expand Down Expand Up @@ -456,6 +459,19 @@
if(new_backbag)
backbag = backbaglist.Find(new_backbag)

if("ringtone")
var/list/pref_ringtones = global.ringtones_by_names + CUSTOM_RINGTONE_NAME
var/Tone = input(user, "Выберите рингтон:", "Character Preference", chosen_ringtone) as null|anything in pref_ringtones
if(!Tone)
return
if(Tone == CUSTOM_RINGTONE_NAME)
var/t = sanitize(input(user, "Введите новый рингтон") as message|null, MAX_CUSTOM_RINGTONE_LENGTH, extra = FALSE, ascii_only = TRUE)
if (!t)
return
custom_melody = t

chosen_ringtone = Tone

if("use_skirt")
use_skirt = !use_skirt

Expand Down
3 changes: 3 additions & 0 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ var/global/list/preferences_datums = list()
var/gear_tab = "General"
var/list/custom_items = list()

var/chosen_ringtone = "Flip-Flap"
var/custom_melody = "E7,E7,E7"

/datum/preferences/New(client/C)
parent = C
UI_style = global.available_ui_styles[1]
Expand Down
7 changes: 7 additions & 0 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
S["socks"] >> socks
S["backbag"] >> backbag
S["use_skirt"] >> use_skirt
S["pda_ringtone"] >> chosen_ringtone
S["pda_custom_melody"] >> custom_melody

//Load prefs
S["alternate_option"] >> alternate_option
Expand Down Expand Up @@ -661,6 +663,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
undershirt = sanitize_integer(undershirt, 1, undershirt_t.len, initial(undershirt))
socks = sanitize_integer(socks, 1, socks_t.len, initial(socks))
backbag = sanitize_integer(backbag, 1, backbaglist.len, initial(backbag))
var/list/pref_ringtones = global.ringtones_by_names + CUSTOM_RINGTONE_NAME
chosen_ringtone = sanitize_inlist(chosen_ringtone, pref_ringtones, initial(chosen_ringtone))
custom_melody = sanitize(custom_melody, MAX_CUSTOM_RINGTONE_LENGTH, extra = FALSE, ascii_only = TRUE)
alternate_option = sanitize_integer(alternate_option, 0, 2, initial(alternate_option))
neuter_gender_voice = sanitize_gender_voice(neuter_gender_voice)

Expand Down Expand Up @@ -773,6 +778,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
S["socks"] << socks
S["backbag"] << backbag
S["use_skirt"] << use_skirt
S["pda_ringtone"] << chosen_ringtone
S["pda_custom_melody"] << custom_melody
//Write prefs
S["alternate_option"] << alternate_option
S["job_preferences"] << job_preferences
Expand Down
2 changes: 1 addition & 1 deletion nano/templates/pda.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ Used In File(s): \code\game\objects\items\devices\PDA\PDA.dm
<div class ="itemContent">
{{:helper.link(data.message_silent==1 ? 'Ringer: Off' : 'Ringer: On', data.message_silent==1 ? 'volume-off' : 'volume-on', {'choice' : "Toggle Ringer"}, null, 'fixedLeftWide')}}
{{:helper.link(data.toff==1 ? 'Messenger: Off' : 'Messenger: On',data.toff==1 ? 'close':'check', {'choice' : "Toggle Messenger"}, null, 'fixedLeftWide')}}
{{:helper.link('Set Ringtone', 'comment', {'choice' : "Ringtone"}, null, 'fixedLeftWide')}}
{{:helper.link('Change Ringtone', 'comment', {'choice' : "Ringtone"}, null, 'fixedLeftWide')}}
{{:helper.link('Delete all Conversations', 'trash', {'choice' : "Clear", 'option' : "All"}, null, 'fixedLeftWider')}}
</div>
</div>
Expand Down
71 changes: 0 additions & 71 deletions scripts/playsound-checker.py

This file was deleted.

Binary file added sound/musical_instruments/pda/A#5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/A#6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/A#7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Ab5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Ab6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Ab7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/An5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/An6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/An7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/B#5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/B#6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Bb5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Bb6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Bb7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Bn5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Bn6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Bn7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/C#5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/C#6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/C#7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Cb6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Cb7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Cn5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Cn6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Cn7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/D#5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/D#6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/D#7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Db5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Db6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Db7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Dn5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Dn6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Dn7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/E#5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/E#6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/E#7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Eb5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Eb6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Eb7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/En5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/En6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/En7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/F#5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/F#6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/F#7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Fb5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Fb6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Fb7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Fn5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Fn6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Fn7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/G#5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/G#6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/G#7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Gb5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Gb6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Gb7.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Gn5.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Gn6.ogg
Binary file not shown.
Binary file added sound/musical_instruments/pda/Gn7.ogg
Binary file not shown.
Loading

0 comments on commit 61990e9

Please sign in to comment.