LayeredIcons v1.0

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 75
What the...?
LAYERED ICONS
By: Ixfuru

Spoiler for INTRODUCTION:
This script allows you to add a note tag to your database items/skills/weapons and armors which specifies overlapping icons so that they are displayed as layered when in game.

Spoiler for HOW TO USE THE SCRIPT:
It's pretty simple, you just add the note tag:

Code: [Select]
<licons a, b, c, d>

It can go into Skills, Weapons, Armors and Items.   You replace the 'a', 'b', 'c', etc. with the ids of the icons you wish to overlay. 
The first entry, 'a' will always be the bottom layer.  The final entry will be the top layer.  You can add as many layers as you want.  Just make sure you don't forget
the '<' and '>', along with the ',' commas!

Spoiler for SCREENSHOTS:



Spoiler for THE SCRIPT:
Code: [Select]
################################################################################
#    LAYERED ICONS
# By: Ixfuru
################################################################################
# This script is really a creator's tool.  It gives you the ability to display
# item/weapon/armor and skill icons as layered graphics instead of the single
# image.  In order to do this, you simply need to place a note tag in the name
# of the item you wish to display as layered icon.
#
#   <licons a, b, c, d, e>
#
# With a, b, c, d, e all being the icon index you wish to use as the layer. You
# may place as many index references as you want as long as you follow two
# rules.
#
# Number 1 : You MUST HAVE commas between each entry
# Number 2 : You MUST HAVE the '<licons' at the beginning and a '>' at the end
#
# If you don't do these things, the images will not display correctly.
#
################################################################################
class RPG::BaseItem
 
  #-----------------------------------------------------------------------------
  # Layered Icons
  #-----------------------------------------------------------------------------
  def layered_icons
self.note.split(/[\r\n]/).each { |line|
case line
when /<licons.+/
  icons = []
  number = []
  line.scan(/./) { |c|
  if /(\d)/ =~ c
number.push($1.to_i)
  elsif /,/ =~ c
icons.push(number.to_s.to_i)
number.clear
  elsif />/ =~ c
icons.push(number.to_s.to_i) unless number.empty?
return icons
  end
  }
end
}
return nil
  end
 
end

 
class Window_Base
 
  #-----------------------------------------------------------------------------
  # Draw Icon (ALIASED)
  #-----------------------------------------------------------------------------
  alias ixfuruwindowbasedrawicon draw_icon unless $@
  def draw_icon(icon_index, x, y, enabled = true)
if icon_index.is_a?(Integer)
  ixfuruwindowbasedrawicon(icon_index, x, y, enabled)
elsif icon_index.is_a?(Array)
  for i in 0...icon_index.size
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index[i] % 16 * 24, icon_index[i] / 16 * 24, 24, 24)
self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  end
end
  end
 
  #-----------------------------------------------------------------------------
  # Draw Item Name (ALIASED)
  #-----------------------------------------------------------------------------
  alias ixfuruwindowbasedrawitemname draw_item_name unless $@
  def draw_item_name(item, x, y, enabled = true)
if !item.nil? && !item.layered_icons.nil?
  draw_icon(item.layered_icons, x, y, enabled)
  self.contents.font.color = normal_color
  self.contents.font.color.alpha = enabled ? 255 : 128
  self.contents.draw_text(x + 24, y, 172, WLH, item.name)
else
  ixfuruwindowbasedrawitemname(item, x, y, enabled)
end
  end
 
end

Spoiler for CREDITS:
Just give me credit if you use it in your commercial or non-commercial projects.  And don't claim you created it.  That's all :)