Skip to content

Commit

Permalink
1.0.2 初期値の設定が効かない不具合を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
elleonard committed Jun 13, 2023
1 parent 7796900 commit 0d4690d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
/// <reference path="./MasterVolume.d.ts" />

import { settings } from './_build/DarkPlasma_MasterVolume_parameters';

/**
* @param {typeof ConfigManager} configManager
*/
function ConfigManager_MasterVolumeMixIn(configManager) {
function WebAudio_MasterVolumeMixIn(webAudio: typeof WebAudio) {
const _initialize = webAudio.initialize;
webAudio.initialize = function () {
const result = _initialize.call(this);
this.setMasterVolume(settings.defaultVolume);
return result;
};
}

WebAudio_MasterVolumeMixIn(WebAudio);

function ConfigManager_MasterVolumeMixIn(configManager: typeof ConfigManager) {
Object.defineProperty(configManager, 'masterVolume', {
get: function () {
return AudioManager._masterVolume;
Expand Down Expand Up @@ -32,31 +42,28 @@ function ConfigManager_MasterVolumeMixIn(configManager) {

ConfigManager_MasterVolumeMixIn(ConfigManager);

/**
* @param {typeof AudioManager} audioManager
*/
function AudioManager_MasterVolumeMixIn(audioManager) {
audioManager._masterVolume = 100;

function AudioManager_MasterVolumeMixIn(audioManager: typeof AudioManager) {
Object.defineProperty(audioManager, 'masterVolume', {
get: function () {
return this._masterVolume;
},
set: function (value) {
set: function (this: typeof AudioManager, value) {
this._masterVolume = value;
WebAudio.setMasterVolume(this._masterVolume / 100);
Video.setVolume(this._masterVolume / 100);
if (this._currentBgm) {
this.updateBgmParameters(this._currentBgm);
}
},
configurable: true,
});

audioManager.masterVolume = settings.defaultVolume;
}

AudioManager_MasterVolumeMixIn(AudioManager);

/**
* @param {Scene_Options.prototype} sceneOptions
*/
function Scene_Options_MasterVolumeMixIn(sceneOptions) {
function Scene_Options_MasterVolumeMixIn(sceneOptions: Scene_Options) {
const _maxCommands = sceneOptions.maxCommands;
sceneOptions.maxCommands = function () {
return _maxCommands.call(this) + 1;
Expand All @@ -65,10 +72,7 @@ function Scene_Options_MasterVolumeMixIn(sceneOptions) {

Scene_Options_MasterVolumeMixIn(Scene_Options.prototype);

/**
* @param {Window_Options.prototype} windowClass
*/
function Window_Options_MasterVolumeMixIn(windowClass) {
function Window_Options_MasterVolumeMixIn(windowClass: Window_Options) {
const _addVolumeOptions = windowClass.addVolumeOptions;
windowClass.addVolumeOptions = function () {
this.addCommand(settings.optionName, 'masterVolume');
Expand Down
14 changes: 14 additions & 0 deletions src/codes/MasterVolume/MasterVolume.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// <reference path="../../typings/rmmz.d.ts" />

declare namespace ConfigManager {
var masterVolume: number;

interface Config {
masterVolume: number;
}
}

declare namespace AudioManager {
var _masterVolume: number;
var masterVolume: number;
}
4 changes: 4 additions & 0 deletions src/codes/MasterVolume/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ DarkPlasma_MasterVolume:
year: 2022
license: MIT
histories:
- date: 2023/06/14
version: 1.0.2
description: 'typescript移行'
- description: '初期値の設定が効かない不具合を修正'
- date: 2022/08/07
version: 1.0.1
description: 'マスターボリューム0で保存するとデフォルトに戻される不具合を修正'
Expand Down
2 changes: 1 addition & 1 deletion src/typings/rmmz-types

0 comments on commit 0d4690d

Please sign in to comment.