部屋でほこってたRPGXPでRGSSお試し

戦闘メニューの「こうげき」をクリックすると、武器選択メニューが開いて、選択すると、装備してから攻撃する、ということをやってみた。

・Scene_Battle 1

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● メイン処理
  #--------------------------------------------------------------------------
  def main
    # 戦闘用の各種一時データを初期化
    $game_temp.in_battle = true
    $game_temp.battle_turn = 0
    $game_temp.battle_event_flags.clear
    $game_temp.battle_abort = false
    $game_temp.battle_main_phase = false
    $game_temp.battleback_name = $game_map.battleback_name
    $game_temp.forcing_battler = nil
    # バトルイベント用インタプリタを初期化
    $game_system.battle_interpreter.setup(nil, 0)
    # トループを準備
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    # アクターコマンドウィンドウを作成
    s1 = $data_system.words.attack
    s2 = $data_system.words.skill
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
    @actor_command_window.y = 160
    @actor_command_window.back_opacity = 160
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # その他のウィンドウを作成
    @party_command_window = Window_PartyCommand.new
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @help_window.visible = false
    @status_window = Window_BattleStatus.new
    @message_window = Window_Message.new
    #kabahandle
    @ti_w = Window_Base.new(0,64,640,64)    #$ti_wという名前でウィンドウを作る
    @ti_w.visible = false
    
    # スプライトセットを作成
    @spriteset = Spriteset_Battle.new
    # ウェイトカウントを初期化
    @wait_count = 0
    # トランジション実行
    if $data_system.battle_transition == ""
      Graphics.transition(20)
    else
      Graphics.transition(40, "Graphics/Transitions/" +
        $data_system.battle_transition)
    end
    # プレバトルフェーズ開始
    start_phase1
    # メインループ
    loop do
      # ゲーム画面を更新
      Graphics.update
      # 入力情報を更新
      Input.update
      # フレーム更新
      update
      # 画面が切り替わったらループを中断
      if $scene != self
        break
      end
    end
    # マップをリフレッシュ
    $game_map.refresh
    # トランジション準備
    Graphics.freeze
    # ウィンドウを解放
    @actor_command_window.dispose
    @party_command_window.dispose
    @help_window.dispose
    @status_window.dispose
    @message_window.dispose
    if @skill_window != nil
      @skill_window.dispose
    end
    if @item_window != nil
      @item_window.dispose
    end
    if @result_window != nil
      @result_window.dispose
    end
    # スプライトセットを解放
    @spriteset.dispose
    # タイトル画面に切り替え中の場合
    if $scene.is_a?(Scene_Title)
      # 画面をフェードアウト
      Graphics.transition
      Graphics.freeze
    end
    # 戦闘テストからゲームオーバー画面以外に切り替え中の場合
    if $BTEST and not $scene.is_a?(Scene_Gameover)
      $scene = nil
    end
  end
・・・
・・・

・Scene_Battle 3

