# Change 499 and 500 to Variable ID for X and Y. (line 21, 22)
# Change 500 to Switch ID to enable custom location for show choice. (line 20)
# Put background into Graphics/System, name choice_bg_X (with X is number of choices)

class Window_ChoiceList < Window_Command
  
  alias yami_xy_initialize initialize
  def initialize(message_window)
    yami_xy_initialize(message_window)
    self.opacity = 0
    @back_sprite = Sprite.new
    @back_sprite.opacity = 0
    @back_sprite.visible = false
    @back_sprite.bitmap = Cache.system("choice_bg")
  end
  
  alias yami_xy_update_placement update_placement
  def update_placement
    yami_xy_update_placement
    name = "choice_bg_#{$game_message.choices.size}"
    @back_sprite.bitmap.dispose if @back_sprite.bitmap && !@back_sprite.bitmap.disposed?
    @back_sprite.bitmap = Cache.system(name)
    #---
    return unless $game_switches[500]
    self.x = $game_variables[499]
    self.y = $game_variables[500]    
  end
  
  def update
    super
    @back_sprite.update
    @back_sprite.x = self.x
    @back_sprite.y = self.y
    @back_sprite.opacity = self.openness
    @back_sprite.visible = self.visible
    @back_sprite.viewport = self.viewport
  end
  
  def dispose
    super
    @back_sprite.dispose
  end
  
end