=begin
#==============================================================================
# Unique_Color
#------------------------------------------------------------------------------
# Hanmac
# Version 1.0
# Date 8/4/07
#------------------------------------------------------------------------------
# with this module you can coloration your item/weapon/armor/skills
#==============================================================================
=end
module Unique_Color
Groups = {
"UNIQUE" => [[[1,2],[2,3],[4,5]],Color.new(255,0,121,255)],
"Quest" => [[[3],[],[]],Color.new(164,143,121,255)]
}
KEYWORDS=["UNIQUE","Quest"] #the rankting of the Groups (last has highest proitity)
SET_COLOR = Color.new(164,143,255,255)
CURSED_COLOR = Color.new(255,100,100,255)
#--------------------------------------------------------------------------
# * Item_color
# This hash holds the colors used for items. The syntax is
# Item_color = {item_id => Color.new(red, green, blue),
# item_id => Color.new(red, green, blue) ...}
# the following color hashes have the same syntax.
# * Weapon_color : holds the colors used for weapons
# * Armor_color : holds the colors used for armors
# * Skill_color : holds the colors used for skills
#--------------------------------------------------------------------------
Item_color = {}
Weapon_color = {}
Armor_color = {}
Skill_color = {}
#--------------------------------------------------------------------------
# * Status_color
# This hash holds the colors used for status. The syntax is the same.
# You see these colors in your actor status in windows, and in items or
# skills with no colors, but with these status.
#--------------------------------------------------------------------------
Status_color = {0 => Color.new(255, 255, 255),
1 => Color.new(255, 64, 0),
2 => Color.new(255, 255, 255),
3 => Color.new(128, 255, 128),
4 => Color.new(255, 255, 128),
5 => Color.new(160, 160, 160),
6 => Color.new(200, 255, 140),
7 => Color.new( 64, 64, 200),
8 => Color.new(128, 255, 255),
9 => Color.new(128, 128, 128),
10 => Color.new(128, 128, 128),
11 => Color.new(128, 128, 128),
12 => Color.new(128, 128, 128),
13 => Color.new(128, 128, 255),
14 => Color.new(128, 128, 255),
15 => Color.new(128, 128, 255),
16 => Color.new(128, 128, 255)}
#--------------------------------------------------------------------------
# * Elements_colors :
# This hash holds colors used for elements. You see these colors in items
# or skills with no colors, but with these elements
#--------------------------------------------------------------------------
Element_color = {1 => Color.new(255, 0, 0),
2 => Color.new( 0, 255, 255),
3 => Color.new( 0, 255, 0),
4 => Color.new( 0, 0, 255),
5 => Color.new(255, 128, 0),
6 => Color.new(200, 200, 200),
7 => Color.new(255, 255, 0),
8 => Color.new(128, 128, 128)}
#--------------------------------------------------------------------------
# * Color_Ranking :
# this Array is to cange what of the item or skill have the higher priority
# 0 = Spezific
# 1 = Cursed
# 2 = Groups (not skills)
# 3 = Sets (only equipment)
# 4 = Element_color
# 5 = plus - Status_color
# 6 = minus- Status_color
#--------------------------------------------------------------------------
Color_Ranking = [0,1,2,3,4,5,6]
def item_typ(item)
case item
when RPG::Item
return 0
when RPG::Weapon
return 1
when RPG::Armor
return 2
when RPG::Skill
return 3
end
end
def self.groups(item)
temp=[]
KEYWORDS.each { |key| temp << key if Groups[key][0][item_typ(item)].include?(item.id)}
return temp
end
def self.color(item)
col=nil
Color_Ranking.each do |i|
if col.nil?
case i
when 0
temp=[Item_color, Weapon_color, Armor_color, Skill_color][item_typ(item)][item.id]
col=temp if temp.is_a?(Color)
when 1
if (item.is_a?(RPG::Armor) or item.is_a?(RPG::Weapon)) and if Object.const_defined?(:Cursed)
col=CURSED_COLOR if item.cursed?
end
when 2
if !item.is_a?(RPG::Skill)
KEYWORDS.each { |key| col=Groups[key][1] if Groups[key][0][item_typ(item)].include?(item.id) and Groups[key][1].is_a?(Color)}
end
when 3
if (item.is_a?(RPG::Armor) or item.is_a?(RPG::Weapon)) and if Object.const_defined?(:Set_item)
col=SET_COLOR if item.set?
end
when 4
for element in item.element_set
col = Element_color[element]
break if col.is_a?(Color)
end
when 5..6
state_set = item.is_a?(RPG::Armor) ? item.guard_state_set :i == 5 ? item.plus_state_set : item.minus_state_set
for state in state_set
col = Status_color[state]
break if col.is_a?(Color)
end
end
end
end
col = ::Window_Base.normal_color if col.nil?
return col
end
def self.is?(item,key)
return if item.nil? or !Groups.has_key?(key)
return Groups[key][0][item_typ(item)].include?(item.id)
end
end
#==========================================================================
class RPG::Armor
#----------------------------------
def element_set
return guard_element_set
end
#----------------------------------
def color
return Unique_Color.color(self)
end
#----------------------------------
end
#==========================================================================
class RPG::Item
#----------------------------------
def color
return Unique_Color.color(self)
end
#----------------------------------
end
#==========================================================================
class RPG::Skill
#----------------------------------
def color
return Unique_Color.color(self)
end
#----------------------------------
end
#==========================================================================
class RPG::Weapon
#----------------------------------
def color
return Unique_Color.color(self)
end
#----------------------------------
end
#==========================================================================
class Window_Base
def draw_item_name(item, x, y, *args)
wigth,flag = 144, false
args.each { |value|
if value.is_a?(Integer)
width = value
else
flag = value
end
}
return unless item.respond_to?(:name)
if item.respond_to?(:icon_name) && item.icon_name != ''
self.contents.font.color = item.color
self.contents.font.color.alpha /= 2 if flag
opacity = self.contents.font.color.alpha
if Object.defined?(:Sprite_AnimatedIcon)
sprite = @item_icon_sprites[item]
unless sprite.nil?
sprite.dispose if sprite.respond_to?(:dispose)
@window_sprites.delete(sprite)
@item_icon_sprites[item] = nil
end
sprite = Sprite_AnimatedIcon.new(x, y + 4, item.icon_name, self, opacity)
@window_sprites << sprite
@item_icon_sprites[item] = sprite
else
self.contents.blt(x, y + 4, RPG::Cache.icon(item.icon_name), Rect.new(0, 0, 24, 24))
end
x += 24
width -= 24
end
return if width <= 40
h = self.is_a?(Window_Selectable) ? oh : 32
self.contents.draw_text(x + 4, y, width - 8, h, item.name)
end
end
#==========================================================================
class Window_Selectable < Window_Base
#-------------------------------------------------------------------------
# Name: oh
# Info: Used to determine row height. This is used to overwrite
# the top_row, top_row=, page_row_max & update_cursor_rect
# methods replacing the constant 32 with a variable amout.
# Author: SephirothSpawn
# Call Info: No Arguments
# Returns: Returns Command Offset Height
#-------------------------------------------------------------------------
def oh
return 32
end
end
#==========================================================================
class Window_Item
def draw_item(index)
item = @data[index]
case item
when RPG::Item ; number = $game_party.item_number(item.id)
when RPG::Weapon ; number = $game_party.weapon_number(item.id)
when RPG::Armor ; number = $game_party.armor_number(item.id)
end
cursor_width = self.width / @column_max - 32
x = 4 + index % @column_max * (cursor_width + 32)
y = index / @column_max * oh
flag=!(item.is_a?(RPG::Item) && $game_party.item_can_use?(item.id))
draw_item_name(item, x, y, cursor_width - 48,flag)
self.contents.draw_text(x + cursor_width - 48, y, 16, oh, ":", 1)
self.contents.draw_text(x + cursor_width - 32, y, 24, oh, number.to_s, 2)
end
end
#==========================================================================
class Window_Skill
def draw_item(index)
skill = @data[index]
cursor_width = self.width / @column_max - 32
x = 4 + index % @column_max * (cursor_width + 32)
y = index / @column_max * oh
flag = !@actor.skill_can_use?(skill.id)
draw_item_name(skill, x, y, cursor_width - 48,flag)
self.contents.draw_text(x + cursor_width - 56, y, 48, oh, skill.sp_cost.to_s, 2)
end
end
#==========================================================================
class Window_EquipItem
def draw_item(index)
item = @data[index]
cursor_width = self.width / @column_max - 32
x = 4 + index % @column_max * (cursor_width + 32)
y = index / @column_max * oh
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
draw_item_name(item, x, y, cursor_width - 48)
self.contents.draw_text(x + cursor_width - 48, y, 16, oh, ":", 1)
self.contents.draw_text(x + cursor_width - 32, y, 24, oh, number.to_s, 2)
end
end
#==========================================================================
class Window_ShopBuy
def draw_item(index)
item = @data[index]
cursor_width = self.width / @column_max - 32
x = 4 + index % @column_max * (cursor_width + 32)
y = index / @column_max * oh
flag= !(item.price > $game_party.gold && number < 99)
draw_item_name(item, x, y, cursor_width - 48,flag)
self.contents.draw_text(x + cursor_width - 96, y, 88, oh, item.price.to_s, 2)
end
end
#==========================================================================
class Window_ShopSell
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
# If items are sellable, set to valid text color. If not, set to invalid
# text color.
self.contents.font.color = item.color
flag = !(item.price > 0)
cursor_width = self.width / @column_max - 32
x = 4 + index % @column_max * (cursor_width + 32)
y = index / @column_max * oh
draw_item_name(item, x, y, cursor_width - 48,flag)
self.contents.draw_text(x + cursor_width - 48, y, 16, oh, ":", 1)
self.contents.draw_text(x + cursor_width - 32, y, 24, oh, number.to_s, 2)
end
end