查看: 3161|回复: 9

[有事请教] 如何实现弹出窗口,然后出现几个按钮?

[复制链接]
梦石
0
星屑
1593
在线时间
252 小时
注册时间
2017-10-24
回帖
158
发表于 2017-10-25 12:30:12 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
如题。事件触发窗口,然后出现几个按钮。按钮负责触发更多的事件。
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

发表于 2017-10-25 12:36:12 | 显示全部楼层
用选项不行吗
回复

使用道具 举报

梦石
0
星屑
7427
在线时间
948 小时
注册时间
2017-9-27
回帖
566
发表于 2017-10-25 17:55:15 | 显示全部楼层
单独设计一个map,做成一个窗口的外观,里面就画出你需要的按钮,把每个按钮绑定好公共事件(需要用插件,YEP里面就有)。
再设计一个传送到这个map的事件就行了。
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2017-10-25 19:29:37 | 显示全部楼层
ピクチャのボタン化プラグイン
http://tm.lucky-duet.com/viewtopic.php?f=5&t=90
アイコンをマップにイベントとして配置するプラグイン
http://tm.lucky-duet.com/viewtopic.php?f=5&t=4348
回复

使用道具 举报

梦石
2
星屑
34507
在线时间
614 小时
注册时间
2014-7-18
回帖
647

MZ评测员开拓者

发表于 2017-10-25 22:27:17 | 显示全部楼层
回复

使用道具 举报

梦石
0
星屑
1593
在线时间
252 小时
注册时间
2017-10-24
回帖
158
 楼主| 发表于 2017-10-26 08:50:03 | 显示全部楼层
xjzsq 发表于 2017-10-25 22:27
这个:
https://rpg.blue/thread-398713-1-1.html
或是这个?

感谢大神
回复

使用道具 举报

梦石
0
星屑
1593
在线时间
252 小时
注册时间
2017-10-24
回帖
158
 楼主| 发表于 2017-10-26 08:50:48 | 显示全部楼层
tseyik 发表于 2017-10-25 19:29
ピクチャのボタン化プラグイン
http://tm.lucky-duet.com/viewtopic.php?f=5&t=90
アイコンをマップにイベ ...

日文总感觉 怪怪的,但是很感谢你的帮助,谢谢
回复

使用道具 举报

梦石
0
星屑
1593
在线时间
252 小时
注册时间
2017-10-24
回帖
158
 楼主| 发表于 2017-10-26 08:52:49 | 显示全部楼层
