Код:
	#----------------------------------------------------------------------------
# * [ACE] SkillInfo Window
#----------------------------------------------------------------------------
# * Автор - caveman
# * Специально для http://rpg-maker.info
# * Версия: 1.1 RU
# * Релиз: 22/07/2015
#
# * Описание:
# * Окно подробного описания скилла
# *
#----------------------------------------------------------------------------
module SkillInfo
  SKILL_NAME_COLOR = Color.new(152,204,255)
  SKILL_DESCR_COLOR = Color.new(255,255,255)
  STAT_NAME_COLOR = Color.new(255,255,255)
  STAT_VALUE_COLOR = Color.new(152,204,255)
  CRITICAL_COLOR = Color.new(255,10,10)
  
  RGX_INFO = /<iinfo>(.*?)<\/iinfo>/im
end
#==============================================================================
# ** Sprite_Base
#------------------------------------------------------------------------------
#  A sprite class with animation display processing added.
#==============================================================================
 
class Sprite_Skill < Sprite
  #--------------------------------------------------------------------------
  # * Class Variable
  #--------------------------------------------------------------------------
  @@ani_checker = []
  @@ani_spr_checker = []
  @@_reference_count = {}
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(rect, viewport = nil)
    super(viewport)
    @use_sprite = true        # Sprite use flag
    @ani_duration = 0         # Remaining time of animation
    @rect = rect              # rectangle of anim
  end
  #--------------------------------------------------------------------------
  # * Free
  #--------------------------------------------------------------------------
  def dispose
    super
    dispose_animation
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    update_animation
    @@ani_checker.clear
    @@ani_spr_checker.clear
  end
  #--------------------------------------------------------------------------
  # * Determine if animation is being displayed
  #--------------------------------------------------------------------------
  def animation?
    @animation != nil
  end
  #--------------------------------------------------------------------------
  # * Start Animation
  #--------------------------------------------------------------------------
  def start_animation(animation, mirror = false)
    dispose_animation
    @animation = animation
    if @animation
      @ani_mirror = mirror
      set_animation_rate
      @ani_duration = @animation.frame_max * @ani_rate + 1
      load_animation_bitmap
      make_animation_sprites
      set_animation_origin
    end
  end
  #--------------------------------------------------------------------------
  # * Set Animation Speed
  #--------------------------------------------------------------------------
  def set_animation_rate
    @ani_rate = 4     # Fixed value by default
  end
  #--------------------------------------------------------------------------
  # * Read (Load) Animation Graphics
  #--------------------------------------------------------------------------
  def load_animation_bitmap
    animation1_name = @animation.animation1_name
    animation1_hue = @animation.animation1_hue
    animation2_name = @animation.animation2_name
    animation2_hue = @animation.animation2_hue
    @ani_bitmap1 = Cache.animation(animation1_name, animation1_hue)
    @ani_bitmap2 = Cache.animation(animation2_name, animation2_hue)
    if @@_reference_count.include?(@ani_bitmap1)
      @@_reference_count[@ani_bitmap1] += 1
    else
      @@_reference_count[@ani_bitmap1] = 1
    end
    if @@_reference_count.include?(@ani_bitmap2)
      @@_reference_count[@ani_bitmap2] += 1
    else
      @@_reference_count[@ani_bitmap2] = 1
    end
    Graphics.frame_reset
  end
  #--------------------------------------------------------------------------
  # * Create Animation Sprites
  #--------------------------------------------------------------------------
  def make_animation_sprites
    @ani_sprites = []
    if @use_sprite && !@@ani_spr_checker.include?(@animation)
      16.times do
        sprite = ::Sprite.new(viewport)
        sprite.visible = false
        @ani_sprites.push(sprite)
      end
      if @animation.position == 3
        @@ani_spr_checker.push(@animation)
      end
    end
    @ani_duplicated = @@ani_checker.include?(@animation)
    if !@ani_duplicated && @animation.position == 3
      @@ani_checker.push(@animation)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Animation Origin
  #--------------------------------------------------------------------------
  def set_animation_origin
    @ani_ox = @rect.x
    @ani_oy = @rect.y
  end
  #--------------------------------------------------------------------------
  # * Free Animation
  #--------------------------------------------------------------------------
  def dispose_animation
    if @ani_bitmap1
      @@_reference_count[@ani_bitmap1] -= 1
      if @@_reference_count[@ani_bitmap1] == 0
        @ani_bitmap1.dispose
      end
    end
    if @ani_bitmap2
      @@_reference_count[@ani_bitmap2] -= 1
      if @@_reference_count[@ani_bitmap2] == 0
        @ani_bitmap2.dispose
      end
    end
    if @ani_sprites
      @ani_sprites.each {|sprite| sprite.dispose }
      @ani_sprites = nil
      @animation = nil
    end
    @ani_bitmap1 = nil
    @ani_bitmap2 = nil
  end
  #--------------------------------------------------------------------------
  # * Update Animation
  #--------------------------------------------------------------------------
  def update_animation
    return unless animation?
    @ani_duration -= 1
    if @ani_duration == 0
      @ani_duration = @animation.frame_max * @ani_rate + 1 
    end
 
    if @ani_duration % @ani_rate == 0
      frame_index = @animation.frame_max
      frame_index -= (@ani_duration + @ani_rate - 1) / @ani_rate
      animation_set_sprites(@animation.frames[frame_index])
    end
  end
  #--------------------------------------------------------------------------
  # * Set Animation Sprite
  #     frame : Frame data (RPG::Animation::Frame)
  #--------------------------------------------------------------------------
  def animation_set_sprites(frame)
    cell_data = frame.cell_data
    @ani_sprites.each_with_index do |sprite, i|
      next unless sprite
      pattern = cell_data[i, 0]
      if !pattern || pattern < 0
        sprite.visible = false
        next
      end
      bmp = pattern < 100 ? @ani_bitmap1 : @ani_bitmap2
      sprite.bitmap = Bitmap.new(bmp.width / 2, bmp.height / 2)
      sprite.bitmap.stretch_blt(Rect.new(0,0,bmp.width/2,bmp.height/2), 
        bmp, bmp.rect) 
 
      sprite.visible = true
      sprite.src_rect.set(pattern % 5 * 96, pattern % 100 / 5 *96, 96, 96)
 
      sprite.x = @rect.x
      sprite.y = @rect.y
      sprite.angle = cell_data[i, 4]
      sprite.mirror = (cell_data[i, 5] == 1)
 
      sprite.z = self.z + 300 + i
      sprite.ox = 0
      sprite.oy = 0
      sprite.zoom_x = 1.0 
      sprite.zoom_y = 1.0 
      sprite.opacity = 256
      sprite.blend_type = cell_data[i, 7]
 
    end
  end
