Advertisement
adiktuzmiko

UNCO Craft Edit

Jan 19th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Crafting System Edit
  3. //   by Unconnected42
  4. //   edit by Adiktuzmiko
  5. // UNCO_Craft_Edit.js
  6. // Last Updated : 2020/01/19
  7. // Make sure this is inserted into your plugin list as the last file or at
  8. // least below the original
  9. //=============================================================================
  10.  
  11. /*:
  12.  * @plugindesc  Edits to the display of UNCO Crafting.
  13.  * <Unco Craft Edit>
  14.  * @author Edited by Adiktuzmiko
  15.  *
  16.  * @param ProdAmount DX
  17.  * @desc  Adjust this value to set the distance between the product name and the amount text
  18.  * @default 128
  19.  *
  20.  * @param Column Width
  21.  * @desc  Adjust this value to adjust the width of each column
  22.  * @default 128
  23.  *
  24.  * @param Ingredient Columns
  25.  * @desc  Adjust this value to adjust how many columns will be used. Make sure the columns will fit the window width
  26.  * @default 2
  27.  *
  28.  * @param Ingredient Per Column
  29.  * @desc  This is for code calculation purposes, if you're using the same window height as in your screenshot leave it at 3
  30.  * @default 3
  31.  *
  32.  */
  33.  
  34. Unco_edit.Parameters = $plugins.filter(function(p) {
  35.     return p.description.contains('<Unco Craft Edit>');
  36. })[0].parameters; //Copied from Ellye, who thanks Iavra
  37. Unco_edit.Param = Unco_edit.Param || {};
  38.  
  39. Unco_edit.Param.prodAmountDX = parseInt(String(Unco_edit.Parameters['ProdAmount DX']));
  40. Unco_edit.Param.columns = parseInt(String(Unco_edit.Parameters['Ingredient Columns']));
  41. Unco_edit.Param.columnWidth = parseInt(String(Unco_edit.Parameters['Column Width']));
  42. Unco_edit.Param.ingColumns = parseInt(String(Unco_edit.Parameters['Ingredient Per Column']));
  43.  
  44. //Overwrites of original functions
  45.  
  46. //To in-line the amount for the product
  47. Window_CraftInfo.prototype.drawProducts = function(dy) {
  48.     var skill = this._item;
  49.     var indent = 24;
  50.     var stockIndent = indent*3;
  51.     var dx = this.textPadding();
  52.     var dw = this.contents.width - this.textPadding() * 2;
  53.     this.resetFontSettings();
  54.     var text = ( (typeof skill.craftProdText !== 'undefined') ? skill.craftProdText : Unco.Param.craftDefProdText);
  55.     this.drawDarkRect(dx-indent, dy, dw+indent, this.lineHeight());
  56.     this.drawText(text, dx, dy, dw, 'left');
  57.     dy += this.lineHeight();
  58.     dx += indent;
  59.     this.contents.fontSize = Unco.Param.craftFontSize;
  60.     this.changeTextColor(this.textColor(Unco.Param.craftFontColorNorm));
  61.     for (var makeId in skill.makeItem) {
  62.        makeId = parseInt(makeId);
  63.        if (!isNaN(makeId) && (makeId > 0)) {
  64.           var makeAmount = parseInt(skill.makeItem[makeId]);
  65.           if (!isNaN(makeAmount) &&  (makeAmount > 0)) {
  66.              this.drawIcon($dataItems[makeId].iconIndex, dx, dy);
  67.              if (Unco.Param.craftDispNames === 'true') {
  68.                 this.drawText($dataItems[makeId].name, dx + Window_Base._iconWidth + 2, dy, dw, 'left');
  69.                 //dy += this.lineHeight();
  70.              }
  71.              text = 'x' + String(makeAmount);
  72.              this.drawText(text, dx + Unco_edit.Param.prodAmountDX + 2, dy, dw, 'left');
  73.              text = '(' + $gameParty.getItemAmount($dataItems[makeId]) + ' ' + Unco.Param.craftDefStocText + ')';
  74.              this.drawText(text, dx + Unco_edit.Param.prodAmountDX + stockIndent, dy, dw, 'left');
  75.              dy += this.lineHeight();
  76.           }
  77.        }
  78.     }
  79.     for (var makeId in skill.makeArmor) {
  80.        makeId = parseInt(makeId);
  81.        if (!isNaN(makeId) && (makeId > 0)) {
  82.           var makeAmount = parseInt(skill.makeArmor[makeId]);
  83.           if (!isNaN(makeAmount) &&  (makeAmount > 0)) {
  84.              this.drawIcon($dataArmors[makeId].iconIndex, dx, dy);
  85.              if (Unco.Param.craftDispNames === 'true') {
  86.                 this.drawText($dataArmors[makeId].name, dx + Window_Base._iconWidth + 2, dy, dw, 'left');
  87.                 //dy += this.lineHeight();
  88.              }
  89.              text = 'x' + String(makeAmount);
  90.              this.drawText(text, dx + Unco_edit.Param.prodAmountDX + 2, dy, dw, 'left');
  91.              text = '(' + $gameParty.getItemAmount($dataArmors[makeId]) + ' ' + Unco.Param.craftDefStocText + ')';
  92.              this.drawText(text, dx + Unco_edit.Param.prodAmountDX + stockIndent, dy, dw, 'left');
  93.              dy += this.lineHeight();
  94.           }
  95.        }
  96.     }
  97.     for (var makeId in skill.makeWeapon) {
  98.        makeId = parseInt(makeId);
  99.        if (!isNaN(makeId) && (makeId > 0)) {
  100.           var makeAmount = parseInt(skill.makeWeapon[makeId]);
  101.           if (!isNaN(makeAmount) &&  (makeAmount > 0)) {
  102.              this.drawIcon($dataWeapons[makeId].iconIndex, dx, dy);
  103.              if (Unco.Param.craftDispNames === 'true') {
  104.                 this.drawText($dataWeapons[makeId].name, dx + Window_Base._iconWidth + 2, dy, dw, 'left');
  105.                 //dy += this.lineHeight();
  106.              }
  107.              text = 'x' + String(makeAmount);
  108.              this.drawText(text, dx + Unco_edit.Param.prodAmountDX + 2, dy, dw, 'left');
  109.              text = '(' + $gameParty.getItemAmount($dataWeapons[makeId]) + ' ' + Unco.Param.craftDefStocText + ')';
  110.              this.drawText(text, dx + Unco_edit.Param.prodAmountDX + stockIndent, dy, dw, 'left');
  111.              dy += this.lineHeight();
  112.           }
  113.        }
  114.     }
  115.     this.resetFontSettings();
  116.     return dy;
  117.  };
  118.  
  119.  //Draw Components
  120.  
  121.  
  122.  Window_CraftInfo.prototype.drawComponents = function(dy) {  
  123.     var skill = this._item;
  124.     var indent = 24;
  125.     var stockIndent = indent*3;
  126.     var dx = this.textPadding();
  127.     var dw = this.contents.width - this.textPadding() * 2;
  128.     var count = 0;
  129.     var dyOrig = 0;
  130.     this.resetFontSettings();
  131.     this.drawDarkRect(dx-indent, dy, dw+indent, this.lineHeight());
  132.     var text = ( (typeof skill.craftCompText !== 'undefined') ? skill.craftCompText : Unco.Param.craftDefCompText);
  133.     this.drawText(text, dx, dy, dw, 'left');
  134.     dy += this.lineHeight();
  135.     dx += indent;
  136.     dyOrig = dy;
  137.     this.contents.fontSize = Unco.Param.craftFontSize;
  138.     var craftLineHeight = Math.max(Unco.Param.craftFontSize,Window_Base._iconHeight)+1;  
  139.      if (typeof skill.goldCost === 'number') {
  140.        this.drawIcon(Unco.Param.goldAmmoIconId, dx, dy);
  141.        if (Unco.Param.craftDispNames === 'true') {
  142.           this.drawText(TextManager.currencyUnit, dx + Window_Base._iconWidth + 2, dy, dw, 'left');
  143.           dy += craftLineHeight;
  144.        }
  145.        var text = 'x' + String(skill.goldCost);
  146.        this.drawText(text, dx + Window_Base._iconWidth + 2, dy, dw, 'left');
  147.        if (skill.goldCost > $gameParty.gold()) this.changeTextColor(this.textColor(Unco.Param.craftFontColorCris));
  148.        text = '(' + $gameParty.gold() + ' ' + Unco.Param.craftDefStocText + ')';
  149.        this.drawText(text, dx + Window_Base._iconWidth + stockIndent, dy, dw, 'left');
  150.        dy += craftLineHeight;
  151.        this.changeTextColor(this.textColor(Unco.Param.craftFontColorNorm));
  152.        this.resetFontSettings();
  153.        count += 1;
  154.        if (count === Unco_edit.Param.ingColumns) {
  155.            count = 0;
  156.            dy = dyOrig;
  157.            dx += Unco_edit.Param.columnWidth;
  158.        }
  159.      }
  160.     for (var ammoId in skill.itemAmmoCost) {
  161.        ammoId = parseInt(ammoId);
  162.        if (!isNaN(ammoId) && (ammoId > 0)) {
  163.           var ammoAmount = parseInt(skill.itemAmmoCost[ammoId]);
  164.           if (!isNaN(ammoAmount) &&  (ammoAmount > 0)) {
  165.              this.drawIcon($dataItems[ammoId].iconIndex, dx, dy);
  166.              if (Unco.Param.craftDispNames === 'true') {
  167.                 this.drawText($dataItems[ammoId].name, dx + Window_Base._iconWidth + 2, dy, dw, 'left');
  168.                 dy += craftLineHeight;
  169.              }
  170.              this.changeTextColor(this.textColor(Unco.Param.craftFontColorNorm));
  171.              text = 'x' + String(ammoAmount);
  172.              this.drawText(text, dx + Window_Base._iconWidth + 2, dy, dw, 'left');
  173.              if (ammoAmount > $gameParty.getItemAmount($dataItems[ammoId])) this.changeTextColor(this.textColor(Unco.Param.craftFontColorCris));
  174.              text = '(' + $gameParty.getItemAmount($dataItems[ammoId]) + ' ' + Unco.Param.craftDefStocText + ')';
  175.              this.drawText(text, dx + Window_Base._iconWidth + stockIndent, dy, dw, 'left');
  176.              dy += craftLineHeight;
  177.              this.changeTextColor(this.textColor(Unco.Param.craftFontColorNorm));
  178.              count += 1;
  179.              if (count === Unco_edit.Param.ingColumns) {
  180.                 count = 0;
  181.                 dy = dyOrig;
  182.                 dx += Unco_edit.Param.columnWidth;
  183.              }  
  184.           }
  185.        }
  186.     }
  187.     for (var ammoId in skill.equipAmmoCost) {
  188.        ammoId = parseInt(ammoId);
  189.        if (!isNaN(ammoId) && (ammoId > 0)) {
  190.           ammoAmount = parseInt(skill.equipAmmoCost[ammoId]);
  191.           if (!isNaN(ammoAmount) && (ammoAmount > 0)) {
  192.              this.drawIcon($dataArmors[ammoId].iconIndex, dx, dy);
  193.              if (Unco.Param.craftDispNames === 'true') {
  194.                 this.drawText($dataArmors[ammoId].name, dx + Window_Base._iconWidth + 2, dy, dw, 'left');
  195.                 dy += craftLineHeight;
  196.              }
  197.              this.changeTextColor(this.textColor(Unco.Param.craftFontColorNorm));
  198.              text = 'x' + String(ammoAmount);
  199.              this.drawText(text, dx + Window_Base._iconWidth + 2, dy, dw, 'left');
  200.              text = '(' + $gameParty.getItemAmount($dataArmors[ammoId]) + ' ' + Unco.Param.craftDefStocText + ')';
  201.              if (ammoAmount > $gameParty.getItemAmount($dataArmors[ammoId])) this.changeTextColor(this.textColor(Unco.Param.craftFontColorCris));
  202.              this.drawText(text, dx + Window_Base._iconWidth + stockIndent, dy, dw, 'left');
  203.              dy += craftLineHeight;
  204.              this.changeTextColor(this.textColor(Unco.Param.craftFontColorNorm));
  205.              count += 1;
  206.              if (count === Unco_edit.Param.ingColumns) {
  207.                 count = 0;
  208.                 dy = dyOrig;
  209.                 dx += Unco_edit.Param.columnWidth;
  210.              }  
  211.           }
  212.        }
  213.     }
  214.     for (var ammoId in skill.weaponAmmoCost) {
  215.        ammoId = parseInt(ammoId);
  216.        if (!isNaN(ammoId) && (ammoId > 0)) {
  217.           ammoAmount = parseInt(skill.weaponAmmoCost[ammoId]);
  218.           if (!isNaN(ammoAmount) && (ammoAmount > 0)) {
  219.              this.drawIcon($dataWeapons[ammoId].iconIndex, dx, dy);
  220.              if (Unco.Param.craftDispNames === 'true') {
  221.                 this.drawText($dataWeapons[ammoId].name, dx + Window_Base._iconWidth + 2, dy, dw, 'left');
  222.                 dy += craftLineHeight;
  223.              }
  224.              this.changeTextColor(this.textColor(Unco.Param.craftFontColorNorm));
  225.              text = 'x' + String(ammoAmount);
  226.              this.drawText(text, dx + Window_Base._iconWidth + 2, dy, dw, 'left');
  227.              text = '(' + $gameParty.getItemAmount($dataWeapons[ammoId]) + ' ' + Unco.Param.craftDefStocText + ')';
  228.              if (ammoAmount > $gameParty.getItemAmount($dataWeapons[ammoId])) this.changeTextColor(this.textColor(Unco.Param.craftFontColorCris));
  229.              this.drawText(text, dx + Window_Base._iconWidth + stockIndent, dy, dw, 'left');
  230.              dy += craftLineHeight;
  231.              this.changeTextColor(this.textColor(Unco.Param.craftFontColorNorm));
  232.              count += 1;
  233.              if (count === Unco_edit.Param.ingColumns) {
  234.                 count = 0;
  235.                 dy = dyOrig;
  236.                 dx += Unco_edit.Param.columnWidth;
  237.              }  
  238.           }
  239.        }
  240.     }
  241.     this.resetFontSettings();
  242.     return dy;
  243.  };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement