princess-synergy/www/js/plugins/JsScript141Set.js
2026-02-05 14:03:22 -06:00

118 lines
4.8 KiB
JavaScript

let CN_数値入力 = 1204;
const NumInput_Path = "pictures/UI_NumInput/";
let ni_Edit変数 = -1;
let ni_入力桁数 = -1;
let ni_InputNo = 0;
let ni_InputArr = [];
Game_Interpreter.prototype.setupNumInput = function (params) {
//$gameMessage.setNumberInput(params[0], params[1]);
ni_Edit変数 = params[0];
ni_入力桁数 = params[1];
ni_InputClear();
this.N_NumImnput_NumDraw();
this.SetCmnEvent(CN_数値入力);
return false;
};
let NIPs = new Pos2D(562, 304);
Game_Interpreter.prototype.N_NumImnput_View = function () {
this.SetSpriteFIn(PN_niBase, NumInput_Path + "PN_niBase", 0, 0, 0, 0, 15);
this.SetSpriteFIn(PN_niBtn_c, NumInput_Path + "PN_niBtn_c",
NIPs._x + 98 * 0, NIPs._y + 98 * 3, 0, 0, 15);
this.SetSpriteFIn(PN_niBtn + 0, NumInput_Path + "PN_niBtn_0",
NIPs._x + 98 * 1, NIPs._y + 98 * 3, 0, 0, 15);
this.SetSpriteFIn(PN_niBtn_ok, NumInput_Path + "PN_niBtn_ok",
NIPs._x + 98 * 2, NIPs._y + 98 * 3, 0, 0, 15);
this.SetSpriteFIn(PN_niBtn + 1, NumInput_Path + "PN_niBtn_1",
NIPs._x + 98 * 0, NIPs._y + 98 * 2, 0, 0, 15);
this.SetSpriteFIn(PN_niBtn + 2, NumInput_Path + "PN_niBtn_2",
NIPs._x + 98 * 1, NIPs._y + 98 * 2, 0, 0, 15);
this.SetSpriteFIn(PN_niBtn + 3, NumInput_Path + "PN_niBtn_3",
NIPs._x + 98 * 2, NIPs._y + 98 * 2, 0, 0, 15);
this.SetSpriteFIn(PN_niBtn + 4, NumInput_Path + "PN_niBtn_4",
NIPs._x + 98 * 0, NIPs._y + 98 * 1, 0, 0, 15);
this.SetSpriteFIn(PN_niBtn + 5, NumInput_Path + "PN_niBtn_5",
NIPs._x + 98 * 1, NIPs._y + 98 * 1, 0, 0, 15);
this.SetSpriteFIn(PN_niBtn + 6, NumInput_Path + "PN_niBtn_6",
NIPs._x + 98 * 2, NIPs._y + 98 * 1, 0, 0, 15);
this.SetSpriteFIn(PN_niBtn + 7, NumInput_Path + "PN_niBtn_7",
NIPs._x + 98 * 0, NIPs._y + 98 * 0, 0, 0, 15);
this.SetSpriteFIn(PN_niBtn + 8, NumInput_Path + "PN_niBtn_8",
NIPs._x + 98 * 1, NIPs._y + 98 * 0, 0, 0, 15);
this.SetSpriteFIn(PN_niBtn + 9, NumInput_Path + "PN_niBtn_9",
NIPs._x + 98 * 2, NIPs._y + 98 * 0, 0, 0, 15);
this.SpriteStr(PN_niSetuTxt, ni_入力桁数 + "桁の数字を入力してください", 24, 544, 120, 0);
this.MoveSprite(PN_niSetuTxt, true, true, 15);
}
Game_Interpreter.prototype.N_NumImnput_Update = function () {
let _BtnArr = [
PN_niBtn + 0,
PN_niBtn + 1, PN_niBtn + 2, PN_niBtn + 3,
PN_niBtn + 4, PN_niBtn + 5, PN_niBtn + 6,
PN_niBtn + 7, PN_niBtn + 8, PN_niBtn + 9
];
this.SpriteCngColorArr(_BtnArr);
if (ni_InputNo == ni_入力桁数) {
this.SpriteCngColorArr(_BtnArr, [-80, -80, -80, 0]);
}
let _CNo = overPointerSpCkArr(_BtnArr);
if (_CNo != -1 && ni_InputNo < ni_入力桁数) {
this.SpriteCngColor(_CNo, [150, 150, 150, 0]);
if (TouchInput.isTriggered()) {
ni_InputArr[ni_InputNo] = String(_CNo - PN_niBtn);
this.N_NumImnput_NumDraw();
ni_InputNo++;
this.PlaySe("GUI_click_05");
}
}
let _CkArr = [PN_niBtn_c];
if (ni_InputNo != ni_入力桁数) {
this.SpriteCngColor(PN_niBtn_ok, [-80, -80, -80, 0]);
} else {
_CkArr.push(PN_niBtn_ok);
}
this.SpriteCngColorArr(_CkArr);
_CNo = overPointerSpCkArr(_CkArr);
if (_CNo != -1) {
this.SpriteCngColor(_CNo, [150, 150, 150, 0]);
switch (_CNo) {
case PN_niBtn_ok:
if (TouchInput.isTriggered()) {
let _SetStr = "";
for (let i = 0; i <= ni_InputArr.length - 1; i++) {
_SetStr += ni_InputArr[i];
}
$gameVariables.setValue(ni_Edit変数, Number(_SetStr))
for (let i = PN_niBase; i <= PN_niSetuTxt; i++) {
this.MoveSprite(i, true, true, 10, 0, true, true);
}
this.PlaySe("beep");
return false;
}
break;
case PN_niBtn_c:
if (TouchInput.isTriggered()) {
ni_InputClear();
this.N_NumImnput_NumDraw();
}
break;
}
}
return true;
}
let ni_InputClear = function () {
ni_InputNo = 0;
ni_InputArr = [];
for (let i = 0; i <= ni_入力桁数 - 1; i++) {
ni_InputArr.push("");
}
}
Game_Interpreter.prototype.N_NumImnput_NumDraw = function () {
let _SetStr = "";
for (let i = 0; i <= ni_InputArr.length - 1; i++) {
_SetStr += ni_InputArr[i];
if (ni_InputArr[i] == "") _SetStr += "_";
}
D_Text_Cng_font = "Makinas";
this.SpriteStrC(PN_niInTxt, _SetStr, 80, 696, 215, 255);
D_Text_Cng_font = "";
}