Advertisement
TwentyFree

Message Window Popup

Jul 10th, 2021
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // MessageWindowPopup.js
  3. // ----------------------------------------------------------------------------
  4. // (C) 2016 Triacontane
  5. // This software is released under the MIT License.
  6. // http://opensource.org/licenses/mit-license.php
  7. // ----------------------------------------------------------------------------
  8. // Version
  9. // 2.14.9 2019/12/27 StandPictureEC.jsおよびMessageAlignmentEC.jsと組み合わせた場合に発生する競合を修正
  10. // 2.14.8 2019/12/27 2.14.7の修正で一部制御文字を使用するとウィンドウ幅の計算が正しく行われない問題を修正
  11. // 2.14.7 2019/12/22 不明な制御文字が挿入されたとき、ウィンドウの横幅が拡張されないよう修正
  12. //                   StandPictureEC.jsでピクチャを表示したとき、初回のみポップアップウィンドウの座標が反映されない競合を修正
  13. // 2.14.6 2019/12/07 YEP_MessageCore.jsでネームボックスを表示する際、同プラグインの位置調整が反映されない競合を修正
  14. // 2.14.5 2019/07/21 YEP_MessageCore.jsでネームボックスを表示する際、特定の条件下で一瞬だけネームボックスが不正な位置に表示される問題を修正
  15. // 2.14.4 2019/06/23 フキダシウィンドウを無効化したときのX座標の値をデフォルトのコアスクリプトの動作に準拠するよう修正
  16. // 2.14.3 2019/06/18 MKR_MessageWindowCustom.jsとの連携で、フキダシウィンドウ有効時はフキダシの横幅と高さを優先するよう変更
  17. // 2.14.2 2019/06/16 FTKR_ExMessageWindow2.jsおよびPauseSignToTextEnd.jsとの連携で、フキダシウィンドウ表示時にポーズサインがはみ出してしまう競合を修正
  18. // 2.14.1 2019/06/16 2.14.0で追加したテール画像がフキダシウィンドウ無効のときも表示されていた問題を修正
  19. // 2.14.0 2019/06/10 テール画像を別途指定できる機能を追加
  20. // 2.13.0 2019/05/26 PauseSignToTextEnd.jsと完全に組み合わせて使用できるよう修正
  21. // 2.12.2 2019/04/14 フキダシウィンドウをキャラクター下に表示した際、Y座標の位置調整が効かなくなる問題を修正
  22. // 2.12.1 2019/02/07 GraphicalDesignMode.jsと併用し、かつフキダシウィンドウ無効時、カスタマイズしたウィンドウの横幅が反映されるよう修正
  23. // 2.12.0 2019/10/21 フキダシウィンドウの表示位置の上限と下限を設定できる機能を追加
  24. //                   フキダシウィンドウを画面上の任意の位置に表示できる機能を追加
  25. // 2.11.2 2018/11/26 ポップアップ用のウィンドウスキン設定後、ポップアップを解除してもスキンがそのままになってしまう場合がある問題を修正
  26. // 2.11.1 2018/11/26 MPP_MessageEX.jsとの競合を解消(ネームウィンドウの表示不整合)
  27. // 2.11.0 2018/11/11 ポップアップウィンドウの横幅と高さの最小値を変数から取得できる機能を追加
  28. // 2.10.2 2018/11/07 ポップアップ用のウィンドウスキン設定後、メニューを開くか場所移動すると設定が戻ってしまう問題を修正
  29. // 2.10.1 2018/06/15 ウィンドウ連携が有効かつ、フキダシウィンドウを1回も表示していない場合に選択肢ウィンドウが見えなくなる問題を修正
  30. // 2.10.0 2018/05/20 ポーズサインのテール化機能を使わない設定を追加しました。
  31. // 2.9.8 2018/03/19 プラグインを未適用の状態でセーブしたデータをロードするとエラーになる現象を修正
  32. // 2.9.7 2018/01/30 BetweenCharacters.jsとの競合を解消
  33. // 2.9.6 2018/01/15 MPP_MessageEX.jsとの競合を解消、パラメータの型指定誤りを修正、2.9.1の修正の取り込みが一部間違っていた問題を修正
  34. // 2.9.5 2018/01/12 KMS_DebugUtil.jsとの競合を解消
  35. // 2.9.4 2017/12/21 FTKR_ExMessageWindow2.jsとの連携で、上下にフキダシウィンドウを同時表示できるよう修正
  36. // 2.9.3 2017/12/14 2.9.2の修正で上方向に対する調整が抜けていたのを修正
  37. // 2.9.2 2017/12/10 フキダシ位置のY座標を調整する際にテール画像が表示されるように微調整
  38. // 2.9.1 2017/12/07 フキダシ表示を無効化後、メッセージの表示をする前に選択肢を表示すると位置がおかしくなる問題を修正(by 奏ねこまさん)
  39. // 2.9.0 2017/10/18 AltWindowFrame.jsとの競合を解消してMADOと連携できるようになりました。
  40. // 2.8.1 2017/08/14 ウィンドウの振動時間を設定できる機能を追加
  41. // 2.8.0 2017/08/14 ウィンドウを振動させる機能を追加
  42. //                  パラメータの型指定機能に対応
  43. // 2.7.0 2017/06/24 フキダシ位置を設定する機能で、イベント名で指定できる機能を追加
  44. //                  フキダシ有効化時にウィンドウ位置を設定できる機能を追加
  45. // 2.6.0 2017/06/21 ウィンドウが画面外に出ないように調整するパラメータを追加
  46. //                  フキダシの位置固定をイベントごとに設定できる機能で、イベント名で指定できる機能を追加
  47. // 2.5.1 2017/06/11 DP_MapZoom.js以外のマップズーム機能に対してフキダシ位置が正しく表示されていなかった問題を修正
  48. // 2.5.0 2017/06/05 マップズームに対してフキダシ位置が正しく表示されるよう対応
  49. //                  フキダシの位置固定をイベントごとに設定できる機能を追加
  50. // 2.4.1 2017/05/28 ウィンドウスキンを変更した直後の文字色のみ変更前の文字色になってしまう問題を修正(by 奏ねこまさん)
  51. //                  2行目以降の文字サイズを変更したときにウィンドウの高さが正しく計算されない問題を修正
  52. // 2.4.0 2017/05/16 並列実行のコモンイベントで「MWP_VALID 0」を実行したときに、実行中のマップイベントを対象とするよう修正
  53. // 2.3.2 2017/05/25 「FTKR_ExMessageWindow2.js」の連携機能の修正(byフトコロ)
  54. //                  ウィンドウを閉じた時にフキダシ無効化をする対象を、指定していたウィンドウIDのみに変更
  55. //                  フキダシ無効化コマンドにウィンドウIDを指定する機能追加
  56. //                  場所移動時にすべてのウィンドウIDのフキダシ無効化処理を追加
  57. //                  プラグインパラメータ[自動設定]をOFFに設定した場合、イベント起動時にフキダシ無効化する対象をウィンドウID0だけに変更
  58. // 2.3.1 2017/05/14 「FTKR_ExMessageWindow2.js」の連携機能の修正(byフトコロ)
  59. //                  ポップアップの初期化および、ポップアップ無効時の文章の表示位置の不具合修正
  60. //                  フキダシ有効化コマンドにウィンドウIDを指定する機能追加
  61. // 2.3.0 2017/05/01 フトコロさんの「FTKR_ExMessageWindow2.js」と連携してフキダシを複数表示できる機能を追加(byフトコロさん)
  62. // 2.2.0 2017/04/20 選択肢および数値ウィンドウをテール画像の右側に表示できるプラグインコマンドを追加
  63. // 2.1.0 2017/02/21 フキダシウィンドウ内で制御文字「\{」「\}」を指定したときの上限、下限、増減幅を設定できる機能を追加
  64. // 2.0.5 2017/01/23 ウィンドウスキンを変更しているデータをロード直後にフキダシメッセージを表示すると
  65. //                  文字が黒くなってしまう問題を修正
  66. // 2.0.4 2016/12/25 ウィンドウを閉じている最中にウィンドウ表示位置を変更するプラグインコマンドを実行すると、
  67. //                  一瞬だけ空ウィンドウが表示される問題を修正
  68. // 2.0.3 2016/10/22 デフォルト以外で制御文字と見なされる記述(\aaa[333]や\d<test>)を枠幅の計算から除外するよう修正
  69. // 2.0.2 2016/09/29 キャラクターの位置によってはネームポップが一部見切れてしまう現象を修正
  70. // 2.0.1 2016/08/25 フォントサイズを\{で変更して\}で戻さなかった場合の文字サイズがおかしくなっていた現象を修正
  71. // 2.0.0 2016/08/22 本体v1.3.0によりウィンドウ透過の実装が変更されたので対応
  72. // 1.3.3 2016/07/02 ポップアップ有効時は選択肢の最大表示数が8になるよう修正
  73. // 1.3.2 2016/06/02 YEP_MessageCore.jsとのウィンドウ位置に関する競合を解消
  74. // 1.3.1 2016/05/25 フォロワーにフキダシを表示できる機能を追加
  75. // 1.3.0 2016/03/21 ウィンドウの表示位置をキャラクターの高さに合わせて自動調整するよう修正
  76. //                  ポップアップウィンドウ専用のウィンドウスキンを使用する機能を追加
  77. //                  位置とサイズを微調整する機能を追加
  78. //                  選択肢と数値入力ウィンドウの表示方法を2種類追加
  79. // 1.2.3 2016/02/23 YEP_MessageCore.jsより上に配置した場合に発生するエラーを修正
  80. //                  (正常に動作しない点はそのままです)
  81. // 1.2.2 2016/02/20 YEP_MessageCore.js最新版に対応
  82. // 1.2.1 2016/02/20 YEP_MessageCore.jsのネームポップをポップアップウィンドウと連動するよう対応
  83. // 1.2.0 2016/02/13 並列処理のイベントが存在するときにポップアップ設定がクリアされてしまう
  84. //                  問題の修正
  85. //                  ウィンドウの表示位置を下に表示できる設定を追加
  86. // 1.1.3 2016/02/04 イベント終了時にポップアップ設定をクリアするよう修正
  87. // 1.1.2 2016/01/31 行間を調整できる機能を追加
  88. // 1.1.1 2016/01/30 選択肢と数値入力ウィンドウをポップアップと連携するよう修正
  89. //                  その他微調整と軽微な表示不良修正
  90. // 1.1.0 2016/01/29 高確率で競合するバグを修正
  91. //                  ポップアップウィンドウがキャラクターの移動に追従するよう修正
  92. //                  顔グラフィックが見切れないよう修正
  93. //                  実行中のイベントをポップアップ対象にできる機能を追加(0を指定)
  94. //                  英語対応
  95. // 1.0.0 2016/01/28 初版
  96. // ----------------------------------------------------------------------------
  97. // [Blog]   : https://triacontane.blogspot.jp/
  98. // [Twitter]: https://twitter.com/triacontane/
  99. // [GitHub] : https://github.com/triacontane/
  100. //=============================================================================
  101.  
  102. /*:
  103.  * @plugindesc Popup window plugin
  104.  * @author triacontane
  105.  *
  106.  * @param FontSize
  107.  * @desc Font size of popup window
  108.  * @default 22
  109.  * @type number
  110.  *
  111.  * @param Padding
  112.  * @desc Padding of popup window
  113.  * @default 10
  114.  * @type number
  115.  *
  116.  * @param AutoPopup
  117.  * @desc Popup set when event starting(ON/OFF)
  118.  * @default true
  119.  * @type boolean
  120.  *
  121.  * @param FaceScale
  122.  * @desc Scale of face graphic of popup window(1-100%)
  123.  * @default 75
  124.  * @type number
  125.  *
  126.  * @param WindowLinkage
  127.  * @desc Select window and Number input window is linkage with popup window(ON/OFF)
  128.  * @default true
  129.  * @type boolean
  130.  *
  131.  * @param BetweenLines
  132.  * @desc Between the Lines
  133.  * @default 4
  134.  * @type number
  135.  *
  136.  * @param ThroughWindow
  137.  * @desc Window through if overlap windows(ON/OFF)
  138.  * @default false
  139.  * @type boolean
  140.  *
  141.  * @param FontSizeRange
  142.  * @desc フキダシウィンドウで制御文字「\{」「\}」を使用した場合のフォントサイズの増減幅です。デフォルトは12です。
  143.  * @default 12
  144.  * @type number
  145.  *
  146.  * @param FontUpperLimit
  147.  * @desc フキダシウィンドウで制御文字「\{」「\}」を使用した場合のフォントサイズの上限値です。デフォルトは96です。
  148.  * @default 96
  149.  * @type number
  150.  *
  151.  * @param FontLowerLimit
  152.  * @desc フキダシウィンドウで制御文字「\{」「\}」を使用した場合のフォントサイズの下限値です。デフォルトは24です。
  153.  * @default 24
  154.  * @type number
  155.  *
  156.  * @param InnerScreen
  157.  * @desc 横方向だけでなく縦方向についても画面内にフキダシウィンドウが収まるように位置を調整します。
  158.  * @default false
  159.  * @type boolean
  160.  *
  161.  * @param ShakeSpeed
  162.  * @desc ウィンドウを振動させる際の速さです。制御文字\v[n]が利用できます。
  163.  * @default 5
  164.  * @type number
  165.  *
  166.  * @param ShakeDuration
  167.  * @desc ウィンドウを振動させる時間(フレーム)です。制御文字\v[n]が利用できます。0を指定するとずっと振動し続けます。
  168.  * @default 60
  169.  * @type number
  170.  *
  171.  * @param NoUseTail
  172.  * @desc ポーズサインのテール化機能を無効化します。デフォルトの位置に表示されます。
  173.  * @default false
  174.  * @type boolean
  175.  *
  176.  * @param MinWidthVariableId
  177.  * @desc 指定した番号の変数の値が、フキダシウィンドウの横幅の最小値(単位はピクセル数)となります。
  178.  * @default 0
  179.  * @type variable
  180.  *
  181.  * @param MinHeightVariableId
  182.  * @desc 指定した番号の変数の値が、フキダシウィンドウの高さの最小値(単位はピクセル数)となります。
  183.  * @default 0
  184.  * @type variable
  185.  *
  186.  * @param lowerLimitX
  187.  * @desc フキダシウィンドウの下限X座標です。
  188.  * @default 0
  189.  * @type number
  190.  *
  191.  * @param lowerLimitY
  192.  * @desc フキダシウィンドウの下限Y座標です。
  193.  * @default 0
  194.  * @type number
  195.  *
  196.  * @param upperLimitX
  197.  * @desc フキダシウィンドウの下限X座標です。
  198.  * @default 0
  199.  * @type number
  200.  *
  201.  * @param upperLimitY
  202.  * @desc フキダシウィンドウの下限Y座標です。
  203.  * @default 0
  204.  * @type number
  205.  *
  206.  * @param tailImage
  207.  * @desc テールに使う画像をピクチャから指定します。
  208.  * @default
  209.  * @require 1
  210.  * @dir img/system/
  211.  * @type file
  212.  *
  213.  * @help Change the message window from fixed to popup
  214.  *
  215.  * Plugin Command
  216.  *
  217.  * MWP_VALID [Character ID]
  218.  *  Popup window valid
  219.  *  Player:-1 Current event:0 Event:1...
  220.  * ex:MWP_VALID 0
  221.  *
  222.  * MWP_INVALID
  223.  *  Popup window invalid
  224.  * ex:MWP_INVALID
  225.  *
  226.  * MWP_FREE 100 200
  227.  * フキダシウィンドウフリー配置 100 200
  228.  * 指定した任意の位置にフキダシウィンドウを表示します。
  229.  *
  230.  * MWP_SETTING [parameter]
  231.  *  Popup window setting. parameter are...
  232.  *   POS_UPPER
  233.  *     Window position fixed upper.
  234.  *
  235.  *  POS_LOWER
  236.  *     Window position fixed upper.
  237.  *
  238.  *  POS_AUTO
  239.  *     Window position auto.
  240.  *
  241.  *   SKIN [File name(/img/system/...)]
  242.  *     Setting window skin for popup message.
  243.  *
  244.  *   SUB_POS_PLAYER
  245.  *     Choice window or NumberInput displays player.
  246.  *
  247.  *   SUB_POS_INNER
  248.  *     Choice window or NumberInput displays internal message window.
  249.  *
  250.  *   SUB_POS_NORMAL
  251.  *     Choice window or NumberInput displays normal position.
  252.  *
  253.  * MWP_ADJUST [parameter]
  254.  *   Popup window adjust. parameter are...
  255.  *
  256.  *   POS [X] [Y]
  257.  *     Popup window adjust relative position.
  258.  *
  259.  *  SIZE [Width] [Height]
  260.  *   Popup window adjust relative size.
  261.  *
  262.  * ・使用可能な制御文字
  263.  * \sh[5] # 強さ[5]でウィンドウを振動させます。
  264.  *
  265.  * This plugin is released under the MIT License.
  266.  */
  267. /*:ja
  268.  * @plugindesc フキダシウィンドウプラグイン
  269.  * @author トリアコンタン
  270.  *
  271.  * @param フォントサイズ
  272.  * @desc フキダシウィンドウのデフォルトフォントサイズ
  273.  * 通常ウィンドウのフォントサイズ:28
  274.  * @default 22
  275.  * @type number
  276.  *
  277.  * @param 余白
  278.  * @desc フキダシウィンドウの余白サイズ
  279.  * 通常ウィンドウの余白:18
  280.  * @default 10
  281.  * @type number
  282.  *
  283.  * @param 自動設定
  284.  * @desc イベント起動時にフキダシの対象が、起動したイベントに自動設定されます。(ON/OFF)
  285.  * OFFの場合は通常のメッセージウィンドウに設定されます。
  286.  * @default true
  287.  * @type boolean
  288.  *
  289.  * @param フェイス倍率
  290.  * @desc フキダシウィンドウの顔グラフィック表示倍率(1-100%)
  291.  * @default 75
  292.  * @type number
  293.  *
  294.  * @param ウィンドウ連携
  295.  * @desc 選択肢ウィンドウと数値入力ウィンドウを
  296.  * ポップアップウィンドウに連動させます。(ON/OFF)
  297.  * @default true
  298.  * @type boolean
  299.  *
  300.  * @param 行間
  301.  * @desc 行と行の間のスペースをピクセル単位で設定します。
  302.  * @default 4
  303.  * @type number
  304.  *
  305.  * @param ウィンドウ透過
  306.  * @desc ウィンドウが重なったときに透過表示します。(ON/OFF)
  307.  * 選択肢をフキダシ内に表示する場合はONにしてください。
  308.  * @default false
  309.  * @type boolean
  310.  *
  311.  * @param フォントサイズ増減幅
  312.  * @desc フキダシウィンドウで制御文字「\{」「\}」を使用した場合のフォントサイズの増減幅です。デフォルトは12です。
  313.  * @default 12
  314.  * @type number
  315.  *
  316.  * @param フォントサイズ上限
  317.  * @desc フキダシウィンドウで制御文字「\{」「\}」を使用した場合のフォントサイズの上限値です。デフォルトは96です。
  318.  * @default 96
  319.  * @type number
  320.  *
  321.  * @param フォントサイズ下限
  322.  * @desc フキダシウィンドウで制御文字「\{」「\}」を使用した場合のフォントサイズの下限値です。デフォルトは24です。
  323.  * @default 24
  324.  * @type number
  325.  *
  326.  * @param 画面内に収める
  327.  * @desc 横方向だけでなく縦方向についても画面内にフキダシウィンドウが収まるように位置を調整します。
  328.  * @default false
  329.  * @type boolean
  330.  *
  331.  * @param 振動の速さ
  332.  * @desc ウィンドウを振動させる際の速さです。制御文字\v[n]が利用できます。
  333.  * @default 5
  334.  * @type number
  335.  *
  336.  * @param 振動時間
  337.  * @desc ウィンドウを振動させる時間(フレーム)です。制御文字\v[n]が利用できます。0を指定するとずっと振動し続けます。
  338.  * @default 60
  339.  * @type number
  340.  *
  341.  * @param テールを使わない
  342.  * @desc ポーズサインのテール化機能を無効化します。デフォルトの位置に表示されます。
  343.  * @default false
  344.  * @type boolean
  345.  *
  346.  * @param 最小横幅取得変数ID
  347.  * @desc 指定した番号の変数の値が、フキダシウィンドウの横幅の最小値(単位はピクセル数)となります。
  348.  * @default 0
  349.  * @type variable
  350.  *
  351.  * @param 最小高さ取得変数ID
  352.  * @desc 指定した番号の変数の値が、フキダシウィンドウの高さの最小値(単位はピクセル数)となります。
  353.  * @default 0
  354.  * @type variable
  355.  *
  356.  * @param lowerLimitX
  357.  * @text 下限X座標
  358.  * @desc フキダシウィンドウの下限X座標です。
  359.  * @default 0
  360.  * @type number
  361.  *
  362.  * @param upperLimitX
  363.  * @text 上限X座標
  364.  * @desc フキダシウィンドウの上限X座標です。
  365.  * @default 0
  366.  * @type number
  367.  *
  368.  * @param lowerLimitY
  369.  * @text 下限Y座標
  370.  * @desc フキダシウィンドウの下限Y座標です。
  371.  * @default 0
  372.  * @type number
  373.  *
  374.  * @param upperLimitY
  375.  * @text 上限Y座標
  376.  * @desc フキダシウィンドウの上限Y座標です。
  377.  * @default 0
  378.  * @type number
  379.  *
  380.  * @param tailImage
  381.  * @text テール画像
  382.  * @desc テールに使う画像をシステム画像から指定します。
  383.  * @default
  384.  * @require 1
  385.  * @dir img/system/
  386.  * @type file
  387.  *
  388.  * @param tailImageAdjustY
  389.  * @text テール画像Y座標
  390.  * @desc テールに使う画像のY座標補正値です。
  391.  * @default 0
  392.  * @type number
  393.  * @min -2000
  394.  * @max 2000
  395.  *
  396.  * @help メッセージウィンドウを指定したキャラクターの頭上にフキダシで
  397.  * 表示するよう変更します。
  398.  *
  399.  * YEP_MessageCore.jsのネームポップと併せて使用する場合は、
  400.  * プラグイン管理画面で当プラグインをYEP_MessageCore.jsより
  401.  * 下に配置してください。
  402.  *
  403.  * また、FTKR_ExMessageWindow2.jsの複数メッセージウィンドウ表示と
  404.  * 併せて使用する場合は、プラグイン管理画面で当プラグインを
  405.  * FTKR_ExMessageWindow2.jsより下に配置してください。
  406.  *
  407.  *
  408.  * プラグインパラメータ[自動設定]詳細
  409.  * FTKR_ExMessageWindow2.jsと併用する場合、
  410.  * 自動設定で使用するメッセージウィンドウは、ウィンドウID0 です。
  411.  * OFFの場合、ウィンドウID0 を通常の表示方法に戻します。
  412.  *
  413.  *
  414.  * プラグインコマンド詳細
  415.  *  イベントコマンド「プラグインコマンド」から実行。
  416.  *  (パラメータの間は半角スペースで区切る)
  417.  *
  418.  * MWP_VALID [キャラクターID] [ウィンドウ位置] or
  419.  * フキダシウィンドウ有効化 [キャラクターID] [ウィンドウ位置]
  420.  *  メッセージウィンドウを指定したキャラクターIDの頭上に表示します。
  421.  *  プレイヤー : -1 このイベント : 0 指定したIDのイベント : 1 ~
  422.  *  フォロワー : -2, -3, -4
  423.  *
  424.  *  ウィンドウ位置
  425.  *   0 : 自動(指定しなかった場合も含む)
  426.  *   1 : キャラクターの上に表示
  427.  *   2 : キャラクターの下に表示
  428.  *
  429.  * 例:MWP_VALID 0 1
  430.  *   フキダシウィンドウ有効化 3 1
  431.  *
  432.  * MWP_VALID [イベント名] [ウィンドウ位置] or
  433.  * フキダシウィンドウ有効化 [イベント名] [ウィンドウ位置]
  434.  *  メッセージウィンドウを指定した名称と一致するイベントの頭上に表示します。
  435.  *
  436.  * 例:MWP_VALID test_event 1
  437.  *   フキダシウィンドウ有効化 テストイベント 2
  438.  *
  439.  * !複数メッセージウィンドウ表示を使う場合!
  440.  * MWP_VALID [キャラクターID] [ウィンドウID] [ウィンドウ位置] or
  441.  * フキダシウィンドウ有効化 [キャラクターID] [ウィンドウID] [ウィンドウ位置]
  442.  *  指定したメッセージウィンドウIDを指定したキャラクターIDの頭上に表示するようにします。
  443.  *  プレイヤー : -1 このイベント : 0 指定したIDのイベント : 1 ~
  444.  *  フォロワー : -2, -3, -4
  445.  *  ウィンドウIDを指定しない(入力なし)場合は、ウィンドウID0を使用します。
  446.  *
  447.  * 例:MWP_VALID 0 1
  448.  *   フキダシウィンドウ有効化 3 2
  449.  *
  450.  * MWP_INVALID or
  451.  * フキダシウィンドウ無効化
  452.  *  ウィンドウの表示方法を通常に戻します。
  453.  *
  454.  * 例:MWP_INVALID
  455.  *   フキダシウィンドウ無効化
  456.  *
  457.  * !複数メッセージウィンドウ表示を使う場合!
  458.  * MWP_INVALID [ウィンドウID]
  459.  * フキダシウィンドウ無効化 [ウィンドウID]
  460.  *  指定したメッセージウィンドウIDの表示方法を通常に戻します。
  461.  *  入力無しはすべてのウィンドウIDの表示方法を通常に戻します。
  462.  *
  463.  * 例:MWP_INVALID 1
  464.  *   フキダシウィンドウ無効化 2
  465.  *   フキダシウィンドウ無効化
  466.  *
  467.  * MWP_FREE 100 200
  468.  * フキダシウィンドウフリー配置 100 200
  469.  * 指定した任意の位置にフキダシウィンドウを表示します。
  470.  *
  471.  * MWP_SETTING [設定内容] or
  472.  * フキダシウィンドウ設定 [設定内容]
  473.  *  フキダシウィンドウの設定を行います。設定内容に以下を入力。
  474.  *
  475.  *   POS_UPPER or 位置_上固定
  476.  *   ウィンドウの位置をキャラクターの上で固定します。
  477.  *
  478.  *   POS_UPPER 1 or 位置_上固定 1
  479.  *   イベントID[1]のみウィンドウの位置をキャラクターの上で固定します。
  480.  *
  481.  *   POS_UPPER aaa or 位置_上固定 aaa
  482.  *   イベント名[aaa]のみウィンドウの位置をキャラクターの上で固定します。
  483.  *
  484.  *   POS_LOWER or 位置_下固定
  485.  *   ウィンドウの位置をキャラクターの下で固定します。
  486.  *
  487.  *   POS_LOWER -1 or 位置_下固定 -1
  488.  *   プレイヤーのみウィンドウの位置をキャラクターの下で固定します。
  489.  *
  490.  *   POS_LOWER aaa or 位置_下固定 aaa
  491.  *   イベント名[aaa]のみウィンドウの位置をキャラクターの下で固定します。
  492.  *
  493.  *   POS_AUTO or 位置_自動
  494.  *   通常はキャラクターの上に表示し、ウィンドウが上に見切れる場合のみ
  495.  *   下に表示します。
  496.  *
  497.  *   SKIN or スキン [/img/system/以下に配置するスキンのファイル名]
  498.  *     フキダシウィンドウ時専用のウィンドウスキンを設定します。
  499.  *
  500.  *   SUB_POS_PLAYER or サブ位置_プレイヤーの頭上
  501.  *    選択肢および数値入力のウィンドウをプレイヤーの頭上に表示します。
  502.  *    位置関係次第でウィンドウが被る場合があるので、必要に応じて
  503.  *    ウィンドウ透過のパラメータを有効にしてください。
  504.  *
  505.  *   SUB_POS_INNER or サブ位置_メッセージウィンドウ内部
  506.  *     選択肢および数値入力のウィンドウをメッセージウィンドウに含めます。
  507.  *     この設定を使用する場合は必ずウィンドウ透過のパラメータを
  508.  *     有効にしてください。
  509.  *
  510.  *   SUB_POS_NORMAL or サブ位置_通常
  511.  *    選択肢および数値入力のウィンドウをフキダシウィンドウの下に表示します。
  512.  *    特に設定を変更しない場合はこの設定になります。
  513.  *
  514.  *   SUB_POS_RIGHT or サブ位置_右
  515.  *    選択肢および数値入力のウィンドウをフキダシウィンドウのテール部分の
  516.  *    右側に表示します。
  517.  *
  518.  * 例:MWP_SETTING POS_UPPER
  519.  *   フキダシウィンドウ設定 位置_自動
  520.  *   MWP_SETTING SKIN window2
  521.  *   フキダシウィンドウ設定 サブ位置_プレイヤーの頭上
  522.  *
  523.  * MWP_ADJUST [設定内容] or
  524.  * フキダシウィンドウ調整 [設定内容]
  525.  *  フキダシウィンドウの表示位置やサイズを微調整します。設定内容に以下を入力。
  526.  *
  527.  *  POS or 位置 [X座標] [Y座標]
  528.  *   ウィンドウのX座標とY座標を調整します。指定するのは元の座標からの相対です。
  529.  *
  530.  *  SIZE or サイズ [横幅] [高さ]
  531.  *   ウィンドウの横幅と高さを調整します。指定するのは元のサイズからの相対です。
  532.  *
  533.  * 例:MWP_ADJUST POS 5 -3
  534.  *   フキダシウィンドウ調整 サイズ 20 -40
  535.  *
  536.  * !複数メッセージウィンドウ表示を使う場合!
  537.  * フキダシウィンドウの設定や表示位置、サイズの調整結果は
  538.  * すべてのウィンドウIDで共通です。
  539.  *
  540.  * ・使用可能な制御文字
  541.  * \sh[5] # 強さ[5]でウィンドウを振動させます。
  542.  *
  543.  * 利用規約:
  544.  *  作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)
  545.  *  についても制限はありません。
  546.  *  このプラグインはもうあなたのものです。
  547.  */
  548.  
  549. (function() {
  550.     'use strict';
  551.     var pluginName = 'MessageWindowPopup';
  552.  
  553.     var checkTypeFunction = function(value) {
  554.         return checkType(value, 'Function');
  555.     };
  556.  
  557.     var checkType = function(value, typeName) {
  558.         return Object.prototype.toString.call(value).slice(8, -1) === typeName;
  559.     };
  560.  
  561.     var getParamNumber = function(paramNames, min, max) {
  562.         var value = getParamString(paramNames);
  563.         if (arguments.length < 2) min = -Infinity;
  564.         if (arguments.length < 3) max = Infinity;
  565.         return (parseInt(value) || 0).clamp(min, max);
  566.     };
  567.  
  568.     var getParamBoolean = function(paramNames) {
  569.         var value = getParamString(paramNames);
  570.         return (value || '').toUpperCase() === 'ON' || (value || '').toUpperCase() === 'TRUE';
  571.     };
  572.  
  573.     var getParamString = function(paramNames) {
  574.         if (!Array.isArray(paramNames)) paramNames = [paramNames];
  575.         for (var i = 0; i < paramNames.length; i++) {
  576.             var name = PluginManager.parameters(pluginName)[paramNames[i]];
  577.             if (name) return name;
  578.         }
  579.         return null;
  580.     };
  581.  
  582.     var getArgNumber = function(arg, min, max) {
  583.         if (arguments.length <= 2) min = -Infinity;
  584.         if (arguments.length <= 3) max = Infinity;
  585.         return (parseInt(convertEscapeCharacters(arg)) || 0).clamp(min, max);
  586.     };
  587.  
  588.     var getArgString = function(arg, upperFlg) {
  589.         arg = convertEscapeCharacters(arg);
  590.         return upperFlg ? arg.toUpperCase() : arg;
  591.     };
  592.  
  593.     var getCommandName = function(command) {
  594.         return (command || '').toUpperCase();
  595.     };
  596.  
  597.     var convertEscapeCharacters = function(text) {
  598.         if (text == null) text = '';
  599.         var window = SceneManager._scene._windowLayer.children[0];
  600.         return window ? window.convertEscapeCharacters(text) : text;
  601.     };
  602.  
  603.     //FTKR_ExMessageWindow2.jsを使用しているか
  604.     var imported_FTKR_EMW = function() {
  605.         return typeof Imported !== 'undefined' && Imported.FTKR_EMW;
  606.     };
  607.  
  608.     var isExistPlugin = function(pluginName) {
  609.         return Object.keys(PluginManager.parameters(pluginName)).length > 0;
  610.     };
  611.  
  612.     //=============================================================================
  613.     // パラメータのバリデーション
  614.     //=============================================================================
  615.     var paramThroughWindow       = getParamBoolean(['ThroughWindow', 'ウィンドウ透過']);
  616.     var paramFaceScale           = getParamNumber(['FaceScale', 'フェイス倍率'], 1, 100);
  617.     var paramFontSize            = getParamNumber(['FontSize', 'フォントサイズ'], 1);
  618.     var paramPadding             = getParamNumber(['Padding', '余白'], 1);
  619.     var paramLinkage             = getParamBoolean(['WindowLinkage', 'ウィンドウ連携']);
  620.     var paramBetweenLines        = getParamNumber(['BetweenLines', '行間'], 0);
  621.     var paramAutoPopup           = getParamBoolean(['AutoPopup', '自動設定']);
  622.     var paramFontSizeRange       = getParamNumber(['FontSizeRange', 'フォントサイズ増減幅'], 0);
  623.     var paramFontUpperLimit      = getParamNumber(['FontUpperLimit', 'フォントサイズ上限'], 0);
  624.     var paramFontLowerLimit      = getParamNumber(['FontLowerLimit', 'フォントサイズ下限'], 0);
  625.     var paramInnerScreen         = getParamBoolean(['InnerScreen', '画面内に収める']);
  626.     var paramShakeSpeed          = getParamString(['ShakeSpeed', '振動の速さ']);
  627.     var paramShakeDuration       = getParamString(['ShakeDuration', '振動時間']);
  628.     var paramNoUseTail           = getParamBoolean(['NoUseTail', 'テールを使わない']);
  629.     var paramMinWidthVariableId  = getParamNumber(['MinWidthVariableId', '最小横幅取得変数ID']);
  630.     var paramMinHeightVariableId = getParamNumber(['MinHeightVariableId', '最小高さ取得変数ID']);
  631.     var paramLowerLimitX         = getParamNumber(['lowerLimitX']);
  632.     var paramUpperLimitX         = getParamNumber(['upperLimitX']);
  633.     var paramLowerLimitY         = getParamNumber(['lowerLimitY']);
  634.     var paramUpperLimitY         = getParamNumber(['upperLimitY']);
  635.     var paramTailImage           = getParamString(['tailImage']);
  636.     var paramTailImageAdjustY    = getParamNumber(['tailImageAdjustY']);
  637.  
  638.     //=============================================================================
  639.     // Game_Interpreter
  640.     //  プラグインコマンドを追加定義します。
  641.     //=============================================================================
  642.     var _Game_Interpreter_pluginCommand      = Game_Interpreter.prototype.pluginCommand;
  643.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
  644.         _Game_Interpreter_pluginCommand.apply(this, arguments);
  645.         this.pluginCommandMessageWindowPopup(command, args);
  646.     };
  647.  
  648.     Game_Interpreter.prototype.pluginCommandMessageWindowPopup = function(command, args) {
  649.         switch (getCommandName(command)) {
  650.             case 'MWP_VALID' :
  651.             case 'フキダシウィンドウ有効化':
  652.                 $gameSystem.clearMessagePopupFree();
  653.                 var eventId = this.getEventIdForMessagePopup(args[0]);
  654.                 if (isNaN(eventId)) {
  655.                     eventId = this.getEventIdFromEventName(eventId);
  656.                 }
  657.                 $gameSystem.setMessagePopup(eventId);
  658.                 var windowPosition;
  659.                 if (imported_FTKR_EMW() && args[1]) {
  660.                     var windowId = getArgNumber(args[1]);
  661.                     if (windowId >= 0) $gameSystem.setMessagePopupEx(windowId, eventId);
  662.                     windowPosition = getArgNumber(args[2]);
  663.                 } else {
  664.                     windowPosition = getArgNumber(args[1]);
  665.                 }
  666.                 if (windowPosition === 1) {
  667.                     $gameSystem.setPopupFixUpper(eventId);
  668.                 } else if (windowPosition === 2) {
  669.                     $gameSystem.setPopupFixLower(eventId);
  670.                 }
  671.                 break;
  672.             case 'MWP_FREE' :
  673.             case 'フキダシウィンドウフリー配置':
  674.                 var x = getArgNumber(args[0]) || 0;
  675.                 var y = getArgNumber(args[1]) || 0;
  676.                 $gameSystem.setMessagePopupFree(x, y);
  677.                 break;
  678.             case 'MWP_INVALID':
  679.             case 'フキダシウィンドウ無効化':
  680.                 $gameSystem.clearMessagePopupFree();
  681.                 if (imported_FTKR_EMW() && args[0]) {
  682.                     var windowId2 = getArgNumber(args[0]);
  683.                     if (windowId2 >= 0) $gameSystem.clearMessagePopupEx(windowId2);
  684.                 } else {
  685.                     $gameSystem.clearMessagePopup();
  686.                 }
  687.                 break;
  688.             case 'MWP_SETTING' :
  689.             case 'フキダシウィンドウ設定':
  690.                 switch (getCommandName(args[0])) {
  691.                     case 'POS_UPPER' :
  692.                     case '位置_上固定':
  693.                         $gameSystem.setPopupFixUpper(args[1] ? this.getEventIdForMessagePopup(args[1]) : null);
  694.                         break;
  695.                     case 'POS_LOWER' :
  696.                     case '位置_下固定':
  697.                         $gameSystem.setPopupFixLower(args[1] ? this.getEventIdForMessagePopup(args[1]) : null);
  698.                         break;
  699.                     case 'POS_AUTO' :
  700.                     case '位置_自動':
  701.                         $gameSystem.setPopupAuto(args[1] ? this.getEventIdForMessagePopup(args[1]) : null);
  702.                         break;
  703.                     case 'SKIN' :
  704.                     case 'スキン' :
  705.                         $gameSystem.setPopupWindowSkin(getArgString(args[1]));
  706.                         this.setWaitMode('image');
  707.                         break;
  708.                     case 'SUB_POS_NORMAL' :
  709.                     case 'サブ位置_通常':
  710.                         $gameSystem.setPopupSubWindowPosition(0);
  711.                         break;
  712.                     case 'SUB_POS_PLAYER' :
  713.                     case 'サブ位置_プレイヤーの頭上':
  714.                         $gameSystem.setPopupSubWindowPosition(1);
  715.                         break;
  716.                     case 'SUB_POS_INNER' :
  717.                     case 'サブ位置_メッセージウィンドウ内部':
  718.                         $gameSystem.setPopupSubWindowPosition(2);
  719.                         break;
  720.                     case 'SUB_POS_RIGHT' :
  721.                     case 'サブ位置_右':
  722.                         $gameSystem.setPopupSubWindowPosition(3);
  723.                         break;
  724.                 }
  725.                 break;
  726.             case 'MWP_ADJUST':
  727.             case 'フキダシウィンドウ調整':
  728.                 switch (getCommandName(args[0])) {
  729.                     case 'SIZE' :
  730.                     case 'サイズ':
  731.                         $gameSystem.setPopupAdjustSize(getArgNumber(args[1]), getArgNumber(args[2]));
  732.                         break;
  733.                     case 'POS' :
  734.                     case '位置':
  735.                         $gameSystem.setPopupAdjustPosition(getArgNumber(args[1]), getArgNumber(args[2]));
  736.                         break;
  737.                 }
  738.                 break;
  739.         }
  740.     };
  741.  
  742.     Game_Interpreter.prototype.getEventIdForMessagePopup = function(arg) {
  743.         var convertedArg = convertEscapeCharacters(arg);
  744.         var eventId      = parseInt(convertedArg);
  745.         if (isNaN(eventId)) {
  746.             return convertedArg;
  747.         }
  748.         if (eventId === 0) {
  749.             eventId = this.eventId() || ($gameMap.isEventRunning() ? $gameMap._interpreter.eventId() : 0);
  750.         }
  751.         return eventId;
  752.     };
  753.  
  754.     Game_Interpreter.prototype.getEventIdFromEventName = function(eventName) {
  755.         var eventId = 0;
  756.         $gameMap.events().some(function(event) {
  757.             if (event.event().name === eventName) {
  758.                 eventId = event.eventId();
  759.                 return true;
  760.             }
  761.             return false;
  762.         });
  763.         return eventId;
  764.     };
  765.  
  766.     var _Game_Interpreter_terminate      = Game_Interpreter.prototype.terminate;
  767.     Game_Interpreter.prototype.terminate = function() {
  768.         _Game_Interpreter_terminate.apply(this, arguments);
  769.         if (this._depth === 0 && this.isGameMapInterpreter()) {
  770.             if (imported_FTKR_EMW()) {
  771.                 $gameSystem.clearMessagePopupEx(this.windowId());
  772.             } else {
  773.                 $gameSystem.clearMessagePopup();
  774.             }
  775.         }
  776.     };
  777.  
  778.     Game_Interpreter.prototype.setGameMapInterpreter = function() {
  779.         this._gameMapInterpreter = true;
  780.     };
  781.  
  782.     Game_Interpreter.prototype.isGameMapInterpreter = function() {
  783.         return this._gameMapInterpreter;
  784.     };
  785.  
  786.     //=============================================================================
  787.     // Game_System
  788.     //  ポップアップフラグを保持します。
  789.     //=============================================================================
  790.     var _Game_System_initialize      = Game_System.prototype.initialize;
  791.     Game_System.prototype.initialize = function() {
  792.         _Game_System_initialize.apply(this, arguments);
  793.         this._messagePopupCharacterId       = 0;
  794.         this._messagePopupPosition          = null;
  795.         this._messagePopupAdjustSize        = null;
  796.         this._messagePopupAdjustPosition    = null;
  797.         this._messagePopupWindowSkin        = null;
  798.         this._messagePopupSubWindowPosition = 0;
  799.     };
  800.  
  801.     Game_System.prototype.initMessagePositionEvents = function() {
  802.         if (!this._messagePopupPositionEvents) {
  803.             this._messagePopupPositionEvents = [];
  804.         }
  805.     };
  806.  
  807.     Game_System.prototype.setPopupSubWindowPosition = function(position) {
  808.         this._messagePopupSubWindowPosition = position.clamp(0, 3);
  809.     };
  810.  
  811.     Game_System.prototype.getPopupSubWindowPosition = function() {
  812.         return this._messagePopupSubWindowPosition;
  813.     };
  814.  
  815.     Game_System.prototype.setPopupWindowSkin = function(fileName) {
  816.         this._messagePopupWindowSkin = fileName;
  817.         ImageManager.loadSystem(fileName);
  818.     };
  819.  
  820.     Game_System.prototype.getPopupWindowSkin = function() {
  821.         return this._messagePopupWindowSkin;
  822.     };
  823.  
  824.     Game_System.prototype.setMessagePopup = function(id) {
  825.         this._messagePopupCharacterId = id;
  826.     };
  827.  
  828.     Game_System.prototype.clearMessagePopup = function() {
  829.         this._messagePopupCharacterId    = 0;
  830.         this._messagePopupPositionEvents = [];
  831.     };
  832.  
  833.     Game_System.prototype.setMessagePopupFree = function(x, y) {
  834.         this._messagePopupFreeX       = x;
  835.         this._messagePopupFreeY       = y;
  836.         this._messagePopupCharacterId = 1;
  837.     };
  838.  
  839.     Game_System.prototype.clearMessagePopupFree = function() {
  840.         this.setMessagePopupFree(undefined, undefined);
  841.     };
  842.  
  843.     Game_System.prototype.getMessagePopupId = function() {
  844.         return this._messagePopupCharacterId !== 0 ? this._messagePopupCharacterId : null;
  845.     };
  846.  
  847.     Game_System.prototype.getMessagePopupFree = function() {
  848.         if (this._messagePopupFreeX === undefined || this._messagePopupFreeY === undefined) {
  849.             return null;
  850.         }
  851.         return {x: this._messagePopupFreeX, y: this._messagePopupFreeY};
  852.     };
  853.  
  854.     Game_System.prototype.setPopupFixUpper = function(characterId) {
  855.         this.setPopupFixPosition(characterId, 1);
  856.     };
  857.  
  858.     Game_System.prototype.setPopupFixLower = function(characterId) {
  859.         this.setPopupFixPosition(characterId, 2);
  860.     };
  861.  
  862.     Game_System.prototype.setPopupAuto = function(characterId) {
  863.         this.setPopupFixPosition(characterId, 0);
  864.     };
  865.  
  866.     Game_System.prototype.setPopupFixPosition = function(characterId, position) {
  867.         if (characterId !== null) {
  868.             this.initMessagePositionEvents();
  869.             this._messagePopupPositionEvents[characterId] = position;
  870.         } else {
  871.             this._messagePopupPosition = position;
  872.         }
  873.     };
  874.  
  875.     Game_System.prototype.setPopupAdjustSize = function(w, h) {
  876.         this._messagePopupAdjustSize = [w, h];
  877.     };
  878.  
  879.     Game_System.prototype.getPopupAdjustSize = function() {
  880.         return this._messagePopupAdjustSize;
  881.     };
  882.  
  883.     Game_System.prototype.setPopupAdjustPosition = function(x, y) {
  884.         this._messagePopupAdjustPosition = [x, y];
  885.     };
  886.  
  887.     Game_System.prototype.getPopupAdjustPosition = function() {
  888.         return this._messagePopupAdjustPosition;
  889.     };
  890.  
  891.     Game_System.prototype.isPopupFixUpper = function(eventId) {
  892.         return this.isPopupFixPosition(1, eventId);
  893.     };
  894.  
  895.     Game_System.prototype.isPopupFixLower = function(eventId) {
  896.         return this.isPopupFixPosition(2, eventId);
  897.     };
  898.  
  899.     Game_System.prototype.isPopupFixPosition = function(position, eventId) {
  900.         var id = eventId || this._messagePopupCharacterId;
  901.         this.initMessagePositionEvents();
  902.         var positionFixForId   = this._messagePopupPositionEvents[id];
  903.         var event              = $gameMap.event(id);
  904.         var positionFixForName = event ? this._messagePopupPositionEvents[event.event().name] : 0;
  905.         if (positionFixForId > 0) {
  906.             return positionFixForId === position;
  907.         } else if (positionFixForName > 0) {
  908.             return positionFixForName === position;
  909.         } else {
  910.             return this._messagePopupPosition === position;
  911.         }
  912.     };
  913.  
  914.     //=============================================================================
  915.     // Game_Map
  916.     //  イベント起動時に自動設定を適用します。
  917.     //=============================================================================
  918.     var _Game_Map_setupStartingMapEvent      = Game_Map.prototype.setupStartingMapEvent;
  919.     Game_Map.prototype.setupStartingMapEvent = function() {
  920.         var result = _Game_Map_setupStartingMapEvent.apply(this, arguments);
  921.         if (result) {
  922.             if (paramAutoPopup) {
  923.                 $gameSystem.setMessagePopup(this._interpreter.eventId());
  924.             } else if (imported_FTKR_EMW()) {
  925.                 $gameSystem.clearMessagePopupEx(0);
  926.             } else {
  927.                 $gameSystem.clearMessagePopup();
  928.             }
  929.         }
  930.         return result;
  931.     };
  932.  
  933.     var _Game_Map_setup      = Game_Map.prototype.setup;
  934.     Game_Map.prototype.setup = function(mapId) {
  935.         _Game_Map_setup.apply(this, arguments);
  936.         this._interpreter.setGameMapInterpreter();
  937.     };
  938.  
  939.     //=============================================================================
  940.     // Game_Troop
  941.     //  戦闘開始時にポップアップフラグを解除します。
  942.     //=============================================================================
  943.     var _Game_Troop_setup      = Game_Troop.prototype.setup;
  944.     Game_Troop.prototype.setup = function(troopId) {
  945.         _Game_Troop_setup.apply(this, arguments);
  946.         $gameSystem.clearMessagePopup();
  947.     };
  948.  
  949.     //=============================================================================
  950.     // Game_CharacterBase
  951.     //  キャラクターの高さを設定します。
  952.     //=============================================================================
  953.     var _Game_CharacterBase_initMembers      = Game_CharacterBase.prototype.initMembers;
  954.     Game_CharacterBase.prototype.initMembers = function() {
  955.         _Game_CharacterBase_initMembers.apply(this, arguments);
  956.         this.setSizeForMessagePopup(0, 0);
  957.     };
  958.  
  959.     Game_CharacterBase.prototype.setSizeForMessagePopup = function(width, height) {
  960.         this._size = [width, height];
  961.     };
  962.  
  963.     Game_CharacterBase.prototype.getHeightForPopup = function() {
  964.         return $gameScreen.zoomScale() * this._size[1];
  965.     };
  966.  
  967.     Game_CharacterBase.prototype.getRealScreenX = function() {
  968.         return $gameScreen.convertRealX(this.screenX());
  969.     };
  970.  
  971.     Game_CharacterBase.prototype.getRealScreenY = function() {
  972.         return $gameScreen.convertRealY(this.screenY());
  973.     };
  974.  
  975.     //=============================================================================
  976.     // Game_Screen
  977.     //  画面座標をズームを考慮した座標に変換します。
  978.     //=============================================================================
  979.     Game_Screen.prototype.convertRealX = function(x) {
  980.         var scale = this.zoomScale();
  981.         return scale * x - (scale - 1.0) * this.zoomX();
  982.     };
  983.  
  984.     Game_Screen.prototype.convertRealY = function(y) {
  985.         var scale = this.zoomScale();
  986.         return scale * y - (scale - 1.0) * this.zoomY();
  987.     };
  988.  
  989.     //=============================================================================
  990.     // Scene_Map
  991.     //  ポップアップ用のウィンドウスキンをロードします。
  992.     //=============================================================================
  993.     var _Scene_Map_isReady      = Scene_Map.prototype.isReady;
  994.     Scene_Map.prototype.isReady = function() {
  995.         var ready   = _Scene_Map_isReady.apply(this, arguments);
  996.         var popSkin = $gameSystem.getPopupWindowSkin();
  997.         if (popSkin && ready) {
  998.             var bitmap = ImageManager.loadSystem(popSkin);
  999.             return bitmap.isReady();
  1000.         }
  1001.         return ready;
  1002.     };
  1003.  
  1004.     //=============================================================================
  1005.     // Sprite_Character
  1006.     //  キャラクターの高さを逆設定します。
  1007.     //=============================================================================
  1008.     var _Sprite_Character_updateBitmap      = Sprite_Character.prototype.updateBitmap;
  1009.     Sprite_Character.prototype.updateBitmap = function() {
  1010.         if (this.isImageChanged()) this._imageChange = true;
  1011.         _Sprite_Character_updateBitmap.apply(this, arguments);
  1012.         if (this._imageChange) {
  1013.             this.bitmap.addLoadListener(function() {
  1014.                 var width  = this.bitmap.width === 1 ? $gameMap.tileWidth() : this.patternWidth();
  1015.                 var height = this.bitmap.height === 1 ? $gameMap.tileHeight() : this.patternHeight();
  1016.                 this._character.setSizeForMessagePopup(width, height);
  1017.             }.bind(this));
  1018.             this._imageChange = false;
  1019.         }
  1020.     };
  1021.  
  1022.     //=============================================================================
  1023.     // Window_Base
  1024.     //  共通処理を定義します。
  1025.     //=============================================================================
  1026.     var _Window_Base_loadWindowskin      = Window_Base.prototype.loadWindowskin;
  1027.     Window_Base.prototype.loadWindowskin = function() {
  1028.         var popSkin = $gameSystem.getPopupWindowSkin();
  1029.         if (this.isPopup() && popSkin) {
  1030.             this.windowskin = ImageManager.loadSystem(popSkin);
  1031.         } else {
  1032.             _Window_Base_loadWindowskin.apply(this, arguments);
  1033.         }
  1034.     };
  1035.  
  1036.     Window_Base.prototype.setPauseSignToTail = function(lowerFlg) {
  1037.         if (lowerFlg) {
  1038.             this._windowPauseSignSprite.rotation = 180 * Math.PI / 180;
  1039.             this._windowPauseSignSprite.y        = 12;
  1040.             this._windowPauseSignSprite.anchor.y = 0;
  1041.         } else {
  1042.             this._windowPauseSignSprite.rotation = 0;
  1043.             this._windowPauseSignSprite.y        = this.height + 12;
  1044.             this._windowPauseSignSprite.anchor.y = 1;
  1045.         }
  1046.         this._pauseSignLower  = lowerFlg;
  1047.         this._pauseSignToTail = true;
  1048.     };
  1049.  
  1050.     Window_Base.prototype.setPauseSignImageToTail = function(lowerFlg) {
  1051.         this._windowPauseSignSprite.visible = false;
  1052.         if (lowerFlg) {
  1053.             this._messageTailImage.rotation = 180 * Math.PI / 180;
  1054.             this._messageTailImage.y        = -paramTailImageAdjustY;
  1055.             this._messageTailImage.anchor.y = 0;
  1056.         } else {
  1057.             this._messageTailImage.rotation = 0;
  1058.             this._messageTailImage.y        = this.height + paramTailImageAdjustY;
  1059.             this._messageTailImage.anchor.y = 0;
  1060.         }
  1061.     };
  1062.  
  1063.     Window_Base.prototype.setPauseSignToNormal = function() {
  1064.         this._windowPauseSignSprite.rotation = 0;
  1065.         this._windowPauseSignSprite.anchor.y = 1.0;
  1066.         this._windowPauseSignSprite.move(this._width / 2, this._height);
  1067.         this._pauseSignToTail = false;
  1068.     };
  1069.  
  1070.     var _Window_Base_updatePauseSign       = Window_Base.prototype._updatePauseSign;
  1071.     Window_Base.prototype._updatePauseSign = function() {
  1072.         _Window_Base_updatePauseSign.apply(this, arguments);
  1073.         if (this._pauseSignToTail) this._windowPauseSignSprite.alpha = 1.0;
  1074.     };
  1075.  
  1076.     Window_Base.prototype.isPopupLower = function() {
  1077.         return $gameSystem.isPopupFixLower() || (!$gameSystem.isPopupFixUpper() && this.y < 0);
  1078.     };
  1079.  
  1080.     Window_Base.prototype.setPopupPosition = function(character) {
  1081.         this._popupCharacter = character;
  1082.         this._popupFreePos   = $gameSystem.getMessagePopupFree();
  1083.         this.setPopupBasePosition();
  1084.         this.setPopupLowerPosition();
  1085.         this.setPopupAdjustInnerScreen();
  1086.         if (this._shakePower > 0) {
  1087.             this.setPopupShakePosition();
  1088.         }
  1089.     };
  1090.  
  1091.     Window_Base.prototype.getPopupBaseX = function() {
  1092.         return this._popupFreePos ? this._popupFreePos.x : this._popupCharacter.getRealScreenX();
  1093.     };
  1094.  
  1095.     Window_Base.prototype.getPopupBaseY = function() {
  1096.         return this._popupFreePos ? this._popupFreePos.y : this._popupCharacter.getRealScreenY();
  1097.     };
  1098.  
  1099.     Window_Base.prototype.getHeightForPopup = function() {
  1100.         return this._popupFreePos ? 0 : (this._popupCharacter.getHeightForPopup() + 8);
  1101.     };
  1102.  
  1103.     Window_Base.prototype.setPopupBasePosition = function() {
  1104.         var pos = $gameSystem.getPopupAdjustPosition();
  1105.         this.x  = this.getPopupBaseX() - this.width / 2 + (pos ? pos[0] : 0);
  1106.         this.y  = this.getPopupBaseY() - this.height - this.getHeightForPopup() + (pos ? pos[1] : 0);
  1107.     };
  1108.  
  1109.     Window_Base.prototype.setPopupShakePosition = function() {
  1110.         var duration = getArgNumber(paramShakeDuration);
  1111.         if (duration && this._shakeCount > duration) {
  1112.             this.setWindowShake(0);
  1113.         }
  1114.         var speed    = getArgNumber(paramShakeSpeed, 1);
  1115.         var position = Math.sin(this._shakeCount / 10 * speed) * this._shakePower;
  1116.         this.x += position;
  1117.         this._windowPauseSignSprite.x -= position;
  1118.         this._messageTailImage.x -= position;
  1119.         this._shakeCount++;
  1120.     };
  1121.  
  1122.     Window_Base.prototype.setPopupLowerPosition = function() {
  1123.         var lowerFlg = this.isPopupLower();
  1124.         if (lowerFlg) {
  1125.             this.y += this.height + this.getHeightForPopup() + 8;
  1126.         }
  1127.         if (!paramNoUseTail && !this.isUsePauseSignTextEnd()) {
  1128.             this.setPauseSignToTail(lowerFlg);
  1129.         }
  1130.         if (paramTailImage) {
  1131.             this.setPauseSignImageToTail(lowerFlg);
  1132.         }
  1133.     };
  1134.  
  1135.     Window_Base.prototype.setPopupAdjustInnerScreen = function() {
  1136.         if (paramInnerScreen) {
  1137.             this.adjustPopupPositionY();
  1138.         }
  1139.         var adjustResultX = this.adjustPopupPositionX();
  1140.         var tailX = this._width / 2 + adjustResultX;
  1141.         if (!this.isUsePauseSignTextEnd()) {
  1142.             this._windowPauseSignSprite.x = tailX
  1143.         }
  1144.         this._messageTailImage.x = tailX;
  1145.     };
  1146.  
  1147.     Window_Base.prototype.setWindowShake = function(power) {
  1148.         this._shakePower = power;
  1149.         this._shakeCount = 0;
  1150.     };
  1151.  
  1152.     Window_Base.prototype.adjustPopupPositionX = function() {
  1153.         var deltaX = 0;
  1154.         var minX   = paramLowerLimitX || 0;
  1155.         var maxX   = paramUpperLimitX || Graphics.boxWidth;
  1156.         if (this.x < minX) {
  1157.             deltaX = this.x - minX;
  1158.             this.x = minX;
  1159.         }
  1160.         if (this.x + this.width > maxX) {
  1161.             deltaX = this.x + this.width - maxX;
  1162.             this.x = maxX - this.width;
  1163.         }
  1164.         return deltaX;
  1165.     };
  1166.  
  1167.     Window_Base.prototype.adjustPopupPositionY = function() {
  1168.         var minY = (this._pauseSignLower ? this._windowPauseSignSprite.height / 2 : 0);
  1169.         minY += paramLowerLimitY || 0;
  1170.         if (this.y < minY) {
  1171.             this.y = minY;
  1172.         }
  1173.         var maxY = (paramUpperLimitY || Graphics.boxHeight) - this._windowPauseSignSprite.height / 2;
  1174.         if (this.y + this.height > maxY) {
  1175.             this.y = maxY - this.height;
  1176.         }
  1177.     };
  1178.  
  1179.     Window_Base.prototype.updatePlacementPopup = function() {
  1180.         if (!this._messageWindow) return;
  1181.         if (paramLinkage) {
  1182.             switch ($gameSystem.getPopupSubWindowPosition()) {
  1183.                 case 0:
  1184.                     this.x = this._messageWindow.x;
  1185.                     this.y = this._messageWindow.y + this._messageWindow.height;
  1186.                     this.setPauseSignToNormal();
  1187.                     break;
  1188.                 case 1:
  1189.                     this.setPopupPosition($gamePlayer);
  1190.                     break;
  1191.                 case 2:
  1192.                     var pos = this._messageWindow.getSubWindowPosition();
  1193.                     this.x  = pos.x;
  1194.                     this.y  = pos.y;
  1195.                     this.setPauseSignToNormal();
  1196.                     this.opacity = 0;
  1197.                     break;
  1198.                 case 3:
  1199.                     this.x = this._messageWindow.x + this._messageWindow.width / 2 + 16;
  1200.                     this.y = this._messageWindow.y + this._messageWindow.height;
  1201.                     this.setPauseSignToNormal();
  1202.                     break;
  1203.             }
  1204.         } else {
  1205.             this.y = Graphics.boxHeight - this.height - this._messageWindow.windowHeight() / 2;
  1206.         }
  1207.     };
  1208.  
  1209.     Window_Base.prototype.isPopup = function() {
  1210.         return false;
  1211.     };
  1212.  
  1213.     Window_Base.prototype.isPopupLinkage = function() {
  1214.         return this.isPopup() && paramLinkage;
  1215.     };
  1216.  
  1217.     Window_Base.prototype.resetLayout = function() {
  1218.         this.padding = this.standardPadding();
  1219.         this.width   = this.windowWidth();
  1220.         this.height  = this.windowHeight();
  1221.         this.loadWindowskin();
  1222.         this.setPauseSignToNormal();
  1223.     };
  1224.  
  1225.     var _Window_Base_makeFontBigger      = Window_Base.prototype.makeFontBigger;
  1226.     Window_Base.prototype.makeFontBigger = function() {
  1227.         if (this.isValidFontRangeForPopup()) {
  1228.             if (this.contents.fontSize <= paramFontUpperLimit) {
  1229.                 this.contents.fontSize += paramFontSizeRange;
  1230.             }
  1231.         } else {
  1232.             _Window_Base_makeFontBigger.apply(this, arguments);
  1233.         }
  1234.     };
  1235.  
  1236.     var _Window_Base_makeFontSmaller      = Window_Base.prototype.makeFontSmaller;
  1237.     Window_Base.prototype.makeFontSmaller = function() {
  1238.         if (this.isValidFontRangeForPopup()) {
  1239.             if (this.contents.fontSize >= paramFontLowerLimit) {
  1240.                 this.contents.fontSize -= paramFontSizeRange;
  1241.             }
  1242.         } else {
  1243.             _Window_Base_makeFontSmaller.apply(this, arguments);
  1244.         }
  1245.     };
  1246.  
  1247.     Window_Base.prototype.isValidFontRangeForPopup = function() {
  1248.         return this.isPopup() && paramFontSizeRange > 0;
  1249.     };
  1250.  
  1251.     Window_Base.prototype.isUsePauseSignTextEnd = function() {
  1252.         return this.isValidPauseSignTextEnd && this.isValidPauseSignTextEnd()
  1253.     };
  1254.  
  1255.     //=============================================================================
  1256.     // Window_Message
  1257.     //  ポップアップする場合、表示内容により座標とサイズを自動設定します。
  1258.     //=============================================================================
  1259.     Window_Message._faceHeight = Math.floor(Window_Base._faceHeight * paramFaceScale / 100);
  1260.     Window_Message._faceWidth  = Math.floor(Window_Base._faceWidth * paramFaceScale / 100);
  1261.  
  1262.     var _Window_Message__createAllParts = Window_Message.prototype._createAllParts;
  1263.     Window_Message.prototype._createAllParts = function() {
  1264.         _Window_Message__createAllParts.apply(this, arguments);
  1265.         this._messageTailImage = new Sprite();
  1266.         if (paramTailImage) {
  1267.             this._messageTailImage.bitmap   = ImageManager.loadSystem(paramTailImage);
  1268.             this._messageTailImage.visible  = false;
  1269.             this._messageTailImage.anchor.x = 0.5;
  1270.             this.addChild(this._messageTailImage);
  1271.         }
  1272.     };
  1273.  
  1274.     var _Window_Message_standardFontSize      = Window_Message.prototype.standardFontSize;
  1275.     Window_Message.prototype.standardFontSize = function() {
  1276.         return this.isPopup() ? paramFontSize : _Window_Message_standardFontSize.apply(this, arguments);
  1277.     };
  1278.  
  1279.     var _Window_Message_standardPadding      = Window_Message.prototype.standardPadding;
  1280.     Window_Message.prototype.standardPadding = function() {
  1281.         return this.isPopup() ? paramPadding : _Window_Message_standardPadding.apply(this, arguments);
  1282.     };
  1283.  
  1284.     var _Window_Message_calcTextHeight      = Window_Message.prototype.calcTextHeight;
  1285.     Window_Message.prototype.calcTextHeight = function(textState, all) {
  1286.         var height = _Window_Message_calcTextHeight.apply(this, arguments);
  1287.         return this.isPopup() ? height - 8 + paramBetweenLines : height;
  1288.     };
  1289.  
  1290.     var _Window_Message_startMessage      = Window_Message.prototype.startMessage;
  1291.     Window_Message.prototype.startMessage = function() {
  1292.         this.updateTargetCharacterId();
  1293.         this.loadWindowskin();
  1294.         // Resolve conflict for MPP_MessageEX
  1295.         if (isExistPlugin('MPP_MessageEX')) {
  1296.             this.width = this.windowWidth();
  1297.         }
  1298.         // Resolve conflict for StandPictureEC
  1299.         if (typeof Imported !== 'undefined' && Imported['StandPictureEC']) {
  1300.             this._textState = {};
  1301.             this._textState.index = 0;
  1302.             this._textState.text = '';
  1303.             this.resetLayout();
  1304.         }
  1305.         _Window_Message_startMessage.apply(this, arguments);
  1306.         this.resetLayout();
  1307.     };
  1308.  
  1309.     var _Window_Message_loadWindowskin      = Window_Message.prototype.loadWindowskin;
  1310.     Window_Message.prototype.loadWindowskin = function() {
  1311.         var popupWindowSkin = $gameSystem.getPopupWindowSkin();
  1312.         if (this._windowSkinName !== popupWindowSkin || !popupWindowSkin) {
  1313.             if (this.isPopup()) {
  1314.                 this._windowSkinName = popupWindowSkin;
  1315.             }
  1316.         }
  1317.         _Window_Message_loadWindowskin.apply(this, arguments);
  1318.     };
  1319.  
  1320.     Window_Message.prototype.updateTargetCharacterId = function() {
  1321.         this._targetCharacterId = $gameSystem.getMessagePopupId();
  1322.     };
  1323.  
  1324.     var _Window_Message_resetFontSettings      = Window_Message.prototype.resetFontSettings;
  1325.     Window_Message.prototype.resetFontSettings = function() {
  1326.         _Window_Message_resetFontSettings.apply(this, arguments);
  1327.         if (this.isPopup()) this.contents.fontSize = paramFontSize;
  1328.     };
  1329.  
  1330.     Window_Message.prototype.getPopupTargetCharacter = function() {
  1331.         var id = this._targetCharacterId;
  1332.         if (id < -1) {
  1333.             return $gamePlayer.followers().follower((id * -1) - 2);
  1334.         } else if (id === -1) {
  1335.             return $gamePlayer;
  1336.         } else if (id > -1) {
  1337.             return $gameMap.event(id);
  1338.         } else {
  1339.             return null;
  1340.         }
  1341.     };
  1342.  
  1343.     Window_Message.prototype.isPopup = function() {
  1344.         return !!this.getPopupTargetCharacter();
  1345.     };
  1346.  
  1347.     var _Window_Message_update      = Window_Message.prototype.update;
  1348.     Window_Message.prototype.update = function() {
  1349.         _Window_Message_update.apply(this, arguments);
  1350.         this.updatePlacementPopupIfNeed();
  1351.     };
  1352.  
  1353.     Window_Message.prototype.updatePlacementPopupIfNeed = function() {
  1354.         var prevX = this.x;
  1355.         var prevY = this.y;
  1356.         if (this.openness > 0 && this.isPopup()) {
  1357.             this.updatePlacementPopup();
  1358.         }
  1359.         if ((prevX !== this.x || prevY !== this.y) && this.isClosing()) {
  1360.             this.openness = 0;
  1361.         }
  1362.     };
  1363.  
  1364.     var _Window_Message_updatePlacement      = Window_Message.prototype.updatePlacement;
  1365.     Window_Message.prototype.updatePlacement = function() {
  1366.         if (typeof Yanfly === 'undefined' || !Yanfly.Message) {
  1367.             var width = this.windowWidth();
  1368.             this.x = (Graphics.boxWidth - width) / 2;
  1369.         }
  1370.         _Window_Message_updatePlacement.apply(this, arguments);
  1371.         if (!this.isPopup()) {
  1372.             if (this._positionLock) {
  1373.                 this.loadContainerInfo();
  1374.             }
  1375.             return;
  1376.         }
  1377.         this.updatePlacementPopup();
  1378.         // Resolve conflict for MKR_MessageWindowCustom.js
  1379.         if (isExistPlugin('MKR_MessageWindowCustom')) {
  1380.             this.processVirtual();
  1381.         }
  1382.     };
  1383.  
  1384.     var _Window_Message__updatePauseSign = Window_Message.prototype.hasOwnProperty('_updatePauseSign') ?
  1385.         Window_Message.prototype._updatePauseSign : null;
  1386.     Window_Message.prototype._updatePauseSign = function() {
  1387.         if (_Window_Message__updatePauseSign) {
  1388.             _Window_Message__updatePauseSign.apply(this, arguments);
  1389.         } else {
  1390.             Window_Base.prototype._updatePauseSign.apply(this, arguments);
  1391.         }
  1392.         this.updateTailImage();
  1393.     };
  1394.  
  1395.     Window_Message.prototype.isPopupLower = function() {
  1396.         var id = this._targetCharacterId;
  1397.         return $gameSystem.isPopupFixLower(id) || (!$gameSystem.isPopupFixUpper(id) && this.getWindowTopY() < 0);
  1398.     };
  1399.  
  1400.     Window_Message.prototype.getWindowTopY = function() {
  1401.         return this.y - (this._nameWindow && this._nameWindow.visible ? this._nameWindow.height : 0);
  1402.     };
  1403.  
  1404.     Window_Message.prototype.updatePlacementPopup = function() {
  1405.         this.setPopupPosition(this.getPopupTargetCharacter());
  1406.         if (this._choiceWindow && $gameMessage.isChoice()) {
  1407.             this._choiceWindow.updatePlacementPopup();
  1408.         }
  1409.         this._numberWindow.updatePlacementPopup();
  1410.         // Resolve conflict for YEP_MessageCore.js and MPP_MessageEX.js
  1411.         if (this._nameWindow && checkTypeFunction(this._nameWindow.updatePlacementPopup)) {
  1412.             this._nameWindow.updatePlacementPopup();
  1413.             if (isExistPlugin('MPP_MessageEX')) {
  1414.                 this._nameWindow.y = this.y - this._nameWindow.height;
  1415.                 this._nameWindow.x = this.x;
  1416.             }
  1417.         }
  1418.     };
  1419.  
  1420.     Window_Message.prototype.updateTailImage = function() {
  1421.         if (!this.isPopup()) {
  1422.             this._messageTailImage.visible = false;
  1423.         } else if (paramTailImage) {
  1424.             this._messageTailImage.visible = this.isOpen();
  1425.             if (!this.isUsePauseSignTextEnd() && !paramNoUseTail) {
  1426.                 this._windowPauseSignSprite.visible = false;
  1427.             }
  1428.         }
  1429.     };
  1430.  
  1431.     Window_Message.prototype.resetLayout = function() {
  1432.         this.padding = this.standardPadding();
  1433.         if (this.getPopupTargetCharacter()) {
  1434.             this.processVirtual();
  1435.         } else {
  1436.             this.width  = this.windowWidth();
  1437.             this.height = this.windowHeight();
  1438.             this.setPauseSignToNormal();
  1439.         }
  1440.         this.updatePlacement();
  1441.         this.updateBackground();
  1442.     };
  1443.  
  1444.     Window_Message.prototype.processVirtual = function() {
  1445.         var virtual      = {};
  1446.         virtual.index    = 0;
  1447.         virtual.text     = this.convertEscapeCharacters($gameMessage.allText());
  1448.         var defaultEscapeList = ['C', 'I', '{', '}'];
  1449.         virtual.text     = virtual.text.replace(/\x1b(\w+)\[.*]/gi, function(text) {
  1450.             return defaultEscapeList.contains(arguments[1].toUpperCase()) ? text : '';
  1451.         });
  1452.         virtual.maxWidth = 0;
  1453.         this.newPage(virtual);
  1454.         while (!this.isEndOfText(virtual)) {
  1455.             this.processVirtualCharacter(virtual);
  1456.         }
  1457.         virtual.y += virtual.height;
  1458.         this._subWindowY = virtual.y;
  1459.         var choices      = $gameMessage.choices();
  1460.         if (choices && $gameSystem.getPopupSubWindowPosition() === 2) {
  1461.             virtual.y += choices.length * this._choiceWindow.lineHeight();
  1462.             virtual.maxWidth = Math.max(virtual.maxWidth, this.newLineX() + this._choiceWindow.maxChoiceWidth());
  1463.         }
  1464.         var digit = $gameMessage.numInputMaxDigits();
  1465.         if (digit && $gameSystem.getPopupSubWindowPosition() === 2) {
  1466.             virtual.y += this._numberWindow.lineHeight();
  1467.         }
  1468.         var width  = virtual.maxWidth + this.padding * 2;
  1469.         var height = Math.max(this.getFaceHeight(), virtual.y) + this.padding * 2;
  1470.         var adjust = $gameSystem.getPopupAdjustSize();
  1471.         if (adjust) {
  1472.             width += adjust[0];
  1473.             height += adjust[1];
  1474.         }
  1475.         if (this.isUsePauseSignTextEnd()) {
  1476.             width += this._windowPauseSignSprite.width;
  1477.         } else if (paramNoUseTail) {
  1478.             height += 8;
  1479.         }
  1480.         this.width  = Math.max(width, this.getMinimumWidth());
  1481.         this.height = Math.max(height, this.getMinimumHeight());
  1482.         this.resetFontSettings();
  1483.     };
  1484.  
  1485.     Window_Message.prototype.getMinimumWidth = function() {
  1486.         return $gameVariables.value(paramMinWidthVariableId);
  1487.     };
  1488.  
  1489.     Window_Message.prototype.getMinimumHeight = function() {
  1490.         return $gameVariables.value(paramMinHeightVariableId);
  1491.     };
  1492.  
  1493.     Window_Message.prototype.getSubWindowPosition = function() {
  1494.         var pos = new Point();
  1495.         pos.x   = this.x + this.newLineX();
  1496.         pos.y   = this.y + this._subWindowY;
  1497.         return pos;
  1498.     };
  1499.  
  1500.     Window_Message.prototype.processVirtualCharacter = function(textState) {
  1501.         switch (textState.text[textState.index]) {
  1502.             case '\n':
  1503.                 this.processNewLine(textState);
  1504.                 break;
  1505.             case '\f':
  1506.                 this.processNewPage(textState);
  1507.                 break;
  1508.             case '\x1b':
  1509.                 this.processVirtualEscapeCharacter(this.obtainEscapeCode(textState), textState);
  1510.                 break;
  1511.             default:
  1512.                 this.processVirtualNormalCharacter(textState);
  1513.                 break;
  1514.         }
  1515.     };
  1516.  
  1517.     var _Window_Message_processNewLine      = Window_Message.prototype.processNewLine;
  1518.     Window_Message.prototype.processNewLine = function(textState) {
  1519.         if (this.isPopup()) {
  1520.             textState.index++;
  1521.             _Window_Message_processNewLine.apply(this, arguments);
  1522.             textState.index--;
  1523.         } else {
  1524.             _Window_Message_processNewLine.apply(this, arguments);
  1525.         }
  1526.     };
  1527.  
  1528.     Window_Message.prototype.processVirtualEscapeCharacter = function(code, textState) {
  1529.         switch (code) {
  1530.             case 'C':
  1531.                 this.changeTextColor(this.textColor(this.obtainEscapeParam(textState)));
  1532.                 break;
  1533.             case 'I':
  1534.                 this.processVirtualDrawIcon(this.obtainEscapeParam(textState), textState);
  1535.                 break;
  1536.             case '{':
  1537.                 this.makeFontBigger();
  1538.                 break;
  1539.             case '}':
  1540.                 this.makeFontSmaller();
  1541.                 break;
  1542.             default:
  1543.                 this.obtainEscapeParam(textState);
  1544.                 if (this.obtainEscapeString) {
  1545.                     this.obtainEscapeString(textState);
  1546.                 }
  1547.         }
  1548.     };
  1549.  
  1550.     Window_Message.prototype.processVirtualNormalCharacter = function(textState) {
  1551.         var c = textState.text[textState.index++];
  1552.         textState.x += this.textWidth(c);
  1553.         // Resolve conflict for BetweenCharacters.js
  1554.         if (this.getBetweenCharacters) {
  1555.             textState.x += this.getBetweenCharacters();
  1556.         }
  1557.         textState.maxWidth = Math.max(textState.maxWidth, textState.x);
  1558.     };
  1559.  
  1560.     Window_Message.prototype.processVirtualDrawIcon = function(iconIndex, textState) {
  1561.         textState.x += Window_Base._iconWidth + 4;
  1562.         textState.maxWidth = Math.max(textState.maxWidth, textState.x);
  1563.     };
  1564.  
  1565.     var _Window_Message_newLineX      = Window_Message.prototype.newLineX;
  1566.     Window_Message.prototype.newLineX = function() {
  1567.         if (this.isPopup()) {
  1568.             return $gameMessage.faceName() === '' ? 0 : Window_Message._faceWidth + 8;
  1569.         } else {
  1570.             return _Window_Message_newLineX.apply(this, arguments);
  1571.         }
  1572.     };
  1573.  
  1574.     Window_Message.prototype.getFaceHeight = function() {
  1575.         return $gameMessage.faceName() === '' ? 0 : Window_Message._faceHeight;
  1576.     };
  1577.  
  1578.     var _Window_Message_drawFace      = Window_Message.prototype.drawFace;
  1579.     Window_Message.prototype.drawFace = function(faceName, faceIndex, x, y, width, height) {
  1580.         if (this.isPopup()) {
  1581.             width      = width || Window_Base._faceWidth;
  1582.             height     = height || Window_Base._faceHeight;
  1583.             var bitmap = ImageManager.loadFace(faceName);
  1584.             var pw     = Window_Base._faceWidth;
  1585.             var ph     = Window_Base._faceHeight;
  1586.             var sw     = Math.min(width, pw);
  1587.             var sh     = Math.min(height, ph);
  1588.             var dx     = Math.floor(x + Math.max(width - pw, 0) / 2);
  1589.             var dy     = Math.floor(y + Math.max(height - ph, 0) / 2);
  1590.             var sx     = faceIndex % 4 * pw + (pw - sw) / 2;
  1591.             var sy     = Math.floor(faceIndex / 4) * ph + (ph - sh) / 2;
  1592.             this.contents.blt(bitmap, sx, sy, sw, sh, dx, dy, Window_Message._faceWidth, Window_Message._faceHeight);
  1593.         } else {
  1594.             _Window_Message_drawFace.apply(this, arguments);
  1595.         }
  1596.     };
  1597.  
  1598.     var _Window_Message_processEscapeCharacter      = Window_Message.prototype.processEscapeCharacter;
  1599.     Window_Message.prototype.processEscapeCharacter = function(code, textState) {
  1600.         if (code === 'SH') {
  1601.             this.setWindowShake(this.obtainEscapeParam(textState));
  1602.         } else {
  1603.             _Window_Message_processEscapeCharacter.apply(this, arguments);
  1604.         }
  1605.     };
  1606.  
  1607.     var _Window_Message_terminateMessage      = Window_Message.prototype.terminateMessage;
  1608.     Window_Message.prototype.terminateMessage = function() {
  1609.         this.setWindowShake(0);
  1610.         _Window_Message_terminateMessage.apply(this, arguments);
  1611.     };
  1612.  
  1613.     //=============================================================================
  1614.     // Window_ChoiceList
  1615.     //  ポップアップする場合、メッセージウィンドウに連動して表示位置と余白を調整します。
  1616.     //=============================================================================
  1617.     var _Window_ChoiceList_standardFontSize      = Window_ChoiceList.prototype.standardFontSize;
  1618.     Window_ChoiceList.prototype.standardFontSize = function() {
  1619.         return this.isPopupLinkage() ? paramFontSize : _Window_ChoiceList_standardFontSize.apply(this, arguments);
  1620.     };
  1621.  
  1622.     var _Window_ChoiceList_standardPadding      = Window_ChoiceList.prototype.standardPadding;
  1623.     Window_ChoiceList.prototype.standardPadding = function() {
  1624.         return this.isPopupLinkage() ? paramPadding : _Window_ChoiceList_standardPadding.apply(this, arguments);
  1625.     };
  1626.  
  1627.     var _Window_ChoiceList_lineHeight      = Window_ChoiceList.prototype.lineHeight;
  1628.     Window_ChoiceList.prototype.lineHeight = function() {
  1629.         return this.isPopupLinkage() ? paramFontSize + 8 : _Window_ChoiceList_lineHeight.apply(this, arguments);
  1630.     };
  1631.  
  1632.     var _Window_ChoiceList_start      = Window_ChoiceList.prototype.start;
  1633.     Window_ChoiceList.prototype.start = function() {
  1634.         this._messageWindow.updateTargetCharacterId();
  1635.         if (!this.isPopup()) {
  1636.             this._messageWindow.resetLayout();
  1637.         }
  1638.         return _Window_ChoiceList_start.apply(this, arguments);
  1639.     };
  1640.  
  1641.     var _Window_ChoiceList_updatePlacement      = Window_ChoiceList.prototype.updatePlacement;
  1642.     Window_ChoiceList.prototype.updatePlacement = function() {
  1643.         this.resetLayout();
  1644.         _Window_ChoiceList_updatePlacement.apply(this, arguments);
  1645.         if (this.isPopup()) this.updatePlacementPopup();
  1646.     };
  1647.  
  1648.     var _Window_ChoiceList_refresh      = Window_ChoiceList.prototype.refresh;
  1649.     Window_ChoiceList.prototype.refresh = function() {
  1650.         this.resetLayout();
  1651.         _Window_ChoiceList_refresh.apply(this, arguments);
  1652.     };
  1653.  
  1654.     Window_ChoiceList.prototype.isPopup = function() {
  1655.         return this._messageWindow.isPopup() && this._messageWindow.isOpen();
  1656.     };
  1657.  
  1658.     var _Window_ChoiceList_numVisibleRows      = Window_ChoiceList.prototype.numVisibleRows;
  1659.     Window_ChoiceList.prototype.numVisibleRows = function() {
  1660.         var result = _Window_ChoiceList_numVisibleRows.apply(this, arguments);
  1661.         if (this.isPopupLinkage()) {
  1662.             result = Math.min($gameMessage.choices().length, 8);
  1663.         }
  1664.         return result;
  1665.     };
  1666.  
  1667.     //=============================================================================
  1668.     // Window_NumberInput
  1669.     //  ポップアップする場合、メッセージウィンドウに連動して表示位置と余白を調整します。
  1670.     //=============================================================================
  1671.     var _Window_NumberInput_standardFontSize      = Window_NumberInput.prototype.standardFontSize;
  1672.     Window_NumberInput.prototype.standardFontSize = function() {
  1673.         return this.isPopupLinkage() ? paramFontSize : _Window_NumberInput_standardFontSize.apply(this, arguments);
  1674.     };
  1675.  
  1676.     var _Window_NumberInput_standardPadding      = Window_NumberInput.prototype.standardPadding;
  1677.     Window_NumberInput.prototype.standardPadding = function() {
  1678.         return this.isPopupLinkage() ? paramPadding : _Window_NumberInput_standardPadding.apply(this, arguments);
  1679.     };
  1680.  
  1681.     var _Window_NumberInput_lineHeight      = Window_NumberInput.prototype.lineHeight;
  1682.     Window_NumberInput.prototype.lineHeight = function() {
  1683.         return this.isPopupLinkage() ? paramFontSize + 8 : _Window_NumberInput_lineHeight.apply(this, arguments);
  1684.     };
  1685.  
  1686.     var _Window_NumberInput_updatePlacement      = Window_NumberInput.prototype.updatePlacement;
  1687.     Window_NumberInput.prototype.updatePlacement = function() {
  1688.         this.resetLayout();
  1689.         this.opacity = 255;
  1690.         _Window_NumberInput_updatePlacement.apply(this, arguments);
  1691.         if (this.isPopup()) this.updatePlacementPopup();
  1692.     };
  1693.  
  1694.     Window_NumberInput.prototype.isPopup = function() {
  1695.         return this._messageWindow.isPopup() && this._messageWindow.isOpen();
  1696.     };
  1697.  
  1698.     // Resolve conflict for KMS_DebugUtil.js
  1699.     if (isExistPlugin('KMS_DebugUtil')) {
  1700.         Window_NumberInput.prototype.isPopup = function() {
  1701.             return this._messageWindow && this._messageWindow.isPopup() && this._messageWindow.isOpen();
  1702.         };
  1703.     }
  1704.  
  1705.     //=============================================================================
  1706.     // Window_NameBox
  1707.     //  メッセージウィンドウに連動して表示位置と余白を調整します。
  1708.     //=============================================================================
  1709.     if (typeof Window_NameBox !== 'undefined') {
  1710.         var _Window_NameBox_standardFontSize      = Window_NameBox.prototype.standardFontSize;
  1711.         Window_NameBox.prototype.standardFontSize = function() {
  1712.             return this.isPopupLinkage() ? paramFontSize : _Window_NameBox_standardFontSize.apply(this, arguments);
  1713.         };
  1714.  
  1715.         var _Window_NameBox_standardPadding      = Window_NameBox.prototype.standardPadding;
  1716.         Window_NameBox.prototype.standardPadding = function() {
  1717.             return this.isPopupLinkage() ? paramPadding : _Window_NameBox_standardPadding.apply(this, arguments);
  1718.         };
  1719.  
  1720.         var _Window_NameBox_lineHeight      = Window_NameBox.prototype.lineHeight;
  1721.         Window_NameBox.prototype.lineHeight = function() {
  1722.             return this.isPopupLinkage() ? paramFontSize + 8 : _Window_NameBox_lineHeight.apply(this, arguments);
  1723.         };
  1724.  
  1725.         var _Window_NameBox_updatePlacement      = Window_NameBox.prototype.updatePlacement;
  1726.         Window_NameBox.prototype.updatePlacement = function() {
  1727.             this.resetLayout();
  1728.             _Window_NameBox_updatePlacement.apply(this, arguments);
  1729.             if (this.isPopup()) this.updatePlacementPopup();
  1730.         };
  1731.  
  1732.         var _Window_NameBox_refresh      = Window_NameBox.prototype.refresh;
  1733.         Window_NameBox.prototype.refresh = function() {
  1734.             this.resetLayout();
  1735.             return _Window_NameBox_refresh.apply(this, arguments);
  1736.         };
  1737.  
  1738.         Window_NameBox.prototype.isPopup = function() {
  1739.             return this._parentWindow.isPopup();
  1740.         };
  1741.  
  1742.         Window_NameBox.prototype.updatePlacementPopup = function() {
  1743.             this.adjustPositionX();
  1744.             this.adjustPositionY();
  1745.             if (!$gameSystem.getMessagePopupId()) {
  1746.                 this.openness = 0;
  1747.             }
  1748.         };
  1749.     }
  1750.  
  1751.     //=============================================================================
  1752.     // ウィンドウを透過して重なり合ったときの表示を自然にします。
  1753.     //=============================================================================
  1754.     if (paramThroughWindow && !WindowLayer.throughWindow) {
  1755.         WindowLayer.throughWindow = true;
  1756.         //=============================================================================
  1757.         //  WindowLayer
  1758.         //   ウィンドウのマスク処理を除去します。
  1759.         //=============================================================================
  1760.         WindowLayer.prototype._maskWindow = function(window) {};
  1761.  
  1762.         WindowLayer.prototype._canvasClearWindowRect = function(renderSession, window) {};
  1763.     }
  1764.  
  1765.     //=============================================================================
  1766.     // FTKR_ExMessageWindow2.js の修正
  1767.     //=============================================================================
  1768.     if (imported_FTKR_EMW()) {
  1769.  
  1770.         //------------------------------------------------------------------------
  1771.         //Game_System
  1772.         //フキダシウィンドウの有効無効フラグをウィンドウID毎に保持
  1773.         //------------------------------------------------------------------------
  1774.         var _EMW_Game_System_initialize  = Game_System.prototype.initialize;
  1775.         Game_System.prototype.initialize = function() {
  1776.             _EMW_Game_System_initialize.apply(this, arguments);
  1777.             this._messagePopupCharacterIds = [];
  1778.         };
  1779.  
  1780.         Game_System.prototype.setMessagePopupEx = function(windowId, eventId) {
  1781.             this._messagePopupCharacterIds[windowId] = eventId;
  1782.         };
  1783.  
  1784.         var _EMW_Game_System_clearMessagePopup  = Game_System.prototype.clearMessagePopup;
  1785.         Game_System.prototype.clearMessagePopup = function() {
  1786.             _EMW_Game_System_clearMessagePopup.apply(this, arguments);
  1787.             this._messagePopupCharacterIds.forEach(function(id, i) {
  1788.                 this.clearMessagePopupEx(i);
  1789.             }, this);
  1790.         };
  1791.  
  1792.         Game_System.prototype.clearMessagePopupEx = function(windowId) {
  1793.             this._messagePopupCharacterIds[windowId] = 0;
  1794.         };
  1795.  
  1796.         Game_System.prototype.getMessagePopupIdEx = function(windowId) {
  1797.             windowId = windowId || 0;
  1798.             return this._messagePopupCharacterIds[windowId] !== 0 ? this._messagePopupCharacterIds[windowId] : null;
  1799.         };
  1800.  
  1801.         //------------------------------------------------------------------------
  1802.         //Scene_Map
  1803.         //場所移動時にすべてのウィンドウIDのフキダシ無効化
  1804.         //------------------------------------------------------------------------
  1805.         var _EMW_Scene_Map_terminate  = Scene_Map.prototype.terminate;
  1806.         Scene_Map.prototype.terminate = function() {
  1807.             _EMW_Scene_Map_terminate.call(this);
  1808.             if (SceneManager.isNextScene(Scene_Map)) {
  1809.                 $gameSystem.clearMessagePopup();
  1810.             }
  1811.         };
  1812.  
  1813.         //------------------------------------------------------------------------
  1814.         //Window_MessageEx
  1815.         //------------------------------------------------------------------------
  1816.         var _Window_MessageEx_startMessage      = Window_MessageEx.prototype.startMessage;
  1817.         Window_MessageEx.prototype.startMessage = function() {
  1818.             this.updateTargetCharacterId();
  1819.             this.loadWindowskin();
  1820.             _Window_MessageEx_startMessage.apply(this, arguments);
  1821.             this.resetLayout();
  1822.         };
  1823.  
  1824.         var _Window_MessageEx_updatePlacement      = Window_MessageEx.prototype.updatePlacement;
  1825.         Window_MessageEx.prototype.updatePlacement = function() {
  1826.             if (typeof Yanfly === 'undefined' || !Yanfly.Message) {
  1827.                 this.x = 0;
  1828.             }
  1829.             _Window_MessageEx_updatePlacement.apply(this, arguments);
  1830.             if (!this.isPopup()) {
  1831.                 return;
  1832.             }
  1833.             this.updatePlacementPopup();
  1834.         };
  1835.  
  1836.         Window_MessageEx.prototype.updateTargetCharacterId = function() {
  1837.             var id                  = $gameSystem.getMessagePopupIdEx(this._windowId);
  1838.             this._targetCharacterId = $gameSystem.getMessagePopupIdEx(this._windowId);
  1839.         };
  1840.  
  1841.         Window_MessageEx.prototype.updatePlacementPopup = function() {
  1842.             this.setPopupPosition(this.getPopupTargetCharacter());
  1843.             if (this._choiceWindow && this._gameMessage.isChoice()) {
  1844.                 this._choiceWindow.updatePlacementPopup();
  1845.             }
  1846.             this._numberWindow.updatePlacementPopup();
  1847.             if (this._nameWindow && checkTypeFunction(this._nameWindow.updatePlacementPopup)) {
  1848.                 this._nameWindow.updatePlacementPopup();
  1849.             }
  1850.         };
  1851.  
  1852.         Window_MessageEx.prototype.processVirtual = function() {
  1853.             var virtual      = {};
  1854.             virtual.index    = 0;
  1855.             virtual.text     = this.convertEscapeCharacters(this._gameMessage.allText());
  1856.             virtual.maxWidth = 0;
  1857.             this.newPage(virtual);
  1858.             while (!this.isEndOfText(virtual)) {
  1859.                 this.processVirtualCharacter(virtual);
  1860.             }
  1861.             virtual.y += virtual.height;
  1862.             this._subWindowY = virtual.y;
  1863.             var choices      = this._gameMessage.choices();
  1864.             if (choices && $gameSystem.getPopupSubWindowPosition() === 2) {
  1865.                 virtual.y += choices.length * this._choiceWindow.lineHeight();
  1866.                 virtual.maxWidth = Math.max(virtual.maxWidth, this.newLineX() + this._choiceWindow.maxChoiceWidth());
  1867.             }
  1868.             var digit = this._gameMessage.numInputMaxDigits();
  1869.             if (digit && $gameSystem.getPopupSubWindowPosition() === 2) {
  1870.                 virtual.y += this._numberWindow.lineHeight();
  1871.             }
  1872.             var width  = virtual.maxWidth + this.padding * 2;
  1873.             var height = Math.max(this.getFaceHeight(), virtual.y) + this.padding * 2;
  1874.             var adjust = $gameSystem.getPopupAdjustSize();
  1875.             if (adjust) {
  1876.                 width += adjust[0];
  1877.                 height += adjust[1];
  1878.             }
  1879.             if (this.isUsePauseSignTextEnd()) {
  1880.                 width += this._windowPauseSignSprite.width;
  1881.             } else if (paramNoUseTail) {
  1882.                 height += 8;
  1883.             }
  1884.             this.width  = width;
  1885.             this.height = height;
  1886.             this.resetFontSettings();
  1887.         };
  1888.  
  1889.         var _Window_MessageEx_newLineX      = Window_MessageEx.prototype.newLineX;
  1890.         Window_MessageEx.prototype.newLineX = function() {
  1891.             if (this.isPopup()) {
  1892.                 return this._gameMessage.faceName() === '' ? 0 : Window_Message._faceWidth + 8;
  1893.             } else {
  1894.                 return _Window_MessageEx_newLineX.apply(this, arguments);
  1895.             }
  1896.         };
  1897.  
  1898.         Window_MessageEx.prototype.getFaceHeight = function() {
  1899.             return this._gameMessage.faceName() === '' ? 0 : Window_Message._faceHeight;
  1900.         };
  1901.  
  1902.         //------------------------------------------------------------------------
  1903.         //Window_ChoiceListEx
  1904.         //------------------------------------------------------------------------
  1905.         var _Window_ChoiceListEx_numVisibleRows      = Window_ChoiceListEx.prototype.numVisibleRows;
  1906.         Window_ChoiceListEx.prototype.numVisibleRows = function() {
  1907.             var result = _Window_ChoiceListEx_numVisibleRows.apply(this, arguments);
  1908.             if (this.isPopupLinkage()) {
  1909.                 result = Math.min(this._gameMessage.choices().length, 8);
  1910.             }
  1911.             return result;
  1912.         };
  1913.  
  1914.         var _Window_ChoiceListEx_updatePlacement      = Window_ChoiceListEx.prototype.updatePlacement;
  1915.         Window_ChoiceListEx.prototype.updatePlacement = function() {
  1916.             this.resetLayout();
  1917.             _Window_ChoiceListEx_updatePlacement.apply(this, arguments);
  1918.             if (this.isPopup()) this.updatePlacementPopup();
  1919.         };
  1920.  
  1921.         //------------------------------------------------------------------------
  1922.         //Window_NumberInputEx
  1923.         //------------------------------------------------------------------------
  1924.         var _Window_NumberInputEx_updatePlacement      = Window_NumberInputEx.prototype.updatePlacement;
  1925.         Window_NumberInputEx.prototype.updatePlacement = function() {
  1926.             this.resetLayout();
  1927.             this.opacity = 255;
  1928.             _Window_NumberInputEx_updatePlacement.apply(this, arguments);
  1929.             if (this.isPopup()) this.updatePlacementPopup();
  1930.         };
  1931.  
  1932.     }//FTKR_ExMessageWindow2
  1933. })();
  1934.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement