class Window_Skill < Window_Selectable
# Skill color by element
# Don't forget to specify skill color for each element,
# else normal color will be used.
# Format:
#
# element_id => my_color
#
# where:
# - element_id is element ID as specified in the game database
# (without any trailing zeroes).
# - my_color is any color you wish to use.
# Predefined colors are normal_color, disabled_color, system_color,
# crisis_color, knockout_color, and text_color(n) where n = 0 to 7
# (this is the same color code you use to color text in message windows).
# Or, define your own color by using
#
# Color.new(red, green, blue)
#
# where red, green, blue are red/green/blue intensity, ranged from 0 to 255,
# being 0 is the least intensity and 255 is the highest intensity.
# E.g. white is Color.new(255, 255, 255) and black is Color.new(0, 0, 0).
# Examples as follows:
SKILL_COLOR =
{
1 => Color.new(255, 0, 0),
6 => Color.new(158, 234, 125),
9 => Color.new(0, 0, 0)
}
# If a skill has more than one element, specify which element will have
# the highest priority
# Format:
#
# skill_id => element_id_with_highest_priority
#
# where:
# - skill_id is the skill ID as specified in the game database
# without any trailing zeroes).
# - element_id_with_highest_priority is self-explanatory
# (don't forget to exclude the trailing zeroes).
# Examples as follows:
SKILL_ELEMENT_HIGHEST_PRIORITY =
{
57 => 9
}
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
if @actor.skill_can_use?(skill.id)
# Determine text color by element
# Have more than one element?
if skill.element_set.size > 1
# Pick the most preferred element to pick
if SKILL_ELEMENT_HIGHEST_PRIORITY.include?(skill.id)
element = SKILL_ELEMENT_HIGHEST_PRIORITY[skill.id]
end
else
# Pick the first and the only element
element = skill.element_set[0]
end
# Has element?
unless element == nil
# Has color?
if SKILL_COLOR.include?(element)
self.contents.font.color = SKILL_COLOR[element]
else
self.contents.font.color = normal_color
end
else
self.contents.font.color = normal_color
end
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
end
end