110 lines
3.7 KiB
JavaScript
110 lines
3.7 KiB
JavaScript
//=============================================================================
|
|
// RPG Maker MZ - IM_GlobalSave
|
|
//
|
|
// Copyright 2025 min-pub. All rights reserved.
|
|
// This source code or any portion thereof must not be
|
|
// reproduced or used without licensed in any manner whatsoever.
|
|
//=============================================================================
|
|
/*:
|
|
* @target MZ
|
|
* @plugindesc グローバルセーブ
|
|
* @author 四号戦車
|
|
* @base PluginCommonBase
|
|
* @base PluginUtils
|
|
* @orderAfter PluginCommonBase
|
|
* @orderAfter PluginUtils
|
|
*
|
|
* @param start
|
|
* @text グローバル指定開始
|
|
* @desc 指定開始
|
|
* @type switch
|
|
* @default 0
|
|
*
|
|
* @param end
|
|
* @text グローバル指定終了
|
|
* @desc 指定終了
|
|
* @type switch
|
|
* @default 0
|
|
*
|
|
* @help IM_GlobalSave.js
|
|
*
|
|
* Version: 0.0.1
|
|
*
|
|
* グローバルセーブプラグイン
|
|
* スイッチをグローバル領域にセーブします。
|
|
*
|
|
*/
|
|
(() => {
|
|
"use strict";
|
|
|
|
//========================================================================
|
|
// プラグイン定義
|
|
//========================================================================
|
|
const pluginName = "IM_GlobalSave";
|
|
const script = document.currentScript;
|
|
const param = PluginManagerEx.createParameter(script);
|
|
|
|
//========================================================================
|
|
// 定数定義
|
|
//========================================================================
|
|
|
|
//========================================================================
|
|
// コアスクリプト変更部 (DataManager)
|
|
//========================================================================
|
|
const _DataManager_loadGlobalInfo = DataManager.loadGlobalInfo;
|
|
DataManager.loadGlobalInfo = function() {
|
|
StorageManager.loadObject("global")
|
|
.then(globalInfo => {
|
|
this._globalInfo = globalInfo.infos;
|
|
this._globalSwitches = globalInfo.switches;
|
|
this.removeInvalidGlobalInfo();
|
|
|
|
if (!!$gameSwitches) {
|
|
for (let slot = param.start; slot <= param.end; slot++) {
|
|
$gameSwitches.setValue(slot, this._globalSwitches[slot]);
|
|
}
|
|
}
|
|
return 0;
|
|
})
|
|
.catch(() => {
|
|
this._globalInfo = [];
|
|
});
|
|
};
|
|
|
|
const _DataManager_saveGlobalInfo = DataManager.saveGlobalInfo;
|
|
DataManager.saveGlobalInfo = function() {
|
|
|
|
for (let slot = param.start; slot <= param.end; slot++) {
|
|
if (!this._globalSwitches) {
|
|
this._globalSwitches = {};
|
|
}
|
|
this._globalSwitches[slot] = $gameSwitches.value(slot);
|
|
}
|
|
|
|
StorageManager.saveObject("global", {
|
|
infos: this._globalInfo,
|
|
switches: this._globalSwitches,
|
|
});
|
|
};
|
|
|
|
const _DataManager_extractSaveContents = DataManager.extractSaveContents;
|
|
DataManager.extractSaveContents = function(contents) {
|
|
_DataManager_extractSaveContents.apply(this, arguments);
|
|
|
|
for (let slot = param.start; slot <= param.end; slot++) {
|
|
$gameSwitches.setValue(slot, this._globalSwitches[slot]);
|
|
}
|
|
};
|
|
|
|
const _DataManager_setupNewGame = DataManager.setupNewGame;
|
|
DataManager.setupNewGame = function() {
|
|
_DataManager_setupNewGame.apply(this, arguments);
|
|
|
|
if (!!this._globalSwitches) {
|
|
for (let slot = param.start; slot <= param.end; slot++) {
|
|
$gameSwitches.setValue(slot, this._globalSwitches[slot]);
|
|
}
|
|
}
|
|
};
|
|
|
|
})();
|