#==============================================================================
# ■ Scene_Battle (分割定義 3)
#------------------------------------------------------------------------------
#  バトル画面の処理を行うクラスです。
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● アクターコマンドフェーズ開始
  #--------------------------------------------------------------------------
  def start_phase3
    # フェーズ 3 に移行
    @phase = 3
    # アクターを非選択状態に設定
    @actor_index = -1
    @active_battler = nil
    # 次のアクターのコマンド入力へ
    phase3_next_actor
  end
  #--------------------------------------------------------------------------
  # ● 次のアクターのコマンド入力へ
  #--------------------------------------------------------------------------
  def phase3_next_actor
    # ループ
    begin
      # アクターの明滅エフェクト OFF
      if @active_battler != nil
        @active_battler.blink = false
      end
      # 最後のアクターの場合
      if @actor_index == $game_party.actors.size-1
        # メインフェーズ開始
        start_phase4
        return
      end
      # アクターのインデックスを進める
      @actor_index += 1
      @active_battler = $game_party.actors[@actor_index]
      @active_battler.blink = true
    # アクターがコマンド入力を受け付けない状態ならもう一度
    end until @active_battler.inputable?
    # アクターコマンドウィンドウをセットアップ
    phase3_setup_command_window
  end
  #--------------------------------------------------------------------------
  # ● 前のアクターのコマンド入力へ
  #--------------------------------------------------------------------------
  def phase3_prior_actor
    # ループ
    begin
      # アクターの明滅エフェクト OFF
      if @active_battler != nil
        @active_battler.blink = false
      end
      # 最初のアクターの場合
      if @actor_index == 0
        # パーティコマンドフェーズ開始
        start_phase2
        return
      end
      # アクターのインデックスを戻す
      @actor_index -= 1
      @active_battler = $game_party.actors[@actor_index]
      @active_battler.blink = true
    # アクターがコマンド入力を受け付けない状態ならもう一度
    end until @active_battler.inputable?
    # アクターコマンドウィンドウをセットアップ
    phase3_setup_command_window
  end
  #--------------------------------------------------------------------------
  # ● アクターコマンドウィンドウのセットアップ
  #--------------------------------------------------------------------------
  def phase3_setup_command_window
    # パーティコマンドウィンドウを無効化
    @party_command_window.active = false
    @party_command_window.visible = false
    # アクターコマンドウィンドウを有効化
    @actor_command_window.active = true
    @actor_command_window.visible = true
    # アクターコマンドウィンドウの位置を設定
    @actor_command_window.x = @actor_index * 160
    # インデックスを 0 に設定
    @actor_command_window.index = 0
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (アクターコマンドフェーズ)
  #--------------------------------------------------------------------------
  def update_phase3
    # エネミーアローが有効の場合
    if @enemy_arrow != nil
      update_phase3_enemy_select
    # アクターアローが有効の場合
    elsif @actor_arrow != nil
      update_phase3_actor_select
    # スキルウィンドウが有効の場合
    elsif @skill_window != nil
      update_phase3_skill_select
    # アイテムウィンドウが有効の場合
    elsif @item_window != nil
      update_phase3_item_select
    # 武器ウィンドウが有効の場合
    elsif @weapon_window != nil
      update_phase3_weapon_select
    # アクターコマンドウィンドウが有効の場合
    elsif @actor_command_window.active
      update_phase3_basic_command
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド)
  #--------------------------------------------------------------------------
  def update_phase3_basic_command

    #kabahandle
    #コマンド入力のはじめで、装備ウィンドウを非表示
    @ti_w.visible = false
      

    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # 前のアクターのコマンド入力へ
      phase3_prior_actor
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # アクターコマンドウィンドウのカーソル位置で分岐
      case @actor_command_window.index
      when 0  # 攻撃
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # アクションを設定
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 0
        # エネミーの選択を開始
        #start_enemy_select #kabahandle
        start_weapon_select #kabahandle
        
      when 1  # スキル
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # アクションを設定
        @active_battler.current_action.kind = 1
        # スキルの選択を開始
        start_skill_select
      when 2  # 防御
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # アクションを設定
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 1
        # 次のアクターのコマンド入力へ
        phase3_next_actor
      when 3  # アイテム
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # アクションを設定
        @active_battler.current_action.kind = 2
        # アイテムの選択を開始
        start_item_select
      end
      
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (アクターコマンドフェーズ : スキル選択)
  #--------------------------------------------------------------------------
  def update_phase3_skill_select
    # スキルウィンドウを可視状態にする
    @skill_window.visible = true
    # スキルウィンドウを更新
    @skill_window.update
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # スキルの選択を終了
      end_skill_select
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # スキルウィンドウで現在選択されているデータを取得
      @skill = @skill_window.skill
      # 使用できない場合
      if @skill == nil or not @active_battler.skill_can_use?(@skill.id)
        # ブザー SE を演奏
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # 決定 SE を演奏
      $game_system.se_play($data_system.decision_se)
      # アクションを設定
      @active_battler.current_action.skill_id = @skill.id
      # スキルウィンドウを不可視状態にする
      @skill_window.visible = false
      # 効果範囲が敵単体の場合
      if @skill.scope == 1
        # エネミーの選択を開始
        start_enemy_select
      # 効果範囲が味方単体の場合
      elsif @skill.scope == 3 or @skill.scope == 5
        # アクターの選択を開始
        start_actor_select
      # 効果範囲が単体ではない場合
      else
        # スキルの選択を終了
        end_skill_select
        # 次のアクターのコマンド入力へ
        phase3_next_actor
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (アクターコマンドフェーズ : アイテム選択)
  #--------------------------------------------------------------------------
  def update_phase3_item_select
    # アイテムウィンドウを可視状態にする
    @item_window.visible = true
    # アイテムウィンドウを更新
    @item_window.update
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # アイテムの選択を終了
      end_item_select
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # アイテムウィンドウで現在選択されているデータを取得
      @item = @item_window.item
      
      # 使用できない場合
      unless $game_party.item_can_use?(@item.id)
        # ブザー SE を演奏
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      
      # 決定 SE を演奏
      $game_system.se_play($data_system.decision_se)
      # アクションを設定
      @active_battler.current_action.item_id = @item.id
      # アイテムウィンドウを不可視状態にする
      @item_window.visible = false
      # 効果範囲が敵単体の場合
      if @item.scope == 1
        # エネミーの選択を開始
        start_enemy_select
      # 効果範囲が味方単体の場合
      elsif @item.scope == 3 or @item.scope == 5
        # アクターの選択を開始
        start_actor_select
      # 効果範囲が単体ではない場合
      else
        # アイテムの選択を終了
        end_item_select
        # 次のアクターのコマンド入力へ
        phase3_next_actor
      end
      return
    end
  end
  
  #kabahandle
  #--------------------------------------------------------------------------
  # ● フレーム更新 (アクターコマンドフェーズ : 武器選択)
  #--------------------------------------------------------------------------
  def update_phase3_weapon_select
    # アイテムウィンドウを可視状態にする
    @weapon_window.visible = true
    # アイテムウィンドウを更新
    @weapon_window.update
    
    if @weapon_window.length < 1 
      # アイテムの選択を終了
      end_weapon_select
      start_enemy_select
      return    
    end
    
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # アイテムの選択を終了
      end_weapon_select
      start_enemy_select
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # アイテムウィンドウで現在選択されているデータを取得
      @item = @weapon_window.item

      unless $data_classes[@active_battler.class_id].weapon_set.include?(@item.id)
        # キャンセル SE を演奏
        $game_system.se_play($data_system.cancel_se)
        # アイテムの選択を終了
        end_weapon_select
        start_enemy_select
        disp_msg("装備できません。" + $data_weapons[@active_battler.weapon_id].name + "を使います。")
        return
      end
      
      #kabahandle 武器は使用できないが、
      #      装備できるように改造する
      # 使用できない場合
      unless $game_party.item_can_use?(@item.id) or $game_party.weapons.include?(@item.id)
        # ブザー SE を演奏
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if $game_party.weapons.include?(@item.id)
        #装備すると同時に攻撃する
        
        # アクションを設定
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 0

        # アイテムウィンドウを不可視状態にする
        @weapon_window.visible = false
        
        #start_actor_select
        start_enemy_select

        #index = @active_battler.current_action.target_index
        #target = $game_troop.smooth_target_enemy(index)
        
        # アクションを設定
        @active_battler.current_action.target_index = @enemy_arrow.index
        #@active_battler.current_action.target_index = @actor_arrow.index
        #装備アイテム(武器)を設定
        @active_battler.current_action.weapon_id = @item.id
        #end_item_select
        
        #kabahandle 「武器を使う」->装備する
          if $game_party.weapons.include?(@active_battler.current_action.weapon_id)    
            #old
    #        @active_battler.equip(0,0)
    #        @active_battler.equip(0,@active_battler.current_action.item_id)
    #        @help_window.set_text(@item.name + "を装備した", 1)
            weaponid_ = @active_battler.current_action.weapon_id
            weapon_ = $data_weapons[weaponid_]
            ## 対象側バトラーを設定
            #set_target_battlers(3) #scope:=3 味方単体
            # アイテムの効果を適用
              @active_battler.equip(0,0)
              @active_battler.equip(0,weaponid_)
              @help_window.set_text(@active_battler.name + "は" + weapon_.name + "を装備した", 1)
              #@party_command_window.set_text(@active_battler.name + "は" + weapon_.name + "を装備した", 1)

              $timei = @active_battler.name + "は" + weapon_.name + "を装備した"
              
              #@ti_w = Window_Base.new(0,64,640,64)    #$ti_wという名前でウィンドウを作る
              @ti_w.contents = Bitmap.new(640,32)      #描画領域の設定
