#===============================================================================
#★ RGSS3 技能树(本体) Verα2.00(角色設定型)  by ヒール
#-------------------------------------------------------------------------------
# 请将本脚本放在"技能树ーα2.00(设定)"之下。
# 无需改变此脚本。(可以设定用语)
#==============================================================================
# ■ Game_Actor [class]
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ○ モジュールの設定
  #--------------------------------------------------------------------------
  include Hi_ru_Skilltree
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :skill_point
  #--------------------------------------------------------------------------
  # ● セットアップ [エイリアス]
  #     actor_id : アクター ID
  #--------------------------------------------------------------------------
  alias setup_skill_point setup
  def setup(actor_id)
    setup_skill_point(actor_id)
    setup_skillpoint
  end
  #--------------------------------------------------------------------------
  # ○ SPのセットアップ
  #--------------------------------------------------------------------------
  def setup_skillpoint
    @skill_point = SP_DEFAULT
  end
  #--------------------------------------------------------------------------
  # ● レベルアップ
  #--------------------------------------------------------------------------
  alias level_up_skill_point level_up
  def level_up
    level_up_skill_point
    @skill_point += SP_LEVELUP
  end
end
#===============================================================================
# ■ Scene_Skill_tree
#===============================================================================
class Scene_Skilltree < Scene_MenuBase
  include Hi_ru_Skilltree
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  def start
    super
    $game_variables[VARIABLES] = $game_party.members[0].actor.id #先頭のアクターで開始
    $game_variables[TREE_ID]   = 0
    create_help_window
    create_task_window
    #create_learn_window スキル習得ウインドウのみ直前で生成
    create_info_window
    create_tree_window 
    window_setting
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウの作成
  #--------------------------------------------------------------------------
  def create_help_window
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # ● スキル習得ウインドウの作成
  #--------------------------------------------------------------------------
  def create_learn_window
    wx = Graphics.width  / 2 - 180
    wy = Graphics.height / 2 - 60
    @learn_window = Window_Skill_learn.new(wx, wy)
    @learn_window.unselect
    @learn_window.deactivate
    @learn_window.z  += 100
    @learn_window.hide 
    @learn_window.set_handler(:ok,   method(:learn_ok)) 
  end
  #--------------------------------------------------------------------------
  # ● タスクウィンドウの作成
  #--------------------------------------------------------------------------
  def create_task_window
    wx = (Graphics.width - 180)/2
    wy = 64
    @task_window = Window_Skillpoint_Task.new(wx, wy)
    @task_window.unselect
    @task_window.deactivate
    @task_window.z  += 100
    @task_window.hide 
    @task_window.set_handler(:cancel,   method(:task_cancel))
    @task_window.set_handler(:ok,   method(:task_ok)) 
  end
  #--------------------------------------------------------------------------
  # ● インフォメーションウインドウの作成
  #--------------------------------------------------------------------------
  def create_info_window
    @info_window = Window_info.new(0,Graphics.height-72,Graphics.width,72)
  end
  #--------------------------------------------------------------------------
  # ● ツリーウインドウの作成
  #--------------------------------------------------------------------------
  def create_tree_window
    @tree_window = Window_tree.new(0,72,200)
    @tree_window.set_handler(:cancel,   method(:tree_cancel))
    @tree_window.set_handler(:ok,   method(:call_task)) 
    @tree_window.set_handler(:pageup,   method(:treeq_downpage))
    @tree_window.set_handler(:pagedown,   method(:treew_nextpage))
    @tree_window.set_handler(:treeup,   method(:tree_up))
    @tree_window.set_handler(:treedown,   method(:tree_down))
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウのセット
  #--------------------------------------------------------------------------
  def window_setting
    @tree_window.help_window = @help_window
    @tree_window.info_window = @info_window
    @info_window.current_ext = @tree_window.current_ext
  end
  #--------------------------------------------------------------------------
  # ● スキル選択ウインドウ[キャンセル]
  #--------------------------------------------------------------------------
  def tree_cancel
    return_scene
  end
  #--------------------------------------------------------------------------
  # ● タスクウィンドウ呼び出し
  #--------------------------------------------------------------------------
  def call_task
    @tree_window.deactivate
    @task_window.show
    @task_window.activate
    @task_window.refresh
    @task_window.select(0)
  end
  #--------------------------------------------------------------------------
  # ● アクターの切り替え
  #--------------------------------------------------------------------------
  def treeq_downpage
    $game_variables[TREE_ID] = 0
    chara_current = $game_variables[VARIABLES]
    loopx = $game_party.members.size - 1
    for i in 0..loopx
      if chara_current == $game_party.members[i].actor.id
        unless i == 0
          chara_next = $game_party.members[i-1].actor.id
        else
          chara_next = $game_party.members[loopx].actor.id
        end
        break
      end
    end
    $game_variables[VARIABLES] = chara_next
    @help_window.refresh
    @info_window.refresh
    @tree_window.refresh
    @tree_window.select(0)
  end
  #--------------------------------------------------------------------------
  # ● アクターの切り替え
  #--------------------------------------------------------------------------
  def treew_nextpage
    $game_variables[TREE_ID] = 0
    chara_current = $game_variables[VARIABLES]
    loopx = $game_party.members.size - 1
    for i in 0..loopx
      if chara_current == $game_party.members[i].actor.id
        unless i == loopx
          chara_next = $game_party.members[i+1].actor.id
        else
          chara_next = $game_party.members[0].actor.id
        end
        break
      end
    end
    $game_variables[VARIABLES] = chara_next
    @help_window.refresh
    @info_window.refresh
    @tree_window.refresh
    @tree_window.select(0)
  end
  #--------------------------------------------------------------------------
  # ● ツリーの切り替え
  #--------------------------------------------------------------------------
  def tree_up
    @help_window.refresh
    @info_window.refresh
    @tree_window.refresh
    @tree_window.select(0)
  end
  #--------------------------------------------------------------------------
  # ● ツリーの切り替え
  #--------------------------------------------------------------------------
  def tree_down
    @help_window.refresh
    @info_window.refresh
    @tree_window.refresh
    @tree_window.select(0)
  end
  #--------------------------------------------------------------------------
  # ● タスクウィンドウの消去
  #--------------------------------------------------------------------------
  def close_task
    @task_window.hide
    @task_window.deactivate
  end
  #--------------------------------------------------------------------------
  # ● スキル習得ウィンドウ呼び出し
  #--------------------------------------------------------------------------
  def call_learn
    @learn_window.show
    @learn_window.activate
    @learn_window.refresh
    @learn_window.select(0)
  end
  #--------------------------------------------------------------------------
  # ● スキル習得ウィンドウの消去
  #--------------------------------------------------------------------------
  def close_learn
    @learn_window.hide
    @learn_window.deactivate
  end
  #--------------------------------------------------------------------------
  # ● スキル習得ウィンドウ[決定]
  #--------------------------------------------------------------------------
  def learn_ok
    case @learn_window.index
    when 0
      close_learn
      @tree_window.activate
      @help_window.refresh
      @info_window.refresh
      @tree_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  # ● タスクウィンドウ[習得する]
  #--------------------------------------------------------------------------
  def task_ok
    case @task_window.index
    when 0
      $game_actors[$game_variables[VARIABLES]].learn_skill($game_variables[CURRENT][0])
      $game_actors[$game_variables[VARIABLES]].skill_point -= $game_variables[CURRENT][1]
      close_task
      @help_window.refresh
      @info_window.refresh
      @tree_window.refresh
      create_learn_window
      call_learn
    when 1
      close_task
      @tree_window.activate
      @help_window.refresh
      @info_window.refresh
      @tree_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  # ● タスクウィンドウ[キャンセル]
  #--------------------------------------------------------------------------
  def task_cancel
    close_task
    @tree_window.activate
    @help_window.refresh
    @tree_window.refresh
    @tree_window.refresh  
  end
