设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3333|回复: 4
打印 上一主题 下一主题

[有事请教] CategorySynthesis合成系统求助!

[复制链接]

Lv2.观梦者

梦石
0
星屑
362
在线时间
102 小时
注册时间
2021-7-1
帖子
22
跳转到指定楼层
1
发表于 2021-7-3 22:25:24 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
有配方有材料却是黑的,请帮帮我!


Lv2.观梦者

梦石
0
星屑
314
在线时间
80 小时
注册时间
2015-9-4
帖子
43
2
发表于 2021-7-3 22:46:17 | 只看该作者
留下联系方式  给你试试吧,练练手
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
362
在线时间
102 小时
注册时间
2021-7-1
帖子
22
3
 楼主| 发表于 2021-7-3 23:29:36 | 只看该作者
花天酒地 发表于 2021-7-3 22:46
留下联系方式  给你试试吧,练练手

a15828095723vx
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
219
在线时间
47 小时
注册时间
2009-7-5
帖子
63
4
发表于 2025-12-6 15:05:36 | 只看该作者
与yep物品核心中的独立物品功能有冲突,我目前也没解决,拷问deepseek一上午,也没帮我修改好= =
30岁了,也要继续创造梦想啊。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
219
在线时间
47 小时
注册时间
2009-7-5
帖子
63
5
发表于 2025-12-6 15:35:34 | 只看该作者
拷问Gemini我得到了修复后的插件。
JAVASCRIPT 代码复制下载
  1. //
  2. //  カテゴリ合成 ver1.00
  3. //
  4. // ------------------------------------------------------
  5. // Copyright (c) 2016 Yana
  6. // Released under the MIT license
  7. // http://opensource.org/licenses/mit-license.php
  8. // ------------------------------------------------------
  9. //
  10. // author Yana
  11. //
  12.  
  13. var Imported = Imported || {};
  14. Imported['CategorySythesis'] = 1.00;
  15.  
  16. /*:
  17.  * @plugindesc ver1.00/アイテムを合成する機能を追加します。【SecondaryCategories必須】
  18.  * @author Yana
  19.  *
  20.  * @param DefaultSynthesisName
  21.  * @desc 合成场景默认显示名称
  22.  * @default 合成
  23.  *
  24.  * @param DefaultSynthesisCategories
  25.  * @desc 合成界面的默认类别
  26.  * @default 物品,武器,护甲,重要物品
  27.  *
  28.  * @param NeedMachineryName
  29.  * @desc 必要设备名称
  30.  * @default 必要器材
  31.  *
  32.  * @param NeedMaterialName
  33.  * @desc 所需材料的名称。
  34.  * @default 必要素材
  35.  *
  36.  * @param MaterialListText
  37.  * @desc 材质列表上方材料清单的显示名
  38.  * @default 材料清单
  39.  *
  40.  * @param SynthesisText
  41.  * @desc 合成选项按钮名
  42.  * @default 合成
  43.  *
  44.  * @param NumberSynthesisText
  45.  * @desc 显示为“合成0个”的文本。
  46.  * @default _num個合成する
  47.  *
  48.  * @param SynthesisHelp
  49.  * @desc 当光标位于“合成0”时,在帮助中显示的文本。
  50.  * @default 上下キーで製作個数を選択します。
  51.  *
  52.  * @param EstimateText
  53.  * @desc 结果预测窗口中显示的文本。
  54.  * @default 合成结果
  55.  *
  56.  * @param SynthesisPriceText
  57.  * @desc 当光标在合成商店时合成时,显示的合成费用的文本。
  58.  * @default 合成费用
  59.  *
  60.  * @param ChangeRecipeTone
  61.  * @desc 配方更改时,预测窗口和结果窗口的色调。
  62.  * @default 206,68,24,0
  63.  *
  64.  * @param SynthesisResultText
  65.  * @desc 合成完毕显示的窗口名
  66.  * @default 获得
  67.  *
  68.  * @param SynthesisSeName
  69.  * @desc 合成时的SE音效名
  70.  * @default Item1
  71.  * @require 1
  72.  * @dir audio/se/
  73.  * @type file
  74.  *
  75.  * @param SynthesisSeSettings
  76.  * @desc 合成音效设置
  77.  * @default 90,100,0
  78.  *
  79.  * @param MenuSynthesisCommandName
  80.  * @desc 要在菜单中显示的复合命令的名称。
  81.  * 如果留为空白,则不会添加到菜单中。
  82.  * @default 合成
  83.  *
  84.  * @help------------------------------------------------------
  85.  *  插件命令
  86.  * ------------------------------------------------------
  87.  * ***直接调用合成场景***
  88.  * カテゴリ合成呼び出し
  89.  * CallCategorySynthesis
  90.  *
  91.  * 你可以额外设置合成窗口左上角的名称、右侧显示的图片,以及要合成的类别。
  92.  * 不设置类别的话,则使用默认值。
  93.  *
  94.  * 例:名称设为“合成屋”、图片设为“test1”、类别设为“回復薬”,“インゴットに”
  95.  * カテゴリ合成呼び出し 名前:合成屋 ピクチャ:test1 カテゴリ:回復薬,インゴット
  96.  *
  97.  *
  98.  *
  99.  *
  100.  * ***通过商店调用合成场景***
  101.  * 合成ショップ設定
  102.  * SettingSynthesisShop
  103.  *
  104.  * 设置方法和上面的同理。
  105.  * 输入插件命令后再执行商店设置(商店需选择要合成的物品)。
  106.  *
  107.  * 此调用方法会无视你拥有的配方,只显示商店里设置的可合成物。
  108.  * 除此以外还需要合成费用(金币),必要设备的限制也会无效。
  109.  *
  110.  *
  111.  *
  112.  * ------------------------------------------------------
  113.  *  用法
  114.  * ------------------------------------------------------
  115.  * ***配方设定***
  116.  * 在物品备注栏内加入以下注释:
  117.  *
  118.  * ―――合成材料设定―――
  119.  * <合成材料:○:x,○:x…>
  120.  * <SyntheticMaterials:○:x,○:x…>
  121.  *
  122.  * ○指物品ID或次级类别,x为数量。(若为类别,则指定所有该类别里的物品作为材料,注释<材料指定不可>似乎可以让对应物品不在这时作为材料。)
  123.  * 若要指定具体物品,使用I◇,W◇,A◇的形式。
  124.  * 其中I指物品,W指武器,A指防具。
  125.  *
  126.  * 若要指定次级类别,直接输入次级类别名即可。
  127.  * 如果相同的材料只要一个,则可以省略:x。
  128.  *
  129.  * 例:指定5号物品2个、1号武器1个、7号护甲1个作为合成材料
  130.  * <合成材料:I5:2,W1,A7>
  131.  *
  132.  * ―――合成设备设定―――
  133.  * <必要器材:○,○…>
  134.  * <Machinery:○,○…>
  135.  *
  136.  * 设置方法同上,所谓设备就是类似mc的炼药台,但这里可以是武器或者护甲。
  137.  * 作为合成的媒介,设备合成后不会被消耗掉。
  138.  * 设备不能指定类别和数量,而且只能插件命令直接调用时生效。
  139.  *
  140.  * 通过商店场景调用时,此设置将被忽略。
  141.  *
  142.  * 例:指定6号物品和8号武器作为必要器材
  143.  * <必要器材:I6,W8>
  144.  *
  145.  * ―――合成数量―――
  146.  * <合成数:x>
  147.  * <SyntheticNumber:x>
  148.  *
  149.  * 一次合成获得的该合成物数量。
  150.  *
  151.  * ―――合成费用设定―――
  152.  * <合成料:x>
  153.  * <SyntheticPrice:x>
  154.  *
  155.  * x为数字,合成费仅在通过商店调用时生效。
  156.  * 如果没有设置,则合成费用为道具的价格。
  157.  *
  158.  *
  159.  * ―――假配方设定―――
  160.  * <ダミーレシピ:○>
  161.  * <DummyRecipe:○>
  162.  *
  163.  * ダミーレシピとは1つのアイテムのレシピを複数設定するための仕組みです。
  164.  * 设置了假配方的合成物,合成后获得的物品会变为假配方里的。
  165.  *
  166.  * 设定方式与配方一致,用I◇,W◇,A◇指定物品。
  167.  *
  168.  * ―――合成优先级设定―――
  169.  * <合成優先度:x>
  170.  * <SyntheticPriority:x>
  171.  *
  172.  * 合成优先级是在配方发生变化时指定变化目标项目的机制。
  173.  * 满足配方时,将变为优先级最高的配方。
  174.  * 如果优先级相同,则优先考虑ID编号大的。
  175.  *
  176.  * ***配方设置***
  177.  * 在备注栏内添加以下注释:
  178.  *
  179.  * <掲載レシピ:○,○,○…>
  180.  * <PublishedRecipe:○,○,○…>
  181.  *
  182.  * 设定方式同上。
  183.  *
  184.  * 例:5号道具,2号武器,6号防具
  185.  * <掲載レシピ:I5,W2,A6>
  186.  *
  187.  * ------------------------------------------------------
  188.  * 利用規約
  189.  * ------------------------------------------------------
  190.  * 当プラグインはMITライセンスで公開されています。
  191.  * 使用に制限はありません。商用、アダルト、いずれにも使用できます。
  192.  * 二次配布も制限はしませんが、サポートは行いません。
  193.  * 著作表示は任意です。行わなくても利用できます。
  194.  * 要するに、特に規約はありません。
  195.  * バグ報告や使用方法等のお問合せはネ実ツクールスレ、または、Twitterにお願いします。
  196.  * https://twitter.com/yanatsuki_
  197.  * 素材利用は自己責任でお願いします。
  198.  * ------------------------------------------------------
  199.  * 更新履歴:
  200.  * ver1.00:
  201.  * 公開
  202.  */
  203.  
  204. (function() {
  205.  
  206.     'use strict';
  207.  
  208.     ////////////////////////////////////////////////////////////////////////////////////
  209.  
  210.     var parameters = PluginManager.parameters('CategorySynthesis');
  211.     var defaultSynthesisName = parameters['DefaultSynthesisName'];
  212.     var defaultSynthesisCategories = parameters['DefaultSynthesisCategories'].split(',');
  213.     var needMachineryName = parameters['NeedMachineryName'];
  214.     var needMaterialName = parameters['NeedMaterialName'];
  215.     var materialListText = parameters['MaterialListText'];
  216.     var synthesisText = parameters['SynthesisText'];
  217.     var numberSynthesisText = parameters['NumberSynthesisText'];
  218.     var synthesisHelp = parameters['SynthesisHelp'];
  219.     var estimateText = parameters['EstimateText'];
  220.     var synthesisPriceText = parameters['SynthesisPriceText'];
  221.     var changeRecipeTone = parameters['ChangeRecipeTone'].split(',').map(function(s){ return Number(s)});
  222.     var synthesisResultText = parameters['SynthesisResultText'];
  223.     var synthesisSeName = parameters['SynthesisSeName'];
  224.     var synthesisSeSettings = parameters['SynthesisSeSettings'].split(',').map(function(s){ return Number(s)});
  225.     var menuSynthesisCommandName = parameters['MenuSynthesisCommandName'];
  226.  
  227.     ////////////////////////////////////////////////////////////////////////////////////
  228.  
  229.     var __WMCommand_addOriginalCommands = Window_MenuCommand.prototype.addOriginalCommands;
  230.     Window_MenuCommand.prototype.addOriginalCommands = function() {
  231.         __WMCommand_addOriginalCommands.call(this);
  232.         if (menuSynthesisCommandName){
  233.             this.addCommand(menuSynthesisCommandName, 'categorySynthesis', true);
  234.         }
  235.     };
  236.  
  237.     var __SMenu_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
  238.     Scene_Menu.prototype.createCommandWindow = function() {
  239.         __SMenu_createCommandWindow.call(this);
  240.         this._commandWindow.setHandler('categorySynthesis',   this.commandCategorySynthesis.bind(this));
  241.     };
  242.  
  243.     Scene_Menu.prototype.commandCategorySynthesis = function() {
  244.         $gameTemp._callShopSynthesis = false;
  245.         SceneManager.push(Scene_CategorySynthesis);
  246.         SceneManager.prepareNextScene('');
  247.     };
  248.  
  249.     ////////////////////////////////////////////////////////////////////////////////////
  250.  
  251.     DataManager.isRecipeBook = function(item) {
  252.         return item && (item.meta['掲載レシピ'] || item.meta['PublishedRecipe']);
  253.     };
  254.  
  255.     DataManager.publishedItemRecipes = function(item) {
  256.         var recipes = item.meta['掲載レシピ'] || item.meta['PublishedRecipe'];
  257.         return recipes.split(',');
  258.     };
  259.  
  260.     DataManager.hasRecipe = function(item) {
  261.        var recipe = this.itemRecipe(item);
  262.        if (recipe.recipe) return true;
  263.        return false;
  264.     };
  265.  
  266.     DataManager.itemRecipe = function(item) {
  267.         if (item._recipe) return item._recipe;
  268.         var recipe = item.meta['合成材料'] || item.meta['SyntheticMaterials'] || '';
  269.         var machinery = item.meta['必要器材'] || item.meta['Machinery'] || '';
  270.         var num = item.meta['合成数'] || item.meta['SyntheticNumber'] || 1;
  271.         var value = item.meta['合成料'] || item.meta['SyntheticPrice'] || item.price;
  272.         var dummy = item.meta['ダミーレシピ'] || item.meta['DummyRecipe'] || '';
  273.         var priority = Number(item.meta['合成優先度'] || item.meta['SyntheticPriority']) || 0;
  274.         var mats = recipe.split(',').filter(function(m){
  275.             return m;
  276.         }).map(function(m){
  277.             var n = 1;
  278.             if (m.match(/:(\d+)/)) n = Number(RegExp.$1);
  279.             m = m.replace(/:\d+/,'');
  280.             return [m,n];
  281.         });
  282.         var mache = machinery.split(',').filter(function(m){
  283.             return m;
  284.         }).map(function(m){
  285.             var n = 1;
  286.             if (m.match(/:(\d+)/)) n = Number(RegExp.$1);
  287.             m = m.replace(/:\d+/,'');
  288.             return [m,n];
  289.         });
  290.         item._recipe = {num:num, value:value, recipe:mats, machinery:mache, dummy:dummy, priority:priority};
  291.         return item._recipe;
  292.     };
  293.  
  294.     DataManager.encodeSynthesisItem = function(obj) {
  295.         if (!obj) return null;
  296.         if (this.isItem(obj))   return 'I' + obj.id;
  297.         if (this.isWeapon(obj)) return 'W' + obj.id;
  298.         if (this.isArmor(obj))  return 'A' + obj.id;
  299.         return null;
  300.     };
  301.  
  302.     DataManager.decodeSynthesisItem = function(obj) {
  303.         if (!obj) return null;
  304.         var type = obj[0].toUpperCase();
  305.         var item = null;
  306.         var id = Number(obj.replace(/[IWA]/,''));
  307.         if (id) {
  308.             switch (type) {
  309.                 case 'I': item = $dataItems[id]; break;
  310.                 case 'W': item = $dataWeapons[id]; break;
  311.                 case 'A': item = $dataArmors[id]; break;
  312.             }
  313.         }
  314.         return item;
  315.     };
  316.  
  317.     DataManager.isSynthesisItem = function(item) {
  318.         return /^[IWA]\d+/i.test(item);
  319.     };
  320.  
  321.     DataManager.isMaterial = function(item) {
  322.         return item && !(item.meta['材料指定不可'] || item.meta['NotMaterial']);
  323.     };
  324.  
  325.     ////////////////////////////////////////////////////////////////////////////////////
  326.  
  327.     var __GInterpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  328.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
  329.         if (command === 'カテゴリ合成呼び出し' || command === 'CallCategorySynthesis') {
  330.             this.callCategorySynthesis(args);
  331.         } else if (command === '合成ショップ設定' || command === 'SettingSynthesisShop') {
  332.             this.callSynthesisShop(args);
  333.         } else {
  334.             __GInterpreter_pluginCommand.call(this, command, args);
  335.         }
  336.     };
  337.  
  338.     Game_Interpreter.prototype.callCategorySynthesis = function(args) {
  339.         $gameTemp._callShopSynthesis = false;
  340.         SceneManager.push(Scene_CategorySynthesis);
  341.         SceneManager.prepareNextScene(args);
  342.     };
  343.  
  344.     Game_Interpreter.prototype.callSynthesisShop = function(args) {
  345.         $gameTemp._categoryShopSetting = args;
  346.     };
  347.  
  348.  
  349.     // Shop Processing
  350.     var __GInterpreter_command302 = Game_Interpreter.prototype.command302;
  351.     Game_Interpreter.prototype.command302 = function() {
  352.         if (!$gameParty.inBattle()) {
  353.             if ($gameTemp._categoryShopSetting) {
  354.                 var goods = [this._params];
  355.                 while (this.nextEventCode() === 605) {
  356.                     this._index++;
  357.                     goods.push(this.currentCommand().parameters);
  358.                 }
  359.                 $gameTemp._callShopSynthesis = true;
  360.                 SceneManager.push(Scene_CategorySynthesis);
  361.                 SceneManager.prepareNextScene($gameTemp._categoryShopSetting, goods);
  362.             } else {
  363.                 __GInterpreter_command302.call(this);
  364.             }
  365.         }
  366.         return true;
  367.     };
  368.  
  369.     ////////////////////////////////////////////////////////////////////////////////////
  370.  
  371.     Window_Base.prototype.drawSynthesisStretchIcon = function(iconIndex, x, y) {
  372.         var bitmap = ImageManager.loadSystem('IconSet');
  373.         var pw = Window_Base._iconWidth;
  374.         var ph = Window_Base._iconHeight;
  375.         var sx = iconIndex % 16 * pw;
  376.         var sy = Math.floor(iconIndex / 16) * ph;
  377.         var n = this.contents.fontSize + 4;
  378.         this.contents.blt(bitmap, sx, sy, pw, ph, x, y, n, n);
  379.     };
  380.  
  381.     Window_Base.prototype.drawSynthesisItemName = function(item, num, x, y, width) {
  382.         width = width || 312;
  383.         if (item) {
  384.             var iconBoxWidth = this.contents.fontSize + 8;
  385.             this.resetTextColor();
  386.             this.drawSynthesisStretchIcon(item.iconIndex, x + 2, y + 4);
  387.             var text = item.name;
  388.             if (num > 1) text += 'x' + num;
  389.             this.drawText(text, x + iconBoxWidth, y, width - iconBoxWidth);
  390.         }
  391.     };
  392.  
  393.     Window_Base.prototype.drawSynthesisHorzLine = function(y) {
  394.         this.contents.fillRect(4, y, this.contentsWidth() - 8, 2, 'rgba(255,255,255,0.5)');
  395.     };
  396.  
  397.     ////////////////////////////////////////////////////////////////////////////////////
  398.  
  399.     //並列処理でレシピの配列を作成
  400.     var __SBase_update = Scene_Base.prototype.update;
  401.     Scene_Base.prototype.update = function() {
  402.         __SBase_update.call(this);
  403.         if ($gameTemp && !$gameTemp._allCheckedRecipes){
  404.             $gameTemp.updateMakeRecipeArray();
  405.         }
  406.     };
  407.  
  408.     ////////////////////////////////////////////////////////////////////////////////////
  409.  
  410.     Game_Temp.prototype.updateMakeRecipeArray = function() {
  411.         if (!this._recipeArray){
  412.             this._recipeArray = [];
  413.             this._allCheckedRecipes = false;
  414.             this._recipeCheckIndex = 0;
  415.         }
  416.         for (var i=0;i<10;i++) {
  417.             var item = null;
  418.             if (this._recipeCheckIndex < 10000) {
  419.                 item = $dataItems[this._recipeCheckIndex];
  420.                 if (item) this.setRecipeArray('I', item);
  421.             } else if (this._recipeCheckIndex < 20000){
  422.                 item = $dataWeapons[this._recipeCheckIndex - 10000];
  423.                 if (item) this.setRecipeArray('W', item);
  424.             } else {
  425.                 item = $dataArmors[this._recipeCheckIndex - 20000];
  426.                 if (item) this.setRecipeArray('A', item);
  427.             }
  428.             this._recipeCheckIndex++;
  429.             if (this._recipeCheckIndex === $dataItems.length) {
  430.                 this._recipeCheckIndex = 10000;
  431.             } else if (this._recipeCheckIndex === $dataWeapons.length + 10000) {
  432.                 this._recipeCheckIndex = 20000;
  433.             } else if (this._recipeCheckIndex === $dataArmors.length + 20000) {
  434.                 this._allCheckedRecipes = true;
  435.             }
  436.         }
  437.     };
  438.  
  439.     Game_Temp.prototype.setRecipeArray = function(type, item) {
  440.         if (DataManager.hasRecipe(item)) {
  441.             var recipe = DataManager.itemRecipe(item);
  442.             var l = 0;
  443.             for (var i=0,max=recipe.recipe.length;i<max;i++) l += recipe.recipe[i][1];
  444.             if (l > 0) {
  445.                 if (!this._recipeArray[l]) this._recipeArray[l] = [];
  446.                 this._recipeArray[l].push(type + item.id);
  447.             }
  448.         }
  449.     };
  450.  
  451.     Game_Temp.prototype.recipeArray = function() {
  452.         if (!this._allCheckedRecipes) {
  453.             for (;;) {
  454.                 this.updateMakeRecipeArray();
  455.                 if (this._allCheckedRecipes) break;
  456.             }
  457.         }
  458.         return this._recipeArray;
  459.     };
  460.  
  461.     ////////////////////////////////////////////////////////////////////////////////////
  462.  
  463.     Game_Party.prototype.setExRecipe = function(base, exItem) {
  464.         if (!this._exRecipes) this._exRecipes = {};
  465.         base = DataManager.encodeSynthesisItem(base);
  466.         exItem = DataManager.encodeSynthesisItem(exItem);
  467.         if (!this._exRecipes[base]) this._exRecipes[base] = [];
  468.         if (this._exRecipes[base].indexOf(exItem) < 0) this._exRecipes[base].push(exItem);
  469.         this._exRecipes[base].sort();
  470.     };
  471.  
  472.     Game_Party.prototype.exRecipes = function(base) {
  473.         if (!this._exRecipes) return null;
  474.         base = DataManager.encodeSynthesisItem(base);
  475.         return this._exRecipes[base];
  476.     };
  477.  
  478.     Game_Party.prototype.isLearnedExRecipe = function(base, item) {
  479.         var exRecipes = this.exRecipes(base);
  480.         item = DataManager.encodeSynthesisItem(item);
  481.         return exRecipes && exRecipes.indexOf(item) >= 0;
  482.     };
  483.  
  484.     ////////////////////////////////////////////////////////////////////////////////////
  485.  
  486.     function Window_Recipe() {
  487.         this.initialize.apply(this, arguments);
  488.     }
  489.  
  490.     Window_Recipe.prototype = Object.create(Window_ShopBuy.prototype);
  491.     Window_Recipe.prototype.constructor = Window_Recipe;
  492.  
  493.     Window_Recipe.prototype.initialize = function(x, y, h, recipes, name) {
  494.         this._name = name;
  495.         Window_ShopBuy.prototype.initialize.call(this, x, y, h, recipes);
  496.     };
  497.  
  498.     Window_Recipe.prototype.standardFontSize = function() {
  499.         return 24;
  500.     };
  501.  
  502.     Window_Recipe.prototype.maxPageRows = function() {
  503.         return Window_ShopBuy.prototype.maxPageRows.call(this) - 1;
  504.     };
  505.  
  506.     Window_Recipe.prototype.setCategory = function(category) {
  507.         this._category = category;
  508.         this.refresh();
  509.     };
  510.  
  511.     Window_Recipe.prototype.windowWidth = function() {
  512.         return 456;
  513.     };
  514.  
  515.     Window_Recipe.prototype.itemRect = function(index) {
  516.         var rect = Window_ShopBuy.prototype.itemRect.call(this, index);
  517.         rect.y += 40;
  518.         return rect;
  519.     };
  520.  
  521.     Window_Recipe.prototype.makeItemList = function() {
  522.         this._data = [];
  523.         this._price = [];
  524.         this._shopGoods.forEach(function(g){
  525.             var item = DataManager.decodeSynthesisItem(g[0]);
  526.             if (item && this.includes(item)){
  527.                 this._data.push(item);
  528.                 this._price.push(g[1]);
  529.                 if (!$gameTemp._callShopSynthesis) {
  530.                     var exRecipes = $gameParty.exRecipes(item);
  531.                     if (exRecipes) {
  532.                         for (var i = 0, max = exRecipes.length; i < max; i++) {
  533.                             var er = exRecipes[i];
  534.                             if (this._shopGoods.filter(function(s){ return s[0] === er}).length === 0) {
  535.                                 var ei = DataManager.decodeSynthesisItem(er);
  536.                                 if (this._data.indexOf(ei) < 0) {
  537.                                     this._data.push(ei);
  538.                                     this._price.push(g[1]);
  539.                                 }
  540.                             }
  541.                         }
  542.                     }
  543.                 }
  544.             }
  545.         }.bind(this));
  546.     };
  547.  
  548.     Window_Recipe.prototype.refresh = function() {
  549.         Window_ShopBuy.prototype.refresh.call(this);
  550.         var name = this._name ? this._name : defaultSynthesisName;
  551.         this.contents.fontSize = 20;
  552.         this.drawText(name, 4, 0, this.contentsWidth() - 8);
  553.         this.drawSynthesisHorzLine(28);
  554.     };
  555.  
  556.     Window_Recipe.prototype.drawItem = function(index) {
  557.         var item = this._data[index];
  558.         var rect = this.itemRect(index);
  559.         var priceWidth = 96;
  560.         var recipe = DataManager.itemRecipe(item);
  561.         rect.width -= this.textPadding();
  562.         this.changePaintOpacity(this.isEnabled(item));
  563.         this.drawSynthesisItemName(item, recipe.num, rect.x, rect.y, rect.width - priceWidth);
  564.         if (this.price(item)) {
  565.             this.drawText(this.price(item), rect.x + rect.width - priceWidth,
  566.                 rect.y, priceWidth, 'right');
  567.         }
  568.         this.changePaintOpacity(true);
  569.     };
  570.  
  571.     Window_Recipe.prototype.includes = function(item) {
  572.         if (this._category === '_item') return DataManager.isItem(item) && item.itypeId === 1;
  573.         if (this._category === '_weapon') return DataManager.isWeapon(item);
  574.         if (this._category === '_armor') return DataManager.isArmor(item);
  575.         if (this._category === '_keyItem') return DataManager.isItem(item) && item.itypeId === 2;
  576.         var categories = DataManager.itemSecondaryCategories(item);
  577.         return categories.indexOf(this._category) >= 0;
  578.     };
  579.  
  580.     Window_Recipe.prototype.isEnabled = function(item) {
  581.         var result = (item && this.price(item) <= this._money && !$gameParty.hasMaxItems(item));
  582.         result = result && this.checkEnableRecipe(DataManager.itemRecipe(item));
  583.         return result;
  584.     };
  585.  
  586.     Window_Recipe.prototype.checkEnableRecipe = function(recipe) {
  587.         var ary = recipe.recipe;
  588.         if (!$gameTemp._callShopSynthesis) ary = ary.concat(recipe.machinery);
  589.         for (var i=0,max=ary.length;i<max;i++) {
  590.             var m = ary[i];
  591.             var item = null;
  592.             if (DataManager.isSynthesisItem(m[0])) {
  593.                 item = DataManager.decodeSynthesisItem(m[0]);
  594.                 // --- 修改开始:检测 Yanfly 独立物品数量 ---
  595.                 var hasNum = 0;
  596.                 if (Imported.YEP_ItemCore && DataManager.isIndependent(item)) {
  597.                     hasNum = $gameParty.numIndependentItems(item);
  598.                 } else {
  599.                     hasNum = $gameParty.numItems(item);
  600.                 }
  601.                 if (hasNum < m[1]) return false;
  602.                 // --- 修改结束 ---
  603.             } else {
  604.                 item = m[0];
  605.                 var n = $gameParty.allItems().reduce(function(r,it){
  606.                     if (DataManager.itemSecondaryCategories(it).indexOf(item) >= 0) {
  607.                         r += $gameParty.numItems(it);
  608.                     }
  609.                     return r;
  610.                 }.bind(this),0);
  611.                 if (n < m[1]) return false;
  612.             }
  613.         }
  614.         return true;
  615.     };
  616.  
  617.     Window_Recipe.prototype.currentPrice = function() {
  618.         return this.price(this.item());
  619.     };
  620.  
  621.     Window_Recipe.prototype.baseItem = function() {
  622.         return Window_ShopBuy.prototype.item.call(this);
  623.     };
  624.  
  625.     Window_Recipe.prototype.item = function() {
  626.         var item = this.baseItem();
  627.         if (!item) return item;
  628.         var dummy = DataManager.itemRecipe(item).dummy;
  629.         return dummy ? DataManager.decodeSynthesisItem(dummy) : item;
  630.     };
  631.  
  632.     ////////////////////////////////////////////////////////////////////////////////////
  633.  
  634.     function Window_SynthesisCategory() {
  635.         this.initialize.apply(this, arguments);
  636.     }
  637.  
  638.     Window_SynthesisCategory.prototype = Object.create(Window_HorzCommand.prototype);
  639.     Window_SynthesisCategory.prototype.constructor = Window_SynthesisCategory;
  640.  
  641.     Window_SynthesisCategory.prototype.initialize = function(x, y, w) {
  642.         this._width = w;
  643.         Window_HorzCommand.prototype.initialize.call(this, x, y);
  644.     };
  645.  
  646.     Window_SynthesisCategory.prototype.windowWidth = function() {
  647.         return this._width;
  648.     };
  649.  
  650.     Window_SynthesisCategory.prototype.setCategories = function(categories) {
  651.         this._categories = categories;
  652.         this.refresh();
  653.     };
  654.  
  655.     Window_SynthesisCategory.prototype.setRecipeWindow = function(window) {
  656.         this._recipeWindow = window;
  657.     };
  658.  
  659.     Window_SynthesisCategory.prototype.maxCols = function() {
  660.         if (this._categories && this._categories.length > 0) return this._categories.length;
  661.         return 4;
  662.     };
  663.  
  664.     Window_SynthesisCategory.prototype.category = function() {
  665.         if (!this._categories) this._categories = [];
  666.         if (this._categories.length > 0) {
  667.             return this._categories[this.index()];
  668.         } else {
  669.             return this.currentSymbol();
  670.         }
  671.     };
  672.  
  673.     Window_SynthesisCategory.prototype.makeCommandList = function() {
  674.         if (this._categories) {
  675.             if (this._categories.length > 0) {
  676.                 for (var i=0,max=this._categories.length;i<max;i++) {
  677.                     var name = this._categories[i];
  678.                     this.addCommand(name, name);
  679.                 }
  680.             } else {
  681.                 this.addCommand(TextManager.item,    '_item');
  682.                 this.addCommand(TextManager.weapon,  '_weapon');
  683.                 this.addCommand(TextManager.armor,   '_armor');
  684.                 this.addCommand(TextManager.keyItem, '_keyItem');
  685.             }
  686.         }
  687.     };
  688.  
  689.     Window_SynthesisCategory.prototype.updateHelp = function() {
  690.         Window_HorzCommand.prototype.updateHelp.call(this);
  691.         if (this._recipeWindow) this._recipeWindow.setCategory(this.category());
  692.     };
  693.  
  694.     ////////////////////////////////////////////////////////////////////////////////////
  695.  
  696.     function Window_SynthesisStatus() {
  697.         this.initialize.apply(this, arguments);
  698.     }
  699.  
  700.     Window_SynthesisStatus.prototype = Object.create(Window_ShopStatus.prototype);
  701.     Window_SynthesisStatus.prototype.constructor = Window_SynthesisStatus;
  702.  
  703.     Window_SynthesisStatus.prototype.initialize = function(x, y, width, height, picture) {
  704.         this._picture = picture;
  705.         Window_ShopStatus.prototype.initialize.call(this, x, y, width, height);
  706.         this.createPictureSprite();
  707.     };
  708.  
  709.     Window_SynthesisStatus.prototype.createPictureSprite = function() {
  710.         if (this._picture) {
  711.             if (!this._sprite) {
  712.                 var sprite = new Sprite();
  713.                 sprite.bitmap = ImageManager.loadPicture(this._picture);
  714.                 sprite.anchor.x = 0.5;
  715.                 sprite.anchor.y = 0.5;
  716.                 sprite.x = Math.floor(this.width / 2);
  717.                 sprite.y = Math.floor(this.height / 2);
  718.                 this._sprite = sprite;
  719.                 this._windowSpriteContainer.addChildAt(this._sprite, 1);
  720.             }
  721.         }
  722.     };
  723.  
  724.     Window_SynthesisStatus.prototype.setRecipeWindow = function(window) {
  725.         this._recipeWindow = window;
  726.     };
  727.  
  728.     Window_SynthesisStatus.prototype.standardFontSize = function() {
  729.         return 24;
  730.     };
  731.  
  732.     Window_SynthesisStatus.prototype.clearNumItems = function() {
  733.         this._numItems = {};
  734.     };
  735.  
  736.     Window_SynthesisStatus.prototype.refresh = function() {
  737.         this.contents.clear();
  738.         this.changePaintOpacity(true);
  739.         this.resetFontSettings();
  740.         var x = this.textPadding();
  741.         var y = 0;
  742.         var l = this.lineHeight();
  743.         if (this._sprite) this._sprite.opacity = 255;
  744.         if (this._item) {
  745.             if (this._sprite) this._sprite.opacity = 64;
  746.             this.drawPossession(x, y);
  747.             y += l;
  748.             if (Imported['LimitPossession']) {
  749.                 this.drawWeight(x, y);
  750.                 y += l;
  751.             }
  752.             this.drawSynthesisHorzLine(y-4);
  753.             y += 8;
  754.             var recipe = DataManager.itemRecipe(this._recipeWindow.baseItem());
  755.             this.contents.fontSize = 20;
  756.             l -= 8;
  757.             if (!$gameTemp._callShopSynthesis) {
  758.                 for (var i = 0, max = recipe.machinery.length; i < max; i++) {
  759.                     var item = recipe.machinery[i];
  760.                     if (item && item[0]) {
  761.                         var num = item[1];
  762.                         item = item[0];
  763.                         if (i === 0) {
  764.                             this.changeTextColor(this.systemColor());
  765.                             this.drawText(needMachineryName, 4, y, this.contentsWidth() - 8);
  766.                             y += l;
  767.                             this.drawSynthesisHorzLine(y);
  768.                             y += 4;
  769.                         }
  770.                         this.changePaintOpacity(this.isEnable([item, num]));
  771.                         item = DataManager.decodeSynthesisItem(item);
  772.                         this.drawSynthesisItemName(item, 1, 24, y, this.contentsWidth());
  773.                         y += l;
  774.                     }
  775.                 }
  776.                 if (recipe.machinery.length > 0) y += 8;
  777.             }
  778.             this.changePaintOpacity(true);
  779.             for (var i=0,max=recipe.recipe.length;i<max;i++) {
  780.                 var item = recipe.recipe[i];
  781.                 if (item) {
  782.                     var num = item[1];
  783.                     item = item[0];
  784.                     if (i === 0) {
  785.                         this.changeTextColor(this.systemColor());
  786.                         this.drawText(needMaterialName, 4, y, this.contentsWidth() - 8);
  787.                         y += l;
  788.                         this.drawSynthesisHorzLine(y);
  789.                         y += 4
  790.                     }
  791.                     if (DataManager.isSynthesisItem(item)) {
  792.                         this.changePaintOpacity(this.isEnable([item, num]));
  793.                         this.drawSynthesisItemName(DataManager.decodeSynthesisItem(item), 1, 24, y, this.contentsWidth() - 80);
  794.                     } else {
  795.                         this.changeTextColor(this.normalColor());
  796.                         this.changePaintOpacity(this.isEnable([item, num]));
  797.                         this.drawText('('+item+')', 24, y, this.contentsWidth() - 80);
  798.                     }
  799.                     this.drawItemNumber(item, num, 24, y, this.contentsWidth());
  800.                     y += l;
  801.                 }
  802.             }
  803.         }
  804.     };
  805.  
  806.     Window_SynthesisStatus.prototype.drawPossession = function(x, y) {
  807.         var width = this.contents.width - this.textPadding() - x;
  808.         var possessionWidth = this.textWidth('0000');
  809.         var item = this._item;
  810.         var recipe = DataManager.itemRecipe(item);
  811.         if (recipe.dummy) item = DataManager.decodeSynthesisItem(recipe.dummy);
  812.         this.changeTextColor(this.systemColor());
  813.         this.drawText(TextManager.possession, x, y, width - possessionWidth);
  814.         this.resetTextColor();
  815.         this.drawText($gameParty.numItems(item), x, y, width, 'right');
  816.     };
  817.  
  818.     Window_SynthesisStatus.prototype.drawItemNumber = function(item, num, x, y, width) {
  819.         var n = this.numItems(item);
  820.         this.drawText(n, x, y, width - 68,'right');
  821.         this.drawText('/', x, y, width - 52,'right');
  822.         this.drawText(num, x, y, width - 24,'right');
  823.     };
  824.  
  825.     Window_SynthesisStatus.prototype.numItems = function(item) {
  826.         if (this._numItems && this._numItems[item]) return this._numItems[item];
  827.         if (!this._numItems) this.clearNumItems();
  828.         this._numItems[item] = 0;
  829.         if (DataManager.isSynthesisItem(item)) {
  830.             // --- 修改开始:使用 Yanfly 独立物品统计 ---
  831.             var realItem = DataManager.decodeSynthesisItem(item);
  832.             if (Imported.YEP_ItemCore && DataManager.isIndependent(realItem)) {
  833.                 this._numItems[item] = $gameParty.numIndependentItems(realItem);
  834.             } else {
  835.                 this._numItems[item] = $gameParty.numItems(realItem);
  836.             }
  837.             // --- 修改结束 ---
  838.         } else {
  839.             var n = $gameParty.allItems().reduce(function(r,it){
  840.                 var categories = DataManager.itemSecondaryCategories(it);
  841.                 if (categories.indexOf(item) >= 0 && DataManager.isMaterial(it)) {
  842.                     r += $gameParty.numItems(it);
  843.                 }
  844.                 return r
  845.             }.bind(this),0);
  846.             this._numItems[item] = n;
  847.         }
  848.         return this._numItems[item];
  849.     };
  850.  
  851.     Window_SynthesisStatus.prototype.isEnable = function(item) {
  852.         return this.numItems(item[0]) >= item[1];
  853.     };
  854.  
  855.     ////////////////////////////////////////////////////////////////////////////////////
  856.  
  857.     function Window_MaterialList() {
  858.         this.initialize.apply(this, arguments);
  859.     }
  860.  
  861.     Window_MaterialList.prototype = Object.create(Window_Selectable.prototype);
  862.     Window_MaterialList.prototype.constructor = Window_MaterialList;
  863.  
  864.     Window_MaterialList.prototype.initialize = function(x, y, height) {
  865.         this._synthesisNum = 1;
  866.         Window_Selectable.prototype.initialize.call(this, x, y, this.windowWidth(), height);
  867.     };
  868.  
  869.     Window_MaterialList.prototype.windowWidth = function() {
  870.         return 456;
  871.     };
  872.  
  873.     Window_MaterialList.prototype.standardFontSize = function() {
  874.         return 24;
  875.     };
  876.  
  877.     Window_MaterialList.prototype.maxPageRows = function() {
  878.         return Window_Selectable.prototype.maxPageRows.call(this) - 2;
  879.     };
  880.  
  881.     Window_MaterialList.prototype.maxItems = function() {
  882.         if (this._recipe) {
  883.            return this._needs.length;
  884.         } else {
  885.            return 1;
  886.         }
  887.     };
  888.  
  889.     Window_MaterialList.prototype.itemRect = function(index) {
  890.         var rect = Window_Selectable.prototype.itemRect.call(this, index);
  891.         rect.y += this.lineHeight() + 2;
  892.         return rect;
  893.     };
  894.  
  895.     Window_MaterialList.prototype.isCurrentItemEnabled = function() {
  896.         return !DataManager.isSynthesisItem(this._needs[this.index()]);
  897.     };
  898.  
  899.     Window_MaterialList.prototype.setEstimateWindow = function(window) {
  900.         this._estimateWindow = window;
  901.     };
  902.  
  903.     Window_MaterialList.prototype.setMaterialWindow = function(window) {
  904.         this._materialWindow = window;
  905.     };
  906.  
  907.     Window_MaterialList.prototype.setNumber = function(number) {
  908.         this._synthesisNum = number;
  909.         this.refresh();
  910.     };
  911.  
  912.     Window_MaterialList.prototype.setRecipe = function(item) {
  913.         this._recipe = DataManager.itemRecipe(item);
  914.         this._needs = [];
  915.         this._sets = [];
  916.         var recipe = this._recipe.recipe;
  917.         for (var i=0,max=recipe.length;i<max;i++) {
  918.             var it = recipe[i];
  919.             for (var j=0;j<it[1];j++) this._needs.push(it[0]);
  920.         }
  921.         this._estimateWindow.setNeeds(this._needs);
  922.         this.autoSet();
  923.         this.refresh();
  924.         this._estimateWindow.setItem(item);
  925.     };
  926.  
  927.     Window_MaterialList.prototype.autoSet = function() {
  928.         for (var i=0,max=this._needs.length;i<max;i++) {
  929.             var need = this._needs[i];
  930.             if (DataManager.isSynthesisItem(need)) {
  931.                 this.setMaterial(i, DataManager.decodeSynthesisItem(need));
  932.             } else {
  933.                 var items = $gameParty.allItems().filter(function(it){
  934.                     return DataManager.itemSecondaryCategories(it).indexOf(need);
  935.                 }.bind(this));
  936.                 if (items.length === 1) this.setMaterial(i, items[0]);
  937.             }
  938.         }
  939.         this._estimateWindow.setMaterials(this._sets);
  940.     };
  941.  
  942.     Window_MaterialList.prototype.setCurrentMaterial = function (item) {
  943.         this.setMaterial(this.index(), item);
  944.         this._estimateWindow.setMaterials(this._sets);
  945.     };
  946.  
  947.     Window_MaterialList.prototype.setMaterial = function(index, item) {
  948.         this._sets[index] = item;
  949.     };
  950.  
  951.     Window_MaterialList.prototype.refresh = function() {
  952.         Window_Selectable.prototype.refresh.call(this);
  953.         this.changePaintOpacity(true);
  954.         this.contents.fontSize = 20;
  955.         this.changeTextColor(this.systemColor());
  956.         this.drawText(materialListText, 4, 0, this.contentsWidth()-8);
  957.         this.drawSynthesisHorzLine(28);
  958.         this.resetFontSettings();
  959.     };
  960.  
  961.     Window_MaterialList.prototype.drawItem = function(index) {
  962.         var rect = this.itemRect(index);
  963.         var item = this._sets[index];
  964.         if (item) {
  965.             this.changePaintOpacity(true);
  966.             this.drawSynthesisItemName(item, 1, 8, rect.y, rect.width - 16);
  967.             var num = $gameParty.numItems(item);
  968.             var l = this._sets.filter(function(s){ return s === item}).length;
  969.             this.drawText(Math.floor(num / l), 0, rect.y, rect.width - 8, 'right');
  970.             this.drawText('/', 0, rect.y, rect.width - 36, 'right');
  971.             this.drawText(this._synthesisNum, 0, rect.y, rect.width - 52,'right');
  972.         } else {
  973.             this.changePaintOpacity(false);
  974.             this.drawText('('+this._needs[index]+')',8, rect.y, rect.width - 16, 'center');
  975.         }
  976.     };
  977.  
  978.     Window_MaterialList.prototype.item = function() {
  979.         if (this._sets[this.index()]) return this._sets[this.index()];
  980.         return null;
  981.     };
  982.  
  983.     Window_MaterialList.prototype.updateHelp = function() {
  984.         this._helpWindow.clear();
  985.         if (this.item()) this._helpWindow.setItem(this.item());
  986.         if (this._materialWindow) this._materialWindow.setData(this._needs[this.index()], this._sets);
  987.     };
  988.  
  989.     Window_MaterialList.prototype.isOkSynthesis = function() {
  990.         return this._sets.filter(function(s){ return s }).length === this._needs.length;
  991.     };
  992.  
  993.     Window_MaterialList.prototype.smoothSelect = function() {
  994.         if (this._sets) {
  995.             for (var i=0,max=this._needs.length;i<max;i++) {
  996.                 if (!this._sets[i]) {
  997.                     this.select(i);
  998.                     return;
  999.                 }
  1000.             }
  1001.         }
  1002.         this.select(0);
  1003.     };
  1004.  
  1005.     // rpg_core.js
  1006.     Window_MaterialList.prototype._refreshArrows = function() {
  1007.         Window_Selectable.prototype._refreshArrows.call(this);
  1008.         this._downArrowSprite.y -= 48;
  1009.         this._upArrowSprite.y += 40;
  1010.     };
  1011.  
  1012.     ////////////////////////////////////////////////////////////////////////////////////
  1013.  
  1014.     function Window_Estimate() {
  1015.         this.initialize.apply(this, arguments);
  1016.     }
  1017.  
  1018.     Window_Estimate.prototype = Object.create(Window_Base.prototype);
  1019.     Window_Estimate.prototype.constructor = Window_Estimate;
  1020.  
  1021.     Window_Estimate.prototype.initialize = function(x, y, width) {
  1022.         this._synthesisNum = 1;
  1023.         Window_Base.prototype.initialize.call(this, x, y, width, this.windowHeight());
  1024.     };
  1025.  
  1026.     Window_Estimate.prototype.windowHeight = function() {
  1027.         return 108;
  1028.     };
  1029.  
  1030.     Window_Estimate.prototype.standardFontSize = function() {
  1031.         return 24;
  1032.     };
  1033.  
  1034.     Window_Estimate.prototype.clear = function() {
  1035.         this._item = null;
  1036.         this._num = null;
  1037.         this._exItem = null;
  1038.         this._recipe = null;
  1039.         this._synthesisNum = 1;
  1040.     };
  1041.  
  1042.     Window_Estimate.prototype.setItem = function(item) {
  1043.         this._item = item;
  1044.         this._recipe = DataManager.itemRecipe(this._item);
  1045.         this._num = this._recipe.num;
  1046.         this.refresh();
  1047.     };
  1048.  
  1049.     Window_Estimate.prototype.setNeeds = function(needs) {
  1050.         this._needs = needs;
  1051.     };
  1052.  
  1053.     Window_Estimate.prototype.setNumber = function(number) {
  1054.         this._synthesisNum = number;
  1055.         this.refresh();
  1056.     };
  1057.  
  1058.     Window_Estimate.prototype.refresh = function() {
  1059.         this.contents.clear();
  1060.         this.resetFontSettings();
  1061.         if (this._item) {
  1062.             this.changePaintOpacity(true);
  1063.             this.contents.fontSize = 20;
  1064.             this.changeTextColor(this.systemColor());
  1065.             this.drawText(estimateText, 4, 0, this.contentsWidth());
  1066.             this.drawSynthesisHorzLine(28);
  1067.             this.resetFontSettings();
  1068.             this.changePaintOpacity(this.isSynthesizable());
  1069.             var item = this.item();
  1070.             if (this._exItem && !$gameParty.isLearnedExRecipe(this._item, this._exItem)) {
  1071.                 var text = '';
  1072.                 var chr = '?';
  1073.                 for (var i=0,max=this.item().name.length + 1;i<max;i++) text += chr;
  1074.                 this.drawText(text, 24, 40, this.contentsWidth() - 8);
  1075.             } else {
  1076.                 this.drawSynthesisItemName(item, this.itemNumber(), 24, 40, this.contentsWidth() - 8);
  1077.             }
  1078.         }
  1079.     };
  1080.  
  1081.     Window_Estimate.prototype.isSynthesizable = function() {
  1082.         if (this._sets && this._needs) {
  1083.             var ms = this._sets.filter(function(m){ return m });
  1084.             if (ms.length === this._needs.length) {
  1085.                 return true;
  1086.             }
  1087.         }
  1088.         return false;
  1089.     };
  1090.  
  1091.     Window_Estimate.prototype.setMaterials = function(sets) {
  1092.         this._sets = sets;
  1093.         this.refresh();
  1094.     };
  1095.  
  1096.     Window_Estimate.prototype.item = function() {
  1097.         if (this.isSynthesizable() && !$gameTemp._callShopSynthesis) this.checkItemChange();
  1098.         if (this._exItem) return this._exItem;
  1099.         if (this._recipe.dummy){
  1100.             return DataManager.decodeSynthesisItem(this._recipe.dummy);
  1101.         } else {
  1102.             return this._item;
  1103.         }
  1104.     };
  1105.  
  1106.     Window_Estimate.prototype.updateTone = function() {
  1107.         var tone = this._exItem ? changeRecipeTone : $gameSystem.windowTone();
  1108.         this.setTone(tone[0], tone[1], tone[2]);
  1109.     };
  1110.  
  1111.     Window_Estimate.prototype.itemNumber = function() {
  1112.         return Number(this._num ? this._num : 1) * this._synthesisNum;
  1113.     };
  1114.  
  1115.     Window_Estimate.prototype.checkItemChange = function() {
  1116.         var l = this._needs.length;
  1117.         var r = $gameTemp.recipeArray();
  1118.         var rn = r[l].filter(function(rr){
  1119.             var item = DataManager.decodeSynthesisItem(rr);
  1120.             var recipe = DataManager.itemRecipe(item);
  1121.             var r1 = recipe.recipe.reduce(function(rs,a){
  1122.                 for(var i=0;i<a[1];i++) rs.push(a[0]);
  1123.                 return rs;
  1124.             }.bind(this),[]);
  1125.             return this.checkMachinery(recipe) && this.checkRecipe(r1);
  1126.         }.bind(this));
  1127.         rn = rn.map(function(a){ return DataManager.decodeSynthesisItem(a) });
  1128.         rn.sort(function(a,b){
  1129.             var r1 = DataManager.itemRecipe(a);
  1130.             var r2 = DataManager.itemRecipe(b);
  1131.             return r1.priority - r2.priority;
  1132.         });
  1133.         if (rn[rn.length-1] !== this._item){
  1134.             this._exItem = rn[rn.length-1];
  1135.             this._num = DataManager.itemRecipe(this._exItem).num;
  1136.         } else {
  1137.             this._exItem = null;
  1138.             this._num = this._recipe.num;
  1139.         }
  1140.     };
  1141.  
  1142.     Window_Estimate.prototype.checkMachinery = function(recipe) {
  1143.         var m1 = this._recipe.machinery;
  1144.         var m2 = recipe.machinery;
  1145.         return String(m1.sort()) === String(m2.sort());
  1146.     };
  1147.  
  1148.     Window_Estimate.prototype.checkRecipe = function(ary) {
  1149.         var sets = this._sets.clone();
  1150.         for (var i=0,max=ary.length;i<max;i++) {
  1151.             if (DataManager.isSynthesisItem(ary[i])) {
  1152.                 var index = sets.indexOf(DataManager.decodeSynthesisItem(ary[i]));
  1153.                 if (index < 0) {
  1154.                     return false;
  1155.                 } else {
  1156.                     sets[index] = null;
  1157.                     ary[i] = null;
  1158.                 }
  1159.             } else {
  1160.                 for (var j=0,jmax=sets.length;j<jmax;j++) {
  1161.                     if (sets[j]){
  1162.                         var sc = DataManager.itemSecondaryCategories(sets[j]);
  1163.                         if (sc.indexOf(ary[i]) < 0) {
  1164.                             return false;
  1165.                         } else {
  1166.                             sets[j] = null;
  1167.                             ary[i] = null;
  1168.                             break;
  1169.                         }
  1170.                     }
  1171.                 }
  1172.             }
  1173.         }
  1174.         return true;
  1175.     };
  1176.  
  1177.     ////////////////////////////////////////////////////////////////////////////////////
  1178.  
  1179.     function Window_Material() {
  1180.         this.initialize.apply(this, arguments);
  1181.     }
  1182.  
  1183.     Window_Material.prototype = Object.create(Window_Selectable.prototype);
  1184.     Window_Material.prototype.constructor = Window_Material;
  1185.  
  1186.     Window_Material.prototype.initialize = function(x, y, width, height) {
  1187.         Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  1188.     };
  1189.  
  1190.     Window_Material.prototype.standardFontSize = function() {
  1191.         return 24;
  1192.     };
  1193.  
  1194.     Window_Material.prototype.maxPageRows = function() {
  1195.         return Window_Selectable.prototype.maxPageRows.call(this) - 1;
  1196.     };
  1197.  
  1198.     Window_Material.prototype.maxItems = function() {
  1199.         return this._data ? this._data.length : 1;
  1200.     };
  1201.  
  1202.     Window_Material.prototype.item = function() {
  1203.         return this._data[this.index()];
  1204.     };
  1205.  
  1206.     Window_Material.prototype.isEnabled = function(index) {
  1207.         return this.itemNumber(this._data[index]) > 0;
  1208.     };
  1209.  
  1210.     Window_Material.prototype.isCurrentItemEnabled = function() {
  1211.         return this.isEnabled(this.index());
  1212.     };
  1213.  
  1214.     Window_Material.prototype.setData = function(category, sets) {
  1215.         this._category = category;
  1216.         this._sets = sets;
  1217.         this._price = 0;
  1218.         this._number = 0;
  1219.         this.refresh();
  1220.     };
  1221.  
  1222.     Window_Material.prototype.setPrice = function(price) {
  1223.         this._price = price;
  1224.     };
  1225.  
  1226.     Window_Material.prototype.setNumber = function(number) {
  1227.         this._number = number;
  1228.         this.refresh();
  1229.     };
  1230.  
  1231.     Window_Material.prototype.makeItemList = function() {
  1232.         this._data = [];
  1233.         var items = $gameParty.allItems();
  1234.         for (var i=0,max=items.length;i<max;i++) {
  1235.             var item = items[i];
  1236.             if (this.includes(item)) this._data.push(item);
  1237.         }
  1238.     };
  1239.  
  1240.     Window_Material.prototype.includes = function(item) {
  1241.         if (!this._category) return false;
  1242.         if (!DataManager.isMaterial(item)) return false;
  1243.         if (DataManager.isItem(item) && item.itypeId > 2) return false;
  1244.         if (DataManager.itemSecondaryCategories(item).indexOf(this._category) >= 0) return true;
  1245.         if (DataManager.isSynthesisItem(this._category)) {
  1246.             // --- 修改开始:允许独立物品的基础 ID 匹配 ---
  1247.             var target = DataManager.decodeSynthesisItem(this._category);
  1248.             // 1. 完全匹配(针对普通物品)
  1249.             if (target === item) return true;
  1250.             // 2. 独立物品匹配(针对装备)
  1251.             if (Imported.YEP_ItemCore && DataManager.isIndependent(target) && DataManager.isIndependent(item)) {
  1252.                 // 检查物品是否属于同一类(如同为武器)且 BaseItemID 相同
  1253.                 if (DataManager.isWeapon(target) && DataManager.isWeapon(item) && item.baseItemId === target.id) return true;
  1254.                 if (DataManager.isArmor(target) && DataManager.isArmor(item) && item.baseItemId === target.id) return true;
  1255.             }
  1256.             return false;
  1257.             // --- 修改结束 ---
  1258.         }
  1259.         return false
  1260.     };
  1261.  
  1262.     Window_Material.prototype.itemRect = function(index) {
  1263.         var rect = Window_Selectable.prototype.itemRect.call(this, index);
  1264.         rect.y += this.lineHeight();
  1265.         return rect;
  1266.     };
  1267.  
  1268.     Window_Material.prototype.refresh = function() {
  1269.         this.contents.clear();
  1270.         this.resetFontSettings();
  1271.         if (this._category) {
  1272.             this.makeItemList();
  1273.             this.drawAllItems();
  1274.             this.changePaintOpacity(true);
  1275.             this.contents.fontSize = 20;
  1276.             //this.changeTextColor(this.systemColor());
  1277.             var name = this._category;
  1278.             if (DataManager.isSynthesisItem(name)) name = DataManager.decodeSynthesisItem(name).name;
  1279.             this.drawText(name, 4, 0, this.contentsWidth()-8);
  1280.             this.drawSynthesisHorzLine(28);
  1281.         } else {
  1282.             if (this._price && this._number) {
  1283.                 this.changeTextColor(this.systemColor());
  1284.                 this.drawText(synthesisPriceText, 0, 0, this.contentsWidth());
  1285.                 this.changeTextColor(this.normalColor());
  1286.                 this.drawText(this._price * this._number, 0, 0, this.contentsWidth() - 36, 'right');
  1287.                 this.changeTextColor(this.systemColor());
  1288.                 this.drawText(TextManager.currencyUnit, 0, 0, this.contentsWidth(), 'right');
  1289.             }
  1290.         }
  1291.     };
  1292.  
  1293.     Window_Material.prototype.drawItem = function(index) {
  1294.         var item = this._data[index];
  1295.         var rect = this.itemRect(index);
  1296.         rect.x += 8;
  1297.         rect.width -= 48;
  1298.         this.changePaintOpacity(this.isEnabled(index));
  1299.         this.drawSynthesisItemName(item, 1,rect.x, rect.y, rect.width);
  1300.         this.drawItemNumber(item, rect.x, rect.y, rect.width + 36, 'right');
  1301.     };
  1302.  
  1303.     Window_Material.prototype.drawItemNumber = function(item, x, y, width) {
  1304.         var num = this.itemNumber(item);
  1305.         this.drawText(':', x, y, width - this.textWidth('00'), 'right');
  1306.         this.drawText(num, x, y, width, 'right');
  1307.     };
  1308.  
  1309.     Window_Material.prototype.itemNumber = function(item) {
  1310.         var num = $gameParty.numItems(item);
  1311.         if (this._sets) {
  1312.             for (var i=0,max=this._sets.length;i<max;i++) {
  1313.                 if (this._sets[i] === item) num--;
  1314.             }
  1315.         }
  1316.         return num;
  1317.     };
  1318.  
  1319.     Window_Material.prototype.updateHelp = function() {
  1320.         this.setHelpWindowItem(this.item());
  1321.     };
  1322.  
  1323.     Window_Material.prototype.smoothSelect = function() {
  1324.         for (var i=0,max=this._data.length;i<max;i++) {
  1325.             if (this.isEnabled(i)) {
  1326.                 this.select(i);
  1327.                 return;
  1328.             }
  1329.         }
  1330.         this.select(0);
  1331.     };
  1332.  
  1333.     ////////////////////////////////////////////////////////////////////////////////////
  1334.  
  1335.     function Window_SynthesisResult() {
  1336.         this.initialize.apply(this, arguments);
  1337.     }
  1338.  
  1339.     Window_SynthesisResult.prototype = Object.create(Window_Selectable.prototype);
  1340.     Window_SynthesisResult.prototype.constructor = Window_SynthesisResult;
  1341.  
  1342.     Window_SynthesisResult.prototype.initialize = function() {
  1343.         var w = this.windowWidth();
  1344.         var h = this.windowHeight();
  1345.         var x = Math.floor((Graphics.boxWidth / 2) - (w / 2));
  1346.         var y = Math.floor((Graphics.boxHeight / 2) - (h / 2));
  1347.         Window_Selectable.prototype.initialize.call(this, x, y, w, h);
  1348.     };
  1349.  
  1350.     Window_SynthesisResult.prototype.windowWidth = function() {
  1351.         return 360;
  1352.     };
  1353.  
  1354.     Window_SynthesisResult.prototype.windowHeight = function() {
  1355.         return 112;
  1356.     };
  1357.  
  1358.     Window_SynthesisResult.prototype.updateTone = function() {
  1359.         var tone = this._changed ? changeRecipeTone : $gameSystem.windowTone();
  1360.         this.setTone(tone[0], tone[1], tone[2]);
  1361.     };
  1362.  
  1363.     Window_SynthesisResult.prototype.setItemAndNumber = function(item, num, changed) {
  1364.         this._item = item;
  1365.         this._num = num;
  1366.         this._changed = changed;
  1367.         this.refresh();
  1368.     };
  1369.  
  1370.     Window_SynthesisResult.prototype.maxItems = function() {
  1371.         return 0;
  1372.     };
  1373.  
  1374.     Window_SynthesisResult.prototype.refresh = function () {
  1375.         this.contents.clear();
  1376.         if (this._item) {
  1377.             this.contents.fontSize = 20;
  1378.             this.changeTextColor(this.systemColor());
  1379.             this.drawText(synthesisResultText, 4, 0, this.contentsWidth());
  1380.             this.drawSynthesisHorzLine(28);
  1381.             this.contents.fontSize = 24;
  1382.             this.changeTextColor(this.normalColor);
  1383.             this.drawSynthesisItemName(this._item, this._num,24, 40, this.contentsWidth() - 8);
  1384.         }
  1385.     };
  1386.  
  1387.     Window_SynthesisResult.prototype.onTouch = function(triggered) {
  1388.         var x = this.canvasToLocalX(TouchInput.x);
  1389.         var y = this.canvasToLocalY(TouchInput.y);
  1390.         if (this.isContentsArea(x, y)) this.processOk();
  1391.     };
  1392.  
  1393.     ////////////////////////////////////////////////////////////////////////////////////
  1394.  
  1395.     function Window_Synthesis() {
  1396.         this.initialize.apply(this, arguments);
  1397.     }
  1398.  
  1399.     Window_Synthesis.prototype = Object.create(Window_Selectable.prototype);
  1400.     Window_Synthesis.prototype.constructor = Window_Synthesis;
  1401.  
  1402.     Window_Synthesis.prototype.initialize = function(x, width) {
  1403.         var height = this.windowHeight();
  1404.         var y = Graphics.boxHeight - height;
  1405.         Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  1406.         this.refresh();
  1407.         this.opacity = 0;
  1408.     };
  1409.  
  1410.     Window_Synthesis.prototype.clear = function() {
  1411.         this._num = 0;
  1412.         this._maxSynthesis = 0;
  1413.         this._maxBuy = 99;
  1414.     };
  1415.  
  1416.     Window_Synthesis.prototype.windowHeight = function() {
  1417.         return 72;
  1418.     };
  1419.  
  1420.     Window_Synthesis.prototype.standardFontSize = function() {
  1421.         return 24;
  1422.     };
  1423.  
  1424.     Window_Synthesis.prototype.setListWindow = function(window) {
  1425.         this._listWindow = window;
  1426.         this.clear();
  1427.     };
  1428.  
  1429.     Window_Synthesis.prototype.setEstimateWindow = function(window) {
  1430.         this._estimateWindow = window;
  1431.     };
  1432.  
  1433.     Window_Synthesis.prototype.setMaterialWindow = function(window) {
  1434.         this._materialWindow = window;
  1435.     };
  1436.  
  1437.     Window_Synthesis.prototype.setMaxBuy = function(maxBuy) {
  1438.         this._maxBuy = maxBuy;
  1439.     };
  1440.  
  1441.     Window_Synthesis.prototype.itemRect = function(index) {
  1442.         var rect = Window_Selectable.prototype.itemRect.call(this, index);
  1443.         rect.y += 6;
  1444.         return rect;
  1445.     };
  1446.  
  1447.     Window_Synthesis.prototype.refresh = function() {
  1448.         this.contents.clear();
  1449.         this._maxSynthesis = 0;
  1450.         if (this._listWindow) {
  1451.             this.changePaintOpacity(true);
  1452.             var y = this.contentsHeight() - this.lineHeight();
  1453.             this.drawSynthesisHorzLine(y);
  1454.             this.changePaintOpacity(this._listWindow.isOkSynthesis());
  1455.             if (this.maxSynthesis() > 1) {
  1456.                 var text = numberSynthesisText;
  1457.                 text = text.replace(/_num/,this._num+1);
  1458.                 this.drawText(text, 8, y + 4, this.contentsWidth() - 16, 'center');
  1459.             } else {
  1460.                 this.drawText(synthesisText, 8, y + 4, this.contentsWidth() - 16, 'center');
  1461.             }
  1462.             this.resetFontSettings();
  1463.         }
  1464.     };
  1465.  
  1466.     Window_Synthesis.prototype.maxSynthesis = function() {
  1467.         if (!this._maxSynthesis) {
  1468.             var n = 0;
  1469.             for (var i = 0, max = this._listWindow._sets.length; i < max; i++) {
  1470.                 var item = this._listWindow._sets[i];
  1471.                 var num = $gameParty.numItems(item);
  1472.                 var l = this._listWindow._sets.filter(function (s) { return s === item }).length;
  1473.                 var nn = Math.floor(num / l);
  1474.                 n = (n === 0 || n > nn) ? nn : n;
  1475.             }
  1476.             this._maxSynthesis = Math.min(n, this._maxBuy);
  1477.         }
  1478.         return this._maxSynthesis;
  1479.     };
  1480.  
  1481.     Window_Synthesis.prototype.isCursorMovable = function() {
  1482.         return this.isOpenAndActive();
  1483.     };
  1484.  
  1485.     Window_Synthesis.prototype.processCursorMove = function() {
  1486.         if (this.isCursorMovable()) {
  1487.             if (Input.isTriggered('down')) {
  1488.                 this.cursorDown(Input.isTriggered('down'));
  1489.             }
  1490.             if (Input.isTriggered('up')) {
  1491.                 this.cursorUp(Input.isTriggered('up'));
  1492.             }
  1493.         }
  1494.     };
  1495.  
  1496.     Window_Synthesis.prototype.cursorUp = function(wrap) {
  1497.         if (this.maxSynthesis() > 1) {
  1498.             var num = (this._num + 1) % this.maxSynthesis();
  1499.             this.updateSynthesisNumber(num);
  1500.             SoundManager.playCursor();
  1501.         }
  1502.     };
  1503.  
  1504.     Window_Synthesis.prototype.cursorDown = function(wrap) {
  1505.         if (this.maxSynthesis() > 1) {
  1506.             var num = (this._num + (this.maxSynthesis() - 1)) % this.maxSynthesis();
  1507.             this.updateSynthesisNumber(num);
  1508.             SoundManager.playCursor();
  1509.         }
  1510.     };
  1511.  
  1512.     Window_Synthesis.prototype.onTouch = function(triggered) {
  1513.         var x = this.canvasToLocalX(TouchInput.x);
  1514.         var y = this.canvasToLocalY(TouchInput.y);
  1515.         var hitIndex = this.hitTest(x, y);
  1516.         if (hitIndex >= 0) {
  1517.             if (hitIndex === this.index()) {
  1518.                 if (triggered && this.isTouchOkEnabled()) {
  1519.                     this.processOk();
  1520.                 }
  1521.             }
  1522.         } else if (this._stayCount >= 15) {
  1523.             if (y < this.padding) {
  1524.                 this.cursorUp();
  1525.             } else if (y >= this.height - this.padding) {
  1526.                 this.cursorDown();
  1527.             }
  1528.             this._stayCount = 0;
  1529.         }
  1530.     };
  1531.  
  1532.     Window_Synthesis.prototype.hitTest = function(x, y) {
  1533.         if (this.isContentsArea(x, y)) return 0;
  1534.         return -1;
  1535.     };
  1536.  
  1537.     Window_Synthesis.prototype.updateSynthesisNumber = function(number) {
  1538.         this._num = number;
  1539.         this._listWindow.setNumber(number + 1);
  1540.         this._estimateWindow.setNumber(number + 1);
  1541.         this._materialWindow.setNumber(number + 1);
  1542.         this.refresh();
  1543.  
  1544.     };
  1545.  
  1546.     Window_Synthesis.prototype.processOk = function() {
  1547.         if (this.isCurrentItemEnabled()) {
  1548.             this.playSynthesisSound();
  1549.             this.updateInputData();
  1550.             this.deactivate();
  1551.             this.callOkHandler();
  1552.         } else {
  1553.             this.playBuzzerSound();
  1554.         }
  1555.     };
  1556.  
  1557.     Window_Synthesis.prototype.playSynthesisSound = function() {
  1558.         var settings = synthesisSeSettings;
  1559.         var se = {name:synthesisSeName, volume:settings[0], pitch:settings[1], pan:settings[2] };
  1560.         AudioManager.playSe(se);
  1561.     };
  1562.  
  1563.     ////////////////////////////////////////////////////////////////////////////////////
  1564.  
  1565.     function Scene_CategorySynthesis() {
  1566.         this.initialize.apply(this, arguments);
  1567.     }
  1568.  
  1569.     Scene_CategorySynthesis.prototype = Object.create(Scene_MenuBase.prototype);
  1570.     Scene_CategorySynthesis.prototype.constructor = Scene_CategorySynthesis;
  1571.  
  1572.     Scene_CategorySynthesis.prototype.create = function() {
  1573.         Scene_MenuBase.prototype.create.call(this);
  1574.         this.createHelpWindow();
  1575.         this.createGoldWindow();
  1576.         this.createCategoryWindow();
  1577.         this.createRecipeListWindow();
  1578.         this.createStatusWindow();
  1579.         this.createMaterialListWindow();
  1580.         this.createEstimateWindow();
  1581.         this.createMaterialWindow();
  1582.         this.createSynthesisWindow();
  1583.         this.createResultWindow();
  1584.         this._categoryWindow.setRecipeWindow(this._recipeWindow);
  1585.         this._recipeWindow.setStatusWindow(this._statusWindow);
  1586.         this._listWindow.setEstimateWindow(this._estimateWindow);
  1587.         this._listWindow.setMaterialWindow(this._materialWindow);
  1588.     };
  1589.  
  1590.     Scene_CategorySynthesis.prototype.setParameters = function(args) {
  1591.         var categories = defaultSynthesisCategories;
  1592.         var name = '';
  1593.         var picture = '';
  1594.         for (var i=0,max=args.length;i<max;i++) {
  1595.             var m = args[i].split(':');
  1596.             switch(m[0]) {
  1597.                 case 'カテゴリ':
  1598.                 case 'categories':
  1599.                     categories = m[1].split(',');
  1600.                     break;
  1601.                 case '名前':
  1602.                 case 'name':
  1603.                     name = m[1];
  1604.                     break;
  1605.                 case 'ピクチャ':
  1606.                 case 'picture':
  1607.                     picture = m[1];
  1608.                     break;
  1609.                 default:
  1610.                     categories = m.split(',');
  1611.             }
  1612.         }
  1613.         this._categories = categories;
  1614.         this._name = name;
  1615.         this._picture = picture;
  1616.     };
  1617.  
  1618.     Scene_CategorySynthesis.prototype.prepare = function(args, goods) {
  1619.         this.setParameters(args);
  1620.         this.createRecipe(goods);
  1621.     };
  1622.  
  1623.     Scene_CategorySynthesis.prototype.createRecipe = function(goods) {
  1624.         this._recipes = [];
  1625.         if (goods) {
  1626.             for (var i=0,max=goods.length;i<max;i++) {
  1627.                 var good = goods[i];
  1628.                 var item = null;
  1629.                 if (good[0] === 0){
  1630.                     item = 'I' + good[1];
  1631.                 } else if (good[0] === 1) {
  1632.                     item = 'W' + good[1];
  1633.                 } else if (good[0] === 2){
  1634.                     item = 'A' + good[1];
  1635.                 }
  1636.                 var price = good[2] ? good[3] : DataManager.decodeSynthesisItem(item).price;
  1637.                 this._recipes.push([item,price]);
  1638.             }
  1639.         } else {
  1640.             var allItems = $gameParty.allItems();
  1641.             var ary = [];
  1642.             for (var i = 0, max = allItems.length; i < max; i++) {
  1643.                 var item = allItems[i];
  1644.                 if (DataManager.isRecipeBook(item)) {
  1645.                     var recipe = DataManager.publishedItemRecipes(item);
  1646.                     ary = ary.concat(recipe);
  1647.                 }
  1648.             }
  1649.             for (var i=0,max=ary.length;i<max;i++) this._recipes[i] = [ary[i]];
  1650.         }
  1651.     };
  1652.  
  1653.     Scene_CategorySynthesis.prototype.createGoldWindow = function() {
  1654.         this._goldWindow = new Window_Gold(0, this._helpWindow.height);
  1655.         this._goldWindow.x = Graphics.boxWidth - this._goldWindow.width;
  1656.         this.addWindow(this._goldWindow);
  1657.         if (!$gameTemp._callShopSynthesis) this._goldWindow.hide();
  1658.     };
  1659.  
  1660.     Scene_CategorySynthesis.prototype.createCategoryWindow = function() {
  1661.         var x = 0;
  1662.         var y = this._helpWindow.y + this._helpWindow.height;
  1663.         var w = Graphics.boxWidth - this._goldWindow.width;
  1664.         if (!$gameTemp._callShopSynthesis) w = Graphics.boxWidth;
  1665.         this._categoryWindow = new Window_SynthesisCategory(x, y, w);
  1666.         this._categoryWindow.setHandler('ok', this.onCategoryOk.bind(this));
  1667.         this._categoryWindow.setHandler('cancel', this.popScene.bind(this));
  1668.         this._categoryWindow.setCategories(this._categories);
  1669.         this._categoryWindow.activate();
  1670.         this._categoryWindow.select(0);
  1671.         this._categoryWindow.setHelpWindow(this._helpWindow);
  1672.         this.addWindow(this._categoryWindow);
  1673.     };
  1674.  
  1675.     Scene_CategorySynthesis.prototype.createRecipeListWindow = function() {
  1676.         var x = 0;
  1677.         var y = this._categoryWindow.y + this._categoryWindow.height;
  1678.         var h = Graphics.boxHeight - y;
  1679.         this._recipeWindow = new Window_Recipe(x, y, h, this._recipes, this._name, this._price);
  1680.         this._recipeWindow.setHandler('ok', this.onRecipeOk.bind(this));
  1681.         this._recipeWindow.setHandler('cancel', this.onRecipeCancel.bind(this));
  1682.         this._recipeWindow.setCategory(this._categoryWindow.category());
  1683.         this._recipeWindow.deselect();
  1684.         this._recipeWindow.setHelpWindow(this._helpWindow);
  1685.         this._recipeWindow.setMoney(this.money());
  1686.         this.addWindow(this._recipeWindow);
  1687.     };
  1688.  
  1689.     Scene_CategorySynthesis.prototype.createStatusWindow = function() {
  1690.         var x = this._recipeWindow.x + this._recipeWindow.width;
  1691.         var y = this._recipeWindow.y;
  1692.         var w = Graphics.boxWidth - (this._recipeWindow.x + this._recipeWindow.width);
  1693.         var h = this._recipeWindow.height;
  1694.         this._statusWindow = new Window_SynthesisStatus(x,y,w,h,this._picture);
  1695.         this._statusWindow.setRecipeWindow(this._recipeWindow);
  1696.         this._windowLayer.addChildAt(this._statusWindow, 0);
  1697.     };
  1698.  
  1699.     Scene_CategorySynthesis.prototype.createMaterialListWindow = function() {
  1700.         var x = 0;
  1701.         var y = this._categoryWindow.y + this._categoryWindow.height;
  1702.         var height = Graphics.boxHeight - y;
  1703.         this._listWindow = new Window_MaterialList(x, y, height);
  1704.         this._listWindow.setHandler('ok', this.onListOk.bind(this));
  1705.         this._listWindow.setHandler('cancel', this.onListCancel.bind(this));
  1706.         this._listWindow.setHelpWindow(this._helpWindow);
  1707.         this.addWindow(this._listWindow);
  1708.         this._listWindow.hide();
  1709.     };
  1710.  
  1711.     Scene_CategorySynthesis.prototype.createEstimateWindow = function() {
  1712.         var x = this._listWindow.x + this._listWindow.width;
  1713.         var y = this._listWindow.y;
  1714.         var width = Graphics.boxWidth - (this._listWindow.x + this._listWindow.width);
  1715.         this._estimateWindow = new Window_Estimate(x, y, width);
  1716.         this.addWindow(this._estimateWindow);
  1717.         this._estimateWindow.hide();
  1718.     };
  1719.  
  1720.     Scene_CategorySynthesis.prototype.createMaterialWindow = function() {
  1721.         var x = this._estimateWindow.x;
  1722.         var y = this._estimateWindow.y + this._estimateWindow.height;
  1723.         var width = this._estimateWindow.width;
  1724.         var height = Graphics.boxHeight - (this._estimateWindow.y + this._estimateWindow.height);
  1725.         this._materialWindow = new Window_Material(x, y, width ,height);
  1726.         this._materialWindow.setHandler('ok', this.onMaterialOk.bind(this));
  1727.         this._materialWindow.setHandler('cancel', this.onMaterialCancel.bind(this));
  1728.         this._materialWindow.setHelpWindow(this._helpWindow);
  1729.         this.addWindow(this._materialWindow);
  1730.         this._materialWindow.hide();
  1731.     };
  1732.  
  1733.     Scene_CategorySynthesis.prototype.createSynthesisWindow = function() {
  1734.         var x = 0;
  1735.         var width = this._listWindow.width;
  1736.         this._synthesisWindow = new Window_Synthesis(x, width);
  1737.         this._synthesisWindow.setHandler('ok', this.onSynthesisOk.bind(this));
  1738.         this._synthesisWindow.setHandler('cancel', this.onSynthesisCancel.bind(this));
  1739.         this._synthesisWindow.setListWindow(this._listWindow);
  1740.         this._synthesisWindow.setEstimateWindow(this._estimateWindow);
  1741.         this._synthesisWindow.setMaterialWindow(this._materialWindow);
  1742.         this._synthesisWindow.setHelpWindow(this._helpWindow);
  1743.         this.addChild(this._synthesisWindow);
  1744.         this._synthesisWindow.hide();
  1745.     };
  1746.  
  1747.     Scene_CategorySynthesis.prototype.createResultWindow = function() {
  1748.         this._resultWindow = new Window_SynthesisResult();
  1749.         this._resultWindow.setHandler('ok', this.onResultOk.bind(this));
  1750.         this._resultWindow.setHandler('cancel', this.onResultOk.bind(this));
  1751.         this.addChild(this._resultWindow);
  1752.         this._resultWindow.hide();
  1753.     };
  1754.  
  1755.     Scene_CategorySynthesis.prototype.popScene = function() {
  1756.         Scene_MenuBase.prototype.popScene.call(this);
  1757.         $gameTemp._callShopSynthesis = false;
  1758.         $gameTemp._categoryShopSetting = null;
  1759.     };
  1760.  
  1761.     Scene_CategorySynthesis.prototype.money = function() {
  1762.         return this._goldWindow.value();
  1763.     };
  1764.  
  1765.     Scene_CategorySynthesis.prototype.onCategoryOk = function() {
  1766.         this._categoryWindow.deactivate();
  1767.         this._recipeWindow.activate();
  1768.         this._recipeWindow.select(0);
  1769.         this._recipeWindow.setMoney(this.money());
  1770.     };
  1771.  
  1772.     Scene_CategorySynthesis.prototype.onRecipeOk = function() {
  1773.         this._recipeWindow.deactivate();
  1774.         this._recipeWindow.hide();
  1775.         this._statusWindow.hide();
  1776.         this._listWindow.setRecipe(this._recipeWindow.baseItem());
  1777.         this._listWindow.show();
  1778.         this._listWindow.activate();
  1779.         this._estimateWindow.show();
  1780.         this._materialWindow.show();
  1781.         this._synthesisWindow.show();
  1782.         this._synthesisWindow.refresh();
  1783.         this._synthesisWindow.setMaxBuy(this.maxBuy());
  1784.         if (this._listWindow.isOkSynthesis()) {
  1785.             this.activateSynthesis();
  1786.         } else {
  1787.             this._listWindow.smoothSelect();
  1788.         }
  1789.     };
  1790.  
  1791.     Scene_CategorySynthesis.prototype.onRecipeCancel = function() {
  1792.         this._recipeWindow.deactivate();
  1793.         this._recipeWindow.deselect();
  1794.         this._statusWindow._item = null;
  1795.         this._statusWindow.refresh();
  1796.         this._categoryWindow.activate();
  1797.         this._helpWindow.clear();
  1798.     };
  1799.  
  1800.     Scene_CategorySynthesis.prototype.onListOk = function() {
  1801.         this._listWindow.deactivate();
  1802.         this._materialWindow.activate();
  1803.         this._materialWindow.smoothSelect();
  1804.     };
  1805.  
  1806.     Scene_CategorySynthesis.prototype.onListCancel = function() {
  1807.         this._listWindow.deactivate();
  1808.         this._listWindow.deselect();
  1809.         this._recipeWindow.activate();
  1810.         this._recipeWindow.show();
  1811.         this._statusWindow.show();
  1812.         this._estimateWindow.hide();
  1813.         this._materialWindow.hide();
  1814.         this._listWindow.hide();
  1815.         this._estimateWindow.clear();
  1816.         this._synthesisWindow.hide();
  1817.     };
  1818.  
  1819.     Scene_CategorySynthesis.prototype.onMaterialOk = function() {
  1820.         this._listWindow.setCurrentMaterial(this._materialWindow.item());
  1821.         this._listWindow.refresh();
  1822.         this._listWindow.activate();
  1823.         this._listWindow.smoothSelect();
  1824.         this._materialWindow.deselect();
  1825.         this._materialWindow.deactivate();
  1826.         if (this._listWindow.isOkSynthesis()) this.activateSynthesis();
  1827.     };
  1828.  
  1829.     Scene_CategorySynthesis.prototype.onMaterialCancel = function() {
  1830.         this._materialWindow.deselect();
  1831.         this._materialWindow.deactivate();
  1832.         this._listWindow.activate();
  1833.     };
  1834.  
  1835.     Scene_CategorySynthesis.prototype.onSynthesisOk = function() {
  1836.         var item = this._estimateWindow.item();
  1837.         var num = this._estimateWindow.itemNumber();
  1838.         var changed = !!this._estimateWindow._exItem;
  1839.         this._resultWindow.setItemAndNumber(item, num, changed);
  1840.         this.doSynthesis();
  1841.         this._resultWindow.show();
  1842.         this._resultWindow.activate();
  1843.         this._synthesisWindow.deactivate();
  1844.         this._synthesisWindow.deselect();
  1845.     };
  1846.  
  1847.     Scene_CategorySynthesis.prototype.onSynthesisCancel = function() {
  1848.         this._listWindow.activate();
  1849.         this._listWindow.select(0);
  1850.         this._synthesisWindow.deactivate();
  1851.         this._synthesisWindow.deselect();
  1852.         this._synthesisWindow.updateSynthesisNumber(0);
  1853.     };
  1854.  
  1855.     Scene_CategorySynthesis.prototype.onResultOk = function() {
  1856.         this._estimateWindow.clear();
  1857.         this._listWindow.setNumber(1);
  1858.         this._synthesisWindow.clear();
  1859.         this._resultWindow.hide();
  1860.         this._resultWindow.deactivate();
  1861.         this._listWindow.hide();
  1862.         this._estimateWindow.hide();
  1863.         this._materialWindow.hide();
  1864.         this._recipeWindow.show();
  1865.         this._recipeWindow.refresh();
  1866.         this._recipeWindow.activate();
  1867.         this._statusWindow.show();
  1868.         this._statusWindow.refresh();
  1869.         this._synthesisWindow.hide();
  1870.     };
  1871.  
  1872.     Scene_CategorySynthesis.prototype.activateSynthesis = function() {
  1873.         this._synthesisWindow.refresh();
  1874.         this._synthesisWindow.activate();
  1875.         this._synthesisWindow.select(0);
  1876.         this._listWindow.deactivate();
  1877.         this._listWindow.deselect();
  1878.         this._materialWindow._category = null;
  1879.         this._materialWindow.setPrice(this._recipeWindow.currentPrice());
  1880.         this._materialWindow.setNumber(1);
  1881.         this._materialWindow.refresh();
  1882.         //this._helpWindow.clear();
  1883.         if (synthesisHelp && this._synthesisWindow.maxSynthesis() > 1){
  1884.             this._synthesisWindow._helpWindow.setText(synthesisHelp);
  1885.         }
  1886.     };
  1887.  
  1888.     Scene_CategorySynthesis.prototype.doSynthesis = function() {
  1889.         var num = this._estimateWindow._synthesisNum;
  1890.         for (var i=0,max=this._listWindow._sets.length;i<max;i++) {
  1891.             var item = this._listWindow._sets[i];
  1892.             $gameParty.loseItem(item, num);
  1893.         }
  1894.         $gameParty.gainItem(this._estimateWindow.item(), this._estimateWindow.itemNumber());
  1895.         if (this._recipeWindow.currentPrice()) $gameParty.loseGold(this._recipeWindow.currentPrice() * num);
  1896.         this._goldWindow.refresh();
  1897.         this._recipeWindow.setMoney(this.money());
  1898.         this._statusWindow._numItems = null;
  1899.         if (this._estimateWindow._exItem) {
  1900.             var item = this._recipeWindow.item();
  1901.             $gameParty.setExRecipe(item, this._estimateWindow._exItem);
  1902.         }
  1903.     };
  1904.  
  1905.     Scene_CategorySynthesis.prototype.maxBuy = function() {
  1906.         var max = $gameParty.maxItems(this._item) - $gameParty.numItems(this._item);
  1907.         var price = this._recipeWindow.currentPrice();
  1908.         if (price > 0) {
  1909.             return Math.min(max, Math.floor(this.money() / price));
  1910.         } else {
  1911.             return max;
  1912.         }
  1913.     };
  1914.  
  1915.     ////////////////////////////////////////////////////////////////////////////////////
  1916. }());
30岁了,也要继续创造梦想啊。
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2026-6-4 18:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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