#              @ti_w.contents.font.name = "MS P明朝"  #フォントを明朝に
              @ti_w.contents.font.bold = true          #太文字に
              @ti_w.contents.font.italic = true        #斜体に
              @ti_w.contents.font.size = 24            #フォントサイズを24に
              
              kage=Color.new(0,0,0,255)                #kageという名前で色を作る(黒)
              timei=Color.new(255,255,255,255)          #timeiという名前で色を作る(白)
              @ti_w.contents.font.color = kage          #フォント色をkageに設定
              @ti_w.contents.draw_text(3,3,640,32,$timei,1)  #文字を描画
              @ti_w.contents.font.color = timei        #フォント色をtimeiに設定
              @ti_w.contents.draw_text(0,0,640,32,$timei,1)  #文字を描画
              
              @ti_w.back_opacity = 140                  #ウィンドウの背景を半透明に
              @ti_w.visible = true                      #ウィンドウを可視状態に            
          end 
        
        #return
      end
      
      # 決定 SE を演奏
      $game_system.se_play($data_system.decision_se)
      # アクションを設定
      @active_battler.current_action.item_id = @item.id
      # アイテムウィンドウを不可視状態にする
      @weapon_window.visible = false
#      # 効果範囲が敵単体の場合
#      if @item.scope == 1
#        # エネミーの選択を開始
#        start_enemy_select
#      # 効果範囲が味方単体の場合
#      elsif @item.scope == 3 or @item.scope == 5
#        # アクターの選択を開始
#        start_actor_select
#      # 効果範囲が単体ではない場合
#      else
        # アイテムの選択を終了
        end_weapon_select
        # 次のアクターのコマンド入力へ
