/*: * @target MZ * @plugindesc メッセージウィンドウ表示時に自動でピクチャを表示し、閉じると消すプラグイン * @author * * @help * 【概要】 * メッセージウィンドウが「開いた」瞬間に、プラグインパラメータで * 指定したピクチャを自動表示します。また、メッセージウィンドウが * 「完全に閉じた」タイミングで、そのピクチャを自動的に消去します。 * * イベントコマンド「文章の表示」を使用するだけで発動し、 * プラグインコマンドは不要です。 * * 【使い方】 * 1. プラグインパラメータで、表示したいピクチャのファイル名や座標などを設定してください。 * 2. イベントコマンドで「文章の表示」を実行すると、ウィンドウが開く際に * 自動でピクチャが表示されます。 * 3. メッセージが続く限り(ウィンドウが連続で開かれ続けている限り)ピクチャは表示されたままです。 * 4. メッセージウィンドウが完全に閉じたタイミングで、ピクチャを消去します。 * * 【注意点】 * - ピクチャIDが他のイベントコマンドで使用中のものと被らないように注意してください。 * - 「文章の表示」を連続するときにウィンドウを閉じない場合、ピクチャは出っぱなしになります。 * - メッセージが終了し、ウィンドウが完全に閉じるとピクチャは消えます。 * * * @param pictureId * @text ピクチャID * @desc 自動表示・消去に使うピクチャ番号(1~100など) * @type number * @min 1 * @default 1 * * @param pictureName * @text ピクチャ名 * @desc 表示したい画像ファイル名(拡張子不要、img/picturesフォルダ内) * @type file * @dir img/pictures * @default * * @param origin * @text 原点 * @desc ピクチャの原点(0:左上, 1:中心) * @type select * @option 左上 * @value 0 * @option 中心 * @value 1 * @default 0 * * @param x * @text X座標 * @desc ピクチャの表示先X座標 * @type number * @default 0 * * @param y * @text Y座標 * @desc ピクチャの表示先Y座標 * @type number * @default 0 * * @param scaleX * @text 横拡大率(%) * @desc ピクチャの横方向拡大率 * @type number * @default 100 * * @param scaleY * @text 縦拡大率(%) * @desc ピクチャの縦方向拡大率 * @type number * @default 100 * * @param opacity * @text 不透明度(0-255) * @desc ピクチャの不透明度 * @type number * @min 0 * @max 255 * @default 255 * * @param blendMode * @text 合成方法 * @desc ピクチャの合成方法(0:通常,1:加算,2:乗算,3:スクリーン) * @type select * @option 通常 * @value 0 * @option 加算 * @value 1 * @option 乗算 * @value 2 * @option スクリーン * @value 3 * @default 0 */ (() => { "use strict"; const pluginName = document.currentScript.src.match(/([^/]+)\.js$/)[1]; const parameters = PluginManager.parameters(pluginName); const pictureId = Number(parameters["pictureId"] || 1); const pictureName= String(parameters["pictureName"] || ""); const origin = Number(parameters["origin"] || 0); const x = Number(parameters["x"] || 0); const y = Number(parameters["y"] || 0); const scaleX = Number(parameters["scaleX"] || 100); const scaleY = Number(parameters["scaleY"] || 100); const opacity = Number(parameters["opacity"] || 255); const blendMode = Number(parameters["blendMode"] || 0); // メッセージウィンドウが開いている間、ピクチャを表示し続けるためのフラグ let isAutoPictureShown = false; //------------------------------------------------------------------------- // Window_Message : メッセージウィンドウが開くときにピクチャ表示 //------------------------------------------------------------------------- const _Window_Message_open = Window_Message.prototype.open; Window_Message.prototype.open = function() { // ウィンドウがまだ開いていないときだけ表示を行う // (連続文章でウィンドウが閉じずに表示が継続する場合はピクチャを再表示しない) if (!this.isOpen()) { // ピクチャ名が設定されていれば表示する if (pictureName) { $gameScreen.showPicture( pictureId, pictureName, origin, x, y, scaleX, scaleY, opacity, blendMode ); isAutoPictureShown = true; } } _Window_Message_open.call(this); }; //------------------------------------------------------------------------- // Window_Message : メッセージウィンドウが閉じたときにピクチャ消去 //------------------------------------------------------------------------- const _Window_Message_close = Window_Message.prototype.close; Window_Message.prototype.close = function() { _Window_Message_close.call(this); // ウィンドウを閉じるメソッド自体は呼ばれても、閉じ終わりまで時間がある // 完全に閉じきったタイミング(onClose)で実行すると安全 }; //------------------------------------------------------------------------- // Window_Message : ウィンドウが閉じ終わったタイミング //------------------------------------------------------------------------- const _Window_Message_onClose = Window_Message.prototype.onClose; Window_Message.prototype.onClose = function() { _Window_Message_onClose.call(this); // 完全に閉じたらピクチャを消去 if (isAutoPictureShown) { $gameScreen.erasePicture(pictureId); isAutoPictureShown = false; } }; })();