CODE
#===============================================================
# ● [VX] ◦ Icon Preview Window ◦ □
# ~ Preview iconset and get specific icon name ~*
# * Use by call script '$scene = Scene_IPreview.net('iconset_file_name')'
# * Iconset picture must be in folder 'Graphics/System/'
#--------------------------------------------------------------
# ◦ by Woratana [woratana@hotmail.com]
# ◦ Released on: 06/04/2008 (D-M-Y)
# ◦ Exclusive Script for RPG RPG Revolution (http://www.rpgrevolution.com/)
#--------------------------------------------------------------
# +[ What is this script do? ]+
# Generate icon list with index.
# +[ Who is this script for? ]+
# Anyone who is going to draw icon by Index
# +[ How to use this script? ]+
# Call Script: $scene = Scene_IPreview.new
class Scene_IPreview < Scene_Base
def initialize(img = 'Iconset')
@img = img
end
def start
bitmap = Cache.system(@img)
lx = bitmap.width / 24
ly = bitmap.height / 24
bitmap.dispose
list = []
for i in 1..(lx * ly)
list.push ('<ic' + i.to_s + '>')
end
@window_ic = Window_CIcon.new(544, list, 16, ((lx * ly) / 16), 8)
@window_help = Window_Help.new
@window_help_detail = Window_Help.new
@window_help_detail.y = Graphics.height - @window_help_detail.height
@last_index = nil
@window_ic.height = Graphics.height - (@window_help.height * 2)
@window_ic.y = 0 + @window_help.height
@window_help_detail.set_text('Page Up [Previous Page] || Page Down [Next Page]', 1)
end
def update
@window_ic.update
if @last_index != @window_ic.index
@last_index = @window_ic.index
@window_help.set_text('Image:' + @img + ' | Index: ' + (@last_index + 1).to_s, 1)
end
if Input.trigger?(Input::B)
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
p (@window_ic.index + 1)
end
end
def terminate
@window_help.dispose
@window_help_detail.dispose
@window_ic.dispose
end
end
$worale = {} if $worale == nil
$worale["IconPreview"] = true
class Window_CIcon < Window_Command
#--------------------------------------------------------------------------
# [Rewrite] * Draw Item: Add Icon
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
command_text = @commands[index].clone # Clone Command Text
# Check if text include <ic
if command_text.include?('<ic')
command_text.gsub!(/\<IC([0-9]+)\>/i) do # Get Icon Index
rect.x -= 4
draw_icon($1.to_i, rect.x, rect.y, enabled) # Draw Icon
rect.x += 24
clear_text = ""
end
end
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, command_text)
end
end