end
 
 
class Window_SkillInfo < Window_Base
  def initialize()
    @window_rect = Rect.new(0,0,544,416)
    @img_rect = Rect.new(32, 32, 96, 96)
    @name_rect = Rect.new(0, 0, 544, 32)
    @state_rect = Rect.new(160, 40, 352, 192)
    @desc_rect = Rect.new(16, 224, 496, 160)
 
    @viewport = Viewport.new
    @viewport.z = 200
 
    @img_sprite = Sprite_Skill.new(@img_rect, @viewport)
 
    super(@window_rect.x, @window_rect.y, @window_rect.width, @window_rect.height)
    self.opacity = 256
    self.contents_opacity = 256
    self.visible = false
    self.active = false
    @skill = nil
    @handler = {}
    refresh
  end
 
  def dispose
    @img_sprite.dispose
    @viewport.dispose
  end
 
  def refresh
    contents.clear
    start_anim
    draw_name
    draw_stats
    draw_descr
    @img_sprite.update
  end
 
  def update_sprite
    @img_sprite.update
  end
 
  def clear
    @img_sprite.dispose_animation
  end
 
  def start_anim
    if @skill != nil && !@img_sprite.animation?
      # проверить, проигралась ли анимашка, если да - начать снова
      if @skill.animation_id > 0
        animation = $data_animations[@skill.animation_id]
        @img_sprite.start_animation(animation)
      end
    end
  end
 
  def draw_name
    if @skill != nil
      contents.font.size = 32
      contents.font.color = SkillInfo::SKILL_NAME_COLOR
      contents.draw_text(@name_rect, @skill.name, 1)
    end
  end
  
  def draw_param(text1, text2, cur_y)
    cur_x = @state_rect.x
    contents.font.color = SkillInfo::STAT_NAME_COLOR
    contents.draw_text(cur_x, cur_y, contents.text_size(text1).width + 4, 
            28, text1)
    cur_x += contents.text_size(text1).width + 4
    contents.font.color = SkillInfo::STAT_VALUE_COLOR
    contents.draw_text(cur_x, cur_y, contents.text_size(text2).width + 4, 
            28, text2)
  end
 
  def draw_stats
    if @skill != nil
      cur_y = @state_rect.y
      contents.font.size = 20
      contents.font.color = normal_color
 
      draw_param("Элемент: ", $data_system.elements[@skill.damage.element_id].to_s, cur_y)
      cur_y += 24
      
      draw_param("Цель: ", get_scope_text(@skill.scope), cur_y)
      cur_y += 24
 
      draw_param("Стоимость: ", sprintf("%d %s", @skill.mp_cost, Vocab::mp_a), cur_y)
      cur_y += 24
      
      draw_param("Скорость: ", @skill.speed.to_s, cur_y)
      cur_y += 24
      
      draw_param("Формула: ",  @skill.damage.formula.to_s, cur_y)
      cur_y += 24
 
      if @skill.damage.critical
        contents.font.color = SkillInfo::CRITICAL_COLOR
        text = sprintf("Возможен критический урон!") 
        contents.draw_text(@state_rect.x, cur_y, contents.text_size(text).width + 4, 
            24, text)
        cur_y += 24
      end
 
      # if @skill.effects.lenght > 0
      # 
      #end
    end
  end
  
  def draw_descr
    contents.fill_rect(@desc_rect.x, @desc_rect.y, @desc_rect.width, 2, 
      text_color(7))
    if @skill != nil
      contents.font.color = SkillInfo::SKILL_DESCR_COLOR
      results = @skill.note.scan(SkillInfo::RGX_INFO)
      results.each do |res|
        draw_text_ex(@desc_rect.x, @desc_rect.y + 4, res[0].to_s)
      end
    end
  end
 
 
  def process_character(c, text, pos)
    case c
    when "\n"   # New line
      process_new_line(text, pos)
    when "\f"   # New page
      process_new_page(text, pos)
    when "\e"   # Control character
      process_escape_character(obtain_escape_code(text), text, pos)
    when " "    # Space
      txt = text.dup
      word = txt.slice(/\A(.+?)\s|\z/)
      text_width = text_size(word).width + 4
 
      if text_width + pos[:x] > 480
        process_new_line(text, pos)
      else
        process_normal_character(c, pos)
      end
    else        # Normal character
      process_normal_character(c, pos)
    end
  end
 
  def get_scope_text(id)
    case id
    when 0 
      return "нет"
    when 1 
      return "один противник"
    when 2 
      return "все противники"
    when 3 
      return "случайный противник"
    when 4 
      return "2 случайных противника"
    when 5 
      return "3 случайных противника"
    when 6 
      return "4 случайных противника"
    when 7 
      return "один союзник"
    when 8 
      return "все союзники"
    when 9 
      return "мертвый союзник"
    when 10 
      return "все мертвые союзники"
    when 11 
      return "игрок"
    else
      return ""
    end
  end
 
  def set_skill(skill)
    @skill = skill
    if @skill.animation_id > 0
      animation = $data_animations[@skill.animation_id]
      @img_sprite.start_animation(animation)
    end
 
    refresh
  end
 
  def update
    if self.active 
      super
      return process_cancel if Input.trigger?(:B)
    end
  end
 
  def process_cancel
    Sound.play_cancel
    Input.update
    deactivate
    @handler[:cancel].call
  end
 
  def set_handler(symbol, method)
    @handler[symbol] = method
  end
