Advertisement
jerry2810

DetailedShop

Nov 18th, 2015
1,695
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // DetailedShop
  3. //=============================================================================
  4. //v1.0
  5. /*:
  6.  * @plugindesc Upgrades the shop to show more options and graphics.
  7.  * @author Jeremy Cannady
  8.  *
  9.  * @param ShopKeeper
  10.  * @desc
  11.  * @default ---------------------------------
  12.  *
  13.  * @param Shopkeeper Enabled
  14.  * @desc Enable or disable shopkeeper picture. true or false
  15.  * @default false
  16.  *
  17.  * @param Shopkeeper Picure
  18.  * @desc The name of the shopkeeper picture. Must be in the /img/pictures folder.
  19.  * @default Package2_2
  20.  *
  21.  * @param Shopkeeper X Adjust
  22.  * @desc Adjust the Shopkeeper picture, x is left(-) and right(+).
  23.  * @default 0
  24.  *
  25.  * @param Shopkeeper Y Adjust
  26.  * @desc Adjust the Shopkeeper picture, y is up(+) and down(-).
  27.  * @default 0
  28.  *
  29.  * @param Background Picture
  30.  * @desc
  31.  * @default ---------------------------------
  32.  *
  33.  * @param BattleBack Default
  34.  * @desc Sets the default background images to what the current battle back is. true or false
  35.  * @default true
  36.  *
  37.  * @param Override Battleback 1
  38.  * @desc If we chose not to use the default then use these specific images for the background. Must be in the /img/battleback1
  39.  * @default Cobblestones1
  40.  *
  41.  * @param Override Battleback 2
  42.  * @desc If we chose not to use the default then use these specific images for the background. Must be in the /img/battleback2
  43.  * @default Town3
  44.  *
  45.  * @param Text Options
  46.  * @desc
  47.  * @default ---------------------------------
  48.  *
  49.  * @param Options Text
  50.  * @desc Text to display when we start the shop.
  51.  * @default What would you like to do?
  52.  *
  53.  * @param Buy Text
  54.  * @desc Text to say when we select buy.
  55.  * @default What would you like to buy?
  56.  *
  57.  * @param Sell Text
  58.  * @desc Text to say when we select sell.
  59.  * @default What would you like to sell?
  60.  
  61.  
  62.  * @help
  63.  *Just use the built in shop processing as normal.
  64.  *
  65. */
  66. var COLD = COLD || {};
  67.  
  68. COLD.Parameters = PluginManager.parameters('DetailedShop');
  69. COLD.Param = COLD.Param || {};
  70. COLD.Param.ShopBBEnabled = COLD.Parameters['BattleBack Enabled'] || 'true';
  71. COLD.Param.ShopKEnabled = COLD.Parameters['Shopkeeper Enabled'] || 'false';
  72. COLD.Param.ShopKPicture = COLD.Parameters['Shopkeeper Picure'] || 'Package2_2';
  73. COLD.Param.ShopxAdjust = Number(COLD.Parameters['Shopkeeper X Adjust'] || 0);
  74. COLD.Param.ShopyAdjust = Number(COLD.Parameters['Shopkeeper Y Adjust'] || 0);
  75. COLD.Param.ShopBBDefault = COLD.Parameters['BattleBack Default'] || 'true';
  76. COLD.Param.ShopBBOverride1 = COLD.Parameters['Override Battleback 1'] || 'Cobblestones1';
  77. COLD.Param.ShopBBOverride2 = COLD.Parameters['Override Battleback 2'] || 'Town3';
  78. COLD.Param.ShopOptionsText = COLD.Parameters['Options Text'];
  79. COLD.Param.ShopBuyText = COLD.Parameters['Buy Text'];
  80. COLD.Param.ShopSellText = COLD.Parameters['Sell Text'];
  81.  
  82.  
  83.     //Plugin Commands Section
  84.     //Changes the shopkeeper picture
  85.     var changeShopPicture_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  86.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
  87.         changeShopPicture_pluginCommand.call(this, command, args);
  88.         if (command === "changeShopPicture") {
  89.             COLD.Param.ShopKPicture = args[0];
  90.         };
  91.     };
  92.     //End Plugin Command Section
  93.    
  94. (function(){
  95.  
  96.     /**
  97.     * Create the description window.
  98.     */
  99.     COLD.shopDescriptionWindow = function() {
  100.         this.initialize.apply(this, arguments);
  101.     };
  102.  
  103.     COLD.shopDescriptionWindow.prototype = Object.create(Window_Base.prototype);
  104.     COLD.shopDescriptionWindow.prototype.constructor = COLD.shopDescriptionWindow;
  105.  
  106.     //Define variables
  107.     COLD.shopDescriptionWindow.prototype.currentItem = null;
  108.     COLD.shopDescriptionWindow.prototype.currentActor = null;
  109.  
  110.     COLD.shopDescriptionWindow.prototype.initialize = function(x, y) {
  111.         var width = this.windowWidth();
  112.         var height = this.windowHeight();
  113.         Window_Base.prototype.initialize.call(this, x, y, width, height);
  114.     };
  115.  
  116.     //What we do on each update.
  117.     COLD.shopDescriptionWindow.prototype.update = function() {
  118.         this.contents.clear();
  119.         if(this.currentItem != null){
  120.             var item = this.currentItem;
  121.             this.drawItemName(0, 0, this.windowWidth(), item);
  122.             this.drawHorzLine(this.lineHeight()-8)
  123.             this.drawItemIcon(this.standardPadding(), this.lineHeight() * 2, item);
  124.             this.drawItemType(0, this.lineHeight() * 2, this.windowWidth(), item);
  125.             this.drawHorzLine(this.lineHeight()*3)
  126.             this.drawItemDescription(0, this.lineHeight() * 4, this.windowWidth(), item);
  127.             this.drawHorzLine(this.windowHeight() - this.lineHeight()*7)
  128.             this.drawHorzLine(this.windowHeight() - this.lineHeight()*2-18)
  129.             this.drawPrice(0, this.windowHeight() - this.lineHeight() * 2, this.windowWidth(), item);
  130.         };
  131.         //Draw the parameter changes.
  132.         if(this.currentItem != null && this.currentActor){
  133.             this.drawItemParamChanges(0, this.windowHeight() - this.lineHeight()*6, this.windowWidth(), this.currentItem);
  134.         }; 
  135.     };
  136.  
  137.     COLD.shopDescriptionWindow.prototype.windowWidth = function() {
  138.         return Graphics.width - 100 - this.standardPadding() * 3;
  139.     };
  140.  
  141.     COLD.shopDescriptionWindow.prototype.windowHeight = function() {
  142.         return Graphics.height - 100;
  143.     };
  144.  
  145.     COLD.shopDescriptionWindow.prototype.drawItemName = function( x, y, width, item) {
  146.         this.drawText(item.name, x, y, width, 'center');
  147.     };
  148.     COLD.shopDescriptionWindow.prototype.drawItemIcon = function( x, y, item) {
  149.         //Load the icon
  150.         this.bitmapIcon = new Sprite(ImageManager.loadSystem('IconSet'));
  151.         //Change the scale to twice as big
  152.         this.bitmapIcon.scale.x = 2;
  153.         this.bitmapIcon.scale.y = 2;
  154.         //Position the icon x, y
  155.         this.bitmapIcon.x = x
  156.         this.bitmapIcon.y = y;
  157.         var pw = Window_Base._iconWidth;
  158.         var ph = Window_Base._iconHeight;
  159.         var sx = item.iconIndex % 16 * pw;
  160.         var sy = Math.floor(item.iconIndex / 16) * ph;
  161.         //Add the bitmap to the window
  162.         this.addChild(this.bitmapIcon);
  163.         this.bitmapIcon.setFrame(sx, sy, 32, 32);
  164.     };
  165.    
  166.     COLD.shopDescriptionWindow.prototype.drawItemType = function( x, y, width, item) {
  167.         if(COLD.shopIconSelectWindow.prototype.equipType == 1){
  168.             var text = 'Weapon type: ' + $dataSystem.weaponTypes[item.wtypeId];
  169.             this.drawText(text, x, y, width - this.standardPadding() * 2, 'right');
  170.         };
  171.         if(COLD.shopIconSelectWindow.prototype.equipType == 2){
  172.             var text = 'Armor type: ' + $dataSystem.armorTypes[item.atypeId];
  173.             this.drawText(text, x, y, width - this.standardPadding() * 2, 'right');
  174.         };
  175.     };
  176.  
  177.     COLD.shopDescriptionWindow.prototype.drawItemDescription = function( x, y, width, item) {
  178.         this.drawText(item.description, x, y, width, 'left');
  179.     };
  180.  
  181.     COLD.shopDescriptionWindow.prototype.drawHorzLine = function(y) {
  182.         var lineY = y + this.lineHeight() / 2 - 1;
  183.         this.contents.paintOpacity = 48;
  184.         this.contents.fillRect(0, lineY, this.contentsWidth(), 2, this.normalColor());
  185.         this.contents.paintOpacity = 255;
  186.     };
  187.  
  188.     COLD.shopDescriptionWindow.prototype.paramChangeText = function(actor, item, paramIndex){
  189.         var slotId = item.etypeId - 1;
  190.         var currentEquipped = actor.equips()[slotId];
  191.         if(!currentEquipped){
  192.             var paramChange = item.params[paramIndex];
  193.         }else{
  194.             var paramChange = item.params[paramIndex] - currentEquipped.params[paramIndex];
  195.         };
  196.         return paramChange;
  197.     };
  198.  
  199.     COLD.shopDescriptionWindow.prototype.drawItemParamChanges = function(x, y, width, item) {
  200.         var item = item;
  201.         if(!DataManager.isItem(item)){
  202.             var length = item.params.length;
  203.             var intialY = y;
  204.             var intialX = x;
  205.             var  x;
  206.             var text;
  207.             for(var i = 0; i < length; i++){
  208.                 if( i % 2 == 0){
  209.                     x = intialX;
  210.                 }else{
  211.                     x = intialX + this.windowWidth() / 2;
  212.                 };
  213.                 text = $dataSystem.terms.params[i] + ': ';
  214.                 var change = this.paramChangeText(this.currentActor ,item, i);
  215.                 this.drawText(text, x, y, width, 'left');
  216.                 var xOffset = this.textWidth(text);
  217.                 if(change > 0){
  218.                     this.changeTextColor(this.textColor(11));
  219.                 }else if(change == 0){
  220.                     this.changeTextColor(this.normalColor());  
  221.                 }else{ 
  222.                     this.changeTextColor(this.textColor(2));
  223.                 }
  224.                 this.drawText(change, x + xOffset, y, width, 'left');
  225.                 if( i % 2 != 0){
  226.                     y += this.lineHeight();
  227.                 };
  228.                 this.resetTextColor();
  229.             };
  230.         };
  231.     };
  232.    
  233.     //Draw the price and our current gold value.
  234.     COLD.shopDescriptionWindow.prototype.drawPrice = function( x, y, width, item) {
  235.         var text = $gameParty._gold + ' ' + $dataSystem.currencyUnit;
  236.         this.changeTextColor(this.textColor(20));
  237.         this.drawText(text, x, y, width - this.standardPadding() * 2, 'right');
  238.         this.changeTextColor(this.textColor(22));
  239.         var text = 'Price: ' + item.price + ' ' + $dataSystem.currencyUnit;
  240.         this.drawText(text, x, y, width - this.standardPadding() * 2, 'left'); 
  241.         this.resetTextColor();
  242.     };
  243.    
  244.     /**
  245.     * Create the item window.
  246.     */
  247.  
  248.     COLD.shopItemWindow = function() {
  249.         this.initialize.apply(this, arguments);
  250.     };
  251.  
  252.     COLD.shopItemWindow.prototype = Object.create(Window_Base.prototype);
  253.     COLD.shopItemWindow.prototype.constructor = COLD.shopItemWindow;
  254.    
  255.     COLD.shopItemWindow.prototype.initialize = function(x, y) {
  256.         var width = this.windowWidth();
  257.         var height = this.windowHeight();
  258.         Window_Base.prototype.initialize.call(this, x, y, width, height);
  259.     };
  260.  
  261.     //What we do on each update.
  262.     COLD.shopItemWindow.prototype.update = function() {
  263.         this.item = this.currentItem;
  264.         //Only execute if we have an item.
  265.         if(this.currentItem != null){
  266.             this.contents.clear();
  267.             this.drawItemName(0, 0, this.windowWidth(), this.item);
  268.             this.drawHorzLine(this.lineHeight() - this.standardPadding());
  269.             this.drawItemDescription(0, this.lineHeight(), this.windowWidth(), this.item)
  270.             this.drawHorzLine(this.lineHeight() * 3 - this.standardPadding());
  271.             this.drawPrice(0, this.lineHeight() * 3, this.windowWidth(), this.item)
  272.         }; 
  273.     };
  274.  
  275.     COLD.shopItemWindow.prototype.windowWidth = function() {
  276.         return Graphics.width;
  277.     };
  278.  
  279.     COLD.shopItemWindow.prototype.windowHeight = function() {
  280.         return this.lineHeight() * 4+ this.standardPadding()*2;
  281.     };
  282.  
  283.     COLD.shopItemWindow.prototype.drawItemName = function( x, y, width, item) {
  284.         this.drawText(item.name, x, y, width, 'center');
  285.     };
  286.  
  287.     COLD.shopItemWindow.prototype.drawItemDescription = function( x, y, width, item) {
  288.         this.drawText(item.description, x, y, width, 'left');
  289.     };
  290.  
  291.     COLD.shopItemWindow.prototype.drawHorzLine = function(y) {
  292.         var lineY = y + this.lineHeight() / 2 - 1;
  293.         this.contents.paintOpacity = 48;
  294.         this.contents.fillRect(0, lineY, this.contentsWidth(), 2, this.normalColor());
  295.         this.contents.paintOpacity = 255;
  296.     };
  297.  
  298.     COLD.shopItemWindow.prototype.drawPrice = function( x, y, width, item) {
  299.         var text = $gameParty._gold + ' ' + $dataSystem.currencyUnit;
  300.         this.changeTextColor(this.textColor(20));
  301.         this.drawText(text, x, y, width - this.standardPadding() * 2, 'right');
  302.         this.changeTextColor(this.textColor(22));
  303.         var text = 'Price: ' + item.price + ' ' + $dataSystem.currencyUnit;
  304.         this.drawText(text, x, y, width - this.standardPadding() * 2, 'left'); 
  305.         this.resetTextColor();
  306.     };
  307.  
  308.     /**
  309.     * Create the actor window.
  310.     */
  311.     COLD.shopAbleToEquipWindow = function() {
  312.         this.initialize.apply(this, arguments);
  313.     };
  314.  
  315.     COLD.shopAbleToEquipWindow.prototype = Object.create(Window_Selectable.prototype);
  316.     COLD.shopAbleToEquipWindow.prototype.constructor = COLD.shopAbleToEquipWindow;
  317.  
  318.     //Define variables.
  319.     COLD.shopAbleToEquipWindow.prototype.lastIndex = -1;
  320.    
  321.     COLD.shopAbleToEquipWindow.prototype.initialize = function(x, y) {
  322.         var width = this.windowWidth();
  323.         var height = this.windowHeight();
  324.         Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  325.         this._pendingIndex = -1;
  326.         this.select(0);
  327.         this.loadImages();
  328.         this.refresh();
  329.     };
  330.  
  331.     //What we do on each update.
  332.     COLD.shopAbleToEquipWindow.prototype.update = function() {
  333.         this._item = COLD.shopDescriptionWindow.prototype.currentItem;
  334.         this.refresh();
  335.         if(this._item){
  336.             Window_Selectable.prototype.update.call(this);
  337.            
  338.             if(this.index() >= 0 && this.index() != this.lastIndex){
  339.                 COLD.shopDescriptionWindow.prototype.currentActor = this.equipAbleList(this._item)[this.index()];
  340.                 this.lastIndex = this.index();
  341.             };
  342.            
  343.             //Check to see if we only have 1 actor and update accordingly.
  344.             if(this.equipAbleList(this._item).length = 1){
  345.                 COLD.shopDescriptionWindow.prototype.currentActor = this.equipAbleList(this._item)[this.index()];
  346.             };
  347.         };
  348.     };
  349.  
  350.     COLD.shopAbleToEquipWindow.prototype.loadImages = function() {
  351.         $gameParty.members().forEach(function(actor) {
  352.             ImageManager.loadFace(actor.faceName());
  353.         }, this);
  354.     };
  355.  
  356.     COLD.shopAbleToEquipWindow.prototype.drawItem = function(index) {
  357.         if(this._item && !DataManager.isItem(this._item)) this.drawItemImage(index);
  358.     };
  359.  
  360.     COLD.shopAbleToEquipWindow.prototype.drawItemImage = function(index) {
  361.         var actor = this.equipAbleList(this._item)[index];
  362.         var rect = this.itemRect(index);
  363.         if(actor) this.drawActorFace(actor, rect.x + 9, rect.y + 9, 100, 100);
  364.     };
  365.  
  366.     COLD.shopAbleToEquipWindow.prototype.equipAbleList = function(item){
  367.         var array = [];
  368.         $gameParty.members().forEach(function(actor){
  369.             if(actor.canEquip(item))array.push(actor);
  370.         }, this);
  371.         return array;
  372.     };
  373.  
  374.     COLD.shopAbleToEquipWindow.prototype.windowWidth = function(){
  375.         return 100 + this.standardPadding() * 3;
  376.     };
  377.  
  378.     COLD.shopAbleToEquipWindow.prototype.windowHeight = function(){
  379.         return Graphics.height - 100;
  380.     };
  381.  
  382.     COLD.shopAbleToEquipWindow.prototype.maxItems = function() {
  383.         return this.equipAbleList(this._item).length || 1;
  384.     };
  385.  
  386.     COLD.shopAbleToEquipWindow.prototype.itemHeight = function() {
  387.         return 118;
  388.     };
  389.  
  390.     COLD.shopAbleToEquipWindow.prototype.itemWidth = function() {
  391.         return 118;
  392.     };
  393.  
  394.     COLD.shopAbleToEquipWindow.prototype.numVisibleRows = function() {
  395.         return 4;
  396.     };
  397.  
  398.     COLD.shopAbleToEquipWindow.prototype.spacing = function() {
  399.         return 0;
  400.     };
  401.  
  402.     COLD.shopAbleToEquipWindow.prototype.maxCols = function() {
  403.         return 1;
  404.     };
  405.  
  406.     COLD.shopAbleToEquipWindow.prototype.selectLast = function() {
  407.         this.select(0);
  408.     };
  409.  
  410.     /**
  411.     * Window to draw the selectable icons.
  412.     */
  413.  
  414.     COLD.shopIconSelectWindow = function() {
  415.         this.initialize.apply(this, arguments);
  416.     }
  417.  
  418.     COLD.shopIconSelectWindow.prototype = Object.create(Window_Selectable.prototype);
  419.     COLD.shopIconSelectWindow.prototype.constructor = COLD.shopIconSelectWindow;
  420.  
  421.     //Define variables.
  422.     COLD.shopIconSelectWindow.prototype.lastIndex = -1;
  423.     COLD.shopIconSelectWindow.prototype.updateIcons = false;
  424.     COLD.shopIconSelectWindow.prototype.currentItems = [];
  425.  
  426.     COLD.shopIconSelectWindow.prototype.initialize = function(x, y, goods) {
  427.         this._goods = goods;
  428.         var width = this.windowWidth();
  429.         var height = this.windowHeight();
  430.         Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  431.         this._pendingIndex = -1;
  432.         this.refresh();
  433.         this.activate();
  434.         this.select(0);
  435.     };
  436.  
  437.     COLD.shopIconSelectWindow.prototype.maxItems = function() {
  438.         var items = [];
  439.         var length = this._goods.length;
  440.         for(var i = 0; i < length; i++){
  441.             if(this._goods[i][0] == this.equipType) items.push(this._goods[i]);
  442.         };
  443.         return items.length || 1;
  444.     };
  445.  
  446.     COLD.shopIconSelectWindow.prototype.itemHeight = function() {
  447.         return 50;
  448.     };
  449.  
  450.     COLD.shopIconSelectWindow.prototype.itemWidth = function() {
  451.         return 50;
  452.     };
  453.  
  454.     COLD.shopIconSelectWindow.prototype.numVisibleRows = function() {
  455.         return 1;
  456.     };
  457.  
  458.     COLD.shopIconSelectWindow.prototype.spacing = function() {
  459.         return this.standardPadding();
  460.     };
  461.  
  462.     COLD.shopIconSelectWindow.prototype.maxCols = function() {
  463.         return this.maxItems() || 1;
  464.     };
  465.  
  466.     COLD.shopIconSelectWindow.prototype.itemRect = function(index) {
  467.         var rect = new Rectangle();
  468.         var maxCols = this.maxCols();
  469.         rect.width = this.itemWidth();
  470.         rect.height = this.itemHeight();
  471.         rect.x = index % maxCols * (rect.width + this.spacing()) - this._scrollX + 9;
  472.         rect.y = Math.floor(index / maxCols) * rect.height - this._scrollY + 9;
  473.         return rect;
  474.     };
  475.  
  476.     COLD.shopIconSelectWindow.prototype.selectLast = function() {
  477.         this.select(0);
  478.     };
  479.  
  480.     COLD.shopIconSelectWindow.prototype.equipType = null;
  481.  
  482.     COLD.shopIconSelectWindow.prototype.windowWidth = function() {
  483.         return Graphics.width;
  484.     };
  485.  
  486.     COLD.shopIconSelectWindow.prototype.windowHeight = function() {
  487.         return 100;
  488.     };
  489.  
  490.     //What we do on each update.
  491.     COLD.shopIconSelectWindow.prototype.update = function() {
  492.         Window_Selectable.prototype.update.call(this);
  493.         this.refresh();
  494.         if(this.index() != this.lastIndex || this.updateIcons == true){
  495.             this.currentItems = [];
  496.             for(var i = 0; i < this._goods.length; i++){
  497.                 if(this._goods[i][0] == COLD.shopIconSelectWindow.prototype.equipType){
  498.                     this.currentItems.push(this._goods[i])
  499.                 };
  500.             };
  501.             var itemNumber = this.currentItems[this.index()];
  502.             var price = null;
  503.             if(this.equipType == 0){
  504.                 COLD.shopItemWindow.prototype.currentItem = $dataItems[itemNumber[1]];
  505.                 price = (itemNumber[2] === 0) ? $dataItems[this.currentItems[this.index()][1]].price : itemNumber[3];
  506.             }
  507.             if(this.equipType == 1){
  508.                 COLD.shopDescriptionWindow.prototype.currentItem = $dataWeapons[itemNumber[1]];
  509.                 price = (itemNumber[2] === 0) ? $dataWeapons[this.currentItems[this.index()][1]].price : itemNumber[3];
  510.             }
  511.             if(this.equipType == 2){
  512.                 COLD.shopDescriptionWindow.prototype.currentItem = $dataArmors[itemNumber[1]];
  513.                 price = (itemNumber[2] === 0) ? $dataArmors[this.currentItems[this.index()][1]].price : itemNumber[3];
  514.             };
  515.             COLD.shopPurchaseCommandWindow.prototype.currentPrice = price;
  516.             this.lastIndex = this.index();
  517.         };
  518.     };
  519.  
  520.     COLD.shopIconSelectWindow.prototype.drawItem = function(index) {
  521.         this.drawItemIcons(index);
  522.     };
  523.  
  524.     COLD.shopIconSelectWindow.prototype.drawItemIcons = function(index){
  525.         var iconIndex = null;
  526.         this.items = [];
  527.    
  528.         var length = this._goods.length;
  529.         for(var i = 0; i < length; i++){
  530.             if(this._goods[i][0] == COLD.shopIconSelectWindow.prototype.equipType){
  531.                 this.items.push(this._goods[i])
  532.             };
  533.         };
  534.  
  535.    
  536.         switch(this.equipType) {
  537.             case 0:
  538.                 iconIndex = $dataItems[this.items[index][1]].iconIndex;
  539.                 break;
  540.             case 1:
  541.                 iconIndex = $dataWeapons[this.items[index][1]].iconIndex;
  542.                 break;
  543.             case 2:
  544.                 iconIndex = $dataArmors[this.items[index][1]].iconIndex;
  545.                 break;
  546.         };
  547.         var rect = this.itemRect(index);
  548.         this.drawIcon(iconIndex, rect.x + 9, rect.y + 9)
  549.     };
  550.    
  551.     /**
  552.     * Window to select options to buy or sell.
  553.     */
  554.    
  555.     COLD.shopOptionsWindow = function() {
  556.         this.initialize.apply(this, arguments);
  557.     }
  558.  
  559.     COLD.shopOptionsWindow.prototype = Object.create(Window_HorzCommand.prototype);
  560.     COLD.shopOptionsWindow.prototype.constructor = COLD.shopOptionsWindow;
  561.  
  562.     COLD.shopOptionsWindow.prototype.initialize = function(x, y, purchaseOnly) {
  563.         this._purchaseOnly = purchaseOnly;
  564.         Window_HorzCommand.prototype.initialize.call(this, x, y);
  565.         this.drawOptionsText();
  566.     };
  567.  
  568.     COLD.shopOptionsWindow.prototype.windowWidth = function() {
  569.         return Graphics.width;
  570.     };
  571.  
  572.     COLD.shopOptionsWindow.prototype.windowHeight = function() {
  573.         return 170;
  574.     };
  575.  
  576.     COLD.shopOptionsWindow.prototype.maxCols = function() {
  577.         return 3;
  578.     };
  579.  
  580.     COLD.shopOptionsWindow.prototype.drawOptionsText = function(){
  581.         this.drawText(COLD.Param.ShopOptionsText, 0, 0 , this.windowWidth(), 'center');
  582.     };
  583.  
  584.     COLD.shopOptionsWindow.prototype.itemRect = function(index) {
  585.         var rect = new Rectangle();
  586.         var maxCols = this.maxCols();
  587.         rect.width = this.itemWidth();
  588.         rect.height = this.itemHeight();
  589.         rect.x = index % maxCols * (rect.width + this.spacing()) - this._scrollX;
  590.         rect.y = Math.floor(index / maxCols) * rect.height - this._scrollY + 100;
  591.         return rect;
  592.     };
  593.  
  594.     COLD.shopOptionsWindow.prototype.itemRectForText = function(index) {
  595.         var rect = this.itemRect(index);
  596.         rect.x += this.textPadding();
  597.         rect.width -= this.textPadding() * 2;
  598.         return rect;
  599.     };
  600.  
  601.     COLD.shopOptionsWindow.prototype.makeCommandList = function() {
  602.         this.addCommand(TextManager.buy,    'buy');
  603.         this.addCommand(TextManager.sell,   'sell',   !this._purchaseOnly);
  604.         this.addCommand(TextManager.cancel, 'cancel');
  605.     };
  606.  
  607.     /**
  608.     * Window to select items, weapons, or armors.
  609.     */
  610.  
  611.     COLD.shopCategoryWindow = function() {
  612.         this.initialize.apply(this, arguments);
  613.     }
  614.  
  615.     COLD.shopCategoryWindow.prototype = Object.create(Window_HorzCommand.prototype);
  616.     COLD.shopCategoryWindow.prototype.constructor = COLD.shopCategoryWindow;
  617.  
  618.     COLD.shopCategoryWindow.prototype.initialize = function(x, y, goods) {
  619.         this._goods = goods;
  620.         Window_HorzCommand.prototype.initialize.call(this, x, y);
  621.         this.refresh();
  622.     };
  623.  
  624.     COLD.shopCategoryWindow.prototype.windowWidth = function() {
  625.         return Graphics.width;
  626.     };
  627.  
  628.     COLD.shopCategoryWindow.prototype.windowHeight = function() {
  629.         return 170;
  630.     };
  631.  
  632.     COLD.shopCategoryWindow.prototype.maxCols = function() {
  633.         return 3;
  634.     };
  635.  
  636.     COLD.shopCategoryWindow.prototype.drawCategory = null;
  637.  
  638.     COLD.shopCategoryWindow.prototype.refresh = function(){
  639.         Window_Command.prototype.refresh.call(this);
  640.             this.drawCategoryText();
  641.     }
  642.  
  643.     COLD.shopCategoryWindow.prototype.drawCategoryText = function(){
  644.         if(this.drawCategory == 'buy'){
  645.             this.drawText(COLD.Param.ShopBuyText, 0, 0 , this.windowWidth(), 'center');
  646.         }else if (this.drawCategory == 'sell'){
  647.             this.drawText(COLD.Param.ShopSellText, 0, 0 , this.windowWidth(), 'center');
  648.         }else{}
  649.     };
  650.  
  651.     COLD.shopCategoryWindow.prototype.checkForItems = function(){
  652.         var haveItems = false;
  653.         for(var i = 0; i < this._goods.length; i++){
  654.             if(this._goods[i][0] == 0){
  655.             var haveItems = true;
  656.             };
  657.         };
  658.         return haveItems;
  659.     };
  660.  
  661.     COLD.shopCategoryWindow.prototype.checkForWeapons = function(){
  662.         var haveWeapons = false;
  663.         for(var i = 0; i < this._goods.length; i++){
  664.             if(this._goods[i][0] == 1){
  665.             var haveWeapons = true;
  666.             };
  667.         };
  668.         return haveWeapons;
  669.     };
  670.  
  671.     COLD.shopCategoryWindow.prototype.checkForArmors = function(){
  672.         var haveArmors = false;
  673.         for(var i = 0; i < this._goods.length; i++){
  674.             if(this._goods[i][0] == 2) var haveArmors = true;
  675.         };
  676.         return haveArmors; 
  677.     };
  678.  
  679.     COLD.shopCategoryWindow.prototype.itemRect = function(index) {
  680.         var rect = new Rectangle();
  681.         var maxCols = this.maxCols();
  682.         rect.width = this.itemWidth();
  683.         rect.height = this.itemHeight();
  684.         rect.x = index % maxCols * (rect.width + this.spacing()) - this._scrollX;
  685.         rect.y = Math.floor(index / maxCols) * rect.height - this._scrollY + 100;
  686.         return rect;
  687.     };
  688.  
  689.     COLD.shopCategoryWindow.prototype.itemRectForText = function(index) {
  690.         var rect = this.itemRect(index);
  691.         rect.x += this.textPadding();
  692.         rect.width -= this.textPadding() * 2;
  693.         return rect;
  694.     };
  695.  
  696.     COLD.shopCategoryWindow.prototype.makeCommandList = function() {
  697.         this.addCommand(TextManager.item,    'item', this.checkForItems());
  698.         this.addCommand(TextManager.weapon,  'weapon', this.checkForWeapons());
  699.         this.addCommand(TextManager.armor,   'armor', this.checkForArmors());
  700.     };
  701.    
  702.     /**
  703.     * Window to select purchase,compare or buy.
  704.     */
  705.    
  706.     COLD.shopPurchaseCommandWindow = function() {
  707.         this.initialize.apply(this, arguments);
  708.     }
  709.  
  710.     COLD.shopPurchaseCommandWindow.prototype = Object.create(Window_HorzCommand.prototype);
  711.     COLD.shopPurchaseCommandWindow.prototype.constructor = COLD.shopPurchaseCommandWindow;
  712.  
  713.     COLD.shopPurchaseCommandWindow.prototype.initialize = function(x, y) {
  714.         Window_HorzCommand.prototype.initialize.call(this, x, y);
  715.     };
  716.  
  717.     COLD.shopPurchaseCommandWindow.prototype.windowWidth = function() {
  718.         return Graphics.width;
  719.     };
  720.  
  721.     COLD.shopPurchaseCommandWindow.prototype.windowHeight = function() {
  722.         return 100;
  723.     };
  724.  
  725.     COLD.shopPurchaseCommandWindow.prototype.maxCols = function() {
  726.         return 3;
  727.     };
  728.    
  729.     COLD.shopPurchaseCommandWindow.prototype.currentPrice = 0;
  730.    
  731.     COLD.shopPurchaseCommandWindow.prototype.makeCommandList = function() {
  732.         var enabled = (this.currentPrice <= $gameParty._gold);
  733.         this.addCommand('Purchase', 'purchase', enabled);
  734.         var actorList = COLD.shopAbleToEquipWindow.prototype.equipAbleList(COLD.shopDescriptionWindow.prototype.currentItem);
  735.         var enabled = actorList.length > 0;
  736.         this.addCommand('Compare', 'compare', enabled);
  737.         this.addCommand('Cancel',  'cancel');
  738.     };
  739.    
  740.     /**
  741.     * Window up list of items to sell.
  742.     */
  743.  
  744.     COLD.Window_ShopSell = function() {
  745.         this.initialize.apply(this, arguments);
  746.     }
  747.  
  748.     COLD.Window_ShopSell.prototype = Object.create(Window_ItemList.prototype);
  749.     COLD.Window_ShopSell.prototype.constructor = COLD.Window_ShopSell;
  750.  
  751.     COLD.Window_ShopSell.prototype.initialize = function(x, y, width, height) {
  752.         Window_ItemList.prototype.initialize.call(this, x, y, width, height);
  753.     };
  754.  
  755.     COLD.Window_ShopSell.prototype.isEnabled = function(item) {
  756.         return item && item.price > 0;
  757.     };
  758. })();
  759.  
  760.     /**
  761.     * Override Scene_Shop
  762.     */
  763.    
  764. function Scene_Shop() {
  765.     this.initialize.apply(this, arguments);
  766. }
  767.  
  768. Scene_Shop.prototype = Object.create(Scene_MenuBase.prototype);
  769. Scene_Shop.prototype.constructor = Scene_Shop;
  770.  
  771. Scene_Shop.prototype.initialize = function() {
  772.    
  773.     Scene_MenuBase.prototype.initialize.call(this);
  774. };
  775.  
  776. Scene_Shop.prototype.createBackground = function() {
  777.     if(COLD.Param.ShopBBDefault === 'true'){
  778.         this._backSprite1 = new Sprite(ImageManager.loadBattleback1($gameMap.battleback1Name()));
  779.         this._backSprite2 = new Sprite(ImageManager.loadBattleback2($gameMap.battleback2Name()));
  780.     }else{
  781.         this._backSprite1 = new Sprite(ImageManager.loadBattleback1(COLD.Param.ShopBBOverride1));
  782.         this._backSprite2 = new Sprite(ImageManager.loadBattleback2(COLD.Param.ShopBBOverride2));      
  783.     };
  784.     this.addChild(this._backSprite1);
  785.     this.addChild(this._backSprite2);
  786. };
  787.  
  788. Scene_Shop.prototype.createShopKeeper = function() {
  789.     if(COLD.Param.ShopKEnabled === 'true'){
  790.         var bitmap = ImageManager.loadPicture(COLD.Param.ShopKPicture)
  791.         bitmap.addLoadListener(function() {
  792.             this._shopkeeper = new Sprite(bitmap);
  793.             this._shopkeeper.setFrame(COLD.Param.ShopxAdjust, COLD.Param.ShopyAdjust, this._shopkeeper.width, this._shopkeeper.height);
  794.             this.addChild(this._shopkeeper);
  795.       }.bind(this));
  796.     };
  797. };
  798.  
  799. Scene_Shop.prototype.centerSprite = function(sprite) {
  800.     var swidth = sprite.width;
  801.     var sheight  = sprite.height;
  802.    
  803.     if(swidth < Graphics.width) sprite.scale.x = Graphics.width/sprite.width;
  804.     else sprite.scale.x = sprite.width/Graphics.width;
  805.     if(sheight < Graphics.height) sprite.scale.y = Graphics.height/sprite.height;
  806.     else sprite.scale.y = sprite.height/Graphics.height;
  807.  
  808.     sprite.x = Graphics.width / 2;
  809.     sprite.y = Graphics.height / 2;
  810.     sprite.anchor.x = 0.5;
  811.     sprite.anchor.y = 0.5;
  812. };
  813.  
  814. Scene_Shop.prototype.prepare = function(goods, purchaseOnly) {
  815.     this._goods = goods;
  816.     this._purchaseOnly = purchaseOnly;
  817.     this._item = null;
  818. };
  819.  
  820. Scene_Shop.prototype.create = function() {
  821.    Scene_MenuBase.prototype.create.call(this);
  822.     this.createBackground();
  823.     this.createWindowLayer();
  824.     this.createShopKeeper();
  825.     this.createDescriptionWindow();
  826.     this.createAbleToEquipWindow();
  827.     this.createCommandWindow();
  828.     this.createIconWindow();
  829.     this.createCategoryWindow();
  830.     this.createPurchaseWindow();
  831.     this.createItemWindow();
  832.     this.createNumberWindow();
  833.     this.createSellWindow();
  834. };
  835.  
  836. Scene_Shop.prototype.start = function() {
  837.     if(COLD.Param.ShopBBEnabled === 'true'){
  838.         this.centerSprite(this._backSprite1);
  839.         this.centerSprite(this._backSprite2);
  840.     };
  841. };
  842. Scene_Shop.prototype.createSellWindow = function() {
  843.     var y = COLD.shopDescriptionWindow.prototype.windowHeight()-70;
  844.     this._sellWindow = new COLD.Window_ShopSell(0, y, Graphics.boxWidth, Graphics.boxHeight - y);
  845.     this._sellWindow.hide();
  846.     this._sellWindow.deactivate();
  847.     this._sellWindow.refresh();
  848.     this._sellWindow.setHandler('ok',     this.onSellOk.bind(this));
  849.     this._sellWindow.setHandler('cancel', this.onSellCanceled.bind(this));
  850.     this.addWindow(this._sellWindow);
  851. };
  852.  
  853. Scene_Shop.prototype.onSellOk = function() {
  854.     this._item = this._sellWindow.item();
  855.     this._numberWindow.setup(this._item, this.maxSell(), this.sellingPrice());
  856.     this._numberWindow.setCurrencyUnit(this.currencyUnit());
  857.     this._numberWindow.show();
  858.     this._numberWindow.activate();
  859.     this._numberWindow.showButtons();
  860. };
  861.  
  862. Scene_Shop.prototype.maxSell = function() {
  863.     return $gameParty.numItems(this._item);
  864. };
  865.  
  866. Scene_Shop.prototype.sellingPrice = function() {
  867.     return Math.floor(this._item.price / 2);
  868. };
  869.  
  870. Scene_Shop.prototype.onSellCanceled = function() {
  871.     this._sellWindow.hide();
  872.     this._sellWindow.deactivate();
  873.     this._categoryWindow.show();
  874.     this._categoryWindow.activate();
  875.     this.updateShopKeeper(255);
  876. };
  877. Scene_Shop.prototype.createDescriptionWindow = function() {
  878.     this._descriptionWindow = new COLD.shopDescriptionWindow(0, 0);
  879.     this._descriptionWindow.hide();
  880.     this.addWindow(this._descriptionWindow );
  881. };
  882.  
  883. Scene_Shop.prototype.createCommandWindow = function() {
  884.     this._commandWindow = new COLD.shopOptionsWindow(0, COLD.shopDescriptionWindow.prototype.windowHeight() - 70,this._purchaseOnly);
  885.     this._commandWindow.setHandler('buy',    this.commandBuy.bind(this));
  886.     this._commandWindow.setHandler('sell',   this.commandSell.bind(this));
  887.     this._commandWindow.setHandler('cancel', this.popScene.bind(this));
  888.     this.addWindow(this._commandWindow);
  889. };
  890.  
  891. Scene_Shop.prototype.createCategoryWindow = function() {
  892.     this._categoryWindow = new COLD.shopCategoryWindow(0, COLD.shopDescriptionWindow.prototype.windowHeight()-70, this._goods);
  893.     this._categoryWindow.hide();
  894.     this._categoryWindow.deactivate();
  895.     this._categoryWindow.setHandler('item',    this.commandItem.bind(this));
  896.     this._categoryWindow.setHandler('weapon',   this.commandWeapon.bind(this));
  897.     this._categoryWindow.setHandler('armor', this.commandArmor.bind(this));
  898.     this._categoryWindow.setHandler('cancel', this.activateCommand.bind(this));
  899.     this.addWindow(this._categoryWindow);
  900. };
  901. Scene_Shop.prototype.createPurchaseWindow = function() {
  902.     this._purchaseWindow = new COLD.shopPurchaseCommandWindow(0, COLD.shopDescriptionWindow.prototype.windowHeight());
  903.     this._purchaseWindow.hide();
  904.     this._purchaseWindow.deactivate();
  905.     this._purchaseWindow.setHandler('purchase',    this.onPurchase.bind(this));
  906.     this._purchaseWindow.setHandler('compare',   this.onSelectionCompare.bind(this));
  907.     this._purchaseWindow.setHandler('cancel', this.onPurchaseCancel.bind(this));
  908.     this.addWindow(this._purchaseWindow);
  909. };
  910.  
  911. Scene_Shop.prototype.createItemWindow = function() {
  912.     var y = COLD.shopDescriptionWindow.prototype.windowHeight();
  913.     this._itemWindow = new COLD.shopItemWindow(0, y - COLD.shopItemWindow.prototype.windowHeight());
  914.     this._itemWindow.hide();
  915.     this.addWindow(this._itemWindow);
  916. };
  917.  
  918. Scene_Shop.prototype.onPurchase = function(){
  919.     switch (this._categoryWindow.currentSymbol()) {
  920.         case 'item':
  921.             this._item = COLD.shopItemWindow.prototype.currentItem;
  922.             break;
  923.         case 'weapon':
  924.             this._item = COLD.shopDescriptionWindow.prototype.currentItem;
  925.             break;
  926.         case 'armor':
  927.             this._item = COLD.shopDescriptionWindow.prototype.currentItem;
  928.             break;
  929.     };
  930.     this._numberWindow.setup(this._item, this.maxBuy(), this.buyingPrice());
  931.     this._numberWindow.setCurrencyUnit(this.currencyUnit());
  932.     this._numberWindow.show();
  933.     this._numberWindow.showButtons();
  934.     this._numberWindow.refresh();
  935.     this._numberWindow.activate();
  936. };
  937.  
  938. Scene_Shop.prototype.maxBuy = function() {
  939.     var max = $gameParty.maxItems(this._item) - $gameParty.numItems(this._item);
  940.     var price = this.buyingPrice();
  941.     if (price > 0) {
  942.         return Math.min(max, Math.floor(this.money() / price));
  943.     } else {
  944.         return max;
  945.     };
  946. };
  947.  
  948. Scene_Shop.prototype.money = function() {
  949.     return $gameParty.gold();
  950. };
  951.  
  952. Scene_Shop.prototype.currencyUnit = function() {
  953.     return TextManager.currencyUnit;
  954. };
  955.  
  956. Scene_Shop.prototype.buyingPrice = function() {
  957.     return this._item.price;
  958. };
  959.  
  960. Scene_Shop.prototype.onPurchaseCancel = function(){
  961.     this._purchaseWindow.hide();
  962.     this._iconWindow.activate();
  963.     this._iconWindow.show();
  964. };
  965.  
  966. Scene_Shop.prototype.activateCommand = function() {
  967.     this._categoryWindow.hide();
  968.     this._commandWindow.show();
  969.     this._commandWindow.activate();
  970. }
  971.  
  972. Scene_Shop.prototype.commandBuy = function() {
  973.     COLD.shopCategoryWindow.prototype.drawCategory = 'buy';
  974.     this._commandWindow.hide();
  975.     this._categoryWindow.show();
  976.     this._commandWindow.deactivate();
  977.     this._categoryWindow.activate();
  978.     this._categoryWindow.refresh();
  979. };
  980.  
  981. Scene_Shop.prototype.commandSell = function() {
  982.     COLD.shopCategoryWindow.prototype.drawCategory = 'sell';
  983.     this._commandWindow.hide();
  984.     this._commandWindow.deactivate();
  985.     this._categoryWindow.show();
  986.     this._categoryWindow.activate();
  987.     this._categoryWindow.refresh();
  988. };
  989.  
  990. Scene_Shop.prototype.commandItem = function() {
  991.     switch (this._commandWindow.currentSymbol()) {
  992.         case 'buy':
  993.             this.updateShopKeeper(0);
  994.             this._categoryWindow.hide();
  995.             COLD.shopIconSelectWindow.prototype.updateIcons = true;
  996.             COLD.shopIconSelectWindow.prototype.equipType = 0;
  997.             this._itemWindow.show();
  998.             this._iconWindow.activate();
  999.             this._iconWindow.show();
  1000.                 break;
  1001.         case 'sell':
  1002.             this.updateShopKeeper(0);
  1003.             this._categoryWindow.hide();
  1004.             this._sellWindow.setCategory('item');
  1005.             this._sellWindow.refresh();
  1006.             this._sellWindow.show();
  1007.             this._sellWindow.activate();
  1008.             this._sellWindow.select(0);
  1009.                 break;
  1010.     };
  1011. };
  1012.  
  1013. Scene_Shop.prototype.updateShopKeeper = function(number){
  1014.     if(COLD.Param.ShopKEnabled === 'true')this._shopkeeper.opacity = number;
  1015. };
  1016.  
  1017. Scene_Shop.prototype.commandWeapon = function() {
  1018.         switch (this._commandWindow.currentSymbol()) {
  1019.     case 'buy':
  1020.         this.updateShopKeeper(0);
  1021.         this._categoryWindow.hide();
  1022.         COLD.shopIconSelectWindow.prototype.updateIcons = true;
  1023.         COLD.shopIconSelectWindow.prototype.equipType = 1;
  1024.         this._ableToEquipWindow.show();
  1025.         this._ableToEquipWindow.refresh();
  1026.         this._descriptionWindow.show();
  1027.         this._iconWindow.activate();
  1028.         this._iconWindow.show();
  1029.             break;
  1030.     case 'sell':
  1031.         this.updateShopKeeper(0);
  1032.         this._sellWindow.setCategory('weapon');
  1033.         this._categoryWindow.hide();
  1034.         this._sellWindow.refresh();
  1035.         this._sellWindow.show();
  1036.         this._sellWindow.activate();
  1037.         this._sellWindow.select(0);
  1038.             break;
  1039.     };
  1040. };
  1041. Scene_Shop.prototype.commandArmor = function() {
  1042.         switch (this._commandWindow.currentSymbol()) {
  1043.     case 'buy':
  1044.     this.updateShopKeeper(0);
  1045.     COLD.shopIconSelectWindow.prototype.updateIcons = true;
  1046.     COLD.shopIconSelectWindow.prototype.equipType = 2;
  1047.     this._descriptionWindow.show();
  1048.     this._ableToEquipWindow.show();
  1049.     this._ableToEquipWindow.refresh();
  1050.     this._iconWindow.activate();
  1051.     this._iconWindow.show();
  1052.         break;
  1053.     case 'sell':
  1054.         this.updateShopKeeper(0);
  1055.         this._categoryWindow.hide();
  1056.         this._sellWindow.activate();
  1057.         this._sellWindow.show();
  1058.         this._sellWindow.setCategory('armor');
  1059.         this._sellWindow.refresh();
  1060.         this._sellWindow.select(0);
  1061.         break;
  1062.     }
  1063.     this._categoryWindow.hide();
  1064.  
  1065. };
  1066.  
  1067. Scene_Shop.prototype.onSelectionCancel = function() {
  1068.     this._categoryWindow.show();
  1069.     this.updateShopKeeper(255);
  1070.     COLD.shopIconSelectWindow.prototype.updateIcons = false;
  1071.     this._categoryWindow.activate();
  1072.     this._descriptionWindow.hide();
  1073.     this._descriptionWindow.contents.clear();
  1074.     this._ableToEquipWindow.hide();
  1075.     this._itemWindow.hide();
  1076.     this._iconWindow.hide();
  1077.     COLD.shopDescriptionWindow.prototype.currentItem = null;
  1078.     COLD.shopIconSelectWindow.prototype.equipType = null;
  1079.     this._iconWindow.select(0);
  1080. };
  1081.  
  1082. Scene_Shop.prototype.onSelectionCompare = function(){
  1083.     this._ableToEquipWindow.activate();
  1084. };
  1085.  
  1086. Scene_Shop.prototype.onSelectionOk = function() {
  1087.     this._iconWindow.hide();
  1088.     this._purchaseWindow.show();
  1089.     this._purchaseWindow.activate();
  1090.     this._purchaseWindow.refresh();
  1091. }
  1092.  
  1093. Scene_Shop.prototype.createIconWindow = function() {
  1094.     this._iconWindow = new COLD.shopIconSelectWindow(0, COLD.shopDescriptionWindow.prototype.windowHeight(), this._goods);
  1095.     this._iconWindow.setHandler('cancel', this.onSelectionCancel.bind(this));
  1096.     this._iconWindow.setHandler('ok', this.onSelectionOk.bind(this));
  1097.     this._iconWindow.hide();
  1098.     this._iconWindow.deactivate();
  1099.     this.addWindow(this._iconWindow );
  1100. };
  1101.  
  1102. Scene_Shop.prototype.onCompareCancel = function(){
  1103.     this._ableToEquipWindow.deactivate();
  1104.     this._purchaseWindow.activate();
  1105. }
  1106.  
  1107. Scene_Shop.prototype.createAbleToEquipWindow = function() {
  1108.     this._ableToEquipWindow = new COLD.shopAbleToEquipWindow(COLD.shopDescriptionWindow.prototype.windowWidth(), 0);
  1109.     this._ableToEquipWindow.setHandler('cancel', this.onCompareCancel.bind(this));
  1110.     this._ableToEquipWindow.hide();
  1111.     this._ableToEquipWindow.deactivate();
  1112.     this.addWindow(this._ableToEquipWindow);
  1113. };
  1114.  
  1115. Scene_Shop.prototype.createNumberWindow = function() {
  1116.     //illuminati
  1117.     this._numberWindow = new Window_ShopNumber(0, 0, 330);
  1118.     this._numberWindow.hide();
  1119.     this._numberWindow.setHandler('ok',     this.onNumberOk.bind(this));
  1120.     this._numberWindow.setHandler('cancel', this.onNumberCancel.bind(this));
  1121.     this.addWindow(this._numberWindow);
  1122. };
  1123.  
  1124. Scene_Shop.prototype.onNumberOk = function() {
  1125.     SoundManager.playShop();
  1126.     switch (this._commandWindow.currentSymbol()) {
  1127.     case 'buy':
  1128.         this.doBuy(this._numberWindow.number());
  1129.         break;
  1130.     case 'sell':
  1131.         this.doSell(this._numberWindow.number());
  1132.         this._sellWindow.refresh();
  1133.         break;
  1134.     }
  1135.     this._purchaseWindow.refresh();
  1136.     this.endNumberInput();
  1137. };
  1138.  
  1139. Scene_Shop.prototype.onNumberCancel = function() {
  1140.     SoundManager.playCancel();
  1141.     this.endNumberInput();
  1142. };
  1143.  
  1144. Scene_Shop.prototype.doBuy = function(number) {
  1145.     $gameParty.loseGold(number * this.buyingPrice());
  1146.     $gameParty.gainItem(this._item, number);
  1147. };
  1148.  
  1149. Scene_Shop.prototype.doSell = function(number) {
  1150.     $gameParty.gainGold(number * this.sellingPrice());
  1151.     $gameParty.loseItem(this._item, number);
  1152. };
  1153.  
  1154. Scene_Shop.prototype.endNumberInput = function() {
  1155.     this._numberWindow.hide();
  1156.     switch (this._commandWindow.currentSymbol()) {
  1157.     case 'buy':
  1158.      this._purchaseWindow.activate();
  1159.         break;
  1160.     case 'sell':
  1161.         this._sellWindow.show();
  1162.         this._sellWindow.activate();
  1163.         break;
  1164.     }
  1165. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement