| 
 
| 赞 | 0 |  
| VIP | 44 |  
| 好人卡 | 2 |  
| 积分 | 4 |  
| 经验 | 6159 |  
| 最后登录 | 2025-10-18 |  
| 在线时间 | 188 小时 |  
 Lv2.观梦者 
	梦石0 星屑424 在线时间188 小时注册时间2006-1-8帖子53 | 
| 复制代码
#==============================================================================
# ■ Window_Selectable
#------------------------------------------------------------------------------
#  拥有光标的移动以及滚动功能的窗口类。
#==============================================================================
class Window_Selectable_Defined < Window_Base
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :index                    # 光标位置
  attr_reader   :help_window              # 帮助窗口
  #--------------------------------------------------------------------------
  # ● 初始画对像
  #     x      : 窗口的 X 坐标
  #     y      : 窗口的 Y 坐标
  #     width  : 窗口的宽
  #     height : 窗口的高
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height, gap = 32, cursor_height = 32)
    super(x, y, width, height)
    # 间距
    @gap = gap
    # 光标高度
    @cursor_height = cursor_height 
    @item_max = 1
    @column_max = 1
    @index = -1
  end
  #--------------------------------------------------------------------------
  # ● 设置光标的位置
  #     index : 新的光标位置
  #--------------------------------------------------------------------------
  def index=(index)
    @index = index
    # 刷新帮助文本 (update_help 定义了继承目标)
    if self.active and @help_window != nil
      update_help
    end
    # 刷新光标矩形
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # ● 获取行数
  #--------------------------------------------------------------------------
  def row_max
    # 由项目数和列数计算出行数
    return (@item_max + @column_max - 1) / @column_max
  end
  #--------------------------------------------------------------------------
  # ● 获取开头行
  #--------------------------------------------------------------------------
  def top_row
    # 将窗口内容的传送源 Y 坐标、1 行的高 @gap 等分
    return self.oy / @gap
  end
  #--------------------------------------------------------------------------
  # ● 设置开头行
  #     row : 显示开头的行
  #--------------------------------------------------------------------------
  def top_row=(row)
    # row 未满 0 的场合更正为 0
    if row < 0
      row = 0
    end
    # row 超过 row_max - 1 的情况下更正为 row_max - 1 
    if row > row_max - 1
      row = row_max - 1
    end
    # row 1 行高的 @gap 倍、窗口内容的传送源 Y 坐标
    self.oy = row * @gap
  end
  #--------------------------------------------------------------------------
  # ● 获取 1 页可以显示的行数
  #--------------------------------------------------------------------------
  def page_row_max
    # 窗口的高度,设置画面的高度减去 @gap ,除以 1 行的高度 @gap 
    return (self.height - @gap) / @gap
  end
  #--------------------------------------------------------------------------
  # ● 获取 1 页可以显示的项目数
  #--------------------------------------------------------------------------
  def page_item_max
    # 将行数 page_row_max 乘上列数 @column_max
    return page_row_max * @column_max
  end
  #--------------------------------------------------------------------------
  # ● 帮助窗口的设置
  #     help_window : 新的帮助窗口
  #--------------------------------------------------------------------------
  def help_window=(help_window)
    @help_window = help_window
    # 刷新帮助文本 (update_help 定义了继承目标)
    if self.active and @help_window != nil
      update_help
    end
  end
  #--------------------------------------------------------------------------
  # ● 更新光标举行
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # 光标位置不满 0 的情况下
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # 获取当前的行
    row = @index / @column_max
    # 当前行被显示开头行前面的情况下
    if row < self.top_row
      # 从当前行向开头行滚动
      self.top_row = row
    end
    # 当前行被显示末尾行之后的情况下
    if row > self.top_row + (self.page_row_max - 1)
      # 从当前行向末尾滚动
      self.top_row = row - (self.page_row_max - 1)
    end
    # 计算光标的宽
    cursor_width = self.width / @column_max - @gap
    # 计算光标坐标
    x = @index % @column_max * (cursor_width + @gap)
    y = @index / @column_max * @gap - self.oy
    # 更新国标矩形
    self.cursor_rect.set(x, y, cursor_width, @cursor_height)
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    super
    # 可以移动光标的情况下
    if self.active and @item_max > 0 and @index >= 0
      # 方向键下被按下的情况下
      if Input.repeat?(Input::DOWN)
        # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
        # 或光标位置在(项目数-列数)之前的情况下
        if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
           @index < @item_max - @column_max
          # 光标向下移动
          $game_system.se_play($data_system.cursor_se)
          @index = (@index + @column_max) % @item_max
        end
      end
      # 方向键上被按下的情况下
      if Input.repeat?(Input::UP)
        # 列数不是 1 并且方向键的下的按下状态不是重复的情况、
        # 或光标位置在列之后的情况下
        if (@column_max == 1 and Input.trigger?(Input::UP)) or
           @index >= @column_max
          # 光标向上移动
          $game_system.se_play($data_system.cursor_se)
          @index = (@index - @column_max + @item_max) % @item_max
        end
      end
      # 方向键右被按下的情况下
      if Input.repeat?(Input::RIGHT)
        # 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
        if @column_max >= 2 and @index < @item_max - 1
          # 光标向右移动
          $game_system.se_play($data_system.cursor_se)
          @index += 1
        end
      end
      # 方向键左被按下的情况下
      if Input.repeat?(Input::LEFT)
        # 列数为 2 以上并且、光标位置在 0 之后的情况下
        if @column_max >= 2 and @index > 0
          # 光标向左移动
          $game_system.se_play($data_system.cursor_se)
          @index -= 1
        end
      end
      # R 键被按下的情况下
      if Input.repeat?(Input::R)
        # 显示的最后行在数据中最后行上方的情况下
        if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
          # 光标向后移动一页
          $game_system.se_play($data_system.cursor_se)
          @index = [@index + self.page_item_max, @item_max - 1].min
          self.top_row += self.page_row_max
        end
      end
      # L 键被按下的情况下
      if Input.repeat?(Input::L)
        # 显示的开头行在位置 0 之后的情况下
        if self.top_row > 0
          # 光标向前移动一页
          $game_system.se_play($data_system.cursor_se)
          @index = [@index - self.page_item_max, 0].max
          self.top_row -= self.page_row_max
        end
      end
    end
    # 刷新帮助文本 (update_help 定义了继承目标)
    if self.active and @help_window != nil
      update_help
    end
    # 刷新光标矩形
    update_cursor_rect
  end
