| 
 
| 赞 | 1 |  
| VIP | 246 |  
| 好人卡 | 87 |  
| 积分 | 1 |  
| 经验 | 34142 |  
| 最后登录 | 2015-1-15 |  
| 在线时间 | 323 小时 |  
 Lv1.梦旅人 
	梦石0 星屑55 在线时间323 小时注册时间2010-8-21帖子666 | 
| 
本帖最后由 沙漠点灰 于 2011-5-1 17:42 编辑
x
加入我们,或者,欢迎回来。您需要 登录 才可以下载或查看,没有帐号?注册会员  
 
 1L普通版  2L鼠标版
 
 
 
 
 
 
 本脚本更新(呵呵,没有TJ),较上个版本(0.91)更新如下:
 1.代码简化,去除Bug
 2.支持多选项打开(上个版本只能把一个打开到底)
 3.用左右键执行上面(2)的功能[即:左键 退到上个选项层 右键 进入下个选项层]
 4.会自动在末尾追加一层"-----------" (占位置)
 效果如下,范例照旧稍后放出(http://rpg.blue/thread-175789-1-1.html就是截图..):
 
   
   代码如下:
 复制代码#______________________________________________________________________________
# * 此脚本归66RPG - Idiot Script Association(ISA)所有,谢绝任何形式转载。
#______________________________________________________________________________
#==============================================================================
# ■ 子选项 - Sub-option
#------------------------------------------------------------------------------
#   遵守协议:66RPG - Idiot Script Association(ISA)
#   当前版本:0.9.5.0
#------------------------------------------------------------------------------
#   更新日记:沙漠.灰(2011.4.2)
#             - 初始化
#             沙漠.灰(2011.4.16)
#             - 0.95版放出
#==============================================================================
#--------------------------------------------------------------------------
# ● 资料记录
#--------------------------------------------------------------------------
module ISA
   Use["子选项"] = [true, "0.9.5.0"]
end
#==============================================================================
# ■ Window_Folder
#------------------------------------------------------------------------------
#  拥有光标的移动以及滚动功能、子项目的窗口类。
#==============================================================================
class Window_Folder < Window_Base
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :index                    # 光标位置
  attr_reader   :c
  #--------------------------------------------------------------------------
  # ● 初始画对像
  #     x      : 窗口的 X 坐标
  #     y      : 窗口的 Y 坐标
  #     width  : 窗口的宽
  #     height : 窗口的高
  #--------------------------------------------------------------------------
  def initialize(x,y,width, height, commands)
    super(x, y, width, height)
    commands += ["-"*(width/11)]
    # 初始化数据
    @move_to        = 0
    @to_refresh     = false
    @commands_size  = 0
    @c              = false
    @index          = [0]
    @spread_command = []
    @disable_item   = []
    commands.size.times{@spread_command.push(1)}
    @true_commands  = commands
    @object_id = 0
    # 生成位图
    self.contents = Bitmap.new(width - 32, @true_commands.self_all_plus * 32-32)
    @v = Viewport.new(16+self.x, 16+self.y, width-32, height-32) ; @v.z = 999
    @new_bitmap = Sprite.new(@v)
    @new_bitmap.bitmap = Bitmap.new(width - 32, @true_commands.self_all_plus * 32-32)
    index = 0 # 描绘顶层项目
    # 描绘父项目
    for unit in @true_commands
      draw_command [index]
      index += 1
    end
  end
  #--------------------------------------------------------------------------
  # ● 项目无效化 index : 项目编号
  #--------------------------------------------------------------------------
  def disable_item(index)
    @disable_item.push(index)
  end
  #--------------------------------------------------------------------------
  # ● 指定项目是否为父项目 index 所在位置
  #--------------------------------------------------------------------------
  def is_folder?(commands,index)
    # 若指定项目为数组且子单元数目大于1就判定为父项目
    if index.size == 1 and commands[index[0]].is_a?(Array)
      return true if commands[index[0]].size > 1
    elsif index.size > 1
      return is_folder?(commands[index[0]],index[1...index.size])
    end
    false
  end
  #--------------------------------------------------------------------------
  # ● 描绘项目名称 index 所在位置  branch 是否分支
  #--------------------------------------------------------------------------
  def draw_command(index,branch=false)
    x, y = check_index_xy(index)
    rect = Rect.new(x+32,y,self.width-32,32)
    self.contents.font.color = disabled_color if @disable_item.include?(index)
    name = get_command(@true_commands,index)
    self.contents.draw_text(rect, name)
    # 为父项目时,描绘指引
    draw_flag(index,branch) if is_folder?(@true_commands,index)
    self.contents.font.color = normal_color
  end
  #--------------------------------------------------------------------------
  # ● 取得项目名称 index 所在位置
  #--------------------------------------------------------------------------
  def get_command(name_array,index)
    return get_command_name(name_array[index[0]]) if index.size == 1
    get_command name_array[index[0]],index[1...index.size]
  end
  #--------------------------------------------------------------------------
  # ● 再次 取得项目名称 index 所在位置
  #--------------------------------------------------------------------------
  def get_command_name(name_array)
    name_array.is_a?(String) ? name_array : name_array[0].is_a?(Array) ?  get_command_name(name_array[0]) : name_array[0]
  end
  #--------------------------------------------------------------------------
  # ● 描绘项目标记 index 所在位置
  #--------------------------------------------------------------------------
  def draw_flag(index,branch=false)
    x, y = check_index_xy index
    src_rect  = Rect.new(x+16,y+10,16,16)
    self.contents.fill_rect(src_rect, Color.new(0,0,0,0))
    dest_rect = branch ? Rect.new(152, 40, 16, 16): Rect.new(168, 24, 16, 16)
    src_bitmap= RPG::Cache.windowskin($game_system.windowskin_name)
    self.contents.stretch_blt(src_rect, src_bitmap, dest_rect)
  end
  #--------------------------------------------------------------------------
  # ● 检查 index 所在坐标
  #--------------------------------------------------------------------------
  def check_index_xy(index)
    # 反复迭代,直到index最后一位
    str = "["
    if index[0] > 0
      for i in 0...index[0]
        str += @spread_command[i].true_to_s + "," rescue str += "1,"
      end
    end
    if @spread_command[index[0]].is_a?(Array) and index.size > 1
      str += check_spread(@spread_command[index[0]],index[1...index.size]) + ","
    end
    [index.size * 32 - 32, eval(str += "]").self_all_plus * 32]
  end
  #--------------------------------------------------------------------------
  # ● 检查展开项目,返回项目数 
  #--------------------------------------------------------------------------
  def check_spread(array,index)
    str = "["
    if index[0] > 0
      for i in 0...index[0]
        str += array[i].true_to_s + "," rescue str += "1,"
      end
    end
    if array[index[0]].is_a?(Array) and index.size > 1
      str += check_spread(array[index[0]],index[1...index.size]) + ","
    end
    str += "]"
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    @new_bitmap.bitmap.dispose
    @new_bitmap.dispose
    @v.dispose
    super
  end
  #--------------------------------------------------------------------------
  # ● 设置光标的位置
  #--------------------------------------------------------------------------
  def index=(index)
    @index = index
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # ● 检查指定项目大小 index : 
  #--------------------------------------------------------------------------
  def check_command_size(index,commands=@true_commands)
    return commands.size if index.size == 1
    check_command_size(index[1...index.size],commands[index[0]])
  end
  #--------------------------------------------------------------------------
  # ● 关闭展开父选项
  #--------------------------------------------------------------------------
  def folder(index,close=true)
    if close
      return if index.size == 1 if closed?(index)
      return folder(index[0...index-1],close) if closed?(index)
      x1, y1 = check_index_xy(index)
      Graphics.freeze
      temp = @spread_command.self_all_plus
      eval("@spread_command#{@index.new_to_s} = 1 ")
      new_height = ((@spread_command.self_all_plus - temp).abs + 1) * 32
      src_rect      = Rect.new(0,0,self.width,self.contents.height)
      dest_rect     = Rect.new(0,y1+new_height,self.width,self.contents.height)
      @new_bitmap.bitmap.stretch_blt(src_rect, self.contents, dest_rect)
      src_rect  = Rect.new(0,y1,self.width,self.contents.height)
      self.contents.fill_rect(src_rect, Color.new(0,0,0,0))
      @new_bitmap.y= y1 + new_height
      @move_to     = -new_height + 32
      @to_refresh  = -1
      draw_command(@index,false)
      Graphics.transition(10)
    else
      return if !is_folder?(@true_commands,index)
      return @index.push(1) if !closed?(index)
      new_height = check_command_size(index+[0]) * 32 - 32
      x1, y1 = check_index_xy(index+[0])
      @new_bitmap.bitmap.clear
      @new_bitmap.y = y1 + 32
      src_rect      = Rect.new(0 ,0    ,self.width,self.contents.height)
      dest_rect     = Rect.new(0,y1+32,self.width,self.contents.height)
      @new_bitmap.bitmap.stretch_blt(src_rect, self.contents, dest_rect)
      src_rect  = Rect.new(0,y1,self.width,self.contents.height)
      self.contents.fill_rect(src_rect, Color.new(0,0,0,0))
      @move_to     = new_height
      @to_refresh  = 1
      draw_command(@index,true)
      size = "1," * check_command_size(@index+[0])
      eval("@spread_command#{@index.new_to_s} = [#{size}] ")
    end
  end
  #--------------------------------------------------------------------------
  # ● 移动项目
  #--------------------------------------------------------------------------
  def move_command
    if @move_to == 0 and @to_refresh != 0
      if @to_refresh == 1
        @to_refresh = 0
        for i in 1...check_command_size(@index+[0])
          draw_command(@index+[i])
        end
        Graphics.freeze
        src_rect  = Rect.new(@new_bitmap.x,@new_bitmap.y,self.width,self.contents.height)
        dest_rect = Rect.new(0,0,self.width,self.contents.height)
        self.contents.stretch_blt(src_rect, @new_bitmap.bitmap, dest_rect)
        @new_bitmap.bitmap.clear
        Graphics.transition(10)
         @index << 1
      else
        @to_refresh = 0
        src_rect  = Rect.new(@new_bitmap.x,@new_bitmap.y,self.width,self.contents.height)
        dest_rect = Rect.new(0,0,self.width,self.contents.height)
        self.contents.stretch_blt(src_rect, @new_bitmap.bitmap, dest_rect)
        @new_bitmap.bitmap.clear
      end
    end
    return if @move_to == 0
    step = @move_to/@move_to.abs * 4
    @move_to -= step
    @new_bitmap.y += step
  end
  #--------------------------------------------------------------------------
  # ● 父选项已关闭? @spread_command
  #--------------------------------------------------------------------------
  def closed?(index,commands=@spread_command)
    return true if !commands[index[0]].is_a?(Array)
    return closed?(index[1...index.size],commands[index[0]]) if index.size > 1
    false
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    super
    move_command
    return if @to_refresh != 0
    if self.active 
      # 方向键下被按下的情况下
      if Input.repeat?(Input::DOWN)
        $game_system.se_play($data_system.cursor_se)
        @index[-1] = (@index[-1]+1)%check_command_size(@index)
        @index[-1] += 1 if @index.size > 1 and @index[-1] == 0
        @index = [0] if @index == [@true_commands.size-1]
      end
      # 方向键上被按下的情况下
      if Input.repeat?(Input::UP)
        $game_system.se_play($data_system.cursor_se)
        @index[-1] -= 1 if @index.size > 1 and @index[-1] == 1
        @index[-1] -= 1 if @index == [0]
        @index[-1] = (@index[-1]-1)%check_command_size(@index)
      end
      # 方向键左被按下的情况下
      if Input.trigger?(Input::LEFT)
        if @index.size == 1
          $game_system.se_play($data_system.buzzer_se)
        else
          @index.pop
          $game_system.se_play($data_system.cancel_se)
        end
      end
      # 方向键右被按下的情况下
      if Input.trigger?(Input::RIGHT)
        if is_folder?(@true_commands,@index)
          $game_system.se_play($data_system.decision_se)
          folder(@index,false)
        end
      end
      # B键被按下的情况下
      if Input.trigger?(Input::B)
        if @index.size == 1
          $game_system.se_play($data_system.buzzer_se)
        else
          @index.pop
          $game_system.se_play($data_system.cancel_se)
          folder(@index)
        end
      end
      # C键被按下的情况下
      if Input.trigger?(Input::C)
        @c = !is_folder?(@true_commands,@index)
        if is_folder?(@true_commands,@index)
          $game_system.se_play($data_system.decision_se)
          folder(@index,false)
        end
      end
    end
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # ● 更新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    x, y = check_index_xy(@index)
    if y - self.oy >= self.height - 32
      self.oy        += 32
      @new_bitmap.oy += 32
    elsif y - self.oy < 0
      self.oy        -= 32
      @new_bitmap.oy -= 32
    end
    self.cursor_rect.set(x, y-self.oy, [email protected]_to_s.size/3*32, 32)
  end
end
#==============================================================================
# ■ Array
#------------------------------------------------------------------------------
#  数组类  又拿数组开刀...
#==============================================================================
class Array
  #--------------------------------------------------------------------------
  # ● 转换 真 字符串
  #--------------------------------------------------------------------------
  def true_to_s
    string = "["
    for unit in self
      string += unit.is_a?(Array) ? unit.true_to_s + "," : "#{unit},"
    end
    string + "]"
  end
  #--------------------------------------------------------------------------
  # ● 转换 新 字符串
  #--------------------------------------------------------------------------
  def new_to_s
    string = ""
    for unit in self
      string += "[#{unit}]"
    end
    string
  end
  #--------------------------------------------------------------------------
  # ● 全部 自相加
  #--------------------------------------------------------------------------
  def self_all_plus
    var = 0
    self.each {|unit| var +=  unit.is_a?(Array) ? unit.self_all_plus : 1}
    var
  end
end
 沙漠点灰于2011-5-1 17:50补充以下内容:
 鼠标版:
 用的鼠标脚本是没有内置dll的那个 Mouse.get_mouse_pos
 可以把我的两个范例(http://rpg.blue/thread-174282-1-1.html
 http://rpg.blue/thread-175789-1-1.html)替换掉
 下面美化脚本(移动光标):
 下面是鼠标版:复制代码#==============================================================================
# ■ Rect
#------------------------------------------------------------------------------
#  矩形类
#==============================================================================
# 移动帧数,自己改
Cursor_Rect_Move = 10
class Rect
  # 设置
  alias old_set set unless Rect.method_defined? "old_set"
  def set(x,y,w,h,de=false)
    if @target_rect.is_a?(Rect)
      return if @target_rect == Rect.new(x,y,w,h)
    end
    if de
      @cursor_rect_move = Cursor_Rect_Move
      @target_rect = Rect.new(x,y,w,h)
    else
      self.old_set(x,y,w,h)
    end
  end
  # 刷新
  def update
    return unless @target_rect and @cursor_rect_move
    return if @cursor_rect_move <= 0
    x = (@target_rect.x - self.x) / @cursor_rect_move
    y = (@target_rect.y - self.y) / @cursor_rect_move
    w = (@target_rect.width - self.width) / @cursor_rect_move 
    h = (@target_rect.height - self.height) / @cursor_rect_move
    @cursor_rect_move -= 1
    self.old_set(x+self.x,y+self.y,w+self.width,h+self.height)
  end
end
#==============================================================================
# ■ Window_Selectable
#------------------------------------------------------------------------------
#  拥有光标的移动以及滚动功能的窗口类。
#==============================================================================
class Window_Selectable < Window_Base
  #--------------------------------------------------------------------------
  # ● 更新光标举行
  #--------------------------------------------------------------------------
  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 - 32
    # 计算光标坐标
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 32 - self.oy
    # 更新国标矩形
    self.cursor_rect.set(x, y, cursor_width, 32,true)
  end
end
#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
#  显示文章的信息窗口。
#==============================================================================
class Window_Message < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index >= 0
      n = $game_temp.choice_start + @index
      self.cursor_rect.set(8, n * 32, @cursor_width, 32,true)
    else
      self.cursor_rect.empty
    end
  end
end
最后,附赠范例(RM文件浏览,据说可以拿来CG、BGM鉴赏)复制代码 * 此脚本归66RPG - Idiot Script Association(ISA)所有,谢绝任何形式转载。
#______________________________________________________________________________
#==============================================================================
# ■ 子选项 - Sub-option
#------------------------------------------------------------------------------
#   遵守协议:66RPG - Idiot Script Association(ISA)
#   当前版本:0.9.7.0
#------------------------------------------------------------------------------
#   更新日记:沙漠.灰(2011.4.2)
#             - 初始化
#             沙漠.灰(2011.4.16)
#             - 0.95版放出
#             沙漠.灰(2011.5.1)
#             - 0.97版放出
#=============================================================================
class Window_Folder < Window_Base
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :index                    # 光标位置
  attr_reader   :c
  #--------------------------------------------------------------------------
  # ● 初始画对像
  #     x      : 窗口的 X 坐标
  #     y      : 窗口的 Y 坐标
  #     width  : 窗口的宽
  #     height : 窗口的高
  #--------------------------------------------------------------------------
  def initialize(x,y,width, height, commands)
    commands += ["-"*(width/11)]
    super(x, y, width, height)
    # 初始化数据
    @move_to        = 0
    @to_refresh     = false
    @commands_size  = 0
    @c              = false
    @index          = [0]
    @spread_command = []
    @disable_item   = []
    commands.size.times{@spread_command.push(1)}
    @true_commands  = commands
    @object_id = 0
    # 生成位图
    self.contents = Bitmap.new(width - 32, @true_commands.self_all_plus * 32-32)
    @v = Viewport.new(16+self.x, 16+self.y, width-32, height-32) ; @v.z = 999
    @new_bitmap = Sprite.new(@v)
    @new_bitmap.bitmap = Bitmap.new(width - 32, @true_commands.self_all_plus * 32-32)
    index = 0 # 描绘顶层项目
    # 描绘父项目
    for unit in @true_commands
      draw_command [index]
      index += 1
    end
  end
  #--------------------------------------------------------------------------
  # ● 项目无效化 index : 项目编号
  #--------------------------------------------------------------------------
  def disable_item(index)
    @disable_item.push(index)
  end
  #--------------------------------------------------------------------------
  # ● 指定项目是否为父项目 index 所在位置
  #--------------------------------------------------------------------------
  def is_folder?(commands,index)
    # 若指定项目为数组且子单元数目大于1就判定为父项目
    if index.size == 1 and commands[index[0]].is_a?(Array)
      return true if commands[index[0]].size > 1
    elsif index.size > 1
      return is_folder?(commands[index[0]],index[1...index.size])
    end
    false
  end
  #--------------------------------------------------------------------------
  # ● 描绘项目名称 index 所在位置  branch 是否分支
  #--------------------------------------------------------------------------
  def draw_command(index,branch=false)
    x, y = check_index_xy(index)
    rect = Rect.new(x+32,y,self.width-32,32)
    self.contents.font.color = disabled_color if @disable_item.include?(index)
    name = get_command(@true_commands,index)
    self.contents.draw_text(rect, name)
    # 为父项目时,描绘指引
    draw_flag(index,branch) if is_folder?(@true_commands,index)
    self.contents.font.color = normal_color
  end
  #--------------------------------------------------------------------------
  # ● 取得项目名称 index 所在位置
  #--------------------------------------------------------------------------
  def get_command(name_array,index)
    return get_command_name(name_array[index[0]]) if index.size == 1
    get_command name_array[index[0]],index[1...index.size]
  end
  #--------------------------------------------------------------------------
  # ● 再次 取得项目名称 index 所在位置
  #--------------------------------------------------------------------------
  def get_command_name(name_array)
    name_array.is_a?(String) ? name_array : name_array[0].is_a?(Array) ?  get_command_name(name_array[0]) : name_array[0]
  end
  #--------------------------------------------------------------------------
  # ● 描绘项目标记 index 所在位置
  #--------------------------------------------------------------------------
  def draw_flag(index,branch=false)
    x, y = check_index_xy index
    src_rect  = Rect.new(x+16,y+10,16,16)
    self.contents.fill_rect(src_rect, Color.new(0,0,0,0))
    dest_rect = branch ? Rect.new(152, 40, 16, 16): Rect.new(168, 24, 16, 16)
    src_bitmap= RPG::Cache.windowskin($game_system.windowskin_name)
    self.contents.stretch_blt(src_rect, src_bitmap, dest_rect)
  end
  #--------------------------------------------------------------------------
  # ● 检查 index 所在坐标
  #--------------------------------------------------------------------------
  def check_index_xy(index)
    # 反复迭代,直到index最后一位
    str = "["
    if index[0] > 0
      for i in 0...index[0]
        str += @spread_command[i].true_to_s + "," rescue str += "1,"
      end
    end
    if @spread_command[index[0]].is_a?(Array) and index.size > 1
      str += check_spread(@spread_command[index[0]],index[1...index.size]) + ","
    end
    [index.size * 32 - 32, eval(str += "]").self_all_plus * 32]
  end
  #--------------------------------------------------------------------------
  # ● 检查展开项目,返回项目数 
  #--------------------------------------------------------------------------
  def check_spread(array,index)
    str = "["
    if index[0] > 0
      for i in 0...index[0]
        str += array[i].true_to_s + "," rescue str += "1,"
      end
    end
    if array[index[0]].is_a?(Array) and index.size > 1
      str += check_spread(array[index[0]],index[1...index.size]) + ","
    end
    str += "]"
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    @new_bitmap.bitmap.dispose
    @new_bitmap.dispose
    @v.dispose
    super
  end
  #--------------------------------------------------------------------------
  # ● 设置光标的位置
  #--------------------------------------------------------------------------
  def index=(index)
    @index = index
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # ● 检查指定项目大小 index : 
  #--------------------------------------------------------------------------
  def check_command_size(index,commands=@true_commands)
    return commands.size if index.size == 1
    check_command_size(index[1...index.size],commands[index[0]])
  end
  #--------------------------------------------------------------------------
  # ● 关闭\展开父选项
  #--------------------------------------------------------------------------
  def folder(index,close=true)
    if close
      return if index.size == 1 if closed?(index)
      return folder(index[0...index-1],close) if closed?(index)
      x1, y1 = check_index_xy(index)
      Graphics.freeze
      temp = @spread_command.self_all_plus
      eval("@spread_command#{@index.new_to_s} = 1 ")
      new_height = ((@spread_command.self_all_plus - temp).abs + 1) * 32
      src_rect      = Rect.new(0,0,self.width,self.contents.height)
      dest_rect     = Rect.new(0,y1+new_height,self.width,self.contents.height)
      @new_bitmap.bitmap.stretch_blt(src_rect, self.contents, dest_rect)
      src_rect  = Rect.new(0,y1,self.width,self.contents.height)
      self.contents.fill_rect(src_rect, Color.new(0,0,0,0))
      @new_bitmap.y= y1 + new_height
      @move_to     = -new_height + 32
      @to_refresh  = -1
      draw_command(@index,false)
      Graphics.transition(10)
    else
      return if !is_folder?(@true_commands,index)
      return @index.push(1) if !closed?(index)
      new_height = check_command_size(index+[0]) * 32 - 32
      x1, y1 = check_index_xy(index+[0])
      @new_bitmap.bitmap.clear
      @new_bitmap.y = y1 + 32
      src_rect      = Rect.new(0 ,0    ,self.width,self.contents.height)
      dest_rect     = Rect.new(0,y1+32,self.width,self.contents.height)
      @new_bitmap.bitmap.stretch_blt(src_rect, self.contents, dest_rect)
      src_rect  = Rect.new(0,y1,self.width,self.contents.height)
      self.contents.fill_rect(src_rect, Color.new(0,0,0,0))
      @move_to     = new_height
      @to_refresh  = 1
      draw_command(@index,true)
      size = "1," * check_command_size(@index+[0])
      eval("@spread_command#{@index.new_to_s} = [#{size}] ")
    end
  end
  #--------------------------------------------------------------------------
  # ● 移动项目
  #--------------------------------------------------------------------------
  def move_command
    if @move_to == 0 and @to_refresh != 0
      if @to_refresh == 1
        @to_refresh = 0
        for i in 1...check_command_size(@index+[0])
          draw_command(@index+[i])
        end
        Graphics.freeze
        src_rect  = Rect.new(@new_bitmap.x,@new_bitmap.y,self.width,self.contents.height)
        dest_rect = Rect.new(0,0,self.width,self.contents.height)
        self.contents.stretch_blt(src_rect, @new_bitmap.bitmap, dest_rect)
        @new_bitmap.bitmap.clear
        Graphics.transition(10)
         @index << 1
      else
        @to_refresh = 0
        src_rect  = Rect.new(@new_bitmap.x,@new_bitmap.y,self.width,self.contents.height)
        dest_rect = Rect.new(0,0,self.width,self.contents.height)
        self.contents.stretch_blt(src_rect, @new_bitmap.bitmap, dest_rect)
        @new_bitmap.bitmap.clear
      end
    end
    return if @move_to == 0
    step = @move_to/@move_to.abs * 4
    @move_to -= step
    @new_bitmap.y += step
  end
  #--------------------------------------------------------------------------
  # ● 父选项已关闭? @spread_command
  #--------------------------------------------------------------------------
  def closed?(index,commands=@spread_command)
    return true if !commands[index[0]].is_a?(Array)
    return closed?(index[1...index.size],commands[index[0]]) if index.size > 1
    false
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    super
    move_command
    return if @to_refresh != 0
    if self.active 
      # 方向键下被按下的情况下
      if Input.repeat?(Input::DOWN)
        $game_system.se_play($data_system.cursor_se)
        @index[-1] = (@index[-1]+1)%check_command_size(@index)
        @index[-1] += 1 if @index.size > 1 and @index[-1] == 0
        @index = [0] if @index == [@true_commands.size-1]
      end
      # 方向键上被按下的情况下
      if Input.repeat?(Input::UP)
        $game_system.se_play($data_system.cursor_se)
        @index[-1] -= 1 if @index.size > 1 and @index[-1] == 1
        @index[-1] -= 1 if @index == [0]
        @index[-1] = (@index[-1]-1)%check_command_size(@index)
      end
      # 方向键左被按下的情况下
      if Input.trigger?(Input::LEFT)
        if @index.size == 1
          $game_system.se_play($data_system.buzzer_se)
        else
          @index.pop
          $game_system.se_play($data_system.cancel_se)
        end
      end
      # 方向键右被按下的情况下
      if Input.trigger?(Input::RIGHT)
        if is_folder?(@true_commands,@index)
          $game_system.se_play($data_system.decision_se)
          folder(@index,false)
        end
      end
      # B键被按下的情况下
      if Input.trigger?(Input::B)
        if @index.size == 1
          $game_system.se_play($data_system.buzzer_se)
        else
          @index.pop
          $game_system.se_play($data_system.cancel_se)
          folder(@index)
        end
      end
      # C键被按下的情况下
      if Input.trigger?(Input::C)
        @c = !is_folder?(@true_commands,@index)
        if is_folder?(@true_commands,@index)
          $game_system.se_play($data_system.decision_se)
          folder(@index,false)
        end
      end
    end
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # ● 更新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    return if @move_to != 0
    mouse_x, mouse_y = Mouse.get_mouse_pos
    # y 坐标修正
    mouse_y -= 16
    if mouse_x > self.x and mouse_x < self.x + self.width and
      mouse_y > self.y - 32 and self.y > mouse_y and self.oy > 0
      self.oy        -= 32
      @new_bitmap.oy -= 32
    end
    iindex = @index.dup
    begin
      if mouse_y > self.y and mouse_y < self.y + self.height and
        mouse_x > self.x and mouse_x < self.x + self.width
        pos = ((mouse_y - self.y+self.oy)/32).to_i
        str = @spread_command.true_to_s.pos(pos+1,"1") + "2"
        size = str.unit_size("[")-str.unit_size("]")
        str += "]" * size
        begin
          @index = eval((eval(str)).pos_(2).gsub("]["){","})
        rescue
          @index = eval((eval(str)).pos_(2))
        end
        @index = [@true_commands.size-2] if @index.size == 1 and @index[0] == @true_commands.size-1
      end
    rescue
      # 超过范围
      @index = iindex
    end
    x, y = check_index_xy(@index)
    if y - self.oy >= self.height - 32
      self.oy        += 32
      @new_bitmap.oy += 32
    elsif y - self.oy < 0
      self.oy        -= 32
      @new_bitmap.oy -= 32
    end
    self.cursor_rect.set(x, y-self.oy, [email protected]_to_s.size/3*32, 32, true)
  end
end
#==============================================================================
# ■ Array
#------------------------------------------------------------------------------
#  数组类  又拿数组开刀...
#==============================================================================
class Array
  #--------------------------------------------------------------------------
  # ● 返回目标位置 [[1,1,1,1],1,1,2]
  #--------------------------------------------------------------------------
  def pos_(unit)
    string = ""
    times = 0
    for i in self
      if i.is_a?(Array)
        string += "[#{times}]#{i.pos_(unit)}" if i.true_to_s.include?(unit.to_s)
      else
        string += "[#{times}]" if i == unit
        break if i == unit
      end
      times += 1
    end
    string
  end
  #--------------------------------------------------------------------------
  # ● 转换 真 字符串
  #--------------------------------------------------------------------------
  def true_to_s
    string = "["
    for unit in self
      string += unit.is_a?(Array) ? unit.true_to_s + "," : "#{unit},"
    end
    string + "]"
  end
  #--------------------------------------------------------------------------
  # ● 转换 新 字符串
  #--------------------------------------------------------------------------
  def new_to_s
    string = ""
    for unit in self
      string += "[#{unit}]"
    end
    string
  end
  #--------------------------------------------------------------------------
  # ● 全部 自相加
  #--------------------------------------------------------------------------
  def self_all_plus
    var = 0
    self.each {|unit| var +=  unit.is_a?(Array) ? unit.self_all_plus : 1}
    var
  end
end
#==============================================================================
# ■ String
#------------------------------------------------------------------------------
#  字符类  拿字符开刀了!
#==============================================================================
class String
  def pos(var,str)
    temp = 0
    self.size.times {|i|
    temp += 1 if self[i,1] == str
    return self[0,i] if temp == var}
  end
  def unit_size(unit)
    temp = 0
    self.size.times {|i|
    temp += 1 if self[i,1] == unit}
    return temp
  end
end
 | 
 |