Skip to content

Commit ed32d84

Browse files
committed
fix: new april season stuff
1 parent 3fb9177 commit ed32d84

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

src/base/game/persistBGM.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import eventManager from '../../utils/eventManager.js';
22
import * as settings from '../../utils/settings/index.js';
33
import { global } from '../../utils/global.js';
4+
import { isApril, IMAGES } from '../../utils/isApril.js';
45

56
const setting = settings.register({
67
name: 'Persist Arena (Background and Music)',
@@ -14,7 +15,8 @@ eventManager.on('GameStart', () => {
1415
eventManager.on('connect', (data) => {
1516
const val = sessionStorage.getItem(`underscript.bgm.${data.gameId}`);
1617
if (setting.value() && val) {
17-
$('body').css('background-image', `url('images/backgrounds/${val}.png')`);
18+
const path = isApril() ? IMAGES : 'images';
19+
$('body').css('background-image', `url('${path}/backgrounds/${val}.png')`);
1820
// Check special skins
1921
if (data.gameType !== 'BOSS' && global('profileSkinsEnabled')) {
2022
global('checkSpecialProfileSkin')(JSON.parse(data.yourProfileSkin));

src/base/game/sound.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import eventManager from '../../utils/eventManager.js';
22
import * as settings from '../../utils/settings/index.js';
33
import { global, globalSet } from '../../utils/global.js';
4-
import { getSeasonMonth } from '../../utils/season.js';
4+
import { isApril, AUDIO } from '../../utils/isApril.js';
55

66
const baseVolumeSettings = { type: 'slider', page: 'Audio', max: 0.5, step: 0.01, default: 0.2, reset: true };
77
let active = false;
@@ -85,14 +85,14 @@ function pauseMusic() {
8585
.forEach((audio) => audio.pause());
8686
}
8787

88-
function isApril() {
89-
return getSeasonMonth() === 4;
90-
}
91-
9288
function enableAprilFools() {
9389
return isApril() && aprilFoolsMusic.value;
9490
}
9591

92+
function musicPath() {
93+
return enableAprilFools() ? AUDIO : 'musics';
94+
}
95+
9696
function overrideResult(name) {
9797
const data = { name, origin: name };
9898
const event = eventManager.cancelable.emit('playMusic', data);
@@ -102,8 +102,7 @@ function overrideResult(name) {
102102
this.super(data.name);
103103
return;
104104
}
105-
const path = enableAprilFools() ? 'afm' : 'musics';
106-
createAudio(`/${path}/${data.name}.ogg`, {
105+
createAudio(`/${musicPath()}/${data.name}.ogg`, {
107106
volume: resultVolume.value(),
108107
repeat: true,
109108
set: 'music',
@@ -118,8 +117,7 @@ function overrideMusic(name) {
118117
this.super(data.name);
119118
return;
120119
}
121-
const path = enableAprilFools() ? 'afm' : 'musics';
122-
createAudio(`/${path}/themes/${data.name}.ogg`, {
120+
createAudio(`/${musicPath()}/themes/${data.name}.ogg`, {
123121
volume: bgmVolume.value(),
124122
repeat: true,
125123
set: 'music',
@@ -147,8 +145,7 @@ function overrideJingle(name = '') {
147145
this.super(data.name);
148146
return;
149147
}
150-
const path = enableAprilFools() ? 'afm' : 'musics';
151-
createAudio(`/${path}/cards/${data.name.replace(/ /g, '_')}.ogg`, {
148+
createAudio(`/${musicPath()}/cards/${data.name.replace(/ /g, '_')}.ogg`, {
152149
volume: jingleVolume.value(),
153150
set: 'jingle',
154151
listener: global('jingleEnd'),

src/utils/isApril.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { getSeasonMonth } from './season.js';
2+
3+
export const AUDIO = 'aprilmusics';
4+
5+
export const IMAGES = 'aprilimages';
6+
7+
export function isApril() {
8+
return getSeasonMonth() === 4;
9+
}

0 commit comments

Comments
 (0)