class Scene_Shop2
  #--------------------------------------------------------------------------
  # ● [覆盖]更新买入选择
  #--------------------------------------------------------------------------
  def update_buy_selection1
    @status_window.item = @buy_window.item 
    if Input.trigger?(Input::B) 
      Sound.play_cancel 
      @command_window2.active = true
      @buy_window.active = false 
      @buy_window.visible = false 
      @status_window.visible = false 
      @status_window.item = nil 
      @help_window.set_text("") 
      return 
    end
    if Input.trigger?(Input::C) 
      @item = @buy_window.item 
      number = $game_party.item_number(@item) 
      if $imported["LimitBreak"] == true
        if @item == nil || @item.price > $game_party.gold || 
          number == @item.max_limit ## 可购入数量修正
          Sound.play_buzzer 
        else 
          Sound.play_decision 
          #=========================================可购入数量修正===========
          max = (@item.price == 0 ? 
          @item.max_limit : $game_party.gold / @item.price) 
          max = [max, @item.max_limit - number].min 
          #==================================================================
          @buy_window.active = false 
          @buy_window.visible = false 
          @number_window.set(@item, max, @item.price) 
          @number_window.active = true 
          @number_window.visible = true 
        end
      else
        if @item == nil or @item.price > $game_party.gold ||
          number >= @item.max_limit ## 可购入数量修正
          Sound.play_buzzer 
        else
          Sound.play_decision
          #=========================================可购入数量修正===========
          max = @item.price == 0 ? @item.max_limit : $game_party.gold / @item.price
          max = [max, @item.max_limit - number].min
          #==================================================================
          @buy_window.active = false
          @buy_window.visible = false
          @number_window.set(@item, max, @item.price)
          @number_window.active = true
          @number_window.visible = true
        end
      end
    end
    if Input.trigger?(Input::RIGHT)
      Sound.play_cursor
      next_actor
    elsif Input.trigger?(Input::LEFT)
      Sound.play_cursor
      prev_actor
    end
    if Input.trigger?(Input::X)
      @buy_window.sort_item
    end
  end
end

class Window_ShopBuy2
  #--------------------------------------------------------------------------
  # ● [覆盖]绘制商品
  #--------------------------------------------------------------------------
  def draw_item1(index)
    if    @type == 0
      item = @data1[index]
    elsif @type == 1
      item = @data2[index]
    else
      item = @data3[index]
    end 
    number = $game_party.item_number(item) 
    if $imported["LimitBreak"] == true
      enabled = (item.price <= $game_party.gold && number < item.max_limit)## 可购入数量修正 
    else
      enabled = (item.price <= $game_party.gold && number < item.max_limit)## 可购入数量修正
    end
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    draw_item_name(item, rect.x, rect.y, enabled)
    rect.width -= 4
    self.contents.draw_text(rect, item.price, 2)
  end
end