梦想家大魔王 发表于 2017-10-25 17:55
单独设计一个map,做成一个窗口的外观,里面就画出你需要的按钮,把每个按钮绑定好公共事件(需要用插件,Y ...

这个思路很好,谢谢大神
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2017-10-26 11:27:32 | 显示全部楼层
本帖最后由 tseyik 于 2017-10-26 11:29 编辑

MKR_MapItemSlot
image01.jpeg
  1. //===============================================================================
  2. // MKR_MapItemSlot.js
  3. //===============================================================================
  4. // Copyright (c) 2016-2017 マンカインド
  5. // This software is released under the MIT License.
  6. // [url]http://opensource.org/licenses/mit-license.php[/url]
  7. // ------------------------------------------------------------------------------
  8. // Version
  9. // 1.1.4 2017/10/12 ・アイテムスロットに背景設定時、
  10. //                    ウィンドウ枠が消去されていなかったため修正。
  11. //
  12. // 1.1.3 2017/10/11 ・一部プラグインとの競合問題を修正。
  13. //                  ・メニューアイテムスロット画面の不透明度指定により他画面の
  14. //                    ウィンドウに影響が出ていた問題を修正。
  15. //                  ・プラグインパラメーターの指定方法を変更。
  16. //                  ・一部プラグインパラメータのデフォルト値を変更。
  17. //                  ・アイテムスロットの拡大表示に対応。
  18. //                  ・アイテムスロットの余白を設定可能に。
  19. //                  ・アイテムスロットウィンドウ及び画面について背景画像を
  20. //                    設定できるように修正。
  21. //                  ・スロットからアイテムを使用後、$gameParty.lastItem()で
  22. //                    最後に使用したアイテムを取得できるように。
  23. //                  ・アイテムスロット画面呼び出し用のプラグインコマンドを追加。
  24. //
  25. // 1.1.2 2017/08/30 ・余計なコードを削除。
  26. //
  27. // 1.1.1 2017/08/30 ・プラグインパラメーターの指定方法を変更。
  28. //                  ・プラグインヘルプを修正。
  29. //
  30. // 1.1.0 2017/08/30 ・一部プラグインとの競合問題を修正。
  31. //                  ・ウィンドウ不透明度を指定可能に。
  32. //                  ・スロット選択カーソルを非表示にする機能を追加。
  33. //                  ・アイテムを自動的にスロットに追加する機能を無効化可能に。
  34. //                  ・アイテム選択、アイテム使用のキーアサインを変更可能に。
  35. //                  ・プラグインパラメーターの指定方法を変更。
  36. //
  37. // 1.0.0 2017/08/15 初版公開。
  38. // ------------------------------------------------------------------------------
  39. // [Twitter] [url]https://twitter.com/mankind_games/[/url]
  40. //  [GitHub] [url]https://github.com/mankindGames/[/url]
  41. //    [Blog] [url]http://mankind-games.blogspot.jp/[/url]
  42. //===============================================================================

  43. /*:
  44. *
  45. * @plugindesc (v1.1.4) マップアイテムスロットプラグイン
  46. * @author マンカインド
  47. *
  48. * @help = マップアイテムスロットプラグイン ver 1.1.4 =
  49. * MKR_MapItemSlot.js - マンカインド
  50. *
  51. * マップ画面上に表示したアイテムスロットからアイテムの使用/装備を
  52. * することができるようになります。
  53. *
  54. * アイテムスロットの選択は
  55. *   ・キーボードの1~9,0キー(デフォルト設定)
  56. *   ・ゲーム画面上でマウスホイール操作
  57. * で可能です。
  58. *
  59. * スロット数を10としたとき、スロット番号は以下のようになります。
  60. * (デフォルトでキーボードの数字キーに対応しています。
  61. *  0キーはスロット番号10として扱います)
  62. * アイテムスロット:[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
  63. * キーボードキー  : 1   2   3   4   5   6   7   8   9   0
  64. *
  65. * 選択したスロットにアイテム(道具)が登録されていた場合、
  66. * 画面上をマウスで左クリック、または指定したキーを押すことで
  67. * 選択されたアイテムを使用することができます。
  68. * (範囲が[味方単体]、[使用者]の場合は先頭のアクターに使用。
  69. *  [味方全体]の場合はパーティ全体に効果を発揮します)
  70. *
  71. * アイテムの使用をマウス、またはキーボード、どちらの方法で
  72. * 行うかは選択可能です。
  73. *
  74. * なお、アイテム使用方法にマウスクリックを選択した場合、
  75. * マップ上を移動するためにマウスクリック/タッチ操作を
  76. * 使うことはできなくなります。
  77. *
  78. * 同じアイテムを複数個所持している場合、
  79. * その個数がスロット右下に数字として表示されます。
  80. * アイテム個数が0になったとき、
  81. * アイテムスロットからそのアイテムを削除するか、
  82. * グレーアウトさせた状態で残しておくかはプラグインパラメータから設定可能です。
  83. *
  84. * 選択したスロットに武器が登録されていた場合、
  85. * 装備可能なものであれば選択と同時にパーティ先頭のアクターに装備されます。
  86. * なお、選択カーソルが武器の登録されたスロットから外れると
  87. * アクターの装備も外れます。
  88. *
  89. * 装備中武器(=選択カーソルが武器の登録されているスロット上にある)の場合、
  90. * スロット左上に E と表示されます。
  91. *
  92. * なお、プラグインパラメータ[武器登録可否]がONのとき、
  93. * メニューの装備画面から先頭アクターの武器変更をすることができなくなります。
  94. * (アイテムスロットの選択によって武器の変更を行ってください)
  95. *
  96. * アイテムスロットは先頭から、
  97. * 既に所持しているアイテム、または入手したアイテムが自動的に
  98. * 登録されていきます。
  99. * (スロットが空いている場合のみ。ゲーム開始時に武器を装備済みの場合は
  100. * その武器がスロットの先頭に登録されます)
  101. * プラグインパラメータ:[アイテム自動使用機能]をOFFにすることで
  102. * この機能を無効にすることができます。
  103. *
  104. * メニュー画面の項目[アイテムスロット]からスロットに
  105. * 登録するアイテム、武器を変更可能です。
  106. *
  107. * [登録]はアイテムスロットにアイテムを登録します。
  108. * マップ画面で選択されているスロットに
  109. * 武器を登録した場合は自動的に装備されます。
  110. *
  111. * [削除]は選択したスロットを空にします。
  112. * 装備していた武器をアイテムスロットから削除した場合、
  113. * アクターから装備が外れます。
  114. *
  115. *
  116. * プラグインパラメータによる動作について:
  117. *   アイテムスロットに対する操作はプラグインパラメータにより変更できます。
  118. *
  119. *     ・マウス使用モード.アイテム使用(Mouse_Mode.Use_Enable)
  120. *         マウスクリック(画面タッチ)でアイテムの使用が可能になります。
  121. *
  122. *     ・マウス使用モード.スロット選択(Mouse_Mode.Select_Enable)
  123. *         マウスホイールでスロットの選択が可能になります。
  124. *
  125. *     ・キーボード使用モード.アイテム使用(Keyboard_Mode.Use_Enable)
  126. *         キーボードでアイテムの使用が可能になります。
  127. *
  128. *     ・キーボード使用モード.スロット選択(Keyboard_Mode.Select_Enable)
  129. *         キーボードでスロットの選択が可能になります。
  130. *
  131. *   以下のプラグインパラメータによりアイテムスロットの挙動が変化します。
  132. *
  133. *     ・アイテム登録モード(Slot_Add_Mode)
  134. *       ONの場合、入手したアイテムは自動的にスロットへと登録されます。
  135. *       自動で登録させたくない場合はOFFにするか、後述するメモ欄の設定を
  136. *       行ってください。
  137. *
  138. *     ・アイテム使用モード(Item_Use_Mode)
  139. *       ONの場合、アイテムが登録されたスロットにカーソルが移動すると、
  140. *       自動的にそのアイテムが使用されます。
  141. *       マウスホイールでのカーソル操作でも自動使用されてしまうため、
  142. *       このモードをONにするときは[マウス使用モード.スロット選択]を
  143. *       OFFにするのを推奨します。
  144. *
  145. *     ・武器登録可否(Slot_Set_Weapon)
  146. *       ONの場合、スロットに武器が登録可能になります。
  147. *       また、装備画面から武器の変更が行えなくなります。
  148. *       アイテムのみ登録させたい、武器は自由に変更したい場合は
  149. *       OFFにしてください。
  150. *
  151. *     ・アイテム削除モード(Item_Remove_Mode)
  152. *       ONの場合、スロットにセットされたアイテムの個数が0個になると
  153. *       スロットからアイテムが自動的に削除されます。
  154. *       OFFにすると、アイテムは個数0の状態でグレー表示になります。
  155. *       アイテム個数が0のため、使用することはできません。
  156. *
  157. *
  158. * スロットサイズ倍率について:
  159. *   プラグインパラメータ[スロットサイズ倍率]からスロットの大きさを
  160. *   変更することができます。(1.0倍~2.0倍まで)
  161. *
  162. *   サイズ倍率と最大スロット数によってはスロットが画面外へと
  163. *   飛び出してしまう可能性があります。
  164. *   (例えばスロット10個でサイズを2.0倍にすると、
  165. *    デフォルトのゲーム画面の横サイズである816pxより大きくなってしまいます)
  166. *
  167. *   自動的にゲーム画面内に収まるよう超過サイズを調整する機能はありませんので、
  168. *   ゲーム画面内に収まるよう設定の考慮をお願いします。
  169. *
  170. *
  171. * 武器・アイテムメモ欄:
  172. *   <itemslot:noadd>
  173. *     ・このメモを設定された武器、アイテムはアイテムスロットへの登録が
  174. *       できなくなります。
  175. *
  176. *
  177. * プラグインコマンド:
  178. *   itemslot hide
  179. *     ・アイテムスロットを非表示にします。
  180. *
  181. *   itemslot show
  182. *     ・アイテムスロットを表示します。パラメータ:Slot_Visibleが
  183. *       OFFの場合、このコマンドを使い任意のタイミングでアイテムスロットを
  184. *       表示させる必要があります。
  185. *
  186. *   itemslot set [スロット番号] [アイテムタイプ] [アイテムID] [装備フラグ]
  187. *     ・指定したアイテムスロットに指定したアイテムを登録します。
  188. *
  189. *     ・[スロット番号]は1~スロット最大数までの番号を指定します。
  190. *       自動的に空きスロットを探してアイテムを登録したい場合は 0 を
  191. *       指定します。(空きスロットが存在しない場合は登録されません)
  192. *
  193. *     ・[アイテムタイプ]は登録したいアイテムの種類を指定します。
  194. *       (item か weapon)
  195. *       データベース【アイテム】のアイテムを登録したい場合は item を、
  196. *       データベース【武器】のアイテムを登録したい場合は weapon を
  197. *       指定してください。
  198. *
  199. *     ・[アイテムID]はアイテムのIDを指定します。
  200. *       例えば、初期登録されている【ポーション】はID:1となります。
  201. *       初期登録されている【弓】はID:4となります。
  202. *
  203. *     ・[装備フラグ]は、登録した武器を
  204. *       すぐに装備(カーソル選択)させる場合に true を指定します。
  205. *       アイテムを登録する場合は true を設定しても意味はありません。
  206. *
  207. *   itemslot remove [スロット番号]
  208. *     ・指定した[スロット番号]のスロットに登録されているアイテムを
  209. *       スロットから削除します。
  210. *
  211. *     ・[スロット番号]は1~スロット最大数までの番号を指定します。
  212. *
  213. *     ・スロットからは削除されますが、
  214. *       所持アイテムを失うわけではありません。
  215. *
  216. *     ・装備中の武器をスロットから削除した場合、
  217. *       アクターから装備が外れますのでご注意ください、
  218. *
  219. *   itemslot clear
  220. *     ・アイテムスロットに登録されているアイテムを全て削除します。
  221. *
  222. *   itemslot menu [方式番号]
  223. *     ・メニュー項目[アイテムスロット]の表示方式を変更します。
  224. *       番号と方式の対応は以下のとおりです。
  225. *       0 : メニューに追加しない
  226. *       1 : メニューに追加し選択有効状態
  227. *       2 : メニューに追加するが選択不能状態
  228. *
  229. *   itemslot use [スロット番号]
  230. *     ・指定したスロットに登録されているアイテムを使用します。
  231. *
  232. *     ・[スロット番号]は1~スロット最大数までの番号を指定します。
  233. *
  234. *     ・指定したスロットに武器、または使用条件を満たさないアイテムが
  235. *       登録されている場合は使用することができません。
  236. *
  237. *   itemslot select [スロット番号 / left / right]
  238. *     ・アイテムスロットの選択カーソルを移動します。
  239. *
  240. *     ・スロット番号を数値で指定した場合、カーソルは指定した番号の
  241. *       スロットへと移動します。
  242. *
  243. *     ・leftを指定した場合、カーソルは一つ左に移動します。
  244. *       カーソルがスロット先頭を選択していた場合は末端に移動します。
  245. *
  246. *     ・rightを指定した場合、カーソルは一つ右に移動します。
  247. *       カーソルがスロット末端を選択していた場合は先頭に移動します。
  248. *
  249. *   itemslot edit
  250. *     ・アイテムスロット編集画面を開きます。
  251. *
  252. *
  253. * スクリプトコマンド:
  254. *   $gameParty.getItemSlotFreeNumber();
  255. *     ・アイテムが登録されていない(=空いている)スロット番号を返します。
  256. *       空いているスロットが存在しない場合は-1を返します。
  257. *
  258. *
  259. * 補足:
  260. *   ・このプラグインに関するメモ欄の設定、プラグインコマンド/パラメーター、
  261. *     制御文字は大文字/小文字を区別していません。
  262. *
  263. *   ・プラグインパラメーターの説明に、[初期値]と書かれているものは
  264. *     プラグインコマンドで個別に設定変更が可能です。
  265. *     変更した場合、[初期値]より変更後の設定が
  266. *     優先されますのでご注意ください。
  267. *
  268. *   ・プラグインパラメータの説明に、[制御文字可]と書かれているものは
  269. *     設定値に制御文字を使用可能です。
  270. *     (例えば、変数を表示する\v[n]や、文章の改行を行う\nなどです)
  271. *
  272. *   ・変数を設定した場合、そのパラメータの利用時に変数の値を
  273. *     参照するため、パラメータの設定をゲーム中に変更できます。
  274. *
  275. *
  276. * 利用規約:
  277. *   ・作者に無断で本プラグインの改変、再配布が可能です。
  278. *     (ただしヘッダーの著作権表示部分は残してください。)
  279. *
  280. *   ・利用形態(フリーゲーム、商用ゲーム、R-18作品等)に制限はありません。
  281. *     ご自由にお使いください。
  282. *
  283. *   ・本プラグインを使用したことにより発生した問題について作者は一切の責任を
  284. *     負いません。
  285. *
  286. *   ・要望などがある場合、本プラグインのバージョンアップを行う
  287. *     可能性がありますが、
  288. *     バージョンアップにより本プラグインの仕様が変更される可能性があります。
  289. *     ご了承ください。
  290. *
  291. * ==============================================================================
  292. *
  293. * @param Slot_Number
  294. * @text 最大スロット数
  295. * @desc アイテムスロットの最大数を指定してください。(1~10までの数字。デフォルト:10)
  296. * @type number
  297. * @min 1
  298. * @max 10
  299. * @default 10
  300. *
  301. * @param Slot_Set_Weapon
  302. * @text 武器登録可否
  303. * @desc アイテムスロットに武器を登録可能にするか選択します。(デフォルト:登録する)
  304. * @type boolean
  305. * @on 登録する
  306. * @off 登録しない
  307. * @default true
  308. *
  309. * @param Mouse_Mode
  310. * @text マウスモード
  311. * @desc マウスでのアイテムスロット操作設定
  312. * @type struct<Mode>
  313. * @default {"Use_Enable":"true","Select_Enable":"true"}
  314. *
  315. * @param Keyboard_Mode
  316. * @text キーボードモード
  317. * @desc キーボードでのアイテムスロット操作設定
  318. * @type struct<Mode>
  319. * @default {"Use_Enable":"true","Select_Enable":"true"}
  320. *
  321. *
  322. * @param map_setting
  323. * @text スロット(マップ)設定
  324. * @default ====================================
  325. *
  326. * @param Slot_Visible
  327. * @text アイテムスロットの表示
  328. * @desc [初期値] アイテムスロットを初期状態で表示するか選択します。(デフォルト:表示)
  329. * @type boolean
  330. * @default true
  331. * @on 表示
  332. * @off 非表示
  333. * @parent map_setting
  334. *
  335. * @param Slot_Background
  336. * @text アイテムスロットの背景
  337. * @desc アイテムスロットの背景画像を指定します。(デフォルト設定での必要画像サイズ:横384px,高さ60px)
  338. * @type file
  339. * @require 1
  340. * @dir img/pictures
  341. * @parent map_setting
  342. *
  343. * @param Slot_X
  344. * @text アイテムスロットX座標
  345. * @desc アイテムスロットを画面描画するためのX座標を指定してください。(数字/left/center/rightのいずれか。デフォルト:center)
  346. * @type combo
  347. * @option left
  348. * @option center
  349. * @option right
  350. * @default center
  351. * @parent map_setting
  352. *
  353. * @param Slot_Y
  354. * @text アイテムスロットY座標
  355. * @desc アイテムスロットを画面描画するためのY座標を指定してください。(数字/top/center/bottomのいずれか。デフォルト:bottom)
  356. * @type combo
  357. * @option top
  358. * @option center
  359. * @option bottom
  360. * @default bottom
  361. * @parent map_setting
  362. *
  363. * @param Map_Slot_Window
  364. * @text ウィンドウ設定(マップ)
  365. * @desc マップ画面のスロットウィンドウに関する設定です。(デフォルト:1.0 / 12 / 6)
  366. * @type struct<SlotWindow>
  367. * @default {"Size_Rate":"1.0","Padding":"12","Spacing":"6"}
  368. * @parent map_setting
  369. *
  370. * @param Hide_Message
  371. * @text 文章表示中のスロット表示
  372. * @desc 文章の表示中、アイテムスロットを非表示にするか選択します。(デフォルト:非表示)
  373. * @type boolean
  374. * @on 非表示
  375. * @off 表示
  376. * @default true
  377. * @parent map_setting
  378. *
  379. * @param Slot_Add_Mode
  380. * @text スロット登録モード
  381. * @desc 入手したアイテムを自動的にアイテムスロットに登録するか選択します。(デフォルト:登録する)
  382. * @type boolean
  383. * @on 登録する
  384. * @off 登録しない
  385. * @default true
  386. * @parent map_setting
  387. *
  388. * @param Item_Use_Mode
  389. * @text アイテム使用モード
  390. * @desc アイテムの登録されたスロットにカーソルを移動後、自動的に使用するか選択します。(デフォルト:使用しない)
  391. * @type boolean
  392. * @on 使用する
  393. * @off 使用しない
  394. * @default false
  395. * @parent map_setting
  396. *
  397. * @param Item_Remove_Mode
  398. * @text アイテム削除モード
  399. * @desc スロットに登録されたアイテムが0個になったとき、スロットから消去するか選択します。(デフォルト:削除する)
  400. * @type boolean
  401. * @on 削除する
  402. * @off 削除しない
  403. * @default true
  404. * @parent map_setting
  405. *
  406. * @param Slot_Cursor_Visible
  407. * @text カーソルの表示
  408. * @desc アイテムスロットの選択カーソルを表示するか選択します。(デフォルト:表示する)
  409. * @type boolean
  410. * @on 表示する
  411. * @off 表示しない
  412. * @default true
  413. * @parent map_setting
  414. *
  415. * @param Map_Slot_Opacity
  416. * @text 不透明度(マップ)
  417. * @desc マップ画面に表示されたアイテムスロットの不透明度を数値で指定します。0で完全に透明になります。(デフォルト:255)
  418. * @type number
  419. * @max 255
  420. * @min 0
  421. * @default 255
  422. * @parent map_setting
  423. *
  424. *
  425. * @param key_config
  426. * @text キーコンフィグ
  427. * @default ====================================
  428. *
  429. * @param Item_Use_Key
  430. * @text アイテム使用キー
  431. * @desc スロットに登録されたアイテムを使用するためのキーを指定してください。(デフォルト:Control) ※括弧内はキー名
  432. * @type struct<Key>
  433. * @default {"Key":"control"}
  434. * @parent key_config
  435. *
  436. * @param Slot_1_Key
  437. * @text スロット1選択キー
  438. * @desc アイテムスロット1番を選択するキーを指定してください。(デフォルト:1) ※括弧内はキー名
  439. * @type struct<Key>
  440. * @default {"Key":"1"}
  441. * @parent key_config
  442. *
  443. * @param Slot_2_Key
  444. * @text スロット2選択キー
  445. * @desc アイテムスロット2番を選択するキーを指定してください。(デフォルト:2) ※括弧内はキー名
  446. * @type struct<Key>
  447. * @default {"Key":"2"}
  448. * @parent key_config
  449. *
  450. * @param Slot_3_Key
  451. * @text スロット3選択キー
  452. * @desc アイテムスロット3番を選択するキーを指定してください。(デフォルト:3) ※括弧内はキー名
  453. * @type struct<Key>
  454. * @default {"Key":"3"}
  455. * @parent key_config
  456. *
  457. * @param Slot_4_Key
  458. * @text スロット4選択キー
  459. * @desc アイテムスロット4番を選択するキーを指定してください。(デフォルト:4) ※括弧内はキー名
  460. * @type struct<Key>
  461. * @default {"Key":"4"}
  462. * @parent key_config
  463. *
  464. * @param Slot_5_Key
  465. * @text スロット5選択キー
  466. * @desc アイテムスロット5番を選択するキーを指定してください。(デフォルト:5) ※括弧内はキー名
  467. * @type struct<Key>
  468. * @default {"Key":"5"}
  469. * @parent key_config
  470. *
  471. * @param Slot_6_Key
  472. * @text スロット6選択キー
  473. * @desc アイテムスロット6番を選択するキーを指定してください。(デフォルト:6) ※括弧内はキー名
  474. * @type struct<Key>
  475. * @default {"Key":"6"}
  476. * @parent key_config
  477. *
  478. * @param Slot_7_Key
  479. * @text スロット7選択キー
  480. * @desc アイテムスロット7番を選択するキーを指定してください。(デフォルト:7) ※括弧内はキー名
  481. * @type struct<Key>
  482. * @default {"Key":"7"}
  483. * @parent key_config
  484. *
  485. * @param Slot_8_Key
  486. * @text スロット8選択キー
  487. * @desc アイテムスロット8番を選択するキーを指定してください。(デフォルト:8) ※括弧内はキー名
  488. * @type struct<Key>
  489. * @default {"Key":"8"}
  490. * @parent key_config
  491. *
  492. * @param Slot_9_Key
  493. * @text スロット9選択キー
  494. * @desc アイテムスロット9番を選択するキーを指定してください。(デフォルト:9) ※括弧内はキー名
  495. * @type struct<Key>
  496. * @default {"Key":"9"}
  497. * @parent key_config
  498. *
  499. * @param Slot_10_Key
  500. * @text スロット10選択キー
  501. * @desc アイテムスロット10番を選択するキーを指定してください。(デフォルト:0) ※括弧内はキー名
  502. * @type struct<Key>
  503. * @default {"Key":"0"}
  504. * @parent key_config
  505. *
  506. *
  507. * @param menu_setting
  508. * @text スロット(メニュー)設定
  509. * @default ====================================
  510. *
  511. * @param Menu_Slot_Mode
  512. * @text メニュー表示モード
  513. * @desc [初期値]アイテムスロット画面コマンドをメニューに追加する方式を指定してください。(デフォルト:コマンド有効状態で追加)
  514. * @type select
  515. * @option 追加しない
  516. * @value 0
  517. * @option コマンド有効状態で追加
  518. * @value 1
  519. * @option コマンド無効状態で追加
  520. * @value 2
  521. * @default 1
  522. * @parent menu_setting
  523. *
  524. * @param Menu_Background
  525. * @text スロットメニューの背景
  526. * @desc スロットメニュー画面の背景画像を指定します。(デフォルトのゲーム画面サイズ:横816px,高さ624px)
  527. * @type file
  528. * @require 1
  529. * @dir img/pictures
  530. * @parent menu_setting
  531. *
  532. * @param Menu_Slot_Window
  533. * @text ウィンドウ設定(メニュー)
  534. * @desc アイテムスロット画面のスロットウィンドウに関する設定です。(デフォルト:1.3 / 12 / 6)
  535. * @type struct<SlotWindow>
  536. * @default {"Size_Rate":"1.3","Padding":"12","Spacing":"6"}
  537. * @parent menu_setting
  538. *
  539. * @param Menu_Slot_Name
  540. * @text スロットコマンド名
  541. * @desc メニューに追加する、アイテムスロット画面へ飛ぶためのコマンド名を指定してください。(デフォルト:アイテムスロット)
  542. * @type text
  543. * @default アイテムスロット
  544. * @parent menu_setting
  545. *
  546. * @param Slot_Set_Name
  547. * @text スロット登録コマンド名
  548. * @desc アイテムスロット画面で、アイテムをスロットへ登録するためのコマンド名を指定してください。(デフォルト:登録)
  549. * @type text
  550. * @default 登録
  551. * @parent menu_setting
  552. *
  553. * @param Slot_Remove_Name
  554. * @text スロット削除コマンド名
  555. * @desc アイテムスロット画面で、スロットに登録されたアイテムをクリアするためのコマンド名を指定してください。(デフォルト:削除)
  556. * @type text
  557. * @default 解除
  558. * @parent menu_setting
  559. *
  560. * @param Slot_Set_Desc
  561. * @text スロット登録説明文
  562. * @desc [制御文字可]アイテムスロット画面で、スロットにアイテムを登録する際の説明文を指定してください。
  563. * @type note
  564. * @default "アイテムを登録したいスロットを選択し、\n登録するアイテムを選択してください。"
  565. * @parent menu_setting
  566. *
  567. * @param Slot_Remove_Desc
  568. * @text スロット削除説明文
  569. * @desc [制御文字可]アイテムスロット画面で、スロットに登録されたアイテムを解除するスロットを選択する際の説明文を指定してください。
  570. * @type note
  571. * @default "アイテムの登録を解除するスロットを選択してください。"
  572. * @parent menu_setting
  573. *
  574. * @param Menu_Slot_Opacity
  575. * @text 不透明度(メニュー)
  576. * @desc アイテムスロット画面のウィンドウの不透明度を数値で指定します。0で完全に透明になります。(デフォルト:255)
  577. * @type number
  578. * @max 255
  579. * @min 0
  580. * @default 255
  581. * @parent menu_setting
  582. *
  583. */

  584. /*~struct~Key:
  585. *
  586. * @param Key
  587. * @text キーコンフィグ
  588. * @desc キーを指定してください。※括弧内はキー名など補足
  589. * @type select
  590. * @option なし
  591. * @value null
  592. * @option ダッシュ(Shift)
  593. * @value shift
  594. * @option Control(Ctrl/Alt/Command/Option)
  595. * @value control
  596. * @option A
  597. * @option B
  598. * @option C
  599. * @option D
  600. * @option E
  601. * @option F
  602. * @option G
  603. * @option H
  604. * @option I
  605. * @option J
  606. * @option K
  607. * @option L
  608. * @option N
  609. * @option M
  610. * @option O
  611. * @option P
  612. * @option R
  613. * @option S
  614. * @option T
  615. * @option U
  616. * @option V
  617. * @option Y
  618. * @option 1
  619. * @option 2
  620. * @option 3
  621. * @option 4
  622. * @option 5
  623. * @option 6
  624. * @option 7
  625. * @option 8
  626. * @option 9
  627. * @option 0
  628. *
  629. */
  630. /*~struct~Mode:
  631. *
  632. * @param Use_Enable
  633. * @text アイテム使用
  634. * @desc このモードでスロットに登録されたアイテムの使用が可能か選択します。(デフォルト:使用可能)
  635. * @type boolean
  636. * @on 使用可能
  637. * @off 使用不可
  638. *
  639. * @param Select_Enable
  640. * @text スロット選択
  641. * @desc このモードでスロットの選択が可能か選択します。(デフォルト:選択可能)
  642. * @type boolean
  643. * @on 選択可能
  644. * @off 選択不可
  645. *
  646. */
  647. /*~struct~SlotWindow:
  648. *
  649. * @param Size_Rate
  650. * @text スロットサイズ倍率
  651. * @desc スロットサイズ倍率を指定してください。サイズは1.0で100%(1倍)、2.0で200%(2倍)となります。(1.0~2.0までの数字)
  652. * @type number
  653. * @decimals 1
  654. * @min 1.0
  655. * @max 2.0
  656. *
  657. * @param Padding
  658. * @text ウィンドウ内余白
  659. * @desc スロットウィンドウとスロットアイコン間の余白を調整します。(7以上の数字)
  660. * @type number
  661. * @min 7
  662. *
  663. * @param Spacing
  664. * @text アイコン間隔
  665. * @desc スロットアイコンの配置間隔を調整します。(0以上の数字)
  666. * @type number
  667. * @min 0
  668. *
  669. * */

  670. var Imported = Imported || {};
  671. Imported.MKR_MapItemSlot = true;

  672. (function () {
  673.     'use strict';

  674.     const PN = "MKR_MapItemSlot";

  675.     const CheckParam = function(type, name, value, def, min, max, options) {
  676.         if(min == undefined || min == null) {
  677.             min = -Infinity;
  678.         }
  679.         if(max == undefined || max == null) {
  680.             max = Infinity;
  681.         }

  682.         if(value == null) {
  683.             value = "";
  684.         } else {
  685.             value = String(value);
  686.         }

  687.         value = value.replace(/\\/g, '\x1b');
  688.         value = value.replace(/\x1b\x1b/g, '\\');

  689.         switch(type) {
  690.             case "bool":
  691.                 if(value == "") {
  692.                     value = (def)? true : false;
  693.                 }
  694.                 value = value.toUpperCase() === "ON" || value.toUpperCase() === "TRUE" || value.toUpperCase() === "1";
  695.                 break;
  696.             case "num":
  697.                 if(value == "") {
  698.                     value = (isFinite(def))? parseInt(def, 10) : 0;
  699.                 } else {
  700.                     value = (isFinite(value))? parseInt(value, 10) : (isFinite(def))? parseInt(def, 10) : 0;
  701.                     value = value.clamp(min, max);
  702.                 }
  703.                 break;
  704.             case "float":
  705.                 if(value == "") {
  706.                     value = (isFinite(def))? parseFloat(def) : 0.0;
  707.                 } else {
  708.                     value = (isFinite(value))? parseFloat(value) : (isFinite(def))? parseFloat(def) : 0.0;
  709.                     value = value.clamp(min, max);
  710.                 }
  711.                 break;
  712.             case "string":
  713.                 value = value.replace(/^"/, "");
  714.                 value = value.replace(/"$/, "");
  715.                 if(value != null && options && options.contains("lower")) {
  716.                     value = value.toLowerCase();
  717.                 }
  718.                 if(value != null && options && options.contains("upper")) {
  719.                     value = value.toUpperCase();
  720.                 }
  721.                 break;
  722.             default:
  723.                 throw new Error("[CheckParam] " + name + "のタイプが不正です: " + type);
  724.                 break;
  725.         }

  726.         return [value, type, def, min, max];
  727.     };

  728.     const CEC = function(params) {
  729.         let text, value, type, def, min, max;
  730.         type = params[1];
  731.         text = String(params[0]);
  732.         text = text.replace(/\\/g, '\x1b');
  733.         text = text.replace(/\x1b\x1b/g, '\\');
  734.         type = params[1];
  735.         def = params[2];
  736.         min = params[3];
  737.         max = params[4];

  738.         text = convertEscapeCharacters(text)

  739.         switch(type) {
  740.             case "bool":
  741.                 if(text == "") {
  742.                     value = (def)? true : false;
  743.                 } else {
  744.                     value = text.toUpperCase() === "ON" || text.toUpperCase() === "TRUE" || text.toUpperCase() === "1";
  745.                 }
  746.                 break;
  747.             case "num":
  748.                 value = (isFinite(text))? parseInt(text, 10) : (isFinite(def))? parseInt(def, 10) : 0;
  749.                 value = value.clamp(min, max);
  750.                 break;
  751.             case "float":
  752.                 value = (isFinite(text))? parseFloat(text) : (isFinite(def))? parseFloat(def) : 0.0;
  753.                 value = value.clamp(min, max);
  754.                 break;
  755.             case "string":
  756.             case "select":
  757.                 if(text == "") {
  758.                     value = (def != "")? def : value;
  759.                 } else {
  760.                     value = text;
  761.                 }
  762.                 break;
  763.             default:
  764.                 throw new Error("[CEC] " + param + "のタイプが不正です: " + type);
  765.                 break;
  766.         }

  767.         return value;
  768.     };

  769.     const convertEscapeCharacters = function(text) {
  770.         let windowChild;

  771.         if(typeof text == "string") {
  772.             if(SceneManager._scene) {
  773.                 windowChild = SceneManager._scene._windowLayer.children[0];
  774.                 text = windowChild ? windowChild.convertEscapeCharacters(text) : text;
  775.             } else {
  776.                 text = ConvVb(text);
  777.             }
  778.         }

  779.         return text;
  780.     };

  781.     const ConvVb = function(text) {
  782.         let num;

  783.         if(typeof text == "string") {
  784.             text = text.replace(/\x1bV\[(\d+)\]/i, function() {
  785.             // text = text.replace(/\\V\[(\d+)\]/i, function() {
  786.                 num = parseInt(arguments[1]);
  787.                 return $gameVariables.value(num);
  788.             }.bind(this));
  789.             text = text.replace(/\x1bV\[(\d+)\]/i, function() {
  790.             // text = text.replace(/\\V\[(\d+)\]/i, function() {
  791.                 num = parseInt(arguments[1]);
  792.                 return $gameVariables.value(num);
  793.             }.bind(this));
  794.         }

  795.         return text;
  796.     };

  797.     const GetMeta = function(meta, name, sep) {
  798.         let value, values, i, count;
  799.         value = "";
  800.         values = [];
  801.         name = name.toLowerCase().trim();

  802.         Object.keys(meta).forEach(function(key) {
  803.             if(key.toLowerCase().trim() == name) {
  804.                 value = meta[key].trim();
  805.                 return false;
  806.             }
  807.         });

  808.         if(sep !== undefined && sep != "" && value != "") {
  809.             values = value.split(sep);
  810.             count = values.length;
  811.             values = values.map(function(elem) {
  812.                 return elem.trim();
  813.             });

  814.             return values;
  815.         }

  816.         return value;
  817.     };

  818.     const paramParse = function(obj) {
  819.         return JSON.parse(JSON.stringify(obj, paramReplace));
  820.     }

  821.     const paramReplace = function(key, value) {
  822.         try {
  823.             return JSON.parse(value || null);
  824.         } catch (e) {
  825.             return value;
  826.         }
  827.     };

  828.     const Parameters = paramParse(PluginManager.parameters(PN));
  829.     let Params = {};

  830.     Params = {
  831.         "SlotVisible" : CheckParam("bool", "Slot_Visible", Parameters["Slot_Visible"], true),
  832.         "SlotBackground" : CheckParam("string", "Slot_Background", Parameters["Slot_Background"], ""),
  833.         "SlotBackgroundNo" : CheckParam("num", "Slot_Background_No", Parameters["Slot_Background_No"], 10, 1, 100),
  834.         "SlotNumber" : CheckParam("num", "Slot_Number", Parameters["Slot_Number"], 10, 1, 10),
  835.         "SlotX" : CheckParam("string", "Slot_X", Parameters["Slot_X"], "center"),
  836.         "SlotY" : CheckParam("string", "Slot_Y", Parameters["Slot_Y"], "bottom"),
  837.         "SlotSetW" : CheckParam("bool", "Slot_Set_Weapon", Parameters["Slot_Set_Weapon"], true),
  838.         "SlotCursorVisible" : CheckParam("bool", "Slot_Cursor_Visible", Parameters["Slot_Cursor_Visible"], true),
  839.         "MapSlotOpacity" : CheckParam("num", "Map_Slot_Opacity", Parameters["Map_Slot_Opacity"], 255, 0, 255),
  840.         "HideMess" : CheckParam("bool", "Hide_Message", Parameters["Hide_Message"], true),
  841.         "SlotAddMode" : CheckParam("bool", "Slot_Add_Mode", Parameters["Slot_Add_Mode"], true),
  842.         "ItemRemoveMode" : CheckParam("bool", "Item_Remove_Mode", Parameters["Item_Remove_Mode"], true),
  843.         "ItemUseMode" : CheckParam("bool", "Item_Use_Mode", Parameters["Item_Use_Mode"], false),
  844.         "MenuSlotMode" : CheckParam("num", "Menu_Slot_Mode", Parameters["Menu_Slot_Mode"], "コマンド有効状態で追加"),
  845.         "MenuBackground" : CheckParam("string", "Menu_Background", Parameters["Menu_Background"], ""),
  846.         "MenuSlotName" : CheckParam("string", "Menu_Slot_Name", Parameters["Menu_Slot_Name"], "アイテムスロット"),
  847.         "SlotSetName" : CheckParam("string", "Slot_Set_Name", Parameters["Slot_Set_Name"], "登録"),
  848.         // "SlotChangeName" : CheckParam("string", "Slot_Change_Name", Parameters["Slot_Change_Name"], "入れ替え"),
  849.         "SlotRemoveName" : CheckParam("string", "Slot_Remove_Name", Parameters["Slot_Remove_Name"], "削除"),
  850.         "SlotSetDesc" : CheckParam("string", "Slot_Set_Desc", Parameters["Slot_Set_Desc"], "アイテムを登録したいスロットを選択し、\n登録するアイテムを選択してください。"),
  851.         "SlotChangeDesc" : CheckParam("string", "Slot_Change_Desc", Parameters["Slot_Change_Desc"], "移動元のスロットを選択し、\n交換先のスロットを選択してください。"),
  852.         "SlotRemoveDesc" : CheckParam("string", "Slot_Remove_Desc", Parameters["Slot_Remove_Desc"], "アイテムの登録を解除するスロットを選択してください。"),
  853.         "MenuSlotOpacity" : CheckParam("num", "Menu_Slot_Opacity", Parameters["Menu_Slot_Opacity"], 255, 0, 255),
  854.         "MapSlotWindow" : {
  855.             "SizeRate" : CheckParam("float", "Map_Slot_Window.Size_Rate", Parameters["Map_Slot_Window"]["Size_Rate"], 1.0, 1.0, 2.0),
  856.             "Padding" : CheckParam("num", "Map_Slot_Window.Padding", Parameters["Map_Slot_Window"]["Padding"], 12, 7),
  857.             "Spacing" : CheckParam("num", "Map_Slot_Window.Spacing", Parameters["Map_Slot_Window"]["Spacing"], 6, 0),
  858.         },
  859.         "MenuSlotWindow" : {
  860.             "SizeRate" : CheckParam("float", "Menu_Slot_Window.Size_Rate", Parameters["Menu_Slot_Window"]["Size_Rate"], 1.0, 1.0, 2.0),
  861.             "Padding" : CheckParam("num", "Menu_Slot_Window.Padding", Parameters["Menu_Slot_Window"]["Padding"], 12, 7),
  862.             "Spacing" : CheckParam("num", "Menu_Slot_Window.Spacing", Parameters["Menu_Slot_Window"]["Spacing"], 6, 0),
  863.         },
  864.         "KeyConfig" : {
  865.             "ItemUseKey" : CheckParam("string", "Item_Use_Key", Parameters["Item_Use_Key"]["Key"], "control", null, null, ["lower"]),
  866.             "Slot1Key" : CheckParam("string", "Slot_1_Key", Parameters["Slot_1_Key"]["Key"], "1", null, null, ["lower"]),
  867.             "Slot2Key" : CheckParam("string", "Slot_2_Key", Parameters["Slot_2_Key"]["Key"], "2", null, null, ["lower"]),
  868.             "Slot3Key" : CheckParam("string", "Slot_3_Key", Parameters["Slot_3_Key"]["Key"], "3", null, null, ["lower"]),
  869.             "Slot4Key" : CheckParam("string", "Slot_4_Key", Parameters["Slot_4_Key"]["Key"], "4", null, null, ["lower"]),
  870.             "Slot5Key" : CheckParam("string", "Slot_5_Key", Parameters["Slot_5_Key"]["Key"], "5", null, null, ["lower"]),
  871.             "Slot6Key" : CheckParam("string", "Slot_6_Key", Parameters["Slot_6_Key"]["Key"], "6", null, null, ["lower"]),
  872.             "Slot7Key" : CheckParam("string", "Slot_7_Key", Parameters["Slot_7_Key"]["Key"], "7", null, null, ["lower"]),
  873.             "Slot8Key" : CheckParam("string", "Slot_8_Key", Parameters["Slot_8_Key"]["Key"], "8", null, null, ["lower"]),
  874.             "Slot9Key" : CheckParam("string", "Slot_9_Key", Parameters["Slot_9_Key"]["Key"], "9", null, null, ["lower"]),
  875.             "Slot10Key" : CheckParam("string", "Slot_10_Key", Parameters["Slot_10_Key"]["Key"], "0", null, null, ["lower"]),
  876.         },
  877.         "KeyboardMode" : {
  878.             "UseEnable" : CheckParam("bool", "KeyboardMode.Use_Enable", Parameters["Keyboard_Mode"]["Use_Enable"], true),
  879.             "SelectEnable" : CheckParam("bool", "KeyboardMode.Select_Enable", Parameters["Keyboard_Mode"]["Select_Enable"], true),
  880.         },
  881.         "MouseMode" : {
  882.             "UseEnable" : CheckParam("bool", "MouseMode.Use_Enable", Parameters["Mouse_Mode"]["Use_Enable"], true),
  883.             "SelectEnable" : CheckParam("bool", "MouseMode.Select_Enable", Parameters["Mouse_Mode"]["Select_Enable"], true),
  884.         },
  885.     };

  886.     const ITEM = "item";
  887.     const WEAPON = "weapon";
  888.     const ARMOR = "armor";


  889.     //=========================================================================
  890.     // Input
  891.     //  ・キー判定処理を再定義します。
  892.     //
  893.     //=========================================================================
  894.     let _Input_onKeyDown = Input._onKeyDown;
  895.     Input._onKeyDown = function(event) {
  896.         _Input_onKeyDown.call(this, event);

  897.         let name;
  898.         name = codeToName(event);

  899.         // console.log(event);
  900.         if(!Input.keyMapper[event.keyCode]) {
  901.             // console.log("name:"+name);
  902.             if(name) {
  903.                 this._currentState[name] = true;
  904.             }
  905.         }
  906.     };

  907.     let _Input_onKeyUp = Input._onKeyUp;
  908.     Input._onKeyUp = function(event) {
  909.         _Input_onKeyUp.call(this, event);

  910.         let name;
  911.         name = codeToName(event);

  912.         if(!Input.keyMapper[event.keyCode]) {
  913.             if(name) {
  914.                 this._currentState[name] = false;
  915.             }
  916.         }
  917.     };


  918.     //=========================================================================
  919.     // Game_Interpreter
  920.     //  ・アイテムスロットを操作するプラグインコマンドを定義します。
  921.     //
  922.     //=========================================================================
  923.     let _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  924.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
  925.         _Game_Interpreter_pluginCommand.call(this, command, args);

  926.         let index, id, type, item, equip, i, cnt, itemSlot, actor, scene;
  927.         index = -1;
  928.         id = 0;
  929.         type = null;
  930.         item = null;
  931.         equip = false;
  932.         itemSlot = [];
  933.         actor = $gameParty.leader();
  934.         scene = SceneManager._scene;

  935.         if (command.toLowerCase() === "itemslot") {
  936.             switch (args[0].toLowerCase()) {
  937.                 case "show":
  938.                     $gameParty.setItemSlotVisible(true);
  939.                     break;
  940.                 case "hide":
  941.                     $gameParty.setItemSlotVisible(false);
  942.                     break;
  943.                 case "edit":
  944.                     SceneManager.push(Scene_ItemSlot);
  945.                     break;
  946.                 case "set":
  947.                     if(args[1] != null && isFinite(args[1])) {
  948.                         index = parseInt(args[1], 10) - 1;
  949.                     }
  950.                     if(args[2]) {
  951.                         if((args[2].toLowerCase() == WEAPON && Params.SlotSetW[0]) || (args[2].toLowerCase() == ITEM)) {
  952.                             type = args[2].toLowerCase();
  953.                         }
  954.                     }
  955.                     if(args[3] != null && isFinite(args[3])) {
  956.                         id = parseInt(args[3], 10);
  957.                     }
  958.                     if(args[4]) {
  959.                         equip = args[4].toLowerCase() === "true" ? true : false;
  960.                         if(type == ITEM) {
  961.                             equip = false;
  962.                         }
  963.                     }

  964.                     if(index < -1 || index >= Params.SlotNumber[0] || !type || id < 1) {
  965.                         break;
  966.                     }

  967.                     item = DataManager.getItemByIdType(id, type);

  968.                     if(type == WEAPON && !actor.isEquipWtypeOk(item.wtypeId)) {
  969.                         equip = false;
  970.                     }

  971.                     if(item && $gameParty.hasItemType(item)) {
  972.                         $gameParty.setItemSlot(index, item, equip);
  973.                         // if(!equip) {
  974.                             $gameParty.gainItem(item, 1, false);
  975.                         // }
  976.                     }
  977.                     break;
  978.                 case "remove":
  979.                     if(args[1] != null && isFinite(args[1])) {
  980.                         index = parseInt(args[1], 10) - 1;
  981.                     }

  982.                     if(index >= 0) {
  983.                         // アイテムスロットのアイテム削除判定
  984.                         $gameParty.removeItemSlot(index);
  985.                         if(scene && scene.constructor == Scene_Map) {
  986.                             scene._mapItemSlotWindow.redrawItem(index);
  987.                         }
  988.                     }
  989.                     break;
  990.                 case "clear":
  991.                     itemSlot = $gameParty.getItemSlot(-1);
  992.                     cnt = itemSlot.length;
  993.                     for(i = 0; i < cnt; i++) {
  994.                         // アイテムスロットのアイテム削除判定
  995.                         $gameParty.removeItemSlot(i);
  996.                         if(scene && scene.constructor == Scene_Map) {
  997.                             scene._mapItemSlotWindow.redrawItem(i);
  998.                         }
  999.                     }
  1000.                     break;
  1001.                 case "menu":
  1002.                     $gameParty.setMenuSlotStatus(args[1]);
  1003.                     break;
  1004.                 case "use":
  1005.                     if(args[1] != null && isFinite(args[1])) {
  1006.                         index = parseInt(args[1], 10) - 1;
  1007.                     }
  1008.                     if(index >= 0) {
  1009.                         itemSlot = $gameParty.getItemSlot(index);
  1010.                         if(itemSlot && itemSlot.type == ITEM) {
  1011.                             item = DataManager.getItemByIdType(itemSlot.id, itemSlot.type);
  1012.                             $gameParty.useItemSlot(item);

  1013.                             // アイテムスロットのアイテム削除判定
  1014.                             if(item && Params.ItemRemoveMode[0] && $gameParty.numItems(item) <= 0) {
  1015.                                 $gameParty.removeItemSlot(index);
  1016.                                 if(scene && scene.constructor == Scene_Map) {
  1017.                                     scene._mapItemSlotWindow.redrawItem(index);
  1018.                                 }
  1019.                             }
  1020.                         }
  1021.                     }
  1022.                     break;
  1023.                 case "select":
  1024.                     if(args[1] != "") {
  1025.                         if(slotToIndex(args[1].toLowerCase()) != -1) {
  1026.                             if(scene && scene.constructor == Scene_Map) {
  1027.                                 scene._mapItemSlotWindow.select(slotToIndex(args[1].toLowerCase()));
  1028.                             }
  1029.                         }
  1030.                     }
  1031.                     break;
  1032.             }
  1033.         }
  1034.     };


  1035.     //=========================================================================
  1036.     // Game_Party
  1037.     //  ・アイテムスロットの内容を定義します。
  1038.     //
  1039.     //=========================================================================
  1040.     let _Game_Party_initialize = Game_Party.prototype.initialize;
  1041.     Game_Party.prototype.initialize = function() {
  1042.         _Game_Party_initialize.call(this);

  1043.         this.initItemSlot();
  1044.     };

  1045.     Game_Party.prototype.initItemSlot = function() {
  1046.         let i, j, items, cnt, actor;
  1047.         i = 0;
  1048.         j = 0;

  1049.         if(this._itemSlot == undefined || this._itemSlot == null) {
  1050.             this._itemSlot = [];
  1051.             items = this.allItems();
  1052.             cnt = Params.SlotNumber[0];
  1053.             // アクターが武器を装備済みの場合、先にスロットに登録する。
  1054.             if($gameParty && Params.SlotAddMode[0]) {
  1055.                 actor = $gameParty.leader();
  1056.                 if(actor.weapons().length > 0) {
  1057.                     actor.weapons().forEach(function(item) {
  1058.                         this.setItemSlot(i, item);
  1059.                         i++;
  1060.                     }, this);
  1061.                 }
  1062.             }
  1063.             for(; i < cnt; i++) {
  1064.                 if(items && items[j] && Params.SlotAddMode[0]) {
  1065.                     this.setItemSlot(i, items[j]);
  1066.                     j++;
  1067.                 } else {
  1068.                     this._itemSlot[i] = null;
  1069.                 }
  1070.             }
  1071.         }

  1072.         this._itemSlotLastIndex = -1;
  1073.         this._itemSlotSetIndex = -1;
  1074.         this._itemSlotVisible = true;
  1075.         if(this._menuSlotStatus == undefined || this._menuSlotStatus == null) {
  1076.             this._menuSlotStatus = Params.MenuSlotMode[0];
  1077.         }
  1078.         this._slotEquipItem = null;
  1079.     };

  1080.     Game_Party.prototype.updateItemSlot = function() {
  1081.         let i, cnt;

  1082.         if(this._itemSlot != undefined && this._itemSlot != null) {
  1083.             cnt = Params.SlotNumber[0];
  1084.             for(i = this._itemSlot.length; i < cnt; i++) {
  1085.                 this._itemSlot[i] = null;
  1086.             }
  1087.         }
  1088.     };

  1089.     let _Game_Party_gainItem = Game_Party.prototype.gainItem;
  1090.     Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
  1091.         let type, index, i, cnt, container, actor, meta;

  1092.         meta = "";
  1093.         if(item && item.meta) {
  1094.             meta = GetMeta(item.meta, "itemslot");
  1095.         }
  1096.         if(Params.SlotAddMode[0] && meta.toLowerCase() != "noadd") {
  1097.             container = this.itemContainer(item);
  1098.             if(container && this.hasItemType(item) && this.getSlotEquipItem() != item) {
  1099.                 cnt = this._itemSlot.length;
  1100.                 type = DataManager.getItemType(item);
  1101.                 index = this.getItemSlotNumber(type, item.id);

  1102.                 if(index == -1) {
  1103.                     this.setItemSlot(index, item);
  1104.                 }
  1105.             }
  1106.         }

  1107.         _Game_Party_gainItem.apply(this, arguments);
  1108.     };

  1109.     Game_Party.prototype.setItemSlot = function(index, item, equip) {
  1110.         let equipFlg, actor, win, cnt, i;

  1111.         if(equip == undefined || equip == null) {
  1112.             equip = false;
  1113.         }

  1114.         if(index == -1) {
  1115.             index = this.getItemSlotFreeNumber() - 1;
  1116.         }

  1117.         // アイテムが登録済みの場合は新たに登録させない
  1118.         if(DataManager.isItem(item) && this.getItemSlotNumber(ITEM, item.id) >= 0) {
  1119.             index = -1;
  1120.         } else if(DataManager.isWeapon(item) && this.getItemSlotNumber(WEAPON, item.id) >= 0) {
  1121.             index = -1;
  1122.         }

  1123.         actor = $gameParty.leader();
  1124.         if(item && index >= 0 && index < Params.SlotNumber[0]) {
  1125.             if(DataManager.isItem(item)) {
  1126.                 this._itemSlot[index] = {};
  1127.                 this._itemSlot[index].id = item.id;
  1128.                 this._itemSlot[index].type = ITEM;
  1129.             } else if(DataManager.isWeapon(item) && actor.isEquipWtypeOk(item.wtypeId)) {
  1130.                 equipFlg = actor.isEquipped(item);
  1131.                 this._itemSlot[index] = {};
  1132.                 this._itemSlot[index].id = item.id;
  1133.                 this._itemSlot[index].type = WEAPON;
  1134.                 this._itemSlot[index].kind = item.wtypeId;
  1135.                 this._itemSlot[index].equip = equipFlg;

  1136.                 if(equip) {
  1137.                     $gameParty.setItemSlotLastIndex(index);
  1138.                     this._itemSlot[index].equip = true;
  1139.                     actor.changeEquip(0, item);
  1140.                 }
  1141.             }
  1142.         }
  1143.     };

  1144.     Game_Party.prototype.removeItemSlot = function(index) {
  1145.         let cnt;
  1146.         cnt = this._itemSlot.length;

  1147.         if(index >= 0 && index < cnt) {
  1148.             if(this._itemSlot[index] && this._itemSlot[index].type == WEAPON) {
  1149.                 this.leader().changeEquip(0, null);
  1150.             }
  1151.             this._itemSlot[index] = null
  1152.         }
  1153.     };

  1154.     Game_Party.prototype.clearItemSlot = function() {
  1155.         let cnt;
  1156.         cnt = this._itemSlot.length;

  1157.         for (i = 0; i < cnt; i++) {
  1158.             this._itemSlot[i] = null;
  1159.         }
  1160.     };

  1161.     Game_Party.prototype.swapItemSlot = function(index1, index2) {
  1162.         let temp;
  1163.         temp = this._itemSlot[index1];

  1164.         this._itemSlot[index1] = this._itemSlot[index2];
  1165.         this._itemSlot[index2] = temp;
  1166.     };

  1167.     Game_Party.prototype.hasItemType = function(item) {
  1168.         let type;
  1169.         type = DataManager.getItemType(item);

  1170.         if(type == WEAPON && !Params.SlotSetW[0]) {
  1171.             return false;
  1172.         } else if(type == ARMOR) {
  1173.             return false;
  1174.         }

  1175.         return true;
  1176.     };

  1177.     Game_Party.prototype.setEquipStatus = function(index, equip) {
  1178.         let equipFlg, actor, itemSlot;
  1179.         itemSlot = this.getItemSlot(index);

  1180.         if(itemSlot && (itemSlot.type == WEAPON || itemSlot.type == ARMOR)) {
  1181.             this._itemSlot[index].equip = equip;
  1182.         }
  1183.     };

  1184.     Game_Party.prototype.getItemSlot = function(index) {
  1185.         if(this._itemSlot && isFinite(index)) {
  1186.             if(index == -1) {
  1187.                 return this._itemSlot;
  1188.             } else if(index >= 0 && index < this._itemSlot.length) {
  1189.                 return this._itemSlot[index];
  1190.             }
  1191.         }
  1192.         return null;
  1193.     };

  1194.     Game_Party.prototype.getItemSlotNumber = function(type, id) {
  1195.         let cnt, i, ret, itemSlot;
  1196.         cnt = this._itemSlot.length;
  1197.         ret = -1;

  1198.         for(i = 0; i < cnt; i++) {
  1199.             itemSlot = this._itemSlot[i];
  1200.             if(itemSlot) {
  1201.                 if(itemSlot.type == type && itemSlot.id == id) {
  1202.                     ret = i;
  1203.                     break;
  1204.                 }
  1205.             }
  1206.         }
  1207.         return ret;
  1208.     };

  1209.     Game_Party.prototype.getItemSlotFreeNumber = function() {
  1210.         let cnt, i, ret;
  1211.         cnt = this._itemSlot.length;
  1212.         ret = -1;

  1213.         cnt = this._itemSlot.length;
  1214.         for(i = 0; i < cnt; i++) {
  1215.             if(this._itemSlot[i] == null) {
  1216.                 ret = i;
  1217.                 break;
  1218.             }
  1219.         }

  1220.         return ++ret;
  1221.     };

  1222.     Game_Party.prototype.getItemSlotLastIndex = function() {
  1223.         return this._itemSlotLastIndex;
  1224.     };

  1225.     Game_Party.prototype.setItemSlotLastIndex = function(index) {
  1226.         this._itemSlotLastIndex = index;
  1227.     };

  1228.     Game_Party.prototype.getItemSlotForceIndex = function() {
  1229.         return this._itemSlotForceIndex;
  1230.     };

  1231.     Game_Party.prototype.setItemSlotForceIndex = function(index) {
  1232.         this._itemSlotForceIndex = index;
  1233.     };

  1234.     Game_Party.prototype.isItemSlotHide = function() {
  1235.         return !this._itemSlotVisible;
  1236.     };

  1237.     Game_Party.prototype.setItemSlotVisible = function(visible) {
  1238.         this._itemSlotVisible = visible;
  1239.     };

  1240.     Game_Party.prototype.getMenuSlotStatus = function() {
  1241.         return this._menuSlotStatus;
  1242.     };

  1243.     Game_Party.prototype.setMenuSlotStatus = function(status) {
  1244.         if(status != null && isFinite(status)) {
  1245.             status = parseInt(status, 10);
  1246.             if(status >= 0 && status <= 2) {
  1247.                 this._menuSlotStatus = status;
  1248.             }
  1249.         }
  1250.     };

  1251.     Game_Party.prototype.getSlotEquipItem = function() {
  1252.         return this._slotEquipItem;
  1253.     };

  1254.     Game_Party.prototype.setSlotEquipItem = function(item) {
  1255.         if(item) {
  1256.             if(DataManager.getItemType(item) == WEAPON) {
  1257.                 this._slotEquipItem = item;
  1258.             } else {
  1259.                 this._slotEquipItem = null;
  1260.             }
  1261.         }
  1262.     };

  1263.     Game_Party.prototype.useItemSlot = function(item) {
  1264.         let actor, action, i;
  1265.         actor = this.leader();

  1266.         if (item && actor.canUse(item) && (item.scope === 0 || this.isItemEffectsValid(item))) {
  1267.             $gameParty.setLastItem(item);
  1268.             actor.useItem(item);
  1269.             action = new Game_Action(actor);
  1270.             action.setItemObject(item);
  1271.             this.itemTargetActors(item).forEach(function(target) {
  1272.                 for (i = 0; i < action.numRepeats(); i++) {
  1273.                     action.apply(target);
  1274.                 }
  1275.             }, this);
  1276.             $gamePlayer.requestAnimation(item.animationId);
  1277.             action.applyGlobal();
  1278.             // this._mapItemSlotWindow.redrawCurrentItem();
  1279.             return true;
  1280.         } else if(item && DataManager.getItemType(item) == ITEM ) {
  1281.             SoundManager.playBuzzer();
  1282.         }

  1283.         return false;
  1284.     };

  1285.     Game_Party.prototype.isItemEffectsValid = function(item) {
  1286.         let actor, action;
  1287.         actor = $gameParty.leader();
  1288.         action = new Game_Action(actor);
  1289.         action.setItemObject(item);

  1290.         return this.itemTargetActors(item).some(function(target) {
  1291.             return action.testApply(target);
  1292.         }, this);
  1293.     };

  1294.     Game_Party.prototype.itemTargetActors = function(item) {
  1295.         let actor, action;
  1296.         actor = $gameParty.leader();
  1297.         action = new Game_Action(actor);
  1298.         action.setItemObject(item);

  1299.         if (!action.isForFriend()) {
  1300.             return [];
  1301.         } else if (action.isForAll()) {
  1302.             return $gameParty.members();
  1303.         } else {
  1304.             return [actor];
  1305.         }
  1306.     };


  1307.     //=========================================================================
  1308.     // Game_Actor
  1309.     //  ・リーダーアクターの武器変更処理を再定義します。
  1310.     //
  1311.     //=========================================================================
  1312.     let _Game_Actor_isEquipChangeOk = Game_Actor.prototype.isEquipChangeOk;
  1313.     Game_Actor.prototype.isEquipChangeOk = function(slotId) {
  1314.         let ret = _Game_Actor_isEquipChangeOk.call(this, slotId);

  1315.         if(Params.SlotSetW[0] && this == $gameParty.leader() && slotId == 0 && ret) {
  1316.             ret = false;
  1317.         }

  1318.         return ret;
  1319.     };

  1320.     let _Game_Actor_changeEquip = Game_Actor.prototype.changeEquip;
  1321.     Game_Actor.prototype.changeEquip = function(slotId, item) {
  1322.         let index;

  1323.         if(Params.SlotSetW[0] && this == $gameParty.leader() && slotId == 0 && DataManager.getItemType(item) == WEAPON) {
  1324.             index = $gameParty.getItemSlotNumber(WEAPON, item.id);
  1325.             if(index == -1) {
  1326.                 index = $gameParty.getItemSlotFreeNumber() - 1;
  1327.                 if(index >= 0) {
  1328.                     $gameParty.setItemSlotForceIndex(index);
  1329.                     _Game_Actor_changeEquip.apply(this, arguments);
  1330.                 }
  1331.             } else {
  1332.                 $gameParty.setItemSlotForceIndex(index);
  1333.                 _Game_Actor_changeEquip.apply(this, arguments);
  1334.             }
  1335.         } else {
  1336.             _Game_Actor_changeEquip.apply(this, arguments);
  1337.         }
  1338.     };


  1339.     //=========================================================================
  1340.     // Window_ItemSlotBase
  1341.     //  ・アイテムスロットウィンドウを定義します。
  1342.     //
  1343.     //=========================================================================
  1344.     function Window_ItemSlotBase() {
  1345.         this.initialize.apply(this, arguments);
  1346.     }

  1347.     Window_ItemSlotBase.prototype = Object.create(Window_Selectable.prototype);
  1348.     Window_ItemSlotBase.prototype.constructor = Window_ItemSlotBase;


  1349.     Window_ItemSlotBase.prototype.initialize = function(x, y, kind) {
  1350.         x = this.stringToPoint(x, "x");
  1351.         y = this.stringToPoint(y, "y");

  1352.         Window_Selectable.prototype.initialize.call(this, x, y, this.windowWidth(), this.windowHeight());
  1353.         this._type = [];
  1354.         this._num = [];
  1355.         this._kind = kind;
  1356.         this._lastIndex = $gameParty.getItemSlotLastIndex();

  1357.         // GALV_GursorImage.jsへの対応
  1358.         if(Imported.Galv_CursorImage) {
  1359.             this.removeChild(this._galvCursor);
  1360.         }

  1361.         this.refresh();
  1362.         this.show();
  1363.     };

  1364.     // Window_ItemSlotBase.prototype.standardPadding = function() {
  1365.     //     return 12;
  1366.     // };

  1367.     // Window_ItemSlotBase.prototype.spacing = function() {
  1368.     //     return 0;
  1369.     // };

  1370.     Window_ItemSlotBase.prototype.maxCols = function() {
  1371.         return Params.SlotNumber[0];
  1372.     };

  1373.     Window_ItemSlotBase.prototype.maxItems = function() {
  1374.         return Params.SlotNumber[0];
  1375.     };

  1376.     Window_ItemSlotBase.prototype.windowWidth = function() {
  1377.         // return this.maxCols() * (this.lineHeight() + this.standardPadding() * 2);
  1378.         return this.maxCols() * this.lineHeight() + this.standardPadding() * 2;
  1379.     };

  1380.     Window_ItemSlotBase.prototype.windowHeight = function() {
  1381.         return this.fittingHeight(1);
  1382.     };

  1383.     Window_ItemSlotBase.prototype.itemHeight = function() {
  1384.         let val = this.contentsHeight();
  1385.         val = val > this.contentsWidth() ? this.contentsWidth() : val;
  1386.         return val;
  1387.     };

  1388.     Window_ItemSlotBase.prototype.lastIndex = function() {
  1389.         return this._lastIndex;
  1390.     };

  1391.     Window_ItemSlotBase.prototype.item = function(index) {
  1392.         let itemSlot;

  1393.         if(index == undefined || index == null || index < 0) {
  1394.             index = this.index();
  1395.         }

  1396.         itemSlot = $gameParty.getItemSlot(index);

  1397.         if(itemSlot) {
  1398.             if(itemSlot.type == ITEM) {
  1399.                 return $dataItems[itemSlot.id];
  1400.             } else if(itemSlot.type == WEAPON) {
  1401.                 return $dataWeapons[itemSlot.id];
  1402.             } else if(itemSlot.type == ARMOR) {
  1403.                 return $dataArmors[itemSlot.id];
  1404.             }
  1405.         }

  1406.         return null;
  1407.     };

  1408.     Window_ItemSlotBase.prototype.isHide = function() {
  1409.         return !this.visible;
  1410.     };

  1411.     Window_ItemSlotBase.prototype.update = function() {
  1412.         Window_Selectable.prototype.update.call(this);
  1413.     };

  1414.     Window_ItemSlotBase.prototype.drawItem = function(index) {
  1415.         Window_Selectable.prototype.drawItem.call(this, index);

  1416.         let item, rect, num, type, id, itemSlot, equipFlg, actor, fontSize, x, y,
  1417.             sizeRate;
  1418.         itemSlot = $gameParty.getItemSlot(index);
  1419.         actor = $gameParty.leader();
  1420.         sizeRate = this._kind ? Params.MapSlotWindow.SizeRate[0] : Params.MenuSlotWindow.SizeRate[0];

  1421.         if(itemSlot) {
  1422.             type = itemSlot.type;
  1423.             id = itemSlot.id;
  1424.             item = this.item(index);
  1425.             if (item) {
  1426.                 rect = this.itemRect(index);
  1427.                 num = $gameParty.numItems(item);

  1428.                 if(type == WEAPON && actor.isEquipped(item)) {
  1429.                     this.changePaintOpacity(true);
  1430.                 } else {
  1431.                     this.changePaintOpacity(num > 0);
  1432.                 }

  1433.                 x = rect.x + rect.width / 2 - Window_Base._iconWidth * sizeRate / 2;
  1434.                 y = rect.y + rect.height / 2 - Window_Base._iconHeight * sizeRate / 2;
  1435.                 this.drawIconEx(item.iconIndex, x, y, sizeRate);

  1436.                 if(type == ITEM) {
  1437.                     fontSize = this.contents.fontSize;
  1438.                     this.contents.fontSize = 20;
  1439.                     this.contents.drawText("" + num, rect.x, rect.height - 20, rect.width - 2, 24, 'right');
  1440.                     this.contents.fontSize = fontSize;
  1441.                     this._type[index] = ITEM;
  1442.                 } else if(type == WEAPON) {
  1443.                     this._type[index] = WEAPON;
  1444.                 }
  1445.                 this._num[index] = num;
  1446.             } else {
  1447.                 this._type[index] = "";
  1448.                 this._num[index] = 0;
  1449.             }
  1450.         }
  1451.     };

  1452.     Window_ItemSlotBase.prototype.drawIconEx = function(iconIndex, x, y, sizeRate) {
  1453.         let bitmap, pw, ph, sx, sy, dw, dh;
  1454.         if(sizeRate == "" || sizeRate <= 1) {
  1455.             sizeRate = 1.0;
  1456.         }
  1457.         bitmap = ImageManager.loadSystem('IconSet');
  1458.         pw = Window_Base._iconWidth;
  1459.         ph = Window_Base._iconHeight;
  1460.         sx = iconIndex % 16 * pw;
  1461.         sy = Math.floor(iconIndex / 16) * ph;
  1462.         dw = pw * sizeRate;
  1463.         dh = ph * sizeRate;

  1464.         this.contents.blt(bitmap, sx, sy, pw, ph, x, y, dw, dh);
  1465.     };

  1466.     Window_ItemSlotBase.prototype.stringToPoint = function(text, type) {
  1467.         let val = 0;

  1468.         if(isFinite(text)) {
  1469.             val = parseInt(text, 10);
  1470.         } else {
  1471.             switch(text.toLowerCase()) {
  1472.                 case "right":
  1473.                     if(type == "x") {
  1474.                         val = Graphics.boxWidth - this.windowWidth();
  1475.                     }
  1476.                     break;
  1477.                 case "left":
  1478.                     if(type == "x") {
  1479.                         val = 0;
  1480.                     }
  1481.                     break;
  1482.                 case "top":
  1483.                     if(type == "y") {
  1484.                         val = 0;
  1485.                     }
  1486.                     break;
  1487.                 case "bottom":
  1488.                     if(type == "y") {
  1489.                         val = Graphics.boxHeight - this.windowHeight();
  1490.                     }
  1491.                     break;
  1492.                 case "center":
  1493.                     if(type == "x") {
  1494.                         val = Graphics.boxWidth / 2 - this.windowWidth() / 2;
  1495.                     } else if(type == "y") {
  1496.                         val = Graphics.boxHeight / 2 - this.windowHeight() / 2;
  1497.                     }
  1498.                     break;
  1499.             }
  1500.         }

  1501.         return val;
  1502.     }

  1503.     Window_ItemSlotBase.prototype.select = function(index) {
  1504.         if(index < Params.SlotNumber[0]) {
  1505.             Window_Selectable.prototype.select.call(this, index);
  1506.         }
  1507.     };

  1508.     Window_ItemSlotBase.prototype.selectLast = function() {
  1509.         if(this._lastIndex <= -1) {
  1510.             this.select(0);
  1511.         } else {
  1512.             this.select(this._lastIndex);
  1513.         }
  1514.     };


  1515.     //=========================================================================
  1516.     // Window_MapItemSlot
  1517.     //  ・マップ画面のアイテムスロットウィンドウを定義します。
  1518.     //
  1519.     //=========================================================================
  1520.     function Window_MapItemSlot() {
  1521.         this.initialize.apply(this, arguments);
  1522.     }

  1523.     Window_MapItemSlot.prototype = Object.create(Window_ItemSlotBase.prototype);
  1524.     Window_MapItemSlot.prototype.constructor = Window_MapItemSlot;

  1525.     Window_MapItemSlot.prototype.initialize = function(x, y, kind) {
  1526.         Window_ItemSlotBase.prototype.initialize.call(this, x, y, kind);
  1527.         this.selectLast();
  1528.     };

  1529.     Window_MapItemSlot.prototype.standardPadding = function() {
  1530.         return Params.MapSlotWindow.Padding[0];
  1531.     };

  1532.     Window_MapItemSlot.prototype.spacing = function() {
  1533.         return Params.MapSlotWindow.Spacing[0];
  1534.     };

  1535.     Window_MapItemSlot.prototype.windowWidth = function() {
  1536.         let val, windowWidth, sizeRate, spacing;
  1537.         windowWidth = Window_ItemSlotBase.prototype.windowWidth.call(this);
  1538.         sizeRate = Params.MapSlotWindow.SizeRate[0];
  1539.         spacing = this.spacing() * (this.maxCols() - 1);
  1540.         val = windowWidth * sizeRate + spacing;
  1541.         // val = Graphics.boxWidth < val ? Graphics.boxWidth : val;

  1542.         return val;
  1543.     };

  1544.     Window_MapItemSlot.prototype.windowHeight = function() {
  1545.         let val;
  1546.         val = Window_ItemSlotBase.prototype.windowHeight.call(this) * Params.MapSlotWindow.SizeRate[0];
  1547.         // val = Graphics.boxHeight < val ? Graphics.boxHeight : val;

  1548.         return val;
  1549.     };

  1550.     Window_MapItemSlot.prototype.update = function() {
  1551.         Window_ItemSlotBase.prototype.update.call(this);

  1552.         let index;
  1553.         index = Graphics.frameCount % Params.SlotNumber[0];

  1554.         // 再描画判定
  1555.         if(this.checkRedraw(index)) {
  1556.             this.redrawItem(index);
  1557.         }

  1558.         this._lastIndex = this.index();
  1559.     };

  1560.     Window_MapItemSlot.prototype.checkRedraw = function(index) {
  1561.         let itemSlot, item, equipFlg, actor;
  1562.         itemSlot = $gameParty.getItemSlot(index);
  1563.         actor = $gameParty.leader();

  1564.         if(itemSlot) {
  1565.             item = this.item(index);
  1566.             if(item) {
  1567.                 if(this._type[index] != itemSlot.type || this._num[index] != $gameParty.numItems(item)) {
  1568.                     return true;
  1569.                 }
  1570.                 // if(itemSlot.type == WEAPON) {
  1571.                 //     if(itemSlot.equip != actor.isEquipped(item)) {
  1572.                 //         console.log("itemSlot equip:"+itemSlot.equip);
  1573.                 //         console.log("actor equip:"+actor.isEquipped(item));
  1574.                 //         return true;
  1575.                 //     }
  1576.                 // }
  1577.             }
  1578.         }

  1579.         return false;
  1580.     };

  1581.     Window_MapItemSlot.prototype.drawItem = function(index) {
  1582.         Window_ItemSlotBase.prototype.drawItem.call(this, index);

  1583.         let item, rect, num, type, id, itemSlot, equipFlg, actor, fontSize;
  1584.         itemSlot = $gameParty.getItemSlot(index);
  1585.         actor = $gameParty.leader();

  1586.         // 装備状態を表示&変更
  1587.         if(itemSlot) {
  1588.             type = itemSlot.type;
  1589.             id = itemSlot.id;
  1590.             item = this.item(index);
  1591.             if (item) {
  1592.                 rect = this.itemRect(index);
  1593.                 if(type == WEAPON) {
  1594.                     equipFlg = actor.isEquipped(item);
  1595.                     if(equipFlg) {
  1596.                         fontSize = this.contents.fontSize;
  1597.                         this.contents.fontSize = 20;
  1598.                         this.contents.drawText("E", rect.x, rect.y, rect.width - 2, 24, 'right');
  1599.                         this.contents.fontSize = fontSize;
  1600.                     }
  1601.                     if(itemSlot.equip != equipFlg) {
  1602.                         $gameParty.setEquipStatus(index, equipFlg);
  1603.                     }
  1604.                 }
  1605.             }
  1606.         }
  1607.     };

  1608.     Window_MapItemSlot.prototype.isCursorVisible = function() {
  1609.         if(Params.SlotCursorVisible[0]) {
  1610.             return Window_Selectable.prototype.isCursorVisible.call(this);
  1611.         } else {
  1612.             return false;
  1613.         }
  1614.     };


  1615.     //=========================================================================
  1616.     // Window_ItemSlotHelp
  1617.     //  ・アイテムスロット画面のヘルプウィンドウを再定義します。
  1618.     //
  1619.     //=========================================================================
  1620.     function Window_ItemSlotHelp() {
  1621.         this.initialize.apply(this, arguments);
  1622.     }

  1623.     Window_ItemSlotHelp.prototype = Object.create(Window_Help.prototype);
  1624.     Window_ItemSlotHelp.prototype.constructor = Window_ItemSlotHelp;

  1625.     Window_ItemSlotHelp.prototype.initialize = function(numLines) {
  1626.         Window_Help.prototype.initialize.call(this, numLines);
  1627.         // this.height += this.fittingHeight(0);
  1628.     };

  1629.     Window_ItemSlotHelp.prototype.setItem = function(item) {
  1630.         this.setText(item ? item.name + "\n" + item.description : '');
  1631.     };


  1632.     //=========================================================================
  1633.     // Window_SlotCommand
  1634.     //  ・アイテムスロット画面のスロットコマンドウィンドウを定義します。
  1635.     //
  1636.     //=========================================================================
  1637.     function Window_SlotCommand() {
  1638.         this.initialize.apply(this, arguments);
  1639.     }

  1640.     Window_SlotCommand.prototype = Object.create(Window_Command.prototype);
  1641.     Window_SlotCommand.prototype.constructor = Window_SlotCommand;

  1642.     Window_SlotCommand.prototype.initialize = function(x, y) {
  1643.         Window_Command.prototype.initialize.call(this, x, y);
  1644.         this.selectLast();
  1645.     };

  1646.     Window_SlotCommand._lastCommandSymbol = null;

  1647.     Window_SlotCommand.initCommandPosition = function() {
  1648.         this._lastCommandSymbol = null;
  1649.     };

  1650.     Window_SlotCommand.prototype.windowWidth = function() {
  1651.         return 240;
  1652.     };

  1653.     Window_SlotCommand.prototype.numVisibleRows = function() {
  1654.         return this.maxItems();
  1655.     };

  1656.     Window_SlotCommand.prototype.makeCommandList = function() {
  1657.         this.addCommand(Params.SlotSetName[0],    "slotset");
  1658.         // this.addCommand(Params.SlotChangeName[0], "slotchange");
  1659.         this.addCommand(Params.SlotRemoveName[0], "slotremove");
  1660.     };

  1661.     Window_SlotCommand.prototype.processOk = function() {
  1662.         Window_SlotCommand._lastCommandSymbol = this.currentSymbol();
  1663.         Window_Command.prototype.processOk.call(this);
  1664.     };

  1665.     Window_SlotCommand.prototype.updateHelp = function() {
  1666.         switch(this.currentSymbol()) {
  1667.             case "slotset":
  1668.                 this._helpWindow.setText(Params.SlotSetDesc[0]);
  1669.                 break;
  1670.             case "slotchange":
  1671.                 this._helpWindow.setText(Params.SlotChangeDesc[0]);
  1672.                 break;
  1673.             case "slotremove":
  1674.                 this._helpWindow.setText(Params.SlotRemoveDesc[0]);
  1675.                 break;
  1676.         }
  1677.     };

  1678.     Window_SlotCommand.prototype.selectLast = function() {
  1679.         this.selectSymbol(Window_SlotCommand._lastCommandSymbol);
  1680.     };


  1681.     //=========================================================================
  1682.     // Window_ItemSlot
  1683.     //  ・アイテムスロット画面のアイテムスロットウィンドウを定義します。
  1684.     //
  1685.     //=========================================================================
  1686.     function Window_ItemSlot() {
  1687.         this.initialize.apply(this, arguments);
  1688.     }

  1689.     Window_ItemSlot.prototype = Object.create(Window_ItemSlotBase.prototype);
  1690.     Window_ItemSlot.prototype.constructor = Window_ItemSlot;

  1691.     Window_ItemSlot.prototype.initialize = function(x, y, w, h, kind) {
  1692.         let x2, y2;
  1693.         x2 = x + w / 2 - this.windowWidth() / 2;
  1694.         y2 = y;

  1695.         Window_ItemSlotBase.prototype.initialize.call(this, x2, y2, kind);
  1696.         this._slotType = null;
  1697.         this._swapTemp = -1;
  1698.         this.resetLastIndex();
  1699.     };

  1700.     Window_ItemSlot.prototype.standardPadding = function() {
  1701.         return Params.MenuSlotWindow.Padding[0];
  1702.     };

  1703.     Window_ItemSlot.prototype.spacing = function() {
  1704.         return Params.MenuSlotWindow.Spacing[0];
  1705.     };

  1706.     Window_ItemSlot.prototype.windowWidth = function() {
  1707.         let val, windowWidth, sizeRate, spacing;
  1708.         windowWidth = Window_ItemSlotBase.prototype.windowWidth.call(this);
  1709.         sizeRate = Params.MenuSlotWindow.SizeRate[0];
  1710.         spacing = this.spacing() * (this.maxCols() - 1);
  1711.         val = windowWidth * sizeRate + spacing;
  1712.         // val = Graphics.boxWidth < val ? Graphics.boxWidth : val;

  1713.         return val;
  1714.     };

  1715.     Window_ItemSlot.prototype.windowHeight = function() {
  1716.         let val;
  1717.         val = Window_ItemSlotBase.prototype.windowHeight.call(this) * Params.MenuSlotWindow.SizeRate[0];
  1718.         // val = Graphics.boxHeight < val ? Graphics.boxHeight : val;

  1719.         return val;
  1720.     };

  1721.     Window_ItemSlot.prototype.update = function() {
  1722.         Window_ItemSlotBase.prototype.update.call(this);

  1723.         let index;
  1724.         index = Graphics.frameCount % Params.SlotNumber[0];

  1725.         // 再描画判定
  1726.         if(this.checkRedraw(index)) {
  1727.             this.redrawItem(index);
  1728.         }

  1729.         // this._lastIndex = this.index();
  1730.     };

  1731.     Window_ItemSlot.prototype.checkRedraw = function(index) {
  1732.         let itemSlot, item, equipFlg, actor;
  1733.         itemSlot = $gameParty.getItemSlot(index);
  1734.         actor = $gameParty.leader();

  1735.         if(itemSlot) {
  1736.             item = this.item(index);
  1737.             if(item) {
  1738.                 if(this._type[index] != itemSlot.type || this._num[index] != $gameParty.numItems(item)) {
  1739.                     return true;
  1740.                 }
  1741.                 // if(itemSlot.type == WEAPON) {
  1742.                 //     if(itemSlot.equip != actor.isEquipped(item)) {
  1743.                 //         console.log("itemSlot equip:"+itemSlot.equip);
  1744.                 //         console.log("actor equip:"+actor.isEquipped(item));
  1745.                 //         return true;
  1746.                 //     }
  1747.                 // }
  1748.             }
  1749.         }

  1750.         return false;
  1751.     };

  1752.     Window_ItemSlot.prototype.drawItem = function(index) {
  1753.         Window_ItemSlotBase.prototype.drawItem.call(this, index);

  1754.         let item, rect, num, type, id, itemSlot, equipFlg, actor, fontSize;
  1755.         itemSlot = $gameParty.getItemSlot(index);
  1756.         actor = $gameParty.leader();

  1757.         // 装備状態を表示
  1758.         if(itemSlot) {
  1759.             type = itemSlot.type;
  1760.             id = itemSlot.id;
  1761.             item = this.item(index);
  1762.             if (item) {
  1763.                 rect = this.itemRect(index);
  1764.                 if(type == WEAPON) {
  1765.                     equipFlg = actor.isEquipped(item);
  1766.                     if(equipFlg) {
  1767.                         fontSize = this.contents.fontSize;
  1768.                         this.contents.fontSize = 20;
  1769.                         this.contents.drawText("E", rect.x, rect.y, rect.width - 2, 24, 'right');
  1770.                         this.contents.fontSize = fontSize;
  1771.                     }
  1772.                 }
  1773.             }
  1774.         }
  1775.     };

  1776.     Window_ItemSlot.prototype.isCurrentItemEnabled = function() {
  1777.         let ret, item, actor;
  1778.         item = this.item();
  1779.         actor = $gameParty.leader();
  1780.         ret = true;

  1781.         if(item) {
  1782.             // if(DataManager.getItemType(item) == WEAPON) {
  1783.             //     ret = !actor.isEquipped(item);
  1784.             // }
  1785.         } else {
  1786.             if(!this._slotType || this._slotType == "slotremove") {
  1787.                 ret = false;
  1788.             }
  1789.         }

  1790.         return ret;
  1791.     };

  1792.     Window_ItemSlot.prototype.updateHelp = function() {
  1793.         this.setHelpWindowItem(this.item());
  1794.     };

  1795.     Window_ItemSlot.prototype.processOk = function() {
  1796.         if (this.isCurrentItemEnabled() && !this.hasLastIndex()) {
  1797.             this._lastIndex = this.index();
  1798.         }

  1799.         Window_ItemSlotBase.prototype.processOk.call(this);
  1800.     };

  1801.     Window_ItemSlot.prototype.setSlotType = function(type) {
  1802.         this._slotType = type;
  1803.     };

  1804.     Window_ItemSlot.prototype.hasLastIndex = function() {
  1805.         return this._lastIndex != -1;
  1806.     };

  1807.     Window_ItemSlot.prototype.resetLastIndex = function() {
  1808.         this._lastIndex = -1;
  1809.     };


  1810.     //=========================================================================
  1811.     // Window_ItemSlotCategory
  1812.     //  ・アイテムスロット画面のカテゴリウィンドウを定義します。
  1813.     //
  1814.     //=========================================================================
  1815.     function Window_ItemSlotCategory() {
  1816.         this.initialize.apply(this, arguments);
  1817.     }

  1818.     Window_ItemSlotCategory.prototype = Object.create(Window_ItemCategory.prototype);
  1819.     Window_ItemSlotCategory.prototype.constructor = Window_ItemSlotCategory;

  1820.     Window_ItemSlotCategory.prototype.initialize = function(width) {
  1821.         this._windowWidth = width;
  1822.         Window_ItemCategory.prototype.initialize.call(this);
  1823.         this.deselect();
  1824.         this.deactivate();
  1825.     };

  1826.     Window_ItemSlotCategory.prototype.windowWidth = function() {
  1827.         return this._windowWidth;
  1828.     };

  1829.     Window_ItemSlotCategory.prototype.maxCols = function() {
  1830.         return 2;
  1831.     };

  1832.     Window_ItemSlotCategory.prototype.makeCommandList = function() {
  1833.         this.addCommand(TextManager.item,    'item');
  1834.         this.addCommand(TextManager.weapon,  'weapon');
  1835.     };


  1836.     //=========================================================================
  1837.     // Window_ItemSlotList
  1838.     //  ・アイテムスロット画面のアイテムリストウィンドウを定義します。
  1839.     //
  1840.     //=========================================================================
  1841.     function Window_ItemSlotList() {
  1842.         this.initialize.apply(this, arguments);
  1843.     }

  1844.     Window_ItemSlotList.prototype = Object.create(Window_ItemList.prototype);
  1845.     Window_ItemSlotList.prototype.constructor = Window_ItemSlotList;

  1846.     Window_ItemSlotList.prototype.initialize = function(x, y, width, height) {
  1847.         Window_ItemList.prototype.initialize.call(this, x, y, width, height);
  1848.     };

  1849.     Window_ItemSlotList.prototype.includes = function(item) {
  1850.         let ret, meta;
  1851.         ret = true;

  1852.         meta = "";
  1853.         if(item && item.meta) {
  1854.             meta = GetMeta(item.meta, "itemslot");
  1855.         }

  1856.         switch (this._category) {
  1857.             case 'item':
  1858.                 ret = DataManager.isItem(item) && item.itypeId === 1 && meta.toLowerCase() != "noadd";
  1859.                 break;
  1860.             case 'weapon':
  1861.                 ret = DataManager.isWeapon(item) && meta.toLowerCase() != "noadd";
  1862.                 break;
  1863.             default:
  1864.                 ret = false;
  1865.                 break;
  1866.         }

  1867.         return ret;
  1868.     };

  1869.     Window_ItemSlotList.prototype.isEnabled = function(item) {
  1870.         let ret, type, actor;
  1871.         actor = $gameParty.leader();
  1872.         ret = false;

  1873.         if(item && $gameParty.hasItemType(item)) {
  1874.             type = DataManager.getItemType(item);
  1875.             // ret = $gameParty.getItemSlotNumber(type, item.id) == -1 ? true : false;
  1876.             ret = $gameParty.getItemSlotNumber(type, item.id) == -1;

  1877.             if(type == WEAPON && !actor.isEquipWtypeOk(item.wtypeId)) {
  1878.                 ret = false;
  1879.             }
  1880.         }

  1881.         return ret;
  1882.         // return $gameParty.canUse(item);
  1883.     };

  1884.     Window_ItemSlotList.prototype.isCurrentItemEnabled = function() {
  1885.         return this.isEnabled(this.item());
  1886.         // let ret, item, type;
  1887.         // item = this.item();
  1888.         // ret = false;

  1889.         // if(item && $gameParty.hasItemType(item)) {
  1890.         //     type = DataManager.getItemType(item);
  1891.         //     ret = $gameParty.getItemSlotNumber(type, item.id) == -1 ? true : false;
  1892.         // }

  1893.         // return ret;
  1894.     };


  1895.     //=========================================================================
  1896.     // Window_MenuCommand
  1897.     //  ・メニュー画面にアイテムスロットコマンドを定義します。
  1898.     //
  1899.     //=========================================================================
  1900.     let _Window_MenuCommand_addOriginalCommands = Window_MenuCommand.prototype.addOriginalCommands;
  1901.     Window_MenuCommand.prototype.addOriginalCommands = function() {
  1902.         _Window_MenuCommand_addOriginalCommands.call(this);

  1903.         let status;
  1904.         status = $gameParty.getMenuSlotStatus();

  1905.         if(status == 1) {
  1906.             this.addCommand(Params.MenuSlotName[0], 'itemslot', true);
  1907.         } else if(status == 2) {
  1908.             this.addCommand(Params.MenuSlotName[0], 'itemslot', false);
  1909.         }
  1910.     };


  1911.     //=========================================================================
  1912.     // Window_Base
  1913.     //  ・制御文字を再定義します。
  1914.     //
  1915.     //=========================================================================
  1916.     let _Window_Base_processEscapeCharacter = Window_Base.prototype.processEscapeCharacter;
  1917.     Window_Base.prototype.processEscapeCharacter = function(code, textState) {
  1918.         _Window_Base_processEscapeCharacter.call(this, code, textState);
  1919.         switch (code.toLowerCase()) {
  1920.             case 'n':
  1921.                 this.processNewLine(textState);
  1922.                 textState.index--;
  1923.                 break;
  1924.         }
  1925.     };


  1926.     //=========================================================================
  1927.     // Scene_Map
  1928.     //  ・マップ画面にアイテムスロットを定義します。
  1929.     //
  1930.     //=========================================================================
  1931.     let _Scene_Map_createDisplayObjects = Scene_Map.prototype.createDisplayObjects;
  1932.     Scene_Map.prototype.createDisplayObjects = function() {
  1933.         _Scene_Map_createDisplayObjects.call(this);
  1934.         this.createMapItemSlotWindow();
  1935.     };

  1936.     Scene_Map.prototype.createMapItemSlotWindow = function() {
  1937.         let kind;
  1938.         kind = 1; // マップ用は1

  1939.         this._mapItemSlotWindow = new Window_MapItemSlot(Params.SlotX[0], Params.SlotY[0], kind);
  1940.         this._mapItemSlotWindow.setHandler("ok", this.onItemSlotOk.bind(this));
  1941.         this._mapItemSlotWindow.opacity = Params.MapSlotOpacity[0];
  1942.         if(Params.SlotBackground[0] != "") {
  1943.             this._mapItemSlotWindow._windowSpriteContainer.removeChild(this._mapItemSlotWindow._windowBackSprite);
  1944.             this._mapItemSlotWindow._windowSpriteContainer.removeChild(this._mapItemSlotWindow._windowFrameSprite);
  1945.             this._mapItemSlotWindow._windowBackSprite = new Sprite();
  1946.             this._mapItemSlotWindow._windowBackSprite.bitmap = ImageManager.loadPicture(Params.SlotBackground[0]);
  1947.             this._mapItemSlotWindow._windowSpriteContainer.addChild(this._mapItemSlotWindow._windowBackSprite);
  1948.         }
  1949.         this.addChild(this._mapItemSlotWindow);
  1950.         if(this._mapItemSlotWindow.lastIndex() <= -1 && !Params.SlotVisible[0]) {
  1951.             $gameParty.setItemSlotVisible(false);
  1952.         }
  1953.         this._mapItemSlotWindow.selectLast();
  1954.     };

  1955.     let _Scene_Map_update = Scene_Map.prototype.update;
  1956.     Scene_Map.prototype.update = function() {
  1957.         _Scene_Map_update.call(this);

  1958.         // 表示判定
  1959.         if($gameParty.isItemSlotHide() || ( Params.HideMess[0] &&
  1960.                 (this._messageWindow.isOpening() || this._messageWindow.openness ||
  1961.                 this._scrollTextWindow.visible))) {
  1962.             this._mapItemSlotWindow.hide();
  1963.         } else {
  1964.             this._mapItemSlotWindow.show();
  1965.         }

  1966.         if(!$gameParty.isItemSlotHide() && !this._mapItemSlotWindow.isHide()) {
  1967.             this.updateItemSlot();
  1968.         }
  1969.     };

  1970.     Scene_Map.prototype.updateItemSlot = function() {
  1971.         let pressKey, index, itemSlot, actor, lastIndex, item, action, win, paramKey,
  1972.             mouseMode, keyboardMode;
  1973.         actor = $gameParty.leader();
  1974.         win = this._mapItemSlotWindow;
  1975.         index = win.index();
  1976.         lastIndex = win.lastIndex();
  1977.         paramKey = getUseKey();
  1978.         mouseMode = Params.MouseMode;
  1979.         keyboardMode = Params.KeyboardMode;

  1980.         if(index < 0) {
  1981.             win.selectLast();
  1982.         }

  1983.         // アイテムスロット選択
  1984.         updateSlotSelect(win, index, true);
  1985.         index = win.index();

  1986.         // アイテム使用
  1987.         if(mouseMode.UseEnable[0] && TouchInput.isTriggered() ||
  1988.                 keyboardMode.UseEnable[0] && paramKey && Input.isTriggered(paramKey)) {
  1989.             win.callHandler("ok");
  1990.         }

  1991.         // 装備アイテム
  1992.         itemSlot = $gameParty.getItemSlot(lastIndex);
  1993.         if(itemSlot && itemSlot.type == WEAPON) {
  1994.             // lastIndex の装備を先に外すこと
  1995.             if(lastIndex != index) {
  1996.                 item = win.item(lastIndex);
  1997.                 if(itemSlot && itemSlot.type == WEAPON && actor.isEquipped(item)) {
  1998.                     actor.changeEquip(0, null);
  1999.                     win.redrawItem(lastIndex);
  2000.                 }
  2001.             }
  2002.         }
  2003.         itemSlot = $gameParty.getItemSlot(index);
  2004.         if(itemSlot && itemSlot.type == WEAPON) {
  2005.             item = win.item();
  2006.             if(itemSlot && itemSlot.type == WEAPON && !actor.isEquipped(item)) {
  2007.                 actor.changeEquipById(1, itemSlot.id);
  2008.                 $gameParty.setSlotEquipItem(item);
  2009.                 win.redrawCurrentItem();
  2010.             }
  2011.         }
  2012.         if((itemSlot == null || itemSlot.type == ITEM) && actor.weapons().length > 0) {
  2013.             // 武器以外のスロット選択時に装備を確実に外す
  2014.             actor.changeEquip(0, null);
  2015.         }

  2016.         // アイテムスロットのアイテム削除判定
  2017.         if(Params.ItemRemoveMode[0]) {
  2018.             itemSlot = $gameParty.getItemSlot(index);
  2019.             item = win.item();
  2020.             if(itemSlot) {
  2021.                 if((itemSlot.type == ITEM && $gameParty.numItems(item) <= 0) || (itemSlot.type == WEAPON && !actor.isEquipped(item))) {
  2022.                     $gameParty.removeItemSlot(index);
  2023.                     win.redrawCurrentItem();
  2024.                 }
  2025.             }
  2026.         }

  2027.         $gameParty.setItemSlotLastIndex(index);
  2028.     };

  2029.     Scene_Map.prototype.onItemSlotOk = function() {
  2030.         let item;
  2031.         item = this._mapItemSlotWindow.item();

  2032.         if($gameParty.useItemSlot(item)){
  2033.             this._mapItemSlotWindow.redrawCurrentItem();
  2034.         }
  2035.     };

  2036.     let _Scene_Map_isMapTouchOk = Scene_Map.prototype.isMapTouchOk;
  2037.     Scene_Map.prototype.isMapTouchOk = function() {
  2038.         let mouseMode = Params.MouseMode;
  2039.         if(mouseMode.UseEnable[0]) {
  2040.             return false;
  2041.         } else {
  2042.             return _Scene_Map_isMapTouchOk.call(this);
  2043.         }
  2044.     };

  2045.     let _Scene_Map_terminate = Scene_Map.prototype.terminate;
  2046.     Scene_Map.prototype.terminate = function() {
  2047.         if (!SceneManager.isNextScene(Scene_Battle)) {
  2048.             this._mapItemSlotWindow.hide();
  2049.             // $gameParty.setItemSlotVisible(false);
  2050.         }
  2051.         _Scene_Map_terminate.call(this);
  2052.     };


  2053.     //=========================================================================
  2054.     // Scene_ItemSlot
  2055.     //  ・メニューから遷移するアイテムスロット画面を定義します。
  2056.     //
  2057.     //=========================================================================
  2058.     function Scene_ItemSlot() {
  2059.         this.initialize.apply(this, arguments);
  2060.     }

  2061.     Scene_ItemSlot.prototype = Object.create(Scene_ItemBase.prototype);
  2062.     Scene_ItemSlot.prototype.constructor = Scene_ItemSlot;

  2063.     Scene_ItemSlot.prototype.initialize = function() {
  2064.         Scene_ItemBase.prototype.initialize.call(this);
  2065.     };

  2066.     Scene_ItemSlot.prototype.create = function() {
  2067.         Scene_ItemBase.prototype.create.call(this);
  2068.         this.createHelpWindow();
  2069.         this.createCommandWindow();
  2070.         this.createItemSlotWindow();
  2071.         this.createCategoryWindow();
  2072.         this.createItemWindow();
  2073.     };

  2074.     Scene_ItemSlot.prototype.createBackground = function(){
  2075.         if(Params.MenuBackground[0]){
  2076.             this._backgroundSprite = new Sprite();
  2077.             this._backgroundSprite.bitmap = ImageManager.loadPicture(Params.MenuBackground[0]);
  2078.             this.addChild(this._backgroundSprite);
  2079.             return;
  2080.         }
  2081.     };

  2082.     Scene_ItemSlot.prototype.createHelpWindow = function() {
  2083.         this._helpWindow = new Window_ItemSlotHelp();
  2084.         this._helpWindow.opacity = Params.MenuSlotOpacity[0];
  2085.         this.addWindow(this._helpWindow);
  2086.     };

  2087.     Scene_ItemSlot.prototype.createCommandWindow = function() {
  2088.         this._commandWindow = new Window_SlotCommand(0, this._helpWindow.height);
  2089.         this._commandWindow.setHandler("slotset",    this.commandItemSlot.bind(this));
  2090.         // this._commandWindow.setHandler("slotchange", this.commandItemSlot.bind(this));
  2091.         this._commandWindow.setHandler("slotremove", this.commandItemSlot.bind(this));
  2092.         this._commandWindow.setHandler("cancel",     this.popScene.bind(this));
  2093.         this._commandWindow.opacity = Params.MenuSlotOpacity[0];
  2094.         this._commandWindow.setHelpWindow(this._helpWindow);
  2095.         this.addWindow(this._commandWindow);
  2096.     };

  2097.     Scene_ItemSlot.prototype.createItemSlotWindow = function() {
  2098.         let x, y, w, h, kind;
  2099.         x = this._commandWindow.width;
  2100.         y = this._commandWindow.y;
  2101.         w = Graphics.boxWidth - x;
  2102.         h = this._commandWindow.height;
  2103.         kind = 0; // スロットシーン用は0

  2104.         this._itemSlotWindow = new Window_ItemSlot(x, y, w, y, kind);
  2105.         this._itemSlotWindow.setHelpWindow(this._helpWindow);
  2106.         this._itemSlotWindow.setHandler('ok',     this.onItemSlotOk.bind(this));
  2107.         this._itemSlotWindow.setHandler('cancel', this.onItemSlotCancel.bind(this));
  2108.         this._itemSlotWindow.opacity = Params.MenuSlotOpacity[0];
  2109.         this.addWindow(this._itemSlotWindow);
  2110.     };

  2111.     Scene_ItemSlot.prototype.createCategoryWindow = function() {
  2112.         let width;
  2113.         width = Graphics.boxWidth - this._commandWindow.width;

  2114.         this._categoryWindow = new Window_ItemSlotCategory(width);
  2115.         this._categoryWindow.x = this._commandWindow.width;
  2116.         // this._categoryWindow.y = this._commandWindow.y + this._commandWindow.height - this._categoryWindow.height;
  2117.         this._categoryWindow.y = this._itemSlotWindow.y + this._itemSlotWindow.height;
  2118.         this._categoryWindow.hide();
  2119.         this._categoryWindow.setHandler('ok',     this.onCategoryOk.bind(this));
  2120.         this._categoryWindow.setHandler('cancel', this.onCategoryCancel.bind(this));
  2121.         this._categoryWindow.opacity = Params.MenuSlotOpacity[0];
  2122.         this.addWindow(this._categoryWindow);
  2123.     };

  2124.     Scene_ItemSlot.prototype.createItemWindow = function() {
  2125.         let wy, wh;
  2126.         wy = this._categoryWindow.y + this._categoryWindow.height;
  2127.         wh = Graphics.boxHeight - wy;

  2128.         this._itemWindow = new Window_ItemSlotList(0, wy, Graphics.boxWidth, wh);
  2129.         this._itemWindow.hide();
  2130.         this._itemWindow.setHelpWindow(this._helpWindow);
  2131.         this._itemWindow.setHandler('ok',     this.onItemOk.bind(this));
  2132.         this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
  2133.         this._itemWindow.opacity = Params.MenuSlotOpacity[0];
  2134.         this.addWindow(this._itemWindow);
  2135.         this._categoryWindow.setItemWindow(this._itemWindow);
  2136.     };

  2137.     Scene_ItemSlot.prototype.commandItemSlot = function() {
  2138.         let symbol;
  2139.         symbol = this._commandWindow.currentSymbol();

  2140.         this._itemSlotWindow.setSlotType(symbol);
  2141.         this._itemSlotWindow.activate();
  2142.         this._itemSlotWindow.selectLast();
  2143.     };

  2144.     Scene_ItemSlot.prototype.onItemSlotOk = function() {
  2145.         let index, lastIndex;
  2146.         lastIndex = this._itemSlotWindow.lastIndex();
  2147.         index = this._itemSlotWindow.index();

  2148.         switch (this._commandWindow.currentSymbol()) {
  2149.             case "slotset":
  2150.                 if(Params.SlotSetW[0]) {
  2151.                     this._categoryWindow.show();
  2152.                     this._categoryWindow.activate();
  2153.                     this._categoryWindow.select(0);
  2154.                     this._itemWindow.deselect();
  2155.                 } else {
  2156.                     this._categoryWindow.select(0);
  2157.                     this._itemWindow.activate();
  2158.                     this._itemWindow.selectLast();
  2159.                 }
  2160.                 this._itemWindow.show();
  2161.                 this._itemWindow.refresh();
  2162.                 this._itemSlotWindow.deactivate();
  2163.                 break;
  2164.             case "slotchange":
  2165.                 if(this._itemSlotWindow.hasLastIndex() && index != lastIndex) {
  2166.                     $gameParty.swapItemSlot(lastIndex, index);
  2167.                     this._itemSlotWindow.resetLastIndex();
  2168.                     this._itemSlotWindow.refresh();
  2169.                 }
  2170.                 this._itemSlotWindow.activate();
  2171.                 break;
  2172.             case "slotremove":
  2173.                 $gameParty.removeItemSlot(this._itemSlotWindow.index());
  2174.                 this._itemSlotWindow.refresh();
  2175.                 this._itemSlotWindow.activate();
  2176.                 break;
  2177.         }
  2178.     };

  2179.     Scene_ItemSlot.prototype.onItemSlotCancel = function() {
  2180.         this._itemSlotWindow.resetLastIndex();
  2181.         this._itemSlotWindow.deselect();
  2182.         this._commandWindow.activate();
  2183.         this._commandWindow.callUpdateHelp();
  2184.         this._itemSlotWindow.setSlotType(null);
  2185.     };

  2186.     Scene_ItemSlot.prototype.onCategoryOk = function() {
  2187.         this._itemWindow.activate();
  2188.         this._itemWindow.selectLast();
  2189.     };

  2190.     Scene_ItemSlot.prototype.onCategoryCancel = function() {
  2191.         this._categoryWindow.deselect();
  2192.         this._categoryWindow.hide();
  2193.         this._itemWindow.hide();
  2194.         this._itemSlotWindow.activate();
  2195.         // this._itemSlotWindow.selectLast();
  2196.     };

  2197.     Scene_ItemSlot.prototype.onItemOk = function() {
  2198.         let item;
  2199.         item = this.item();

  2200.         // setslot専用
  2201.         // $gameParty.setLastItem(this.item());
  2202.         $gameParty.setSlotEquipItem(this._itemSlotWindow.item());
  2203.         $gameParty.setItemSlot(this._itemSlotWindow.index(), this.item());
  2204.         $gameParty.setSlotEquipItem(this.item());
  2205.         this._itemSlotWindow.refresh();
  2206.         this._itemWindow.activate();
  2207.         this._itemWindow.refresh();
  2208.         // this.determineItem();
  2209.     };

  2210.     Scene_ItemSlot.prototype.onItemCancel = function() {
  2211.         this._itemWindow.deselect();
  2212.         this._itemWindow.deactivate();
  2213.         if(Params.SlotSetW[0]) {
  2214.             this._categoryWindow.activate();
  2215.         } else {
  2216.             this._itemSlotWindow.activate();
  2217.         }
  2218.         this._helpWindow.setItem(this._itemSlotWindow.item());
  2219.     };

  2220.     Scene_ItemSlot.prototype.update = function() {
  2221.         Scene_ItemBase.prototype.update.call(this);
  2222.         this.updateItemSlot();
  2223.     };

  2224.     Scene_ItemSlot.prototype.updateItemSlot = function() {
  2225.         let pressKey, index, win, itemSlot, item, actor, lastIndex;
  2226.         win = this._itemSlotWindow;
  2227.         index = win.index();
  2228.         lastIndex = win.lastIndex();
  2229.         actor = $gameParty.leader();

  2230.         // アイテムスロット選択
  2231.         updateSlotSelect(win, index, false);
  2232.         index = win.index();

  2233.         // 装備アイテム
  2234.         itemSlot = $gameParty.getItemSlot($gameParty.getItemSlotLastIndex());
  2235.         if(itemSlot) {
  2236.             if(itemSlot.type == WEAPON) {
  2237.                 if(!actor.isEquipped(win.item($gameParty.getItemSlotLastIndex()))) {
  2238.                     actor.changeEquipById(1, itemSlot.id);
  2239.                     win.redrawItem($gameParty.getItemSlotLastIndex());
  2240.                 }
  2241.             } else if(actor.weapons().length > 0) {
  2242.                 actor.changeEquipById(1, 0);
  2243.                 win.redrawItem($gameParty.getItemSlotLastIndex());
  2244.             }
  2245.         }
  2246.     };


  2247.     //=========================================================================
  2248.     // Scene_Menu
  2249.     //  ・メニュー画面にアイテムスロットコマンドを定義します。
  2250.     //
  2251.     //=========================================================================
  2252.     let _Scene_Menu_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
  2253.     Scene_Menu.prototype.createCommandWindow = function() {
  2254.         _Scene_Menu_createCommandWindow.call(this);
  2255.         this._commandWindow.setHandler('itemslot', this.commandItemSlot.bind(this));
  2256.     };

  2257.     Scene_Menu.prototype.commandItemSlot = function() {
  2258.         SceneManager.push(Scene_ItemSlot);
  2259.     };


  2260.     //=========================================================================
  2261.     // DataManager
  2262.     //  ・プラグイン導入前のセーブデータをロードしたとき用の処理を定義します。
  2263.     //  ・アイテム用関数を定義します。
  2264.     //
  2265.     //=========================================================================
  2266.     let _DataManager_extractSaveContents = DataManager.extractSaveContents;
  2267.     DataManager.extractSaveContents = function(contents) {
  2268.         _DataManager_extractSaveContents.call(this, contents);
  2269.         // 処理を追記

  2270.         if($gameParty.getItemSlot(-1) == undefined || $gameParty.getItemSlot(-1) == null) {
  2271.             $gameParty.initItemSlot();
  2272.         } else if($gameParty.getItemSlot(-1).length != Params.SlotNumber[0]) {
  2273.             $gameParty.updateItemSlot();
  2274.         }
  2275.     };

  2276.     DataManager.getItemType = function(item) {
  2277.         if(this.isItem(item)) {
  2278.             return ITEM;
  2279.         } else if(this.isWeapon(item)) {
  2280.             return WEAPON;
  2281.         } else if(this.isArmor(item)) {
  2282.             return ARMOR;
  2283.         }

  2284.         return null;
  2285.     };

  2286.     DataManager.getItemByIdType = function(id, type) {
  2287.         if(!type) {
  2288.             return null;
  2289.         }
  2290.         if(!id || !isFinite(id)) {
  2291.             return null;
  2292.         }

  2293.         id = parseInt(id, 10);
  2294.         type = type.toLowerCase();

  2295.         if(id < 1) {
  2296.             return null;
  2297.         }

  2298.         if(type == ITEM && $dataItems.length > id) {
  2299.             return $dataItems[id];
  2300.         } else if(type == WEAPON && $dataWeapons.length > id) {
  2301.             return $dataWeapons[id];
  2302.         } else if(type == ARMOR && $dataArmors.length > id) {
  2303.             return $dataArmors[id];
  2304.         }

  2305.         return null;
  2306.     };


  2307.     //=========================================================================
  2308.     // Utility
  2309.     //  ・汎用的な処理を定義します。
  2310.     //
  2311.     //=========================================================================
  2312.     // キーイベントのkeyCodeからキー名を取得
  2313.     function codeToName(event) {
  2314.         let name, key;
  2315.         name = null;

  2316.         if(event.key != undefined && event.key != null) {
  2317.             name = event.key;
  2318.             // console.log("key name:"+name);
  2319.         } else if(event.keyIdentifier != undefined && event.keyIdentifier != null) {
  2320.             key = event.keyIdentifier;
  2321.             if(/^U\+/.test(key)) {
  2322.                 key = parseInt(key.substr(2), 16);
  2323.                 // console.log("key:"+key);
  2324.             }
  2325.             if(isFinite(key)) {
  2326.                 if (key >= 112 && key <= 123) {
  2327.                     name = 'f' + (key - 111);// ファンクションキー
  2328.                 } else if (key >= 96 && key <= 105) {
  2329.                     name = 'num' + (key - 96); // 0 ~ 9 (テンキー)
  2330.                 } else if (key >= 65 && key <= 90) {
  2331.                     name = String.fromCharCode(key); // A ~ Z キー
  2332.                 } else if (key >= 48 && key <= 57) {
  2333.                     name = (key - 48).toString(); // 0 ~ 9 キー
  2334.                 } else {
  2335.                     switch(key) {
  2336.                         case 32:
  2337.                             name = "space";
  2338.                             break;
  2339.                     }
  2340.                 }
  2341.             } else {
  2342.                 name = key;
  2343.             }
  2344.             // console.log(event);
  2345.             // console.log("keyIdentifier name:"+name);
  2346.         }

  2347.         if(name) {
  2348.             name = name.toLowerCase();
  2349.         }

  2350.         return name;
  2351.     }

  2352.     // スロット番号の指定をindexに変換する
  2353.     function slotToIndex(slot) {
  2354.         let ret;
  2355.         ret = -1;

  2356.         if(slot == "left") {
  2357.             ret = $gameParty.getItemSlotLastIndex() - 1;
  2358.             ret = ret < 0 ? Params.SlotNumber[0] - 1 : ret;
  2359.         } else if(slot == "right") {
  2360.             ret = $gameParty.getItemSlotLastIndex() + 1;
  2361.             ret = ret >= Params.SlotNumber[0] ? 0 : ret;
  2362.         } else if(slot != null && isFinite(slot)) {
  2363.             ret = parseInt(slot, 10);
  2364.             if(ret > Params.SlotNumber[0] || ret < 1) {
  2365.                 ret = -1;
  2366.             } else {
  2367.                 ret--;
  2368.             }
  2369.         }

  2370.         return ret;
  2371.     }

  2372.     // スロット使用キーを取得する
  2373.     function getUseKey() {
  2374.         let keys;
  2375.         keys = Params.KeyConfig;

  2376.         // console.log(keys);
  2377.         // return keys.ItemUseKey[0].toLowerCase();
  2378.         return keys.ItemUseKey[0];
  2379.     }

  2380.     // スロットウィンドウselect
  2381.     function updateSlotSelect(win, index, useFlg) {
  2382.         let i, key, item, pushFlg, keys, mouseMode, keyboardMode;
  2383.         pushFlg = false;
  2384.         keys = Params.KeyConfig;
  2385.         mouseMode = Params.MouseMode;
  2386.         keyboardMode = Params.KeyboardMode;

  2387.         // アイテムスロット選択

  2388.         // 強制選択
  2389.         if($gameParty.getItemSlotForceIndex() >= 0) {
  2390.             win.select($gameParty.getItemSlotForceIndex());
  2391.             $gameParty.setItemSlotForceIndex(-1);
  2392.             pushFlg = true;
  2393.         }

  2394.         // キーボード
  2395.         if(keyboardMode.SelectEnable[0]) {
  2396.             if(Input.isTriggered(keys.Slot1Key[0]) && slotToIndex(1) != -1) {
  2397.                 win.select(slotToIndex(1));
  2398.                 pushFlg = true;
  2399.             }
  2400.             if(Input.isTriggered(keys.Slot2Key[0]) && slotToIndex(2) != -1) {
  2401.                 win.select(slotToIndex(2));
  2402.                 pushFlg = true;
  2403.             }
  2404.             if(Input.isTriggered(keys.Slot3Key[0]) && slotToIndex(3) != -1) {
  2405.                 win.select(slotToIndex(3));
  2406.                 pushFlg = true;
  2407.             }
  2408.             if(Input.isTriggered(keys.Slot4Key[0]) && slotToIndex(4) != -1) {
  2409.                 win.select(slotToIndex(4));
  2410.                 pushFlg = true;
  2411.             }
  2412.             if(Input.isTriggered(keys.Slot5Key[0]) && slotToIndex(5) != -1) {
  2413.                 win.select(slotToIndex(5));
  2414.                 pushFlg = true;
  2415.             }
  2416.             if(Input.isTriggered(keys.Slot6Key[0]) && slotToIndex(6) != -1) {
  2417.                 win.select(slotToIndex(6));
  2418.                 pushFlg = true;
  2419.             }
  2420.             if(Input.isTriggered(keys.Slot7Key[0]) && slotToIndex(7) != -1) {
  2421.                 win.select(slotToIndex(7));
  2422.                 pushFlg = true;
  2423.             }
  2424.             if(Input.isTriggered(keys.Slot8Key[0]) && slotToIndex(8) != -1) {
  2425.                 win.select(slotToIndex(8));
  2426.                 pushFlg = true;
  2427.             }
  2428.             if(Input.isTriggered(keys.Slot9Key[0]) && slotToIndex(9) != -1) {
  2429.                 win.select(slotToIndex(9));
  2430.                 pushFlg = true;
  2431.             }
  2432.             if(Input.isTriggered(keys.Slot10Key[0]) && slotToIndex(10) != -1) {
  2433.                 win.select(slotToIndex(10));
  2434.                 pushFlg = true;
  2435.             }
  2436.         }

  2437.         // アイテム自動使用
  2438.         if(useFlg && pushFlg && Params.ItemUseMode[0]) {
  2439.             pushFlg = false;
  2440.             item = win.item();
  2441.             $gameParty.useItemSlot(item);
  2442.         }

  2443.         // マウスホイール
  2444.         if(mouseMode.SelectEnable[0]) {
  2445.             if(TouchInput.wheelY > 0) {
  2446.                 if(index <= 0) {
  2447.                     win.select(Params.SlotNumber[0] - 1);
  2448.                 } else {
  2449.                     win.select(index - 1);
  2450.                 }
  2451.             } else if(TouchInput.wheelY < 0) {
  2452.                 if(index >= Params.SlotNumber[0] - 1) {
  2453.                     win.select(0);
  2454.                 } else {
  2455.                     win.select(index + 1);
  2456.                 }
  2457.             }
  2458.             // if(TouchInput.wheelY > 0) {
  2459.             //     if(index >= Params.SlotNumber[0] - 1) {
  2460.             //         win.select(0);
  2461.             //     } else {
  2462.             //         win.select(index + 1);
  2463.             //     }
  2464.             // } else if(TouchInput.wheelY < 0) {
  2465.             //     if(index <= 0) {
  2466.             //         win.select(Params.SlotNumber[0] - 1);
  2467.             //     } else {
  2468.             //         win.select(index - 1);
  2469.             //     }
  2470.             // }
  2471.         }
  2472.     }

  2473. })();
复制代码

评分

参与人数 1赞 +1 收起 理由
Peekaboo + 1 我很赞同

查看全部评分

回复

使用道具 举报

梦石
0
星屑
133
在线时间
4 小时
注册时间
2017-9-27
回帖
7
发表于 2017-10-27 03:25:34 | 显示全部楼层
学习了,楼上几位大神
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部