File size: 52,564 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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 | "use strict";
/*:
@target MV MZ
@plugindesc Dot movement system decision trigger extension v1.1.1
@author unagi ootoro
@url https://raw.githubusercontent.com/unagiootoro/RPGMZ/master/DotMoveSystem_DecideTriggerEx.js
@base DotMoveSystem
@help
A plugin that extends the decision trigger extension of the dot moving system.
By using this plugin, the event triggered by the decision button
It becomes possible to set the bootable range.
You can also display a popup in the event when the player enters the launchable range.
Popup can be selected from balloon icon, icon, picture and window.
※ When installing this plugin, "DotMoveSystem.js v2.2.1" or later is required.
【How to use】
■ Popup display settings
By writing the following content in the annotation on page 0, when the event becomes determinable
You can show popups.
・Display icons
<popupIcon: icon number>
Example: To display the 4th icon
<popupIcon: 4>
・Display message window
<popupWindowText: Message to display>
Example: Displaying a message window called Test
<popupWindowText: test>
・Specify the font size of the window
<popupWindowTextFontSize: font size>
Example: Specifying a font size of 24 pixels
<popupWindowTextFontSize: 24>
・Specify the font name of the window
<popupWindowTextFontFace: font name>
Example: When specifying MS P Gothic
<popupWindowTextFontFace: MS PGothic>
・Specify window skin image
<popupWindowSkin: image file name>
Example: When specifying Window_Popup.png
<popupWindowSkin: Window_Popup>
Window skin images must be placed in the system folder.
・Display images
<popupImage: image file name>
Example: To display popup.png
<popupImage: popup>
Images should be placed in the picture folder.
・Display the balloon icon
<popupBalloon: balloon icon number>
Example: To display the first balloon icon
<popupBalloon: 1>
■ Change popup settings (MZ only)
By executing the plug-in command "Pop-up setting change",
You can change the popup settings.
For the "setting contents" of the parameter, set in the same format as when setting in the annotation.
*This function is limited to MZ. In the case of MV, it can be reconfigured by using the script below.
■ When changing popup display by script
By using a script, it is possible to change the event popup display later.
・Change to display icons
this.event().changePopupIcon(icon number);
Example: To display the 4th icon
this.event().changePopupIcon(4);
・Change to display the message window
this.event().changePopupWindowText(message to display);
Example: Displaying a message window called Test
this.event().changePopupWindowText("Test");
・Change the font size of the window
this.event().changePopupWindowTextFontSize(font size);
Example: When changing to 32 pixels
this.event().changePopupWindowTextFontSize(32);
・Change the font name of the window
this.event().changePopupWindowTextFontFace(message to display);
Example: When changing to MS P Gothic
this.event().changePopupWindowTextFontFace("MSPGothic");
・Change to display images
this.event().changePopupImage(image file name);
Example: To display popup.png
this.event().changePopupImage("popup");
・Change to display balloon icon
this.event().changePopupBalloon(balloon icon number);
Example: To display the first balloon icon
this.event().changePopupBalloon(1);
・Change the skin image of the message window
this.event().changePopupWindowSkin(message to display);
Example: When using a skin image with the file name "Window_MV"
this.event().changePopupWindowSkin("Window_MV");
・Clear the current popup settings
this.event().clearPopupSetting();
・Reflect changes in popup settings
this.event().applyPopupSetting();
※Note
The old settings remain in the state where the settings are changed by the script.
So run clearPopupSetting to clear old settings.
Also, since the settings are not reflected on the actual game screen as they are,
It is necessary to execute applyPopupSetting to reflect the setting change on the game screen.
【License】
This plugin is available under the terms of the MIT license.
@command ChangePopupParameter
@text popup parameter change
@desc Change popup display settings.
@arg EventId
@type number
@text setting
@desc
Specifies the event ID for which popup settings are to be changed. If 0 is specified, the event targeted for command execution is targeted.
@arg PopupParameter
@text popup parameter
@type struct<PopupParameter>
@desc
Specifies the popup parameter to change.
@param DecideTriggerAreaWidth
@text decision trigger area width
@type number
@decimals 2
@default 2
@desc
Specifies the width of the area in which decision triggers can be executed. Internally the area width is treated as the diameter of the circle.
@param DefaultPopupParameter
@text default popup parameter
@type struct<PopupParameter>
@default {"BalloonId":"0","IconNumber":"0","ImageFileName":"","WindowText":"","WindowTextFontSize":"0","WindowTextFontFace":"","WindowSkinFileName ":""}
@desc
Specify default popup parameters.
*/
/*~struct~PopupParameter:
@param BalloonId
@text Balloon ID
@type number
@default 0
@desc
Specify the balloon ID.
@param IconNumber
@text icon number
@type number
@default 0
@desc
Specifies the icon number.
@param ImageFileName
@text image filename
@type file
@dir img/pictures
@desc
Specifies the image file name.
@param WindowText
@text window text
@type string
@desc
Specifies the text to display in the window.
@param WindowTextFontSize
@text window text font size
@type number
@default 0
@desc
Specifies the font size of the text displayed in the window. Specify 0 to use the standard size.
@param WindowTextFontFace
@text window text font face
@type string
@desc
Specifies the font face of the text displayed in the window. If empty, use standard faces.
@param WindowSkinFileName
@text window skin filename
@type file
@dir img/system
@desc
Specifies the window skin file name. If empty, use standard Window.
*/
/*:ja
@target MV MZ
@plugindesc ドット移動システム 決定トリガー拡張 v1.1.1
@author うなぎおおとろ
@url https://raw.githubusercontent.com/unagiootoro/RPGMZ/master/DotMoveSystem_DecideTriggerEx.js
@base DotMoveSystem
@help
ドット移動システムの決定トリガー拡張を拡張するプラグインです。
このプラグインを使用することで決定ボタンによって起動するイベントの
起動可能な範囲を設定することが可能になります。
また、プレイヤーが起動可能範囲に入った際にイベントにポップアップを表示することもできます。
ポップアップはフキダシアイコン、アイコン、ピクチャ、ウィンドウから選択することが可能です。
※ 本プラグインを導入する場合、「DotMoveSystem.js v2.2.1」以降が必要になります。
【使用方法】
■ ポップアップの表示設定について
0ページ目の注釈に以下の内容を記載することで、イベントが決定可能になった際に
ポップアップを表示することができます。
・アイコンを表示する
<popupIcon: アイコン番号>
例: 4番目のアイコンを表示する場合
<popupIcon: 4>
・メッセージウィンドウを表示する
<popupWindowText: 表示するメッセージ>
例: テストというメッセージウィンドウを表示する場合
<popupWindowText: テスト>
・ウィンドウのフォントサイズを指定する
<popupWindowTextFontSize: フォントサイズ>
例: 24ピクセルのフォントサイズを指定する場合
<popupWindowTextFontSize: 24>
・ウィンドウのフォント名を指定する
<popupWindowTextFontFace: フォント名>
例: MS Pゴシックを指定する場合
<popupWindowTextFontFace: MS Pゴシック>
・ウィンドウスキンの画像を指定する
<popupWindowSkin: 画像ファイル名>
例: Window_Popup.pngを指定する場合
<popupWindowSkin: Window_Popup>
ウィンドウスキンの画像はsystemフォルダに配置する必要があります。
・画像を表示する
<popupImage: 画像ファイル名>
例: popup.pngを表示する場合
<popupImage: popup>
画像はpictureフォルダに配置する必要があります。
・フキダシアイコンを表示する
<popupBalloon: フキダシアイコン番号>
例: 1番目のフキダシアイコンを表示する場合
<popupBalloon: 1>
■ ポップアップ設定の変更(MZ限定)
プラグインコマンド「ポップアップ設定変更」を実行することで、
ポップアップの設定を変更することができます。
パラメータの「設定内容」には、注釈で設定する際と同じ形式で設定を行ってください。
※本機能はMZ限定です。MVの場合は下記のスクリプトを使用することで再設定が可能です。
■ スクリプトでポップアップの表示を変更する場合
スクリプトを使用することで、イベントのポップアップ表示を後から変更することが可能です。
・アイコンを表示するように変更する
this.event().changePopupIcon(アイコン番号);
例: 4番目のアイコンを表示する場合
this.event().changePopupIcon(4);
・メッセージウィンドウを表示するように変更する
this.event().changePopupWindowText(表示するメッセージ);
例: テストというメッセージウィンドウを表示する場合
this.event().changePopupWindowText("テスト");
・ウィンドウのフォントサイズを変更する
this.event().changePopupWindowTextFontSize(フォントサイズ);
例: 32ピクセルに変更する場合
this.event().changePopupWindowTextFontSize(32);
・ウィンドウのフォント名を変更する
this.event().changePopupWindowTextFontFace(表示するメッセージ);
例: MS Pゴシックに変更する場合
this.event().changePopupWindowTextFontFace("MS Pゴシック");
・画像を表示するように変更する
this.event().changePopupImage(画像ファイル名);
例: popup.pngを表示する場合
this.event().changePopupImage("popup");
・フキダシアイコンを表示するように変更する
this.event().changePopupBalloon(フキダシアイコン番号);
例: 1番目のフキダシアイコンを表示する場合
this.event().changePopupBalloon(1);
・メッセージウィンドウのスキン画像を変更する
this.event().changePopupWindowSkin(表示するメッセージ);
例: ファイル名「Window_MV」というスキン画像を使用する場合
this.event().changePopupWindowSkin("Window_MV");
・現在のポップアップの設定をクリアする
this.event().clearPopupSetting();
・ポップアップ設定の変更を反映する
this.event().applyPopupSetting();
※注意
スクリプトで設定変更を行った状態では古い設定が残ったままになっています。
そのため、clearPopupSettingを実行して古い設定をクリアしてください。
また、そのままでは設定が実際のゲーム画面に反映されないため、
applyPopupSettingを実行して設定変更をゲーム画面に反映する必要があります。
【ライセンス】
このプラグインは、MITライセンスの条件の下で利用可能です。
@command ChangePopupParameter
@text ポップアップパラメータ変更
@desc ポップアップ表示の設定を変更します。
@arg EventId
@type number
@text 設定内容
@desc
ポップアップ設定を変更する対象のイベントIDを指定します。0を指定するとコマンド実行対象のイベントを対象にします。
@arg PopupParameter
@text ポップアップパラメータ
@type struct<PopupParameter>
@desc
変更するポップアップパラメータを指定します。
@param DecideTriggerAreaWidth
@text 決定トリガーエリア幅
@type number
@decimals 2
@default 2
@desc
決定トリガーが実行可能になるエリアの幅を指定します。内部的にはエリア幅は円の直径として扱われます。
@param DefaultPopupParameter
@text デフォルトポップアップパラメータ
@type struct<PopupParameter>
@default {"BalloonId":"0","IconNumber":"0","ImageFileName":"","WindowText":"","WindowTextFontSize":"0","WindowTextFontFace":"","WindowSkinFileName":""}
@desc
デフォルトのポップアップパラメータを指定します。
*/
/*~struct~PopupParameter:ja
@param BalloonId
@text フキダシID
@type number
@default 0
@desc
フキダシIDを指定します。
@param IconNumber
@text アイコン番号
@type number
@default 0
@desc
アイコン番号を指定します。
@param ImageFileName
@text 画像ファイル名
@type file
@dir img/pictures
@desc
画像ファイル名を指定します。
@param WindowText
@text ウィンドウテキスト
@type string
@desc
ウィンドウに表示するテキストを指定します。
@param WindowTextFontSize
@text ウィンドウテキストフォントサイズ
@type number
@default 0
@desc
ウィンドウに表示するテキストのフォントサイズを指定します。0を指定すると標準のサイズを使用します。
@param WindowTextFontFace
@text ウィンドウテキストフォントフェイス
@type string
@desc
ウィンドウに表示するテキストのフォントフェイスを指定します。空の場合は標準のフェイスを使用します。
@param WindowSkinFileName
@text ウィンドウスキンファイル名
@type file
@dir img/system
@desc
ウィンドウスキンファイル名を指定します。空の場合は標準のWindowを使用します。
*/
const DotMoveSystem_DecideTriggerExPluginName = document.currentScript ? decodeURIComponent(document.currentScript.src.match(/^.*\/(.+)\.js$/)[1]) : "DotMoveSystem_DecideTriggerEx";
var DotMoveSystem;
(function (DotMoveSystem) {
var DecideTriggerEx;
(function (DecideTriggerEx) {
function mixin(dest, src) {
for (const name of Object.getOwnPropertyNames(src.prototype)) {
if (name === "constructor")
continue;
const value = Object.getOwnPropertyDescriptor(src.prototype, name) || Object.create(null);
Object.defineProperty(dest.prototype, name, value);
}
}
if (typeof PluginManager.registerCommand !== "undefined") {
PluginManager.registerCommand(DotMoveSystem_DecideTriggerExPluginName, "ChangePopupParameter", function (args) {
const eventId = parseInt(args.EventId);
const popupParams = PopupParameter.fromParams(JSON.parse(args.PopupParameter));
let event;
if (eventId === 0) {
event = $gameMap.event(this.eventId());
}
else {
event = $gameMap.event(eventId);
}
event.changePopupParams(popupParams);
});
}
// MV Compatible
if (Utils.RPGMAKER_NAME === "MV") {
Spriteset_Map.prototype.findTargetSprite = function (target) {
return this._characterSprites.find((sprite) => sprite.checkCharacter(target));
};
Sprite_Character.prototype.checkCharacter = function (character) {
return this._character === character;
};
Window_Base.prototype.textSizeEx = function (text) {
if (text) {
this.resetFontSettings();
var textState = { index: 0, x: 0, y: 0, left: 0 };
textState.undrawing = true;
textState.text = this.convertEscapeCharacters(text);
// @ts-ignore
textState.height = this.calcTextHeight(textState, false);
while (textState.index < textState.text.length) {
this.processCharacter(textState);
}
return { width: textState.x, height: textState.height };
}
else {
return { width: 0, height: 0 };
}
};
// @ts-ignore
Window_Base.prototype.processNormalCharacter = function (textState) {
var c = textState.text[textState.index++];
var w = this.textWidth(c);
if (!textState.undrawing) {
this.contents.drawText(c, textState.x, textState.y, w * 2, textState.height);
}
textState.x += w;
};
}
class PopupParameter {
constructor(balloonId, iconNumber, imageFileName, windowText, windowTextFontSize, windowTextFontFace, windowSkinFileName) {
this.balloonId = balloonId != null ? balloonId : 0;
this.iconNumber = iconNumber != null ? iconNumber : 0;
this.imageFileName = imageFileName != null ? imageFileName : "";
this.windowText = windowText != null ? windowText : "";
this.windowTextFontSize = windowTextFontSize != null ? windowTextFontSize : 0;
this.windowTextFontFace = windowTextFontFace != null ? windowTextFontFace : "";
this.windowSkinFileName = windowSkinFileName != null ? windowSkinFileName : "";
}
static fromParams(params) {
const balloonId = params.BalloonId != null ? parseInt(params.BalloonId) : undefined;
const iconNumber = params.IconNumber;
const imageFileName = params.ImageFileName;
const windowText = params.WindowText;
const windowTextFontSize = params.WindowTextFontSize != null ? parseInt(params.WindowTextFontSize) : undefined;
const windowTextFontFace = params.WindowTextFontFace;
const windowSkinFileName = params.WindowSkinFileName;
return new PopupParameter(balloonId, iconNumber, imageFileName, windowText, windowTextFontSize, windowTextFontFace, windowSkinFileName);
}
}
DecideTriggerEx.PopupParameter = PopupParameter;
class PluginParams {
constructor() {
const params = PluginManager.parameters(DotMoveSystem_DecideTriggerExPluginName);
this.decideTriggerAreaWidth = parseFloat(params.DecideTriggerAreaWidth);
if (params.DefaultPopupParameter) {
this.defaultPopupParameter = PopupParameter.fromParams(JSON.parse(params.DefaultPopupParameter));
}
else {
this.defaultPopupParameter = new PopupParameter();
}
}
}
DecideTriggerEx.PluginParams = PluginParams;
const PP = new PluginParams();
class Circle {
constructor(...args) {
this.initialize(...args);
}
get x() { return this._x; }
set x(_x) { this._x = _x; }
get y() { return this._y; }
set y(_y) { this._y = _y; }
get d() { return this._d; }
set d(_d) { this._d = _d; }
get r() { return this.d / 2; }
initialize(x, y, d) {
this._x = x;
this._y = y;
this._d = d;
}
isCollidedCircle(circle) {
const pos = new DotMoveSystem.DotMovePoint(this.x, this.y);
const far = pos.calcFar(new DotMoveSystem.DotMovePoint(circle.x, circle.y));
return far < this.r + circle.r;
}
}
DecideTriggerEx.Circle = Circle;
class DecideTriggerArea extends Game_Character {
constructor(...args) {
super(...args);
}
get type() { return this._type; }
get owner() { return this._owner; }
initialize(...args) {
const [type, owner] = args;
super.initialize();
this._type = type;
this._owner = owner;
}
update() {
super.update();
const ownerPos = this._owner.positionPoint();
const x = ownerPos.x - (this.width() - this._owner.width()) / 2;
const y = ownerPos.y - (this.height() - this._owner.height()) / 2;
this.setPositionPoint(new DotMoveSystem.DotMovePoint(x, y));
}
width() {
return PP.decideTriggerAreaWidth;
}
height() {
return PP.decideTriggerAreaWidth;
}
}
DecideTriggerEx.DecideTriggerArea = DecideTriggerArea;
class PlayerDotMoveTempData_Mixin extends DotMoveSystem.PlayerDotMoveTempData {
initialize(character) {
PlayerDotMoveTempData_Mixin._initialize.call(this, character);
this._decideTriggerCollidedEventIds = [];
this._remainDisableTouchEventTime = 0;
}
get decideTriggerCollidedEventIds() { return this._decideTriggerCollidedEventIds; }
set decideTriggerCollidedEventIds(_decideTriggerCollidedEventIds) { this._decideTriggerCollidedEventIds = _decideTriggerCollidedEventIds; }
get remainDisableTouchEventTime() { return this._remainDisableTouchEventTime; }
set remainDisableTouchEventTime(_remainDisableTouchEventTime) { this._remainDisableTouchEventTime = _remainDisableTouchEventTime; }
}
PlayerDotMoveTempData_Mixin._initialize = DotMoveSystem.PlayerDotMoveTempData.prototype.initialize;
mixin(DotMoveSystem.PlayerDotMoveTempData, PlayerDotMoveTempData_Mixin);
class EventDotMoveTempData_Mixin extends DotMoveSystem.EventDotMoveTempData {
get decideTriggerArea() { return this._decideTriggerArea; }
set decideTriggerArea(_decideTriggerArea) { this._decideTriggerArea = _decideTriggerArea; }
}
mixin(DotMoveSystem.EventDotMoveTempData, EventDotMoveTempData_Mixin);
class Game_Character_Mixin extends Game_Character {
onPress() {
}
onClick() {
}
}
mixin(Game_Character, Game_Character_Mixin);
class Game_Player_Mixin extends Game_Player {
update(sceneActive) {
Game_Player_Mixin._update.call(this, sceneActive);
if (sceneActive) {
this.updateDecideTriggerEvent();
this.updateDisableTouchEventTimer();
}
}
updateDisableTouchEventTimer() {
if ($gameMap.isEventRunning()) {
this.dotMoveTempData().remainDisableTouchEventTime = 10;
}
else {
if (this.dotMoveTempData().remainDisableTouchEventTime > 0) {
this.dotMoveTempData().remainDisableTouchEventTime--;
}
}
}
updateDecideTriggerEvent() {
if ($gameMap.isEventRunning())
return;
const tempData = this.dotMoveTempData();
const lastDecideTriggerCollidedEventIds = tempData.decideTriggerCollidedEventIds;
this.checkDecideTriggerEventProcess();
const decideTriggerCollidedEventIds = tempData.decideTriggerCollidedEventIds;
for (const eventId of decideTriggerCollidedEventIds) {
const event = $gameMap.event(eventId);
if (!event)
continue;
event.setDecidablePopupVisible(true);
}
for (const eventId of lastDecideTriggerCollidedEventIds) {
if (!decideTriggerCollidedEventIds.includes(eventId)) {
const event = $gameMap.event(eventId);
if (!event)
continue;
event.setDecidablePopupVisible(false);
}
}
}
checkDecideTriggerEventProcess() {
const eventIds = [];
const dir = this.direction();
eventIds.push(...this.checkDecideTriggerEventInternal(this._realX, this._realY, dir));
let currentPoint = this.positionPoint();
while (true) {
let nextPoint = DotMoveSystem.DotMoveUtils.nextPointWithDirection(currentPoint, dir);
let nextX = Math.round(nextPoint.x);
let nextY = Math.round(nextPoint.y);
if ($gameMap.isCounter(nextX, nextY)) {
eventIds.push(...this.checkDecideTriggerEventInternal(nextX, nextY, dir));
}
else {
break;
}
currentPoint = nextPoint;
}
const uniqEventIds = [];
for (const id of eventIds) {
if (!uniqEventIds.includes(id))
uniqEventIds.push(id);
}
this.dotMoveTempData().decideTriggerCollidedEventIds = uniqEventIds;
}
checkDecideTriggerEventInternal(x, y, d) {
const eventIds = [];
for (const result of this.mover().checkHitCharacters(x, y, d, DecideTriggerArea)) {
const event = result.targetObject.owner;
if (!event)
continue;
if (!this.isTowardDirectionToCharacter(event))
continue;
if (!(event.isTriggerIn([0]) && event.isNormalPriority()))
continue;
if (event.isEventPageEmpty(0))
continue;
const subjectRect = result.subjectRect;
const targetRect = result.targetRect;
const circle1 = new Circle(subjectRect.x + subjectRect.width / 2, subjectRect.y + subjectRect.height / 2, 1);
const circle2 = new Circle(targetRect.x + targetRect.width / 2, targetRect.y + targetRect.height / 2, PP.decideTriggerAreaWidth);
if (!circle1.isCollidedCircle(circle2))
continue;
eventIds.push(event.eventId());
}
for (const result of this.mover().checkHitCharacters(x, y, this._direction, Game_Event)) {
const event = result.targetObject;
if (!(event.isTriggerIn([0]) && !event.isNormalPriority()))
continue;
if (result.collisionLengthX() >= event.widthArea() && result.collisionLengthY() >= event.heightArea()) {
eventIds.push(event.eventId());
}
}
return eventIds;
}
isTowardDirectionToCharacter(character) {
let towardDir;
const sx = this.deltaRealXFrom(character.centerRealX());
const sy = this.deltaRealYFrom(character.centerRealY());
if (Math.abs(sx) > Math.abs(sy)) {
towardDir = sx > 0 ? 4 : 6;
}
else {
towardDir = sy > 0 ? 8 : 2;
}
return this._direction === towardDir;
}
triggerButtonAction() {
if (Input.isTriggered("ok")) {
if (this.getOnOffVehicle()) {
return true;
}
this.checkEventTriggerHere([0]);
if ($gameMap.setupStartingEvent()) {
return true;
}
this.checkEventTriggerThere([0, 1, 2], { isDecide: true });
if ($gameMap.setupStartingEvent()) {
return true;
}
}
return false;
}
checkEventTriggerThere(triggers, opt = {}) {
var _a;
const isDecide = (_a = opt.isDecide) !== null && _a !== void 0 ? _a : false;
if (isDecide) {
if (!this.canStartLocalEvents())
return;
if (!triggers.includes(0))
return;
this.startMapEventDecideTriggerEx();
}
else {
Game_Player_Mixin._checkEventTriggerThere.call(this, triggers);
}
}
startMapDecideEventByTouch(event) {
if (this.dotMoveTempData().remainDisableTouchEventTime > 0)
return;
if (!this.canStartLocalEvents())
return;
if ($gameMap.isEventRunning())
return;
const eventIds = this.dotMoveTempData().decideTriggerCollidedEventIds;
if (!eventIds.includes(event.eventId()))
return;
event.start();
}
startMapEventDecideTriggerEx() {
if ($gameMap.isEventRunning())
return;
const eventIds = this.dotMoveTempData().decideTriggerCollidedEventIds;
for (const eventId of eventIds) {
const event = $gameMap.event(eventId);
if (event)
event.start();
}
}
}
Game_Player_Mixin._update = Game_Player.prototype.update;
Game_Player_Mixin._checkEventTriggerThere = Game_Player.prototype.checkEventTriggerThere;
mixin(Game_Player, Game_Player_Mixin);
class Game_Event_Mixin extends Game_Event {
initMembers() {
Game_Event_Mixin._initMembers.call(this);
this._popupDelayTime = 0;
this._decidablePopupVisible = false;
this._popupIcon = 0;
this._decidableBalloonId = 0;
this._popupImageFileName = "";
this._popupWindowText = "";
this._popupWindowTextFontSize = 0;
this._popupWindowTextFontFace = "";
this._popupWindowSkinFileName = "";
this._popupSettingChanged = false;
}
update() {
Game_Event_Mixin._update.call(this);
if (this._decidableBalloonId > 0)
this.updateDecideBalloon();
if (this._popupDelayTime > 0)
this._popupDelayTime--;
const tempData = this.dotMoveTempData();
tempData.decideTriggerArea.update();
}
isLocked() {
return this._locked;
}
changePopupIcon(iconIndex) {
this._popupIcon = iconIndex;
}
changePopupWindowText(text) {
this._popupWindowText = text;
}
changePopupImage(imageFileName) {
this._popupImageFileName = imageFileName;
}
changePopupBalloon(balloonId) {
this._decidableBalloonId = balloonId;
}
changePopupWindowSkin(windowSkinFileName) {
this._popupWindowSkinFileName = windowSkinFileName;
}
clearPopupSetting() {
this.changePopupParams(new PopupParameter());
}
applyPopupSetting() {
this.refresh();
this._needUpdatePopupObject = true;
}
changePopupParams(popupParams) {
this._popupIcon = popupParams.iconNumber;
this._decidableBalloonId = popupParams.balloonId;
this._popupImageFileName = popupParams.imageFileName;
this._popupWindowText = popupParams.windowText;
this._popupWindowTextFontSize = popupParams.windowTextFontSize;
this._popupWindowTextFontFace = popupParams.windowTextFontFace;
this._popupWindowSkinFileName = popupParams.windowSkinFileName;
this._needUpdatePopupObject = true;
}
checkNeedUpdatePopupObject() {
if (this._needUpdatePopupObject) {
this._needUpdatePopupObject = false;
return true;
}
return false;
}
startPopupDelay() {
this._popupDelayTime = 30;
}
updateDecideBalloon() {
if (this.isDecidablePopupVisible()) {
if (!this.isBalloonPlaying()) {
if (Utils.RPGMAKER_NAME === "MZ") {
$gameTemp.requestBalloon(this, this._decidableBalloonId);
}
else {
// @ts-ignore // MV Compatible
this.requestBalloon(this._decidableBalloonId);
}
}
}
}
setDecidablePopupVisible(visible) {
this._decidablePopupVisible = visible;
}
isDecidablePopupVisible() {
if ($gameMap.isEventRunning())
return false;
if (this._popupDelayTime > 0)
return false;
return this._decidablePopupVisible;
}
popupIcon() {
return this._popupIcon;
}
popupImageFileName() {
return this._popupImageFileName;
}
popupWindowText() {
return this._popupWindowText;
}
popupWindowTextFontSize() {
return this._popupWindowTextFontSize;
}
popupWindowTextFontFace() {
return this._popupWindowTextFontFace;
}
popupWindowSkinFileName() {
return this._popupWindowSkinFileName;
}
refresh() {
Game_Event_Mixin._refresh.call(this);
if (!this._popupSettingChanged) {
this._popupSettingChanged = true;
this.resetPopupSetting();
}
}
resetPopupSetting() {
const values = this.getAnnotationValues(0);
if (values.popupIcon)
this._popupIcon = parseInt(values.popupIcon);
if (values.popupBalloon)
this._decidableBalloonId = parseInt(values.popupBalloon);
if (values.popupImage)
this._popupImageFileName = values.popupImage.replace(/^\s+/, "");
if (values.popupWindowText)
this._popupWindowText = values.popupWindowText.replace(/^\s+/, "");
if (values.popupWindowTextFontSize)
this._popupWindowTextFontSize = parseInt(values.popupWindowTextFontSize);
if (values.popupWindowTextFontFace)
this._popupWindowTextFontFace = values.popupWindowTextFontFace.replace(/^\s+/, "");
if (values.popupWindowSkin) {
this._popupWindowSkinFileName = values.popupWindowSkin.replace(/^\s+/, "");
}
else {
this._popupWindowSkinFileName = PP.defaultPopupParameter.windowSkinFileName;
}
if (!this.isNeedPopupObject() && this._decidableBalloonId === 0 && !values.unuseDefault) {
this._popupIcon = PP.defaultPopupParameter.iconNumber;
this._decidableBalloonId = PP.defaultPopupParameter.balloonId;
this._popupImageFileName = PP.defaultPopupParameter.imageFileName;
this._popupWindowText = PP.defaultPopupParameter.windowText;
}
}
createDotMoveTempData() {
const tempData = Game_Event_Mixin._createTempData.call(this);
tempData.decideTriggerArea = new DecideTriggerArea("circle", this);
return tempData;
}
isNeedPopupObject() {
if (this._popupIcon > 0)
return true;
if (this._popupImageFileName !== "")
return true;
if (this._popupWindowText !== "")
return true;
return false;
}
start() {
Game_Event_Mixin._start.call(this);
this.startPopupDelay();
}
isEventPageEmpty(page) {
const eventData = this.event();
if (eventData) {
const pageList = eventData.pages[page].list;
for (let i = 0; i < pageList.length; i++) {
if (!(pageList[i].code === 0 || pageList[i].code === 108 || pageList[i].code === 408)) {
return false;
}
}
}
return true;
}
onClick() {
Game_Character.prototype.onClick();
$gamePlayer.startMapDecideEventByTouch(this);
if (this.isLocked()) {
$gameTemp.clearDestination();
}
}
}
Game_Event_Mixin._initMembers = Game_Event.prototype.initMembers;
Game_Event_Mixin._refresh = Game_Event.prototype.refresh;
Game_Event_Mixin._update = Game_Event.prototype.update;
Game_Event_Mixin._createTempData = Game_Event.prototype.createDotMoveTempData;
Game_Event_Mixin._start = Game_Event.prototype.start;
mixin(Game_Event, Game_Event_Mixin);
class Game_Map_Mixin extends Game_Map {
allCharacters() {
const characters = Game_Map_Mixin._allCharacters.call(this);
for (const event of this.events()) {
characters.add(event.dotMoveTempData().decideTriggerArea);
}
return characters;
}
}
Game_Map_Mixin._allCharacters = Game_Map.prototype.allCharacters;
mixin(Game_Map, Game_Map_Mixin);
let baseSpriteClass;
if (Utils.RPGMAKER_NAME === "MZ") {
baseSpriteClass = Sprite;
}
else {
// @ts-ignore // MV Compatible
baseSpriteClass = Sprite_Base;
}
class Sprite_Icon extends baseSpriteClass {
setIconIndex(iconIndex) {
if (iconIndex > 0) {
if (!this.bitmap) {
this.bitmap = ImageManager.loadSystem("IconSet");
}
const iconFrame = this.iconFrame(iconIndex);
this.setFrame(iconFrame.x, iconFrame.y, iconFrame.width, iconFrame.height);
}
else {
this.bitmap = null;
}
}
iconFrame(iconIndex) {
let pw, ph;
if (Utils.RPGMAKER_NAME === "MZ") {
pw = ImageManager.iconWidth;
ph = ImageManager.iconHeight;
}
else {
pw = 32;
ph = 32;
}
const sx = (iconIndex % 16) * pw;
const sy = Math.floor(iconIndex / 16) * ph;
return new Rectangle(sx, sy, pw, ph);
}
}
DecideTriggerEx.Sprite_Icon = Sprite_Icon;
class Window_Popup extends Window_Base {
initialize(rect) {
if (Utils.RPGMAKER_NAME === "MZ") {
super.initialize(rect);
}
else {
// @ts-ignore // MV Compatible
super.initialize(rect.x, rect.y, rect.width, rect.height);
}
this._text = "";
this._textFontSize = 0;
this._textFontFace = "";
this.downArrowVisible = true;
}
get text() {
return this._text;
}
set text(_text) {
this._text = _text;
this.refresh();
}
get textFontSize() {
return this._textFontSize;
}
set textFontSize(_textFontSize) {
this._textFontSize = _textFontSize;
this.refresh();
}
get textFontFace() {
return this._textFontFace;
}
set textFontFace(_textFontFace) {
this._textFontFace = _textFontFace;
this.refresh();
}
refresh() {
this.contents.clear();
if (Utils.RPGMAKER_NAME === "MZ") {
this.contentsBack.clear();
}
const { width, height } = this.textSizeEx(this._text);
this.width = width + this.padding * 2;
this.height = height + this.padding * 2;
this.drawTextEx(this._text, 0, 0, this.width);
}
_refreshArrows() {
super._refreshArrows();
this._downArrowSprite.y += 16;
}
resetFontSettings() {
this.contents.fontFace = this.realTextFontFace();
this.contents.fontSize = this.realTextFontSize();
this.resetTextColor();
}
realTextFontSize() {
if (this._textFontSize === 0) {
if (Utils.RPGMAKER_NAME === "MZ") {
return $gameSystem.mainFontSize();
}
else {
// @ts-ignore // MV Compatible
return this.standardFontSize();
}
}
return this._textFontSize;
}
realTextFontFace() {
if (this._textFontFace === "") {
if (Utils.RPGMAKER_NAME === "MZ") {
return $gameSystem.mainFontFace();
}
else {
// @ts-ignore // MV Compatible
return this.standardFontFace();
}
}
return this._textFontFace;
}
}
DecideTriggerEx.Window_Popup = Window_Popup;
class Sprite_Character_Mixin extends Sprite_Character {
initMembers() {
Sprite_Character_Mixin._initMembers.call(this);
this._pressed = false;
}
update() {
Sprite_Character_Mixin._update.call(this);
this.processTouch();
}
character() {
return this._character;
}
processTouch() {
if (this.isClickEnabled()) {
if (this.isBeingTouched()) {
if (TouchInput.isTriggered()) {
this._pressed = true;
this.onPress();
}
}
else {
this._pressed = false;
}
if (this._pressed && TouchInput.isReleased()) {
this._pressed = false;
this.onClick();
}
}
else {
this._pressed = false;
}
}
isPressed() {
return this._pressed;
}
isClickEnabled() {
return this.worldVisible;
}
isBeingTouched() {
const touchPos = new Point(TouchInput.x, TouchInput.y);
const localPos = this.worldTransform.applyInverse(touchPos);
return this.hitTest(localPos.x, localPos.y);
}
hitTest(x, y) {
const width = this.spriteWidth();
const height = this.spriteHeight();
const rect = new Rectangle(-this.anchor.x * width, -this.anchor.y * height, width, height);
return rect.contains(x, y);
}
spriteWidth() {
if (this._bushDepth > 0 && this._upperBody && this._lowerBody) {
return this._upperBody.width;
}
else {
return this.width;
}
}
spriteHeight() {
if (this._bushDepth > 0 && this._upperBody && this._lowerBody) {
return this._upperBody.height + this._lowerBody.height;
}
else {
return this.width;
}
}
onPress() {
this._character.onPress();
}
onClick() {
this._character.onClick();
}
}
Sprite_Character_Mixin._initMembers = Sprite_Character.prototype.initMembers;
Sprite_Character_Mixin._update = Sprite_Character.prototype.update;
mixin(Sprite_Character, Sprite_Character_Mixin);
class Scene_Map_Mixin extends Scene_Map {
processMapTouch() {
Scene_Map_Mixin._processMapTouch.call(this);
const characterSprites = this._spriteset.characterSprites();
for (const characterSprite of characterSprites) {
characterSprite.processTouch();
}
}
checkCharacterEventStarted() {
const characterSprites = this._spriteset.characterSprites();
let startEvent = false;
const eventIds = $gamePlayer.dotMoveTempData().decideTriggerCollidedEventIds;
for (const characterSprite of characterSprites) {
if (characterSprite.isPressed()) {
const character = characterSprite.character();
if ((character instanceof Game_Event) && eventIds.includes(character.eventId())) {
startEvent = true;
}
}
}
return startEvent;
}
onMapTouch() {
const startEvent = this.checkCharacterEventStarted();
if (!startEvent) {
// @ts-ignore
if (typeof $virtualStickController !== "undefined") {
return;
}
Scene_Map_Mixin._onMapTouch.call(this);
}
}
}
Scene_Map_Mixin._processMapTouch = Scene_Map.prototype.processMapTouch;
Scene_Map_Mixin._onMapTouch = Scene_Map.prototype.onMapTouch;
mixin(Scene_Map, Scene_Map_Mixin);
class Spriteset_Map_Mixin extends Spriteset_Map {
initialize() {
this._popupObjects = new Map();
Spriteset_Map_Mixin._initialize.call(this);
}
update() {
Spriteset_Map_Mixin._update.call(this);
this.updatePopupObjects();
}
characterSprites() {
return this._characterSprites;
}
updatePopupObjects() {
const characters = this._characterSprites.map(sprite => sprite.character());
const events = characters.filter(character => character instanceof Game_Event);
for (const event of events) {
if (!this._popupObjects.has(event)) {
if (event.isNeedPopupObject()) {
const popupObject = this.createPopupObject(event);
this._popupObjects.set(event, popupObject);
this._tilemap.addChild(popupObject);
}
}
else {
if (event.checkNeedUpdatePopupObject()) {
const oldPopupObject = this._popupObjects.get(event);
this._tilemap.removeChild(oldPopupObject);
this._popupObjects.delete(event);
if (event.isNeedPopupObject()) {
const newPopupObject = this.createPopupObject(event);
this._popupObjects.set(event, newPopupObject);
this._tilemap.addChild(newPopupObject);
}
}
}
}
for (const event of this._popupObjects.keys()) {
const popupObject = this._popupObjects.get(event);
if (events.includes(event)) {
this.updatePopupObject(event, popupObject);
}
else {
this._tilemap.removeChild(popupObject);
this._popupObjects.delete(event);
}
}
}
createPopupObject(event) {
const popupIcon = event.popupIcon();
const popupImageFileName = event.popupImageFileName();
const popupWindowText = event.popupWindowText();
const popupWindowSkinFileName = event.popupWindowSkinFileName();
let popupObject;
if (popupIcon > 0) {
const sprite = new Sprite_Icon();
sprite.setIconIndex(popupIcon);
sprite.hide();
popupObject = sprite;
}
else if (popupImageFileName !== "") {
const sprite = new baseSpriteClass();
sprite.bitmap = ImageManager.loadPicture(popupImageFileName);
sprite.hide();
popupObject = sprite;
}
else if (popupWindowText !== "") {
const rect = new Rectangle(0, 0, Graphics.boxWidth, 128);
const window = new Window_Popup(rect);
if (popupWindowSkinFileName !== "") {
window.windowskin = ImageManager.loadSystem(popupWindowSkinFileName);
}
window.text = popupWindowText;
window.textFontSize = event.popupWindowTextFontSize();
window.textFontFace = event.popupWindowTextFontFace();
window.hide();
popupObject = window;
}
if (!popupObject)
throw new Error("Create popup object failed.");
popupObject.z = 7;
return popupObject;
}
updatePopupObject(event, popupObject) {
if (event.isDecidablePopupVisible()) {
const characterSprite = this.findTargetSprite(event);
if (characterSprite && (characterSprite instanceof Sprite_Character)) {
popupObject.x = characterSprite.x - popupObject.width / 2;
popupObject.y = characterSprite.y - characterSprite.height - popupObject.height;
popupObject.show();
}
}
else {
popupObject.hide();
}
}
}
Spriteset_Map_Mixin._initialize = Spriteset_Map.prototype.initialize;
Spriteset_Map_Mixin._update = Spriteset_Map.prototype.update;
mixin(Spriteset_Map, Spriteset_Map_Mixin);
class Game_Interpreter_Mixin extends Game_Interpreter {
event() {
return $gameMap.event(this._eventId);
}
}
mixin(Game_Interpreter, Game_Interpreter_Mixin);
})(DecideTriggerEx = DotMoveSystem.DecideTriggerEx || (DotMoveSystem.DecideTriggerEx = {}));
})(DotMoveSystem || (DotMoveSystem = {}));
|