mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-02-28 09:27:07 +08:00
feat: 音效设置
This commit is contained in:
parent
cb761aede0
commit
793394335d
2
idea.md
2
idea.md
@ -108,7 +108,7 @@ dam4.png ---- 存档 59
|
||||
[] 新的事件系统,并丰富自定义事件
|
||||
[] 事件、eval 内容预编译
|
||||
[] 新的存档系统,可以注册存档项
|
||||
[] 渐变切 bgm
|
||||
[x] 渐变切 bgm
|
||||
[] 新的 Flag 系统,使用 for 申请变量,dispose 释放变量,可设为渲染进程与游戏进程共通变量
|
||||
[] 注册可录像操作,比如可以在点击的时候执行,自动计入录像
|
||||
[] 机关门显示绑定怪物
|
||||
|
@ -3374,12 +3374,6 @@ control.prototype.triggerBgm = function () {
|
||||
////// 播放音频 //////
|
||||
control.prototype.playSound = function (sound, pitch, callback) {
|
||||
sound = core.getMappedName(sound);
|
||||
if (
|
||||
main.mode != 'play' ||
|
||||
!core.musicStatus.soundStatus ||
|
||||
!core.material.sounds[sound]
|
||||
)
|
||||
return;
|
||||
Mota.require('var', 'sound').play(sound, callback);
|
||||
};
|
||||
|
||||
|
@ -11,6 +11,11 @@ type Listener = AudioParamOf<AudioListener>;
|
||||
export class SoundEffect extends AudioPlayer {
|
||||
static playIndex = 0;
|
||||
|
||||
/** 音量 */
|
||||
static volume: number = 1;
|
||||
/** 是否关闭音效 */
|
||||
static disable: boolean = false;
|
||||
|
||||
private playing: Record<string, AudioBufferSourceNode> = {};
|
||||
private _stopingAll: boolean = false;
|
||||
private playMap: Map<AudioBufferSourceNode, number> = new Map();
|
||||
@ -22,10 +27,10 @@ export class SoundEffect extends AudioPlayer {
|
||||
merger: ChannelMergerNode | null = null;
|
||||
|
||||
set volumn(value: number) {
|
||||
this.gain.gain.value = value;
|
||||
this.gain.gain.value = value * SoundEffect.volume;
|
||||
}
|
||||
get volumn(): number {
|
||||
return this.gain.gain.value;
|
||||
return this.gain.gain.value / SoundEffect.volume;
|
||||
}
|
||||
|
||||
set stereo(value: boolean) {
|
||||
@ -71,8 +76,6 @@ export class SoundEffect extends AudioPlayer {
|
||||
this.panner = null;
|
||||
this.merger = null;
|
||||
if (stereo) {
|
||||
console.log(1);
|
||||
|
||||
this.panner = ac.createPanner();
|
||||
this.panner.connect(this.gain);
|
||||
if (channel === 1) {
|
||||
@ -96,6 +99,7 @@ export class SoundEffect extends AudioPlayer {
|
||||
* @returns 音频的唯一id
|
||||
*/
|
||||
playSE() {
|
||||
if (SoundEffect.disable) return;
|
||||
const node = this.play();
|
||||
if (!node) return;
|
||||
const index = SoundEffect.playIndex++;
|
||||
|
@ -4,6 +4,7 @@ import { GameStorage } from './storage';
|
||||
import { has, triggerFullscreen } from '@/plugin/utils';
|
||||
import { createSettingComponents } from './init/settings';
|
||||
import { bgm } from '../audio/bgm';
|
||||
import { SoundEffect } from '../audio/sound';
|
||||
|
||||
export interface SettingComponentProps {
|
||||
item: MotaSettingItem;
|
||||
@ -378,6 +379,10 @@ function handleAudioSetting<T extends number | boolean>(
|
||||
core.checkBgm();
|
||||
} else if (key === 'bgmVolume') {
|
||||
bgm.volume = (n as number) / 100;
|
||||
} else if (key === 'soundEnabled') {
|
||||
SoundEffect.disable = !n;
|
||||
} else if (key === 'soundVolume') {
|
||||
SoundEffect.volume = (n as number) / 100;
|
||||
}
|
||||
}
|
||||
|
||||
@ -417,6 +422,8 @@ mainSetting
|
||||
new MotaSetting()
|
||||
.register('bgmEnabled', '开启音乐', true, COM.Boolean)
|
||||
.register('bgmVolume', '音乐音量', 80, COM.Number, [0, 100, 5])
|
||||
.register('soundEnabled', '开启音效', true, COM.Boolean)
|
||||
.register('soundVolume', '音效音量', 80, COM.Number, [0, 100, 5])
|
||||
)
|
||||
.register(
|
||||
'utils',
|
||||
@ -459,6 +466,8 @@ loading.once('coreInit', () => {
|
||||
'action.fixed': !!storage.getValue('action.fixed', true),
|
||||
'audio.bgmEnabled': !!storage.getValue('audio.bgmEnabled', true),
|
||||
'audio.bgmVolume': storage.getValue('audio.bgmVolume', 80),
|
||||
'audio.soundEnabled': !!storage.getValue('audio.soundEnabled', true),
|
||||
'audio.soundVolume': storage.getValue('audio.soundVolume', 80),
|
||||
'utils.betterLoad': !!storage.getValue('utils.betterLoad', true),
|
||||
'utils.autoScale': !!storage.getValue('utils.autoScale', true),
|
||||
'fx.paraLight': !!storage.getValue('fx.paraLight', true),
|
||||
|
Loading…
Reference in New Issue
Block a user