幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3619|回复: 21

[分享][原创]存档/读档加强

[复制链接]

33

主题

152

帖子

2555

积分

⑥精研

第七封印-使者-龙

积分
2555
QQ
发表于 2005-1-18 16:19:13 | 显示全部楼层 |阅读模式
首先当然是先放脚本了,效果后放。。。。。

注意:红的部分是修改和追加的。。。。

第一个脚本改"Scene_File"

#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
#  存档画面及读档画面的超级类。
#==============================================================================

class Scene_File
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     help_text : 帮助窗口显示的字符串
  #--------------------------------------------------------------------------
  def initialize(help_text)
    @help_text = help_text
  end
  #--------------------------------------------------------------------------
  # ● 主处理
  #--------------------------------------------------------------------------
  def main
    # 生成帮助窗口
    @help_window = Window_Help.new
    @help_window.set_text(@help_text)
    # 生成存档文件查
    @savefile_windows = []
#--------------------------------------------------------------------------
  # ● 增加一个for循环(j)
  #--------------------------------------------------------------------------
    for i in 0..1
        @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
    end
    for j in 2..3
        @savefile_windows.push(Window_SaveFile2.new(j, make_filename(i)))
    end
  #--------------------------------------------------------------------------
    # 选择最后操作的文件
    @file_index = $game_temp.last_file_index
    @savefile_windows[@file_index].selected = true
    # 执行过渡
    Graphics.transition
    # 主循环
    loop do
      # 刷新游戏画面
      Graphics.update
      # 刷新输入信息
      Input.update
      # 刷新画面
      update
      # 如果画面被切换的话就中断循环
      if $scene != self
        break
      end
    end
    # 准备过渡
    Graphics.freeze
    # 释放窗口
    @help_window.dispose
    for i in @savefile_windows
      i.dispose
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    # 刷新窗口
    @help_window.update
    for i in @savefile_windows
      i.update
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 调用过程 on_decision (定义继承目标)
      on_decision(make_filename(@file_index))
      $game_temp.last_file_index = @file_index
      return
    end
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 调用过程 on_cancel (定义继承目标)
      on_cancel
      return
    end
    # 按下方向键下的情况下
    if Input.repeat?(Input:OWN)
      # 方向键下的按下状态不是重复的情况下、
      # 并且光标的位置在 3 以前的情况下
      if Input.trigger?(Input:OWN) or @file_index < 3
        # 演奏光标 SE
        $game_system.se_play($data_system.cursor_se)
        # 光标向下移动
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 1) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
    # 按下方向键上的情况下
    if Input.repeat?(Input::UP)
      # 方向键上的按下状态不是重复的情况下、
      # 并且光标的位置在 0 以后的情况下
      if Input.trigger?(Input::UP) or @file_index > 0
        # 演奏光标 SE
        $game_system.se_play($data_system.cursor_se)
        # 光标向上移动
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index - 1) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
   #--------------------------------------------------------------------------
    # 按左方向键下的情况下
    if Input.repeat?(Input::RIGHT)
      # 方向键左的按下状态不是重复的情况下、
      # 并且光标的位置在 3 以前的情况下
      if Input.trigger?(Input::RIGHT) or @file_index < 0 or @file_index < 1
        # 演奏光标 SE
        $game_system.se_play($data_system.cursor_se)
        # 光标向左移动
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index - 2) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
    # 按右方向键上的情况下
    if Input.repeat?(Input:EFT)
      # 方向键右的按下状态不是重复的情况下、
      # 并且光标的位置在 3 以前的情况下
      if Input.trigger?(Input:EFT) or @file_index < 2 or @file_index < 3
        # 演奏光标 SE
        $game_system.se_play($data_system.cursor_se)
        # 光标向右移动
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 2) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
    #--------------------------------------------------------------------------
  end
  #--------------------------------------------------------------------------
  # ● 生成文件名
  #     file_index : 文件名的索引 (0~3)
  #--------------------------------------------------------------------------
  def make_filename(file_index)
    return "Save#{file_index + 1}.rxdata"
  end
