do-disciplinary-committee-m.../www/js/plugins/IZ_ChoiceWindow_mod.js
2025-05-04 14:43:03 -05:00

158 lines
No EOL
5.2 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//=============================================================================
// IZ_ChoiceWindow
//=============================================================================
//=============================================================================
/*:
* @plugindesc v1.0 選択肢ウィンドウをスマホ操作に最適化します。
*
* @author いず
* @help
*・選択肢ウィンドウを横長に表示して、スマホの縦持ち操作に最適化します。
*・エディタの選択肢ウィンドウ表示位置の設定で、
* ウィンドウの位置の設定の代わりに選択肢の列数を選択するようにします。
*
* 位置 行数
* 左 4
* 中 1
* 右 1
*
* 左指定時のみ動作するように変更 by suzu (MPP_CoiceEXより上に配置)
*/
(function () {
//-----------------------------------------------------------------------------
// Window_ChoiceList
//
// The window used for the event command [Show Choices].
//
// MPP_ChoiceEX.js との競合バグ回避 by suzu
//
var _Window_ChoiceList_start = Window_ChoiceList.prototype.start;
Window_ChoiceList.prototype.start = function(){
this.resetScroll();
_Window_ChoiceList_start.call(this);
}
//
//■選択肢ウィンドウの場所を変更する機能を列数変更機能に書き換え
//
// MPP_ChoiceEX.js との競合バグ回避 by suzu
// 関数実行順変更
var _Window_ChoiceList_updatePlacement = Window_ChoiceList.prototype.updatePlacement;
Window_ChoiceList.prototype.updatePlacement = function () {
var positionType = $gameMessage.choicePositionType();
var messageY = this._messageWindow.y;
this.width = this.windowWidth();
switch (positionType) {
case 0:
this.x = 0;
Window_ChoiceList.prototype.maxCols = function () {
if($gameSwitches.value(628)){ //にんじん探しミニゲーム中
return 8;
}else{
return 4;
}
};
break;
case 1:
this.x = (Graphics.boxWidth - this.width) / 2;
Window_ChoiceList.prototype.maxCols = function () {
return 1;
};
break;
case 2:
this.x = Graphics.boxWidth - this.width;
Window_ChoiceList.prototype.maxCols = function () {
//本の整理ミニゲーム中
if($gameSwitches.value(282)){
return 3;
}else{
return 1;
}
};
break;
}
this.height = this.windowHeight();
if (messageY >= Graphics.boxHeight / 2) {
this.y = messageY - this.height;
} else {
this.y = messageY + this._messageWindow.height;
}
};
//
//■ウィンドウ幅を画面幅に合わせる
//
// 左指定時のみ動作に変更 by suzu
Window_ChoiceList.prototype.windowWidth = function () {
var positionType = $gameMessage.choicePositionType();
switch(positionType){
case 0:
return Graphics.boxWidth;
case 1:
case 2:
var width = this.maxChoiceWidth() + this.padding * 2;
return Math.min(width, Graphics.boxWidth);
default:
var width = this.maxChoiceWidth() + this.padding * 2;
return Math.min(width, Graphics.boxWidth);
}
};
//
//■行数の調整
//
Window_ChoiceList.prototype.numVisibleRows = function () {
var messageY = this._messageWindow.y;
var messageHeight = this._messageWindow.height;
var centerY = Graphics.boxHeight / 2;
var choices = $gameMessage.choices();
var positionType = $gameMessage.choicePositionType();
switch (positionType) {
case 0:
var numLines = Math.ceil(choices.length / 2);
break;
case 1:
var numLines = choices.length;
break;
case 2:
var numLines = Math.ceil(choices.length / 3);
break;
}
var maxLines = 8;
if (messageY < centerY && messageY + messageHeight > centerY) {
maxLines = 4;
}
if (numLines > maxLines) {
numLines = maxLines;
}
return numLines;
};
//
//■1つの選択肢に表示できる文字数の調整
// 上手いやり方がわからないので暫定的に最大240pxにしておく
//
Window_ChoiceList.prototype.maxChoiceWidth = function () {
var maxWidth = 240;//表示できる文章の最大長さpx
var choices = $gameMessage.choices();
for (var i = 0; i < choices.length; i++) {
var choiceWidth = this.textWidthEx(choices[i]) + this.textPadding() * 2;
if (maxWidth < choiceWidth) {
maxWidth = choiceWidth;
}
}
return maxWidth;
};
})();