File size: 3,095 Bytes
99b0de1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | //=============================================================================
// RPG Maker MZ - Button Picture
//=============================================================================
/*:
* @target MZ
* @plugindesc Makes a picture clickable.
* @author Yoji Ojima
*
* @help ButtonPicture.js
*
* This plugin provides a command to call a common event when a picture is
* clicked.
*
* Use it in the following procedure.
* 1. Execute "Show Picture" to display your button image.
* 2. Call the plugin command "Set Button Picture".
*
* @command set
* @text Set Button Picture
* @desc Makes the specified picture clickable.
*
* @arg pictureId
* @type number
* @min 1
* @max 100
* @default 1
* @text Picture Number
* @desc Control number of the picture.
*
* @arg commonEventId
* @type common_event
* @default 1
* @text Common Event
* @desc Common event to call when the picture is clicked.
*/
/*:ja
* @target MZ
* @plugindesc ピクチャをクリック可能にします。
* @author Yoji Ojima
*
* @help ButtonPicture.js
*
* このプラグインは、ピクチャのクリック時にコモンイベントを呼び出すコマンドを
* 提供します。
*
* 次の手順で使用してください。
* 1. 「ピクチャの表示」を実行して、ボタン画像を表示します。
* 2. プラグインコマンド「ボタンピクチャの設定」を呼び出します。
*
* @command set
* @text ボタンピクチャの設定
* @desc 指定したピクチャをクリック可能にします。
*
* @arg pictureId
* @type number
* @min 1
* @max 100
* @default 1
* @text ピクチャ番号
* @desc ピクチャの管理番号です。
*
* @arg commonEventId
* @type common_event
* @default 1
* @text コモンイベント
* @desc ピクチャがクリックされた時に呼び出すコモンイベントです。
*/
(() => {
const pluginName = "ButtonPicture";
PluginManager.registerCommand(pluginName, "set", args => {
const pictureId = Number(args.pictureId);
const commonEventId = Number(args.commonEventId);
const picture = $gameScreen.picture(pictureId);
if (picture) {
picture.mzkp_commonEventId = commonEventId;
}
});
Sprite_Picture.prototype.isClickEnabled = function() {
const picture = this.picture();
return picture && picture.mzkp_commonEventId && !$gameMessage.isBusy();
};
Sprite_Picture.prototype.onClick = function() {
$gameTemp.reserveCommonEvent(this.picture().mzkp_commonEventId);
};
Spriteset_Base.prototype.mzkp_isAnyPicturePressed = function() {
return this._pictureContainer.children.some(sprite =>
sprite.isPressed()
);
};
const _Scene_Map_isAnyButtonPressed =
Scene_Map.prototype.isAnyButtonPressed;
Scene_Map.prototype.isAnyButtonPressed = function() {
return (
_Scene_Map_isAnyButtonPressed.apply(this, arguments) ||
this._spriteset.mzkp_isAnyPicturePressed()
);
};
})();
|