找回密码
 注册用户
查看: 63|回复: 0

[RMMZ] 【汉化】仿XP/VX模式屏幕渐变

[复制链接]

88

主题

7

回帖

1277

积分

资深会员

积分
1277
发表于 2024-10-5 20:14:59 | 显示全部楼层 |阅读模式
原贴:RPGツクール2000/XPのトランジション【プラグイン】: あわや自己またもや三時 (seesaa.net)


复刻 XP/VX 模式的屏幕渐变图渐变效果。
附带渐变图素材网站:For You | ぽけっとの中のいたち (4you.bz)



Transition200X-thumbnail2.png


另存为 Transition200X.js
  1. // Transition200X.js Ver.2.0.0
  2. // MIT License (C) 2024 あわやまたな
  3. // http://opensource.org/licenses/mit-license.php

  4. /*:
  5. * @target MZ
  6. * @plugindesc 增加类似 RPG Maker XP/VX 的屏幕渐变效果。
  7. * 汉化 by 烁灵 更多脚本请访问 www.hknmtt.com
  8. * @author あわやまたな (Awaya_Matana)
  9. * @url https://awaya3ji.seesaa.net/article/499185153.html
  10. * @help Ver.2.0.0
  11. * 将渐变图像放置于 img/transitions 文件夹中。
  12. * The color of "Transfer Player" is reflected when fade to white.
  13. *
  14. * 文件名开头为 ! 会反转渐变顺序。
  15. * 文件名开头为 $ 会保持图像的宽高比。
  16. *
  17. * 本插件是 Shioinu 的 PD_Transition_MZ.js 的修改版本。
  18. *
  19. * -----------------------------------------------
  20. * Copyright (c) 2020 PixelDOG
  21. * Released under the MIT license
  22. * https://opensource.org/licenses/mit-license.php
  23. * -----------------------------------------------
  24. *
  25. * @command hideScreen
  26. * @text 隐藏屏幕内容
  27. * @desc 隐藏屏幕内容。
  28. * 在 XP 模式下固定屏幕。
  29. *
  30. * @arg duration
  31. * @text 持续时间
  32. * @desc 指定帧数。
  33. * 输入数字或从下拉框中选择。
  34. * @default normal
  35. * @type combo
  36. * @option 立刻
  37. * @value instant
  38. * @option 快速
  39. * @value faster
  40. * @option 正常
  41. * @value normal
  42. * @option 缓慢
  43. * @value slower
  44. *
  45. * @arg wait
  46. * @text 等待
  47. * @desc 等待渐变完成。
  48. * @default true
  49. * @type boolean
  50. *
  51. * @command showScreen
  52. * @text 显示屏幕内容
  53. * @desc 显示屏幕内容。
  54. *
  55. * @arg duration
  56. * @text 持续时间
  57. * @desc 指定帧数。
  58. * 输入数字或从下拉框中选择。
  59. * @default normal
  60. * @type combo
  61. * @option 立刻
  62. * @value instant
  63. * @option 快速
  64. * @value faster
  65. * @option 正常
  66. * @value normal
  67. * @option 缓慢
  68. * @value slower
  69. *
  70. * @arg wait
  71. * @text 等待
  72. * @desc 等待渐变完成。
  73. * @default true
  74. * @type boolean
  75. *
  76. * @command changeImage
  77. * @text 更改图像
  78. * @desc 设置渐变图像。
  79. *
  80. * @arg type
  81. * @text 类型
  82. * @desc 选择渐变的类型。
  83. * 在 XP 模式下使用(显示)设置。
  84. *
  85. * @option 插件指令(隐藏)
  86. * @value Plugin Command (Hide)
  87. * @option 插件指令(显示)
  88. * @value Plugin Command (Show)
  89. * @option 场所移动(隐藏)
  90. * @value Transfer Player (Hide)
  91. * @option 场所移动(显示)
  92. * @value Transfer Player (Show)
  93. * @option  战斗开始(隐藏)
  94. * @value Start Battle (Hide)
  95. * @option 战斗开始(显示)
  96. * @value Start Battle (Show)
  97. * @option 战斗结束(隐藏)
  98. * @value End Battle (Hide)
  99. * @option 战斗结束(显示)
  100. * @value End Battle (Show)
  101. * @default Plugin Command (Hide)
  102. *
  103. * @arg name
  104. * @text 图像
  105. * @desc 指定文件名。
  106. * 设置为(无)以使用标准淡入效果。
  107. * @type file
  108. * @default
  109. * @dir img/transitions
  110. *
  111. * @command changeMode
  112. * @text 更改模式
  113. * @desc 在 2000 模式和 XP 模式之间切换。
  114. *
  115. * @arg type
  116. * @text 类型
  117. * @desc 选择渐变的类型。
  118. * @type select
  119. * @option 插件指令
  120. * @value Plugin Command
  121. * @option 场所移动
  122. * @value Transfer Player
  123. * @option 战斗开始
  124. * @value Start Battle
  125. * @option 战斗结束
  126. * @value End Battle
  127. * @default Plugin Command
  128. *
  129. * @arg mode
  130. * @text 模式
  131. * @desc 切换模式。
  132. * @type select
  133. * @option 2000
  134. * @option XP
  135. * @default 2000
  136. *
  137. * @command changeColor
  138. * @text 更改颜色
  139. * @desc 更改颜色。
  140. *
  141. * @arg type
  142. * @text 类型
  143. * @desc 选择渐变的类型。
  144. * @type select
  145. * @option 插件指令
  146. * @value Plugin Command
  147. * @option 场所移动
  148. * @value Transfer Player
  149. * @option 战斗开始
  150. * @value Start Battle
  151. * @option 战斗结束
  152. * @value End Battle
  153. * @default Plugin Command
  154. *
  155. * @arg color
  156. * @text 颜色
  157. * @desc 请使用逗号分隔输入 RGB。
  158. * 如果未输入,则为黑色。
  159. * @type string
  160. * @default
  161. *
  162. * @command changeSmoothness
  163. * @text 更改平滑度
  164. * @desc 切换渐变的平滑度。
  165. *
  166. * @arg type
  167. * @text 类型
  168. * @desc 选择渐变的类型。
  169. * @type select
  170. * @option 插件指令
  171. * @value Plugin Command
  172. * @option 场所移动
  173. * @value Transfer Player
  174. * @option 战斗开始
  175. * @value Start Battle
  176. * @option 战斗结束
  177. * @value End Battle
  178. * @default Plugin Command
  179. *
  180. * @arg smoothness
  181. * @text 平滑度
  182. * @desc 平滑屏幕变化。
  183. * 在 0-7 范围内指定。0 不平滑。
  184. * @default 4.5
  185. *
  186. * @command clearTransition
  187. * @text 清除渐变
  188. * @desc 重置渐变设置为默认。
  189. *
  190. * @command waitForCompletion
  191. * @text 等待完成
  192. * @desc 等待渐变完成。
  193. *
  194. * @param pluginCommand
  195. * @text 插件命令
  196. * @desc 选择渐变的类型。
  197. * 在 XP 模式下使用(显示)设置。
  198. * @type struct<settings>
  199. *
  200. * @param transfer
  201. * @text 场所移动
  202. * @desc 选择渐变的类型。
  203. * 在 XP 模式下使用(显示)设置。
  204. * @type struct<settings>
  205. *
  206. * @param battleStart
  207. * @text 战斗开始
  208. * @desc 选择渐变的类型。
  209. * 在 XP 模式下使用(显示)设置。
  210. * @type struct<settings>
  211. *
  212. * @param battleEnd
  213. * @text 战斗结束
  214. * @desc 选择渐变的类型。
  215. * 在 XP 模式下使用(显示)设置。
  216. * @type struct<settings>
  217. *
  218. * @param instant
  219. * @text 立即
  220. * @desc 指定帧数。
  221. * @type number
  222. * @default 1
  223. *
  224. * @param faster
  225. * @text 快速
  226. * @desc 指定帧数。
  227. * @type number
  228. * @default 24
  229. *
  230. * @param normal
  231. * @text 正常
  232. * @desc 指定帧数。
  233. * @type number
  234. * @default 48
  235. *
  236. * @param slower
  237. * @text 缓慢
  238. * @desc 指定帧数。
  239. * @type number
  240. * @default 96
  241. *
  242. * @param encounterEffect
  243. * @text 遭遇效果
  244. * @desc 选择想要用于遭遇效果的制作工具名。
  245. * @type select
  246. * @option 2000
  247. * @option XP
  248. * @option VX
  249. * @option VXAce
  250. * @option Fes
  251. * @option MZ
  252. * @default MZ
  253. *
  254. * @param hideCharacters
  255. * @text 隐藏角色
  256. * @desc 在遭遇效果期间隐藏角色。
  257. * @type select
  258. * @option default
  259. * @option true
  260. * @option false
  261. * @default default
  262. *
  263. * @param sceneTransition
  264. * @text 场景过渡
  265. * @desc 选择想要用于场景过渡的制作工具名。
  266. * @type select
  267. * @option 2000
  268. * @option XP
  269. * @option VX (VXAce)
  270. * @value VX
  271. * @option MZ
  272. * @default MZ
  273. *
  274. * @param speedUpWindows
  275. * @text 加速窗口
  276. * @desc 加速打开和关闭窗口的速度。
  277. * “默认”将匹配场景过渡规格。
  278. * @type select
  279. * @option default
  280. * @option true
  281. * @option false
  282. * @default default
  283. *
  284. * @param gameoverBgm
  285. * @text 失败游戏背景音乐
  286. * @desc 2000 的再现功能(附加)
  287. * @type struct<bgm>
  288. *
  289. */

  290. /*~struct~settings:
  291. *
  292. * @param name1
  293. * @text 隐藏时渐变图像
  294. * @desc 指定文件名。
  295. * 设置为(无)以使用标准淡入效果。
  296. * @type file
  297. * @default
  298. * @dir img/transitions
  299. *
  300. * @param name2
  301. * @text 显示时渐变图像 / XP 模式时渐变图像
  302. * @desc 指定文件名。
  303. * 设置为(无)以使用标准淡入效果。
  304. * @type file
  305. * @default
  306. * @dir img/transitions
  307. *
  308. * @param mode
  309. * @text 模式
  310. * @desc 切换模式。
  311. * @type select
  312. * @option 2000
  313. * @option XP
  314. * @default 2000
  315. *
  316. * @param color
  317. * @text 颜色
  318. * @desc 请使用逗号分隔输入 RGB。
  319. * 如果未输入,则为黑色。
  320. * @type string
  321. * @default
  322. *
  323. * @param smoothness
  324. * @text 平滑度
  325. * @desc 平滑屏幕变化。
  326. * 在 0-7 范围内指定。0 不平滑。
  327. * @default 4.5

  328. /*~struct~bgm:
  329. *
  330. * @param name
  331. * @text 名称
  332. * @desc
  333. * @type file
  334. * @default
  335. * @dir audio/bgm
  336. *
  337. * @param volume
  338. * @text 音量
  339. * @desc
  340. * @type number
  341. * @default 90
  342. * @min 0
  343. *
  344. * @param pitch
  345. * @text 音调
  346. * @desc
  347. * @type number
  348. * @default 100
  349. * @min 0
  350. *
  351. * @param pan
  352. * @text 声像(左右声道)
  353. * @desc
  354. * @type number
  355. * @default 0
  356. * @min -100
  357. * @max 100
  358. */

  359. /*:ja
  360. * @target MZ
  361. * @plugindesc 画像によるトランジション演出機能を追加します。
  362. * @author あわやまたな (Awaya_Matana)
  363. * @url https://awaya3ji.seesaa.net/article/499185153.html
  364. * @help トランジション画像はimg/transitionsフォルダに配置してください。
  365. * 「場所移動」の色はフェードを白にすると反映されます。
  366. *
  367. * ファイル名先頭に!があるとトランジションの順序を反転します。
  368. * ファイル名先頭に$があると画像のアスペクト比を保持します。
  369. *
  370. * このプラグインはしおいぬ氏のPD_Transition_MZ.jsを改変したものです。
  371. *
  372. * -----------------------------------------------
  373. * Copyright (c) 2020 PixelDOG
  374. * Released under the MIT license
  375. * https://opensource.org/licenses/mit-license.php
  376. * -----------------------------------------------
  377. *
  378. * [更新履歴]
  379. * 2023/04/30:Ver.1.0.0 公開。
  380. * 2023/07/04:Ver.1.0.1 不具合修正。
  381. * 2024/09/08:Ver.2.0.0 不具合修正。スムージング機能、エンカウントエフェクト、シーン遷移、プラグインコマンドを追加。
  382. *
  383. * @command hideScreen
  384. * @text 画面の消去
  385. * @desc 画面を消去します。
  386. * XPモード時は画面を固定します。
  387. *
  388. * @arg duration
  389. * @text 時間
  390. * @desc フレーム数を指定します。
  391. * 数値を入力するかコンボボックスから選択します。
  392. * @default 普通
  393. * @type combo
  394. * @option 瞬時
  395. * @option 速い
  396. * @option 普通
  397. * @option 遅い
  398. *
  399. * @arg wait
  400. * @text 完了までウェイト
  401. * @desc トランジョンが完了するまで待ちます。
  402. * @default true
  403. * @type boolean
  404. *
  405. * @command showScreen
  406. * @text 画面の表示
  407. * @desc 画面を表示します。
  408. *
  409. * @arg duration
  410. * @text 時間
  411. * @desc フレーム数を指定します。
  412. * 数値を入力するかコンボボックスから選択します。
  413. * @default 普通
  414. * @type combo
  415. * @option 瞬時
  416. * @option 速い
  417. * @option 普通
  418. * @option 遅い
  419. *
  420. * @arg wait
  421. * @text 完了までウェイト
  422. * @desc トランジョンが完了するまで待ちます。
  423. * @default true
  424. * @type boolean
  425. *
  426. * @command changeImage
  427. * @text 画像の変更
  428. * @desc トランジションの画像を設定します。
  429. *
  430. * @arg type
  431. * @text 種類
  432. * @desc 画面切り替えの種類を選択します。
  433. * XPモード時は表示の設定を使用します。
  434. * @type select
  435. *
  436. * @option プラグインコマンド/消去
  437. * @value Plugin Command (Hide)
  438. * @option プラグインコマンド/表示
  439. * @value Plugin Command (Show)
  440. * @option 場所移動/消去
  441. * @value Transfer Player (Hide)
  442. * @option 場所移動/表示
  443. * @value Transfer Player (Show)
  444. * @option 戦闘開始/消去
  445. * @value Start Battle (Hide)
  446. * @option 戦闘開始/表示
  447. * @value Start Battle (Show)
  448. * @option 戦闘終了/消去
  449. * @value End Battle (Hide)
  450. * @option 戦闘終了/表示
  451. * @value End Battle (Show)
  452. * @default Plugin Command (Hide)
  453. *
  454. * @arg name
  455. * @text 画像
  456. * @desc ファイル名を指定します。
  457. * (なし)にすると標準のフェードを行います。
  458. * @type file
  459. * @default
  460. * @dir img/transitions
  461. *
  462. * @command changeMode
  463. * @text モードの変更
  464. * @desc 2000形式、XP形式を切り替えます。
  465. *
  466. * @arg type
  467. * @text 種類
  468. * @desc 画面切り替えの種類を選択します。
  469. * @type select
  470. * @option プラグインコマンド
  471. * @value Plugin Command
  472. * @option 場所移動
  473. * @value Transfer Player
  474. * @option 戦闘開始
  475. * @value Start Battle
  476. * @option 戦闘終了
  477. * @value End Battle
  478. * @default Plugin Command
  479. *
  480. * @arg mode
  481. * @text モード
  482. * @desc モードを切り替えます。
  483. * @type select
  484. * @option 2000
  485. * @option XP
  486. * @default 2000
  487. *
  488. * @command changeColor
  489. * @text 色の変更
  490. * @desc 色を変更します。
  491. *
  492. * @arg type
  493. * @text 種類
  494. * @desc 画面切り替えの種類を選択します。
  495. * @type select
  496. * @option プラグインコマンド
  497. * @value Plugin Command
  498. * @option 場所移動
  499. * @value Transfer Player
  500. * @option 戦闘開始
  501. * @value Start Battle
  502. * @option 戦闘終了
  503. * @value End Battle
  504. * @default Plugin Command
  505. *
  506. * @arg color
  507. * @text 色
  508. * @desc コンマ区切りでRGBを入力して下さい。
  509. * 未入力で黒。
  510. * @type string
  511. * @default
  512. *
  513. * @command changeSmoothness
  514. * @text 滑らかさの変更
  515. * @desc 画面遷移の滑らかさを切り替えます。
  516. *
  517. * @arg type
  518. * @text 種類
  519. * @desc 画面切り替えの種類を選択します。
  520. * @type select
  521. * @option プラグインコマンド
  522. * @value Plugin Command
  523. * @option 場所移動
  524. * @value Transfer Player
  525. * @option 戦闘開始
  526. * @value Start Battle
  527. * @option 戦闘終了
  528. * @value End Battle
  529. * @default Plugin Command
  530. *
  531. * @arg smoothness
  532. * @text 滑らかさ
  533. * @desc 画面の変化を滑らかにします。
  534. * 0-7の範囲で指定。0でスムージングなし。
  535. * @default 4.5
  536. *
  537. * @command clearTransition
  538. * @text トランジションの初期化
  539. * @desc トランジションの設定をデフォルトに戻します。
  540. *
  541. * @command waitForCompletion
  542. * @text 完了までウェイト
  543. * @desc トランジションが完了するまで待ちます。
  544. *
  545. * @param pluginCommand
  546. * @text プラグインコマンド
  547. * @desc トランジションの設定をします。
  548. * XPモード時は表示の設定を使用します。
  549. * @type struct<settings>
  550. *
  551. * @param transfer
  552. * @text 場所移動
  553. * @desc トランジションの設定をします。
  554. * XPモード時は表示の設定を使用します。
  555. * @type struct<settings>
  556. *
  557. * @param battleStart
  558. * @text 戦闘開始
  559. * @desc トランジションの設定をします。
  560. * XPモード時は表示の設定を使用します。
  561. * @type struct<settings>
  562. *
  563. * @param battleEnd
  564. * @text 戦闘終了
  565. * @desc トランジションの設定をします。
  566. * XPモード時は表示の設定を使用します。
  567. * @type struct<settings>
  568. *
  569. * @param instant
  570. * @text 瞬時
  571. * @desc トランジションのフレーム数です。
  572. * @type number
  573. * @default 1
  574. *
  575. * @param faster
  576. * @text 速い
  577. * @desc トランジションのフレーム数です。
  578. * @type number
  579. * @default 24
  580. *
  581. * @param normal
  582. * @text 普通
  583. * @desc トランジションのフレーム数です。
  584. * @type number
  585. * @default 48
  586. *
  587. * @param slower
  588. * @text 遅い
  589. * @desc トランジションのフレーム数です。
  590. * @type number
  591. * @default 96
  592. *
  593. * @param encounterEffect
  594. * @text エンカウントエフェクト
  595. * @desc どのツクールに準拠したエンカウントエフェクトを行うか選択します。
  596. * @type select
  597. * @option 2000
  598. * @option XP
  599. * @option VX
  600. * @option VXAce
  601. * @option Fes
  602. * @option MZ
  603. * @default MZ
  604. *
  605. * @param hideCharacters
  606. * @text キャラクターを隠す
  607. * @desc エンカウントエフェクト中にキャラクターを隠します。
  608. * @type select
  609. * @option デフォルト
  610. * @value default
  611. * @option true
  612. * @option false
  613. * @default default
  614. *
  615. * @param sceneTransition
  616. * @text シーン遷移
  617. * @desc どのツクールに準拠したシーン遷移を行うか選択します。
  618. * @type select
  619. * @option 2000
  620. * @option XP
  621. * @option VX (VXAce)
  622. * @value VX
  623. * @option MZ
  624. * @default MZ
  625. *
  626. * @param speedUpWindows
  627. * @text ウィンドウ高速化
  628. * @desc ウィンドウの開閉を高速化します。
  629. * 「デフォルト」はシーン遷移の仕様に合わせます。
  630. * @type select
  631. * @option デフォルト
  632. * @value default
  633. * @option true
  634. * @option false
  635. * @default default
  636. *
  637. * @param gameoverBgm
  638. * @text ゲームオーバーBGM
  639. * @desc 2000の再現機能(おまけ)
  640. * @type struct<bgm>
  641. *
  642. */

  643. /*~struct~settings:ja
  644. *
  645. * @param name1
  646. * @text 消去時の画像
  647. * @desc ファイル名を指定します。
  648. * (なし)にすると標準のフェードを行います。
  649. * @type file
  650. * @default
  651. * @dir img/transitions
  652. *
  653. * @param name2
  654. * @text 表示時の画像/XPモードの画像
  655. * @desc ファイル名を指定します。
  656. * (なし)にすると標準のフェードを行います。
  657. * @type file
  658. * @default
  659. * @dir img/transitions
  660. *
  661. * @param mode
  662. * @text モード
  663. * @desc モードを切り替えます。
  664. * @type select
  665. * @option 2000
  666. * @option XP
  667. * @default 2000
  668. *
  669. * @param color
  670. * @text 色
  671. * @desc コンマ区切りでRGBを入力して下さい。
  672. * 未入力で黒。
  673. * @type string
  674. * @default
  675. *
  676. * @param smoothness
  677. * @text 滑らかさ
  678. * @desc 画面の変化を滑らかにします。
  679. * 0-7の範囲で指定。0でスムージングなし。
  680. * @default 4.5
  681. */

  682. /*~struct~bgm:ja
  683. *
  684. * @param name
  685. * @text 名前
  686. * @desc
  687. * @type file
  688. * @default
  689. * @dir audio/bgm
  690. *
  691. * @param volume
  692. * @text 音量
  693. * @desc
  694. * @type number
  695. * @default 90
  696. * @min 0
  697. *
  698. * @param pitch
  699. * @text ピッチ
  700. * @desc
  701. * @type number
  702. * @default 100
  703. * @min 0
  704. *
  705. * @param pan
  706. * @text 位相
  707. * @desc
  708. * @type number
  709. * @default 0
  710. * @min -100
  711. * @max 100
  712. */


  713. (function(){
  714.         'use strict';

  715.         const pluginName = document.currentScript.src.match(/^.*\/(.*).js$/)[1];
  716.         const parameters = PluginManager.parameters(pluginName);

  717.         const instant = Number(parameters["instant"]);
  718.         const faster = Number(parameters["faster"]);
  719.         const normal = Number(parameters["normal"]);
  720.         const slower = Number(parameters["slower"]);
  721.         const encounterEffect = parameters["encounterEffect"] || "MZ";
  722.         const sceneTransition = parameters["sceneTransition"] || "MZ";
  723.         let hideCharacters = parameters["hideCharacters"] || "default";
  724.         let speedUpWindows = parameters["speedUpWindows"] || "default";
  725.         if (hideCharacters === "default") {
  726.                 hideCharacters = encounterEffect === "MZ";
  727.         } else {
  728.                 hideCharacters = hideCharacters === "true";
  729.         }
  730.         if (speedUpWindows === "default") {
  731.                 speedUpWindows = sceneTransition === "VX" || sceneTransition === "2000";
  732.         } else {
  733.                 speedUpWindows = speedUpWindows === "true";
  734.         }
  735.         const gameoverBgm = JSON.parse(parameters.gameoverBgm || "{}");
  736.         gameoverBgm.volume = parseInt(gameoverBgm.volume || 90);
  737.         gameoverBgm.pitch = parseInt(gameoverBgm.pitch || 100);
  738.         gameoverBgm.pan = parseInt(gameoverBgm.pan || 0);
  739.         const defaultSettings = [];
  740.         defaultSettings.push(JSON.parse(parameters["pluginCommand"] || "{}"));
  741.         defaultSettings.push(JSON.parse(parameters["transfer"] || "{}"));
  742.         defaultSettings.push(JSON.parse(parameters["battleStart"] || "{}"));
  743.         defaultSettings.push(JSON.parse(parameters["battleEnd"] || "{}"));
  744.         const transitionNames = [];
  745.         const transitionXps = [];
  746.         const transitionColors = [];
  747.         const transitionSmooths = [];
  748.         defaultSettings.forEach(params => {
  749.                 transitionNames.push(params.name1 || "");
  750.                 transitionNames.push(params.name2 || "");
  751.                 transitionXps.push(params.mode === "XP");
  752.                 const color = !!params.color && params.color.split(",").map(Number);
  753.                 transitionColors.push(color);
  754.                 transitionSmooths.push(Number(params.smoothness || 4.5));
  755.         });

  756.         const typeList = [
  757.         "Plugin Command (Hide)",
  758.         "Plugin Command (Show)",
  759.         "Transfer Player (Hide)",
  760.         "Transfer Player (Show)",
  761.         "Start Battle (Hide)",
  762.         "Start Battle (Show)",
  763.         "End Battle (Hide)",
  764.         "End Battle (Show)"
  765.         ];

  766.         const commandList = [
  767.         {"code":112,"indent":0,"parameters":[]},
  768.         {"code":357,"indent":1,"parameters":[pluginName,"updateWaitMode","",{}]},
  769.         {"code":0,"indent":1,"parameters":[]},
  770.         {"code":413,"indent":0,"parameters":[]},
  771.         {"code":0,"indent":0,"parameters":[]}
  772.         ];

  773.         function typeToIndex(type, dev = 1) {
  774.                 let index = 0;
  775.                 if (typeof type === "string") {
  776.                         index = typeList.findIndex(str => str.startsWith(type));
  777.                 } else {
  778.                         index = Number(type || 0);
  779.                 }
  780.                 if (index < 0) {
  781.                         index = 0;
  782.                 }
  783.                 return Math.floor(index / dev);
  784.         }

  785.         function getDuration(duration) {
  786.                 switch (duration) {
  787.                 case "instant":
  788.                 case "瞬時":
  789.                         return instant;
  790.                 case "faster":
  791.                 case "速い":
  792.                         return faster;
  793.                 case "normal":
  794.                 case "普通":
  795.                         return normal;
  796.                 case "slower":
  797.                 case "遅い":
  798.                         return slower;
  799.                 }
  800.                 return Number(duration || 0);
  801.         }

  802.         //-----------------------------------------------------------------------------
  803.         // SceneManager
  804.         //スクショ
  805.         SceneManager.snapForTransition = function() {
  806.                 if (this._transitionBitmap) {
  807.                         this._transitionBitmap.destroy();
  808.                 }
  809.                 this._transitionBitmap = this.snap();
  810.         };

  811.         SceneManager.transitionBitmap = function() {
  812.                 return this._transitionBitmap;
  813.         };

  814.         if (sceneTransition === "VX") {
  815.                 const _SceneManager_goto = SceneManager.goto;
  816.                 SceneManager.goto = function(sceneClass) {
  817.                         _SceneManager_goto.call(this, sceneClass);
  818.                         if (this.isNextScene(Scene_Gameover)) {
  819.                                 this._nextScene.playGameoverMusic();
  820.                         }
  821.                 };
  822.         }

  823.         //-----------------------------------------------------------------------------
  824.         // PluginManager

  825.         const _PluginManager = window.PluginManagerEx ?? PluginManager
  826.         const script = window.PluginManagerEx ? document.currentScript : pluginName;
  827.         _PluginManager.registerCommand(script, "hideScreen", function(args) {
  828.                 const type = "Plugin Command (Hide)";
  829.                 const xpMode = $gameSystem.transitionXp(type);
  830.                 const duration = getDuration(args.duration);
  831.                 SceneManager._scene.hideScreenWithPreset(duration, type);
  832.                 if (String(args.wait) === "true" && !xpMode) {
  833.                         this.setupChild(commandList);
  834.                 }
  835.         });

  836.         _PluginManager.registerCommand(script, "showScreen", function(args) {
  837.                 const type = "Plugin Command (Show)";
  838.                 const duration = getDuration(args.duration);
  839.                 SceneManager._scene.showScreenWithPreset(duration, type);
  840.                 if (String(args.wait) === "true") {
  841.                         this.setupChild(commandList);
  842.                 }
  843.         });

  844.         _PluginManager.registerCommand(script, "changeImage", function(args) {
  845.                 $gameSystem.setTransitionName(args.type, args.name);
  846.         });

  847.         _PluginManager.registerCommand(script, "changeMode", function(args) {
  848.                 $gameSystem.setTransitionXp(args.type, args.mode === "XP");
  849.         });

  850.         _PluginManager.registerCommand(script, "changeColor", function(args) {
  851.                 $gameSystem.setTransitionColor(args.type, args.color !== "" && String(args.color).split(",").map(Number));
  852.         });

  853.         _PluginManager.registerCommand(script, "changeSmoothness", function(args) {
  854.                 $gameSystem.setTransitionSmoothness(args.type, +args.smoothness);
  855.         });

  856.         PluginManager.registerCommand(pluginName, "clearTransition", function() {
  857.                 $gameSystem.clearTransitionData();
  858.         });

  859.         PluginManager.registerCommand(pluginName, "waitForCompletion", function() {
  860.                 this.setupChild(commandList);
  861.         });

  862.         PluginManager.registerCommand(pluginName, "updateWaitMode", function() {
  863.                 if (SceneManager._scene.isTransitioning()) {
  864.                         this.wait(1);
  865.                 } else {
  866.                         this.command113();
  867.                 }
  868.         });

  869.         //-----------------------------------------------------------------------------
  870.         // Tilemap
  871.         //エンカウントエフェクト時に画面を固めるためだけの関数
  872.         if (!hideCharacters) {
  873.                 Tilemap.prototype.setFreeze = function(freeze) {
  874.                         this._frozenMap = freeze;
  875.                 };

  876.                 const _Tilemap_update = Tilemap.prototype.update;
  877.                 Tilemap.prototype.update = function(freeze) {
  878.                         if (!this._frozenMap) {
  879.                                 _Tilemap_update.call(this);
  880.                         }
  881.                 };
  882.         }

  883.         //-----------------------------------------------------------------------------
  884.         // Game_System
  885.         //演出に使うトランジションデータ
  886.         Game_System.prototype.clearTransitionData = function() {
  887.                 delete this._transitionNames;
  888.                 delete this._transitionXps;
  889.                 delete this._transitionColors;
  890.                 delete this._transitionSmooths;
  891.         };

  892.         Game_System.prototype.transitionData = function(type) {
  893.                 const data = {
  894.                         name: this.transitionName(type),
  895.                         xpMode: this.transitionXp(type),
  896.                         color: this.transitionColor(type),
  897.                         smoothness: this.transitionSmoothness(type)
  898.                 }
  899.                 return data;
  900.         };

  901.         Game_System.prototype.setTransitionName = function(type, fileName) {
  902.                 if (!this._transitionNames) {
  903.                         this._transitionNames = [];
  904.                 }
  905.                 const index = typeToIndex(type);
  906.                 if (fileName != null) {
  907.                         this._transitionNames[index] = String(fileName);
  908.                 } else {
  909.                         delete this._transitionNames[index];
  910.                 }
  911.         };

  912.         Game_System.prototype.transitionName = function(type) {
  913.                 const index = typeToIndex(type)
  914.                 const sysData = this._transitionNames && this._transitionNames[index];
  915.                 if (sysData != null) {
  916.                         return sysData;
  917.                 }
  918.                 return transitionNames[index];
  919.         };

  920.         Game_System.prototype.setTransitionXp = function(type, bool) {
  921.                 if (!this._transitionXps) {
  922.                         this._transitionXps = [];
  923.                 }
  924.                 const index = typeToIndex(type, 2);
  925.                 if (bool != null) {
  926.                         this._transitionXps[index] = bool;
  927.                 } else {
  928.                         delete this._transitionXps[index];
  929.                 }
  930.         };

  931.         Game_System.prototype.transitionXp = function(type) {
  932.                 const index = typeToIndex(type, 2);
  933.                 const sysData = this._transitionXps && this._transitionXps[index];
  934.                 if (sysData != null) {
  935.                         return sysData;
  936.                 }
  937.                 return transitionXps[index];
  938.         };

  939.         Game_System.prototype.setTransitionColor = function(type, color) {
  940.                 if (!this._transitionColors) {
  941.                         this._transitionColors = [];
  942.                 }
  943.                 const index = typeToIndex(type, 2);
  944.                 if (color != null) {
  945.                         this._transitionColors[index] = typeof color === "boolean" ? color : color.clone();
  946.                 } else {
  947.                         delete this._transitionColors[index];
  948.                 }
  949.         };

  950.         Game_System.prototype.transitionColor = function(type) {
  951.                 const index = typeToIndex(type, 2);
  952.                 let color = this._transitionColors && this._transitionColors[index];
  953.                 if (color == null) {
  954.                         color = transitionColors[index];
  955.                 }
  956.                 return typeof color === "boolean" ? color : color.clone()
  957.         };

  958.         Game_System.prototype.setTransitionSmoothness = function(type, value) {
  959.                 if (!this._transitionSmooths) {
  960.                         this._transitionSmooths = [];
  961.                 }
  962.                 const index = typeToIndex(type, 2);
  963.                 if (value != null) {
  964.                         this._transitionSmooths[index] = value;
  965.                 } else {
  966.                         delete this._transitionSmooths[index];
  967.                 }
  968.         };

  969.         Game_System.prototype.transitionSmoothness = function(type) {
  970.                 const index = typeToIndex(type, 2);
  971.                 const sysData = this._transitionSmooths && this._transitionSmooths[index];
  972.                 if (sysData != null) {
  973.                         return sysData;
  974.                 }
  975.                 return transitionSmooths[index];
  976.         };

  977.         //-----------------------------------------------------------------------------
  978.         // Game_Temp
  979.         //マップ移動時に色や状態を保存するための一時データ。
  980.         //旧作と異なる方式で行う為必須。
  981.         Game_Temp.prototype.clearMapTransition = function() {
  982.                 this._inMapTransition = false;
  983.                 this._mapTransitionColor = false;
  984.                 this._mapTransitionXp = false;
  985.         };

  986.         Game_Temp.prototype.setMapTransition = function(xpMode, color) {
  987.                 this._inMapTransition = true;
  988.                 this._mapTransitionColor = color;
  989.                 this._mapTransitionXp = xpMode;
  990.         };

  991.         Game_Temp.prototype.inMapTransition = function() {
  992.                 return !!this._inMapTransition;
  993.         };

  994.         Game_Temp.prototype.mapTransitionData = function() {
  995.                 const data = {
  996.                         color: this._mapTransitionColor,
  997.                         xpMode: !!this._mapTransitionXp
  998.                 }
  999.                 return data;
  1000.         };

  1001.         //-----------------------------------------------------------------------------
  1002.         // Scene_Base

  1003.         const _Scene_Base_initialize = Scene_Base.prototype.initialize;
  1004.         Scene_Base.prototype.initialize = function() {
  1005.                 _Scene_Base_initialize.call(this);
  1006.                 this._transitionSprite = null;
  1007.                 this._transitionSign = 0;
  1008.                 this._transitionDuration = 0;
  1009.                 this._transitionUpdated = false;
  1010.         };
  1011.         //必要なら行う
  1012.         const _Scene_Base_start = Scene_Base.prototype.start;
  1013.         Scene_Base.prototype.start = function() {
  1014.                 _Scene_Base_start.call(this);
  1015.                 if (this.needsTransition(1)) {
  1016.                         this.performTransition();
  1017.                 }
  1018.         };

  1019.         Scene_Base.prototype.performTransition = function() {
  1020.                 this.executeTransition(this.transitionSpeed());  //シーン変更直前のスクショを利用してフェード
  1021.         };

  1022.         if (sceneTransition === "2000") {
  1023.                 const _Scene_Base_stop = Scene_Base.prototype.stop;
  1024.                 Scene_Base.prototype.stop = function() {
  1025.                         _Scene_Base_stop.call(this);
  1026.                         if (this.needsTransition(-1) && !this.isFading()) {
  1027.                                 this.startFadeOut(this.transitionSpeed());
  1028.                         }
  1029.                 };
  1030.         }

  1031.         const _Scene_Base_terminate = Scene_Base.prototype.terminate;
  1032.         Scene_Base.prototype.terminate = function() {
  1033.                 _Scene_Base_terminate.call(this);
  1034.                 this.snapForTransition();
  1035.         };
  1036.         //シーン遷移が旧ツクール仕様なら利用
  1037.         Scene_Base.prototype.needsTransition = function() {
  1038.                 return sceneTransition !== "MZ";
  1039.         };
  1040.         //トランジションを開始した直後なら時間を上書き(既存機能と互換性を保つため)
  1041.         const _Scene_Base_startFadeIn = Scene_Base.prototype.startFadeIn;
  1042.         Scene_Base.prototype.startFadeIn = function(duration, white) {
  1043.                 if (this.isTransitioning() && this._transitionSign > 0 && !this._transitionUpdated) {
  1044.                         this._transitionDuration = duration || this._transitionDuration;
  1045.                         return;
  1046.                 }
  1047.                 _Scene_Base_startFadeIn.apply(this, arguments);
  1048.         };

  1049.         const _Scene_Base_startFadeOut = Scene_Base.prototype.startFadeOut;
  1050.         Scene_Base.prototype.startFadeOut = function(duration, white) {
  1051.                 if (this.isTransitioning() && this._transitionSign < 0 && !this._transitionUpdated) {
  1052.                         this._transitionDuration = duration || this._transitionDuration;
  1053.                         return;
  1054.                 }
  1055.                 _Scene_Base_startFadeOut.apply(this, arguments);
  1056.         };
  1057.        
  1058.         Scene_Base.prototype.transitionSpeed = function() {
  1059.                 return 12;
  1060.         };

  1061.         if (sceneTransition === "2000") {
  1062.                 Scene_Base.prototype.transitionSpeed = function() {
  1063.                         return 5;
  1064.                 };
  1065.         } else if (sceneTransition === "VX") {
  1066.                 Scene_Base.prototype.transitionSpeed = function() {
  1067.                         return 10;
  1068.                 };
  1069.         }

  1070.         const _Scene_Base_isFading = Scene_Base.prototype.isFading;
  1071.         Scene_Base.prototype.isFading = function() {
  1072.                 return _Scene_Base_isFading.call(this) || this.isTransitioning();
  1073.         };

  1074.         Scene_Base.prototype.isTransitioning = function() {
  1075.                 return this._transitionDuration > 0;
  1076.         };

  1077.         Scene_Base.prototype.rejectFade = function() {
  1078.                 this._fadeSign = 0;
  1079.                 this._fadeDuration = 0;
  1080.                 this._fadeWhite = 0;
  1081.                 this._fadeOpacity = 0;
  1082.                 this.updateColorFilter();
  1083.         };

  1084.         Scene_Base.prototype.showScreenWithPreset = function(duration, type, color) {
  1085.                 const data = $gameSystem.transitionData(type);
  1086.                 data.color = color ?? data.color;
  1087.                 this._transitionDuration = duration || (data.xpMode && !name ? 15 : 30);
  1088.                 this.setupTransition(data, 1);
  1089.         };
  1090.         //2000:画面の表示
  1091.         Scene_Base.prototype.showScreen = function(duration, name, smoothness, pos, color) {
  1092.                 const data = {
  1093.                         name: name,
  1094.                         xpMode: false,
  1095.                         pos: pos,
  1096.                         color: color,
  1097.                         smoothness: smoothness
  1098.                 };
  1099.                 this._transitionDuration = duration || 30;
  1100.                 this.setupTransition(data, 1);
  1101.         };
  1102.         //XP:トランジション実行
  1103.         Scene_Base.prototype.executeTransition = function(duration, name, smoothness, pos) {
  1104.                 const data = {
  1105.                         name: name,
  1106.                         xpMode: true,
  1107.                         pos: pos,
  1108.                         smoothness: smoothness
  1109.                 };
  1110.                 this._transitionDuration = duration || (name ? 30 : 15);
  1111.                 this.setupTransition(data, 1);
  1112.         };

  1113.         Scene_Base.prototype.hideScreenWithPreset = function(duration, type, color) {
  1114.                 const data = $gameSystem.transitionData(type);
  1115.                 data.color = color ?? data.color;
  1116.                 this._transitionDuration = duration || 30;
  1117.                 this.setupTransition(data, -1);
  1118.         };
  1119.         //2000:画面の消去
  1120.         Scene_Base.prototype.hideScreen = function(duration, name, smoothness, pos, color) {
  1121.                 const data = {
  1122.                         name: name,
  1123.                         xpMode: false,
  1124.                         pos: pos,
  1125.                         color: color,
  1126.                         smoothness: smoothness
  1127.                 };
  1128.                 this._transitionDuration = duration || 30;
  1129.                 this.setupTransition(data, -1);
  1130.         };
  1131.         //XP:トランジション準備
  1132.         Scene_Base.prototype.prepareForTransition = function() {
  1133.                 const data = {
  1134.                         xpMode: true
  1135.                 };
  1136.                 this.setupTransition(data, -1);
  1137.         };

  1138.         Scene_Base.prototype.snapForTransition = function() {
  1139.                 SceneManager.snapForTransition();
  1140.         };

  1141.         Scene_Base.prototype.createTransitionSprite = function(data) {
  1142.                 if (this._transitionSprite) {
  1143.                         this.removeTransitionSprite();
  1144.                 }
  1145.                 this._transitionSprite = new Sprite_Transition(data);
  1146.                 this.addChild(this._transitionSprite);
  1147.         };

  1148.         Scene_Base.prototype.removeTransitionSprite = function() {
  1149.                 if (this._transitionSprite) {
  1150.                         this._transitionSprite.destroy();
  1151.                         this._transitionSprite = null;
  1152.                 }
  1153.         };

  1154.         const _Scene_Base_update = Scene_Base.prototype.update;
  1155.         Scene_Base.prototype.update = function() {
  1156.                 this.updateTransition();
  1157.                 _Scene_Base_update.call(this);
  1158.         };

  1159.         Scene_Base.prototype.setupTransition = function(data, sign) {
  1160.                 this._transitionUpdated = false;
  1161.                 if (sign < 0) {
  1162.                         if (data.xpMode) {
  1163.                                 this.snapForTransition();
  1164.                                 this._transitionDuration = 1;
  1165.                         }
  1166.                 } else if (this._transitionSprite) {
  1167.                         data.color = data.color ?? this._transitionSprite.getBlendColor().slice(0, 3);
  1168.                 }
  1169.                 this._transitionSign = sign;
  1170.                 this.createTransitionSprite(data);
  1171.                 this._transitionSprite.setBitmap(sign);
  1172.                 this._transitionSprite.opacity = sign < 0 ? 0 : 255;
  1173.         };

  1174.         Scene_Base.prototype.updateTransition = function() {
  1175.                 if (this._transitionDuration > 0) {
  1176.                         this._transitionUpdated = true;
  1177.                         if (this._transitionSprite.durationMax() === 0){
  1178.                                 const ready = this._transitionSprite.setDefault(this._transitionSign);
  1179.                                 if(!ready){
  1180.                                         return;
  1181.                                 }
  1182.                                 this._transitionSprite.setDurationMax(this._transitionDuration);
  1183.                         }
  1184.                         this._transitionDuration--;
  1185.                         const d = this._transitionDuration;
  1186.                         const sign = this._transitionSign;
  1187.                         this._transitionSprite.updateBitmap(d, sign);
  1188.                         if (this._transitionDuration === 0 && sign > 0) {
  1189.                                 this.removeTransitionSprite();
  1190.                         }
  1191.                 }
  1192.         };
  1193.        
  1194.         Scene_Base.prototype.needsPresetTransition = function(type) {
  1195.                 const data = $gameSystem.transitionData(type);
  1196.                 return data.name || data.xpMode || data.color;
  1197.         };

  1198.         Scene_Base.prototype.presetTransitionSpeed = function(type, slow, normal) {
  1199.                 const data = $gameSystem.transitionData(type);
  1200.                 return (data.xpMode && data.name) ? slow ?? this.slowFadeSpeed() : normal ?? this.fadeSpeed();
  1201.         };

  1202.         //-----------------------------------------------------------------------------
  1203.         // Scene_MenuBase

  1204.         const _Scene_MenuBase_createBackground = Scene_MenuBase.prototype.createBackground;
  1205.         Scene_MenuBase.prototype.createBackground = function() {
  1206.                 _Scene_MenuBase_createBackground.call(this);
  1207.                 const bitmap = SceneManager.backgroundBitmap();
  1208.                 if (bitmap && sceneTransition === "2000") {
  1209.                         bitmap.fillAll("#002063");
  1210.                         this.setBackgroundOpacity(255);
  1211.                 }
  1212.         };

  1213.         //-----------------------------------------------------------------------------
  1214.         // Scene_Title

  1215.         if (sceneTransition === "2000") {
  1216.                 const _Scene_Title_start = Scene_Title.prototype.start;
  1217.                 Scene_Title.prototype.start = function() {
  1218.                         _Scene_Title_start.call(this);
  1219.                         this._shouldAlwaysOpenCommandWindow = false;
  1220.                         if ([Scene_Load, Scene_Options].some(scene => SceneManager.isPreviousScene(scene))) {
  1221.                                 this.startFadeIn(this.transitionSpeed());
  1222.                                 this._shouldAlwaysOpenCommandWindow = true;
  1223.                         } else if (SceneManager.isPreviousScene(Scene_Map)) {
  1224.                                 this.startFadeIn(this.slowFadeSpeed());
  1225.                         }
  1226.                 };

  1227.                 let slowFadeSpeed = 0;
  1228.                 const _Scene_Title_commandNewGame = Scene_Title.prototype.commandNewGame;
  1229.                 Scene_Title.prototype.commandNewGame = function() {
  1230.                         slowFadeSpeed = this.transitionSpeed();
  1231.                         _Scene_Title_commandNewGame.call(this);
  1232.                         slowFadeSpeed = 0;
  1233.                 };

  1234.                 if (Scene_Title.prototype.slowFadeSpeed === Scene_Base.prototype.slowFadeSpeed) {
  1235.                         Scene_Title.prototype.slowFadeSpeed = function() {
  1236.                                 return Scene_Base.prototype.slowFadeSpeed.apply(this, arguments);
  1237.                         };
  1238.                 }

  1239.                 const _Scene_Title_slowFadeSpeed = Scene_Title.prototype.slowFadeSpeed
  1240.                 Scene_Title.prototype.slowFadeSpeed = function() {
  1241.                         return slowFadeSpeed || _Scene_Title_slowFadeSpeed.call(this);
  1242.                 };

  1243.                 const _Scene_Title_update = Scene_Title.prototype.update;
  1244.                 Scene_Title.prototype.update = function() {
  1245.                         _Scene_Title_update.call(this);
  1246.                         if (this._shouldAlwaysOpenCommandWindow || this._commandWindow.isClosing()) {
  1247.                                 this._commandWindow.openness = 255;
  1248.                                 this._commandWindow.open();
  1249.                         }
  1250.                 };
  1251.         } else if (sceneTransition === "XP") {
  1252.                 const _Scene_Title_start = Scene_Title.prototype.start;
  1253.                 Scene_Title.prototype.start = function() {
  1254.                         _Scene_Title_start.call(this);
  1255.                         this.startFadeIn(this.transitionSpeed());
  1256.                 };

  1257.                 const _Scene_Title_commandNewGame = Scene_Title.prototype.commandNewGame;
  1258.                 Scene_Title.prototype.commandNewGame = function() {
  1259.                         _Scene_Title_commandNewGame.call(this);
  1260.                         this.rejectFade();
  1261.                 };

  1262.                 const _Scene_Title_update = Scene_Title.prototype.update;
  1263.                 Scene_Title.prototype.update = function() {
  1264.                         _Scene_Title_update.call(this);
  1265.                         this._commandWindow.openness = 255;
  1266.                         this._commandWindow.open();
  1267.                 };
  1268.         }

  1269.         //-----------------------------------------------------------------------------
  1270.         // Scene_Load

  1271.         const _Scene_Load_onLoadSuccess = Scene_Load.prototype.onLoadSuccess;
  1272.         Scene_Load.prototype.onLoadSuccess = function() {
  1273.                 _Scene_Load_onLoadSuccess.call(this);
  1274.                 if (sceneTransition === "XP") {
  1275.                         this.rejectFade();
  1276.                 } else if (sceneTransition === "2000") {
  1277.                         this.startFadeOut(this.transitionSpeed());
  1278.                 }
  1279.         };

  1280.         //-----------------------------------------------------------------------------
  1281.         // Scene_GameEnd

  1282.         const _Scene_GameEnd_createBackground = Scene_GameEnd.prototype.createBackground;
  1283.         Scene_GameEnd.prototype.createBackground = function() {
  1284.                 _Scene_GameEnd_createBackground.call(this);
  1285.                 if (sceneTransition === "2000") {
  1286.                         this.setBackgroundOpacity(255);
  1287.                 }
  1288.         };

  1289.         if (["2000", "XP"].includes(sceneTransition)) {
  1290.                 const _Scene_GameEnd_create = Scene_GameEnd.prototype.create;
  1291.                 Scene_GameEnd.prototype.create = function() {
  1292.                         _Scene_GameEnd_create.call(this);
  1293.                         this._commandWindow.openness = 255;
  1294.                         this._commandWindow.open();
  1295.                 };

  1296.                 const _Scene_GameEnd_stop = Scene_GameEnd.prototype.stop;
  1297.                 Scene_GameEnd.prototype.stop = function() {
  1298.                         _Scene_GameEnd_stop.call(this);
  1299.                         this._commandWindow.open();
  1300.                 };

  1301.                 const _Scene_GameEnd_commandToTitle = Scene_GameEnd.prototype.commandToTitle;
  1302.                 Scene_GameEnd.prototype.commandToTitle = function() {
  1303.                         _Scene_GameEnd_commandToTitle.call(this);
  1304.                         this.startFadeOut(sceneTransition === "XP" ? this.transitionSpeed() : this.fadeSpeed());
  1305.                 };
  1306.         } else if (sceneTransition === "VX") {
  1307.                 if (Scene_MenuBase.prototype.isBusy === Scene_GameEnd.prototype.isBusy) {
  1308.                         Scene_GameEnd.prototype.isBusy = function() {
  1309.                                 return Scene_MenuBase.prototype.isBusy.call(this);
  1310.                         };
  1311.                 }
  1312.                 const _Scene_GameEnd_isBusy = Scene_GameEnd.prototype.isBusy;
  1313.                 Scene_GameEnd.prototype.isBusy = function() {
  1314.                         return this._commandWindow.isClosing() || _Scene_GameEnd_isBusy.call(this);
  1315.                 };
  1316.         }

  1317.         //-----------------------------------------------------------------------------
  1318.         // Scene_Gameover

  1319.         const _Scene_Gameover_playGameoverMusic = Scene_Gameover.prototype.playGameoverMusic;
  1320.         Scene_Gameover.prototype.playGameoverMusic = function() {
  1321.                 _Scene_Gameover_playGameoverMusic.call(this);
  1322.                 if (gameoverBgm.name) {
  1323.                         AudioManager.playBgm(gameoverBgm);
  1324.                 }
  1325.         };

  1326.         if (sceneTransition === "VX") {
  1327.                 let createGameover = false;
  1328.                 const _Scene_Gameover_create = Scene_Gameover.prototype.create;
  1329.                 Scene_Gameover.prototype.create = function() {
  1330.                         createGameover = true;
  1331.                         _Scene_Gameover_create.call(this);
  1332.                         createGameover = false;
  1333.                 };

  1334.                 const _Scene_Gameover_playGameoverMusic = Scene_Gameover.prototype.playGameoverMusic;
  1335.                 Scene_Gameover.prototype.playGameoverMusic = function() {
  1336.                         if (createGameover) return;
  1337.                         _Scene_Gameover_playGameoverMusic.call(this);
  1338.                 };
  1339.         }

  1340.         if (sceneTransition === "XP")  {
  1341.                 const _Scene_Gameover_start = Scene_Gameover.prototype.start;
  1342.                 Scene_Gameover.prototype.start = function() {
  1343.                         _Scene_Gameover_start.call(this);
  1344.                         this.startFadeIn(180);
  1345.                 };
  1346.         }

  1347.         //-----------------------------------------------------------------------------
  1348.         // Scene_Message

  1349.         Scene_Message.prototype.needsTransition = function() {
  1350.                 return false;
  1351.         };

  1352.         if (sceneTransition === "VX") {
  1353.                 Scene_Message.prototype.transitionSpeed = function() {
  1354.                         return 12;
  1355.                 };
  1356.         }

  1357.         //-----------------------------------------------------------------------------
  1358.         // Scene_Map

  1359.         Scene_Map.prototype.inTransition = function() {
  1360.                 return $gameTemp.inMapTransition() && SceneManager.isPreviousScene(Scene_Map);
  1361.         };

  1362.         if (sceneTransition !== "MZ") {
  1363.                 Scene_Map.prototype.needsTransition = function(sign) {
  1364.                         if (sign < 0) {
  1365.                                 return ![Scene_Map, Scene_Battle].some(scene => SceneManager.isNextScene(scene));
  1366.                         } else {
  1367.                                 return ![Scene_Map, Scene_Battle].some(scene => SceneManager.isPreviousScene(scene));
  1368.                         }
  1369.                 };
  1370.         }

  1371.         Scene_Map.prototype.restoreTransition = function() {
  1372.                 if (!this.inTransition()) {
  1373.                         $gameTemp.clearMapTransition();
  1374.                         return;
  1375.                 }
  1376.                 this.rejectFade();
  1377.                 const data = $gameTemp.mapTransitionData();
  1378.                 this._transitionDuration = 1;
  1379.                 this.setupTransition(data, -1);
  1380.                 this.updateTransition();
  1381.         };

  1382.         const _Scene_Base_setupTransition = Scene_Base.prototype.setupTransition;
  1383.         Scene_Map.prototype.setupTransition = function(data, sign) {
  1384.                 _Scene_Base_setupTransition.apply(this, arguments);
  1385.                 if (sign < 0) {
  1386.                         $gameTemp.setMapTransition(data.xpMode, data.color);
  1387.                 } else {
  1388.                         $gameTemp.clearMapTransition();
  1389.                 }
  1390.         };

  1391.         Scene_Map.prototype.snapForTransition = function() {
  1392.                 this._windowLayer.visible = false;
  1393.                 Scene_Message.prototype.snapForTransition.call(this);
  1394.                 this._windowLayer.visible = true;
  1395.         };

  1396.         const _Scene_Map_fadeInForTransfer = Scene_Map.prototype.fadeInForTransfer;
  1397.         Scene_Map.prototype.fadeInForTransfer = function() {
  1398.                 const type = "Transfer Player (Show)";
  1399.                 if (!this.needsPresetTransition(type)) {
  1400.                         _Scene_Map_fadeInForTransfer.call(this);
  1401.                         return;
  1402.                 }
  1403.                 this.showScreenForTransfer(type);
  1404.         };

  1405.         Scene_Map.prototype.showScreenForTransfer = function(type) {
  1406.                 const fadeType = $gamePlayer.fadeType();
  1407.                 switch (fadeType) {
  1408.                         case 0:
  1409.                         case 1:
  1410.                                 const color = $gameSystem.transitionColor(type) || true;
  1411.                                 this.showScreenWithPreset(this.presetTransitionSpeed(type), type, fadeType === 1 && color);
  1412.                                 break;
  1413.                 }
  1414.         };

  1415.         const _Scene_Map_fadeOutForTransfer = Scene_Map.prototype.fadeOutForTransfer;
  1416.         Scene_Map.prototype.fadeOutForTransfer = function() {
  1417.                 const type = "Transfer Player (Hide)";
  1418.                 if (!this.needsPresetTransition(type)) {
  1419.                         _Scene_Map_fadeOutForTransfer.call(this);
  1420.                         return;
  1421.                 }
  1422.                 this.hideScreenForTransfer(type);
  1423.         };

  1424.         Scene_Map.prototype.hideScreenForTransfer = function(type) {
  1425.                 const fadeType = $gamePlayer.fadeType();
  1426.                 switch (fadeType) {
  1427.                         case 0:
  1428.                         case 1:
  1429.                                 const color = $gameSystem.transitionColor(type) || true;
  1430.                                 this.hideScreenWithPreset(this.presetTransitionSpeed(type), type, fadeType === 1 && color);
  1431.                                 break;
  1432.                 }
  1433.         };

  1434.         if (Scene_Base.prototype.startFadeOut === Scene_Map.prototype.startFadeOut) {
  1435.                 Scene_Map.prototype.startFadeOut = function(duration, white) {
  1436.                         Scene_Base.prototype.startFadeOut.apply(this, arguments);
  1437.                 };
  1438.         }
  1439.         //エンカウントエフェクト乗っ取り
  1440.         const _Scene_Map_startFadeOut = Scene_Map.prototype.startFadeOut;
  1441.         Scene_Map.prototype.startFadeOut = function(duration, white) {
  1442.                 if (updateEncounterEffect) {
  1443.                         const type = "Start Battle (Hide)";
  1444.                         this.hideScreenWithPreset(duration, type);
  1445.                         return;
  1446.                 }
  1447.                 _Scene_Map_startFadeOut.apply(this, arguments);
  1448.         };

  1449.         const _Scene_Map_start = Scene_Map.prototype.start;
  1450.         Scene_Map.prototype.start = function() {
  1451.                 _Scene_Map_start.call(this);
  1452.                 const type = "End Battle (Show)";
  1453.                 if (SceneManager.isPreviousScene(Scene_Battle) && this.needsPresetTransition(type)) {
  1454.                         this.rejectFade();
  1455.                         if (sceneTransition === "XP") {
  1456.                                 //XPなら更に速くする。
  1457.                                 this.showScreenWithPreset(this.presetTransitionSpeed(type, this.fadeSpeed(), this.transitionSpeed()), type);
  1458.                         } else {
  1459.                                 this.showScreenWithPreset(this.presetTransitionSpeed(type), type);
  1460.                         }
  1461.                 }
  1462.                 this.restoreTransition();
  1463.         };
  1464.         //ニューゲーム、ロードを特殊演出に
  1465.         if (sceneTransition === "2000") {
  1466.                 const _Scene_Map_start = Scene_Map.prototype.start;
  1467.                 Scene_Map.prototype.start = function() {
  1468.                         _Scene_Map_start.call(this);
  1469.                         if (SceneManager.isPreviousScene(Scene_Load) || SceneManager.isPreviousScene(Scene_Title)) {
  1470.                                 this.startFadeIn(this.slowFadeSpeed());
  1471.                         }
  1472.                 };
  1473.         } else if (sceneTransition === "XP") {
  1474.                 const _Scene_Map_start = Scene_Map.prototype.start;
  1475.                 Scene_Map.prototype.start = function() {
  1476.                         _Scene_Map_start.call(this);
  1477.                         if (SceneManager.isPreviousScene(Scene_Load) || SceneManager.isPreviousScene(Scene_Title)) {
  1478.                                 this.startFadeIn(this.transitionSpeed());
  1479.                         }
  1480.                 };
  1481.         }

  1482.         if (!hideCharacters) {
  1483.                 Scene_Map.prototype.startEncounterEffect = function() {
  1484.                         this._encounterEffectDuration = this.encounterEffectSpeed();
  1485.                         this._spriteset._tilemap.setFreeze(true);
  1486.                 };
  1487.         }

  1488.         if (encounterEffect === "2000") {
  1489.                 Scene_Map.prototype.encounterEffectSpeed = function() {
  1490.                         return 17;
  1491.                 };
  1492.                 //フラッシュからのフェード
  1493.                 Scene_Map.prototype.updateEncounterEffect = function() {
  1494.                         if (this._encounterEffectDuration > 0) {
  1495.                                 this._encounterEffectDuration--;
  1496.                                 const speed = this.encounterEffectSpeed();
  1497.                                 const n = speed - this._encounterEffectDuration;
  1498.                                 if (n === 1) {
  1499.                                         this.snapForBattleBackground();
  1500.                                         this.startFlashForEncounter(10);
  1501.                                         BattleManager.playBattleBgm();
  1502.                                 }
  1503.                                 if (n === 11) {
  1504.                                         this.startFlashForEncounter(10);
  1505.                                 }
  1506.                                 if (n === 17) {
  1507.                                         this.startFadeOut(40);
  1508.                                 }
  1509.                         }
  1510.                 };

  1511.         } else if (["XP", "VX", "VXAce", "Fes"].includes(encounterEffect)) {
  1512.                 Scene_Map.prototype.encounterEffectSpeed = function() {
  1513.                         return 1;
  1514.                 };

  1515.                 Scene_Map.prototype.updateEncounterEffect = function() {
  1516.                         if (this._encounterEffectDuration > 0) {
  1517.                                 this._encounterEffectDuration--;
  1518.                                 const speed = this.encounterEffectSpeed();
  1519.                                 const n = speed - this._encounterEffectDuration;
  1520.                                 if (n === 1) {
  1521.                                         this.snapForBattleBackground();
  1522.                                         if (encounterEffect !== "Fes") {
  1523.                                                 BattleManager.playBattleBgm();
  1524.                                         }
  1525.                                         switch (encounterEffect) {
  1526.                                         case "XP":
  1527.                                                 this.startFadeOut(30);
  1528.                                                 break;
  1529.                                         case "VX":
  1530.                                                 this.startFadeOut(80);
  1531.                                                 this._transitionSprite._pos = 80; //途中から開始する
  1532.                                                 break;
  1533.                                         case "VXAce":
  1534.                                                 this.startFadeOut(60);
  1535.                                                 this._transitionSprite._pos = 120; //同上
  1536.                                                 break;
  1537.                                         case "Fes":
  1538.                                                 this.startFadeOut(16);
  1539.                                                 break;
  1540.                                                
  1541.                                         }
  1542.                                 }
  1543.                         }
  1544.                 };
  1545.         }

  1546.         let updateEncounterEffect = false;
  1547.         const _Scene_Map_updateEncounterEffect = Scene_Map.prototype.updateEncounterEffect;
  1548.         Scene_Map.prototype.updateEncounterEffect = function() {
  1549.                 updateEncounterEffect = this.needsPresetTransition("Start Battle (Hide)");
  1550.                 _Scene_Map_updateEncounterEffect.call(this);
  1551.                 updateEncounterEffect = false;
  1552.         };

  1553.         if (sceneTransition === "2000") {
  1554.                 const _Scene_Map_stop = Scene_Map.prototype.stop;
  1555.                 Scene_Map.prototype.stop = function() {
  1556.                         _Scene_Map_stop.call(this);
  1557.                         if (SceneManager.isNextScene(Scene_Title)) {
  1558.                                 this.startFadeOut(this.transitionSpeed());
  1559.                         }
  1560.                 };
  1561.         } else if (sceneTransition === "XP") {
  1562.                 const _Scene_Map_needsSlowFadeOut = Scene_Map.prototype.needsSlowFadeOut;
  1563.                 Scene_Map.prototype.needsSlowFadeOut = function() {
  1564.                         return _Scene_Map_needsSlowFadeOut.call(this) && !SceneManager.isNextScene(Scene_Gameover);
  1565.                 };
  1566.                 const _Scene_Map_stop = Scene_Map.prototype.stop;
  1567.                 Scene_Map.prototype.stop = function() {
  1568.                         _Scene_Map_stop.call(this);
  1569.                         if (SceneManager.isNextScene(Scene_Title)) {
  1570.                                 this.startFadeOut(this.transitionSpeed());
  1571.                         }
  1572.                 };
  1573.         }

  1574.         //-----------------------------------------------------------------------------
  1575.         // Scene_Battle

  1576.         const _Scene_Battle_start = Scene_Battle.prototype.start;
  1577.         Scene_Battle.prototype.start = function() {
  1578.                 const type = "Start Battle (Show)";
  1579.                 _Scene_Battle_start.call(this);
  1580.                 if (this.needsPresetTransition(type) || encounterEffect !== "MZ") {
  1581.                         const xpMode = $gameSystem.transitionXp(type);
  1582.                         let duration = this.presetTransitionSpeed(type);
  1583.                         let pos = 0;
  1584.                         switch (encounterEffect) {
  1585.                         case "2000":
  1586.                                 duration = xpMode ? 40 : 20;
  1587.                                 break;
  1588.                         case "VX":
  1589.                                 duration = xpMode ? 80 : 12;
  1590.                                 if (xpMode) pos = 80;
  1591.                                 break;
  1592.                         case "VXAce":
  1593.                                 duration = xpMode ? 60 : 12;
  1594.                                 if (xpMode) pos = 120;
  1595.                                 break;
  1596.                         case "Fes":
  1597.                                 duration = 16;
  1598.                                 break;
  1599.                         }
  1600.                         this.rejectFade();
  1601.                         this.showScreenWithPreset(duration, type);
  1602.                         this._transitionSprite._pos = pos;
  1603.                 }
  1604.         };

  1605.         const _Scene_Battle_stop = Scene_Battle.prototype.stop;
  1606.         Scene_Battle.prototype.stop = function() {
  1607.                 _Scene_Battle_stop.call(this);
  1608.                 const type = "End Battle (Hide)";
  1609.                 if (SceneManager.isNextScene(Scene_Map) && this.needsPresetTransition(type)) {
  1610.                         this.rejectFade();
  1611.                         this.hideScreenWithPreset(this.fadeSpeed(), type);
  1612.                 }
  1613.         };

  1614.         if (sceneTransition === "2000") {
  1615.                 const _Scene_Battle_stop = Scene_Battle.prototype.stop;
  1616.                 Scene_Battle.prototype.stop = function() {
  1617.                         _Scene_Battle_stop.call(this);
  1618.                         if (SceneManager.isNextScene(Scene_Title)) {
  1619.                                 this.startFadeOut(this.transitionSpeed());
  1620.                         }
  1621.                 };
  1622.         } else if (sceneTransition === "XP") {
  1623.                 const _Scene_Battle_stop = Scene_Battle.prototype.stop;
  1624.                 Scene_Battle.prototype.stop = function() {
  1625.                         _Scene_Battle_stop.call(this);
  1626.                         if (SceneManager.isNextScene(Scene_Title)) {
  1627.                                 this.startFadeOut(this.transitionSpeed());
  1628.                         } else if (!SceneManager.isNextScene(Scene_Map)) {
  1629.                                 this.rejectFade();
  1630.                         }
  1631.                 };
  1632.         } else if (sceneTransition === "VX") {
  1633.                 const _Scene_Battle_terminate = Scene_Battle.prototype.terminate;
  1634.                 Scene_Battle.prototype.terminate = function() {
  1635.                         const playMe = AudioManager.playMe;
  1636.                         const stopMe = AudioManager.stopMe;
  1637.                         if (SceneManager.isNextScene(Scene_Gameover)) {
  1638.                                 AudioManager.playMe = function() {};
  1639.                                 AudioManager.stopMe = function() {};
  1640.                         }
  1641.                         _Scene_Battle_terminate.call(this);
  1642.                         AudioManager.playMe = playMe;
  1643.                         AudioManager.stopMe = stopMe;
  1644.                 };
  1645.         }

  1646.         //-----------------------------------------------------------------------------
  1647.         // Sprite_Transition
  1648.         // トランジション用スプライトの定義です。

  1649.         function Sprite_Transition() {
  1650.                 this.initialize(...arguments);
  1651.         }

  1652.         Sprite_Transition.prototype = Object.create(Sprite.prototype);
  1653.         Sprite_Transition.prototype.constructor = Sprite_Transition;

  1654.         //イニシャライザ
  1655.         //smoothnessとposでVXのvagueを再現できる
  1656.         Sprite_Transition.prototype.initialize = function(data) {
  1657.                 Sprite.prototype.initialize.call(this);
  1658.                 this.bitmap = new Bitmap(Graphics.width, Graphics.height);
  1659.                 this._xpMode = !!data.xpMode; //スクショ付きトランジション
  1660.                 this._fileName = data.name || "";
  1661.                 this._smoothness = data.smoothness ?? 4.5; //滑らかさ(0-7)
  1662.                 this._pos = data.pos ?? 0; //開始位置(0-255)
  1663.                 this.createTransitionData(this._fileName);
  1664.                 this._durationMax = 0;
  1665.                 this.setColor(data.color ?? false);
  1666.         };

  1667.         Sprite_Transition.prototype.setColor = function(c) {
  1668.                 if (this._xpMode) {
  1669.                         c = false;
  1670.                 } else if (c === true) {
  1671.                         c = [255, 255, 255];
  1672.                 }
  1673.                 if (c && c.some(n => n > 0)) {
  1674.                         this.setBlendColor([c[0], c[1], c[2], 255]);
  1675.                 } else {
  1676.                         this.setBlendColor([0, 0, 0, 0]);
  1677.                 }
  1678.         };

  1679.         Sprite_Transition.prototype.durationMax = function() {
  1680.                 return this._durationMax;
  1681.         };

  1682.         Sprite_Transition.prototype.setDurationMax = function(d) {
  1683.                 this._durationMax = d;
  1684.         };

  1685.         Sprite_Transition.prototype.destroy = function(options) {
  1686.                 if (this.bitmap) {
  1687.                         this.bitmap.destroy();
  1688.                 }
  1689.                 Sprite.prototype.destroy.call(this, options);
  1690.         };

  1691.         //トランジションの元画像を読み込んでトランジション情報を作成する
  1692.         Sprite_Transition.prototype.createTransitionData = function(fileName) {
  1693.                 const bitmap = new Bitmap(Graphics.width, Graphics.height);
  1694.                 this._transitionBitmap = null;
  1695.                 if(fileName){
  1696.                         //ファイル名が設定されていたら読み込む
  1697.                         const bitmap2 = ImageManager.loadTransition(fileName);
  1698.                         if(bitmap2.isReady()){
  1699.                                 //キャッシュから読み込んだ場合は描画
  1700.                                 this.synthesizeBitmap(bitmap, bitmap2, ImageManager.isBigCharacter(fileName));
  1701.                         } else {
  1702.                                 //すぐに読み込めなかったらバックアップ
  1703.                                 this._transitionBitmap = bitmap2;
  1704.                         }
  1705.                 }
  1706.                 //XPならデータ反転
  1707.                 const negative = ImageManager.isObjectCharacter(fileName);
  1708.                 this._transitionData = bitmap.getTransitionData(this._xpMode ? !negative : negative);
  1709.                 bitmap.destroy();
  1710.         };

  1711.         Sprite_Transition.prototype.updateBitmap = function(duration, sign) {
  1712.                 //ファイル名がない場合は普通のフェードを模倣
  1713.                 this.opacity = 255;
  1714.                 if (!this._fileName) {
  1715.                         this.updateFade(duration, sign);
  1716.                 } else if (this._smoothness > 0) {
  1717.                         this.updateSmoothTransition(duration, sign);
  1718.                 } else {
  1719.                         this.updateTransition(duration, sign);
  1720.                 }
  1721.         };

  1722.         Sprite_Transition.prototype.updateFade = function(duration, sign) {
  1723.                 this.opacity = sign > 0 ? 255 * (duration / this._durationMax) : 255 - 255 * (duration / this._durationMax);
  1724.         };

  1725.         Sprite_Transition.prototype.updateSmoothTransition = function(duration, sign) {
  1726.                 const speedRate = 2**(8 - this._smoothness);
  1727.                 const rate = speedRate / (speedRate-1);
  1728.                 const max = 255 * rate;
  1729.                 const speed = 255 * speedRate / this._durationMax;
  1730.                 const pos = this._pos;
  1731.                 if (sign > 0) {
  1732.                         const offset = 255 - max;
  1733.                         let threshold = (max * duration / this._durationMax) + offset;
  1734.                         let lastThreshold = (max * (duration + 1) / this._durationMax) + offset;
  1735.                         if (pos > 0) {
  1736.                                 threshold *= (255 - pos) / 255;
  1737.                                 lastThreshold *= (255 - pos) / 255;
  1738.                         }
  1739.                         this.bitmap.createSmoothTransitionFadeIn(this._transitionData, threshold, lastThreshold, speed);
  1740.                 } else {
  1741.                         let threshold = max - (max * duration / this._durationMax);
  1742.                         let lastThreshold = max - (max * (duration + 1) / this._durationMax);
  1743.                         if (pos > 0) {
  1744.                                 threshold = threshold * (255 - pos) / 255 + pos;
  1745.                                 lastThreshold = lastThreshold * (255 - pos) / 255 + pos;
  1746.                         }
  1747.                         this.bitmap.createSmoothTransitionFadeOut(this._transitionData, threshold, lastThreshold, speed);
  1748.                 }
  1749.         };

  1750.         Sprite_Transition.prototype.updateTransition = function(duration, sign) {
  1751.                 const pos = this._pos;
  1752.                 if (sign > 0) {
  1753.                         let threshold = (255 * duration / this._durationMax);
  1754.                         if (pos > 0) {
  1755.                                 threshold *= (255 - pos) / 255;
  1756.                         }
  1757.                         this.bitmap.createTransitionFadeIn(this._transitionData, threshold);
  1758.                 } else {
  1759.                         let threshold = 255 - (255 * duration / this._durationMax);
  1760.                         if (pos > 0) {
  1761.                                 threshold = threshold * (255 - pos) / 255 + pos;
  1762.                         }
  1763.                         this.bitmap.createTransitionFadeOut(this._transitionData, threshold);
  1764.                 }
  1765.         };

  1766.         Sprite_Transition.prototype.setDefault = function(sign) {
  1767.                 if(this._transitionBitmap){
  1768.                         if(!this._transitionBitmap.isReady()){
  1769.                                 return false;
  1770.                         }
  1771.                         this.createTransitionData(this._fileName);
  1772.                 }
  1773.                 return true;
  1774.         };

  1775.         Sprite_Transition.prototype.synthesizeBitmap = function(bitmap1, bitmap2, zoom) {
  1776.                 if (!zoom) {
  1777.                         bitmap1.blt(bitmap2, 0, 0, bitmap2.width, bitmap2.height,
  1778.                                 0, 0, bitmap1.width, bitmap1.height);
  1779.                         return;
  1780.                 }
  1781.                 const aspect1 = bitmap1.width / bitmap1.height;
  1782.                 const aspect2 = bitmap2.width / bitmap2.height;
  1783.                 let left, top, width, height;
  1784.                 if(aspect2 < aspect1) {// 画像が横長
  1785.                         left = 0;
  1786.                         width = bitmap1.width;
  1787.                         height = bitmap1.width / aspect2;
  1788.                         top = (bitmap1.height - height) / 2;
  1789.                 } else {// 画像が縦長
  1790.                         top = 0;
  1791.                         height = bitmap1.height;
  1792.                         width = bitmap1.height * aspect2;
  1793.                         left = (bitmap1.width - width) / 2;
  1794.                 }
  1795.                 bitmap1.blt(bitmap2, 0, 0, bitmap2.width, bitmap2.height,
  1796.                         left, top, width, height);
  1797.         };

  1798.         Sprite_Transition.prototype.setBitmap = function(sign) {
  1799.                 if (this._xpMode) {
  1800.                         const snap = SceneManager.transitionBitmap();
  1801.                         this.bitmap.fillAll("black"); //ここで染めておくことでスクショが透明でも動作可能にする。
  1802.                         if (snap) {
  1803.                                 this.synthesizeBitmap(this.bitmap, snap);
  1804.                         }
  1805.                 } else if (sign > 0 || !this._fileName) {
  1806.                         //フェードイン
  1807.                         this.bitmap.fillAll("black");
  1808.                 } else {
  1809.                         //フェードアウト
  1810.                         this.bitmap.clear();
  1811.                 }
  1812.         };

  1813.         //-----------------------------------------------------------------------------
  1814.         // Window_Base

  1815.         if (speedUpWindows) {
  1816.                 Window_Base.prototype.updateOpen = function() {
  1817.                         if (this._opening) {
  1818.                                 this.openness += 48;
  1819.                                 if (this.isOpen()) {
  1820.                                         this._opening = false;
  1821.                                 }
  1822.                         }
  1823.                 };

  1824.                 Window_Base.prototype.updateClose = function() {
  1825.                         if (this._closing) {
  1826.                                 this.openness -= 48;
  1827.                                 if (this.isClosed()) {
  1828.                                         this._closing = false;
  1829.                                 }
  1830.                         }
  1831.                 };
  1832.         }

  1833.         //-----------------------------------------------------------------------------
  1834.         // ImageManager

  1835.         ImageManager.loadTransition = function(filename) {
  1836.                 return this.loadBitmap('img/transitions/', filename);
  1837.         };

  1838.         //-----------------------------------------------------------------------------
  1839.         // Bitmap

  1840.         //トランジションデータを作る
  1841.         Bitmap.prototype.createTransitionFadeIn = function(data, threshold) {
  1842.                 if(this.width > 0 && this.height > 0){
  1843.                         const context = this._context;
  1844.                         const imageData = context.getImageData(0, 0, this.width, this.height);
  1845.                         const pixels = imageData.data;
  1846.                         for(let i = 0; i < pixels.length; i+=4){
  1847.                                 if(pixels[i + 3] === 255){
  1848.                                    const alpha = (data[i] >= threshold) ? 0 : 255;
  1849.                                    pixels[i + 3] = alpha;
  1850.                                 }
  1851.                         }
  1852.                         context.putImageData(imageData, 0, 0);
  1853.                         this._baseTexture.update();
  1854.                 }
  1855.         };

  1856.         Bitmap.prototype.createTransitionFadeOut = function(data, threshold) {
  1857.                 if(this.width > 0 && this.height > 0){
  1858.                         const context = this._context;
  1859.                         const imageData = context.getImageData(0, 0, this.width, this.height);
  1860.                         const pixels = imageData.data;
  1861.                         for(let i = 0; i < pixels.length; i+=4){
  1862.                                 if(pixels[i + 3] === 0){
  1863.                                    const alpha = (data[i] > threshold) ? 0 : 255;
  1864.                                    pixels[i + 3] = alpha;
  1865.                                 }
  1866.                         }
  1867.                         context.putImageData(imageData, 0, 0);
  1868.                         this._baseTexture.update();
  1869.                 }
  1870.         };
  1871.         //閾値の差からグラデーションを復元
  1872.         function getSmoothSpeed(opacity, threshold, lastThreshold, speed) {
  1873.                 return speed * (threshold - opacity) / (threshold - lastThreshold);
  1874.         }

  1875.         Bitmap.prototype.createSmoothTransitionFadeIn = function(data, threshold, lastThreshold, speed) {
  1876.                 if(this.width > 0 && this.height > 0){
  1877.                         const context = this._context;
  1878.                         const imageData = context.getImageData(0, 0, this.width, this.height);
  1879.                         const pixels = imageData.data;
  1880.                         for(let i = 0; i < pixels.length; i+=4){
  1881.                                 if(pixels[i + 3] === 255){
  1882.                                         const alpha = (data[i] >= threshold) ? 255 - getSmoothSpeed(data[i], threshold, lastThreshold, speed) : 255;
  1883.                                         pixels[i + 3] = alpha;
  1884.                                 } else if(pixels[i + 3] !== 0) {
  1885.                                         pixels[i + 3] -= speed;
  1886.                                 }
  1887.                         }
  1888.                         context.putImageData(imageData, 0, 0);
  1889.                         this._baseTexture.update();
  1890.                 }
  1891.         };

  1892.         Bitmap.prototype.createSmoothTransitionFadeOut = function(data, threshold, lastThreshold, speed) {
  1893.                 if(this.width > 0 && this.height > 0){
  1894.                         const context = this._context;
  1895.                         const imageData = context.getImageData(0, 0, this.width, this.height);
  1896.                         const pixels = imageData.data;
  1897.                         for(let i = 0; i < pixels.length; i+=4){
  1898.                                 if(pixels[i + 3] === 0){
  1899.                                         const alpha = (data[i] > threshold) ? 0 : getSmoothSpeed(data[i], threshold, lastThreshold, speed);
  1900.                                         pixels[i + 3] = alpha;
  1901.                                 } else if(pixels[i + 3] !== 255) {
  1902.                                         pixels[i + 3] += speed;
  1903.                                 }
  1904.                         }
  1905.                         context.putImageData(imageData, 0, 0);
  1906.                         this._baseTexture.update();
  1907.                 }
  1908.         };

  1909.         //画像データの配列情報を取得する
  1910.         Bitmap.prototype.getTransitionData = function(negative) {
  1911.                 if(this.width > 0 && this.height > 0){
  1912.                         const context = this._context;
  1913.                         const imageData = context.getImageData(0, 0, this.width, this.height);
  1914.                         const pixels = imageData.data;
  1915.                         if (negative) {
  1916.                                 for(let i = 0; i < pixels.length; i+=4){
  1917.                                         pixels[i] = 255 - pixels[i];
  1918.                                         pixels[i + 1] = 255 - pixels[i + 1];
  1919.                                         pixels[i + 2] = 255 - pixels[i + 2];
  1920.                                 }
  1921.                         }
  1922.                         return pixels;
  1923.                 }
  1924.         };

  1925. })();
复制代码





回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册用户

本版积分规则

Archiver|QQ群: 48625831|爱上RPG|哈库纳玛塔塔 |网站地图 Clicky

GMT+8, 2024-10-23 07:26 , Processed in 0.090524 second(s), 22 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表