Skip to content

Commit d2dd047

Browse files
committed
Add: KK slider support
K.K. slider returns with this commit, allowing users to select whether they want to only listen to the live, aircheck or both variations of his songs. It also revamps K.K. slider notifications to now mention the name of the song he is playing.
1 parent d6bbe00 commit d2dd047

File tree

7 files changed

+216
-15
lines changed

7 files changed

+216
-15
lines changed

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"background": {
3-
"scripts": [ "scripts/Utility.js", "scripts/tune_player.js", "scripts/TownTuneManager.js", "scripts/TimeKeeper.js", "scripts/LoopTimes.js", "scripts/WeatherManager.js", "scripts/AudioManager.js", "scripts/BadgeManager.js", "scripts/NotificationManager.js", "scripts/StateManager.js", "scripts/main.js" ]
3+
"scripts": [ "scripts/Utility.js", "scripts/tune_player.js", "scripts/TownTuneManager.js", "scripts/TimeKeeper.js", "scripts/LoopTimes.js", "scripts/WeatherManager.js", "scripts/KKSongs.js", "scripts/AudioManager.js", "scripts/BadgeManager.js", "scripts/NotificationManager.js", "scripts/StateManager.js", "scripts/main.js" ]
44
},
55
"browser_action": {
66
"default_icon": {

options.html

+11
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ <h3>Weather</h3>
8585

8686
<section>
8787
<h3>K.K. Slider</h3>
88+
<h4>K.K. Slider - Play Times</h4>
8889
<div class="radio">
8990
<input id="no-kk" name="enable-kk" type="radio"><label for="no-kk"><span><span></span></span>Do not play K.K. Slider songs</label>
9091
</div>
@@ -94,6 +95,16 @@ <h3>K.K. Slider</h3>
9495
<div class="radio">
9596
<input id="always-kk" name="enable-kk" type="radio"><label for="always-kk"><span><span></span></span>Play K.K. Slider songs at all times</label>
9697
</div>
98+
<h4>K.K. Slider - Version Choice</h4>
99+
<div class="radio">
100+
<input id="kk-version-live" name="kk-version" type="radio"><label for="kk-version-live"><span><span></span></span>Live</label>
101+
</div>
102+
<div class="radio">
103+
<input id="kk-version-aircheck" name="kk-version" type="radio"><label for="kk-version-aircheck"><span><span></span></span>Aircheck</label>
104+
</div>
105+
<div class="radio">
106+
<input id="kk-version-both" name="kk-version" type="radio"><label for="kk-version-both"><span><span></span></span>Both</label>
107+
</div>
97108
</section>
98109

99110
<section>

scripts/AudioManager.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function AudioManager(addEventListener, isTownTune) {
1515
let killFadeInterval;
1616
let townTuneManager = new TownTuneManager();
1717
let timeKeeper = new TimeKeeper();
18+
let kkVersion;
1819

1920
// isHourChange is true if it's an actual hour change,
2021
// false if we're activating music in the middle of an hour
@@ -73,17 +74,28 @@ function AudioManager(addEventListener, isTownTune) {
7374
audio.play();
7475
}
7576

76-
function playKKMusic() {
77+
function playKKMusic(_kkVersion) {
78+
kkVersion = _kkVersion;
7779
clearLoop();
7880
audio.loop = false;
7981
audio.addEventListener("ended", playKKSong);
8082
fadeOutAudio(500, playKKSong);
8183
}
8284

8385
function playKKSong() {
84-
let randomSong = Math.floor((Math.random() * 36) + 1).toString();
85-
audio.src = '../sound/kk/' + randomSong + '.ogg';
86+
let version;
87+
if (kkVersion == 'both') {
88+
if (Math.floor(Math.random() * 2) == 0) version = 'live';
89+
else version = 'aircheck';
90+
} else version = kkVersion;
91+
92+
let randomSong;
93+
if (version == 'live') randomSong = liveKKSongList[Math.floor(Math.random() * liveKKSongList.length)];
94+
else if (version == 'aircheck') randomSong = aircheckKKSongList[Math.floor(Math.random() * aircheckKKSongList.length)];
95+
audio.src = `../sound/kk/${version}/${randomSong}.ogg`;
8696
audio.play();
97+
98+
window.notify("kkMusic", [randomSong.split(' - ')[1]]);
8799
}
88100

89101
// clears the loop point timeout and the fadeout

scripts/KKSongs.js

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/*
2+
A list of all of the K.K. Songs.
3+
Used for reference so the extension can easily know the song name and game each song came from.
4+
Also used to make the songs more human-readable.
5+
*/
6+
7+
const liveKKSongList = [
8+
'AC - Aloha K.K.',
9+
'AC - Cafe K.K.',
10+
'AC - Comrade K.K.',
11+
'AC - DJ K.K.',
12+
'AC - Go K.K. Rider!',
13+
'AC - I Love You',
14+
'AC - Imperial K.K.',
15+
'AC - K.K. Aria',
16+
'AC - K.K. Ballad',
17+
'AC - K.K. Blues',
18+
'AC - K.K. Bossa',
19+
'AC - K.K. Calypso',
20+
'AC - K.K. Casbah',
21+
'AC - K.K. Chorale',
22+
'AC - K.K. Condor',
23+
'AC - K.K. Country',
24+
"AC - K.K. Cruisin'",
25+
'AC - K.K. D & B',
26+
'AC - K.K. Dirge',
27+
'AC - K.K. Etude',
28+
'AC - K.K. Faire',
29+
'AC - K.K. Folk',
30+
'AC - K.K. Fusion',
31+
'AC - K.K. Gumbo',
32+
'AC - K.K. Jazz',
33+
'AC - K.K. Lament',
34+
'AC - K.K. Love Song',
35+
'AC - K.K. Lullaby',
36+
'AC - K.K. Mambo',
37+
'AC - K.K. March',
38+
'AC - K.K. Parade',
39+
'AC - K.K. Ragtime',
40+
'AC - K.K. Reggae',
41+
'AC - K.K. Rock',
42+
'AC - K.K. Safari',
43+
'AC - K.K. Salsa',
44+
'AC - K.K. Samba',
45+
'AC - K.K. Ska',
46+
'AC - K.K. Song',
47+
'AC - K.K. Soul',
48+
'AC - K.K. Steppe',
49+
'AC - K.K. Swing',
50+
'AC - K.K. Tango',
51+
'AC - K.K. Technopop',
52+
'AC - K.K. Waltz',
53+
'AC - K.K. Western',
54+
'AC - Lucky K.K.',
55+
'AC - Mr. K.K.',
56+
'AC - Not My Bag 1',
57+
'AC - Not My Bag 2',
58+
'AC - Not My Bag 3',
59+
'AC - Only Me',
60+
"AC - Rockin' K.K.",
61+
'AC - Senor K.K.',
62+
'AC - Soulful K.K.',
63+
"AC - Surfin' K.K.",
64+
'AC - The K. Funk',
65+
'AC - Two Days Ago',
66+
'CF - Agent K.K.',
67+
'CF - Forest Life',
68+
'CF - K.K. Dixie',
69+
'CF - K.K. House',
70+
'CF - K.K. Marathon',
71+
'CF - K.K. Metal',
72+
'CF - K.K. Rally',
73+
'CF - K.K. Rockabilly',
74+
'CF - K.K. Sonata',
75+
'CF - King K.K.',
76+
'CF - Marine Song 2001',
77+
'CF - Mountain Song',
78+
'CF - My Place',
79+
'CF - Neapolitan',
80+
'CF - Off-Time Jive 1',
81+
'CF - Off-Time Jive 2',
82+
'CF - Off-Time Jive 3',
83+
'CF - Pondering',
84+
'CF - Spring Blossoms',
85+
'CF - Stale Cupcakes',
86+
'CF - Steep Hill',
87+
'CF - To the Edge',
88+
'CF - Wandering'
89+
];
90+
91+
const aircheckKKSongList = [
92+
'AC - Aloha K.K.',
93+
'AC - Cafe K.K.',
94+
'AC - Comrade K.K.',
95+
'AC - DJ K.K.',
96+
'AC - Go K.K. Rider!',
97+
'AC - I Love You',
98+
'AC - Imperial K.K.',
99+
'AC - K.K. Aria',
100+
'AC - K.K. Ballad',
101+
'AC - K.K. Blues',
102+
'AC - K.K. Bossa',
103+
'AC - K.K. Calypso',
104+
'AC - K.K. Casbah',
105+
'AC - K.K. Chorale',
106+
'AC - K.K. Condor',
107+
'AC - K.K. Country',
108+
"AC - K.K. Cruisin'",
109+
'AC - K.K. D & B',
110+
'AC - K.K. Dirge',
111+
'AC - K.K. Etude',
112+
'AC - K.K. Faire',
113+
'AC - K.K. Folk',
114+
'AC - K.K. Fusion',
115+
'AC - K.K. Gumbo',
116+
'AC - K.K. Jazz',
117+
'AC - K.K. Lament',
118+
'AC - K.K. Love Song',
119+
'AC - K.K. Lullaby',
120+
'AC - K.K. Mambo',
121+
'AC - K.K. March',
122+
'AC - K.K. Parade',
123+
'AC - K.K. Ragtime',
124+
'AC - K.K. Reggae',
125+
'AC - K.K. Rock',
126+
'AC - K.K. Safari',
127+
'AC - K.K. Salsa',
128+
'AC - K.K. Samba',
129+
'AC - K.K. Ska',
130+
'AC - K.K. Song',
131+
'AC - K.K. Soul',
132+
'AC - K.K. Steppe',
133+
'AC - K.K. Swing',
134+
'AC - K.K. Tango',
135+
'AC - K.K. Technopop',
136+
'AC - K.K. Waltz',
137+
'AC - K.K. Western',
138+
'AC - Lucky K.K.',
139+
'AC - Mr. K.K.',
140+
'AC - Only Me',
141+
"AC - Rockin' K.K.",
142+
'AC - Senor K.K.',
143+
'AC - Soulful K.K.',
144+
"AC - Surfin' K.K.",
145+
'AC - The K. Funk',
146+
'AC - Two Days Ago',
147+
'CF - Agent K.K.',
148+
'CF - Forest Life',
149+
'CF - K.K. Dixie',
150+
'CF - K.K. House',
151+
'CF - K.K. Marathon',
152+
'CF - K.K. Metal',
153+
'CF - K.K. Rally',
154+
'CF - K.K. Rockabilly',
155+
'CF - K.K. Sonata',
156+
'CF - King K.K.',
157+
'CF - Marine Song 2001',
158+
'CF - Mountain Song',
159+
'CF - My Place',
160+
'CF - Neapolitan',
161+
'CF - Pondering',
162+
'CF - Spring Blossoms',
163+
'CF - Stale Cupcakes',
164+
'CF - Steep Hill',
165+
'CF - To the Edge',
166+
'CF - Wandering'
167+
];

scripts/NotificationManager.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ function NotificationManager(addEventListener, isEnabled) {
2424
isEnabled() && doNotification(`It is now ${formatHour(hour)}m`);
2525
});
2626

27-
addEventListener("kkStart", () => {
28-
isEnabled() && doNotification('K.K. Slider has started to play!');
27+
addEventListener("kkMusic", title => {
28+
isEnabled() && doNotification('K.K. Slider is now playing ' + title);
2929
});
30-
3130
}

scripts/StateManager.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function StateManager() {
3838
}
3939

4040
notifyListeners("volume", [options.volume]);
41-
if (isKK()) notifyListeners("kkStart");
41+
if (isKK()) notifyListeners("kkStart", [options.kkVersion]);
4242
else {
4343
let musicAndWeather = getMusicAndWeather();
4444
notifyListeners("hourMusic", [timeKeeper.getHour(), musicAndWeather.weather, musicAndWeather.music, false]);
@@ -75,6 +75,7 @@ function StateManager() {
7575
enableNotifications: true,
7676
enableKK: true,
7777
alwaysKK: false,
78+
kkVersion: 'live',
7879
paused: false,
7980
enableTownTune: true,
8081
//enableAutoPause: false,
@@ -95,7 +96,6 @@ function StateManager() {
9596
weather: options.weather
9697
};
9798

98-
console.log(options.music)
9999
if (options.music === "random") {
100100
let games = [
101101
'animal-crossing',
@@ -132,7 +132,7 @@ function StateManager() {
132132
timeKeeper.registerHourlyCallback((day, hour) => {
133133
let wasKK = isKK();
134134
isKKTime = day == 6 && hour >= 20;
135-
if (isKK() && !wasKK) notifyListeners("kkStart");
135+
if (isKK() && !wasKK) notifyListeners("kkStart", [options.kkVersion]);
136136
else if (!isKK()) {
137137
let musicAndWeather = getMusicAndWeather();
138138
notifyListeners("hourMusic", [hour, musicAndWeather.weather, musicAndWeather.music, true]);
@@ -143,6 +143,7 @@ function StateManager() {
143143
// of any pertinent changes.
144144
chrome.storage.onChanged.addListener(changes => {
145145
let wasKK = isKK();
146+
let kkVersion = options.kkVersion;
146147
let oldMusicAndWeather = getMusicAndWeather();
147148
getSyncedOptions(() => {
148149
if (typeof changes.zipCode !== 'undefined') weatherManager.setZip(options.zipCode);
@@ -154,7 +155,7 @@ function StateManager() {
154155
notifyListeners("gameChange", [timeKeeper.getHour(), musicAndWeather.weather, musicAndWeather.music]);
155156
}
156157

157-
if (isKK() && !wasKK) notifyListeners("kkStart");
158+
if ((isKK() && !wasKK) || kkVersion != options.kkVersion) notifyListeners("kkStart", [options.kkVersion]);
158159
if (!isKK() && wasKK) {
159160
let musicAndWeather = getMusicAndWeather();
160161
notifyListeners("hourMusic", [timeKeeper.getHour(), musicAndWeather.weather, musicAndWeather.music, false]);
@@ -171,11 +172,11 @@ function StateManager() {
171172
});
172173
});
173174
});
175+
176+
// Make notifyListeners public to allow for easier notification sending.
177+
window.notify = notifyListeners;
174178

175-
// Gives easy access to the notifyListeners function if
176-
// we're debugging.
177179
if (DEBUG_FLAG) {
178-
window.notify = notifyListeners;
179180
window.setTime = function (hour, playTownTune) {
180181
notifyListeners("hourMusic", [hour, options.weather, options.music, playTownTune]);
181182
};

scripts/options.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ function saveOptions() {
2424
else if (document.getElementById('live').checked) weather = 'live';
2525
else if (document.getElementById('weather-random').checked) weather = 'weather-random';
2626

27+
let kkVersion;
28+
if (document.getElementById('kk-version-live').checked) kkVersion = 'live';
29+
else if (document.getElementById('kk-version-aircheck').checked) kkVersion = 'aircheck';
30+
else if (document.getElementById('kk-version-both').checked) kkVersion = 'both';
31+
2732
document.getElementById('raining').disabled = music == 'animal-crossing';
2833

2934
chrome.storage.sync.set({
@@ -33,6 +38,7 @@ function saveOptions() {
3338
enableNotifications,
3439
enableKK,
3540
alwaysKK,
41+
kkVersion,
3642
enableTownTune,
3743
zipCode,
3844
countryCode,
@@ -48,6 +54,7 @@ function restoreOptions() {
4854
enableNotifications: true,
4955
enableKK: true,
5056
alwaysKK: false,
57+
kkVersion: 'live',
5158
enableTownTune: true,
5259
zipCode: "98052",
5360
countryCode: "us",
@@ -60,6 +67,7 @@ function restoreOptions() {
6067
document.getElementById('no-kk').checked = true;
6168
document.getElementById('enable-kk').checked = items.enableKK;
6269
document.getElementById('always-kk').checked = items.alwaysKK;
70+
document.getElementById('kk-version-' + items.kkVersion).checked = true;
6371
document.getElementById('enable-town-tune').checked = items.enableTownTune;
6472
document.getElementById('zip-code').value = items.zipCode;
6573
document.getElementById('country-code').value = items.countryCode;
@@ -88,7 +96,10 @@ const onClickElements = [
8896
'enable-town-tune',
8997
'enable-notifications',
9098
'enable-badge',
91-
'update-location'
99+
'update-location',
100+
'kk-version-live',
101+
'kk-version-aircheck',
102+
'kk-version-both'
92103
];
93104

94105
document.getElementById('volume').oninput = saveOptions;

0 commit comments

Comments
 (0)