問題は、画像とイベントを削除する場合(「Clear Picture Common Event」を使用)、その瞬間にマウスカーソルが画像の上にあったら、色調変更が残ってしまうことです。つまり、画像を再表示すると、そのまま白く色がかった状態になってしまいます。
この問題を解決する方法をご存知ですか?「Change Tone on Hover」の設定を無効にしても、この問題は発生するということもお伝えしておきます。
あと、Change Tone on Hoverはどこでオフにした?プラグインのパラメータで切ったとしても、ピクチャがChange Picture Common Eventのプラグインコマンド経由でイベントを受け取ってるなら、そのコマンド側のCustom settingsが実際に使われてるんじゃないかな。
スクリーンショットでは「Use Global?」が true に設定されています。この設定が、下部の「Custom settings」を無視し、プラグインパラメータにある「Default Global Settings」を使用するようにコマンドに指示しているのかもしれません。これにより、そこで「Change Tone on Hover」を false に設定しても効果が現れない理由が説明つく可能性があります。そのコマンドで「Use Global?」を false に設定してみてください。もしその画像に最初からトーンが適用されていないなら、残留してしまうこともないはずです。
わあ、ご協力いただき誠にありがとうございます。心から感謝いたします!
残念ながら、問題の性質が変わってしまいました。スクリプトは1つの問題は解決してくれました:マウスが画像から離れたとき、画像に色調変化(ティント)が適用されなくなりました!しかし、同じ画像に再びマウスをホバーさせると色調変化が再び現れ、クリックするとイベントが発生しません。つまり、イベント自体は画像から切り離されたものの、「Change Tone on Hover(ホバー時の色調変更)」機能はまだバックグラウンドで動作しているようです。「Change Tone on Hover」機能を無効にしても、この問題は残ります。
とても奇妙です。あなたのスクリプトにより、画像が消えるとホバー効果は画像から切り離されますが、色調変更機能はイベントが発生できなくなったにもかかわらず、依然としてアクティブなままです。
このバージョンでは、Picture Common Eventsコマンドも追跡します。「Clear」または「Erase & Clear」の実行後、そのピクチャIDは、「Change Picture Common Event」で再びイベントが割り当てられるまで、ホバー時のトーンが適用されません。また、このコマンドで「Use Global?」と「Change Tone on Hover?」の両方がfalseに設定されている場合もトーンをブロックします。1%ピクチャのテクニックも削除できます。ファイルを丸ごと以下のものに置き換えてください。
//=============================================================================
// PictureHoverToneFix.js
//=============================================================================
/*:
* @target MZ
* @plugindesc ピクチャを消去して再表示した後でも、ホバー時のトーンが残らないようにします。
* @author Baz
*
* @param pictureIds
* @text ピクチャID
* @type number[]
* @min 1
* @default []
* @desc この修正を適用するピクチャ。空のままにすると、すべてのピクチャに適用されます。
*
* @help PictureHoverToneFix.js
*
* プラグインマネージャーで、VisuMZ_4_PictureCmnEvtsより下にこのプラグインを配置してください。
*
* ピクチャのホバー時のトーンは、最後に「Show Picture」を実行して以降、マウスが実際にそのピクチャ上で移動した場合にのみ保持されます。
*
* 「Clear Picture Common Event」、「Erase & Clear Picture」、または「Clear All」コマンドを実行した後、そのピクチャには「Change Picture Common Event」でコモンイベントが再度割り当てられるまで、ホバー時のトーンは一切適用されません。「Use Global?」と「Change Tone on Hover?」の両方がfalseに設定されている「Change Picture Common Event」の場合も同様です。
*
* その他の場合は、トーンと合成モードがピクチャ自身の値(「Show Picture」と「Tint Picture」で制御される値)に戻されます。
*
* プラグインコマンドはありません。
*/
(() => {
const params = PluginManager.parameters("PictureHoverToneFix");
const pictureIds = JSON.parse(params.pictureIds || "[]").map(Number);
const pictureCommonEventsName = "VisuMZ_4_PictureCmnEvts";
const isFixedPicture = pictureId =>
pictureIds.length === 0 || pictureIds.includes(pictureId);
// Returns null when the command takes no picture IDs (the Clear All ones).
const commandPictureIds = args => {
if (!("PictureIDs:arraynum" in args)) {
return null;
}
try {
return JSON.parse(args["PictureIDs:arraynum"]).map(Number);
} catch (e) {
return [];
}
};
const isFalse = value => String(value).trim() === "false";
// Picture IDs that shouldn't get a hover tint, kept in save files.
Game_Screen.prototype.hoverFixBlocked = function() {
if (!this._hoverFixBlocked) {
this._hoverFixBlocked = {};
}
return this._hoverFixBlocked;
};
const trackPictureCommonEvents = (commandName, args) => {
args = args || {};
const blocked = $gameScreen.hoverFixBlocked();
const ids = commandPictureIds(args);
if (commandName === "ChangePictureCommonEvent") {
const hasCommonEvent = Number(args["CommonEventID:num"]) > 0;
const toneOff =
isFalse(args["UseGlobal:eval"]) && isFalse(args["ChangeTone:eval"]);
for (const id of ids || []) {
blocked[id] = !hasCommonEvent || toneOff;
}
} else if (ids) {
for (const id of ids) {
blocked[id] = true;
}
} else {
for (let id = 1; id <= $gameScreen.maxPictures(); id++) {
blocked[id] = true;
}
}
};
const _PluginManager_callCommand = PluginManager.callCommand;
PluginManager.callCommand = function(self, pluginName, commandName, args) {
if (pluginName === pictureCommonEventsName) {
trackPictureCommonEvents(commandName, args);
}
_PluginManager_callCommand.call(this, self, pluginName, commandName, args);
};
const _Sprite_Picture_update = Sprite_Picture.prototype.update;
Sprite_Picture.prototype.update = function() {
_Sprite_Picture_update.call(this);
this.updateHoverToneFix();
};
Sprite_Picture.prototype.updateHoverToneFix = function() {
const picture = this.picture();
if (!picture || !this.visible || !isFixedPicture(this._pictureId)) {
return;
}
// Show Picture always makes a new Game_Picture, so a new object
// means the picture was just shown and starts out not hovered.
if (this._hoverFixPicture !== picture) {
this._hoverFixPicture = picture;
this._hoverFixHovered = false;
}
if (!this.isBeingTouched()) {
this._hoverFixHovered = false;
} else if (TouchInput.isHovered()) {
this._hoverFixHovered = true;
}
const blocked = $gameScreen.hoverFixBlocked()[this._pictureId];
if (blocked || !this._hoverFixHovered) {
this.setColorTone(picture.tone() || [0, 0, 0, 0]);
this.blendMode = picture.blendMode();
}
};
})();