// // カテゴリ合成 ver1.02 // // ------------------------------------------------------ // Copyright (c) 2016 Yana // Released under the MIT license // http://opensource.org/licenses/mit-license.php // ------------------------------------------------------ // // author Yana // var Imported = Imported || {}; Imported['CategorySythesis'] = 1.02; /*: * @plugindesc ver1.02/アイテムを合成する機能を追加します。【SecondaryCategories必須】 * @author Yana * * @param DefaultSynthesisName * @desc 合成シーンの名前として表示する名称のデフォルト値です。 * @default 合成 * * @param DefaultSynthesisCategories * @desc 合成で投入できるカテゴリの初期設定です。 * @default アイテム,武器,防具,大事なもの * * @param NeedMachineryName * @desc 必要器材の名称です。 * @default 必要器材 * * @param NeedMaterialName * @desc 必要素材の名称です。 * @default 必要素材 * * @param MaterialListText * @desc 素材リストの上に表示するウィンドウの名前です。 * @default マテリアルリスト * * @param SynthesisText * @desc 「合成する」として表示するテキストです。 * @default 合成する * * @param NumberSynthesisText * @desc 「○個合成する」として表示するテキストです。 * @default _num個合成する * * @param SynthesisHelp * @desc 「○個合成する」にカーソルがあっているときにヘルプに表示されるテキストです。 * @default 上下キーで製作個数を選択します。 * * @param EstimateText * @desc 結果予測ウィンドウに表示するテキストです。 * @default 結果予測 * * @param SynthesisPriceText * @desc 合成ショップ時に合成するにカーソルがあっているとき、表示される合成代金のテキストです。 * @default 合成代金 * * @param ChangeRecipeTone * @desc レシピが変化した際の予測ウィンドウと結果ウィンドウのウィンドウトーンです。 * @default 206,68,24,0 * * @param SynthesisResultText * @desc 合成結果ウィンドウに表示するテキストです。 * @default 合成結果 * * @param SynthesisSeName * @desc 合成時に鳴らすSE名です。 * @default Item1 * @require 1 * @dir audio/se/ * @type file * * @param SynthesisSeSettings * @desc 合成時に鳴らすSEの設定です。 * @default 90,100,0 * * @param MenuSynthesisCommandName * @desc メニューに表示する合成のコマンド名です。 * 空欄にするとメニューに合成を追加しません。 * @default 合成 * * @help------------------------------------------------------ * プラグインコマンド * ------------------------------------------------------ * ***合成シーンを直接呼び出す*** * カテゴリ合成呼び出し * CallCategorySynthesis * * 追加設定として、名前、ピクチャ、カテゴリの設定が可能です。 * 名前の設定をすると、レシピリストに表示されます。 * ピクチャの設定をすると、レシピステータスに指定した画像が表示されます。 * カテゴリの設定をすると、その合成で合成できるカテゴリを設定できます。 * カテゴリを未設定にすると、通常通り、「アイテム、武器、防具、大事なもの」が設定されます。 * * 例:名前を合成屋、ピクチャをtest1、カテゴリを回復薬,インゴットに設定する。 * カテゴリ合成呼び出し 名前:合成屋 ピクチャ:test1 カテゴリ:回復薬,インゴット * * ***ショップを経由して合成シーンを呼び出す*** * 合成ショップ設定 * SettingSynthesisShop * * 合成ショップの設定も上記の呼び出しと同じように設定が可能です。 * この設定を呼び出した後イベントコマンドでショップを呼び出すことにより、 * 合成ショップを呼び出すことができます。 * * ショップ経由で合成を呼び出した場合、合成可能なレシピは所持しているレシピブックを無視し、 * イベントコマンドで設定したラインナップを合成できます。 * また、ショップ経由の場合は合成に合成料が必要となり、器具の設定が無視されます。 * * ------------------------------------------------------ * 使い方 * ------------------------------------------------------ * ***レシピの設定*** * 合成の為のレシピはアイテムのメモを使って設定します。 * * ―――材料の設定――― * <合成材料:○:x,○:x…> * * * そのアイテムのレシピを○:x,○:x…に設定します。 * ○にはアイテムまたはカテゴリの指定、xには個数を設定します。 * アイテムの指定は、I◇,W◇,A◇のように行います。 * I◇の場合は、ID◇番のアイテム、W◇の場合は◇番の武器、A◇の場合は◇番の防具になります。 * カテゴリを指定する場合は、カテゴリ名で直接指定してください。 * 必要な材料が1つの場合は:xを省略することができます。 * * 例:5番のアイテム2個、1番の武器1つ、7番の防具1つを材料に指定する * <合成材料:I5:2,W1,A7> * * ―――器材の設定――― * <必要器材:○,○…> * * * そのアイテムの必要器材を○,○…に設定します。 * ○にはアイテムを指定します。アイテムの設定方法は上記のレシピと同じです。 * 器材はカテゴリと数量の指定ができません。 * この器材は合成シーンをプラグインコマンドで呼び出した時のみ必要になります。 * ショップシーンを経由した場合は、この設定は無視されます。 * * 例:6番のアイテムと8番の武器を必要器材に指定する * <必要器材:I6,W8> * * ―――合成数の設定――― * <合成数:x> * * * そのアイテムの制作数をx個に指定します。 * * ―――合成料の設定――― * <合成料:x> * * * そのアイテムの合成料をxに設定します。 * 合成料はショップを経由して呼び出された場合のみ使用されます。 * 設定がない場合は、アイテムの価格が合成料として設定されます。 * * ―――ダミーレシピの設定――― * <ダミーレシピ:○> * * * ダミーレシピとは1つのアイテムのレシピを複数設定するための仕組みです。 * ダミーレシピの設定されたアイテムを合成すると、 * 生成されるアイテムがダミーレシピで設定したアイテムに置き換わります。 * ○にはレシピと同じようにI◇,W◇,A◇でアイテムを設定します。 * * ―――合成優先度の設定――― * <合成優先度:x> * * * 合成優先度はレシピ変化が起きた際に変化先のアイテムを指定するための仕組みです。 * レシピを満たした時、優先度が最も高いものに変化します。 * 優先度が同じ場合、IDの高いものが優先されます。 * * ***レシピブックの設定*** * レシピブックもアイテムのメモを使って設定します。 * * <掲載レシピ:○,○,○…> * * * そのアイテムの掲載レシピを○,○,○…に設定します。 * ○にはレシピと同じようにI◇,W◇,A◇でアイテムを設定します。 * 例:5番のアイテム、2番の武器、6番の防具 * <掲載レシピ:I5,W2,A6> * * ------------------------------------------------------ * 利用規約 * ------------------------------------------------------ * 当プラグインはMITライセンスで公開されています。 * 使用に制限はありません。商用、アダルト、いずれにも使用できます。 * 二次配布も制限はしませんが、サポートは行いません。 * 著作表示は任意です。行わなくても利用できます。 * 要するに、特に規約はありません。 * バグ報告や使用方法等のお問合せはネ実ツクールスレ、または、Twitterにお願いします。 * https://twitter.com/yanatsuki_ * 素材利用は自己責任でお願いします。 * ------------------------------------------------------ * 更新履歴: * ver1.02:190212 * 合成結果で変化したアイテムの最大合成数が正常に処理されていなかったバグを修正。 * アイテム重量制と併用時、所持重量がオーバーしているときは合成できないように変更。 * ver1.01:180214 * 所持限界以上に合成できていたバグを修正。 * ver1.00: * 公開 */ (function() { 'use strict'; //////////////////////////////////////////////////////////////////////////////////// var parameters = PluginManager.parameters('CategorySynthesis'); var defaultSynthesisName = parameters['DefaultSynthesisName']; var defaultSynthesisCategories = parameters['DefaultSynthesisCategories'].split(','); var needMachineryName = parameters['NeedMachineryName']; var needMaterialName = parameters['NeedMaterialName']; var materialListText = parameters['MaterialListText']; var synthesisText = parameters['SynthesisText']; var numberSynthesisText = parameters['NumberSynthesisText']; var synthesisHelp = parameters['SynthesisHelp']; var estimateText = parameters['EstimateText']; var synthesisPriceText = parameters['SynthesisPriceText']; var changeRecipeTone = parameters['ChangeRecipeTone'].split(',').map(function(s){ return Number(s)}); var synthesisResultText = parameters['SynthesisResultText']; var synthesisSeName = parameters['SynthesisSeName']; var synthesisSeSettings = parameters['SynthesisSeSettings'].split(',').map(function(s){ return Number(s)}); var menuSynthesisCommandName = parameters['MenuSynthesisCommandName']; //////////////////////////////////////////////////////////////////////////////////// var __WMCommand_addOriginalCommands = Window_MenuCommand.prototype.addOriginalCommands; Window_MenuCommand.prototype.addOriginalCommands = function() { __WMCommand_addOriginalCommands.call(this); if (menuSynthesisCommandName){ this.addCommand(menuSynthesisCommandName, 'categorySynthesis', true); } }; var __SMenu_createCommandWindow = Scene_Menu.prototype.createCommandWindow; Scene_Menu.prototype.createCommandWindow = function() { __SMenu_createCommandWindow.call(this); this._commandWindow.setHandler('categorySynthesis', this.commandCategorySynthesis.bind(this)); }; Scene_Menu.prototype.commandCategorySynthesis = function() { $gameTemp._callShopSynthesis = false; SceneManager.push(Scene_CategorySynthesis); SceneManager.prepareNextScene(''); }; //////////////////////////////////////////////////////////////////////////////////// DataManager.isRecipeBook = function(item) { return item && (item.meta['掲載レシピ'] || item.meta['PublishedRecipe']); }; DataManager.publishedItemRecipes = function(item) { var recipes = item.meta['掲載レシピ'] || item.meta['PublishedRecipe']; return recipes.split(','); }; DataManager.hasRecipe = function(item) { var recipe = this.itemRecipe(item); if (recipe.recipe) return true; return false; }; DataManager.itemRecipe = function(item) { if (item._recipe) return item._recipe; var recipe = item.meta['合成材料'] || item.meta['SyntheticMaterials'] || ''; var machinery = item.meta['必要器材'] || item.meta['Machinery'] || ''; var num = item.meta['合成数'] || item.meta['SyntheticNumber'] || 1; var value = item.meta['合成料'] || item.meta['SyntheticPrice'] || item.price; var dummy = item.meta['ダミーレシピ'] || item.meta['DummyRecipe'] || ''; var priority = Number(item.meta['合成優先度'] || item.meta['SyntheticPriority']) || 0; var mats = recipe.split(',').filter(function(m){ return m; }).map(function(m){ var n = 1; if (m.match(/:(\d+)/)) n = Number(RegExp.$1); m = m.replace(/:\d+/,''); return [m,n]; }); var mache = machinery.split(',').filter(function(m){ return m; }).map(function(m){ var n = 1; if (m.match(/:(\d+)/)) n = Number(RegExp.$1); m = m.replace(/:\d+/,''); return [m,n]; }); item._recipe = {num:num, value:value, recipe:mats, machinery:mache, dummy:dummy, priority:priority}; return item._recipe; }; DataManager.encodeSynthesisItem = function(obj) { if (!obj) return null; if (this.isItem(obj)) return 'I' + obj.id; if (this.isWeapon(obj)) return 'W' + obj.id; if (this.isArmor(obj)) return 'A' + obj.id; return null; }; DataManager.decodeSynthesisItem = function(obj) { if (!obj) return null; var type = obj[0].toUpperCase(); var item = null; var id = Number(obj.replace(/[IWA]/,'')); if (id) { switch (type) { case 'I': item = $dataItems[id]; break; case 'W': item = $dataWeapons[id]; break; case 'A': item = $dataArmors[id]; break; } } return item; }; DataManager.isSynthesisItem = function(item) { return /^[IWA]\d+/i.test(item); }; DataManager.isMaterial = function(item) { return item && !(item.meta['材料指定不可'] || item.meta['NotMaterial']); }; //////////////////////////////////////////////////////////////////////////////////// var __GInterpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand; Game_Interpreter.prototype.pluginCommand = function(command, args) { if (command === 'カテゴリ合成呼び出し' || command === 'CallCategorySynthesis') { this.callCategorySynthesis(args); } else if (command === '合成ショップ設定' || command === 'SettingSynthesisShop') { this.callSynthesisShop(args); } else { __GInterpreter_pluginCommand.call(this, command, args); } }; Game_Interpreter.prototype.callCategorySynthesis = function(args) { $gameTemp._callShopSynthesis = false; SceneManager.push(Scene_CategorySynthesis); SceneManager.prepareNextScene(args); }; Game_Interpreter.prototype.callSynthesisShop = function(args) { $gameTemp._categoryShopSetting = args; }; // Shop Processing var __GInterpreter_command302 = Game_Interpreter.prototype.command302; Game_Interpreter.prototype.command302 = function() { if (!$gameParty.inBattle()) { if ($gameTemp._categoryShopSetting) { var goods = [this._params]; while (this.nextEventCode() === 605) { this._index++; goods.push(this.currentCommand().parameters); } $gameTemp._callShopSynthesis = true; SceneManager.push(Scene_CategorySynthesis); SceneManager.prepareNextScene($gameTemp._categoryShopSetting, goods); } else { __GInterpreter_command302.call(this); } } return true; }; //////////////////////////////////////////////////////////////////////////////////// Window_Base.prototype.drawSynthesisStretchIcon = function(iconIndex, x, y) { var bitmap = ImageManager.loadSystem('IconSet'); var pw = Window_Base._iconWidth; var ph = Window_Base._iconHeight; var sx = iconIndex % 16 * pw; var sy = Math.floor(iconIndex / 16) * ph; var n = this.contents.fontSize + 4; this.contents.blt(bitmap, sx, sy, pw, ph, x, y, n, n); }; Window_Base.prototype.drawSynthesisItemName = function(item, num, x, y, width) { width = width || 312; if (item) { var iconBoxWidth = this.contents.fontSize + 8; this.resetTextColor(); this.drawSynthesisStretchIcon(item.iconIndex, x + 2, y + 4); var text = item.name; if (num > 1) text += 'x' + num; this.drawText(text, x + iconBoxWidth, y, width - iconBoxWidth); } }; Window_Base.prototype.drawSynthesisHorzLine = function(y) { this.contents.fillRect(4, y, this.contentsWidth() - 8, 2, 'rgba(255,255,255,0.5)'); }; //////////////////////////////////////////////////////////////////////////////////// //並列処理でレシピの配列を作成 var __SBase_update = Scene_Base.prototype.update; Scene_Base.prototype.update = function() { __SBase_update.call(this); if ($gameTemp && !$gameTemp._allCheckedRecipes){ $gameTemp.updateMakeRecipeArray(); } }; //////////////////////////////////////////////////////////////////////////////////// Game_Temp.prototype.updateMakeRecipeArray = function() { if (!this._recipeArray){ this._recipeArray = []; this._allCheckedRecipes = false; this._recipeCheckIndex = 0; } for (var i=0;i<10;i++) { var item = null; if (this._recipeCheckIndex < 10000) { item = $dataItems[this._recipeCheckIndex]; if (item) this.setRecipeArray('I', item); } else if (this._recipeCheckIndex < 20000){ item = $dataWeapons[this._recipeCheckIndex - 10000]; if (item) this.setRecipeArray('W', item); } else { item = $dataArmors[this._recipeCheckIndex - 20000]; if (item) this.setRecipeArray('A', item); } this._recipeCheckIndex++; if (this._recipeCheckIndex === $dataItems.length) { this._recipeCheckIndex = 10000; } else if (this._recipeCheckIndex === $dataWeapons.length + 10000) { this._recipeCheckIndex = 20000; } else if (this._recipeCheckIndex === $dataArmors.length + 20000) { this._allCheckedRecipes = true; } } }; Game_Temp.prototype.setRecipeArray = function(type, item) { if (DataManager.hasRecipe(item)) { var recipe = DataManager.itemRecipe(item); var l = 0; for (var i=0,max=recipe.recipe.length;i 0) { if (!this._recipeArray[l]) this._recipeArray[l] = []; this._recipeArray[l].push(type + item.id); } } }; Game_Temp.prototype.recipeArray = function() { if (!this._allCheckedRecipes) { for (;;) { this.updateMakeRecipeArray(); if (this._allCheckedRecipes) break; } } return this._recipeArray; }; //////////////////////////////////////////////////////////////////////////////////// Game_Party.prototype.setExRecipe = function(base, exItem) { if (!this._exRecipes) this._exRecipes = {}; base = DataManager.encodeSynthesisItem(base); exItem = DataManager.encodeSynthesisItem(exItem); if (!this._exRecipes[base]) this._exRecipes[base] = []; if (this._exRecipes[base].indexOf(exItem) < 0) this._exRecipes[base].push(exItem); this._exRecipes[base].sort(); }; Game_Party.prototype.exRecipes = function(base) { if (!this._exRecipes) return null; base = DataManager.encodeSynthesisItem(base); return this._exRecipes[base]; }; Game_Party.prototype.isLearnedExRecipe = function(base, item) { var exRecipes = this.exRecipes(base); item = DataManager.encodeSynthesisItem(item); return exRecipes && exRecipes.indexOf(item) >= 0; }; //////////////////////////////////////////////////////////////////////////////////// function Window_Recipe() { this.initialize.apply(this, arguments); } Window_Recipe.prototype = Object.create(Window_ShopBuy.prototype); Window_Recipe.prototype.constructor = Window_Recipe; Window_Recipe.prototype.initialize = function(x, y, h, recipes, name) { this._name = name; if (Imported['LimitPossession']) this._allWeight = $gameParty.allItemsWeight(); Window_ShopBuy.prototype.initialize.call(this, x, y, h, recipes); }; Window_Recipe.prototype.standardFontSize = function() { return 24; }; Window_Recipe.prototype.maxPageRows = function() { return Window_ShopBuy.prototype.maxPageRows.call(this) - 1; }; Window_Recipe.prototype.setCategory = function(category) { this._category = category; this.refresh(); }; Window_Recipe.prototype.windowWidth = function() { return 456; }; Window_Recipe.prototype.itemRect = function(index) { var rect = Window_ShopBuy.prototype.itemRect.call(this, index); rect.y += 40; return rect; }; Window_Recipe.prototype.makeItemList = function() { this._data = []; this._price = []; this._shopGoods.forEach(function(g){ var item = DataManager.decodeSynthesisItem(g[0]); if (item && this.includes(item)){ this._data.push(item); this._price.push(g[1]); if (!$gameTemp._callShopSynthesis) { var exRecipes = $gameParty.exRecipes(item); if (exRecipes) { for (var i = 0, max = exRecipes.length; i < max; i++) { var er = exRecipes[i]; if (this._shopGoods.filter(function(s){ return s[0] === er}).length === 0) { var ei = DataManager.decodeSynthesisItem(er); if (this._data.indexOf(ei) < 0) { this._data.push(ei); this._price.push(g[1]); } } } } } } }.bind(this)); }; Window_Recipe.prototype.refresh = function() { Window_ShopBuy.prototype.refresh.call(this); var name = this._name ? this._name : defaultSynthesisName; this.contents.fontSize = 20; this.drawText(name, 4, 0, this.contentsWidth() - 8); this.drawSynthesisHorzLine(28); }; Window_Recipe.prototype.drawItem = function(index) { var item = this._data[index]; var rect = this.itemRect(index); var priceWidth = 96; var recipe = DataManager.itemRecipe(item); rect.width -= this.textPadding(); this.changePaintOpacity(this.isEnabled(item)); this.drawSynthesisItemName(item, recipe.num, rect.x, rect.y, rect.width - priceWidth); if (this.price(item)) { this.drawText(this.price(item), rect.x + rect.width - priceWidth, rect.y, priceWidth, 'right'); } this.changePaintOpacity(true); }; Window_Recipe.prototype.includes = function(item) { if (this._category === '_item') return DataManager.isItem(item) && item.itypeId === 1; if (this._category === '_weapon') return DataManager.isWeapon(item); if (this._category === '_armor') return DataManager.isArmor(item); if (this._category === '_keyItem') return DataManager.isItem(item) && item.itypeId === 2; var categories = DataManager.itemSecondaryCategories(item); return categories.indexOf(this._category) >= 0; }; Window_Recipe.prototype.isEnabled = function(item) { var result = (item && this.price(item) <= this._money && !$gameParty.hasMaxItems(item)); result = result && this.checkEnableRecipe(DataManager.itemRecipe(item)); if (Imported['LimitPossession']) { if ((this._allWeight + item._weight) > $gameParty.maxWeight()) return false; } return result; }; Window_Recipe.prototype.checkEnableRecipe = function(recipe) { var ary = recipe.recipe; if (!$gameTemp._callShopSynthesis) ary = ary.concat(recipe.machinery); for (var i=0,max=ary.length;i= 0) { r += $gameParty.numItems(it); } return r; }.bind(this),0); if (n < m[1]) return false; } } return true; }; Window_Recipe.prototype.currentPrice = function() { return this.price(this.item()); }; Window_Recipe.prototype.baseItem = function() { return Window_ShopBuy.prototype.item.call(this); }; Window_Recipe.prototype.item = function() { var item = this.baseItem(); if (!item) return item; var dummy = DataManager.itemRecipe(item).dummy; return dummy ? DataManager.decodeSynthesisItem(dummy) : item; }; //////////////////////////////////////////////////////////////////////////////////// function Window_SynthesisCategory() { this.initialize.apply(this, arguments); } Window_SynthesisCategory.prototype = Object.create(Window_HorzCommand.prototype); Window_SynthesisCategory.prototype.constructor = Window_SynthesisCategory; Window_SynthesisCategory.prototype.initialize = function(x, y, w) { this._width = w; Window_HorzCommand.prototype.initialize.call(this, x, y); }; Window_SynthesisCategory.prototype.windowWidth = function() { return this._width; }; Window_SynthesisCategory.prototype.setCategories = function(categories) { this._categories = categories; this.refresh(); }; Window_SynthesisCategory.prototype.setRecipeWindow = function(window) { this._recipeWindow = window; }; Window_SynthesisCategory.prototype.maxCols = function() { if (this._categories && this._categories.length > 0) return this._categories.length; return 4; }; Window_SynthesisCategory.prototype.category = function() { if (!this._categories) this._categories = []; if (this._categories.length > 0) { return this._categories[this.index()]; } else { return this.currentSymbol(); } }; Window_SynthesisCategory.prototype.makeCommandList = function() { if (this._categories) { if (this._categories.length > 0) { for (var i=0,max=this._categories.length;i 0) y += 8; } this.changePaintOpacity(true); for (var i=0,max=recipe.recipe.length;i= 0 && DataManager.isMaterial(it)) { r += $gameParty.numItems(it); } return r }.bind(this),0); this._numItems[item] = n; } return this._numItems[item]; }; Window_SynthesisStatus.prototype.isEnable = function(item) { return this.numItems(item[0]) >= item[1]; }; //////////////////////////////////////////////////////////////////////////////////// function Window_MaterialList() { this.initialize.apply(this, arguments); } Window_MaterialList.prototype = Object.create(Window_Selectable.prototype); Window_MaterialList.prototype.constructor = Window_MaterialList; Window_MaterialList.prototype.initialize = function(x, y, height) { this._synthesisNum = 1; Window_Selectable.prototype.initialize.call(this, x, y, this.windowWidth(), height); }; Window_MaterialList.prototype.windowWidth = function() { return 456; }; Window_MaterialList.prototype.standardFontSize = function() { return 24; }; Window_MaterialList.prototype.maxPageRows = function() { return Window_Selectable.prototype.maxPageRows.call(this) - 2; }; Window_MaterialList.prototype.maxItems = function() { if (this._recipe) { return this._needs.length; } else { return 1; } }; Window_MaterialList.prototype.itemRect = function(index) { var rect = Window_Selectable.prototype.itemRect.call(this, index); rect.y += this.lineHeight() + 2; return rect; }; Window_MaterialList.prototype.isCurrentItemEnabled = function() { return !DataManager.isSynthesisItem(this._needs[this.index()]); }; Window_MaterialList.prototype.setEstimateWindow = function(window) { this._estimateWindow = window; }; Window_MaterialList.prototype.setMaterialWindow = function(window) { this._materialWindow = window; }; Window_MaterialList.prototype.setNumber = function(number) { this._synthesisNum = number; this.refresh(); }; Window_MaterialList.prototype.setRecipe = function(item) { this._recipe = DataManager.itemRecipe(item); this._needs = []; this._sets = []; var recipe = this._recipe.recipe; for (var i=0,max=recipe.length;i 0; }; Window_Material.prototype.isCurrentItemEnabled = function() { return this.isEnabled(this.index()); }; Window_Material.prototype.setData = function(category, sets) { this._category = category; this._sets = sets; this._price = 0; this._number = 0; this.refresh(); }; Window_Material.prototype.setPrice = function(price) { this._price = price; }; Window_Material.prototype.setNumber = function(number) { this._number = number; this.refresh(); }; Window_Material.prototype.makeItemList = function() { this._data = []; var items = $gameParty.allItems(); for (var i=0,max=items.length;i 2) return false; if (DataManager.itemSecondaryCategories(item).indexOf(this._category) >= 0) return true; if (DataManager.isSynthesisItem(this._category)) { return DataManager.decodeSynthesisItem(this._category) === item; } return false }; Window_Material.prototype.itemRect = function(index) { var rect = Window_Selectable.prototype.itemRect.call(this, index); rect.y += this.lineHeight(); return rect; }; Window_Material.prototype.refresh = function() { this.contents.clear(); this.resetFontSettings(); if (this._category) { this.makeItemList(); this.drawAllItems(); this.changePaintOpacity(true); this.contents.fontSize = 20; //this.changeTextColor(this.systemColor()); var name = this._category; if (DataManager.isSynthesisItem(name)) name = DataManager.decodeSynthesisItem(name).name; this.drawText(name, 4, 0, this.contentsWidth()-8); this.drawSynthesisHorzLine(28); } else { if (this._price && this._number) { this.changeTextColor(this.systemColor()); this.drawText(synthesisPriceText, 0, 0, this.contentsWidth()); this.changeTextColor(this.normalColor()); this.drawText(this._price * this._number, 0, 0, this.contentsWidth() - 36, 'right'); this.changeTextColor(this.systemColor()); this.drawText(TextManager.currencyUnit, 0, 0, this.contentsWidth(), 'right'); } } }; Window_Material.prototype.drawItem = function(index) { var item = this._data[index]; var rect = this.itemRect(index); rect.x += 8; rect.width -= 48; this.changePaintOpacity(this.isEnabled(index)); this.drawSynthesisItemName(item, 1,rect.x, rect.y, rect.width); this.drawItemNumber(item, rect.x, rect.y, rect.width + 36, 'right'); }; Window_Material.prototype.drawItemNumber = function(item, x, y, width) { var num = this.itemNumber(item); this.drawText(':', x, y, width - this.textWidth('00'), 'right'); this.drawText(num, x, y, width, 'right'); }; Window_Material.prototype.itemNumber = function(item) { var num = $gameParty.numItems(item); if (this._sets) { for (var i=0,max=this._sets.length;i 1) { var text = numberSynthesisText; text = text.replace(/_num/,this._num+1); this.drawText(text, 8, y + 4, this.contentsWidth() - 16, 'center'); } else { this.drawText(synthesisText, 8, y + 4, this.contentsWidth() - 16, 'center'); } this.resetFontSettings(); } }; Window_Synthesis.prototype.maxSynthesis = function() { if (!this._maxSynthesis) { var n = 0; for (var i = 0, max = this._listWindow._sets.length; i < max; i++) { var item = this._listWindow._sets[i]; var num = $gameParty.numItems(item); var l = this._listWindow._sets.filter(function (s) { return s === item }).length; var nn = Math.floor(num / l); n = (n === 0 || n > nn) ? nn : n; } var item = this._estimateWindow.item(); this._maxSynthesis = Math.min(Math.min(n, this._maxBuy),$gameParty.maxItems(item)); if (this._maxSynthesis + $gameParty.numItems(item) > $gameParty.maxItems(item)) { this._maxSynthesis = $gameParty.maxItems(item) - $gameParty.numItems(item); } } return this._maxSynthesis; }; Window_Synthesis.prototype.isCursorMovable = function() { return this.isOpenAndActive(); }; Window_Synthesis.prototype.processCursorMove = function() { if (this.isCursorMovable()) { if (Input.isTriggered('down')) { this.cursorDown(Input.isTriggered('down')); } if (Input.isTriggered('up')) { this.cursorUp(Input.isTriggered('up')); } } }; Window_Synthesis.prototype.cursorUp = function(wrap) { if (this.maxSynthesis() > 1) { var num = (this._num + 1) % this.maxSynthesis(); this.updateSynthesisNumber(num); SoundManager.playCursor(); } }; Window_Synthesis.prototype.cursorDown = function(wrap) { if (this.maxSynthesis() > 1) { var num = (this._num + (this.maxSynthesis() - 1)) % this.maxSynthesis(); this.updateSynthesisNumber(num); SoundManager.playCursor(); } }; Window_Synthesis.prototype.onTouch = function(triggered) { var x = this.canvasToLocalX(TouchInput.x); var y = this.canvasToLocalY(TouchInput.y); var hitIndex = this.hitTest(x, y); if (hitIndex >= 0) { if (hitIndex === this.index()) { if (triggered && this.isTouchOkEnabled()) { this.processOk(); } } } else if (this._stayCount >= 15) { if (y < this.padding) { this.cursorUp(); } else if (y >= this.height - this.padding) { this.cursorDown(); } this._stayCount = 0; } }; Window_Synthesis.prototype.hitTest = function(x, y) { if (this.isContentsArea(x, y)) return 0; return -1; }; Window_Synthesis.prototype.updateSynthesisNumber = function(number) { this._num = number; this._listWindow.setNumber(number + 1); this._estimateWindow.setNumber(number + 1); this._materialWindow.setNumber(number + 1); this.refresh(); }; Window_Synthesis.prototype.processOk = function() { if (this.isCurrentItemEnabled()) { this.playSynthesisSound(); this.updateInputData(); this.deactivate(); this.callOkHandler(); } else { this.playBuzzerSound(); } }; Window_Synthesis.prototype.playSynthesisSound = function() { var settings = synthesisSeSettings; var se = {name:synthesisSeName, volume:settings[0], pitch:settings[1], pan:settings[2] }; AudioManager.playSe(se); }; Window_Synthesis.prototype.isCurrentItemEnabled = function() { if (this.maxSynthesis() < 1) return false; return Window_Selectable.prototype.isCurrentItemEnabled.call(this); }; //////////////////////////////////////////////////////////////////////////////////// function Scene_CategorySynthesis() { this.initialize.apply(this, arguments); } Scene_CategorySynthesis.prototype = Object.create(Scene_MenuBase.prototype); Scene_CategorySynthesis.prototype.constructor = Scene_CategorySynthesis; Scene_CategorySynthesis.prototype.create = function() { Scene_MenuBase.prototype.create.call(this); this.createHelpWindow(); this.createGoldWindow(); this.createCategoryWindow(); this.createRecipeListWindow(); this.createStatusWindow(); this.createMaterialListWindow(); this.createEstimateWindow(); this.createMaterialWindow(); this.createSynthesisWindow(); this.createResultWindow(); this._categoryWindow.setRecipeWindow(this._recipeWindow); this._recipeWindow.setStatusWindow(this._statusWindow); this._listWindow.setEstimateWindow(this._estimateWindow); this._listWindow.setMaterialWindow(this._materialWindow); }; Scene_CategorySynthesis.prototype.setParameters = function(args) { var categories = defaultSynthesisCategories; var name = ''; var picture = ''; for (var i=0,max=args.length;i 1){ this._synthesisWindow._helpWindow.setText(synthesisHelp); } }; Scene_CategorySynthesis.prototype.doSynthesis = function() { var num = this._estimateWindow._synthesisNum; for (var i=0,max=this._listWindow._sets.length;i 0) { return Math.min(max, Math.floor(this.money() / price)); } else { return max; } }; //////////////////////////////////////////////////////////////////////////////////// }());