#        phase3_next_actor
#      end
      return
    end
  end
  #kabahandle
  #メッセージ表示
  def disp_msg(msg)
      #@ti_w = Window_Base.new(0,64,640,64)    #$ti_wという名前でウィンドウを作る
      @ti_w.contents = Bitmap.new(640,32)      #描画領域の設定
#              @ti_w.contents.font.name = "MS P明朝"  #フォントを明朝に
      @ti_w.contents.font.bold = true          #太文字に
      @ti_w.contents.font.italic = true        #斜体に
      @ti_w.contents.font.size = 24            #フォントサイズを24に
      
      kage=Color.new(0,0,0,255)                #kageという名前で色を作る(黒)
      timei=Color.new(255,255,255,255)          #timeiという名前で色を作る(白)
      @ti_w.contents.font.color = kage          #フォント色をkageに設定
      @ti_w.contents.draw_text(3,3,640,32,msg,1)  #文字を描画
      @ti_w.contents.font.color = timei        #フォント色をtimeiに設定
      @ti_w.contents.draw_text(0,0,640,32,msg,1)  #文字を描画
      
      @ti_w.back_opacity = 140                  #ウィンドウの背景を半透明に
      @ti_w.visible = true                      #ウィンドウを可視状態に              
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (アクターコマンドフェーズ : エネミー選択)
  #--------------------------------------------------------------------------
  def update_phase3_enemy_select
    # エネミーアローを更新
    @enemy_arrow.update
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)

      #kabahandle
      # 武器交換表示中の場合
      if @ti_w != nil
        # 非表示
        @ti_w.visible = false
      end
      
      
      # エネミーの選択を終了
      end_enemy_select
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # 決定 SE を演奏
      $game_system.se_play($data_system.decision_se)
      # アクションを設定
      @active_battler.current_action.target_index = @enemy_arrow.index
      # エネミーの選択を終了
      end_enemy_select
      # スキルウィンドウ表示中の場合
      if @skill_window != nil
        # スキルの選択を終了
        end_skill_select
      end
      # アイテムウィンドウ表示中の場合
      if @item_window != nil
        # アイテムの選択を終了
        end_item_select
      end
      
      
      # 次のアクターのコマンド入力へ
      phase3_next_actor
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (アクターコマンドフェーズ : アクター選択)
  #--------------------------------------------------------------------------
  def update_phase3_actor_select
    # アクターアローを更新
    @actor_arrow.update
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # アクターの選択を終了
      end_actor_select
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # 決定 SE を演奏
      $game_system.se_play($data_system.decision_se)
      # アクションを設定
      @active_battler.current_action.target_index = @actor_arrow.index
      # アクターの選択を終了
      end_actor_select
      # スキルウィンドウ表示中の場合
      if @skill_window != nil
        # スキルの選択を終了
        end_skill_select
      end
      # アイテムウィンドウ表示中の場合
      if @item_window != nil
        # アイテムの選択を終了
        end_item_select
      end
      # 次のアクターのコマンド入力へ
      phase3_next_actor
    end
  end
  #--------------------------------------------------------------------------
  # ● エネミー選択開始
  #--------------------------------------------------------------------------
  def start_enemy_select
    # エネミーアローを作成
    @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport1)
    # ヘルプウィンドウを関連付け
    @enemy_arrow.help_window = @help_window
    # アクターコマンドウィンドウを無効化
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end
  #--------------------------------------------------------------------------
  # ● エネミー選択終了
  #--------------------------------------------------------------------------
  def end_enemy_select
    # エネミーアローを解放
    @enemy_arrow.dispose
    @enemy_arrow = nil
    # コマンドが [戦う] の場合
    if @actor_command_window.index == 0
      # アクターコマンドウィンドウを有効化
      @actor_command_window.active = true
      @actor_command_window.visible = true
      # ヘルプウィンドウを隠す
      @help_window.visible = false
    end
  end
  #--------------------------------------------------------------------------
  # ● アクター選択開始
  #--------------------------------------------------------------------------
  def start_actor_select
    # アクターアローを作成
    @actor_arrow = Arrow_Actor.new(@spriteset.viewport2)
    @actor_arrow.index = @actor_index
    # ヘルプウィンドウを関連付け
    @actor_arrow.help_window = @help_window
    # アクターコマンドウィンドウを無効化
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end
  #--------------------------------------------------------------------------
  # ● アクター選択終了
  #--------------------------------------------------------------------------
  def end_actor_select
    # アクターアローを解放
    @actor_arrow.dispose
    @actor_arrow = nil
  end
  #--------------------------------------------------------------------------
  # ● スキル選択開始
  #--------------------------------------------------------------------------
  def start_skill_select
    # スキルウィンドウを作成
    @skill_window = Window_Skill.new(@active_battler)
    # ヘルプウィンドウを関連付け
    @skill_window.help_window = @help_window
    # アクターコマンドウィンドウを無効化
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end
  #--------------------------------------------------------------------------
  # ● スキル選択終了
  #--------------------------------------------------------------------------
  def end_skill_select
    # スキルウィンドウを解放
    @skill_window.dispose
    @skill_window = nil
    # ヘルプウィンドウを隠す
    @help_window.visible = false
    # アクターコマンドウィンドウを有効化
    @actor_command_window.active = true
    @actor_command_window.visible = true
  end
  #--------------------------------------------------------------------------
  # ● アイテム選択開始
  #--------------------------------------------------------------------------
  def start_item_select
    # アイテムウィンドウを作成
    @item_window = Window_Item.new
    # ヘルプウィンドウを関連付け
    @item_window.help_window = @help_window
    # アクターコマンドウィンドウを無効化
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end
  #--------------------------------------------------------------------------
  # ● アイテム選択終了
  #--------------------------------------------------------------------------
  def end_item_select
    # アイテムウィンドウを解放
    @item_window.dispose
    @item_window = nil
    # ヘルプウィンドウを隠す
    @help_window.visible = false
    # アクターコマンドウィンドウを有効化
    @actor_command_window.active = true
    @actor_command_window.visible = true
  end
  #--------------------------------------------------------------------------
  # kabahandle
  # ● 武器選択開始
  #--------------------------------------------------------------------------
  def start_weapon_select
    @active_battler.equip(0,0)
    
    # アイテムウィンドウを作成
    @weapon_window = Window_Weapon.new(@active_battler.class_id)
    #cid = $game_party.actors[@actor_index].class_id
    #a = $data_classes[cid].weapon_set.include?(0)
    # ヘルプウィンドウを関連付け
    @weapon_window.help_window = @help_window
    # アクターコマンドウィンドウを無効化
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end
  #--------------------------------------------------------------------------
  # kabahandle
  # ● 武器選択終了
  #--------------------------------------------------------------------------
  def end_weapon_select
    # アイテムウィンドウを解放
    @weapon_window.dispose
    @weapon_window = nil
    # ヘルプウィンドウを隠す
    @help_window.visible = false
    # アクターコマンドウィンドウを有効化
    @actor_command_window.active = true
    @actor_command_window.visible = true
  end
