TitanMyth

DevAid.js

Sep 16th, 2020 (edited)
616
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /** /*:
  2.  * @author TitanMyth
  3.  * @plugindesc Some tools to aid development
  4.  * @version 0.0.1
  5.  *
  6.  * @param enableBGM
  7.  * @desc To set initial value as to whether the BGM is enabled. (on/off)
  8.  * @default on
  9.  * @param audioLevel
  10.  * @desc To set initial audio level. (0-100)
  11.  * @default 100
  12.  */
  13. (() => {
  14.     function toNumber(str, def) {
  15.         return isNaN(str) ? def : +(str || def);
  16.     }
  17.  
  18.     var parameters = PluginManager.parameters('DevAid');
  19.     var enableBGM = parameters['enableBGM'].toLowerCase() === 'on';
  20.     var audioLevel = toNumber(parameters['audioLevel'], 100);
  21.  
  22.     var _ConfigManager_applyData = ConfigManager.applyData;
  23.     ConfigManager.applyData = function(config) {
  24.         _ConfigManager_applyData.apply(this, arguments);
  25.         if (config['bgmVolume'] === undefined) {
  26.             this.bgmVolume = enableBGM ? audioLevel : 0;
  27.         }
  28.         if (config['bgsVolume'] === undefined) {
  29.             this.bgsVolume = audioLevel;
  30.         }
  31.         if (config['meVolume'] === undefined) {
  32.             this.meVolume = audioLevel;
  33.         }
  34.         if (config['seVolume'] === undefined) {
  35.             this.seVolume = audioLevel;
  36.         }
  37.     };
  38. })();
RAW Paste Data