查看: 6865|回复: 11

[有事请教] 关于SRD_CharacterCreator疑问

[复制链接]
梦石
0
星屑
38
在线时间
2 小时
注册时间
2018-4-5
回帖
4
发表于 2018-4-9 23:49:33 | 显示全部楼层 |阅读模式

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

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

×
1.png 2.png 3.png 4.png 5.png 6.png 都和帮助里一样 为什么最后点确定是无限循环确定>?跳转不到自定义捏人画面
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2018-4-10 08:40:46 | 显示全部楼层
本帖最后由 tseyik 于 2018-4-10 08:50 编辑

你試試在各選項加入等待一輯的指令;以避免系統當你連按
但建議用這個
キャラクターメイク(因可用中文做各選棋)
功能較多(詳細看説明)
http://woodpenguin.web.fc2.com/MV_Plugin/CharacterMake.html
CharacterMake1.jpg

下載
http://woodpenguin.web.fc2.com/M ... PP_CharacterMake.js
把Generat文件夾複制到專項内(如圖)
CharacterMake3.jpg
回复

使用道具 举报

梦石
0
星屑
38
在线时间
2 小时
注册时间
2018-4-5
回帖
4
 楼主| 发表于 2018-4-10 11:44:20 | 显示全部楼层
tseyik 发表于 2018-4-10 08:40
你試試在各選項加入等待一輯的指令;以避免系統當你連按
但建議用這個
キャラクターメイク(因可用中文做各選 ...

链接失效了~~~~

点评

没失效,國内上fc網要翻。穡  发表于 2018-4-10 12:59
回复

使用道具 举报

梦石
0
星屑
38
在线时间
2 小时
注册时间
2018-4-5
回帖
4
 楼主| 发表于 2018-4-10 11:47:50 | 显示全部楼层

加了等待还是一样没效果
回复

使用道具 举报

梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
回帖
1464
发表于 2018-4-10 14:34:18 | 显示全部楼层
好棒的样子,求下脚本?

点评

腳本(沒有圖像)在樓下  发表于 2018-4-11 01:09
回复

使用道具 举报

梦石
0
星屑
16296
在线时间
4017 小时
注册时间
2015-9-14
回帖
1322

开拓者

发表于 2018-4-11 00:57:35 | 显示全部楼层
本帖最后由 wabcmcc 于 2018-4-11 01:07 编辑

作者宣佈SRD-Character Creator停止支援,
改為SRD- Character Creator EX 取代
素材圖像包從新下載.

SRD_CharacterCreatorEX.rar (15.34 KB, 下载次数: 87)

https://rpg.blue/data/attachment/album/202003/28/021323lltgrsvfytfwuya5.gif
回复

使用道具 举报

梦石
0
星屑
449
在线时间
62 小时
注册时间
2016-5-10
回帖
7
发表于 2018-5-1 11:56:03 | 显示全部楼层
tseyik 发表于 2018-4-10 08:40
你試試在各選項加入等待一輯的指令;以避免系統當你連按
但建議用這個
キャラクターメイク(因可用中文做各選 ...

翻墙也不行,求插件和素材
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2018-5-1 12:30:15 | 显示全部楼层
本帖最后由 tseyik 于 2018-5-1 12:35 编辑
chelsea0989 发表于 2018-5-1 11:56
翻墙也不行,求插件和素材

MPP_CharacterMake.js.zip (18.66 KB, 下载次数: 48)

把Generat文件夾複制到專項内

MPP_CharacterMake.js
  1. //=============================================================================
  2. // MPP_CharacterMake.js
  3. //=============================================================================
  4. // Copyright (c) 2017 Mokusei Penguin
  5. // Released under the MIT license
  6. // [url]http://opensource.org/licenses/mit-license.php[/url]
  7. //=============================================================================

  8. /*:
  9. * @plugindesc 【ver.1.0】ゲーム内でキャラクター生成を行えます。
  10. * @author 木星ペンギン
  11. *
  12. * @help プラグインコマンド:
  13. *   SetCharGeneBaseKind n kind  # アクターId n 番の基礎タイプを変更
  14. *                                 kind : Male/Female/Kid/ 空白で解除
  15. *   SetCharGeneDamage bool n1 n2...
  16. *                               # アクターId n 番の歩行グラフィックを変更 ※1
  17. *                                 bool : trueで倒れキャラ、falseで歩行キャラ
  18. *                                 n1,n2... : 変更したいアクターのID (複数可)
  19. *   StartCharEdit n             # アクターId n 番のキャラクターエディットを開始
  20. *   
  21. *   ※指定する値には変数が使用できます。
  22. *    v[n] と記述することでn番の変数の値を参照します。
  23. *   
  24. * アクターのメモ欄:
  25. *   <geneDef BaseKind:type>      # 基礎タイプのデフォルト値 type(文字列)
  26. *                                  Male:男性, Female:女性, Kid:子供
  27. *   <geneDef xxx:n>              # パーツ名 xxx のデフォルトパーツ番号 n ※2
  28. *   <geneDef Color x:n>          # 色番号 x のデフォルト値 n ※3
  29. *   <geneDef Color x:-2, r1,g1,b1, r2,g2,b2, r3,g3,b3>
  30. *                                # 色番号 x のデフォルト値カスタム設定
  31. *                                  r1,g1,b1 : ブライト色のrgb
  32. *                                  r2,g2,b2 : ノーマル色のrgb
  33. *                                  r3,g3,b3 : ダーク色のrgb
  34. *
  35. * 特徴を持つオブジェクトのメモ欄:
  36. *     ※ 優先順位 : 装備 > 職業 > アクター > ステート
  37. *   <gene xxx:n>                 # パーツ名 xxx のパーツ番号 n ※2
  38. *   <gene Color x:n>             # 色番号 x の値 n ※3
  39. *   <gene Color x:-2, r1,g1,b1, r2,g2,b2, r3,g3,b3>
  40. *                                # 色番号 x のカスタム設定
  41. *
  42. * ※1:変更後のグラフィックが読み込まれるまでウェイトが入ります。
  43. *
  44. * ※2:パーツ名
  45. *   Face      : 顔             FrontHair  : 前髪
  46. *   RearHair  : 後髪           Beard      : ヒゲ
  47. *   Ears      : 耳             Eyes       : 目
  48. *   Eyebrows  : 眉             Nose       : 鼻
  49. *   Mouth     : 口             FacialMark : 紋様
  50. *   BeastEars : 獣耳           Tail       : 尻尾
  51. *   Wing      : 羽             Clothing   : 服
  52. *   Cloak     : マント         AccA       : 装身具1
  53. *   AccB      : 装身具2        Glasses    : メガネ
  54. *   
  55. *   パーツ番号はファイル名の p〇〇 の数字を指定します。
  56. *   -1で未設定となります。
  57. *
  58. * ※3:色番号
  59. *   プラグインパラメータの Color を参照してください。
  60. *   指定する値は Generator/gradients.png ファイルの色となります。
  61. *   上から何列目の色にするかを指定してください。
  62. *   -1で色指定なし、-2でカスタムとなります。
  63. *
  64. * ================================
  65. * ●本プラグインを実行するには、キャラクター生成用の画像ファイルが必要です。
  66. *  実行前に下記のURLを参考にGeneratorフォルダを移してください。
  67. *  
  68. *   [url]http://woodpenguin.web.fc2.com/MV_Plugin/CharacterMake.html[/url]
  69. *  
  70. * ●テストプレイを行った際、Generatorフォルダ内にキャラクター生成用のファイル
  71. *  CharGene.jsonが作成されます。
  72. *  このファイルがないと動作しないので、Generatorフォルダ内を変更した際には
  73. *  必ず一度はテストプレイを実行してください。
  74. *  
  75. * ●容量削減のため、Generatorフォルダ内の使用しないファイルは削除してください。
  76. *  子供のキャラクター生成を行わなければ、すべてのKidフォルダが不要です。
  77. *  フロントビューであれば、SVフォルダは不要です。
  78. *
  79. * ●カラー変更[Edit Color?]について
  80. *  カラー変更機能を有効にすると、パーツの色を変更できるようになりますが
  81. *  処理が重くなります。
  82. *  特にエディット画面が重くなるので、対策として
  83. *  プラグインパラメータ[Preview List]から SV を削除することをおすすめします。
  84. *  
  85. *   
  86. * ================================
  87. * 制作 : 木星ペンギン
  88. * URL : [url]http://woodpenguin.blog.fc2.com/[/url]
  89. *
  90. * @param Edit Color?
  91. * @type boolean
  92. * @desc カラー変更を可能にするかどうか
  93. * (画像表示に時間がかかります)
  94. * @default false
  95. *
  96. * @param Parts List
  97. * @type select[]
  98. * @option Face
  99. * @option FrontHair
  100. * @option RearHair
  101. * @option Beard
  102. * @option Ears
  103. * @option Eyes
  104. * @option Eyebrows
  105. * @option Nose
  106. * @option Mouth
  107. * @option FacialMark
  108. * @option BeastEars
  109. * @option Tail
  110. * @option Wing
  111. * @option Clothing
  112. * @option Cloak
  113. * @option AccA
  114. * @option AccB
  115. * @option Glasses
  116. * @desc エディット画面のパーツの並び順
  117. * @default ["Face","FrontHair","RearHair","Beard","Ears","Eyes","Eyebrows","Nose","Mouth","FacialMark","BeastEars","Tail","Wing","Clothing","Cloak","AccA","AccB","Glasses"]
  118. *
  119. * @param Preview List
  120. * @desc プレビュー表示の順番
  121. * (TV:歩行キャラ、SV:戦闘キャラ、FG:顔グラフィック)
  122. * @default FG,TV,SV
  123. *
  124. * @param Default Parts
  125. * @type struct<DefaultParts>
  126. * @desc パーツの初期値
  127. * 各画像ファイル名にある p○○ の数字を指定
  128. * @default {"Face":"1","FrontHair":"1","RearHair":"1","Beard":"-1","Ears":"1","Eyes":"1","Eyebrows":"1","Nose":"1","Mouth":"1","FacialMark":"-1","BeastEars":"-1","Tail":"-1","Wing":"-1","Clothing":"1","Cloak":"-1","AccA":"-1","AccB":"-1","Glasses":"-1"}
  129. *
  130. * @param Default Kid Parts
  131. * @type struct<DefaultParts>
  132. * @desc パーツの初期値(Kid用)
  133. * 各画像ファイル名にある p○○ の数字を指定
  134. * @default {"Face":"1","FrontHair":"0","RearHair":"0","Beard":"-1","Ears":"0","Eyes":"0","Eyebrows":"0","Nose":"0","Mouth":"0","FacialMark":"-1","BeastEars":"-1","Tail":"-1","Wing":"-1","Clothing":"0","Cloak":"-1","AccA":"-1","AccB":"-1","Glasses":"-1"}
  135. *
  136. * @param Force Parts
  137. * @type select[]
  138. * @option Face
  139. * @option FrontHair
  140. * @option RearHair
  141. * @option Beard
  142. * @option Ears
  143. * @option Eyes
  144. * @option Eyebrows
  145. * @option Nose
  146. * @option Mouth
  147. * @option FacialMark
  148. * @option BeastEars
  149. * @option Tail
  150. * @option Wing
  151. * @option Clothing
  152. * @option Cloak
  153. * @option AccA
  154. * @option AccB
  155. * @option Glasses
  156. * @desc 設定が必須なパーツ
  157. * @default ["Face","Ears","Eyes","Eyebrows","Nose","Mouth"]
  158. *
  159. * @param Confirmation Scene?
  160. * @type boolean
  161. * @desc 確認画面を入れるかどうか
  162. * @default true
  163. *
  164. * @param === Random ===
  165. *
  166. * @param Random Text
  167. * @desc (制御文字使用可能)
  168. * @default Shift:  ランダム
  169. * @parent === Random ===
  170. *
  171. * @param Random Parts List
  172. * @type select[]
  173. * @option Face
  174. * @option FrontHair
  175. * @option RearHair
  176. * @option Beard
  177. * @option Ears
  178. * @option Eyes
  179. * @option Eyebrows
  180. * @option Nose
  181. * @option Mouth
  182. * @option FacialMark
  183. * @option BeastEars
  184. * @option Tail
  185. * @option Wing
  186. * @option Clothing
  187. * @option Cloak
  188. * @option AccA
  189. * @option AccB
  190. * @option Glasses
  191. * @desc ランダム使用時に変更されるパーツ
  192. * @default ["Face","FrontHair","RearHair","Beard","Ears","Eyes","Eyebrows","Nose","Mouth","FacialMark","Clothing","AccA","AccB","Glasses"]
  193. * @parent === Random ===
  194. *
  195. * @param Random Color List
  196. * @desc ランダム使用時に変更される色番号
  197. * @default 3,7,8
  198. * @parent === Random ===
  199. *
  200. * @param Random SE
  201. * @type struct<RandomSE>
  202. * @desc ランダム選択時のSE
  203. * @default {"Name":"Decision1","Volume":"90","Pitch":"100","Pan":"0"}
  204. * @parent === Random ===
  205. *
  206. * @param Random Background Type
  207. * @type number
  208. * @min 0
  209. * @max 2
  210. * @desc ランダム表示ウィンドウの背景タイプ
  211. * (0:通常, 1:暗くする, 2:透明)
  212. * @default 0
  213. * @parent === Random ===
  214. *
  215. * @param === Terms ===
  216. * @desc 用語
  217. *
  218. * @param Command
  219. * @type struct<Command>
  220. * @desc 用語(コマンド)
  221. * @default {"Yes":"はい","No":"いいえ","Default":"元に戻す","Ok":"決定","Custom":"カスタム","Bright":"ブライト","Normal":"ノーマル","Dark":"ダーク"}
  222. * @parent === Terms ===
  223. *
  224. * @param Message
  225. * @type struct<Message>
  226. * @desc 用語(メッセージ)
  227. * @default {"Confirmation":"このグラフィックでよろしいですか?","Loading":"Loading"}
  228. * @parent === Terms ===
  229. *
  230. * @param Base Kind
  231. * @type struct<BaseKind>
  232. * @desc 用語(基礎タイプ)
  233. * @default {"Male":"男性","Female":"女性","Kid":"子ども"}
  234. * @parent === Terms ===
  235. *
  236. * @param Parts
  237. * @type struct<Parts>
  238. * @desc 用語(パーツ)
  239. * @default {"Face":"顔","FrontHair":"前髪","RearHair":"後髪","Beard":"ヒゲ","Ears":"耳","Eyes":"目","Eyebrows":"眉","Nose":"鼻","Mouth":"口","FacialMark":"紋様","BeastEars":"獣耳","Tail":"尻尾","Wing":"羽","Clothing":"服","Cloak":"マント","AccA":"装身具1","AccB":"装身具2","Glasses":"メガネ"}
  240. * @parent === Terms ===
  241. *
  242. * @param Colors
  243. * @type struct<Colors>
  244. * @desc 用語(色)
  245. * @default {"Color1":"肌の色","Color2":"目の色","Color3":"毛の色","Color4":"サブカラー","Color5":"紋様の色","Color6":"獣耳の色","Color7":"メインカラー","Color8":"サブカラー1","Color9":"サブカラー2","Color10":"サブカラー3","Color11":"メインカラー","Color12":"サブカラー1","Color13":"メインカラー","Color14":"サブカラー1","Color15":"サブカラー2","Color16":"メインカラー","Color17":"サブカラー1","Color18":"サブカラー2","Color19":"サブカラー3","Color20":"メインカラー","Color21":"サブカラー1","Color22":"サブカラー2","Color23":"尻尾の色","Color24":"羽の色"}
  246. * @parent === Terms ===
  247. *
  248. */

  249. /*~struct~DefaultParts:
  250. * @param Face
  251. * @type number
  252. * @min -1
  253. *
  254. * @param FrontHair
  255. * @type number
  256. * @min -1
  257. *
  258. * @param RearHair
  259. * @type number
  260. * @min -1
  261. *
  262. * @param Beard
  263. * @type number
  264. * @min -1
  265. *
  266. * @param Ears
  267. * @type number
  268. * @min -1
  269. *
  270. * @param Eyes
  271. * @type number
  272. * @min -1
  273. *
  274. * @param Eyebrows
  275. * @type number
  276. * @min -1
  277. *
  278. * @param Nose
  279. * @type number
  280. * @min -1
  281. *
  282. * @param Mouth
  283. * @type number
  284. * @min -1
  285. *
  286. * @param FacialMark
  287. * @type number
  288. * @min -1
  289. *
  290. * @param BeastEars
  291. * @type number
  292. * @min -1
  293. *
  294. * @param Tail
  295. * @type number
  296. * @min -1
  297. *
  298. * @param Wing
  299. * @type number
  300. * @min -1
  301. *
  302. * @param Clothing
  303. * @type number
  304. * @min -1
  305. *
  306. * @param Cloak
  307. * @type number
  308. * @min -1
  309. *
  310. * @param AccA
  311. * @type number
  312. * @min -1
  313. *
  314. * @param AccB
  315. * @type number
  316. * @min -1
  317. *
  318. * @param Glasses
  319. * @type number
  320. * @min -1
  321. *
  322. */

  323. /*~struct~RandomSE:
  324. * @param Name
  325. * @desc ファイル名
  326. * @default Decision1
  327. * @require 1
  328. * @dir audio/se
  329. * @type file
  330. *
  331. * @param Volume
  332. * @type number
  333. * @max 100
  334. * @desc 音量
  335. * @default 90
  336. *
  337. * @param Pitch
  338. * @type number
  339. * @min 50
  340. * @max 150
  341. * @desc ピッチ
  342. * @default 100
  343. *
  344. * @param Pan
  345. * @type number
  346. * @min -100
  347. * @max 100
  348. * @desc 位相
  349. * @default 0
  350. *
  351. */

  352. /*~struct~Command:
  353. * @param Yes
  354. * @default はい
  355. *
  356. * @param No
  357. * @default いいえ
  358. *
  359. * @param Default
  360. * @default 元に戻す
  361. *
  362. * @param Ok
  363. * @default 決定
  364. *
  365. * @param Custom
  366. * @default カスタム
  367. *
  368. * @param Bright
  369. * @default ブライト
  370. *
  371. * @param Normal
  372. * @default ノーマル
  373. *
  374. * @param Dark
  375. * @default ダーク
  376. *
  377. */

  378. /*~struct~Message:
  379. * @param Confirmation
  380. * @default このグラフィックでよろしいですか?
  381. *
  382. * @param Loading
  383. * @default Loading
  384. *
  385. */

  386. /*~struct~BaseKind:
  387. * @param Male
  388. * @default 男性
  389. *
  390. * @param Female
  391. * @default 女性
  392. *
  393. * @param Kid
  394. * @default 子ども
  395. *
  396. */

  397. /*~struct~Parts:
  398. * @param Face
  399. * @default 顔
  400. *
  401. * @param FrontHair
  402. * @default 前髪
  403. *
  404. * @param RearHair
  405. * @default 後髪
  406. *
  407. * @param Beard
  408. * @default ヒゲ
  409. *
  410. * @param Ears
  411. * @default 耳
  412. *
  413. * @param Eyes
  414. * @default 目
  415. *
  416. * @param Eyebrows
  417. * @default 眉
  418. *
  419. * @param Nose
  420. * @default 鼻
  421. *
  422. * @param Mouth
  423. * @default 口
  424. *
  425. * @param FacialMark
  426. * @default 紋様
  427. *
  428. * @param BeastEars
  429. * @default 獣耳
  430. *
  431. * @param Tail
  432. * @default 尻尾
  433. *
  434. * @param Wing
  435. * @default 羽
  436. *
  437. * @param Clothing
  438. * @default 服
  439. *
  440. * @param Cloak
  441. * @default マント
  442. *
  443. * @param AccA
  444. * @default 装身具1
  445. *
  446. * @param AccB
  447. * @default 装身具2
  448. *
  449. * @param Glasses
  450. * @default メガネ
  451. *
  452. */

  453. /*~struct~Colors:
  454. * @param Color1
  455. * @desc 肌の色
  456. * @default 肌の色
  457. *
  458. * @param Color2
  459. * @desc 目の色
  460. * @default 目の色
  461. *
  462. * @param Color3
  463. * @desc 毛の色
  464. * @default 毛の色
  465. *
  466. * @param Color4
  467. * @desc 後髪のサブカラー
  468. * @default サブカラー
  469. *
  470. * @param Color5
  471. * @desc 紋様の色
  472. * @default 紋様の色
  473. *
  474. * @param Color6
  475. * @desc 獣耳の色
  476. * @default 獣耳の色
  477. *
  478. * @param Color7
  479. * @desc 服のメインカラー
  480. * @default メインカラー
  481. *
  482. * @param Color8
  483. * @desc 服のサブカラー1
  484. * @default サブカラー1
  485. *
  486. * @param Color9
  487. * @desc 服のサブカラー2
  488. * @default サブカラー2
  489. *
  490. * @param Color10
  491. * @desc 服のサブカラー3
  492. * @default サブカラー3
  493. *
  494. * @param Color11
  495. * @desc マントのメインカラー
  496. * @default メインカラー
  497. *
  498. * @param Color12
  499. * @desc マントのサブカラー1
  500. * @default サブカラー1
  501. *
  502. * @param Color13
  503. * @desc 装身具1のメインカラー
  504. * @default メインカラー
  505. *
  506. * @param Color14
  507. * @desc 装身具1のサブカラー1
  508. * @default サブカラー1
  509. *
  510. * @param Color15
  511. * @desc 装身具1のサブカラー2
  512. * @default サブカラー2
  513. *
  514. * @param Color16
  515. * @desc 装身具2のメインカラー
  516. * @default メインカラー
  517. *
  518. * @param Color17
  519. * @desc 装身具2のサブカラー1
  520. * @default サブカラー1
  521. *
  522. * @param Color18
  523. * @desc 装身具2のサブカラー2
  524. * @default サブカラー2
  525. *
  526. * @param Color19
  527. * @desc 装身具2のサブカラー3
  528. * @default サブカラー3
  529. *
  530. * @param Color20
  531. * @desc メガネのメインカラー
  532. * @default メインカラー
  533. *
  534. * @param Color21
  535. * @desc メガネのサブカラー1
  536. * @default サブカラー1
  537. *
  538. * @param Color22
  539. * @desc メガネのサブカラー2
  540. * @default サブカラー2
  541. *
  542. * @param Color23
  543. * @desc 尻尾の色
  544. * @default 尻尾の色
  545. *
  546. * @param Color24
  547. * @desc 羽の色
  548. * @default 羽の色
  549. *
  550. */


  551. var $dataCharGene       = null;

  552. (function() {

  553. var Database = {
  554.     BaseKinds: ['Male', 'Female', 'Kid'],
  555.     Variation: ['Body', 'body', 'Face', 'FrontHair', 'RearHair', 'Beard', 'Ears', 'Eyes',
  556.         'Eyebrows', 'Nose', 'Mouth', 'FacialMark', 'BeastEars', 'Tail', 'Wing',
  557.         'Clothing', 'Cloak', 'AccA', 'AccB', 'Glasses'],
  558.     TVD: ['AccB', 'FrontHair', 'AccA', 'Eyes', 'BeastEars', 'RearHair', 'Wing',
  559.         'Glasses', 'Cloak', 'Tail', 'Beard', 'Clothing', 'FacialMark', 'Body'],
  560.     TV: ['Wing1', 'AccB', 'FrontHair1', 'AccA', 'RearHair1', 'Glasses',
  561.         'BeastEars', 'Cloak1', 'Tail1', 'Clothing1', 'Beard1', 'Clothing2',
  562.         'RearHair2', 'FacialMark', 'Body', 'Beard2', 'FrontHair2', 'Tail2',
  563.         'Cloak2', 'Wing2'],
  564.     SV: ['AccB', 'FrontHair', 'AccA', 'Glasses', 'Ears', 'BeastEars', 'Cloak1',
  565.         'Clothing1', 'Beard', 'Clothing2', 'RearHair1', 'FacialMark', 'body',
  566.         'Tail', 'Cloak2', 'Wing'],
  567.     FG: ['AccB', 'Glasses', 'FrontHair', 'Cloak1', 'AccA', 'BeastEars',
  568.         'Beard', 'Clothing1', 'Ears', 'RearHair1', 'Eyebrows', 'Eyes',
  569.         'FacialMark', 'Nose', 'Mouth', 'Face', 'Clothing2', 'Body', 'Cloak2',
  570.         'RearHair2'],
  571.     Color:{Face:[1], FrontHair:[3], RearHair:[3,4], Beard:[3], Ears:[1],
  572.         Eyes:[2], Eyebrows:[3], Nose:[1], Mouth:[1], FacialMark:[5],
  573.         BeastEars:[6], Tail:[23], Wing:[24], Clothing:[7,8,9,10],
  574.         Cloak:[11,12], AccA:[13,14,15], AccB:[16,17,18,19], Glasses:[20,21,22]},
  575.     gradients:[0,0, 36,17, 24,12, 0,23, 0,23, 53,17, 0,23, 53,17, 53,17, 53,17,
  576.         53,17, 53,17, 53,17, 53,17, 53,17, 53,17, 53,17, 53,17, 53,17, 53,17,
  577.         53,17, 53,17, 53,17, 0,23, 53,17]
  578. };

  579. var MPPlugin = {};

  580. (function() {
  581.    
  582.     var parameters = PluginManager.parameters('MPP_CharacterMake');
  583.     var keys = Object.keys(parameters);
  584.     for (var i = 0; i < keys.length; i++) {
  585.         try {
  586.             parameters[keys[i]] = JSON.parse(parameters[keys[i]]);
  587.         } catch (e) {
  588.             
  589.         }
  590.     }
  591.    
  592.     MPPlugin.EditColor = parameters['Edit Color?'];

  593.     MPPlugin.PartsList = parameters['Parts List'];
  594.     MPPlugin.PreviewList = (parameters['Preview List'] || 'TV').split(',');

  595.     var param = parameters['Default Parts'];
  596.     MPPlugin.DefaultParts = [];
  597.     for (var i = 2; i < Database.Variation.length; i++) {
  598.         var name = Database.Variation[i];
  599.         MPPlugin.DefaultParts.push(Number(param[name] || -1));
  600.     }

  601.     param = parameters['Default Parts'];
  602.     MPPlugin.DefaultKidParts = [];
  603.     for (var i = 2; i < Database.Variation.length; i++) {
  604.         var name = Database.Variation[i];
  605.         MPPlugin.DefaultKidParts.push(Number(param[name] || -1));
  606.     }

  607.     MPPlugin.ForceParts = parameters['Force Parts'];
  608.     MPPlugin.ConfirmationScene = parameters['Confirmation Scene?'];

  609.     MPPlugin.RandomPartsList = parameters['Random Parts List'];
  610.     MPPlugin.RandomColorList = eval('[' + parameters['Random Color List'] + ']');
  611.     param = parameters['Random SE'];
  612.     MPPlugin.RandomSE = {
  613.         name:param.Name,
  614.         volume:Number(param.Volume),
  615.         pitch:Number(param.Pitch),
  616.         pan:Number(param.Pan)
  617.     };
  618.     MPPlugin.RandomBackgroundType = parameters['Random Background Type'];

  619.     MPPlugin.text = {};
  620.     param = parameters['Command'];
  621.     MPPlugin.text.Yes = param['Yes'];
  622.     MPPlugin.text.No = param['No'];
  623.     MPPlugin.text.Default = param['Default'];
  624.     MPPlugin.text.Ok = param['Ok'];
  625.     MPPlugin.text.Custom = param['Custom'];
  626.     MPPlugin.text.CustomCommands = [param['Bright'], param['Normal'], param['Dark']];

  627.     param = parameters['Message'];
  628.     MPPlugin.text.Confirmation = param['Confirmation'];
  629.     MPPlugin.text.Loading = param['Loading'];
  630.     MPPlugin.text.Random = parameters['Random Text'];

  631.     param = parameters['Base Kind'];
  632.     MPPlugin.text.Male = param['Male'];
  633.     MPPlugin.text.Female = param['Female'];
  634.     MPPlugin.text.Kid = param['Kid'];

  635.     param = parameters['Parts'];
  636.     MPPlugin.text.Face = param['Face'];
  637.     MPPlugin.text.FrontHair = param['FrontHair'];
  638.     MPPlugin.text.RearHair = param['RearHair'];
  639.     MPPlugin.text.Beard = param['Beard'];
  640.     MPPlugin.text.Ears = param['Ears'];
  641.     MPPlugin.text.Eyes = param['Eyes'];
  642.     MPPlugin.text.Eyebrows = param['Eyebrows'];
  643.     MPPlugin.text.Nose = param['Nose'];
  644.     MPPlugin.text.Mouth = param['Mouth'];
  645.     MPPlugin.text.FacialMark = param['FacialMark'];
  646.     MPPlugin.text.BeastEars = param['BeastEars'];
  647.     MPPlugin.text.Tail = param['Tail'];
  648.     MPPlugin.text.Wing = param['Wing'];
  649.     MPPlugin.text.Clothing = param['Clothing'];
  650.     MPPlugin.text.Cloak = param['Cloak'];
  651.     MPPlugin.text.AccA = param['AccA'];
  652.     MPPlugin.text.AccB = param['AccB'];
  653.     MPPlugin.text.Glasses = param['Glasses'];

  654.     MPPlugin.colorText = [null];
  655.     param = parameters['Colors'];
  656.     for (var i = 1; i <= 24; i++) {
  657.         MPPlugin.colorText[i] = param['Color' + i];
  658.     }
  659.    
  660. })();

  661. var Alias = {};

  662. var Method = {};

  663. //-----------------------------------------------------------------------------
  664. // GenerateEntry

  665. function GenerateEntry(type, item) {
  666.     this._type = type;
  667.     this._item = item;
  668.     var kind = item.kind;
  669.     var data = item.data;
  670.    
  671.     var variation = Database.Variation;
  672.     var typeList = Database[type];
  673.     var bitmaps = [];
  674.     var colors = [];
  675.     for (var i = 0; i < typeList.length; i++) {
  676.         var partsName = typeList[i];
  677.         var partsList = $dataCharGene[type][kind][partsName];
  678.         var baseName = (/\d$/.test(partsName) ? partsName.slice(0,-1) : partsName);
  679.         var partsIndex = variation.indexOf(baseName);
  680.         if (partsList && partsIndex >= 0) {
  681.             var partsId = data[partsIndex];
  682.             if (partsId >= 0 && partsList.contains(partsId)) {
  683.                 if (type !== 'FG') {
  684.                     var fileName = type+'_'+partsName+'_p'+partsId.padZero(2);
  685.                     bitmaps.unshift(ImageManager.loadGenerator(type, kind, fileName));
  686.                     if (MPPlugin.EditColor) {
  687.                         var path = type + '/' + kind + '/' + fileName;
  688.                         colors.unshift(GenerateColors.get(path));
  689.                     }
  690.                 } else {
  691.                     var fList = $dataCharGene.Face[kind][partsName][partsId];
  692.                     for (var n = 0; n < fList.length; n++) {
  693.                         var fileName = fList[n];
  694.                         bitmaps.unshift(ImageManager.loadGenerator('Face', kind, fileName, true));
  695.                         if (MPPlugin.EditColor) {
  696.                             var path = type + '/' + kind + '/' + fileName;
  697.                             var m = (/_m(\d\d\d)/.test(fileName) ? Number(RegExp.$1) : 0);
  698.                             colors.unshift(GenerateColors.make(path, m));
  699.                         }
  700.                     }
  701.                 }
  702.             }
  703.         }
  704.     }
  705.     this._bitmaps = bitmaps;
  706.     this._colors = colors;
  707.     this._loaded = false;
  708. };

  709. //GenerateEntry.prototype.equals = function(item) {
  710. //    return this._item.kind === item.kind && this._item.data.equals(item.data);
  711. //};

  712. GenerateEntry.prototype.isLoaded = function() {
  713.     var bitmaps = this._bitmaps;
  714.     var colors = this._colors;
  715.     if (bitmaps.length === 0) return false;
  716.     for (var i = 0; i < bitmaps.length; i++) {
  717.         if (!bitmaps[i].isReady()) return false;
  718.     }
  719.     for (var i = 0; i < colors.length; i++) {
  720.         if (!colors[i].isReady()) return false;
  721.     }
  722.     return true;
  723. };

  724. GenerateEntry.prototype.onGenerate = function() {
  725.     //this._bitmap._onGenerate(this);
  726. //    if (this._bitmap) {
  727. //        if (this._bitmap.isGenerateReady()) {
  728.             setTimeout(this._bitmap._onGenerate.bind(this._bitmap, this), 1);
  729. //        } else {
  730. //            setTimeout(this.onGenerate.bind(this), 100);
  731. //        }
  732. //    } else {
  733. //        this._loaded = true;
  734. //    }
  735. };

  736. //GenerateEntry.prototype.onLoad = function() {
  737. //    this._loaded = true;
  738. //};

  739. GenerateEntry.prototype.isReady = function() {
  740.     return this._loaded;
  741. };

  742. //-----------------------------------------------------------------------------
  743. // GenerateMap

  744. function GenerateMap() {
  745.     throw new Error('This is a static class');
  746. }

  747. GenerateMap._items = {};

  748. GenerateMap.add = function(path, entry) {
  749.     this._items[path] = entry;
  750.     if (this._path === path) this._path = null;
  751. };

  752. //GenerateMap.prototype.delete = function(path) {
  753. //    delete this._items[path];
  754. //};

  755. GenerateMap.update = function() {
  756.     if (this._entry && this._entry.isReady()) {
  757.         if (this._path) delete this._items[this._path];
  758.         this._entry = null;
  759.         this._path = null;
  760.     }
  761.     if (!this._entry) {
  762.         var keys = Object.keys(this._items);
  763.         for (var i = 0; i < keys.length; i++) {
  764.             var entry = this._items[keys[i]];
  765.             if (entry.isLoaded()) {
  766.                 entry.onGenerate();
  767.                 this._entry = entry;
  768.                 this._path = keys[i];
  769.                 break;
  770.             }
  771.         }
  772.     }
  773. };

  774. GenerateMap.isReady = function() {
  775.     return Object.keys(this._items).length === 0;
  776. };

  777. //-----------------------------------------------------------------------------
  778. // GenerateColor

  779. function GenerateColor(path) {
  780.     this._data = null;
  781.     this._path = path;
  782.     if (path) {
  783.         this._image = new Image();
  784.         this._image.src = 'Generator/' + path + '_c.png';
  785.         this._image.onload = GenerateColor.prototype._onLoad.bind(this);
  786.         this._image.onerror = GenerateColor.prototype._onError.bind(this);
  787.     }
  788.     //this._bitmap = (path ? Bitmap.load('Generator/' + path + '_c.png') : null);
  789. };

  790. GenerateColor.prototype.isReady = function() {
  791. //    if (!this._data && (!this._bitmap || this._bitmap.isReady())) {
  792. //        this.onConvert();
  793. //    }
  794.     return !!this._data;
  795. };

  796. GenerateColor.prototype._onLoad = function() {
  797.     var canvas = document.createElement('canvas');
  798.     var context = canvas.getContext('2d');
  799.     var w = Math.max(this._image.width || 0, 1);
  800.     var h = Math.max(this._image.height || 0, 1);
  801.     canvas.width = w;
  802.     canvas.height = h;
  803.     context.drawImage(this._image, 0, 0);
  804.    
  805.     var data = [];
  806.     var pixels = context.getImageData(0, 0, w, h).data;
  807.     var lastIndex = 0;
  808.     for (var i = 0; i < pixels.length; i += 4) {
  809.         var index = this.getColorIndex(pixels[i+0], pixels[i+1], pixels[i+2]);
  810.         if (lastIndex !== index) {
  811.             data.push(i - 4, lastIndex);
  812.             lastIndex = index;
  813.         }
  814.     }
  815.     this._data = data;
  816.     this._image = null;
  817. };

  818. //GenerateColor.prototype.onConvert = function() {
  819. //    var data = [];
  820. //    if (this._bitmap) {
  821. //        var bitmap = this._bitmap;
  822. //        var pixels = bitmap._context.getImageData(0, 0, bitmap.width, bitmap.height).data;
  823. //        var lastIndex = 0;
  824. //        for (var i = 0; i < pixels.length; i += 4) {
  825. //            var index = this.getColorIndex(pixels[i+0], pixels[i+1], pixels[i+2]);
  826. //            if (lastIndex !== index) {
  827. //                data.push(i - 4, lastIndex);
  828. //                lastIndex = index;
  829. //            }
  830. //        }
  831. //        this._bitmap = null;
  832. //    }
  833. //   
  834. //    this._data = data;
  835. //};

  836. GenerateColor.prototype.getColorIndex = function(r, g, b) {
  837.     if (r === 255 && g === 255 && b === 255) return 0;
  838.     if (r === 249 && g === 193 && b === 157) return 1;
  839.     if (r ===  44 && g === 128 && b === 203) return 2;
  840.     if (r === 252 && g === 203 && b ===  10) return 3;
  841.     if (r === 184 && g === 146 && b === 197) return 4;
  842.     if (r ===   0 && g === 146 && b === 150) return 5;
  843.     if (r === 211 && g === 206 && b === 199) return 6;
  844.     if (r === 174 && g === 134 && b === 130) return 7;
  845.     if (r === 254 && g === 157 && b ===  30) return 8;
  846.     if (r ===  28 && g === 118 && b === 208) return 9;
  847.     if (r === 217 && g === 164 && b ===   4) return 10;
  848.     if (r === 216 && g === 172 && b ===   0) return 11;
  849.     if (r === 163 && g ===   7 && b ===   8) return 12;
  850.     if (r === 211 && g === 206 && b === 194) return 13;
  851.     if (r === 218 && g ===  52 && b === 110) return 14;
  852.     if (r === 164 && g === 201 && b ===  17) return 15;
  853.     if (r === 199 && g === 132 && b ===   7) return 16;
  854.     if (r === 192 && g === 211 && b === 210) return 17;
  855.     if (r ===  65 && g ===  85 && b === 182) return 18;
  856.     if (r === 186 && g ===  59 && b ===  69) return 19;
  857.     if (r === 153 && g === 153 && b === 153) return 20;
  858.     if (r === 204 && g === 186 && b === 210) return 21;
  859.     if (r ===  96 && g === 126 && b ===  75) return 22;
  860.     if (r === 230 && g === 214 && b === 189) return 23;
  861.     if (r === 167 && g === 214 && b === 214) return 24;
  862.     //if (r ===  79 && g ===  65 && b ===  60) return 25;
  863.    
  864.     if (r === 240 && g === 193 && b === 153) return 1; // What?
  865.     if (r === 241 && g === 205 && b ===  11) return 3; // What?
  866.     if (r ===   0 && g ===   0 && b ===   0) return 5; // What?
  867.     //if (r ===  87 && g ===  87 && b ===  85) return 0;
  868.     //if (r === 170 && g === 175 && b === 175) return 0;
  869.     //if (r ===  56 && g ===  59 && b ===  59) return 0;
  870.     //if (r === 123 && g ===  66 && b ===   0) return 0;
  871.     //if (r ===  73 && g ===  14 && b ===  18) return 0;
  872.     //if (r === 218 && g === 121 && b ===  18) return 0;
  873.     //if (r === 211 && g === 136 && b ===  79) return 0;
  874.     //if (r === 255 && g === 252 && b === 255) return 0;
  875.     if (r === 206 && g === 204 && b === 192) return 13; // What?
  876.     if (r === 206 && g ===  40 && b === 107) return 14; // What?
  877.     if (r === 155 && g === 203 && b ===   6) return 15; // What?
  878.     if (r === 168 && g === 210 && b === 210) return 24; // What?
  879.     //if (r ===  32 && g ===  29 && b ===  26) return 0;
  880.     //if (r === 183 && g === 118 && b ===  38) return 0;
  881.     //if (r ===  37 && g ===  38 && b ===  66) return 0;
  882.     if (r === 255 && g === 235 && b === 157) return 17; // Miss?
  883.     if (r === 255 && g === 207 && b ===  23) return 17; // Miss?
  884.     if (r === 165 && g === 132 && b === 129) return 7; // What?
  885.     if (r === 242 && g === 156 && b ===  27) return 8; // What?
  886.     if (r ===  69 && g === 103 && b === 204) return 9; // What!?
  887.    
  888.     return 0;
  889. };

  890. GenerateColor.prototype._onError = function() {
  891.     this._data = [Infinity, 0];
  892. };

  893. //-----------------------------------------------------------------------------
  894. // GenerateColors

  895. function GenerateColors() {
  896.     throw new Error('This is a static class');
  897. }

  898. GenerateColors._items = {};

  899. GenerateColors.get = function(path) {
  900.     var item = this._items[path];
  901.     if (!item) {
  902.         item = new GenerateColor(path);
  903.         this._items[path] = item;
  904.     }
  905.     return item;
  906. };

  907. GenerateColors.make = function(path, c) {
  908.     var item = new GenerateColor();
  909.     item._data = [Infinity, c];
  910.     this._items[path] = item;
  911.     return item;
  912. };

  913. //-----------------------------------------------------------------------------
  914. // Bitmap

  915. Bitmap.generate = function(type) {
  916.     var bitmap = new Bitmap();
  917.    
  918.     bitmap._geneType = type;
  919.     bitmap._geneData = [];
  920.     bitmap._geneCount = 0;
  921.     //bitmap._geneEntries =[];
  922.     switch (type) {
  923.         case 'TVD': case 'TV':
  924.             bitmap.resize(144, 192);
  925.             break;
  926.         case 'SV':
  927.             bitmap.resize(576, 384);
  928.             break;
  929.         case 'FG':
  930.             bitmap.resize(144 * 4, 144 * 2);
  931.             break;
  932.     }
  933.     return bitmap;
  934. };

  935. //Bitmap.prototype.isGenerateReady = function() {
  936. //    return this._loadingState === 'generateLoading' ||
  937. //            this._loadingState === 'loaded';
  938. //};

  939. Bitmap.prototype.setGenerate = function(item) {
  940.     this._loadingState = 'generateLoading';
  941.     this._decodeAfterRequest = true;
  942.     var entry = new GenerateEntry(this._geneType, item);
  943.     entry._bitmap = this;
  944.     this._geneData[item.index] = item;
  945.     GenerateMap.add(item.key + ':' +item.index, entry);
  946. };

  947. Bitmap.prototype._onGenerate = function(entry) {
  948.     this._loadingState = 'generateCreating';
  949.     var bitmaps = entry._bitmaps;
  950.     var colors = entry._colors;
  951.     if (bitmaps.length > 0) {
  952.         
  953.         var actorData = entry._item.data.slice(20);
  954.         var defaultColors = Method.getDefaultColors(actorData);
  955.         var gradData = Method.createGradData(actorData);
  956.         var rgbToX = Method.rgbToX;
  957.         
  958.         var bw = bitmaps[0].width;
  959.         var bh = bitmaps[0].height;
  960.         var context = this._context;
  961.         var index = entry._item.index;
  962.         var dx = index % 4 * bw;
  963.         var dy = Math.floor(index / 4) * bh;
  964.         var tempCanvas = document.createElement('canvas');
  965.         var tempContext = tempCanvas.getContext('2d');
  966.         tempCanvas.width = bw;
  967.         tempCanvas.height = bh;
  968.         if (this._geneType === 'TVD') {
  969.             context.clearRect(0, 0, this.width, this.height);
  970.         }else {
  971.             context.clearRect(dx, dy, bw, bh);
  972.         }
  973.         context.globalCompositeOperation = 'source-over';
  974.         for (var i = 0; i < bitmaps.length; i++) {
  975.             if (colors[i]) {
  976.                 var imageData = bitmaps[i]._context.getImageData(0, 0, bw, bh);
  977.                 var pixels = imageData.data;
  978.                 var colorData = colors[i]._data.clone();
  979.                 var cn = -1, ci = 0;
  980.                 var pixelMax = pixels.length;
  981.                 for (var n = 0; n < pixelMax; n += 4) {
  982.                     if (cn < n) {
  983.                         if (colorData.length === 0) break;
  984.                         cn = colorData.shift();
  985.                         ci = colorData.shift() - 1;
  986.                         if (defaultColors.contains(ci)) {
  987.                             n = cn;
  988.                             continue;
  989.                         }
  990.                     }
  991.                     if (pixels[n+3] === 0) continue;

  992.                     var x = (ci * 256 + rgbToX(pixels[n+0], pixels[n+1], pixels[n+2])) * 4;
  993.                     pixels[n+0] = gradData[x+0];
  994.                     pixels[n+1] = gradData[x+1];
  995.                     pixels[n+2] = gradData[x+2];
  996.                 }
  997.                 tempContext.putImageData(imageData, 0, 0);
  998.                 context.drawImage(tempCanvas, dx, dy);
  999.             } else {
  1000.                 context.drawImage(bitmaps[i]._canvas, dx, dy);
  1001.             }
  1002.         }
  1003.     }
  1004.     if (this._geneType === 'TVD') {
  1005.         context.drawImage(this._canvas, 0,0,bw,bh, 0,bh,bw,bh);
  1006.         context.drawImage(this._canvas, 0,0,bw,bh*2, 0,bh*2,bw,bh*2);
  1007.     }
  1008.    
  1009.     entry._loaded = true;
  1010.     //var index = this._geneEntries.indexOf(entry);
  1011.     //if (index >= 0) this._geneEntries.splice(index, 1);
  1012.     //if (this._geneCount === 0) {
  1013.         this._loadingState = 'loaded';
  1014.     //} else {
  1015.     //    this._loadingState = 'generateLoading';
  1016.     //}
  1017.    
  1018.     this._setDirty();
  1019.     this._callLoadListeners();
  1020. };

  1021. Method.getDefaultColors = function(data) {
  1022.     var result = [-1];
  1023.     for (var i = 0; i < 24; i++) {
  1024.         if (data[i * 10] === -1) result.push(i);
  1025.     }
  1026.     return result;
  1027. };

  1028. Method.createGradData = function(data) {
  1029.     var gradients = ImageManager.loadGeneGradients();
  1030.     var canvas = document.createElement('canvas');
  1031.     var context = canvas.getContext('2d');
  1032.     canvas.width = 256;
  1033.     canvas.height = 24;
  1034.     for (var i = 0; i < 24; i++) {
  1035.         var c = data[i * 10];
  1036.         if (c >= 0) {
  1037.             context.drawImage(gradients._canvas, 0,c*4,256,1, 0,i,256,1);
  1038.         } else if (c === -2) {
  1039.             var d = data.slice(i * 10, i * 10 + 10);
  1040.             var gradient = context.createLinearGradient(0,0,256,0);
  1041.             gradient.addColorStop(0, 'rgb(%1,%2,%3)'.format(d[1], d[2], d[3]));
  1042.             gradient.addColorStop(0.5, 'rgb(%1,%2,%3)'.format(d[4], d[5], d[6]));
  1043.             gradient.addColorStop(1, 'rgb(%1,%2,%3)'.format(d[7], d[8], d[9]));
  1044.             context.fillStyle = gradient;
  1045.             context.fillRect(0, i, 256, 1);
  1046.         }
  1047.     }
  1048.     return context.getImageData(0, 0, 256, 24).data;
  1049. };

  1050. Method.rgbToX = function(r, g, b) {
  1051.     return Math.floor(255 - (Math.min(r, g, b) + Math.max(r, g, b)) / 2);
  1052. };

  1053. Bitmap.prototype.equalsGeneData = function(item) {
  1054.     if (!this._geneData) return false;
  1055.     var genaItem = this._geneData[item.index];
  1056.     return genaItem && genaItem.kind === item.kind && genaItem.data.equals(item.data);
  1057. };

  1058. //-----------------------------------------------------------------------------
  1059. // DataManager

  1060. //61
  1061. Alias.DaMa_loadDatabase = DataManager.loadDatabase;
  1062. DataManager.loadDatabase = function() {
  1063.     Alias.DaMa_loadDatabase.call(this);
  1064.     this._createEdit = Utils.isOptionValid('test') && Utils.isNwjs();
  1065.     if (this._createEdit) {
  1066.         this.createEditData();
  1067.     } else {
  1068.         this.loadGeneData('$dataCharGene', 'CharGene.json');
  1069.     }
  1070. };

  1071. DataManager.createEditData = function() {
  1072.     var fs = require('fs');
  1073.     var path = require('path');
  1074.     var base = path.dirname(process.mainModule.filename);
  1075.    
  1076.     $dataCharGene = {};
  1077.    
  1078.     var re = /^icon_([A-Za-z]+)_p(\d\d)/;
  1079.     $dataCharGene.Variation = this.createGenePartsList('Variation', re);
  1080.    
  1081.     re = /^TVD_([A-Za-z]+)_p(\d\d)\./;
  1082.     $dataCharGene.TVD = this.createGenePartsList('TVD', re);
  1083.    
  1084.     re = /^TV_([A-Za-z]+\d?)_p(\d\d)\./;
  1085.     $dataCharGene.TV = this.createGenePartsList('TV', re);

  1086.     re = /^SV_([A-Za-z]+\d?)_p(\d\d)\./;
  1087.     $dataCharGene.SV = this.createGenePartsList('SV', re);
  1088.    
  1089.     var list1 = {}, list2 = {};
  1090.     var dirPath = path.join(base, 'Generator/Face');
  1091.     if (fs.existsSync(dirPath)) {
  1092.         var baseKinds = Database.BaseKinds;
  1093.         for (var i = 0; i < baseKinds.length; i++) {
  1094.             var kind = baseKinds[i];
  1095.             var files1 = {}, files2 = {};
  1096.             var kindPath = 'Generator/Face/'+kind+'/';
  1097.             dirPath = path.join(base, kindPath);
  1098.             if (fs.existsSync(dirPath)) {
  1099.                 var dir = fs.readdirSync(dirPath);
  1100.                 dir.sort();
  1101.                 for (var n = 0; n < dir.length; n++) {
  1102.                     var names = dir[n].split('_');
  1103.                     var name = names[1];
  1104.                     var p = Number(names[2].slice(1));
  1105.                     if (!files1[name]) files1[name] = [];
  1106.                     files1[name].push(p);
  1107.                     
  1108.                     if (!files2[name]) files2[name] = {};
  1109.                     if (!files2[name][p]) files2[name][p] = [];
  1110.                     files2[name][p].push(dir[n].slice(0, -4));
  1111.                 }
  1112.             }
  1113.             list1[kind] = files1;
  1114.             list2[kind] = files2;
  1115.         }
  1116.     }
  1117.     $dataCharGene.FG = list1;
  1118.     $dataCharGene.Face = list2;
  1119.    
  1120.     var json = JsonEx.stringify($dataCharGene);
  1121.     this.saveGeneData('Generator/', 'CharGene.json', json);
  1122. };

  1123. DataManager.createGenePartsList = function(type, re) {
  1124.     var fs = require('fs');
  1125.     var path = require('path');
  1126.     var base = path.dirname(process.mainModule.filename);
  1127.    
  1128.     var list = {};
  1129.     var dirPath = path.join(base, 'Generator/' + type + '/');
  1130.     if (fs.existsSync(dirPath)) {
  1131.         var baseKinds = Database.BaseKinds;
  1132.         for (var i = 0; i < baseKinds.length; i++) {
  1133.             var kind = baseKinds[i];
  1134.             var files = {};
  1135.             var kindPath = 'Generator/' + type + '/' + kind + '/';
  1136.             dirPath = path.join(base, kindPath);
  1137.             if (fs.existsSync(dirPath)) {
  1138.                 var dir = fs.readdirSync(dirPath);
  1139.                 for (var n = 0; n < dir.length; n++) {
  1140.                     if (re.test(dir[n])) {
  1141.                         var name = RegExp.$1;
  1142.                         if (!files[name]) files[name] = [];
  1143.                         files[name].push(Number(RegExp.$2));
  1144.                     }
  1145.                 }
  1146.             }
  1147.             list[kind] = files;
  1148.         }
  1149.     }
  1150.     return list;
  1151. };

  1152. //92
  1153. Alias.DaMa_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  1154. DataManager.isDatabaseLoaded = function() {
  1155.     if (!this._createEdit && !window['$dataCharGene']) {
  1156.         return false;
  1157.     }
  1158.     return Alias.DaMa_isDatabaseLoaded.call(this);
  1159. };

  1160. DataManager.saveGeneData = function(kindPath, name, json) {
  1161.     var fs = require('fs');
  1162.     var path = require('path');
  1163.    
  1164.     var base = path.dirname(process.mainModule.filename);
  1165.     var data = LZString.compressToBase64(json);
  1166.     var filePath = path.join(base, kindPath) + name;
  1167.     fs.writeFileSync(filePath, data);
  1168. };

  1169. DataManager.loadGeneData = function(name, src) {
  1170.     var xhr = new XMLHttpRequest();
  1171.     var url = 'Generator/' + src;
  1172.     xhr.open('GET', url);
  1173.     xhr.overrideMimeType('application/json');
  1174.     xhr.onload = function() {
  1175.         if (xhr.status < 400) {
  1176.             var json = LZString.decompressFromBase64(xhr.responseText);
  1177.             window[name] = JsonEx.parse(json);
  1178.         }
  1179.     };
  1180.     xhr.onerror = function() {
  1181.         DataManager._errorUrl = DataManager._errorUrl || url;
  1182.     };
  1183.     window[name] = null;
  1184.     xhr.send();
  1185. };

  1186. DataManager.existGeneImage = function(type, kind, parts, p) {
  1187.     if (type === undefined) return true;
  1188.     var node = $dataCharGene[type];
  1189.     if (node === undefined) return false;
  1190.     if (kind === undefined) return true;
  1191.     node = node[kind];
  1192.     if (node === undefined) return false;
  1193.     if (parts === undefined) return true;
  1194.     node = node[parts];
  1195.     if (node === undefined) return false;
  1196.     if (p === undefined) return true;
  1197.     return node.contains(p);
  1198. };

  1199. //-----------------------------------------------------------------------------
  1200. // ImageManager

  1201. ImageManager._geneImageCache = null;

  1202. ImageManager.createGeneCache = function() {
  1203.     this._geneImageCache = new ImageCache();
  1204. };

  1205. ImageManager.deleteGeneCache = function() {
  1206.     this._geneImageCache = null;
  1207. };

  1208. //36
  1209. Alias.ImMa_loadCharacter = ImageManager.loadCharacter;
  1210. ImageManager.loadCharacter = function(filename, hue) {
  1211.     if (/^\$MPP_Gene(TVD|TV)/.test(filename)) {
  1212.         return this.reserveGenerateBitmap(filename, RegExp.$1);
  1213.     } else {
  1214.         return Alias.ImMa_loadCharacter.call(this, filename, hue);
  1215.     }
  1216. };

  1217. //40
  1218. Alias.ImMa_loadFace = ImageManager.loadFace;
  1219. ImageManager.loadFace = function(filename, hue) {
  1220.     if (/^MPP_GeneFG/.test(filename)) {
  1221.         return this.reserveGenerateBitmap(filename, 'FG');
  1222.     } else {
  1223.         return Alias.ImMa_loadFace.call(this, filename, hue);
  1224.     }
  1225. };

  1226. //52
  1227. Alias.ImMa_loadSvActor = ImageManager.loadSvActor;
  1228. ImageManager.loadSvActor = function(filename, hue) {
  1229.     if (/^MPP_GeneSV/.test(filename)) {
  1230.         return this.reserveGenerateBitmap(filename, 'SV');
  1231.     } else {
  1232.         return Alias.ImMa_loadSvActor.call(this, filename, hue);
  1233.     }
  1234. };

  1235. ImageManager.loadGenerateBitmap = function(filename, type) {
  1236.     var item = this.makeGenerateItem(filename, type);
  1237.     var cache = this._geneImageCache || this._imageCache;
  1238.     var bitmap = cache.get(item.key);;
  1239.     if (!bitmap) {
  1240.         bitmap = Bitmap.generate(type);
  1241.         bitmap.smooth = (type === 'FG');
  1242.         cache.add(item.key, bitmap);
  1243.     }
  1244.     if (!bitmap.equalsGeneData(item)) {
  1245.         bitmap.setGenerate(item);
  1246.     }
  1247.     return bitmap;
  1248. };

  1249. ImageManager.makeGenerateItem = function(filename, type) {
  1250.     var params = filename.split('/');
  1251.     var item = {};
  1252.     item.key = params.shift();
  1253.     item.actorId = Number(params.shift());
  1254.     item.index = 0;
  1255.     item.kind = params.shift();
  1256.     item.data = params.map(Number);
  1257.     if (type === 'FG') {
  1258.         item.key += Math.floor((item.actorId - 1) / 8);
  1259.         item.index = item.actorId % 8 - 1;
  1260.     } else {
  1261.         item.key += item.actorId;
  1262.     }
  1263.     if (this._geneImageCache) item.key = type + ',' + item.kind + ',' + params.toString();
  1264.     return item;
  1265. };

  1266. ImageManager.loadGenerator = function(type, kind, filename, smooth) {
  1267.     return this.loadBitmap('Generator/' + type + '/' + kind + '/', filename,
  1268.         0, smooth || false);
  1269. };

  1270. ImageManager.loadGeneGradients = function() {
  1271.     return this.loadBitmap('Generator/', 'gradients', 0, false);
  1272. };

  1273. //118
  1274. Alias.ImMa_isReady = ImageManager.isReady
  1275. ImageManager.isReady = function() {
  1276.     return Alias.ImMa_isReady.call(this) && GenerateMap.isReady();
  1277. };


  1278. //153
  1279. Alias.ImMa_reserveCharacter = ImageManager.reserveCharacter;
  1280. ImageManager.reserveCharacter = function(filename, hue, reservationId) {
  1281.     if (/^\$MPP_Gene(TVD|TV)/.test(filename)) {
  1282.         return this.reserveGenerateBitmap(filename, RegExp.$1, reservationId);
  1283.     } else {
  1284.         return Alias.ImMa_reserveCharacter.call(this, filename, hue, reservationId);
  1285.     }
  1286. };

  1287. //157
  1288. Alias.ImMa_reserveFace = ImageManager.reserveFace;
  1289. ImageManager.reserveFace = function(filename, hue, reservationId) {
  1290.     if (/^MPP_GeneFG/.test(filename)) {
  1291.         return this.reserveGenerateBitmap(filename, 'FG', reservationId);
  1292.     } else {
  1293.         return Alias.ImMa_reserveFace.call(this, filename, hue, reservationId);
  1294.     }
  1295. };

  1296. //169
  1297. Alias.ImMa_reserveSvActor = ImageManager.reserveSvActor;
  1298. ImageManager.reserveSvActor = function(filename, hue, reservationId) {
  1299.     if (/^MPP_GeneSV/.test(filename)) {
  1300.         return this.reserveGenerateBitmap(filename, 'SV', reservationId);
  1301.     } else {
  1302.         return Alias.ImMa_reserveSvActor.call(this, filename, hue, reservationId);
  1303.     }
  1304. };

  1305. ImageManager.reserveGenerateBitmap = function(filename, type, reservationId) {
  1306.     var bitmap = this.loadGenerateBitmap(filename, type);
  1307.     var item = this.makeGenerateItem(filename, type);
  1308.     var cache = this._geneImageCache || this._imageCache;
  1309.     cache.reserve(item.key, bitmap, reservationId || this._defaultReservationId);
  1310.     return bitmap;
  1311. };

  1312. ImageManager.reserveGenerator = function(type, kind, filename, reservationId) {
  1313.     return this.reserveBitmap('Generator/' + type + '/' + kind + '/', filename,
  1314.         0, kind === 'FG', reservationId);
  1315.     return this.reserveBitmap('Generator/', 'gradients', 0, false);
  1316. };

  1317. ImageManager.reserveGeneGradients = function() {
  1318.     return this.reserveBitmap('Generator/', 'gradients', 0, false);
  1319. };


  1320. //236
  1321. Alias.ImMa_requestCharacter = ImageManager.requestCharacter;
  1322. ImageManager.requestCharacter = function(filename, hue) {
  1323.     if (/^\$MPP_Gene(TVD|TV)/.test(filename)) {
  1324.         return this.requestGenerateBitmap(filename, RegExp.$1);
  1325.     } else {
  1326.         return Alias.ImMa_requestCharacter.call(this, filename, hue);
  1327.     }
  1328. };

  1329. //240
  1330. Alias.ImMa_requestFace = ImageManager.requestFace;
  1331. ImageManager.requestFace = function(filename, hue) {
  1332.     if (/^MPP_GeneFG/.test(filename)) {
  1333.         return this.requestGenerateBitmap(filename, 'FG');
  1334.     } else {
  1335.         return Alias.ImMa_requestFace.call(this, filename, hue);
  1336.     }
  1337. };

  1338. //252
  1339. Alias.ImMa_requestSvActor = ImageManager.requestSvActor;
  1340. ImageManager.requestSvActor = function(filename, hue) {
  1341.     if (/^MPP_GeneSV/.test(filename)) {
  1342.         return this.requestGenerateBitmap(filename, 'SV');
  1343.     } else {
  1344.         return Alias.ImMa_requestSvActor.call(this, filename, hue);
  1345.     }
  1346. };

  1347. ImageManager.requestGenerateBitmap = function(filename, type) {
  1348.     //requestには未対応
  1349.     return this.loadGenerateBitmap(filename, type);
  1350. };

  1351. ImageManager.requestGenerator = function(type, kind, filename) {
  1352.     return this.requestBitmap('Generator/' + type + '/' + kind + '/', filename,
  1353.         0, type === 'Face');
  1354. };

  1355. //304
  1356. Alias.ImMa_update = ImageManager.update;
  1357. ImageManager.update = function(){
  1358.     Alias.ImMa_update.call(this);
  1359.     GenerateMap.update();
  1360. };

  1361. //-----------------------------------------------------------------------------
  1362. // Game_Actor

  1363. //25
  1364. Alias.GaAc_initMembers = Game_Actor.prototype.initMembers;
  1365. Game_Actor.prototype.initMembers = function() {
  1366.     Alias.GaAc_initMembers.call(this);
  1367.     this._geneKind = null;
  1368.     this._geneParts = [];
  1369.     this._geneColors = [];
  1370.     this._geneCharacterDamage = false;
  1371. };

  1372. //46
  1373. Alias.GaAc_setup = Game_Actor.prototype.setup;
  1374. Game_Actor.prototype.setup = function(actorId) {
  1375.     Alias.GaAc_setup.call(this, actorId);
  1376.     this.initCharGene();
  1377. };

  1378. Game_Actor.prototype.initCharGene = function() {
  1379.     var actor = this.actor();
  1380.     var meta = actor.meta;
  1381.     this._geneKind = meta['geneDef BaseKind'];
  1382.     var defParts = MPPlugin.DefaultParts;
  1383.     if (this._geneKind === 'Kid') {
  1384.         defParts = MPPlugin.DefaultKidParts;
  1385.     }
  1386.     this._geneParts = this.setupGeneParts(defParts, 'geneDef ', [actor]);
  1387.     var ganeColors = [];
  1388.     while (ganeColors.length < 24 * 10) {
  1389.         ganeColors.push(-1, 255,255,255, 136,136,136, 0,0,0);
  1390.     }
  1391.     this._geneColors = this.setupGeneColors(ganeColors, 'geneDef Color ', [actor]);
  1392.     this._geneCharacterDamage = false;
  1393.     this.refreshImageName();
  1394. };

  1395. //368
  1396. Alias.GaAc_refresh = Game_Actor.prototype.refresh;
  1397. Game_Actor.prototype.refresh = function() {
  1398.     Alias.GaAc_refresh.call(this);
  1399.     this.refreshImageName();
  1400. };

  1401. Game_Actor.prototype.refreshImageName = function() {
  1402.     if (this._geneKind && !Database.BaseKinds.contains(this._geneKind)) {
  1403.         alert('存在しない基礎タイプです : ' + this._geneKind);
  1404.         this._geneKind = null;
  1405.     }
  1406.     if (this._geneKind) {
  1407.         var dataStr = this.getGeneDataStr();
  1408.         var charaType = (this._geneCharacterDamage ? 'TVD/' : 'TV/');
  1409.         this._characterName = '$MPP_Gene' + charaType + dataStr;
  1410.         this._characterIndex = 0;
  1411.         this._faceName = 'MPP_GeneFG/' + dataStr;
  1412.         this._faceIndex = this._actorId % 8 - 1;
  1413.         this._battlerName =  'MPP_GeneSV/' + dataStr;
  1414.         $gamePlayer.refresh();
  1415.     }
  1416. };

  1417. Game_Actor.prototype.getGeneDataStr = function() {
  1418.     var traits = this.traitObjects().reverse();
  1419.     var parts = this.setupGeneParts(this._geneParts, 'gene ', traits);
  1420.     var colors = this.setupGeneColors(this._geneColors, 'gene Color ', traits);
  1421.     var s = '/';
  1422.     var dataStr = this._actorId + s + this._geneKind + '/1/1';
  1423.     for (var i = 0; i < parts.length; i++) {
  1424.         dataStr += s + parts[i];
  1425.     }
  1426.     for (var i = 0; i < colors.length; i++) {
  1427.         dataStr += s + colors[i];
  1428.     }
  1429.     return dataStr;
  1430. };

  1431. Game_Actor.prototype.setupGeneParts = function(parts, baseName, traits) {
  1432.     parts = parts.clone();
  1433.     var variation = Database.Variation;
  1434.     var forceParts = MPPlugin.ForceParts;
  1435.     for (var n = 2; n < variation.length; n++) {
  1436.         var index = n - 2;
  1437.         var name = baseName + variation[n];
  1438.         if (forceParts.contains(variation[n]) && parts[index] === -1) {
  1439.             var list = $dataCharGene.Variation[this._geneKind];
  1440.             list = (list ? list[variation[n]] : []);
  1441.             if (list.length > 0) {
  1442.                 parts[index] = list[0];
  1443.             }
  1444.         }
  1445.         for (var m = 0; m < traits.length; m++) {
  1446.             var meta = traits[m].meta;
  1447.             if (meta[name]) {
  1448.                 parts[index] = Number(meta[name]);
  1449.                 break;
  1450.             }
  1451.         }
  1452.     }
  1453.     return parts;
  1454. };

  1455. Game_Actor.prototype.setupGeneColors = function(colors, baseName, traits) {
  1456.     colors = colors.clone();
  1457.     for (var n = 0; n < 24; n++) {
  1458.         var name = baseName + (n + 1);
  1459.         for (var m = 0; m < traits.length; m++) {
  1460.             var meta = traits[m].meta;
  1461.             if (meta[name]) {
  1462.                 var ary = meta[name].split(',').map(Number);
  1463.                 for (var l = 0; l < ary.length; l++) {
  1464.                     colors[n * 10 + l] = ary[l];
  1465.                 }
  1466.                 break;
  1467.             }
  1468.         }
  1469.     }
  1470.     return colors;
  1471. };

  1472. Game_Actor.prototype.setGeneKind = function(kind) {
  1473.     if (this._geneKind !== kind) {
  1474.         if (this._geneKind && !kind) {
  1475.             this.initImages();
  1476.         }
  1477.         this._geneKind = kind;
  1478.         this.initCharGene();
  1479.         this.refreshImageName();
  1480.     }
  1481. };

  1482. Game_Actor.prototype.setGeneParts = function(parts, n, setOnly) {
  1483.     var index = Database.Variation.indexOf(parts) - 2;
  1484.     if (index >= 0 && this._geneParts[index] !== n) {
  1485.         this._geneParts[index] = n;
  1486.         if (!setOnly) this.refreshImageName();
  1487.     }
  1488. };

  1489. Game_Actor.prototype.setGeneColor = function(number, index, setOnly) {
  1490.     if (number > 0 && number <= 24) {
  1491.         this._geneColors[(number - 1) * 10] = index;
  1492.         if (!setOnly) this.refreshImageName();
  1493.     }
  1494. };

  1495. Game_Actor.prototype.setGeneColorCustom = function(n1, n2, r, g, b) {
  1496.     if (n1 > 0) {
  1497.         this._geneColors.splice((n1 - 1) * 10 + 1 + n2 * 3, 3, r, g, b);
  1498.         this.refreshImageName();
  1499.     }
  1500. };

  1501. Game_Actor.prototype.setCharacterDamage = function(damage) {
  1502.     if (this._geneCharacterDamage !== damage) {
  1503.         this._geneCharacterDamage = damage;
  1504.         this.refreshImageName();
  1505.     }
  1506. };

  1507. //-----------------------------------------------------------------------------
  1508. // Game_Interpreter

  1509. //27
  1510. Alias.GaIn_clear = Game_Interpreter.prototype.clear;
  1511. Game_Interpreter.prototype.clear = function() {
  1512.     Alias.GaIn_clear.call(this);
  1513.     this._geneDamage = false;
  1514.     this._actors = [];
  1515. };

  1516. //110
  1517. Alias.GaIn_updateWaitMode = Game_Interpreter.prototype.updateWaitMode;
  1518. Game_Interpreter.prototype.updateWaitMode = function() {
  1519.     var waiting = false;
  1520.     if (this._waitMode === 'GeneDamage') {
  1521.         waiting = !GenerateMap.isReady();
  1522.         if (!waiting) {
  1523.             for (var i = 0; i < this._actors.length; i++) {
  1524.                 this._actors[i].setCharacterDamage(this._geneDamage);
  1525.             }
  1526.             this._waitMode = '';
  1527.         }
  1528.     }
  1529.     return waiting || Alias.GaIn_updateWaitMode.call(this);
  1530. };

  1531. //1722
  1532. Alias.GaIn_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  1533. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  1534.     Alias.GaIn_pluginCommand.call(this, command, args);
  1535.     var v = $gameVariables._data;
  1536.     switch (command) {
  1537.         case 'SetCharGeneBaseKind':
  1538.             var actor = $gameActors.actor(eval(args[0]));
  1539.             if (actor) actor.setGeneKind(args[1]);
  1540.             break;
  1541.         case 'SetCharGeneDamage':
  1542.             this._actors = [];
  1543.             this._geneDamage = !!eval(args[0]);
  1544.             for (var i = 1; i < args.length; i++) {
  1545.                 var actor = $gameActors.actor(eval(args[i]));
  1546.                 if (actor && actor._geneKind) {
  1547.                     var dataStr = actor.getGeneDataStr();
  1548.                     var charaType = (this._geneDamage ? 'TVD/' : 'TV/');
  1549.                     var characterName = '$MPP_Gene' + charaType + dataStr;
  1550.                     ImageManager.loadCharacter(characterName, 0);
  1551.                     this._actors.push(actor);
  1552.                 }
  1553.             }
  1554.             if (this._actors.length > 0) {
  1555.                 this._waitMode = 'GeneDamage';
  1556.             }
  1557.             break;
  1558.         case 'StartCharEdit':
  1559.             if (!$gameParty.inBattle()) {
  1560.                 var actor = $gameActors.actor(eval(args[0]));
  1561.                 if (actor && actor._geneKind) {
  1562.                     $gameParty.setMenuActor(actor);
  1563.                     SceneManager.push(Scene_CharacterEdit);
  1564.                 }
  1565.             }
  1566.             break;
  1567.     }
  1568. };

  1569. //-------------------------------------------------------------------
  1570. // Window_CharEdit_Category

  1571. function Window_CharEdit_Category() {
  1572.     this.initialize.apply(this, arguments);
  1573. }

  1574. Window_CharEdit_Category.prototype = Object.create(Window_Command.prototype);
  1575. Window_CharEdit_Category.prototype.constructor = Window_CharEdit_Category;

  1576. Window_CharEdit_Category.prototype.initialize = function(x, y, actor) {
  1577.     this._actor = actor;
  1578.     Window_Command.prototype.initialize.call(this, x, y);
  1579. };

  1580. Window_CharEdit_Category.prototype.windowWidth = function() {
  1581.     return 200;
  1582. };

  1583. Window_CharEdit_Category.prototype.numVisibleRows = function() {
  1584.     var maxHeight = Graphics.boxHeight - 64 - this.standardPadding() * 2
  1585.     return Math.floor(maxHeight / this.itemHeight());
  1586. };

  1587. Window_CharEdit_Category.prototype.update = function() {
  1588.     Window_Command.prototype.update.call(this);
  1589.     if (this._partsWindow) {
  1590.         this._partsWindow.setCategory(this.currentSymbol());
  1591.     }
  1592. };

  1593. Window_CharEdit_Category.prototype.makeCommandList = function() {
  1594.     var list = MPPlugin.PartsList;
  1595.     var variation = $dataCharGene.Variation[this._actor._geneKind];
  1596.     if (!variation) return;
  1597.     for (var i = 0; i < list.length; i++) {
  1598.         var symbol = list[i];
  1599.         if (variation[symbol] && variation[symbol].length > 0) {
  1600.             this.addCommand(MPPlugin.text[symbol], symbol);
  1601.         }
  1602.     }
  1603. };

  1604. Window_CharEdit_Category.prototype.setPartsWindow = function(partsWindow) {
  1605.     this._partsWindow = partsWindow;
  1606.     this.update();
  1607. };

  1608. Window_CharEdit_Category.prototype.processOk = function() {
  1609.     if (this.isOkTriggered()) {
  1610.         Window_Command.prototype.processOk.call(this);
  1611.     }
  1612. };

  1613. //-----------------------------------------------------------------------------
  1614. // Window_CharEdit_PartsList

  1615. function Window_CharEdit_PartsList() {
  1616.     this.initialize.apply(this, arguments);
  1617. }

  1618. Window_CharEdit_PartsList.prototype = Object.create(Window_Selectable.prototype);
  1619. Window_CharEdit_PartsList.prototype.constructor = Window_CharEdit_PartsList;

  1620. Window_CharEdit_PartsList.prototype.initialize = function(x, y, actor) {
  1621.     var width = this.itemWidth() * this.maxCols() + this.standardPadding() * 2;
  1622.     var height = this.itemHeight() * 2 + this.standardPadding() * 2;
  1623.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  1624.     this._actor = actor;
  1625.     this._category = 'none';
  1626.     this._data = [];
  1627. };

  1628. Window_CharEdit_PartsList.prototype.setCategory = function(category) {
  1629.     if (this._category !== category) {
  1630.         this._category = category;
  1631.         this.refresh();
  1632.         this.resetScroll();
  1633.         this.selectParts();
  1634.     }
  1635. };

  1636. Window_CharEdit_PartsList.prototype.maxCols = function() {
  1637.     return 4;
  1638. };

  1639. Window_CharEdit_PartsList.prototype.spacing = function() {
  1640.     return 0;
  1641. };

  1642. Window_CharEdit_PartsList.prototype.itemWidth = function() {
  1643.     return 72;
  1644. };

  1645. Window_CharEdit_PartsList.prototype.itemHeight = function() {
  1646.     return 72;
  1647. };

  1648. Window_CharEdit_PartsList.prototype.maxItems = function() {
  1649.     return this._data ? this._data.length : 1;
  1650. };

  1651. Window_CharEdit_PartsList.prototype.item = function() {
  1652.     var index = this.index();
  1653.     return this._data && index >= 0 ? this._data[index] : 0;
  1654. };

  1655. Window_CharEdit_PartsList.prototype.makeItemList = function() {
  1656.     var kind = this._actor._geneKind;
  1657.     var parts = (kind ? $dataCharGene.Variation[kind] : null);
  1658.     var list = (parts ? parts[this._category] : null);
  1659.     this._data = (list ? list.clone() : []);
  1660.     if (!MPPlugin.ForceParts.contains(this._category)) {
  1661.         this._data.unshift(-1);
  1662.     }
  1663. };

  1664. Window_CharEdit_PartsList.prototype.selectParts = function() {
  1665.     var c = Database.Variation.indexOf(this._category) - 2;
  1666.     var p = this._actor._geneParts[c];
  1667.     var index = this._data.indexOf(p);
  1668.     this.select(index >= 0 ? index : 0);
  1669. };

  1670. Window_CharEdit_PartsList.prototype.update = function() {
  1671.     var lastIndex = this._index;
  1672.     Window_Selectable.prototype.update.call(this);
  1673.     if (this.isOpenAndActive() && lastIndex !== this._index) {
  1674.         this.setActorParts();
  1675.     }
  1676.     if (this._colorWindow) {
  1677.         this._colorWindow.setItem(this._category, this.item());
  1678.     }
  1679. };

  1680. Window_CharEdit_PartsList.prototype.getBitmap = function(index) {
  1681.     var p = this._data[index];
  1682.     if (p < 0) return null;
  1683.     var name = 'icon_' + this._category + '_p' + p.padZero(2);
  1684.     return ImageManager.requestGenerator('Variation', this._actor._geneKind, name);
  1685. };

  1686. Window_CharEdit_PartsList.prototype.setActorParts = function() {
  1687.     this._actor.setGeneParts(this._category, this.item());
  1688. };

  1689. Window_CharEdit_PartsList.prototype.drawItem = function(index) {
  1690.     var bitmap = this.getBitmap(index);
  1691.     if (bitmap) {
  1692.         var process = this.variationDrawer.bind(this, index, bitmap);
  1693.         if (process()) this.addUpdateDrawer(process);
  1694.     }
  1695. };

  1696. Window_CharEdit_PartsList.prototype.variationDrawer = function(index, bitmap) {
  1697.     if (bitmap.isReady()) {
  1698.         var rect = this.itemRect(index);
  1699.         var dx = rect.x + Math.floor((rect.width - 64) / 2);
  1700.         var dy = rect.y + Math.floor((rect.height - 64) / 2);
  1701.         this.contents.blt(bitmap, 0, 0, 64, 64, dx, dy);
  1702.         return false;
  1703.     } else if (bitmap._loadingState === 'purged') {
  1704.         bitmap.decode();
  1705.     }
  1706.     return true;
  1707. };

  1708. Window_CharEdit_PartsList.prototype.processOk = function() {
  1709.     if (this.isOkTriggered()) {
  1710.         Window_Selectable.prototype.processOk.call(this);
  1711.     }
  1712. };

  1713. Window_CharEdit_PartsList.prototype.processCancel = function() {
  1714.     if (this.isCancelTriggered()) {
  1715.         SoundManager.playCancel();
  1716.         this.updateInputData();
  1717.         this.deactivate();
  1718.         this.callHandler('keyCancel');
  1719.     } else {
  1720.         Window_Selectable.prototype.processCancel.call(this);
  1721.     }
  1722. };

  1723. Window_CharEdit_PartsList.prototype.setColorWindow = function(colorWindow) {
  1724.     this._colorWindow = colorWindow;
  1725.     this.update();
  1726. };

  1727. Window_CharEdit_PartsList.prototype.refresh = function() {
  1728.     this.clearUpdateDrawer();
  1729.     this.makeItemList();
  1730.     this.createContents();
  1731.     this.drawAllItems();
  1732. };

  1733. //-----------------------------------------------------------------------------
  1734. // Window_CharEdit_ColorSlot

  1735. function Window_CharEdit_ColorSlot() {
  1736.     this.initialize.apply(this, arguments);
  1737. }

  1738. Window_CharEdit_ColorSlot.prototype = Object.create(Window_Command.prototype);
  1739. Window_CharEdit_ColorSlot.prototype.constructor = Window_CharEdit_ColorSlot;

  1740. Window_CharEdit_ColorSlot.prototype.initialize = function(x, y, width, actor) {
  1741.     this._width = width;
  1742.     Window_Command.prototype.initialize.call(this, x, y);
  1743.     this._actor = actor;
  1744.     this._category = 'none';
  1745.     this._parts = 0;
  1746.     this._colorLoaded = false;
  1747.     this._colorData = [];
  1748.     this.deactivate();
  1749. };

  1750. Window_CharEdit_ColorSlot.prototype.windowWidth = function() {
  1751.     return this._width;
  1752. };

  1753. Window_CharEdit_ColorSlot.prototype.numVisibleRows = function() {
  1754.     return 4;
  1755. };

  1756. Window_CharEdit_ColorSlot.prototype.currentBottomY = function() {
  1757.     return this.y + this.standardPadding() +
  1758.             Math.floor(this.index() / this.maxCols() + 1) * this.itemHeight() -
  1759.             this._scrollY;
  1760. };

  1761. Window_CharEdit_ColorSlot.prototype.setItem = function(category, parts) {
  1762.     if (this._category !== category || this._parts !== parts) {
  1763.         this._category = category;
  1764.         this._parts = parts;
  1765.         this.loadColorData();
  1766.         this.clearCommandList();
  1767.         this.makeItemList();
  1768.         this.checkColorData();
  1769.         this.refresh();
  1770.         this.select(0);
  1771.     }
  1772. };

  1773. Window_CharEdit_ColorSlot.prototype.loadColorData = function() {
  1774.     this._colorData = [];
  1775.     var kind = this._actor._geneKind;
  1776.     var cate = this._category;
  1777.     var parts = this._parts;
  1778.     if (DataManager.existGeneImage('TV', kind, cate, parts)) {
  1779.         var path = 'TV/'+kind+'/TV_'+cate+'_p'+parts.padZero(2);
  1780.         this._colorData.push(GenerateColors.get(path));
  1781.     }
  1782.     if (DataManager.existGeneImage('TV', kind, cate+'1', parts)) {
  1783.         var path = 'TV/'+kind+'/TV_'+cate+'1_p'+parts.padZero(2);
  1784.         this._colorData.push(GenerateColors.get(path));
  1785.     }
  1786.     if (DataManager.existGeneImage('TV', kind, cate+'2', parts)) {
  1787.         path = 'TV/'+kind+'/TV_'+cate+'2_p'+parts.padZero(2);
  1788.         this._colorData.push(GenerateColors.get(path));
  1789.     }
  1790.     this._colorLoaded = (this._colorData.length === 0);
  1791. };

  1792. Window_CharEdit_ColorSlot.prototype.update = function() {
  1793.     Window_Command.prototype.update.call(this);
  1794.     this.checkColorData();
  1795. };

  1796. Window_CharEdit_ColorSlot.prototype.checkColorData = function() {
  1797.     if (!this._colorLoaded && this.isColorReady()) {
  1798.         var colors = [];
  1799.         for (var n = 0; n < this._colorData.length; n++) {
  1800.             var data = this._colorData[n]._data;
  1801.             for (var m = 1; m < data.length; m += 2) {
  1802.                 colors.push(data[m]);
  1803.             }
  1804.         }
  1805.         var list = this._list;
  1806.         for (var n = 1; n < list.length; n++) {
  1807.             list[n].enabled = colors.contains(list[n].ext);
  1808.         }
  1809.         this.refresh();
  1810.         this._colorLoaded = true;
  1811.     }
  1812. };

  1813. Window_CharEdit_ColorSlot.prototype.isColorReady = function() {
  1814.     for (var i = 0; i < this._colorData.length; i++) {
  1815.         if (!this._colorData[i].isReady()) return false;
  1816.     }
  1817.     return true;
  1818. };

  1819. Window_CharEdit_ColorSlot.prototype.processCancel = function() {
  1820.     if (this.isCancelTriggered()) {
  1821.         SoundManager.playCancel();
  1822.         this.updateInputData();
  1823.         this.deactivate();
  1824.         this.callHandler('keyCancel');
  1825.     } else {
  1826.         Window_Command.prototype.processCancel.call(this);
  1827.     }
  1828. };

  1829. Window_CharEdit_ColorSlot.prototype.makeItemList = function() {
  1830.     var list = Database.Color[this._category] || [];
  1831.     for (var i = 0; i < list.length; i++) {
  1832.         var c = list[i];
  1833.         this.addCommand(MPPlugin.colorText[c], 'color', i === 0, c);
  1834.     }
  1835. };

  1836. Window_CharEdit_ColorSlot.prototype.refresh = function() {
  1837.     Window_Selectable.prototype.refresh.call(this);
  1838. };

  1839. Window_CharEdit_ColorSlot.prototype.drawItem = function(index) {
  1840.     var rect = this.itemRect(index);
  1841.     var name = this.commandName(index);
  1842.     var c = this._list[index].ext;
  1843.     this.resetTextColor();
  1844.     this.changePaintOpacity(this.isCommandEnabled(index));
  1845.     var data = this._actor._geneColors.slice(c * 10 - 10, c * 10);
  1846.     Method.drawColor.call(this, data, rect.x, rect.y);
  1847.     this.drawText(name, rect.x + 36, rect.y, rect.width - 36);
  1848. };

  1849. Method.drawColor = function(data, x, y) {
  1850.     this.contents.fillRect(x + 3, y + 3, 30, 30, 'rgba(0,0,0,0.5)');
  1851.     this.contents.fillRect(x + 4, y + 4, 28, 28, 'white');
  1852.     var c = data[0];
  1853.     if (c === -1) {
  1854.         for (var i = 0; i < 28; i++) {
  1855.             var dx = x + 4 + (i < 27 ? 28 - i - 2 : 0);
  1856.             var dw = (i === 0 || i === 27 ? 2 : 3);
  1857.             this.contents.fillRect(dx, y + 4 + i, dw, 1, 'red');
  1858.         }
  1859.     } else if (c >= 0) {
  1860.         var bitmap = ImageManager.loadGeneGradients();
  1861.         for (var i = 0; i < 26; i++) {
  1862.             var color = bitmap.getPixel(i * 5 + 5, c * 4);
  1863.             this.contents.fillRect(x + 5 + i, y + 5, 1, 26, color);
  1864.         }
  1865.     } else {
  1866.         var bitmap = Method.createGeneGradBitmap(data);
  1867.         for (var i = 0; i < 26; i++) {
  1868.             var color = bitmap.getPixel(i * 5 + 5, 0);
  1869.             this.contents.fillRect(x + 5 + i, y + 5, 1, 26, color);
  1870.         }
  1871.     }
  1872. };

  1873. Method.createGeneGradBitmap = function(data) {
  1874.     var bitmap = new Bitmap(256, 1);
  1875.     var context = bitmap.context;
  1876.     var gradient = context.createLinearGradient(0,0,256,0);
  1877.     gradient.addColorStop(0, 'rgb(%1,%2,%3)'.format(data[1], data[2], data[3]));
  1878.     gradient.addColorStop(0.5, 'rgb(%1,%2,%3)'.format(data[4], data[5], data[6]));
  1879.     gradient.addColorStop(1, 'rgb(%1,%2,%3)'.format(data[7], data[8], data[9]));
  1880.     context.fillStyle = gradient;
  1881.     context.fillRect(0, 0, 256, 1);
  1882.     return bitmap;
  1883. };

  1884. //-----------------------------------------------------------------------------
  1885. // Window_CharEdit_ColorList

  1886. function Window_CharEdit_ColorList() {
  1887.     this.initialize.apply(this, arguments);
  1888. }

  1889. Window_CharEdit_ColorList.prototype = Object.create(Window_Command.prototype);
  1890. Window_CharEdit_ColorList.prototype.constructor = Window_CharEdit_ColorList;

  1891. Window_CharEdit_ColorList.prototype.initialize = function(actor) {
  1892.     Window_Command.prototype.initialize.call(this, 0, 0);
  1893.     this.openness = 0;
  1894.     this._actor = actor;
  1895.     this.deactivate();
  1896. };

  1897. Window_CharEdit_ColorList.prototype.windowWidth = function() {
  1898.     return (this.itemWidth() + this.spacing()) * this.maxCols() -
  1899.             this.spacing() + this.standardPadding() * 2;
  1900. };

  1901. Window_CharEdit_ColorList.prototype.numVisibleRows = function() {
  1902.     return 5;
  1903. };

  1904. Window_CharEdit_ColorList.prototype.maxCols = function() {
  1905.     return 6;
  1906. };

  1907. Window_CharEdit_ColorList.prototype.spacing = function() {
  1908.     return 6;
  1909. };

  1910. Window_CharEdit_ColorList.prototype.itemWidth = function() {
  1911.     return 36;
  1912. };

  1913. Window_CharEdit_ColorList.prototype.cursorDown = function(wrap) {
  1914.     if (this.index() >= this.maxItems() - this.maxCols()) {
  1915.         this.select(this.maxItems() - 1);
  1916.     } else {
  1917.         Window_Command.prototype.cursorDown.call(this, wrap);
  1918.     }
  1919. };

  1920. Window_CharEdit_ColorList.prototype.makeCommandList = function() {
  1921.     var n = this._number * 2;
  1922.     this.addCommand(-1, 'color');
  1923.     var startIndex = Database.gradients[n];
  1924.     var maxColors = Database.gradients[n + 1];
  1925.     for (var i = 0; i < maxColors; i++) {
  1926.         this.addCommand(i + startIndex, 'color');
  1927.     }
  1928.     this.addCommand(-2, 'custom');
  1929. };

  1930. Window_CharEdit_ColorList.prototype.setup = function(number) {
  1931.     this._number = number;
  1932.     this.refresh();
  1933.     var colorIndex = number > 0 ? this._actor._geneColors[number * 10 - 10] : 0;
  1934.     var index = 0;
  1935.     var list = this._list;
  1936.     for (var i = 0; i < list.length; i++) {
  1937.         if (list[i].name === colorIndex) {
  1938.             index = i;
  1939.             break;
  1940.         }
  1941.     }
  1942.     this.select(index);
  1943.     this.activate();
  1944.     this.open();
  1945. };

  1946. Window_CharEdit_ColorList.prototype.itemRect = function(index) {
  1947.     if (this.commandSymbol(index) === 'custom') {
  1948.         var i = index - 1;
  1949.         var rect = new Rectangle();
  1950.         var maxCols = this.maxCols();
  1951.         rect.width = this.contentsWidth();
  1952.         rect.height = this.itemHeight();
  1953.         rect.x = 0;
  1954.         rect.y = Math.floor(i / maxCols + 1) * rect.height - this._scrollY;
  1955.         return rect;
  1956.     } else {
  1957.         return Window_Selectable.prototype.itemRect.call(this, index);
  1958.     }
  1959. };

  1960. Window_CharEdit_ColorList.prototype.update = function() {
  1961.     var lastIndex = this._index;
  1962.     Window_Selectable.prototype.update.call(this);
  1963.     if (this.isOpenAndActive() && lastIndex !== this._index) {
  1964.         this.setActorColor();
  1965.     }
  1966. };

  1967. Window_CharEdit_ColorList.prototype.setActorColor = function() {
  1968.     if (this.currentSymbol() === 'color') {
  1969.         this._actor.setGeneColor(this._number, this.commandName(this.index()));
  1970.     }
  1971. };

  1972. Window_CharEdit_ColorList.prototype.drawItem = function(index) {
  1973.     var c = this.commandName(index);
  1974.     var rect = this.itemRect(index);
  1975.     if (c === -2) {
  1976.         this.drawText(MPPlugin.text.Custom, rect.x, rect.y, rect.width, 'center');
  1977.     } else {
  1978.         Method.drawColor.call(this, [c], rect.x, rect.y);
  1979.     }
  1980. };

  1981. //-----------------------------------------------------------------------------
  1982. // Window_CharEdit_ColorCustom

  1983. function Window_CharEdit_ColorCustom() {
  1984.     this.initialize.apply(this, arguments);
  1985. }

  1986. Window_CharEdit_ColorCustom.prototype = Object.create(Window_Selectable.prototype);
  1987. Window_CharEdit_ColorCustom.prototype.constructor = Window_CharEdit_ColorCustom;

  1988. Window_CharEdit_ColorCustom.prototype.initialize = function(x, y, width, actor) {
  1989.     var height = this.fittingHeight(2);
  1990.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  1991.     this.openness = 0;
  1992.     this._actor = actor;
  1993.     this._colors = [0,0,0, 0,0,0, 0,0,0];
  1994. };

  1995. Window_CharEdit_ColorCustom.prototype.maxCols = function() {
  1996.     return 3;
  1997. };

  1998. Window_CharEdit_ColorCustom.prototype.maxItems = function() {
  1999.     return 3;
  2000. };

  2001. Window_CharEdit_ColorCustom.prototype.spacing = function() {
  2002.     return 36;
  2003. };

  2004. Window_CharEdit_ColorCustom.prototype.setup = function(number) {
  2005.     this._number = number;
  2006.     this._actor.setGeneColor(number, -2);
  2007.     this.refresh();
  2008.     this.select(1);
  2009.     this.activate();
  2010.     this.open();
  2011. };

  2012. Window_CharEdit_ColorCustom.prototype.itemRect = function(index) {
  2013.     var rect = Window_Selectable.prototype.itemRect.call(this, index);
  2014.     rect.y += rect.height;
  2015.     return rect;
  2016. };

  2017. Window_CharEdit_ColorCustom.prototype.drawItem = function(index) {
  2018.     var name = MPPlugin.text.CustomCommands[index];
  2019.     var rect = this.itemRect(index);
  2020.     this.drawText(name, rect.x, rect.y, rect.width, 'center');
  2021. };

  2022. Window_CharEdit_ColorCustom.prototype.refresh = function() {
  2023.     Window_Selectable.prototype.refresh.call(this);
  2024.     var x = 12;
  2025.     var width = this.contentsWidth() - 24;
  2026.     var height = this.lineHeight() - 6;
  2027.     var n = this._number;
  2028.     var c = this._actor._geneColors.slice(n * 10 - 9, n * 10);
  2029.     var context = this.contents.context;
  2030.     var gradient = context.createLinearGradient(x,3, x + width, 3);
  2031.     gradient.addColorStop(0, 'rgb(%1,%2,%3)'.format(c[0], c[1], c[2]));
  2032.     gradient.addColorStop(0.5, 'rgb(%1,%2,%3)'.format(c[3], c[4], c[5]));
  2033.     gradient.addColorStop(1, 'rgb(%1,%2,%3)'.format(c[6], c[7], c[8]));
  2034.     context.fillStyle = gradient;
  2035.     context.fillRect(x, 3, width, height);
  2036.     this.contents._setDirty();
  2037. };

  2038. //-----------------------------------------------------------------------------
  2039. // Window_CharEdit_ColorRgb

  2040. function Window_CharEdit_ColorRgb() {
  2041.     this.initialize.apply(this, arguments);
  2042. }

  2043. Window_CharEdit_ColorRgb.prototype = Object.create(Window_Selectable.prototype);
  2044. Window_CharEdit_ColorRgb.prototype.constructor = Window_CharEdit_ColorRgb;

  2045. Window_CharEdit_ColorRgb.prototype.initialize = function(actor) {
  2046.     var width = 382;
  2047.     var height = this.fittingHeight(4);
  2048.     Window_Selectable.prototype.initialize.call(this, 0, 0, width, height);
  2049.     this.openness = 0;
  2050.     this._actor = actor;
  2051.     this._color = [0,0,0];
  2052.     this._sliderIndex = -1;
  2053. };

  2054. Window_CharEdit_ColorRgb.prototype.maxItems = function() {
  2055.     return 4;
  2056. };

  2057. Window_CharEdit_ColorRgb.prototype.itemWidth = function() {
  2058.     return 288;
  2059. };

  2060. Window_CharEdit_ColorRgb.prototype.isOpenAndActive = function() {
  2061.     return Window_Selectable.prototype.isOpenAndActive.call(this) &&
  2062.             this._sliderIndex < 0;
  2063. };

  2064. Window_CharEdit_ColorRgb.prototype.cursorRight = function() {
  2065.     var index = this.index();
  2066.     if (index < 3 && this._color[index] < 255) {
  2067.         this._color[index] = Math.min(this._color[index] + 17, 255);
  2068.         SoundManager.playCursor();
  2069.         this.redrawCurrentItem();
  2070.     }
  2071. };

  2072. Window_CharEdit_ColorRgb.prototype.cursorLeft = function() {
  2073.     var index = this.index();
  2074.     if (index < 3 && this._color[index] > 0) {
  2075.         this._color[index] = Math.max(this._color[index] - 17, 0);
  2076.         SoundManager.playCursor();
  2077.         this.redrawCurrentItem();
  2078.     }
  2079. };

  2080. Window_CharEdit_ColorRgb.prototype.setup = function(n1, n2) {
  2081.     if (this._customWindow) {
  2082.         var window = this._customWindow;
  2083.         this.x = window.x + Math.floor((window.width - this.width) * n2 / 2);
  2084.         this.y = window.y + window.height;
  2085.     }
  2086.     this._number1 = n1;
  2087.     this._number2 = n2;
  2088.     var n = (n1 - 1) * 10 + 1 + n2 * 3;
  2089.     this._color = this._actor._geneColors.slice(n, n + 3);
  2090.     this.refresh();
  2091.     this.select(0);
  2092.     this.activate();
  2093.     this.open();
  2094. };

  2095. Window_CharEdit_ColorRgb.prototype.setActorColor = function() {
  2096.     var c = this._color;
  2097.     this._actor.setGeneColorCustom(this._number1, this._number2, c[0], c[1], c[2]);
  2098. };

  2099. Window_CharEdit_ColorRgb.prototype.update = function() {
  2100.     Window_Selectable.prototype.update.call(this);
  2101.     this.updateSlider();
  2102. };

  2103. Window_CharEdit_ColorRgb.prototype.updateSlider = function() {
  2104.     if (this._sliderIndex < 0) {
  2105.         var index = this.index();
  2106.         if (index < 3 && TouchInput.isTriggered()) {
  2107.             var tx = this.canvasToLocalX(TouchInput.x) - this.standardPadding() - 88;
  2108.             if (tx >= 0 && tx < 192) {
  2109.                 SoundManager.playCursor();
  2110.                 this._sliderIndex = index;
  2111.             }
  2112.         }
  2113.     }
  2114.     if (this._sliderIndex >= 0) {
  2115.         if (TouchInput.isPressed()) {
  2116.             var index = this.index();
  2117.             var lc = this._color[index];
  2118.             var tx = this.canvasToLocalX(TouchInput.x) - this.standardPadding();
  2119.             tx -= 88 + 4;
  2120.             var tw = 192 - 8;
  2121.             var c = Math.round(255 * tx / tw / 17) * 17;
  2122.             this._color[index] = c.clamp(0, 255);
  2123.             if (lc !== this._color[index]) {
  2124.                 //SoundManager.playCursor();
  2125.                 this.redrawCurrentItem();
  2126.             }
  2127.         } else {
  2128.             this._sliderIndex = -1;
  2129.         }
  2130.     }
  2131. };

  2132. Window_CharEdit_ColorRgb.prototype.processOk = function() {
  2133.     if (this.index() === 3) {
  2134.         Window_Selectable.prototype.processOk.call(this);
  2135.     }
  2136. };

  2137. Window_CharEdit_ColorRgb.prototype.drawItem = function(index) {
  2138.     var rect = this.itemRect(index);
  2139.     if (index < 3) {
  2140.         var name, color;
  2141.         if (index === 0) {
  2142.             name = 'R:';
  2143.             color = 'red';
  2144.         } else if (index === 1) {
  2145.             name = 'G:';
  2146.             color = 'lime';
  2147.         } else {
  2148.             name = 'B:';
  2149.             color = 'blue';
  2150.         }
  2151.         var c = this._color[index];
  2152.         this.drawText(name + c, rect.x + 6, rect.y, rect.width);
  2153.         var dx = rect.x + 88;
  2154.         var dy = rect.y + Math.floor(rect.height / 2);
  2155.         this.drawSlider(dx, dy, 192, 8, c / 255, color);
  2156.         return;
  2157.     } else {
  2158.         this.drawText(MPPlugin.text.Ok, rect.x + 6, rect.y, rect.width, 'center');
  2159.     }
  2160. };

  2161. Window_CharEdit_ColorRgb.prototype.drawSlider = function(x, y, width, height, value, color) {
  2162.     var context = this.contents.context;
  2163.     var dx = x + height / 2;
  2164.     var dw = width - height;
  2165.     context.save();
  2166.    
  2167.     context.strokeStyle = 'gray';
  2168.     context.lineWidth = height;
  2169.     context.lineCap = 'round';
  2170.     context.beginPath();
  2171.     context.moveTo(dx, y);
  2172.     context.lineTo(dx + dw, y);
  2173.     context.stroke();
  2174.     var gradient = context.createLinearGradient(x, y, x + width, y);
  2175.     gradient.addColorStop(0, 'white');
  2176.     gradient.addColorStop(1, color);
  2177.     context.strokeStyle = gradient;
  2178.     context.lineWidth = height - 2;
  2179.     context.stroke();
  2180.    
  2181.     context.restore();
  2182.    
  2183.     var vx = dx + dw * value;
  2184.     context.fillStyle = 'gainsboro';
  2185.     context.shadowColor = 'black';
  2186.     context.shadowOffsetX = 1;
  2187.     context.shadowOffsetY = 1;
  2188.     context.shadowBlur = 6;
  2189.     context.beginPath();
  2190.     context.arc(vx, y, 9, 0, Math.PI * 2);
  2191.     context.fill();
  2192.     context.strokeStyle = 'gray';
  2193.     context.shadowColor = 'rgba(0,0,0,0)';
  2194.     context.stroke();
  2195.    
  2196.     context.restore();
  2197.     this.contents._setDirty();
  2198. };

  2199. Window_CharEdit_ColorRgb.prototype.redrawItem = function(index) {
  2200.     Window_Selectable.prototype.redrawItem.call(this, index);
  2201.     this.refreshColor();
  2202. };

  2203. Window_CharEdit_ColorRgb.prototype.refresh = function() {
  2204.     Window_Selectable.prototype.refresh.call(this);
  2205.     this.refreshColor();
  2206. };

  2207. Window_CharEdit_ColorRgb.prototype.refreshColor = function() {
  2208.     var x = 288 + 2;
  2209.     var y = 2;
  2210.     var width = this.contentsWidth() - x - 2;
  2211.     var height = this.lineHeight() * 3 - 4;
  2212.     this.contents.clearRect(x, y, width, height);
  2213.     this.contents.fillRect(x, y, width, height, 'black');
  2214.     this.contents.fillRect(x+1, y+1, width-2, height-2, 'white');
  2215.     var color = 'rgb(%1)'.format(this._color.join());
  2216.     this.contents.fillRect(x+2, y+2, width-4, height-4, color);
  2217. };

  2218. //-----------------------------------------------------------------------------
  2219. // Window_CharEdit_Preview

  2220. function Window_CharEdit_Preview() {
  2221.     this.initialize.apply(this, arguments);
  2222. }

  2223. Window_CharEdit_Preview.prototype = Object.create(Window_Base.prototype);
  2224. Window_CharEdit_Preview.prototype.constructor = Window_CharEdit_Preview;

  2225. Window_CharEdit_Preview._directionPattern = [2, 4, 8, 6];
  2226. Window_CharEdit_Preview._battlerPattern = [0, 7, 2, 10];

  2227. Window_CharEdit_Preview.prototype.initialize = function(x, y, actor) {
  2228.     var width = MPPlugin.PreviewList.length * 144 + 8 + this.standardPadding() * 2;
  2229.     var height = Window_Base._faceHeight + this.standardPadding() * 2;
  2230.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  2231.     this._actor = actor;
  2232.     this._animeCount = 0;
  2233.     this._animeIndex = 0;
  2234.     this._animePattern = 0;
  2235. };

  2236. Window_CharEdit_Preview.prototype.update = function() {
  2237.     Window_Base.prototype.update.call(this);
  2238.     if (this._characterName !== this._actor.characterName()) {
  2239.         this._characterName = this._actor.characterName();
  2240.         this.redrawAllItem();
  2241.     }
  2242.     this._animeCount++;
  2243.     if (this._animeCount === 24) {
  2244.         this._animeCount = 0;
  2245.         this._animePattern++;
  2246.         if (this._animePattern === 8) {
  2247.             this._animePattern = 0;
  2248.             this._animeIndex = (this._animeIndex + 1) % 4;
  2249.         }
  2250.     }
  2251. };

  2252. Window_CharEdit_Preview.prototype.refresh = function() {
  2253.     this.contents.clear();
  2254.     this.redrawAllItem();
  2255. };

  2256. Window_CharEdit_Preview.prototype.redrawAllItem = function() {
  2257.     this.clearUpdateDrawer();
  2258.     for (var i = 0; i < MPPlugin.PreviewList.length; i++) {
  2259.         this.redrawItem(i);
  2260.     }
  2261. };

  2262. Window_CharEdit_Preview.prototype.redrawItem = function(index) {
  2263.     var type = MPPlugin.PreviewList[index];
  2264.     var actor = this._actor;
  2265.     var bitmap;
  2266.     if (type === 'TV') {
  2267.         bitmap = ImageManager.loadCharacter(actor.characterName());
  2268.     } else if (type === 'SV') {
  2269.         bitmap = ImageManager.loadSvActor(actor.battlerName());
  2270.     } else if (type === 'FG') {
  2271.         bitmap = ImageManager.loadFace(actor.faceName());
  2272.     }
  2273.     if (bitmap) {
  2274.         if (!bitmap.isReady()) {
  2275.             this.drawLoading(index);
  2276.         }
  2277.         var process = this.itemDrawer.bind(this, index, bitmap);
  2278.         if (process()) this.addUpdateDrawer(process);
  2279.     }
  2280. };

  2281. Window_CharEdit_Preview.prototype.redrawItem2 = function(index) {
  2282.     this.contents.clearRect(index * 144, 0, 144, 144);
  2283.     var type = MPPlugin.PreviewList[index];
  2284.     if (type === 'TV') {
  2285.         this.drawActorCharacter(this._actor, index * 144 + 72, 136);
  2286.     } else if (type === 'SV') {
  2287.         this.drawActorBattler(this._actor, index * 144 + 72, 136);
  2288.     } else if (type === 'FG') {
  2289.         this.drawActorFace(this._actor, index * 144, 0, 144, 144);
  2290.     }
  2291. };

  2292. Window_CharEdit_Preview.prototype.itemDrawer = function(index, bitmap) {
  2293.     if (bitmap.isReady() && this._animeCount === 0) {
  2294.         this.redrawItem2(index);
  2295.     }
  2296.     return true;
  2297. };

  2298. Window_CharEdit_Preview.prototype.drawLoading = function(index) {
  2299.     if (index >= 0) {
  2300.         var text = MPPlugin.text.Loading;
  2301.         var dx = index * 144;
  2302.         var dy = Math.floor((144 - this.lineHeight()) / 2);
  2303.         this.drawText(text, dx, dy, 144, 'center');
  2304.     }
  2305. };

  2306. Window_CharEdit_Preview.prototype.drawCharacter = function(characterName, characterIndex, x, y) {
  2307.     var bitmap = ImageManager.loadCharacter(characterName);
  2308.     var big = ImageManager.isBigCharacter(characterName);
  2309.     var pw = bitmap.width / (big ? 3 : 12);
  2310.     var ph = bitmap.height / (big ? 4 : 8);
  2311.     var n = characterIndex;
  2312.     var p = this._animePattern % 4;
  2313.     p = (p < 3 ? p : 1);
  2314.     var d = Window_CharEdit_Preview._directionPattern[this._animeIndex];
  2315.     d = (d - 2) / 2;
  2316.     var sx = (n % 4 * 3 + p) * pw;
  2317.     var sy = (Math.floor(n / 4) * 4 + d) * ph;
  2318.     var rate = 1.75;
  2319.     this.contents.blt(bitmap, sx, sy, pw, ph,
  2320.                         x - pw * rate / 2, y - ph * rate, pw * rate, ph * rate);
  2321. };

  2322. Window_CharEdit_Preview.prototype.drawActorBattler = function(actor, x, y) {
  2323.     var bitmap = ImageManager.loadSvActor(actor.battlerName())
  2324.     var motionIndex = Window_CharEdit_Preview._battlerPattern[this._animeIndex];
  2325.     var pattern = this._animePattern % 4;
  2326.     pattern = (pattern < 3 ? pattern : 1);
  2327.     var cw = bitmap.width / 9;
  2328.     var ch = bitmap.height / 6;
  2329.     var cx = Math.floor(motionIndex / 6) * 3 + pattern;
  2330.     var cy = motionIndex % 6;
  2331.     var rate = 1.75;
  2332.     this.contents.blt(bitmap, cx * cw, cy * ch, cw, ch,
  2333.                         x - cw * rate / 2, y - ch * rate, cw * rate, ch * rate);
  2334. };

  2335. //-----------------------------------------------------------------------------
  2336. // Window_CharEdit_Random

  2337. function Window_CharEdit_Random() {
  2338.     this.initialize.apply(this, arguments);
  2339. }

  2340. Window_CharEdit_Random.prototype = Object.create(Window_Base.prototype);
  2341. Window_CharEdit_Random.prototype.constructor = Window_CharEdit_Random;

  2342. Window_CharEdit_Random.prototype.initialize = function() {
  2343.     Window_Base.prototype.initialize.call(this, 0, 0, 0, this.fittingHeight(1));
  2344.     var text = MPPlugin.text.Random;
  2345.     var allPadding = (this.textPadding() + this.standardPadding()) * 2;
  2346.     this.width = this.textWidth(text) + allPadding;
  2347.     this.setBackgroundType(MPPlugin.RandomBackgroundType);
  2348.     this.createContents();
  2349.     this.refresh();
  2350. };

  2351. Window_CharEdit_Random.prototype.standardPadding = function() {
  2352.     return 8;
  2353. };

  2354. Window_CharEdit_Random.prototype.textPadding = function() {
  2355.     return 12;
  2356. };

  2357. Window_CharEdit_Random.prototype.textWidthEx = function(text) {
  2358.     return this.drawTextEx(text, 0, this.contents.height);
  2359. };

  2360. Window_CharEdit_Random.prototype.refresh = function() {
  2361.     this.contents.clear();
  2362.     this.drawTextEx(MPPlugin.text.Random, this.textPadding(), 0);
  2363. };

  2364. Window_CharEdit_Random.prototype.update = function() {
  2365.     Window_Base.prototype.update.call(this);
  2366.     this.processHandling();
  2367. };

  2368. Window_CharEdit_Random.prototype.processHandling = function() {
  2369.     if (this.isOpen() && this.active) {
  2370.         if (Input.isTriggered('shift') ||
  2371.                 (TouchInput.isTriggered() && this.isTouchedInsideFrame())) {
  2372.             this.processOk();
  2373.         }
  2374.     }
  2375. };

  2376. Window_CharEdit_Random.prototype.isTouchedInsideFrame = function() {
  2377.     return Window_Selectable.prototype.isTouchedInsideFrame.call(this);
  2378. };

  2379. Window_CharEdit_Random.prototype.processOk = function() {
  2380.     if (this._randomHandler) {
  2381.         AudioManager.playStaticSe(MPPlugin.RandomSE);
  2382.         Input.update();
  2383.         TouchInput.update();
  2384.         this._randomHandler();
  2385.     }
  2386. };

  2387. //-----------------------------------------------------------------------------
  2388. // Scene_Boot

  2389. //29
  2390. Alias.ScBo_loadSystemImages = Scene_Boot.loadSystemImages;
  2391. Scene_Boot.loadSystemImages = function() {
  2392.     Alias.ScBo_loadSystemImages.call(this);
  2393.     ImageManager.reserveGeneGradients();
  2394.     ImageManager.reserveGenerator('TV', 'Male', 'TV_Body_p01');
  2395.     ImageManager.reserveGenerator('TV', 'Female', 'TV_Body_p01');
  2396.     if ($dataSystem.optSideView) {
  2397.         ImageManager.reserveGenerator('SV', 'Male', 'SV_body_p01');
  2398.         ImageManager.reserveGenerator('SV', 'Female', 'SV_body_p01');
  2399.     }
  2400. };

  2401. //-----------------------------------------------------------------------------
  2402. // Scene_File

  2403. //17
  2404. Alias.ScFi_create = Scene_File.prototype.create;
  2405. Scene_File.prototype.create = function() {
  2406.     ImageManager.createGeneCache();
  2407.     Alias.ScFi_create.call(this);
  2408. };

  2409. Alias.ScFi_terminate = Scene_File.prototype.terminate
  2410. Scene_File.prototype.terminate = function() {
  2411.     Alias.ScFi_terminate.call(this);
  2412.     ImageManager.deleteGeneCache();
  2413. };

  2414. //-----------------------------------------------------------------------------
  2415. // Scene_CharacterEdit

  2416. function Scene_CharacterEdit() {
  2417.     this.initialize.apply(this, arguments);
  2418. }

  2419. Scene_CharacterEdit.prototype = Object.create(Scene_MenuBase.prototype);
  2420. Scene_CharacterEdit.prototype.constructor = Scene_CharacterEdit;

  2421. Scene_CharacterEdit.prototype.initialize = function() {
  2422.     Scene_MenuBase.prototype.initialize.call(this);
  2423. };

  2424. Scene_CharacterEdit.prototype.prepare = function(tempActor) {
  2425.     this._tempActor = tempActor;
  2426. };
  2427. Scene_CharacterEdit.prototype.create = function() {
  2428.     Scene_MenuBase.prototype.create.call(this);
  2429.     this._switchWindows = [];
  2430.     this.createRandomWindow();
  2431.     this.createCategoryWindow();
  2432.     this.createPartsWindow();
  2433.     this.createPreviewWindow();
  2434.     if (MPPlugin.EditColor) {
  2435.         this.createColorSlotWindow();
  2436.         this.createColorListWindow();
  2437.         this.createColorCustomWindow();
  2438.         this.createColorRgbWindow();
  2439.     }
  2440. };

  2441. Scene_CharacterEdit.prototype.updateActor = function() {
  2442.     Scene_MenuBase.prototype.updateActor.call(this);
  2443.     if (!this._tempActor) {
  2444.         this._tempActor = JsonEx.makeDeepCopy(this._actor);
  2445.         this._tempActor.initEquips([]);
  2446.     }
  2447.     this._tempActor.refreshImageName();
  2448. };

  2449. Scene_CharacterEdit.prototype.createRandomWindow = function() {
  2450.     this._randomWindow = new Window_CharEdit_Random();
  2451.     this._randomWindow.x = Graphics.boxWidth - this._randomWindow.width;
  2452.     this._randomWindow.y = Graphics.boxHeight - this._randomWindow.height;
  2453.     this._randomWindow._randomHandler = this.processRandom.bind(this);
  2454.     this.addWindow(this._randomWindow);
  2455. };

  2456. Scene_CharacterEdit.prototype.createCategoryWindow = function() {
  2457.     this._categoryWindow = new Window_CharEdit_Category(32, 32, this._tempActor);
  2458.     this._categoryWindow.setHandler('ok',     this.onCategoryOk.bind(this));
  2459.     this._categoryWindow.setHandler('cancel', this.onEditCancel.bind(this));
  2460.     this.addWindow(this._categoryWindow);
  2461.     this._switchWindows.push(this._categoryWindow);
  2462. };

  2463. Scene_CharacterEdit.prototype.createPartsWindow = function() {
  2464.     var wx = this._categoryWindow.x + this._categoryWindow.width;
  2465.     var wy = this._categoryWindow.y;
  2466.     this._partsWindow = new Window_CharEdit_PartsList(wx, wy, this._tempActor);
  2467.     this._partsWindow.setHandler('ok',        this.onPartsOk.bind(this));
  2468.     this._partsWindow.setHandler('keyCancel', this.onPartsCancel.bind(this));
  2469.     this._partsWindow.setHandler('cancel',    this.onEditCancel.bind(this));
  2470.     this.addWindow(this._partsWindow);
  2471.     this._categoryWindow.setPartsWindow(this._partsWindow);
  2472.     this._switchWindows.push(this._partsWindow);
  2473. };

  2474. Scene_CharacterEdit.prototype.createPreviewWindow = function() {
  2475.     var wx = this._partsWindow.x;
  2476.     this._previewWindow = new Window_CharEdit_Preview(wx, 0, this._tempActor);
  2477.     var window = this._categoryWindow;
  2478.     this._previewWindow.y = window.y + window.height - this._previewWindow.height;
  2479.     this.addWindow(this._previewWindow);
  2480. };

  2481. Scene_CharacterEdit.prototype.createColorSlotWindow = function() {
  2482.     var wx = this._partsWindow.x + this._partsWindow.width;
  2483.     var wy = this._partsWindow.y;
  2484.     var ww = Math.max(Graphics.boxWidth - wx - 32, 96);
  2485.     this._colorSlotWindow = new Window_CharEdit_ColorSlot(wx, wy, ww, this._tempActor);
  2486.     this._colorSlotWindow.setHandler('ok',        this.onColorSlotOk.bind(this));
  2487.     this._colorSlotWindow.setHandler('keyCancel', this.onColorSlotCancel.bind(this));
  2488.     this._colorSlotWindow.setHandler('cancel',    this.onEditCancel.bind(this));
  2489.     this.addWindow(this._colorSlotWindow);
  2490.     this._partsWindow.setColorWindow(this._colorSlotWindow);
  2491.     this._switchWindows.push(this._colorSlotWindow);
  2492. };

  2493. Scene_CharacterEdit.prototype.createColorListWindow = function() {
  2494.     this._colorListWindow = new Window_CharEdit_ColorList(this._tempActor);
  2495.     var wx = this._colorSlotWindow.x + this._colorSlotWindow.width - this._colorListWindow.width;
  2496.     this._colorListWindow.x = wx;
  2497.     this._colorListWindow.setHandler('ok',     this.onColorListOk.bind(this));
  2498.     this._colorListWindow.setHandler('cancel', this.onColorListCancel.bind(this));
  2499.     this.addWindow(this._colorListWindow);
  2500. };

  2501. Scene_CharacterEdit.prototype.createColorCustomWindow = function() {
  2502.     var wx = this._categoryWindow.x + this._categoryWindow.width;
  2503.     var wy = this._partsWindow.y + this._partsWindow.height;
  2504.     var ww = this._partsWindow.width + this._colorSlotWindow.width;
  2505.     this._colorCustomWindow = new Window_CharEdit_ColorCustom(wx, wy, ww, this._tempActor);
  2506.     this._colorCustomWindow.setHandler('ok',     this.onColorCustomOk.bind(this));
  2507.     this._colorCustomWindow.setHandler('cancel', this.onColorCustomCancel.bind(this));
  2508.     this.addWindow(this._colorCustomWindow);
  2509. };

  2510. Scene_CharacterEdit.prototype.createColorRgbWindow = function() {
  2511.     this._colorRgbWindow = new Window_CharEdit_ColorRgb(this._tempActor);
  2512.     this._colorRgbWindow.setHandler('ok',     this.onColorRgbOk.bind(this));
  2513.     this._colorRgbWindow.setHandler('cancel', this.onColorRgbCancel.bind(this));
  2514.     this._colorRgbWindow._customWindow = this._colorCustomWindow;
  2515.     this.addWindow(this._colorRgbWindow);
  2516. };

  2517. Scene_CharacterEdit.prototype.update = function() {
  2518.     this.updateWindowSwitch();
  2519.     Scene_Base.prototype.update.call(this);
  2520. };

  2521. Scene_CharacterEdit.prototype.updateWindowSwitch = function() {
  2522.     if (TouchInput.isTriggered()) {
  2523.         var windows = this._switchWindows;
  2524.         if (windows.some(function(window) { return window.active; })) {
  2525.             var touchWindow = null;
  2526.             for (var i = 0; i < windows.length; i++) {
  2527.                 if (windows[i].isTouchedInsideFrame()) {
  2528.                     touchWindow = windows[i];
  2529.                 }
  2530.             }
  2531.             if (touchWindow && !touchWindow.active) {
  2532.                 for (var i = 0; i < windows.length; i++) {
  2533.                     if (windows[i] === touchWindow) {
  2534.                         windows[i].activate();
  2535.                     } else {
  2536.                         windows[i].deactivate();
  2537.                     }
  2538.                 }
  2539.             }
  2540.         }
  2541.     }
  2542. };

  2543. Scene_CharacterEdit.prototype.onEditCancel = function() {
  2544.     if (MPPlugin.ConfirmationScene &&
  2545.             (!this._actor._geneParts.equals(this._tempActor._geneParts) ||
  2546.             !this._actor._geneColors.equals(this._tempActor._geneColors))) {
  2547.         SceneManager.push(Scene_Confirm);
  2548.         SceneManager.prepareNextScene(this._tempActor);
  2549.     } else {
  2550.         this._actor._geneParts = this._tempActor._geneParts;
  2551.         this._actor._geneColors = this._tempActor._geneColors;
  2552.         this._actor.refreshImageName();
  2553.         this.popScene();
  2554.     }
  2555. };

  2556. Scene_CharacterEdit.prototype.onCategoryOk = function() {
  2557.     this._partsWindow.activate();
  2558. };

  2559. Scene_CharacterEdit.prototype.onPartsOk = function() {
  2560.     if (this._colorSlotWindow) {
  2561.         this._colorSlotWindow.activate();
  2562.     } else {
  2563.         this._categoryWindow.activate();
  2564.     }
  2565. };

  2566. Scene_CharacterEdit.prototype.onPartsCancel = function() {
  2567.     this._categoryWindow.activate();
  2568. };

  2569. Scene_CharacterEdit.prototype.onColorSlotOk = function() {
  2570.     this._colorListWindow.y = this._colorSlotWindow.currentBottomY();
  2571.     this._colorListWindow.setup(this._colorSlotWindow.currentExt());
  2572.     this._randomWindow.deactivate();
  2573. };

  2574. Scene_CharacterEdit.prototype.onColorSlotCancel = function() {
  2575.     this._partsWindow.activate();
  2576. };

  2577. Scene_CharacterEdit.prototype.onColorListOk = function() {
  2578.     if (this._colorListWindow.currentSymbol() === 'color') {
  2579.         this._colorSlotWindow.activate();
  2580.         this._colorSlotWindow.refresh();
  2581.         this._colorListWindow.close();
  2582.         this._randomWindow.activate();
  2583.     } else {
  2584.         this._colorListWindow.close();
  2585.         this._colorCustomWindow.setup(this._colorSlotWindow.currentExt());
  2586.     }
  2587. };

  2588. Scene_CharacterEdit.prototype.onColorListCancel = function() {
  2589.     this._colorSlotWindow.activate();
  2590.     this._colorSlotWindow.refresh();
  2591.     this._colorListWindow.close();
  2592.     this._randomWindow.activate();
  2593. };

  2594. Scene_CharacterEdit.prototype.onColorCustomOk = function() {
  2595.     var n1 = this._colorSlotWindow.currentExt();
  2596.     var n2 = this._colorCustomWindow.index();
  2597.     this._colorRgbWindow.setup(n1, n2);
  2598. };

  2599. Scene_CharacterEdit.prototype.onColorCustomCancel = function() {
  2600.     this._colorSlotWindow.activate();
  2601.     this._colorSlotWindow.refresh();
  2602.     this._colorCustomWindow.close();
  2603.     this._randomWindow.activate();
  2604. };

  2605. Scene_CharacterEdit.prototype.onColorRgbOk = function() {
  2606.     this._colorRgbWindow.setActorColor();
  2607.     this._colorCustomWindow.refresh();
  2608.     this._colorCustomWindow.activate();
  2609.     this._colorRgbWindow.close();
  2610. };

  2611. Scene_CharacterEdit.prototype.onColorRgbCancel = function() {
  2612.     this._colorCustomWindow.activate();
  2613.     this._colorRgbWindow.close();
  2614. };

  2615. Scene_CharacterEdit.prototype.processRandom = function() {
  2616.     var partsList = MPPlugin.RandomPartsList;
  2617.     var variation = $dataCharGene.Variation[this._tempActor._geneKind];
  2618.     for (var i = 0; i < partsList.length; i++) {
  2619.         var name = partsList[i];
  2620.         var list = variation[name];
  2621.         if (list && list.length > 0) {
  2622.             if (!MPPlugin.ForceParts.contains(name)) {
  2623.                 list = list.clone();
  2624.                 list.push(-1);
  2625.             }
  2626.             this._tempActor.setGeneParts(name, list[Math.randomInt(list.length)], true);
  2627.         }
  2628.     }
  2629.     if (MPPlugin.EditColor) {
  2630.         var colorList = MPPlugin.RandomColorList;
  2631.         for (var i = 0; i < colorList.length; i++) {
  2632.             var n = colorList[i];
  2633.             var start = Database.gradients[n * 2] || 0;
  2634.             var max = Database.gradients[n * 2 + 1] || 0;
  2635.             if (max > 0) {
  2636.                 var c = Math.randomInt(max + 1);
  2637.                 c = (c === max ? -1 : start + c);
  2638.                 this._tempActor.setGeneColor(n, c);
  2639.             }
  2640.         }
  2641.     }
  2642.     this._tempActor.refreshImageName();
  2643.     this._partsWindow.selectParts();
  2644.     if (this._colorSlotWindow) this._colorSlotWindow.refresh();
  2645. };


  2646. //=============================================================================
  2647. // Scene_Confirm
  2648. //=============================================================================

  2649. //-----------------------------------------------------------------------------
  2650. // Window_Confirm

  2651. function Window_Confirm() {
  2652.     this.initialize.apply(this, arguments);
  2653. }

  2654. Window_Confirm.prototype = Object.create(Window_Base.prototype);
  2655. Window_Confirm.prototype.constructor = Window_Confirm;

  2656. Window_Confirm.prototype.initialize = function(y) {
  2657.     var x = -this.standardPadding();
  2658.     var width = Graphics.boxWidth + this.standardPadding() * 2;
  2659.     var height = this.fittingHeight(1);
  2660.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  2661.     this.openness = 0;
  2662.     this.refresh();
  2663.     this.open();
  2664. };

  2665. Window_Confirm.prototype.standardPadding = function() {
  2666.     return 12;
  2667. };

  2668. Window_Confirm.prototype.refresh = function() {
  2669.     this.contents.clear();
  2670.     this.drawText(MPPlugin.text.Confirmation, 0, 0, this.contentsWidth(), 'center');
  2671. };

  2672. //-----------------------------------------------------------------------------
  2673. // Window_ConfirmCommand

  2674. function Window_ConfirmCommand() {
  2675.     this.initialize.apply(this, arguments);
  2676. }

  2677. Window_ConfirmCommand.prototype = Object.create(Window_Command.prototype);
  2678. Window_ConfirmCommand.prototype.constructor = Window_ConfirmCommand;

  2679. Window_ConfirmCommand.prototype.initialize = function(y) {
  2680.     var x = (Graphics.boxWidth - this.windowWidth()) / 2;
  2681.     Window_Command.prototype.initialize.call(this, x, y);
  2682.     this.openness = 0;
  2683.     this.open();
  2684. };

  2685. Window_ConfirmCommand.prototype.windowWidth = function() {
  2686.     return 0;
  2687. };

  2688. Window_ConfirmCommand.prototype.numVisibleRows = function() {
  2689.     return 3;
  2690. };

  2691. Window_ConfirmCommand.prototype.makeCommandList = function() {
  2692.     this.addCommand(MPPlugin.text.Yes, 'yes');
  2693.     this.addCommand(MPPlugin.text.No, 'no');
  2694.     this.addCommand(MPPlugin.text.Default, 'default');
  2695. };

  2696. Window_ConfirmCommand.prototype.itemTextAlign = function() {
  2697.     return 'center';
  2698. };

  2699. Window_ConfirmCommand.prototype.refresh = function() {
  2700.     this.clearCommandList();
  2701.     this.makeCommandList();
  2702.     var widthMax = Math.max(this.textWidth(MPPlugin.text.Yes),
  2703.                         this.textWidth(MPPlugin.text.No),
  2704.                         this.textWidth(MPPlugin.text.Default));
  2705.     this.width = widthMax + (this.textPadding() + this.standardPadding()) * 2;
  2706.     this.x = (Graphics.boxWidth - this.width) / 2;
  2707.     this.createContents();
  2708.     Window_Selectable.prototype.refresh.call(this);
  2709. };
  2710. //-----------------------------------------------------------------------------
  2711. // Scene_Confirm

  2712. function Scene_Confirm() {
  2713.     this.initialize.apply(this, arguments);
  2714. }

  2715. Scene_Confirm.prototype = Object.create(Scene_MenuBase.prototype);
  2716. Scene_Confirm.prototype.constructor = Scene_Confirm;

  2717. Scene_Confirm.prototype.initialize = function() {
  2718.     Scene_MenuBase.prototype.initialize.call(this);
  2719. };

  2720. Scene_Confirm.prototype.prepare = function(tempActor) {
  2721.     this._tempActor = tempActor;
  2722. };

  2723. Scene_Confirm.prototype.create = function() {
  2724.     Scene_MenuBase.prototype.create.call(this);
  2725.     this.createConfirmWindow();
  2726.     this.createCommandWindow();
  2727.     this.createPreviewWindow();
  2728. };

  2729. Scene_Confirm.prototype.createConfirmWindow = function() {
  2730.     this._confirmWindow = new Window_Confirm(192);
  2731.     this.addWindow(this._confirmWindow);
  2732. };

  2733. Scene_Confirm.prototype.createCommandWindow = function() {
  2734.     this._commandWindow = new Window_ConfirmCommand(256);
  2735.     this._commandWindow.setHandler('yes',     this.onCommandYes.bind(this));
  2736.     this._commandWindow.setHandler('no',      this.onCommandNo.bind(this));
  2737.     this._commandWindow.setHandler('default', this.onCommandDefault.bind(this));
  2738.     this.addWindow(this._commandWindow);
  2739. };

  2740. Scene_Confirm.prototype.createPreviewWindow = function() {
  2741.     this._previewWindow = new Window_CharEdit_Preview(0, 0, this._tempActor);
  2742.     this._previewWindow.x = (Graphics.boxWidth - this._previewWindow.width) / 2;
  2743.     this._previewWindow.y = 408;
  2744.     this.addWindow(this._previewWindow);
  2745. };

  2746. Scene_Confirm.prototype.onCommandYes = function() {
  2747.     this._actor._geneParts = this._tempActor._geneParts;
  2748.     this._actor._geneColors = this._tempActor._geneColors;
  2749.     this._actor.refreshImageName();
  2750.     SceneManager.goto(Scene_Map);
  2751. };

  2752. Scene_Confirm.prototype.onCommandNo = function() {
  2753.     this.popScene();
  2754.     SceneManager.prepareNextScene(this._tempActor);
  2755. };

  2756. Scene_Confirm.prototype.onCommandDefault = function() {
  2757.     this._tempActor._geneParts = this._actor._geneParts.clone();
  2758.     this._tempActor._geneColors = this._actor._geneColors.clone();
  2759.     //this._tempActor.refreshImageName();
  2760.     this.popScene();
  2761.     SceneManager.prepareNextScene(this._tempActor);
  2762. };




  2763. })();


  2764. //=============================================================================
  2765. // UpdateDrawer
  2766. //=============================================================================

  2767. (function() {

  2768. if (!Window_Base.Mpp_UpdateDrawer || Window_Base.Mpp_UpdateDrawer < 1.0) {

  2769. var Alias = {};

  2770. //-----------------------------------------------------------------------------
  2771. // Window_Base

  2772. //13
  2773. Alias.WiBa_initialize = Window_Base.prototype.initialize;
  2774. Window_Base.prototype.initialize = function(x, y, width, height) {
  2775.     Alias.WiBa_initialize.call(this, x, y, width, height);
  2776.     this._updateDrawers = [];
  2777. };

  2778. //105
  2779. Alias.WiBa_update = Window_Base.prototype.update;
  2780. Window_Base.prototype.update = function() {
  2781.     Alias.WiBa_update.call(this);
  2782.     this.updateDrawer();
  2783. };

  2784. Window_Base.prototype.updateDrawer = function() {
  2785.     if (this.isOpen() && this.visible && this._updateDrawers.length > 0) {
  2786.         this._updateDrawers = this._updateDrawers.filter(function(process) {
  2787.             return process();
  2788.         });
  2789.     }
  2790. };

  2791. Window_Base.prototype.addUpdateDrawer = function(process) {
  2792.     this._updateDrawers.push(process);
  2793. };

  2794. Window_Base.prototype.clearUpdateDrawer = function() {
  2795.     this._updateDrawers = [];
  2796. };

  2797. Window_Base.Mpp_UpdateDrawer = 1.0;
  2798. } //if (!Window_Base.MPP_UpdateDrawer || Window_Base.MPP_UpdateDrawer < 1.0)


  2799. })();
复制代码


導入手順

    本プラグインを導入します。
    キャラクター生成用の画像をゲームフォルダに移します。
    RPGツクールMVがインストールされているフォルダからGeneratorフォルダをゲームプロジェクトフォルダ内にコピー&ペーストしてください。

    RPGツクールMVをインストールする際に選んだフォルダ内にあります。
    Windowsであれば通常は C:\Program Files (x86)\KADOKAWA\RPGMV です。
    各フォルダの画像ファイルは必要に応じて追加・削除してください。
    子供を使わない場合、Kidフォルダごと削除しても構いません。
    画像ファイル名のパーツ番号(p○○)の数値は変更可能です。
    パーツ番号に空きがあっても動作します。

    ただし、Variation / TVD / TV / SV / Faceフォルダ内にある各パーツはすべて連動しています。
    パーツ番号を変える場合は、すべてのフォルダにある同じパーツの番号を変えてください。
    プラグインを導入したゲームでテストプレイを実行してください。
    テストプレイ実行時に、Generatorフォルダ内にある画像ファイルが自動でリスト化され、
    Generatorフォルダ内に CharGene.json というファイルが作成されます。

    このCharGene.json がなければ、本プラグインは動作しません。
    Generatorフォルダ内のファイルを変更した際も、必ず一度はテストプレイを実行し、
    CharGene.json を更新してください。
回复

使用道具 举报

梦石
0
星屑
449
在线时间
62 小时
注册时间
2016-5-10
回帖
7
发表于 2018-5-1 15:11:33 | 显示全部楼层
本帖最后由 chelsea0989 于 2018-5-1 15:59 编辑
tseyik 发表于 2018-5-1 12:30
把Generat文件夾複制到專項内

[fold=MPP_CharacterMake.js]//======================================= ...


感谢大大!!但是帮助文件里面什么也没有,并且报错 1 (1).png 1525161566(1).jpg
回复

使用道具 举报

梦石
0
星屑
60
在线时间
147 小时
注册时间
2018-7-19
回帖
49
发表于 2018-9-10 12:50:43 | 显示全部楼层
MPP_CharacterMake這個插件我使用了,
但是要怎樣才能打開捏臉系統?
插件命令是什麼?
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部