end


@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

第二个改动"Window_SaveFile"

#==============================================================================
# ■ Window_SaveFile
#------------------------------------------------------------------------------
#  显示存档以及读档画面、保存文件的窗口。
#==============================================================================

class Window_SaveFile < Window_Base
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :filename                 # 文件名
  attr_reader   :selected                 # 选择状态
  attr_reader   :level                    # 水平
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     file_index : 存档文件的索引 (0~3)
  #     filename   : 文件名
  #--------------------------------------------------------------------------
  def initialize(file_index, filename)
    super(0, 64 + file_index % 2 * 200, 320, 220)
    self.contents = Bitmap.new(width - 32, height - 32)
    @file_index = file_index
    @filename = "Save#{@file_index + 1}.rxdata"
    @time_stamp = Time.at(0)
    @file_exist = FileTest.exist?(@filename)
    if @file_exist
      file = File.open(@filename, "r")
      @time_stamp = file.mtime
      @characters = Marshal.load(file)
      @battler = Marshal.load(file)
      @frame_count = Marshal.load(file)
      @game_system = Marshal.load(file)
      @game_switches = Marshal.load(file)
      @game_variables = Marshal.load(file)
      file.close
    end
    refresh
    @selected = false
  end
#--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    # 描绘文件编号
    self.contents.font.color = normal_color
    if @file_index == 0
     name = "游戲檔 — — — — — 壹"
    end
    if @file_index == 1
     name = "游戲檔 — — — — — 贰"
    end
    self.contents.draw_text(10, 0, 310, 32, name)
    @name_width = contents.text_size(name).width
    # 存档文件存在的情况下
    if @file_exist
      # 描绘角色
      for i in
0...@characters.size      

        bitmap = RPG::Cache.character(@characters[0], @characters[1])
        cw = bitmap.rect.width / 4
        ch = bitmap.rect.height / 4
        src_rect = Rect.new(0, 0, cw, ch)
        x = 70 - @characters.size * 32 + i * 64 - cw / 2
        self.contents.blt(x, 90 - ch, bitmap, src_rect)
      end
     
      #------------------------------------------------------------------------
      self.contents.draw_text(50, 15, 150, 50, "角色名稱:", 1)
      self.contents.draw_text(50, 45, 150, 50, "角色职业:", 1)
      self.contents.draw_text(2, 85, 150, 50, "角色體力:", 1)
      self.contents.draw_text(2, 105, 150, 50, "角色精神:", 1)
      self.contents.draw_text(2, 125, 150, 50, "杀敌個数:", 1)
      self.contents.draw_text(2, 145, 150, 50, "持有金钱:", 1)
     
      else
      #------------------------------------------------------------------------
      self.contents.draw_text(50, 15, 150, 50, "角色名稱:", 1)
      self.contents.draw_text(50, 45, 150, 50, "角色职业:", 1)
      self.contents.draw_text(2, 85, 150, 50, "角色體力:", 1)
      self.contents.draw_text(2, 105, 150, 50, "角色精神:", 1)
      self.contents.draw_text(2, 125, 150, 50, "杀敌個数:", 1)
      self.contents.draw_text(2, 145, 150, 50, "持有金钱:", 1)
   
    end
  end
  #--------------------------------------------------------------------------
  # ● 设置选择状态
  #     selected : 新的选择状态 (true=选择 false=不选择)
  #--------------------------------------------------------------------------
  def selected=(selected)
    @selected = selected
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @selected
      self.cursor_rect.set(0, 0, @name_width + 8, 32)
    else
      self.cursor_rect.empty
    end
  end
end




@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

[此贴子已经被作者于2005-1-20 16:02:10编辑过]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
制作更好,挑战高难度 QQ:233944397 新开03研讨群:20673132 我的网站:http://www.itcat-gm.net
回复

使用道具 举报

512 该用户已被删除
发表于 2005-1-18 16:22:10 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

512 该用户已被删除
发表于 2005-1-18 16:25:22 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

carol3 该用户已被删除
发表于 2005-1-18 22:22:21 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