end

・Scene_Battle 4

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● メインフェーズ開始
  #--------------------------------------------------------------------------
  def start_phase4
    #kabahandle
    #【フェーズ4】のはじめで、装備ウィンドウを非表示
    @ti_w.visible = false
・・・
・・・

・武器ウィンドウクラス

#kabahandle 武器ウィンドウクラス
class Window_Weapon < Window_Item
  attr_accessor   :cid                     #ClassID

  def initialize(cid)
    @cid = cid
    super()
  end
  
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # アイテムを追加
    #for i in 1...$data_items.size
    #  if $game_party.item_number(i) > 0
    #    @data.push($data_items[i])
    #  end
    #end
    
    # 戦闘中以外なら武器と防具も追加
    #
    #kabahandle 戦闘中も武器・防具追加
    #
    #unless $game_temp.in_battle
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0
         if @cid != nil
            if $data_classes[@cid].weapon_set.include?(i)
              @data.push($data_weapons[i])
            end
          end
        end
      end
    #  for i in 1...$data_armors.size
    #    if $game_party.armor_number(i) > 0
    #      @data.push($data_armors[i])
    #    end
    #  end
    #end
    
    #kabahandle  逆順ソート
    @data = @data.sort_by{|i| 
      -1 * i.id 
    }
    
    
    # 項目数が 0 でなければビットマップを作成し、全項目を描画
    @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
  #--------------------------------------------------------------------------
  # ● アイテムの取得
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● アイテム数の取得
  #--------------------------------------------------------------------------
  def length
    return @data.length
  end
end