RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Item Icon Hue

0 Members and 2 Guests are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Item Icon Hue
Version: 1.0
Author: modern algebra
Date: September 24, 2010

Version History


  • <Version 1.0> 09.24.2010 - Original Release

Description


This script allows you to specify a hue for the icons of individual items, weapons, armors, skills, and states. This way you can use the same icon for various items, only changing the hue.

Features

  • Allows you to set the hue of the icon of any individual item, weapon, armor, skill, or state
  • Very easy to configure and use

Screenshots


All potions use the same icon but are set to different hues.

Instructions

Place this script above Main and below default scripts in the Script Editor. Put it above all other custom scripts, with the exception of the Note Editor and its General Compatibility Patch if you have it. Some other scripts might require it to be below as well, such as scripts that overwrite draw_item_name or draw_actor_state (like ziifee's animated state icon) For further instructions, such as how to specify the icon hue of an item, see the header of the script.

Script


Code: [Select]
#==============================================================================
#    Item Icon Hue
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: September 24, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to specify a hue for the icons of individual items,
#   weapons, armors, skills, and states. This way you can use the same icon for
#   various items, only changing the hue.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script above Main and below default scripts in the Script
#   Editor. Put it above all other custom scripts, with the exception of the
#   Note Editor and its General Compatibility Patch if you have it.
#
#    To specify a hue for an icon, simply put the following in the note field
#   of an item, weapon, armor, skill, or state:
#     
#         \icon_hue[x]
#           x : the hue you want. It can be any integer between 0 and 360.
#==============================================================================

#==============================================================================
# *** RPG
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    modified classes - BaseItem; State
#==============================================================================

module RPG

#==============================================================================
# ** BaseItem
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - icon_hue
#==============================================================================

class BaseItem
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Icon Hue
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def icon_hue
    @icon_hue = (self.note[/\\ICON[_ ]HUE\[(\d+)\]/i] != nil ? $1.to_i : 0) if @icon_hue.nil?
    return @icon_hue
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Reset Note Values (if using Note Editor and Patch)
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  if self.method_defined? (:ma_reset_note_values)
    alias mod_ichue_restnot_7yh3 ma_reset_note_values
    def ma_reset_note_values (*args)
      @icon_hue = nil
      mod_ichue_restnot_7yh3 (*args)
    end
  end
end

#==============================================================================
# ** State
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - icon_hue
#==============================================================================

class State
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Icon Hue
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def icon_hue
    @icon_hue = (self.note[/\\ICON[_ ]HUE\[(\d+)\]/i] != nil ? $1.to_i : 0) if @icon_hue.nil?
    return @icon_hue
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Reset Note Values (if using Note Editor and Patch)
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  if self.method_defined? (:ma_reset_note_values)
    alias mod_ichue_restnot_7yh3 ma_reset_note_values
    def ma_reset_note_values (*args)
      @icon_hue = nil
      mod_ichue_restnot_7yh3 (*args)
    end
  end
end

end

#==============================================================================
# ** Window_Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased/redefined method - draw_icon
#    aliased methods - draw_actor_state; draw_item_name
#==============================================================================

class Window_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Icon
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modrn_drwicn_hue_6yh1 draw_icon
  def draw_icon(icon_index, x, y, enabled = true, *args)
    hue = @iih_icon_hue.is_a? (Array) ? @iih_icon_hue.shift : @iih_icon_hue
    if !hue || hue == 0
      modrn_drwicn_hue_6yh1 (icon_index, x, y, enabled, *args)
    else
      bitmap = Cache.system("Iconset")
      rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
      # Draw Icon onto small and independent bitmap
      icon_bmp = Bitmap.new (24, 24)
      icon_bmp.blt (0, 0, bitmap, rect)
      icon_bmp.hue_change (hue) # Change hue of icon
      rect.x, rect.y = 0, 0
      self.contents.blt(x, y, icon_bmp, rect, enabled ? 255 : 128)
      icon_bmp.dispose # Dispose Icon Bitmap
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw State
  #    actor : Game_Actor object
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_icnhue_dstat_7uj3 draw_actor_state
  def draw_actor_state(actor, *args)
    @iih_icon_hue = []
    for state in actor.states do @iih_icon_hue.push (state.icon_hue) end
    malg_icnhue_dstat_7uj3 (actor, *args)
    @iih_icon_hue = nil
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Item Name
  #     item    : Item (skill, weapon, armor are also possible)
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modra_ichue_dritm_8ik2 draw_item_name
  def draw_item_name(item, *args)
    @iih_icon_hue = item.icon_hue if item != nil
    modra_ichue_dritm_8ik2 (item, *args)
    @iih_icon_hue = nil
  end
end

Credit


  • modern algebra

Thanks

  • Vermin, for the request

Support


Please post in this topic for support. Do not PM me.

Known Compatibility Issues

No currently known compatibility issues, however it will not work with any scripts that do not use the default Window_Base methods for drawing item names or states or that rewrite those methods.
« Last Edit: September 25, 2010, 01:35:53 PM by modern algebra »

**
Rep:
Level 84
This is a great script.
At first I thought it was the same as item name colors but it works on the icons.

Can be very useful since you do not need to have a ton of different item icons colored differently.

**
Rep:
Level 79
Firstly, sorry if this is a necropost! ><;

Secondly, this is a wonderful script that saves a lot of time recoloring icon sets and I love it very much!

Thirdly, is there any way to make this compatible with OriginalWij's "Chest Item Pop-Up" script? I use the older 3.0 version edited by Mac Malone (Dr. ?) v1.2.
.: Current Project :.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Where there's a will there's a way, but I'd need to see the script before I could decide whether I have the will.

**
Rep:
Level 79
Oh ok, here is the script!

Code: [Select]
==============================================================================
# Chest Item Pop-Up
#==============================================================================
# Author    : OriginalWij
# Edited By : Mac Malone (Dr. ?)
# Version   : 3.0 - Dr. ? Edit v1.2
#==============================================================================

#==============================================================================
# v1.0
# - Initial release
# v1.1
# - Added description window
# v1.2
# - Bug fix and added forgotten aliases
# v1.3
# - Added option to only popup once for many of the same item
# v2.0
# - Reworked name popup window (won't show "1 x" if only one item)
# - Reworked gold display (more efficient)
# - Added option to turn popup sound on/off
# - Added option to turn popup text on/off
# - Added icon to name popup and the ability to turn it on/off
# - Added adjustable X & Y coordinates for name popup window
# - Added "call" feature - with and without adding the item to inventory
# - Added option to wait for button or time for popup name window
# - Added options to define button and time for popup name window wait
# - Added option to enable/disable the "close window" sound
# - Added options to define "close window" sound
# v2.1
# - Fixed moving event bug
# - Added option to have popup always active
# - Added option for overlay graphic
# - Added auto-adjust name window location, depending on actor X/Y
# v2.2
# - Several minor (non-bug) display fixes
# - Removed overlay option due to compatibility problems
# - Optimized script
# v3.0
# - Bugfix for when called from a common event
# - Reworked main popup scene for new X/Y determination
# - Added option for 2nd window cancellation button
# - Added option to center the text window or auto-move to not cover the player
# - Added option to popup items & gold after battle
# v3.0 - Dr. ? Edit
# - Added sound groups
# - Added ME compadibiltiy
# - Added Chest_Popup.new2 command
# - Added option to show or not show gold
# - Added option to show popup above event
# - Added Chest_Popup.new3 command
# - Added Popup_Data class (Incompadible with old save files)
# v3.0 - Dr. ? Edit v1.1
# - Bugfix for $popup.show_above_event
# v3.0 - Dr. ? Edit v1.2
# - Bugfix for save bug in lines 339-353 (now lines 341-355)
#==============================================================================

#==============================================================================
# To use:
#
#   Normal Mode    : turn on the switch (designated below) BEFORE
#                    each gold/item addition
#   Automatic Mode : turn on the switch (designated below) if you DON'T want
#                    popups and then turn the switch off when done
#
# To call manually:
#
#   (useful if using a break-limits script and popping-up 100+ of one item)
#
#   $scene = Chest_Popup.new(type, amount, index, add = false, x = pX, y = pY, sound_group = nil)
#          type : 0 :gold, 1 :items, 2 :weapons, 3 :armor
#        amount : number of items "gaining"
#         index : item ID
#           add : adds item(s) shown into inventory if true (default = false)
#             x : custom X coordinate to pop-up at (default = player X)
#             y : custom Y coordinate to pop-up at (default = player Y)
#   sound_group : play different sounds; an array containing [SI, VI, PI] look
#               : at PLAY_P_SOUND for more. (default = nil) - Dr.? Edit
#==============================================================================

#==============================================================================
# NOTE: when adding multiple (different) items in an event, insert a WAIT(1)
#       between them (insert the WAIT(1) even if in AUTOMATIC mode)
#==============================================================================
# NOTE: the switch turns itself off after each "add item/gold" event command
#       UNLESS in automatic mode (you MUST turn it off MANUALLY in auto-mode)
#==============================================================================
# NOTE: insert a WAIT(7) between a text message and adding items in events
#       (allows time for the message window to close)
#==============================================================================

  #-----------------------------------------------------------------------------
  # Popup Controls
  #-----------------------------------------------------------------------------
  # Automatic popup mode
  # (true = ALWAYS popup UNLESS $game_switches[POPUP_SWITCH] is on)
  AUTO_POPUP = true
  # Switch to activate/deactivate popups
  # (activate if AUTO_POPUP = false) (deactivate if AUTO_POPUP = true)
  POPUP_SWITCH = 7
  # Popup gold
  GOLD_POP = true
    # "Gold" icon index
    # (if GOLD_POPUP = true)
    GOLD_ICON = 205
  # Only popup once (if many of the same item)
  ONLY_SHOW_ONE = true
  # Popup gold/items gained in battle (pops-up after battle)
  BATTLE_POP = false
    # Battle reward prefix text for popup text window
    # (if BATTLE_POP = true)
    BATTLE_REWARD = 'Battle Reward: '
  # Show the Popup icon above the event which gave you the item.
  SHOW_ABOVE_EVENT = false
 
  #-----------------------------------------------------------------------------
  # Sound Groups (Dr. ?)
  #-----------------------------------------------------------------------------
  # With this edit you can play multiple sounds depending on what you pick up.
  # You can also play custom sounds when an important item is gained.
  #
  # Defining your Sounds, Volumes, and Pitches:
  # ===========================================
  # To set up your volumes, pitchs, and sound files you put a new pitch, volume,
  # and or sound into the 3 constants below (P_SND, P_SND_V, P_SND_P).
  #
  # Sounds:
  # -------
  # For sounds you can either play a SE or a ME.
  # To add a new sound simply add new index to P_SND like so:
  #
  # old:
  # P_SND = ['Audio/SE/Chime2']
  # new:
  # P_SND = ['Audio/SE/Chime2', 'Audio/SE/Item1'] # Added a new SE called Item1
  #
  # Volumes:
  # --------
  # To add a new volume add a new index to P_SND_V like so:
  #
  # old:
  # P_SND_V = [100]
  # new:
  # P_SND_V = [100, 80] # Added a volume with a percentage of 80. The precentage can be 0 - 100
  #
  # Pitchs:
  # -------
  # Same as with volumes except you add it to P_SND_P. The precentage can be 0 - 150.
  # Examples: [150] # Pitch of 150
  #
  # Defining your Sound Groups:
  # ===========================
  # A sound group is an array cosisting of a Sound Index (SI), a Volume Index (VI),
  # and a Pitch Index (PI). So the format is: [SI, VI, PI]. A sound index is the
  # index of one of your defined sounds, a volume index is the index of one of
  # your defined volumes, and a pitch index is the index of one of your defined
  # pitchs. Here are some examples (Using the values above):
  #
  # [0, 0, 0] # This would be the SE, Chime2, with a volume of 100 and a pitch of 150.
  # [1, 1, 0] # This would be the SE, Item1, with a volume of 80 and a pitch of 150.
  #
  # I hope you understood that.
  #
  # Using Sound Groups:
  # ===================
  # There are two ways to use sound groups. The GOLD_SOUND, WEAPON_SOUND, etc.
  # constants and via Chest_Popup.new or Chest_Popup.new2 commands.
  #
  # GOLD_SOUND, ITEM_SOUND, WEAPON_SOUND, etc.:
  # -------------------------------------------
  # To use a sound group in these constants simply write: GOLD_SOUND = [0, 0, 0]
  # or whatever your sound group is. These constants mean what sounds will play
  # when gold is gained, when a weapon is gained, etc. It should be evident, but
  # it does tell you what each one is beside the constant definition. Examples:
  #
  # GOLD_SOUND = [0, 0, 0] # This would play the SE, Chime2, with a volume of 100
  # and a pitch of 150 when gold is gained.
  # ITEM_SOUND = [1, 1, 0] # This would play the SE, Item1, witha volume of 80
  # and a pitch of 150 when an item is gained.
  #
  # Chest_Popup.new and Chest_Popup.new2 Commands:
  # ----------------------------------------------
  # Use this to make special music play when you get a special item.
  #
  # Example:
  # Let's say we get a very special item (Like a crystal) and we want it to
  # popup and play the ME Fanfare1 with the defualt volume and pitch (100, 150).
  # So here is what we would do. We would first add that ME into P_SND like so:
  #
  # P_SND = ['Audio/SE/Chime2', 'Audio/SE/Item1', 'Audio/ME/Fanfare1']
  #
  # Then we would make our event with Quick Event Creation > Treasure Chest,
  # select our chest character set and choose our crystal item from the drop-down.
  # Then we open up the event. We delete the second to last event on the first
  # page, the one that adds the a item. Then We replace it with a script event.
  # If the index of the crystal was 8 it would look like this:
  #
  # $scene=Chest_Popup.new(1,1,8,true,nil,nil,[2,0,0]) # See the 8 in this command?
  # That is the index of the item in the database.
  #
  # Note: This WON'T fit one just one line, and I'm not sure if that's going to
  # be a problem or not. If you want the command to fit on one line you could
  # ethier use the new2 command or do this:
  #
  # sg = [2,0,0] # sound group
  # t = true     # add value
  # $scene=Chest_Popup.new(1,1,8,t,nil,nil,sg)
  #
  # This would end up taking 3 lines but all of the commands would fit on one
  # line.
  #
  # After that, click OK and you are done.
  #
  # About New2:
  # -----------
  # The Chest_Popup.new2 is a command made just for the sound group purpose. It
  # shortens the new command by rearrganing it and removing the x, y settings.
  # In the example above the new2 command would have made the script look like
  # this:
  #
  # $scene = Chest_Popup.new2(1, 1, 10, [2,0,0])
  #
  # Thus, it would fit on one line. The syntax for this command is:
  #
  # $scene = Chest_Popup.new2(type, amount, index, sound_group=nil, add=true)
  #
  # Each of them have the same meaning the same as their counterparts in the
  # Chest_Popup.new command explained at the top of this script, with the
  # exception of the defualt of add now being true.
  #
  # Notes:
  # ======
  # PLAY_P_SND must be true for any of this to work.
  #
  #-----------------------------------------------------------------------------
  # Play sound on popup?
  PLAY_P_SND = true
    #######################################################
    # 3 options below are valid ONLY if PLAY_P_SND = true #
    #######################################################
    # Sound to play upon popup
    # Can be a list of sounds, volumes, and pitchs, but must be surrounded in []
    P_SND = ['Audio/SE/Chime2', 'Audio/SE/Chime1', 'Audio/ME/Fanfare1']
    P_SND_V = [100]
    P_SND_P = [150]
   
  # Which sound to play from P_SND at certain occasions.
  # SI = Sound Index, VI = Volume Index, PI = Pitch Index
  #                SI VI PI
  GOLD_SOUND    =  [1, 0, 0]      # Sound to play if gold
  ITEM_SOUND    =  [0, 0, 0]      # Sound to play if item
  ARMOR_SOUND   =  [1, 0, 0]      # Sound to play if armour
  WEAPON_SOUND  =  [1, 0, 0]      # Sound to play if weapon
  DEFAULT_SOUND =  [0, 0, 0]      # Sound to play if all others are nil
   
  # Play "close window" sound?
  # Sound Groups do not currently work with this sound.
  PLAY_C_SND = false
    #######################################################
    # 3 options below are valid ONLY if PLAY_C_SND = true #
    #######################################################
    # Sound to play upon popup close
    C_SND = 'Audio/SE/Cancel'
    C_SND_V = 80
    C_SND_P = 100
   
  #-----------------------------------------------------------------------------
  # Popup Text Controls
  #-----------------------------------------------------------------------------
  # Show popup text?
  SHOW_POPUP_TEXT = true
    ##############################################################
    # ALL options below are valid ONLY if SHOW_POPUP_TEXT = true #
    ##############################################################
    # Show icon with popup text?
    SHOW_POPUP_TEXT_ICON = true
    # Auto adjust window if over player
    TEXT_WINDOW_MOVE = true
    # Popup text window Y coordinate
    TEXT_WINDOW_Y = 180
    # Popup text window X coordinate offset
    # 0 (Zero)         : centered in the window
    # negative integer : offset left  (centered)
    # positive integer : offset right (centered)
    TEXT_WINDOW_X_OFFSET = 0
    # Wait for button to close? (false = wait for time)
    WAIT_FOR_BUTTON = false
      # Buttons to wait for
      # (if WAIT_FOR_BUTTON = true)
      # (Set both to the same button to check for only one)
      BUTTON_TO_WAIT_FOR1 = Input::C
      BUTTON_TO_WAIT_FOR2 = Input::B
      # Frames to wait
      # (if WAIT_FOR_BUTTON = false)
      WAIT_FOR_TIME = 40

#==============================================================================
# Popup_Data
#   - Added by Dr.?
#==============================================================================

class Popup_Data
 
  attr_accessor :gold_pop, :only_show_one, :show_above_event, :battle_pop, :play_p_snd, :play_c_snd,
  :c_snd, :c_snd_v, :c_snd_p, :show_popup_text, :show_popup_text_icon, :text_window_move,
  :text_window_y, :text_window_x_offset, :wait_for_button, :wait_for_time
 
  def initialize
    create_popup_data
  end
 
  def create_popup_data
    @gold_pop = GOLD_POP
    @only_show_one = ONLY_SHOW_ONE
    @battle_pop = BATTLE_POP
    @show_above_event = SHOW_ABOVE_EVENT
    @play_p_snd = PLAY_P_SND
    @play_c_snd = PLAY_C_SND
    @c_snd = C_SND
    @c_snd_v = C_SND_V
    @c_snd_p = C_SND_P
    @show_popup_text = SHOW_POPUP_TEXT
    @show_popup_text_icon = SHOW_POPUP_TEXT_ICON
    @text_window_move = TEXT_WINDOW_MOVE
    @text_window_y = TEXT_WINDOW_Y
    @text_window_x_offset = TEXT_WINDOW_X_OFFSET
    @wait_for_button = WAIT_FOR_BUTTON
    @wait_for_time = WAIT_FOR_TIME
  end
 
end

$popup = Popup_Data.new

#==============================================================================
# Scene_File
#   - Added by Dr.?
#==============================================================================

class Scene_File
 
  alias popup_save write_save_data
  def write_save_data(file)
    popup_save(file)
    Marshal.dump($popup, file)
  end
 
  alias popup_load read_save_data
  def read_save_data(file)
    popup_load(file)
    $popup = Marshal.load(file)
  end
 
end
     
#==============================================================================
# Game_System
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # Public Instance Variables (Added)
  #--------------------------------------------------------------------------
  attr_accessor :battle_pop       # holds items to popup after battle
  attr_accessor :battle_pop_gold  # holds gold to popup after battle
  attr_accessor :pop_event        # holds the event if SHOW_ABOVE_EVENT=true
  #--------------------------------------------------------------------------
  # Initialize (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_gs_initialize initialize unless $@
  def initialize
    chest_pop_gs_initialize
    @battle_pop = nil
    @battle_pop_gold = 0
    @pop_event = nil # Add by Dr. ?
  end
  #--------------------------------------------------------------------------
  # Get Battle Pop (New)
  #--------------------------------------------------------------------------
  def battle_pop
    return @battle_pop
  end
  #--------------------------------------------------------------------------
  # Set Battle Pop (New)
  #--------------------------------------------------------------------------
  def battle_pop=(items)
    @battle_pop = items
  end
  #--------------------------------------------------------------------------
  # Get Battle Pop Gold (New)
  #--------------------------------------------------------------------------
  def battle_pop_gold
    return @battle_pop_gold
  end
  #--------------------------------------------------------------------------
  # Set Battle Pop Gold (New)
  #--------------------------------------------------------------------------
  def battle_pop_gold=(gold)
    @battle_pop_gold = gold
  end
 
end

#==============================================================================
# Game_Interpreter
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # Change Gold (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_command_125 command_125 unless $@
  def command_125
    value = operate_value(@params[0], @params[1], @params[2])
    # Pop-up
    event = $game_map.events[@event_id]
    $game_system.pop_event = event
    if $game_switches[POPUP_SWITCH] != AUTO_POPUP and @params[0] == 0 and $popup.gold_pop
      if !$popup.show_above_event
        $scene = Chest_Popup.new(0, value, 1)
      elsif !@event_id.nil?
        $scene = Chest_Popup.new(0, value, 1, false, event.screen_x, event.screen_y)
      end
    end
    chest_pop_command_125   
  end
  #--------------------------------------------------------------------------
  # Change Items (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_command_126 command_126 unless $@
  def command_126
    value = operate_value(@params[1], @params[2], @params[3])
    # Pop-up
    event = $game_map.events[@event_id]
    $game_system.pop_event = event
    if $game_switches[POPUP_SWITCH] != AUTO_POPUP and @params[1] == 0
      if !$popup.show_above_event
        $scene = Chest_Popup.new(1, value, @params[0])
      elsif !@event_id.nil?
        $scene = Chest_Popup.new(1, value, @params[0], false, event.screen_x, event.screen_y)
      end
    end
    chest_pop_command_126
  end
  #--------------------------------------------------------------------------
  # Change Weapons (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_command_127 command_127 unless $@
  def command_127
    value = operate_value(@params[1], @params[2], @params[3])
    # Pop-up
    event = $game_map.events[@event_id]
    $game_system.pop_event = event
    if $game_switches[POPUP_SWITCH] != AUTO_POPUP and @params[1] == 0
      if !$popup.show_above_event
        $scene = Chest_Popup.new(2, value, @params[0])
      elsif !@event_id.nil?
        $scene = Chest_Popup.new(2, value, @params[0], false, event.screen_x, event.screen_y)
      end
    end
    chest_pop_command_127
  end
  #--------------------------------------------------------------------------
  # Change Armor (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_command_128 command_128 unless $@
  def command_128
    value = operate_value(@params[1], @params[2], @params[3])
    # Pop-up
    event = $game_map.events[@event_id]
    $game_system.pop_event = event
    if $game_switches[POPUP_SWITCH] != AUTO_POPUP and @params[1] == 0
      if !$popup.show_above_event
        $scene = Chest_Popup.new(3, value, @params[0])
      elsif !@event_id.nil?
        $scene = Chest_Popup.new(3, value, @params[0], false, event.screen_x, event.screen_y)
      end
    end
    chest_pop_command_128
  end
end

#==============================================================================
# Item Popup Window (New)
#==============================================================================

class Item_Popup_Window < Window_Base
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(0, 0, 544, 416)
    self.opacity = 0
    # Adjust X/Y to proper origin
    @x, @y = x - 27, y - 60
  end
  #--------------------------------------------------------------------------
  # Pop-Up
  #--------------------------------------------------------------------------
  def pop_up(icon_index, x_offset, y_offset)
    self.contents.clear
    # Draw pop-up icon
    draw_icon(icon_index, @x + x_offset, @y + y_offset, true)
  end
end

#==============================================================================
# Name window (New)
#==============================================================================

class Name_Window < Window_Base
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize(x, y, desc, no_desc, index, gold = false, icon = 0)
    super(x, y, 56, WLH + 32)
    # Adjust window to content's size and center
    icon_x = self.contents.text_size(index).width + 6
    width = self.contents.text_size(desc).width
    self.width = width + 32
    self.x = ((544 - self.width) / 2) + $popup.text_window_x_offset
    create_contents
    # Draw pop-up text
    ix = no_desc ? 0 : icon_x
    item_check = $game_system.battle_pop
    gold_check = $game_system.battle_pop_gold
    if $popup.battle_pop and (item_check != nil or gold_check > 0) # If battle reward
      ix += self.contents.text_size(BATTLE_REWARD).width + 2
    end
    tx = gold ? 4 : 0
    draw_icon(icon, ix, 0) if $popup.show_popup_text_icon and !gold
    self.contents.draw_text(tx, 0, width, WLH, desc, 0)
    draw_icon(GOLD_ICON, width - 24, 0, true) if gold
  end
end

#==============================================================================
# Scene_Base
#==============================================================================

class Scene_Base
  #--------------------------------------------------------------------------
  # Initialize (New)
  #--------------------------------------------------------------------------
  def initialize
    @disable_blur = false
  end
  #--------------------------------------------------------------------------
  # Disable blur (New)
  #--------------------------------------------------------------------------
  def disable_blur=(enabled)
    @disable_blur = enabled
  end
  #--------------------------------------------------------------------------
  # Create Snapshot for Using as Background of Another Screen (Rewrite)
  #--------------------------------------------------------------------------
  def snapshot_for_background
    $game_temp.background_bitmap.dispose
    $game_temp.background_bitmap = Graphics.snap_to_bitmap
    # Don't blur if disabled
    $game_temp.background_bitmap.blur unless @disable_blur # changed
  end
end

#==============================================================================
# Scene_Map
#==============================================================================

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # Start (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_start start unless $@
  def start
    chest_pop_start
    # Popup battle rewards
    if $popup.battle_pop
      if $game_system.battle_pop_gold > 0  # gold
        gold = $game_system.battle_pop_gold
        $game_system.battle_pop_gold = 0
        $scene = Chest_Popup.new(0, gold, 0, true)
      elsif $game_system.battle_pop != nil # items
        item = $game_system.battle_pop.shift
        if item == nil
          $game_system.battle_pop = nil
        else
          type = 1 if item.is_a?(RPG::Item)
          type = 2 if item.is_a?(RPG::Weapon)
          type = 3 if item.is_a?(RPG::Armor)
          $scene = Chest_Popup.new(type, 1, item.id, true)
        end
      end
    end
  end
end

#==============================================================================
# Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # Display Gained Experience and Gold (Rewrite)
  #--------------------------------------------------------------------------
  def display_exp_and_gold
    # Save gold to popup after battle
    $game_system.battle_pop_gold = $game_troop.gold_total if $popup.battle_pop # added
    exp = $game_troop.exp_total
    gold = $popup.battle_pop && $popup.gold_pop ? 0 : $game_troop.gold_total # changed
    $game_party.gain_gold(gold) unless $popup.battle_pop  # changed
    text = sprintf(Vocab::Victory, $game_party.name)
    $game_message.texts.push('\|' + text)
    if exp > 0
      text = sprintf(Vocab::ObtainExp, exp)
      $game_message.texts.push('\.' + text)
    end
    if gold > 0
      text = sprintf(Vocab::ObtainGold, gold, Vocab::gold)
      $game_message.texts.push('\.' + text)
    end
    wait_for_message
  end
  #--------------------------------------------------------------------------
  # Display Gained Drop Items (Mod)
  #--------------------------------------------------------------------------
  alias chest_pop_display_drop_items display_drop_items unless $@
  def display_drop_items
    # Save items to popup after battle
    $game_system.battle_pop = $game_troop.make_drop_items if $popup.battle_pop
    return if $popup.battle_pop
    chest_pop_display_drop_items
  end
end

#==============================================================================
# Chest_Popup (New)
#==============================================================================

class Chest_Popup < Scene_Base
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize(type, amount, index, add = false, x = nil, y = nil, sound_group = nil)
    x = $game_player.screen_x if x == nil
    y = $game_player.screen_y if y == nil
    $game_switches[POPUP_SWITCH] = !AUTO_POPUP
    $scene.disable_blur = true
    @x, @y, @amount = x, y, amount
    @gold = @no_desc = false
    case type
    when 0 # Gold
      $game_party.gain_gold(amount) if add
      @icon = GOLD_ICON
      @desc_amount = ''
      @desc = @amount.to_s
      @amount = 1
      @gold = true
      @sound = GOLD_SOUND
    when 1 # Items
      $game_party.gain_item($data_items[index], amount) if add
      @icon = $data_items[index].icon_index
      @desc_amount = @amount.to_s + ' x'
      @desc_amount = '' if @amount == 1
      @no_desc = true if @amount == 1
      @desc = $data_items[index].name
      @amount = 1 if $popup.only_show_one
      @sound = ITEM_SOUND
    when 2 # Weapons
      $game_party.gain_item($data_weapons[index], amount) if add
      @icon = $data_weapons[index].icon_index
      @desc_amount = @amount.to_s + ' x'
      @desc_amount = '' if @amount == 1
      @no_desc = true if @amount == 1
      @desc = $data_weapons[index].name
      @amount = 1 if $popup.only_show_one
      @sound = WEAPON_SOUND
    when 3 # Armors
      $game_party.gain_item($data_armors[index], amount) if add
      @icon = $data_armors[index].icon_index
      @desc_amount = @amount.to_s + ' x'
      @desc_amount = '' if @amount == 1
      @no_desc = true if @amount == 1
      @desc = $data_armors[index].name
      @amount = 1 if $popup.only_show_one
      @sound = ARMOR_SOUND
    end
    # Check sound_group
    @sound = sound_group if !sound_group.nil?
    # Set index
    @index = @desc_amount
    # Add description to text
    if @gold
      @desc = @desc + '      '
    else
      if $popup.show_popup_text_icon
        @desc = @desc_amount + '      ' + @desc
      else
        @desc = @desc_amount + ' ' + @desc if @desc_amount != ''
      end
    end
    # If battle reward
    item_check = $game_system.battle_pop
    gold_check = $game_system.battle_pop_gold
    if $popup.battle_pop and (item_check != nil or gold_check > 0)
      @desc = BATTLE_REWARD + @desc
    end
  end
  #--------------------------------------------------------------------------
  # New2
  #   - Added by Dr.?
  #   - This is mostly used for controling sound groups
  #--------------------------------------------------------------------------
  def self.new2(type, amount, index, sound_group = nil, add = true)
    return Chest_Popup.new(type, amount, index, add, nil, nil, sound_group)
  end
  #--------------------------------------------------------------------------
  # New3
  #   - Added by Dr.?
  #   - This is mostly used for making the icon pop-up over an event
  #--------------------------------------------------------------------------
  def self.new3(type, amount, index, event, add = false, sound_group = nil)
    event = $game_map.events[event] if event.is_a?(Integer)
    return Chest_Popup.new(type, amount, index, add, event.screen_x, event.screen_y, sound_group)
  end
  #--------------------------------------------------------------------------
  # Start
  #--------------------------------------------------------------------------
  def start
    create_background
    # Create pop-up window
    @popup_window = Item_Popup_Window.new(@x, @y)
  end
  #--------------------------------------------------------------------------
  # Terminate
  #--------------------------------------------------------------------------
  def terminate
    # Dispose windows
    @popup_window.dispose
    @menuback_sprite.dispose
    @name_window.dispose if $popup.show_popup_text
  end
  #--------------------------------------------------------------------------
  # Return Scene
  #--------------------------------------------------------------------------
  def return_scene
    # Turn off blur and pop-up switch
    $scene.disable_blur = false
    $game_switches[POPUP_SWITCH] = false
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # Update
  #--------------------------------------------------------------------------
  def update
    super
    # Update pop-up window
    @popup_window.update
    @menuback_sprite.update
    # Do the actual popping-up
    do_popup
  end
  #--------------------------------------------------------------------------
  # Update Basic
  #--------------------------------------------------------------------------
  def update_basic
    Graphics.update             
    Input.update                 
  end
  #--------------------------------------------------------------------------
  # Wait
  #--------------------------------------------------------------------------
  def wait(duration)
    # Wait for DURATION frames
    for i in 0..duration
      update_basic
    end
  end
  #--------------------------------------------------------------------------
  # Wait for close
  #--------------------------------------------------------------------------
  def wait_for_close
    count = 0
    loop do
      update_basic
      count += 1
      # Close if button 1 pressed
      break if Input.trigger?(BUTTON_TO_WAIT_FOR1) and $popup.wait_for_button
      # Close if button 2 pressed
      break if Input.trigger?(BUTTON_TO_WAIT_FOR2) and $popup.wait_for_button
      # Close if time elapsed
      break if count >= $popup.wait_for_time and !$popup.wait_for_button
    end
  end
  #--------------------------------------------------------------------------
  # Create Background
  #--------------------------------------------------------------------------
  def create_background
    # Create modified background
    @menuback_sprite = Sprite.new
    @menuback_sprite.bitmap = $game_temp.background_bitmap
    @menuback_sprite.update
  end
  #--------------------------------------------------------------------------
  # Show Name
  #--------------------------------------------------------------------------
  def show_name
    x = 272
    y = $popup.text_window_y
    py = $game_player.screen_y - 32
    cy = (py - y).abs
    # Offset Y if text box is above player's position
    if cy < 128 and $popup.text_window_move
      y = py < y ? y + (y / 2) : y - (y / 2)
    end
    # Create Window
    @name_window = Name_Window.new(x, y, @desc, @no_desc, @index, @gold, @icon)
    # Wait for button(s) or time
    wait_for_close
    # Play sound
    Audio.se_play($popup.c_snd, $popup.c_snd_v, $popup.c_snd_p) if $popup.wait_for_button and $popup.play_c_snd
  end
  #--------------------------------------------------------------------------
  # Do Pop-Up
  #--------------------------------------------------------------------------
  def do_popup
    # Set sound index - Dr.?
    @sound = DEFAULT_SOUND if @sound.nil?
    # Pop-up icon(s)
    for i in 1..@amount
      # Support for ME added - Dr.?
      if P_SND[@sound[0]].include?("/SE/")
        Audio.se_play(P_SND[@sound[0]], P_SND_V[@sound[1]], P_SND_P[@sound[2]]) if $popup.play_p_snd
      elsif P_SND[@sound[0]].include?("/ME/")
        Audio.me_play(P_SND[@sound[0]], P_SND_V[@sound[1]], P_SND_P[@sound[2]]) if $popup.play_p_snd
      end
      for i in 0..4
        @popup_window.pop_up(@icon, 0, i * -4)
        @popup_window.update
        wait(2)
      end
      wait(5) if i != @amount and !$popup.only_show_one
    end
    wait(5)
    # Pop-up text
    show_name if $popup.show_popup_text
    # Exit
    return_scene
  end
 
end
.: Current Project :.