daily pastebin goal
44%
SHARE
TWEET

BM_ShopCore

blackmorning Jun 3rd, 2016 (edited) 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Blackmorning Engine Plugins - Shop Core
  3. // BM_ShopCore.js
  4. //=============================================================================
  5.  
  6. var Imported = Imported || {};
  7. Imported.BM_ShopCore = true;
  8.  
  9. var BM = BM || {};
  10. //=============================================================================
  11.  /*:
  12.  * @plugindesc Shop Scene (v1.10)
  13.  * Shop layout setup
  14.  * @author Blackmorning
  15.  *
  16.  * @param ---General---
  17.  * @default
  18.  *
  19.  * @param WindowAlign
  20.  * @desc Location of the command window.
  21.  * left     right
  22.  * @default right
  23.  *
  24.  * @param CommandColumns
  25.  * @desc Number of columns in the command window.
  26.  * default for basic 3, yanfly 1
  27.  * @default 3
  28.  *
  29.  * @param CommandRows
  30.  * @desc Number of rows visible in the command window.
  31.  * default for basic 1, yanfly 4
  32.  * @default 1
  33.  *
  34.  * @param CommandFull
  35.  * @desc Command window goes all the way across (best with 1 row)
  36.  * false     true
  37.  * @default false
  38.  *
  39.  * @param ---Status Window---
  40.  * @default
  41.  *
  42.  * @param StatusWindowWidth
  43.  * @desc Width of the Shop Status window.
  44.  * default 400
  45.  * @default 400
  46.  *
  47.  * @param ParametersFontSize
  48.  * @desc Font size of parameters.
  49.  * @default 20
  50.  *
  51.  * @param ---Status Actor Display---
  52.  * @default
  53.  *
  54.  * @param ShopActorParameters
  55.  * @desc Parameters shown when comparing equipment.
  56.  * Separate parameters by a space. * see help *
  57.  * @default mhp mmp atk def mat mdf agi
  58.  *
  59.  * @param DisplayActors
  60.  * @desc Display a comparison for actors (# per page) or special
  61.  * # actors per page     0 - special display (single actor)
  62.  * @default 4
  63.  *
  64.  * @param CantEquipTxt
  65.  * @desc Text for when actor can't equip item for special display
  66.  * @default Can't Equip
  67.  *
  68.  * @param EquippedTxt
  69.  * @desc Text for number of equipment worn (
  70.  * if blank, number of equipment worn not shown
  71.  * @default Equipped
  72.  *
  73.  * @param ShowDifference
  74.  * @desc shows the change in parameters for special display
  75.  * Show - true     Hide - false
  76.  * @default true
  77.  *
  78.  * @param ComparePlusIcon
  79.  * @desc Choose icon to show positive stat changes.
  80.  * default - leave blank to show none.
  81.  * @default
  82.  *
  83.  * @param CompareMinusIcon
  84.  * @desc Choose icon to show negative stat changes.
  85.  * default - leave blank to show none.
  86.  * @default
  87.  *
  88.  * @param ---Number Window---
  89.  * @default
  90.  *
  91.  * @param ShowTouchButtons
  92.  * @desc Choose to always show touch buttons or default
  93.  * Show - true     Hide - false
  94.  * @default true
  95.  *
  96.  * @help
  97.  * ============================================================================
  98.  * Introduction
  99.  * ============================================================================
  100.  * Title: BM Shop Scene
  101.  * Author: Blackmorning
  102.  * Version: 1.10
  103.  * Website: http://bmscripts.weebly.com/mv-shop.html
  104.  
  105.  * - Decide what parameters to show/compare (using symbols in table below)
  106.  * - parameter percentage added directly to comparison
  107.  * - Customize layout of shop
  108.  * - added information on items, equipment
  109.  * - choose between special single actor or group comparison
  110.  *
  111.  * -- Compatiblity --
  112.  *
  113.  * - YEP Shop Core (Put YEP above this script)
  114.  * ============================================================================
  115.  * Instructions
  116.  * ============================================================================
  117.  * Table of built-in parameters:
  118.  * ============================
  119.  * | Symbol |      Name       |
  120.  * ============================
  121.  * | mhp    | Max HP          |
  122.  * | mmp    | Max MP          |
  123.  * | atk    | Attack          |
  124.  * | def    | Defense         |
  125.  * | mat    | M.Attack        |
  126.  * | mdf    | M.Defense       |
  127.  * | agi    | Agility         |
  128.  * | luk    | Luck            |
  129.  * =======================================
  130.  * | hit    | Hit Rate        | percent  |
  131.  * | eva    | Evasion         | percent  |
  132.  * | cri    | Critical Rate   | percent  |
  133.  * | cev    | Crit Evasion    | percent  |
  134.  * | mev    | Magic Evasion   | percent  |
  135.  * | mrf    | M. Reflection   | percent  |
  136.  * | cnt    | Counterattack   | percent  |
  137.  * | hrg    | HP Regen Rate   | percent  |
  138.  * | mrg    | MP Regen Rate   | percent  |
  139.  * | trg    | TP Regen Rate   | percent  |
  140.  * =======================================
  141.  * | tgr    | Target Rate     | percent  |
  142.  * | grd    | Guard Effect    | percent  |
  143.  * | rec    | Recovery Effect | percent  |
  144.  * | pha    | Pharmacology    | percent  |
  145.  * | mcr    | MP Cost Rate    | percent  |
  146.  * | tcr    | TP Cost Rate    | percent  |
  147.  * | pdr    | Phys Damage %   | percent  |
  148.  * | mdr    | Magic Damage %  | percent  |
  149.  * | fdr    | Floor Damage %  | percent  |
  150.  * | exr    | Exp Gain Rate   | percent  |
  151.  * =======================================
  152.  *
  153.  * ============================================================================
  154.  * Changelog
  155.  ============================================================================
  156.  * Version 1.10: 2017-Feb-23
  157.  * added info from YEP ShopCore
  158.  * Version 1.00: 2016-Jun-03
  159.  * - Finished plugin!
  160.  */
  161. //=============================================================================
  162. BM.Parameters = PluginManager.parameters('BM_ShopCore');
  163. BM.Shop = BM.Shop || {};
  164. BM.Icon = BM.Icon || {};
  165. BM.Vocab = BM.Vocab || {};
  166.  
  167. BM.Shop.WindowAlign = String(BM.Parameters['WindowAlign'] || 'right');
  168. BM.Shop.CommandColumns = Number(BM.Parameters['CommandColumns'] || 1);
  169. BM.Shop.CommandRows = Number(BM.Parameters['CommandRows'] || 1);
  170. BM.Shop.CommandFull = BM.Parameters['CommandFull'] == "true" ? true : false;
  171. BM.Shop.StatusWidth = Number(BM.Parameters['StatusWindowWidth'] || 400);
  172. BM.Shop.ParamFontSize = Number(BM.Parameters['ParametersFontSize']);
  173.  
  174. BM.Shop.SDisplayActors = Number(BM.Parameters['DisplayActors'] || 4);
  175. BM.Shop.SShowDifference = BM.Parameters['ShowDifference'] == "true" ? true : false;
  176. BM.Shop.CantEquipTxt = String(BM.Parameters['CantEquipTxt'])
  177. BM.Shop.EquippedTxt = String(BM.Parameters['EquippedTxt'] || '')
  178. BM.Shop.ShowTouchButtons = BM.Parameters['ShowTouchButtons'] == "true" ? true : false;
  179.  
  180. BM.Icon.Plus = Number(BM.Parameters['ComparePlusIcon']);
  181. BM.Icon.Minus = Number(BM.Parameters['CompareMinusIcon']);
  182.  
  183. BM.Data = String(BM.Parameters['ShopActorParameters']);
  184. BM.Data = BM.Data.split(' ');
  185. BM.Shop.SActorParam = [];
  186. for (BM.i = 0; BM.i < BM.Data.length; ++BM.i) {
  187.   BM.Shop.SActorParam.push(BM.Data[BM.i]);
  188. };
  189. //=============================================================================
  190. if (!Imported.BM_EquipCore){
  191. TextManager.paramName = function(paramName) {
  192.     var name = ''
  193.     if(!name || name == '') {
  194.         switch(paramName){
  195.             case 'mhp':
  196.             return $dataSystem.terms.params[0] || '';
  197.             case 'mmp':
  198.             return $dataSystem.terms.params[1] || '';
  199.             case 'atk':
  200.             return $dataSystem.terms.params[2] || '';
  201.             case 'def':
  202.             return $dataSystem.terms.params[3] || '';
  203.             case 'mat':
  204.             return $dataSystem.terms.params[4] || '';
  205.             case 'mdf':
  206.             return $dataSystem.terms.params[5] || '';
  207.             case 'agi':
  208.             return $dataSystem.terms.params[6] || '';
  209.             case 'luk':
  210.             return $dataSystem.terms.params[7] || '';
  211.             case 'hit':
  212.             return $dataSystem.terms.params[8] || '';
  213.             case 'eva':
  214.             return $dataSystem.terms.params[9] || '';
  215.         }
  216.     }
  217.     if (!name || name == "undefined" && Imported.Quasi_ParamsPlus){
  218.         for (var i = 0; i < QuasiParams._custom.length; i++) {
  219.             if (paramName == QuasiParams._customAbr(i)){
  220.                 name = capitalize_Words(paramName)
  221.                 break;
  222.             }
  223.         }
  224.     }
  225.     if (!name || name == "undefined"){
  226.         name = capitalize_Words(paramName)
  227.     }  
  228.     return name
  229. };
  230. function capitalize_Words(str)
  231. {
  232.  return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
  233. }
  234. //=============================================================================
  235. Window_Base.prototype.checkParamPercent = function(paramName) {
  236.     percent = true;
  237.     switch(paramName){
  238.     case 'mhp':
  239.     case 'mmp':
  240.     case 'atk':
  241.     case 'def':
  242.     case 'mat':
  243.     case 'mdf':
  244.     case 'agi':
  245.     case 'luk':
  246.     percent = false;
  247.     break;
  248.     }
  249.     if (Imported.Quasi_ParamsPlus){
  250.         for (var i = 0; i < QuasiParams._custom.length; i++) {
  251.             if (paramName == QuasiParams._customAbr(i)){   
  252.                 percent = false;
  253.                 break;
  254.             }
  255.         }
  256.     }
  257.     return percent
  258. }
  259. Window_Base.prototype.textLineHeight = function() {
  260.     return (this.contents.fontSize + this.textPadding()*2)
  261. };
  262. Window_Base.prototype.drawDarkRect = function(dx, dy, dw, dh) {
  263.     var color = this.gaugeBackColor();    
  264.     this.changePaintOpacity(false);    
  265.     this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color);    
  266.     this.changePaintOpacity(true);
  267. };
  268. }
  269. Window_Base.prototype.calculateHeight = function(y, list, height) {
  270.     height = height || this.contents.height;
  271.     this._plist = 0
  272.     this._newPY = 0
  273.     var h = height - y;
  274.     var tf = h / this.textLineHeight();
  275.     var pf = Math.floor(Math.min(tf,list.length));
  276.     var dh = pf * this.textLineHeight();
  277.     var dy = Math.floor((h - dh)/2);
  278.     this._newPY = y + dy
  279.     this._plist = pf
  280. }
  281. //=============================================================================
  282. Game_Actor.prototype.forceChangeEquipById = function(etypeId, itemId) {
  283.     var slotId = etypeId - 1;
  284.     if (this.equipSlots()[slotId] === 1) {
  285.         this.forceChangeEquip(slotId, $dataWeapons[itemId]);
  286.     } else {
  287.         this.forceChangeEquip(slotId, $dataArmors[itemId]);
  288.     }
  289. };
  290. //=============================================================================
  291. Window_ShopCommand.prototype.windowWidth = function() {
  292.     if (BM.Shop.CommandFull){
  293.         return Graphics.width
  294.     } else {
  295.         return Graphics.width - BM.Shop.StatusWidth;
  296.     }    
  297. };
  298. Window_ShopCommand.prototype.maxCols = function() {
  299.     return BM.Shop.CommandColumns;
  300. };
  301. Window_ShopCommand.prototype.numVisibleRows = function() {
  302.     return BM.Shop.CommandRows;
  303. };
  304. //=============================================================================
  305. Window_ShopBuy.prototype.windowWidth = function() {
  306.     return Graphics.width - BM.Shop.StatusWidth;
  307. };
  308. Window_ShopBuy.prototype.drawItem = function(index) {
  309.     var item = this._data[index];
  310.     var rect = this.itemRect(index);
  311.     var priceWidth = this.textWidth(this.price(item));
  312.     rect.width -= this.textPadding();
  313.     this.changePaintOpacity(this.isEnabled(item));
  314.     this.drawItemName(item, rect.x, rect.y, rect.width - priceWidth);
  315.     this.drawText(this.price(item), rect.x + rect.width - priceWidth,
  316.                   rect.y, priceWidth, 'right');
  317.     this.changePaintOpacity(true);
  318. };
  319. Window_ShopSell.prototype.maxCols = function() {
  320.     return 1;
  321. };
  322. Window_ShopSell.prototype.setStatusWindow = function(statusWindow) {
  323.     this._statusWindow = statusWindow;
  324.     this.callUpdateHelp();
  325. };
  326. Window_ShopSell.prototype.updateHelp = function() {
  327.     this.setHelpWindowItem(this.item());
  328.     if (this._statusWindow) {
  329.         this._statusWindow.setItem(this.item());
  330.     }
  331. };
  332. //=============================================================================
  333. Window_ShopStatus.prototype.refresh = function() {
  334.     this.contents.clear();
  335.     if (this._item) {
  336.         var x = this.textPadding();
  337.         this.drawPossession(x, 0);
  338.         this.contents.fontSize = BM.Shop.ParamFontSize
  339.         if (BM.Shop.EquippedTxt != ''){
  340.             y = Window_Base._iconHeight/2 + this.textPadding() + this.lineHeight() * 3.5
  341.             dy = this.lineHeight()*5
  342.         }else{
  343.             y = Window_Base._iconHeight/2 + this.textPadding() + this.lineHeight() * 2.5
  344.             dy = this.lineHeight()*4
  345.         }
  346.        
  347.         var param = BM.Shop.SActorParam
  348.         this.calculateHeight(dy, param)
  349.         this.resetFontSettings();
  350.         console.log(this.textLineHeight())
  351.         if (this.isEquipItem()) {
  352.             if (BM.Shop.EquippedTxt != ''){
  353.                 this.drawEquipped(x)
  354.             }
  355.             this.drawEquipInfo(x, y);
  356.          } else {
  357.             this.drawItemInfo(this._item);
  358.         }      
  359.     }
  360. };
  361. Window_ShopStatus.prototype.drawPossession = function(x, y) {
  362.     var width = this.contents.width - this.textPadding() - x;
  363.     var possessionWidth = this.textWidth('0000');
  364.     this.changeTextColor(this.systemColor());
  365.     this.drawText(TextManager.currencyUnit, x, y, width - possessionWidth);
  366.     this.drawText(TextManager.possession, x, y + this.lineHeight(), width - possessionWidth);
  367.     this.resetTextColor();
  368.     this.drawText($gameParty.gold(), x, y, width, 'right');
  369.     this.drawText($gameParty.numItems(this._item), x, y + this.lineHeight(), width, 'right');
  370. };
  371. Window_ShopStatus.prototype.drawEquipped = function(x) {
  372.     this._equipped = 0
  373.     var width = this.contents.width - this.textPadding() - x;
  374.     var members = $gameParty.members()
  375.     for (var i = 0; i < members.length; i++) {
  376.         var item1 = this.currentEquippedItem(members[i], this._item.etypeId);
  377.         if (this._item == item1){
  378.             this._equipped += 1
  379.         }
  380.     }
  381.     this.changeTextColor(this.systemColor());
  382.     this.drawText(BM.Shop.EquippedTxt, x, this.lineHeight()*2, width - this.textWidth('0000'));
  383.     this.resetTextColor();
  384.     this.drawText(this._equipped, x, this.lineHeight()*2, width, 'right');
  385. }
  386. Window_ShopStatus.prototype.pageSize = function() {
  387.     if (BM.Shop.SDisplayActors != 0){
  388.         return BM.Shop.SDisplayActors;
  389.     } else{
  390.         return 1;
  391.     }    
  392. };
  393. Window_ShopStatus.prototype.createWidths = function() {
  394.     this._paramNameWidth = 0;
  395.     this._paramValueWidth = 0;
  396.     this._columnSize = 0
  397.     this._arrowWidth = this.textWidth('\u2192' + ' ');
  398.     var buffer = this.textWidth(' ')
  399.     for (var i = 0; i < 8; ++i) {
  400.       var value1 = this.textWidth(TextManager.param(i));
  401.       var value2 = this.textWidth('9999');
  402.       this._paramNameWidth = Math.max(value1, this._paramNameWidth);
  403.       this._paramValueWidth = Math.max(value2, this._paramValueWidth);
  404.     }
  405.     this._bonusValueWidth = this._paramValueWidth;
  406.     this._bonusValueWidth += this.textWidth('(+)') + buffer;
  407.     this._paramNameWidth += buffer;
  408.     if (this._paramNameWidth + this._paramValueWidth * 2 + this._arrowWidth + this._bonusValueWidth > this.contents.width) {
  409.         this._bonusValueWidth = 0;
  410.     }
  411.     this._columnSize = (this.contents.width - this._paramNameWidth/1.5)/this.pageSize()
  412. };
  413. Window_ShopStatus.prototype.drawEquipInfo = function(x, y) {
  414.     this.createWidths()
  415.     var members = this.statusMembers();
  416.     this.contents.fontSize = BM.Shop.ParamFontSize 
  417.     var param = BM.Shop.SActorParam
  418.     if (BM.Shop.SDisplayActors != 0){
  419.         for (var i = 0; i < this._plist; i++) {
  420.             dy = this._newPY + this.textLineHeight()*i
  421.             this.drawDarkRect(0, dy, this.contents.width, this.textLineHeight());
  422.             this.drawParamName(dy, param[i])
  423.         }
  424.     }
  425.     this.resetFontSettings();
  426.     for (var i = 0; i < members.length; i++) {
  427.         if (BM.Shop.SDisplayActors != 0){
  428.             var dw = this._columnSize
  429.             dx = this.contents.width - dw*this.pageSize() + (i * dw) - this.textPadding()
  430.             this.drawActorEquipInfo(dx, y, members[i]);
  431.         } else{
  432.             this.drawSoloEquipInfo(this._paramNameWidth, y, members[i]);
  433.         }
  434.     }
  435. };
  436. Window_ShopStatus.prototype.drawItemInfo = function(item) {
  437.     //for plugin
  438. };
  439. Window_ShopStatus.prototype.drawActorEquipInfo = function(x, y, actor) {
  440.     var enabled = actor.canEquip(this._item);
  441.     this.changePaintOpacity(enabled);
  442.     this.resetTextColor();
  443.     var item1 = this.currentEquippedItem(actor, this._item.etypeId);
  444.     dw = (this._columnSize)/2
  445.     this.drawActorCharacter(actor, x + dw + 16, y)
  446.     this.drawIcon((item1 ? item1.iconIndex : 0), x + dw, y)
  447.     if (enabled) {
  448.         this.setTempActor(actor, item1);
  449.         this.contents.fontSize = BM.Shop.ParamFontSize
  450.         var param = BM.Shop.SActorParam
  451.         for (var i = 0; i < this._plist; i++) {
  452.             dy = this._newPY +  this.textLineHeight()*i
  453.             this.drawActorParamChange(x, dy, actor, item1, param[i]);
  454.             this.contents.fontSize = BM.Shop.ParamFontSize
  455.         }
  456.     }
  457.     this.resetFontSettings();
  458.     this.changePaintOpacity(true);
  459. };
  460. Window_ShopStatus.prototype.setTempActor = function(actor, item1) {
  461.     this._actor = actor
  462.     this._tempActor = JsonEx.makeDeepCopy(actor)
  463.     if (item1 === null){
  464.         this._tempActor.forceChangeEquip(this._item.etypeId-1, this._item);
  465.     } else {
  466.         this._tempActor.forceChangeEquipById(item1.etypeId, this._item.id);
  467.     }
  468. }
  469. Window_ShopStatus.prototype.drawActorParamChange = function(x, y, actor, item1, paramName) {
  470.     var percent = this.checkParamPercent(paramName)
  471.     var width = this._columnSize;
  472.     var oldValue = eval("this._actor." + paramName, this);
  473.     var newValue = eval("this._tempActor." + paramName, this);
  474.     var diffvalue = newValue - oldValue;
  475.     var change = diffvalue
  476.     if (diffvalue > 0 && BM.Icon.Plus && BM.Icon.Plus != 0){
  477.         this.drawIcon(BM.Icon.Plus, x, y)
  478.     }
  479.     if (diffvalue < 0 && BM.Icon.Minus && BM.Icon.Minus != 0){
  480.         this.drawIcon(BM.Icon.Minus, x, y)
  481.     }
  482.     if (percent == true) {
  483.         change = Math.round(diffvalue * 100) + "%";
  484.     }
  485.     this.changeTextColor(this.paramchangeTextColor(change));
  486.     this.drawText((diffvalue > 0 ? '+' : '') + change, x, y, width, 'right');
  487. };
  488. Window_ShopStatus.prototype.drawSoloEquipInfo = function(x, y, actor) {
  489.     var enabled = actor.canEquip(this._item);
  490.     this.changePaintOpacity(enabled);
  491.     this.resetTextColor();
  492.     var item1 = this.currentEquippedItem(actor, this._item.etypeId);
  493.     this.drawActorCharacter(actor, 25, y)
  494.     this.drawText(actor.name(), 50, y - this.lineHeight(), this.contents.height - x);
  495.     this.contents.fontSize = BM.Shop.ParamFontSize
  496.     this.drawDarkRect(Window_Base._iconWidth, y, this.contents.width-this.padding-Window_Base._iconWidth/2, Window_Base._iconHeight+this.textPadding());
  497.     if (enabled) {
  498.         this.drawItemName(item1, Window_Base._iconWidth, y);       
  499.         this.setTempActor(actor, item1);       
  500.         var param = BM.Shop.SActorParam
  501.         for (var i = 0; i < this._plist; i++) {
  502.             this.contents.fontSize = BM.Shop.ParamFontSize
  503.             dy = this._newPY +  this.textLineHeight()*i
  504.             this.drawDarkRect(0, dy, this.contents.width, this.textLineHeight());
  505.             this.drawParamName(dy, param[i])           
  506.             this.drawSoloParamChange(x, dy, param[i]);
  507.         }
  508.     } else{
  509.         this.changePaintOpacity(enabled);
  510.         this.drawText(BM.Shop.CantEquipTxt, Window_Base._iconWidth + this.textPadding(), y, this.contents.width-this.padding-Window_Base._iconWidth/2);
  511.     }
  512.     this.resetFontSettings();
  513.     this.changePaintOpacity(true);
  514. };
  515. BM.Shop.Window_ShopStatus_drawItemName = Window_ShopStatus.prototype.drawItemName;
  516. Window_ShopStatus.prototype.drawItemName = function(item, x, y, width) {
  517.     width = width || this.contents.width;
  518.     BM.Shop.Window_ShopStatus_drawItemName.call(this, item, x, y, width - x - this.textPadding());    
  519. };
  520. Window_ShopStatus.prototype.drawSoloParamChange = function(x, y, paramName) {
  521.     var width = this._columnSize;
  522.     this.drawRightArrow(y);
  523.     this.drawCurrentParam(y, paramName)
  524.     this.drawNewParam(y, paramName)
  525.     if (BM.Shop.SShowDifference) this.drawParamDifference(y, paramName);
  526. };
  527. Window_ShopStatus.prototype.drawParamName = function(y, paramName) {
  528.     var x = this.textPadding()
  529.     this.changeTextColor(this.systemColor());
  530.     var name = TextManager.paramName(paramName);
  531.     this.drawText(name, x, y, this._paramNameWidth);
  532. };
  533. Window_ShopStatus.prototype.drawRightArrow = function(y) {
  534.     var x = this.contents.width - this.textPadding();
  535.     x -= this._paramValueWidth * 2 + this._arrowWidth;
  536.     var dw = this.textWidth('\u2192' + ' ');
  537.     this.changeTextColor(this.systemColor());
  538.     this.drawText('\u2192', x, y, dw, 'right');
  539. };
  540. Window_ShopStatus.prototype.drawCurrentParam = function(y, paramName) {
  541.     var percent = this.checkParamPercent(paramName)
  542.     var x = this.contents.width - this.padding;
  543.     x -= this._paramValueWidth * 3 + this._arrowWidth;
  544.     this.resetTextColor();
  545.     var value = eval("this._actor." + paramName, this);
  546.     if (percent == true) {         
  547.         value = Math.round(value * 100) + "%";
  548.     }
  549.     this.drawText(value, x, y, this._paramValueWidth, 'right');
  550. };
  551. Window_ShopStatus.prototype.drawNewParam = function(y, paramName) {
  552.     var percent = this.checkParamPercent(paramName)
  553.     var x = this.contents.width - this.padding;
  554.     x -= this._paramValueWidth;
  555.     var oldValue = eval("this._actor." + paramName, this);
  556.     var newValue = eval("this._tempActor." + paramName, this);
  557.     var diffvalue = newValue - oldValue;
  558.     this.changeTextColor(this.paramchangeTextColor(diffvalue));
  559.     if (diffvalue > 0 && BM.Icon.Plus && BM.Icon.Plus != 0){
  560.         this.drawIcon(BM.Icon.Plus, x, y)
  561.     }
  562.     if (diffvalue < 0 && BM.Icon.Minus && BM.Icon.Minus != 0){
  563.         this.drawIcon(BM.Icon.Minus, x, y)
  564.     }
  565.     if (percent == true) {         
  566.         newValue = Math.round(newValue * 100) + "%";
  567.     }
  568.     this.drawText(newValue, 0, y, this.contents.width, 'right');
  569. };
  570. Window_ShopStatus.prototype.drawParamDifference = function(y, paramName) {
  571.     var percent = this.checkParamPercent(paramName)
  572.     this.contents.fontSize = BM.Shop.ParamFontSize/1.5
  573.     var x = this.contents.width - this.textPadding();
  574.     x -= this._paramValueWidth * 2 + this._arrowWidth/2;
  575.     var oldValue = eval("this._actor." + paramName, this);
  576.     var newValue = eval("this._tempActor." + paramName, this);
  577.     var diffvalue = newValue - oldValue;
  578.     this.changeTextColor(this.paramchangeTextColor(diffvalue));
  579.     var text = diffvalue;
  580.     if (percent == true) {
  581.         text = Math.round(text * 100) + "%";
  582.     }
  583.     text = (diffvalue > 0 ? '+' : '') + text
  584.     text = (diffvalue != 0 ? '(' + text + ')' : '')
  585.     this.drawText(text, x, y - this.contents.fontSize/1.5, this._bonusValueWidth, 'left');
  586. };
  587. //=============================================================================
  588. Window_ShopNumber.prototype.windowWidth = function() {
  589.     return Graphics.width - BM.Shop.StatusWidth;
  590. };
  591. Window_ShopNumber.prototype.refresh = function() {
  592.     this.contents.clear();
  593.     this.drawDarkRect(0, 0, this.contents.width, this.textLineHeight());
  594.     this.drawItemName(this._item, 0, 0);
  595.     this.drawItemEntry();
  596.     this.drawInitialPrice()
  597.     this.drawMultiplicationSign();
  598.     this.drawNumber();
  599.     this.drawTotalPrice();
  600. };
  601. Window_ShopNumber.prototype.drawItemEntry = function() {
  602.     if (!this._item) return;
  603.     var item = this._item;
  604.     if (DataManager.isItem(item)) this.drawItemInfo(item);
  605.     if (DataManager.isWeapon(item)) this.drawEquipInfo(item);
  606.     if (DataManager.isArmor(item)) this.drawEquipInfo(item);
  607. };
  608. Window_ShopNumber.prototype.drawItemInfo = function(item) {
  609.     //for plugin
  610. };
  611. Window_ShopNumber.prototype.drawEquipInfo = function(item) {
  612.     //for plugin
  613. };
  614. Window_ShopNumber.prototype.drawInitialPrice = function() {
  615.     var total = this._price;
  616.     var width = this.contentsWidth() - this.textPadding();
  617.     this.changeTextColor(this.systemColor());
  618.     this.drawText("Price", 0, this.itemY() - this.lineHeight(), width);
  619.     this.resetTextColor();
  620.     this.drawCurrencyValue(total, this._currencyUnit, 0, this.itemY() - this.lineHeight(), width);
  621. };
  622. Window_ShopNumber.prototype.drawNumber = function() {
  623.     var x = this.cursorX();
  624.     var y = this.itemY();
  625.     var width = this.cursorWidth() - this.textPadding();
  626.     this.changeTextColor(this.systemColor());
  627.     this.drawText("Number", 0, y, this.contentsWidth() - this.textPadding());
  628.     this.resetTextColor();
  629.     this.drawText(this._number, x, y, width, 'right');
  630. };
  631. Window_ShopNumber.prototype.drawTotalPrice = function() {
  632.     var total = this._price * this._number;
  633.     var width = this.contentsWidth() - this.textPadding();
  634.     this.changeTextColor(this.systemColor());
  635.     this.drawText("Total", 0, this.priceY(), width);
  636.     this.resetTextColor();
  637.     this.drawCurrencyValue(total, this._currencyUnit, 0, this.priceY(), width);
  638. };
  639. Window_ShopNumber.prototype.priceY = function() {
  640.     return Math.round(this.contentsHeight() - this.lineHeight());
  641. };
  642. Window_ShopNumber.prototype.itemY = function() {
  643.     this.visibleButtons()
  644.     if (this._buttonsVisible) {
  645.         return Math.round(this.contentsHeight() - this.lineHeight()*4.5);
  646.     }else{
  647.         return Math.round(this.contentsHeight() - this.lineHeight()*2);
  648.     }
  649. };
  650. Window_ShopNumber.prototype.buttonY = function() {
  651.     return Math.round(this.contentsHeight() - this.lineHeight() * 2.5);
  652. };
  653. Window_ShopNumber.prototype.visibleButtons = function(){
  654.     if (BM.Shop.ShowTouchButtons || (TouchInput.date > Input.date)){
  655.         this._buttonsVisible = true
  656.     }else{
  657.         this._buttonsVisible = false
  658.     }
  659. }
  660. Window_ShopNumber.prototype.updateButtonsVisiblity = function() {
  661.     this.visibleButtons()
  662.     if (this._buttonsVisible) {
  663.         this.showButtons();
  664.     } else {
  665.         this.hideButtons();
  666.     }
  667. };
  668. //=============================================================================
  669. function Window_Item2Category() {
  670.     this.initialize.apply(this, arguments);
  671. }
  672.  
  673. Window_Item2Category.prototype = Object.create(Window_HorzCommand.prototype);
  674. Window_Item2Category.prototype.constructor = Window_Item2Category;
  675.  
  676. Window_Item2Category.prototype.initialize = function() {
  677.     Window_HorzCommand.prototype.initialize.call(this, 0, 0);
  678. };
  679.  
  680. Window_Item2Category.prototype.windowWidth = function() {
  681.     return Graphics.width - BM.Shop.StatusWidth;
  682. };
  683.  
  684. Window_Item2Category.prototype.maxCols = function() {
  685.     return 4;
  686. };
  687.  
  688. Window_Item2Category.prototype.update = function() {
  689.     Window_HorzCommand.prototype.update.call(this);
  690.     if (this._itemWindow) {
  691.         this._itemWindow.setCategory(this.currentSymbol());
  692.     }
  693. };
  694.  
  695. Window_Item2Category.prototype.makeCommandList = function() {
  696.     this.addCommand(TextManager.item,    'item');
  697.     this.addCommand(TextManager.weapon,  'weapon');
  698.     this.addCommand(TextManager.armor,   'armor');
  699.     this.addCommand(TextManager.keyItem, 'keyItem');
  700. };
  701.  
  702. Window_Item2Category.prototype.setItemWindow = function(itemWindow) {
  703.     this._itemWindow = itemWindow;
  704.     this.update();
  705. };
  706. //=============================================================================
  707. BM.Shop.Scene_Shop_create = Scene_Shop.prototype.create;
  708. Scene_Shop.prototype.create = function() {
  709.     BM.Shop.Scene_Shop_create.call(this);
  710.     this.relocateWindows();
  711. }
  712. Scene_Shop.prototype.relocateWindows = function() {
  713.     if (BM.Shop.WindowAlign == 'right') {
  714.         this._commandWindow.x  = this._statusWindow.width;
  715.         this._dummyWindow.x    = this._statusWindow.width;
  716.         this._buyWindow.x      = this._statusWindow.width;
  717.         this._sellWindow.x     = this._statusWindow.width;
  718.         this._categoryWindow.x = this._statusWindow.width;
  719.         this._numberWindow.x   = this._statusWindow.width;
  720.         this._statusWindow.x = 0;      
  721.     };
  722. }
  723. Scene_Shop.prototype.createGoldWindow = function() {
  724.     this._goldWindow = new Window_Gold(0, this._helpWindow.height);
  725.     this._goldWindow.x = Graphics.boxWidth - this._goldWindow.width;
  726.     this.addWindow(this._goldWindow);
  727.     this._goldWindow.hide();
  728. };
  729. Scene_Shop.prototype.createStatusWindow = function() {
  730.     var wx = this._numberWindow.width;
  731.     if (BM.Shop.CommandFull){
  732.         var wy = this._commandWindow.y + this._commandWindow.height;
  733.     }else{
  734.         var wy = this._commandWindow.y;
  735.     }
  736.     var ww = Graphics.boxWidth - wx;
  737.     var wh = Graphics.boxHeight - wy;
  738.     this._statusWindow = new Window_ShopStatus(wx, wy, ww, wh);
  739.     this.addWindow(this._statusWindow);
  740. };
  741. BM.Shop.Scene_Shop_createDummyWindow = Scene_Shop.prototype.createDummyWindow;
  742. Scene_Shop.prototype.createDummyWindow = function() {
  743.     BM.Shop.Scene_Shop_createDummyWindow.call(this);
  744.     this._dummyWindow.width = Graphics.boxWidth - BM.Shop.StatusWidth;
  745. };
  746. Scene_Shop.prototype.createCategoryWindow = function() {
  747.     this._categoryWindow = new Window_Item2Category();
  748.     this._categoryWindow.setHelpWindow(this._helpWindow);
  749.     this._categoryWindow.y = this._dummyWindow.y;
  750.     this._categoryWindow.hide();
  751.     this._categoryWindow.deactivate();
  752.     this._categoryWindow.setHandler('ok',     this.onCategoryOk.bind(this));
  753.     this._categoryWindow.setHandler('cancel', this.onCategoryCancel.bind(this));
  754.     this.addWindow(this._categoryWindow);
  755. };
  756. Scene_Shop.prototype.createSellWindow = function() {
  757.     var wy = this._categoryWindow.y + this._categoryWindow.height;
  758.     var ww = this._dummyWindow.width;
  759.     var wh = Graphics.boxHeight - wy;
  760.     this._sellWindow = new Window_ShopSell(0, wy, ww, wh);
  761.     this._sellWindow.setHelpWindow(this._helpWindow);
  762.     this._sellWindow.setStatusWindow(this._statusWindow);
  763.     this._sellWindow.hide();
  764.     this._sellWindow.setHandler('ok',     this.onSellOk.bind(this));
  765.     this._sellWindow.setHandler('cancel', this.onSellCancel.bind(this));
  766.     this._categoryWindow.setItemWindow(this._sellWindow);
  767.     this.addWindow(this._sellWindow);
  768. };
  769. BM.Shop.Scene_Shop_commandBuy = Scene_Shop.prototype.commandBuy;
  770. Scene_Shop.prototype.commandBuy = function() {
  771.     BM.Shop.Scene_Shop_commandBuy.call(this);
  772.     this._statusWindow.show();
  773. };
  774. BM.Shop.Scene_Shop_onBuyCancel = Scene_Shop.prototype.onBuyCancel;
  775. Scene_Shop.prototype.onBuyCancel = function() {
  776.     BM.Shop.Scene_Shop_onBuyCancel.call(this);
  777.     this._statusWindow.show();
  778. };
  779. BM.Shop.Scene_Shop_activateSellWindow = Scene_Shop.prototype.activateSellWindow;
  780. Scene_Shop.prototype.activateSellWindow = function() {
  781.     BM.Shop.Scene_Shop_activateSellWindow.call(this);
  782.     this._statusWindow.show();
  783. };
  784. //=============================================================================
  785. if (Imported.YEP_ShopMenuCore){
  786. //=============================================================================
  787. Window_ShopStatus.prototype.initialize = function(x, y, width, height) {
  788.     Yanfly.Shop.Window_ShopStatus_initialize.call(this, x, y, width, height);
  789. };
  790. Window_ShopStatus.prototype.update = function() {
  791.     Yanfly.Shop.Window_ShopStatus_update.call(this);
  792. };
  793. Window_ShopStatus.prototype.paramId = function() {
  794.     return Yanfly.Shop.Window_ShopStatus_paramId.call(this);
  795. };
  796. //=============================================================================
  797. BM.Shop.Scene_Shop_createStatusWindow = Scene_Shop.prototype.createStatusWindow;
  798. Scene_Shop.prototype.createStatusWindow = function() {
  799.     BM.Shop.Scene_Shop_createStatusWindow.call(this);
  800.     this._buyWindow.setStatusWindow(this._statusWindow);
  801.     this._sellWindow.setStatusWindow(this._statusWindow);
  802. };
  803.  
  804. Window_ShopStatus.prototype.drawItemInfo = function(item) {
  805.     this.contents.fontSize = BM.Shop.ParamFontSize
  806.     console.log(this.textLineHeight())
  807.     var rect = new Rectangle();
  808.     rect.width = this.contents.width;
  809.     for (var i = 0; i < 8; ++i) {
  810.       rect = this.getRectPosition(rect, i);
  811.       var dx = rect.x + this.textPadding();
  812.       var dw = rect.width - this.textPadding() * 2;  
  813.       this.drawDarkRect(rect.x, rect.y, rect.width, this.textLineHeight());
  814.       this.changeTextColor(this.systemColor());
  815.       var text = this.getItemInfoCategory(i);
  816.       this.drawText(text, dx, rect.y, dw);
  817.       this.drawItemData(i, dx, rect.y, dw);
  818.     }
  819.     this.resetFontSettings();
  820. };
  821. Window_ShopStatus.prototype.getRectPosition = function(rect, i) {  
  822.     rect.x = 0
  823.     rect.y = this._newPY + this.textLineHeight()*i;
  824.     return rect;
  825. };
  826. Window_Base.prototype.getItemInfoCategory = function(i) {
  827.     var fmt = Yanfly.Param.ItemRecoverFmt;
  828.     if (i === 0) return fmt.format(TextManager.param(0));
  829.     if (i === 1) return fmt.format(TextManager.hp);
  830.     if (i === 2) return fmt.format(TextManager.param(1));
  831.     if (i === 3) return fmt.format(TextManager.mp);
  832.     if (i === 4) return Yanfly.Param.ItemAddState;
  833.     if (i === 5) return Yanfly.Param.ItemRemoveState;
  834.     if (i === 6) return Yanfly.Param.ItemAddBuff;
  835.     if (i === 7) return Yanfly.Param.ItemRemoveBuff;
  836.     return '';
  837. };
  838. Window_Base.prototype.drawItemData = function(i, dx, dy, dw) {
  839.     if (!this._item) return;
  840.     var effect;
  841.     var value = '---';
  842.     var pre = '';
  843.     var text = '';
  844.     var icons = [];
  845.     if (i === 0) {
  846.       effect = this.getEffect(Game_Action.EFFECT_RECOVER_HP);
  847.       value = (effect) ? effect.value1 : '---';
  848.       if (value === 0) value = '---';
  849.       if (value !== '---' && value !== 0) value *= 100;
  850.     }
  851.     if (i === 1) {
  852.       effect = this.getEffect(Game_Action.EFFECT_RECOVER_HP);
  853.       value = (effect) ? effect.value2 : '---';
  854.       if (value === 0) value = '---';
  855.     }
  856.     if (i === 2) {
  857.       effect = this.getEffect(Game_Action.EFFECT_RECOVER_MP);
  858.       value = (effect) ? effect.value1 : '---';
  859.       if (value === 0) value = '---';
  860.       if (value !== '---' && value !== 0) value *= 100;
  861.     }
  862.     if (i === 3) {
  863.       effect = this.getEffect(Game_Action.EFFECT_RECOVER_MP);
  864.       value = (effect) ? effect.value2 : '---';
  865.       if (value === 0) value = '---';
  866.     }
  867.     if (i >= 4) {
  868.       icons = this.getItemIcons(i, icons);
  869.     }
  870.     this.changeTextColor(this.normalColor());
  871.     if (value === '---') {
  872.       this.changePaintOpacity(false);
  873.     } else if (i < 4) {
  874.       if (value > 0) pre = '+';
  875.       value = Yanfly.Util.toGroup(parseInt(value));
  876.       if ([0, 2].contains(i)) text = '%';
  877.     }
  878.     if (icons.length > 0) {
  879.       this.changePaintOpacity(true);
  880.       dx = dx + dw - icons.length * Window_Base._iconWidth;
  881.       dx += this.textPadding() - 2;
  882.       for (var j = 0; j < icons.length; ++j) {
  883.         var icon = icons[j];
  884.         this.drawIcon(icon, dx, dy + 2);
  885.         dx += Window_Base._iconWidth;
  886.       }
  887.     } else {
  888.       text = pre + value + text;
  889.       this.drawText(text, dx, dy, dw, 'right');
  890.       this.changePaintOpacity(true);
  891.     }
  892. };
  893. Window_Base.prototype.getEffect = function(code) {
  894.     var targetEffect;
  895.     this._item.effects.forEach(function(effect) {
  896.       if (effect.code === code) targetEffect = effect;
  897.     }, this);
  898.     return targetEffect;
  899. };
  900. Window_Base.prototype.getItemIcons = function(i, array) {
  901.     this._item.effects.forEach(function(effect) {
  902.       if (i === 4 && effect.code === Game_Action.EFFECT_ADD_STATE) {
  903.         var state = $dataStates[effect.dataId];
  904.         if (state && state.iconIndex !== 0) array.push(state.iconIndex);
  905.       }
  906.       if (i === 5 && effect.code === Game_Action.EFFECT_REMOVE_STATE) {
  907.         var state = $dataStates[effect.dataId];
  908.         if (state && state.iconIndex !== 0) array.push(state.iconIndex);
  909.       }
  910.       if (i === 6 && effect.code === Game_Action.EFFECT_ADD_BUFF) {
  911.         var icon = Game_BattlerBase.ICON_BUFF_START + effect.dataId;
  912.         array.push(icon);
  913.       }
  914.       if (i === 6 && effect.code === Game_Action.EFFECT_ADD_DEBUFF) {
  915.         var icon = Game_BattlerBase.ICON_DEBUFF_START + effect.dataId;
  916.         array.push(icon);
  917.       }
  918.       if (i === 7 && effect.code === Game_Action.EFFECT_REMOVE_BUFF) {
  919.         var icon = Game_BattlerBase.ICON_BUFF_START + effect.dataId;
  920.         array.push(icon);
  921.       }
  922.       if (i === 7 && effect.code === Game_Action.EFFECT_REMOVE_DEBUFF) {
  923.         var icon = Game_BattlerBase.ICON_DEBUFF_START + effect.dataId;
  924.         array.push(icon);
  925.       }
  926.     }, this);
  927.     array = array.slice(0, Yanfly.Param.ItemMaxIcons);
  928.     return array;
  929. }
  930. }
RAW Paste Data
Top