Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Window_Skill
- #------------------------------------------------------------------------------
- # This window displays usable skills on the skill and battle screens.
- #==============================================================================
- class Window_Skill < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- # actor : actor
- #--------------------------------------------------------------------------
- def initialize(actor)
- super(120, 128, 190, 90)
- @actor = actor
- if $game_temp.in_battle
- @column_max = 1
- else
- @column_max = 2
- end
- refresh
- self.index = 0
- # If in battle, move window to center of screen
- # and make it semi-transparent
- if $game_temp.in_battle
- self.y = 320
- self.height = 160
- self.back_opacity = $game_system.window_opacity #**
- end
- end
- #--------------------------------------------------------------------------
- # * Acquiring Skill
- #--------------------------------------------------------------------------
- def skill
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- for i in 0...@actor.skills.size
- skill = $data_skills[@actor.skills[i]]
- if skill != nil
- @data.push(skill)
- end
- end
- # If item count is not 0, make a bit map and draw all items
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- # index : item number
- #--------------------------------------------------------------------------
- def draw_item(index)
- skill = @data[index]
- if @actor.skill_can_use?(skill.id)
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- if $game_temp.in_battle
- x = 4 + index % 1 * (288 + 32)
- y = index / 1 * 32
- else
- x = 4 + index % 2 * (288 + 32)
- y = index / 2 * 32
- end
- 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.font.size = 14
- self.contents.font.bold = true
- self.contents.draw_text(x + 28, y, 200, 32, skill.name, 0)
- skill = @data[index]
- # decide color depending on the fact if currently usable
- if @actor.skill_can_use?(skill.id)
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- # remove old SP display
- self.contents.fill_rect(236 + index % 1 * 320, index / 1 * 32, 48, 32,
- Color.new(0, 0, 0, 0))
- # calculate SP cost considering skill level
- sp_cost = (skill.sp_cost * @actor.get_skill_sp_cost_factor(skill.id)).to_i
- # draw SP cost
- self.contents.draw_text(107 + index % 1 * 320, index / 1 * 32, 48, 32,
- sp_cost.to_s, 2)
- #self.contents.draw_text(x + 100, y, 48, 32, skill.sp_cost.to_s, 2)
- end
- #--------------------------------------------------------------------------
- # * Help Text Update
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(self.skill == nil ? "" : self.skill.description)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement