#╔═=══════════════════════════════════════════════════════════════════════════=#
#║ Tinys Simple Pop Up Icons
#║ By TinyMine
#║
#║  First Published/Erstveröffentlicht 01.12.2013
#║
#║  Visit : http://rpgmaker-vx-ace.de/ for further Information
#║
#║  Suggestions? Support? Bugs? Contact me in http://rpgmaker-vx-ace.de/
#║
#║  Credits recommended : TinyMine
#║  
#║  Commercial : Have fun with it!
#║  Editable?  : Only by original editor TinyMine
#║  
#║ Version : 1.00 // 01.12.2013
#╚═=═=════════════════════════════════════════════════════════════════════════=#

$imported ||= {}
$imported[:TINY_SPUI] = true

#╔═=══════════════════════════════════════════════════════════════════════════=#
#║ ** FEATURES **
#║   
#║    Use a new command to pop up icons like the known balloons.
#║   
#║    █   pop_up_item(event_id, icon_index[, wait])
#║  
#║    Where...
#║   - event_id is the id of an event where the item should pop up from
#║   - icon_index is the number of the icon which will be visible
#║   - wait controlls if following commands only start when animation is done
#║   
#║    For example 
#║    pop_up_item(0, 120)
#║    
#║    The icon number 120 will be visible on the triggered event (0).
#║    It won't wait because default is false. 
#╚═=═=════════════════════════════════════════════════════════════════════════=#


#╔═=══════════════════════════════════════════════════════════════════════════=#
#║ █ ** OLD Class Sprite
#╚═=═=════════════════════════════════════════════════════════════════════════=#
class Sprite
  
  def draw_icon(icon_index)
    self.bitmap = Bitmap.new(24, 24)
    biap = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    self.bitmap.blt(0, 0, biap, rect)
  end
  
end # Sprite

#╔═=══════════════════════════════════════════════════════════════════════════=#
#║ █ ** OLD Class Game_Interpreter
#╚═=═=════════════════════════════════════════════════════════════════════════=#
class Game_Interpreter
  
  def pop_up_item(event_id, icon_index, wait = false)
      character = get_character(event_id)
    if character
      character.pop_up_id = icon_index
      Fiber.yield while character.pop_up_id > 0 && wait
    end
  end
  
end # Game_Interpreter 

#╔═=══════════════════════════════════════════════════════════════════════════=#
#║ █ ** OLD Class Game_CharacterBase
#╚═=═=════════════════════════════════════════════════════════════════════════=#
class Game_CharacterBase
  
  attr_accessor :pop_up_id
  
  alias_method  :initialize_tiny_pop_up_12313,                       :initialize
  
  def initialize
    initialize_tiny_pop_up_12313
    init_addon_members
  end
  
  def init_addon_members
    @pop_up_id = 0
  end

end # Game_CharacterBase

#╔═=══════════════════════════════════════════════════════════════════════════=#
#║ █ ** OLD Class Sprite_Character
#╚═=═=════════════════════════════════════════════════════════════════════════=#
class Sprite_Character  
  
  alias_method :initialize_tiny_pop_up_13455,                        :initialize
  alias_method :dispose_tiny_pop_up_78568,                              :dispose
  alias_method :update_tiny_pop_up_19934,                                :update
  alias_method :setup_new_effect_tiny_pop_up_83747,            :setup_new_effect

  
  def initialize(viewport, character = nil)
    @pop_up_duration = 0
    initialize_tiny_pop_up_13455(viewport, character)
  end
  
  def dispose
    end_pop_up
    dispose_tiny_pop_up_78568
  end  
  def update
    update_tiny_pop_up_19934
    update_pop_up
  end
 
  def setup_new_effect
    setup_new_effect_tiny_pop_up_83747
    if !@pop_up_sprite && @character.pop_up_id > 0
      @pop_up_id = @character.pop_up_id
      start_pop_up
    end
  end  
  
  def start_pop_up
    dispose_pop_up
    @pop_up_duration = 120
    @pop_up_sprite = ::Sprite.new(viewport)
    @pop_up_sprite.draw_icon(@pop_up_id)
    @pop_up_sprite.x = x
    @pop_up_sprite.y = y
    @pop_up_sprite.ox = 12
    @pop_up_sprite.oy = 12
    @pop_up_sprite.zoom_x = 0.0
    @pop_up_sprite.zoom_y = 0.0
    @pop_up_sprite.z = z + 200
    update_pop_up
  end
  
  def dispose_pop_up
    if @pop_up_sprite
      @pop_up_sprite.dispose
      @pop_up_sprite = nil
    end
  end
  
  def update_pop_up
    if @pop_up_duration > 0
      @pop_up_duration -= 1
      if @pop_up_duration > 0
        @pop_up_sprite.zoom_x += 0.02 if @pop_up_sprite.zoom_x < 1.0
        @pop_up_sprite.zoom_y += 0.02 if @pop_up_sprite.zoom_y < 1.0
        @pop_up_sprite.y -= 0.2 unless @pop_up_sprite.y <= y - height
      else
        end_pop_up
      end
    end
  end
  
  def end_pop_up
    dispose_pop_up
    @character.pop_up_id = 0
  end
  
end # Sprite_Character

#╔═=═══════════════════════════════════════════════════════════════════════════╗
#╠══════════════════════════════▲ END OF SCRIPT ▲══════════════════════════════╣
#╚═=═=═════════════════════════════════════════════════════════════════════════╝