end

#==============================================================================
# ■ Window_tree
#------------------------------------------------------------------------------
#  メイン部分のウインドウです。
#==============================================================================
class Window_tree< Window_Command
  include Hi_ru_Skilltree 
  attr_accessor :info_window
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x,y,height)
    @window_height = 292
    super(x,y)
  end
  #--------------------------------------------------------------------------
  # ● 桁数の取得
  #--------------------------------------------------------------------------
  def col_max
    return 9
  end
  #--------------------------------------------------------------------------
  # ● 横に項目が並ぶときの空白の幅を取得
  #--------------------------------------------------------------------------
  def spacing
    return 28
  end
  #--------------------------------------------------------------------------
  # ● 項目の幅を取得
  #--------------------------------------------------------------------------
  def item_width
    26
  end
  #--------------------------------------------------------------------------
  # ● 項目の高さを取得
  #--------------------------------------------------------------------------
  def item_height
    26
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ幅の取得
  #--------------------------------------------------------------------------
  def window_width
    Graphics.width
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ高さの取得
  #--------------------------------------------------------------------------
  def window_height
    Graphics.height - 144
  end
  #--------------------------------------------------------------------------
  # ● カーソルの更新
  #--------------------------------------------------------------------------
  def update_cursor
    #カーソル描画フラグ
    @flag_cursor = 1
    
    if @cursor_all
      cursor_rect.set(0, 0, contents.width, row_max * item_height)
      self.top_row = 0
    elsif @index < 0
      cursor_rect.empty
    else
      ensure_cursor_visible
      cursor_rect.set(item_rect(@index))
    end
    #カーソル描画フラグ
    @flag_cursor = 0
  end
  #--------------------------------------------------------------------------
  # ● 項目を描画する矩形の取得
  #--------------------------------------------------------------------------
  def item_rect(index)
    if @flag_cursor == 1
      draw_x = 0
    else  
      draw_x = 40
    end  
    rect = Rect.new
    rect.width = item_width - draw_x
    rect.height = item_height
    rect.x = index % col_max * (item_width + spacing) + draw_x + 48
    rect.y = index / col_max * (item_height + spacing/2 +1)
    rect
  end
  #--------------------------------------------------------------------------
  # ● 項目の描画
  #--------------------------------------------------------------------------
  def draw_item(index)
    change_color(normal_color, command_enabled?(index))
    draw_text(item_rect_for_text(index), command_name(index), alignment)
  end
  #--------------------------------------------------------------------------
  # ● コマンドリストの作成
  #--------------------------------------------------------------------------
  def make_command_list
    a     = $game_variables[VARIABLES]
   loopx = TREE[a].size - 1
   check = []
   exts  = []
    for j in (0..loopx)
      next if TREE[a][j][0] != $game_variables[TREE_ID]
      branch   = TREE[a][j][1]
      order    = TREE[a][j][2]
      before   = TREE[a][j][3]
      ext      = [TREE[a][j][4],TREE[a][j][5],branch,order,before,TREE[a][j][6]]
      calculate = 9 * order + branch + 1
      check[calculate] = true if branch <= 8
      exts[calculate]  = ext
    end
    for i in (1..54)
      add_command("", :ok, check[i],exts[i])
    end
  end
  #--------------------------------------------------------------------------
  # ● 決定やキャンセルなどのハンドリング処理
  #--------------------------------------------------------------------------
  def process_handling
    return unless open? && active
    return process_ok       if ok_enabled?        && Input.trigger?(:C)
    return process_cancel   if cancel_enabled?    && Input.trigger?(:B)
    return process_pagedown if handle?(:pagedown) && Input.trigger?(:R)
    return process_pageup   if handle?(:pageup)   && Input.trigger?(:L)
    return process_treeup   if Input.trigger?(:Y)
    return process_treedown if Input.trigger?(:Z)
  end
  #--------------------------------------------------------------------------
  # ● カーソル位置の設定
  #--------------------------------------------------------------------------
  def index=(index)
    @index = index
    update_cursor
    call_update_help
    @info_window.current_ext = current_ext if @info_window
  end
  #--------------------------------------------------------------------------
  # ● カーソルを下に移動
  #--------------------------------------------------------------------------
  def cursor_down(wrap = false)
    if index < item_max - col_max || (wrap && col_max == 1)
      select((index + col_max) % item_max)
     for c in 1..100
      if current_item_enabled?
        break
      end
        select((index + col_max) % item_max)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● カーソルを上に移動
  #--------------------------------------------------------------------------
  def cursor_up(wrap = false)
    if index >= col_max || (wrap && col_max == 1)
      select((index - col_max + item_max) % item_max)
     for c in 1..100
      if current_item_enabled?
        break
      end
        select((index - col_max + item_max) % item_max)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● カーソルを右に移動
  #--------------------------------------------------------------------------
  def cursor_right(wrap = false)
    if col_max >= 2 && (index < item_max - 1 || (wrap && horizontal?))
      select((index + 1) % item_max)
      for c in 1..100
      if current_item_enabled?
        break
      end
        select((index + 1) % item_max)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● カーソルを左に移動
  #--------------------------------------------------------------------------
  def cursor_left(wrap = false)
    if col_max >= 2 && (index > 0 || (wrap && horizontal?))
      select((index - 1 + item_max) % item_max)
      for c in 1..100
      if current_item_enabled?
        break
      end
        select((index - 1 + item_max) % item_max)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● L ボタン(PageUp)が押されたときの処理
  #--------------------------------------------------------------------------
  def process_pageup
    Sound.play_cursor
    Input.update
    call_handler(:pageup)
  end
  #--------------------------------------------------------------------------
  # ● R ボタン(PageDown)が押されたときの処理
  #--------------------------------------------------------------------------
  def process_pagedown
    Sound.play_cursor
    Input.update
    call_handler(:pagedown)
  end
  #--------------------------------------------------------------------------
  # ● Y ボタン(TreeUp)が押されたときの処理
  #--------------------------------------------------------------------------
  def process_treeup
    a     = $game_variables[VARIABLES]
    loopx = TREE[a].size - 1
    tree_next = 0
    for i in (0..loopx)
      tree_next = TREE[a][i][0] if tree_next < TREE[a][i][0]
    end
    unless $game_variables[TREE_ID] == 0
      $game_variables[TREE_ID] -= 1
    else
      $game_variables[TREE_ID] = tree_next
    end
    Sound.play_cursor
    Input.update
    call_handler(:treeup)
  end
  #--------------------------------------------------------------------------
  # ● Z ボタン(TreeDown)が押されたときの処理
  #--------------------------------------------------------------------------
  def process_treedown
    a     = $game_variables[VARIABLES]
    loopx = TREE[a].size - 1
    tree_next = 0
    for i in (0..loopx)
      tree_next = TREE[a][i][0] if tree_next < TREE[a][i][0]
    end
    unless $game_variables[TREE_ID] == tree_next
      $game_variables[TREE_ID] += 1
    else
      $game_variables[TREE_ID] = 0
    end
    Sound.play_cursor
    Input.update
    call_handler(:treedown)
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    clear_command_list
    make_command_list
    create_contents
    super
    draw_icon_bar
  end
  #--------------------------------------------------------------------------
  # ● 各種描画
  #--------------------------------------------------------------------------
  def draw_icon_bar
    a     = $game_variables[VARIABLES]
    loopx = TREE[a].size - 1
    d     = $game_actors[a].level
    self.contents.font.size = 16
    
    for i in (0..loopx)
      next if TREE[a][i][0] != $game_variables[TREE_ID]
      branch   = TREE[a][i][1] * 54
      order    = TREE[a][i][2] * 41
      skill_id = TREE[a][i][4]
      icon_index = $data_skills[skill_id].icon_index
      if $game_actors[a].skill_learn?($data_skills[skill_id])
        learn = true
      else
        learn = false
      end
      change_color(text_color(LEVEL_COLOR))
      draw_text(branch+40,order-2, 30, 24,TREE[a][i][6]) if d < TREE[a][i][6] && TREE[a][i][6] >= 1  && TREE[a][i][6] <10
      draw_text(branch+34,order-2, 30, 24,TREE[a][i][6]) if d < TREE[a][i][6] && TREE[a][i][6] >= 10 && TREE[a][i][6] <100
      draw_text(branch+28,order-2, 30, 24,TREE[a][i][6]) if d < TREE[a][i][6] && TREE[a][i][6] >= 100
      draw_icon(icon_index,48+branch,order,learn)
    end
    change_color(normal_color)
    
    for i in (0..loopx)
      next if TREE[a][i][0] != $game_variables[TREE_ID] #現在のツリー以外を無視
      branch   = TREE[a][i][1]
      order    = TREE[a][i][2] 
      before   = TREE[a][i][3]
      if before == 2 || before == 8
       for j in (0..loopx)
         next if TREE[a][j][0] != $game_variables[TREE_ID] #現在のツリー以外を無視
         next if branch  != TREE[a][j][1]
         next if order   != (TREE[a][j][2] - 1) && before == 2
         next if order   != (TREE[a][j][2] + 1) && before == 8
         skill_id = TREE[a][j][4]
         if $game_actors[a].skill_learn?($data_skills[skill_id])
           colors = hp_gauge_color1
         else
           colors = text_color(8)
         end
         contents.fill_rect(58+branch*54,27+(order-1)*41,3,12,colors) if before == 8
         contents.fill_rect(58+branch*54,27+order*41,3,12,colors) if before == 2
        end
      elsif before == 4 || before == 6
        for j in (0..loopx)
          next if TREE[a][j][0] != $game_variables[TREE_ID]
          next if branch  != (TREE[a][j][1] - 1) && before == 6
          next if branch  != (TREE[a][j][1] + 1) && before == 4
          next if order   != TREE[a][j][2]
          skill_id = TREE[a][j][4]
          if $game_actors[a].skill_learn?($data_skills[skill_id])
            colors = hp_gauge_color1
          else
            colors = text_color(8)
          end
        contents.fill_rect(22+branch*54,15+order*41,24,3,colors) if before == 4
        contents.fill_rect(22+(branch+1)*54,15+order*41,24,3,colors) if before == 6
        end
      end
    end
    
    chr = $game_actors[a]
    draw_character(chr.character_name, chr.character_index, 16, 32)
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウ更新メソッドの呼び出し
  #--------------------------------------------------------------------------
  def call_update_help
    update_help if active && @help_window
  end
  #--------------------------------------------------------------------------
  # ● ヘルプウィンドウの更新
  #--------------------------------------------------------------------------
  def update_help
    @help_window.clear
      @help_window.set_item($data_skills[current_ext[0]]) unless current_ext == nil
  end