end
 
 
class Scene_Skill
  alias skillinfo_start start
  def start
    @skillinfo_window = Window_SkillInfo.new
    @skillinfo_window.set_handler(:cancel, method(:on_skillinfo_cancel))
    create_select
    skillinfo_start
    @sel_window.viewport = @viewport
    @sel_window.z = 300
  end
 
  def create_select
    @sel_window = Window_SkillSelect.new(160, 200,200)
    @sel_window.set_handler(:use,    method(:command_suse))
    @sel_window.set_handler(:show,   method(:command_sshow))
    @sel_window.set_handler(:cancel,   method(:command_scancel))
    @sel_window.hide.deactivate
  end
  
  def command_suse
    @sel_window.hide.deactivate
    determine_item
  end
  
  def command_sshow
    @sel_window.hide.deactivate
    @skillinfo_window.set_skill(item)
    show_sub_window(@skillinfo_window)
  end
  
  def command_scancel
    @sel_window.hide.deactivate
    activate_item_window
  end
  
  def on_skillinfo_cancel
    @skillinfo_window.clear
    hide_sub_window(@skillinfo_window)
  end
  
  def on_item_ok
    @actor.last_skill.object = item
    @sel_window.set_use(@actor && @actor.usable?(item))
    @sel_window.show.activate
  end
  
  def update 
    super
    if @skillinfo_window != nil
      @skillinfo_window.update_sprite
    end
  end
end
 
class Window_SkillSelect < Window_Command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(window_width, x, y)
    @window_width = window_width
    clear_command_list
    make_command_list
    @first_enabled = true
    super(x, y)
    @viewport = Viewport.new
    @viewport.z = 200
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    @window_width
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max
    return 1
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    add_command("Использовать",    :use)
    add_command("Посмотреть",   :show)
    add_command("Отмена",   :cancel)
  end
  
  def set_use(usable)
    @first_enabled = usable
    refresh
  end
  #---HACKS------------------------------------------------------
  def draw_item(index)
    if index == 0 && !@first_enabled
      change_color(normal_color, false)
      draw_text(item_rect_for_text(index), command_name(index), alignment)
    else
      change_color(normal_color, command_enabled?(index))
      draw_text(item_rect_for_text(index), command_name(index), alignment)
    end
  end
  
  def current_item_enabled?
    if index == 0 && !@first_enabled
      false
    else
      current_data ? current_data[:enabled] : false
    end
  end
end
class Window_SkillList 
  def enable?(item)
    if item != nil 
      return true
    end
    return false
  end
end
 
Социальные закладки