/
DarkPlasma_ChoiceListCancelSE.js
68 lines (61 loc) · 2.36 KB
/
DarkPlasma_ChoiceListCancelSE.js
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
// DarkPlasma_ChoiceListCancelSE
// Copyright (c) 2020 DarkPlasma
// This software is released under the MIT license.
// http://opensource.org/licenses/mit-license.php
/**
* 2020/03/25 1.0.1 マウスクリックやタッチでキャンセル項目を選択した際に決定SEが再生される不具合を修正
* 2020/03/17 1.0.0 公開
*/
/*:
* @plugindesc 選択肢でキャンセル項目を選択したときにキャンセルSEを再生するプラグイン
* @author DarkPlasma
* @license MIT
*
* @help
* イベントコマンドの選択肢でキャンセルにあたる項目を選択して決定キーを押した際にも
* キャンセルSEを再生します。
*/
(function () {
'use strict';
const pluginName = document.currentScript.src.replace(/^.*\/(.*).js$/, function() {
return arguments[1];
});
const pluginParameters = PluginManager.parameters(pluginName);
const _Window_ChoiceList_isOkTriggered = Window_ChoiceList.prototype.isOkTriggered;
Window_ChoiceList.prototype.isOkTriggered = function() {
if (this.isCancelEnabled() && this.index() === $gameMessage.choiceCancelType()) {
return false;
}
return _Window_ChoiceList_isOkTriggered.call(this);
};
const _Window_ChoiceList_isCancelTriggered = Window_ChoiceList.prototype.isCancelTriggered;
Window_ChoiceList.prototype.isCancelTriggered = function () {
if (Input.isTriggered('ok') && this.isCancelEnabled() && this.index() === $gameMessage.choiceCancelType()) {
return true;
}
return _Window_ChoiceList_isCancelTriggered.call(this);
};
/**
* キャンセルに相当する選択肢がタッチされたかどうか
* @param {boolean} triggered
* @return {boolean}
*/
Window_ChoiceList.prototype.isTouchedCancel = function (triggered) {
if (!triggered || !this.isCancelEnabled() || this.index() !== $gameMessage.choiceCancelType()) {
return false;
}
const hitIndex = this.hitTest(
this.canvasToLocalX(TouchInput.x),
this.canvasToLocalY(TouchInput.y)
);
return hitIndex >= 0 && hitIndex === this.index();
};
const _Window_ChoiceList_onTouch = Window_ChoiceList.prototype.onTouch;
Window_ChoiceList.prototype.onTouch = function (triggered) {
if (this.isTouchedCancel(triggered)) {
this.processCancel();
} else {
_Window_ChoiceList_onTouch.call(this, triggered);
}
};
})();