end

#==============================================================================
# ■ Window_info
#==============================================================================
class Window_info < Window_Base
  include Hi_ru_Skilltree
  attr_accessor :current_ext
  #--------------------------------------------------------------------------
  # ● 現在情報の設定
  #--------------------------------------------------------------------------
  def current_ext=(current_ext)
    return if @current_ext == current_ext
    @current_ext = current_ext
    refresh
  end

  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    unless current_ext == nil
    change_color(normal_color)
     @stype_id = $data_skills[current_ext[0]].stype_id
    draw_text(0,0, 54, 24," #{$data_system.skill_types[@stype_id]}:")
    draw_text(54,0, 180, 24, $data_skills[current_ext[0]].name)
    $game_variables[CURRENT] = []
    $game_variables[CURRENT] = [current_ext[0],current_ext[1],current_ext[2],current_ext[3],current_ext[4],current_ext[5]]
    
    change_color(mp_cost_color)
    draw_text(260,0, Graphics.width, 24, $data_skills[current_ext[0]].mp_cost)
    change_color(normal_color)
    draw_text(288,0, Graphics.width, 24, "/")
    change_color(tp_cost_color)
    draw_text(300,0, Graphics.width, 24, $data_skills[current_ext[0]].tp_cost)
    change_color(normal_color) 
    
    draw_text(348,0,Graphics.width, 24,"SP:")
    self.contents.font.size = 24
    sizex = 27
    sizex = 18 if current_ext[1] >= 10
    sizex = 9 if current_ext[1] >= 100
    sizex = 0  if current_ext[1] >= 1000
    draw_text(390+sizex,0,48, 24, current_ext[1])
    self.contents.font.size = 28
    draw_text(430,0,Graphics.width, 24, "/")
    draw_text(440,0,Graphics.width, 24, $game_actors[$game_variables[VARIABLES]].skill_point)
    self.contents.font.size = 24
    draw_text(0,24,Graphics.width,24," Q,W键:切换角色  S,D键:切换技能树")
    
    end
  end