33

主题

152

帖子

2555

积分

⑥精研

第七封印-使者-龙

积分
2555
QQ
 楼主| 发表于 2005-1-19 14:46:40 | 显示全部楼层
有错就改,繁体追求

续一楼

····························

同时再建一个\"Window_SaveFile2\"

#==============================================================================
# ■ Window_SaveFile
#------------------------------------------------------------------------------
#  显示存档以及读档画面、保存文件的窗口。
#==============================================================================

class Window_SaveFile2 < Window_Base
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :filename                 # 文件名
  attr_reader   :selected                 # 选择状态
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     file_index : 存档文件的索引 (0~3)
  #     filename   : 文件名
  #--------------------------------------------------------------------------
  def initialize(file_index, filename)
    super(320, 64 + file_index % 2 * 200, 320, 220)
    self.contents = Bitmap.new(width - 32, height - 32)
    @file_index = file_index
    @filename = \"Save#{@file_index + 1}.rxdata\"
    @time_stamp = Time.at(0)
    @file_exist = FileTest.exist?(@filename)
    if @file_exist
      file = File.open(@filename, \"r\")
      @time_stamp = file.mtime
      @characters = Marshal.load(file)
      @frame_count = Marshal.load(file)
      @game_system = Marshal.load(file)
      @game_switches = Marshal.load(file)
      @game_variables = Marshal.load(file)
      @total_sec = @frame_count / Graphics.frame_rate
      file.close
    end
    refresh
    @selected = false
  end
  #----------------------------------------------------------------------------
  def initialize2(file_index2, filename2)
    super(204, 64 + file_index % 4 * 200, 320, 200)
    self.contents = Bitmap.new(width - 32, height - 32)
    @file_index = file_index
    @filename = \"Save#{@file_index + 1}.rxdata\"
    @time_stamp = Time.at(0)
    @file_exist = FileTest.exist?(@filename)
    if @file_exist
      file = File.open(@filename, \"r\")
      @time_stamp = file.mtime
      @characters = Marshal.load(file)
      @frame_count = Marshal.load(file)
      @game_system = Marshal.load(file)
      @game_switches = Marshal.load(file)
      @game_variables = Marshal.load(file)
      @total_sec = @frame_count / Graphics.frame_rate
      file.close
    end
    refresh2
    @selected = false
  end
#--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    # 描绘文件编号
    self.contents.font.color = normal_color
    if @file_index == 2
     name = \"游戲檔 — — — — — 叁\"
    end
    if @file_index == 3
     name = \"游戲檔 — — — — — 肆\"
    end
    self.contents.draw_text(10, 0, 310, 32, name)
    @name_width = contents.text_size(name).width
    # 存档文件存在的情况下
    if @file_exist
      # 描绘角色
       for i in
0...@characters.size

        bitmap = RPG::Cache.character(@characters[0], @characters[1])
        cw = bitmap.rect.width / 4
        ch = bitmap.rect.height / 4
        src_rect = Rect.new(0, 0, cw, ch)
        x = 70 - @characters.size * 32 + i * 64 - cw / 2
        self.contents.blt(x, 90 - ch, bitmap, src_rect)
      end
     
      #------------------------------------------------------------------------
      self.contents.draw_text(50, 15, 150, 50, \"角色名稱:\" , 1)
      self.contents.draw_text(50, 45, 150, 50, \"角色职业:\", 1)
      self.contents.draw_text(2, 85, 150, 50, \"角色體力:\", 1)
      self.contents.draw_text(2, 105, 150, 50, \"角色精神:\", 1)
      self.contents.draw_text(2, 125, 150, 50, \"杀敌個数:\", 1)
      self.contents.draw_text(2, 145, 150, 50, \"持有金钱:\", 1)
     
      else
      #------------------------------------------------------------------------
      self.contents.draw_text(50, 15, 150, 50, \"角色名稱:\", 1)
      self.contents.draw_text(50, 45, 150, 50, \"角色职业:\", 1)
      self.contents.draw_text(2, 85, 150, 50, \"角色體力:\", 1)
      self.contents.draw_text(2, 105, 150, 50, \"角色精神:\", 1)
      self.contents.draw_text(2, 125, 150, 50, \"杀敌個数:\", 1)
      self.contents.draw_text(2, 145, 150, 50, \"持有金钱:\", 1)
     
    end
  end
  #--------------------------------------------------------------------------
  # ● 设置选择状态
  #     selected : 新的选择状态 (true=选择 false=不选择)
  #--------------------------------------------------------------------------
  def selected=(selected)
    @selected = selected
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @selected
      self.cursor_rect.set(0, 0, @name_width + 8, 32)
    else
      self.cursor_rect.empty
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh2
    self.contents.clear
    # 描绘文件编号
    self.contents.font.color = normal_color
    name = \"游戲檔 #{@file_index + 1}\"
    self.contents.draw_text(4, 0, 104, 32, name)
    @name_width = contents.text_size(name).width
    # 存档文件存在的情况下
    if @file_exist
      # 描绘角色
      for i in 0...@characters.size
        bitmap = RPG::Cache.character(@characters[0], @characters[1])
        cw = bitmap.rect.width / 4
        ch = bitmap.rect.height / 4
        src_rect = Rect.new(0, 0, cw, ch)
        x = 180 - @characters.size * 32 + i * 64 - cw / 2
        self.contents.blt(x, 68 - ch, bitmap, src_rect)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 设置选择状态
  #     selected : 新的选择状态 (true=选择 false=不选择)
  #--------------------------------------------------------------------------
  def selected=(selected)
    @selected = selected
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # ● 刷新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @selected
      self.cursor_rect.set(0, 0, @name_width + 8, 32)
    else
      self.cursor_rect.empty
    end
  end
end




@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

接下来是效果图.........[em05]



[upload=jpg]UploadFile/2005-1/2005118161721448.jpg[/upload]

还有一些图片 AND 这三个脚本,米传上来大家可以到下面的网址下一个网盘:

http://www.vdisk.cn/install/

登陆名&密码:TINE2CX
第一次发教程,不好就请多多包涵!!!

[em05][em05][em05][em05][em05][em05]

[此贴子已经被作者于2005-1-20 16:01:37编辑过]
制作更好,挑战高难度 QQ:233944397 新开03研讨群:20673132 我的网站:http://www.itcat-gm.net
回复 支持 反对

使用道具 举报

carol3 该用户已被删除
发表于 2005-1-19 23:47:44 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

22

主题

766

帖子

3330

积分

⑥精研

事件派RMer

积分
3330
发表于 2005-1-20 06:48:34 | 显示全部楼层
楼上……只要装了全拼输入法就会有繁体啦……
还有……发出来错误好多啊……又要自己慢慢改吗……
……我的签名……怎么倒档了……
回复 支持 反对

使用道具 举报

33

主题

152

帖子

2555

积分

⑥精研

第七封印-使者-龙

积分
2555
QQ
 楼主| 发表于 2005-1-20 11:26:35 | 显示全部楼层
那是当然的啦。

繁体的事等游戏序章出来就明了
制作更好,挑战高难度 QQ:233944397 新开03研讨群:20673132 我的网站:http://www.itcat-gm.net
回复 支持 反对

使用道具 举报

18

主题

230

帖子

3055

积分

⑥精研

积分
3055
QQ
发表于 2005-1-20 12:20:00 | 显示全部楼层
运行不能。。。。。。。。。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 支持 反对

使用道具 举报

33

主题

152

帖子

2555

积分

⑥精研

第七封印-使者-龙

积分
2555
QQ
 楼主| 发表于 2005-1-20 14:00:11 | 显示全部楼层
不能运行?

改了改你再试试看[em06]

实在不行的话,就下个网盘

http://www.vdisk.cn/install/

登陆名&密码:TINE2CX

在我的共享里有这三个脚本
制作更好,挑战高难度 QQ:233944397 新开03研讨群:20673132 我的网站:http://www.itcat-gm.net
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2025-6-27 04:51 , Processed in 0.024191 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表