end
class Pop_Window < Window_Selectable_Defined
  
  def initialize
    super(0,0,640,480)
    @item_max = $game_party.actors.size
    @gap = 116
    @cursor_height = 96
    @column_max = 1
    refresh
    self.index = 0
  end
  
  def refresh
    self.contents = Bitmap.new(width - 32, row_max * 116)
    self.contents.clear
    for i in 0...$game_party.actors.size
      x = 4
      y = i * 116
      actor = $game_party.actors[i]
      draw_actor_graphic(actor, x - 40, y + 80)
      draw_actor_name(actor, x, y)
      draw_actor_class(actor, x + 144, y)
      draw_actor_level(actor, x, y + 32)
      draw_actor_state(actor, x + 90, y + 32)
      draw_actor_exp(actor, x, y + 64)
      draw_actor_hp(actor, x + 236, y + 32)
      draw_actor_sp(actor, x + 236, y + 64)
    end
  end
end
class Scene_SelecPop
  def main
    @pop_window = Pop_Window.new
    @pop_window.active = true
    @cmd = Window_Command.new(96,["离队","取消"])
    @cmd.visible = false
    @cmd.active = false
    # 执行过渡
    Graphics.transition
    # 主循环
    loop do
      # 刷新游戏画面
      Graphics.update
      # 刷新输入信息
      Input.update
      # 刷新画面
      update
      # 如果切换画面就中断循环
      if $scene != self
        break
      end
    end
    # 准备过渡
    Graphics.freeze
    @pop_window.dispose
    @cmd.dispose
  end
  
  def update
    @pop_window.update
    @cmd.update
    if @pop_window.active
      update_pop
      return
    end
    if @cmd.active
      update_cmd
      return
    end
  end
  
  def update_pop
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @pop_window.active = false
      @cmd.visible = true
      @cmd.x = 500
      @cmd.y = [email protected]
      @cmd.active = true
      return
    end  
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene=Scene_Map.new
    end
  end
  
  def update_cmd
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      case @cmd.index
      when 0
        actor = $game_party.actors[@pop_window.index]
        $game_party.remove_actor(actor.id)
        $scene=Scene_SelecPop.new
      when 1
        @cmd.visible = false
        @cmd.active = false
        @pop_window.active = true
        return
      end
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @cmd.visible = false
      @cmd.active = false
      @pop_window.active = true
      return
    end
  end
end
 # 呼出 $scene = Scene_SelecPop.new
 
 
 系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
 | 
 |