end

#==============================================================================
# ■ Window_Skillpoint_Task
#------------------------------------------------------------------------------
#  スキルの習得に関する選択肢を表示するウィンドウです。
#==============================================================================
class Window_Skillpoint_Task < Window_Command
  include Hi_ru_Skilltree
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y)
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ幅の取得
  #--------------------------------------------------------------------------
  def window_width
    return 240
  end
  #--------------------------------------------------------------------------
  # ● 決定ボタンが押されたときの処理
  #--------------------------------------------------------------------------
  def process_ok
    if current_item_enabled?
      Input.update
      deactivate
      call_ok_handler
    else
      Sound.play_buzzer
    end
  end
  #--------------------------------------------------------------------------
  # ● コマンドリストの作成
  #--------------------------------------------------------------------------
  def make_command_list
    a     = $game_variables[VARIABLES]
    loopx = TREE[a].size - 1
    can   = false
    branch   = $game_variables[CURRENT][2]
    order    = $game_variables[CURRENT][3]
    before   = $game_variables[CURRENT][4]
    
    if before == 2 || before == 8
      for j in (0..loopx)
        next if TREE[a][j][0] != $game_variables[TREE_ID] #現在のツリー以外を無視
        next if branch  != TREE[a][j][1]
        next if order   != (TREE[a][j][2] - 1) && before == 2
        next if order   != (TREE[a][j][2] + 1) && before == 8
        skill_id = TREE[a][j][4]
        if $game_actors[a].skill_learn?($data_skills[skill_id])
          can = true
        end
      end
    end
    if before == 4 || before == 6
      for j in (0..loopx)
        next if TREE[a][j][0] != $game_variables[TREE_ID] #現在のツリー以外を無視
        next if branch  != (TREE[a][j][1] - 1) && before == 6
        next if branch  != (TREE[a][j][1] + 1) && before == 4
        next if order   != TREE[a][j][2]
        skill_id = TREE[a][j][4]
        if $game_actors[a].skill_learn?($data_skills[skill_id])
          can = true
        end
      end
    end
    can = true if before == 0
    
    if can == true
      unless $game_actors[$game_variables[VARIABLES]].skill_learn?($data_skills[$game_variables[CURRENT][0]])
        if $game_variables[CURRENT][5] > $game_actors[a].level
          add_command("等级不足", :ok, false, 1)
        elsif $game_actors[$game_variables[VARIABLES]].skill_point >= $game_variables[CURRENT][1]
          add_command("学习该技能!", :ok, true, 1)
        else
          add_command("技能点不足", :ok, false, 1)
        end
      else
        add_command("已经学会该技能了", :ok, false, 1)
      end
    else
      add_command("需要前提技能", :ok, false, 1)
    end
    add_command("取消", :ok, true, 2)
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    clear_command_list
    make_command_list
    create_contents
    self.height = window_height
    select(0)
    super
  end
