#==============================================================================
# 
# ▼ Vel System - Shop: Sell Only v1.10
# -- Last Updated: 3/16/2013
# -- Author: Ven01273
# -- Level: Normal
# -- Requires: n/a
#  *Inspired by Star Stealing Prince's Numismatist
#==============================================================================

$imported = {} if $imported.nil?
$imported["VS-SSO"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 3/16/2013 - Added Yanfly Engine Ace - Ace Shop Options compatibility.
# 3/8/2013 - Fixed script breaking bug.
# 2/8/2013 - Finished Script.
# 2/4/2013 - Started Script.
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script allows you to allow the shop only to buy things from you.
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials but above ▼ Main Process. Remember to save.
#
# To make a shop sell only, use the following script command before it. Remember
# to use it again after shop processing.
#
# call_sell_only
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script was made with RGSS3. I don't use the other versions, so I don't
# know if it'll work. See for yourself.
#==============================================================================
# ▼ Commercial?
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Yes, this script can be used in commercial games.
#==============================================================================

#==============================================================================
# Don't edit anything past this point, unless you know what you're doing.
#==============================================================================

#--------------------------------------------------------------------------
# * New Global Variable
#--------------------------------------------------------------------------

class Game_Temp
  attr_accessor :shop_sell_only
end

#--------------------------------------------------------------------------
# * Edit Script: Yanfly Engine Ace - Ace Shop Options
#--------------------------------------------------------------------------

if $imported["YEA-ShopOptions"] == true
#--------------------------------------------------------------------------
# * Overwrite Method: draw_item
#--------------------------------------------------------------------------
class Window_ShopBuy < Window_Selectable
  def draw_item(index)
    if @sell_only == false
    item = @data[index]
    return if item.nil?
    rect = item_rect(index)
    draw_item_name(item, rect.x, rect.y, enable?(item), rect.width-24)
    rect.width -= 4
    contents.font.size = YEA::LIMIT::SHOP_FONT if $imported["YEA-AdjustLimits"]
    draw_text(rect, price(item).group, 2)
    reset_font_settings
  end
end
end
end

#--------------------------------------------------------------------------
# * Edit Script: Window_ShopCommand
#--------------------------------------------------------------------------

class Window_ShopCommand < Window_HorzCommand
  
#--------------------------------------------------------------------------
# * Overwrite Method: Object Initialization
#--------------------------------------------------------------------------
  def initialize(window_width, purchase_only, sell_only)
    @window_width = window_width
    @sell_only = sell_only
    @purchase_only = purchase_only
    super(0, 0)
  end

#--------------------------------------------------------------------------
# * Overwrite Method: Create Command List
#--------------------------------------------------------------------------
  def make_command_list
    add_command(Vocab::ShopBuy,    :buy,    !@sell_only)
    add_command(Vocab::ShopSell,   :sell,   !@purchase_only)
    add_command(Vocab::ShopCancel, :cancel)
  end
end


#--------------------------------------------------------------------------
# * Edit Script: Scene_Shop
#--------------------------------------------------------------------------

class Scene_Shop < Scene_MenuBase
   
#--------------------------------------------------------------------------
# * Overwrite Method: Prepare
#--------------------------------------------------------------------------
def prepare(goods, purchase_only, sell_only)
    @goods = goods
    @purchase_only = purchase_only
    if $game_temp.shop_sell_only == true
      @sell_only = true
    else
      @sell_only = false
    end
  end
  
#--------------------------------------------------------------------------
# * Overwrite Method: Create Command Window
#--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_ShopCommand.new(@gold_window.x, @purchase_only, @sell_only)
    @command_window.viewport = @viewport
    @command_window.y = @help_window.height
    @command_window.set_handler(:buy,    method(:command_buy))
    @command_window.set_handler(:sell,   method(:command_sell))
    @command_window.set_handler(:cancel, method(:return_scene))
  end
end
  
class Game_Interpreter

#--------------------------------------------------------------------------
# * Edit Method: Shop Processing
#--------------------------------------------------------------------------
  def command_302
    return if $game_party.in_battle
    goods = [@params]
    while next_event_code == 605
      @index += 1
      goods.push(@list[@index].parameters)
    end
    SceneManager.call(Scene_Shop)
    SceneManager.scene.prepare(goods, @params[4], @sell_only)
    Fiber.yield
  end
  
  
#--------------------------------------------------------------------------
# * New Method: Call Sell Only Shop
#--------------------------------------------------------------------------
  def call_sell_only
    if $game_temp.shop_sell_only == true
      $game_temp.shop_sell_only = false
    else
      $game_temp.shop_sell_only = true
    end
  end
end

#==============================================================================
#                               END OF FILE
#==============================================================================