end

class Window_Skill_learn < Window_Command
  include Hi_ru_Skilltree
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y)
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ幅の取得
  #--------------------------------------------------------------------------
  def window_width
    360
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ高さの取得
  #--------------------------------------------------------------------------
  def window_height
    72
  end
  #--------------------------------------------------------------------------
  # ● 項目の幅を取得
  #--------------------------------------------------------------------------
  def item_width
    1
  end
  #--------------------------------------------------------------------------
  # ● 項目の高さを取得
  #--------------------------------------------------------------------------
  def item_height
    1
  end
  #--------------------------------------------------------------------------
  # ● コマンドリストの作成
  #--------------------------------------------------------------------------
  def make_command_list
     add_command("", :ok, true, 1) #エラー回避
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    clear_command_list
    make_command_list
    create_contents
    self.height = window_height
    select(0)
    super
    draw_learn
    Audio.me_stop
    Audio.me_play(SKILL_LEARN_ME, SKILL_LEARN_VOLUME, SKILL_LEARN_PITCH)
  end
  #--------------------------------------------------------------------------
  # ● 各種描画
  #--------------------------------------------------------------------------
  def draw_learn
    icon_index = $data_skills[$game_variables[CURRENT][0]].icon_index
    draw_icon(icon_index,0,0,true)
    draw_text(32,0,320,24,$data_skills[$game_variables[CURRENT][0]].name + " 已被学会!")
    draw_text(80,24,200,24,"SP")
    draw_text(120,24,48,24,$game_actors[$game_variables[VARIABLES]].skill_point + $game_variables[CURRENT][1])
    draw_text(160,24,24,24,"→")
    draw_text(190,24,48,24,$game_actors[$game_variables[VARIABLES]].skill_point)
  end
end

#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
#  メニュー画面の処理を行うクラスです。
#==============================================================================
class Scene_Menu < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ● コマンドウィンドウの作成
  #--------------------------------------------------------------------------
  alias skilltree_create_command_window create_command_window
  def create_command_window
    skilltree_create_command_window
    @command_window.set_handler(:skill_tree_go,    method(:command_skill_tree))
  end
  #--------------------------------------------------------------------------
  # ○ コマンド[スキルツリー]
  #--------------------------------------------------------------------------
  def command_skill_tree
    SceneManager.call(Scene_Skilltree)
  end
end
#==============================================================================
# ■ Window_MenuCommand
#------------------------------------------------------------------------------
#  メニュー画面で表示するコマンドウィンドウです。
#==============================================================================
class Window_MenuCommand
  #--------------------------------------------------------------------------
  # ● 独自コマンドの追加用
  #--------------------------------------------------------------------------
  alias skilltree_add_original_commands add_original_commands
  def add_original_commands
    skilltree_add_original_commands
    if $game_switches[Hi_ru_Skilltree::MENU_SWITCH]
      add_command(Hi_ru_Skilltree::MENU_COMMAND, :skill_tree_go, true)
    end
  end
end