查看: 3292|回复: 2

[已经解决] 免dll截图存档的一些bug②

[复制链接]
梦石
0
星屑
2957
在线时间
398 小时
注册时间
2013-6-13
回帖
24

开拓者

发表于 2019-1-13 16:06:24 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 水母书亚 于 2019-1-13 16:05 编辑

前年发过一次提问
后来有大佬帮忙修过一遍,现在难道是会和别的脚本冲突?
现在发现了一个新的问题。
如果先打开物品界面然后在存档会截图截到物品栏……
QQ截图20190113154449.png


甚至截到存档界面【按确定进入存档界面不存档直接退出来,再进入存档存一次就会变成这样】
QQ图片20190113155642.jpg


以上反复刷会变成
QQ截图20190113154435.png

存档相关的脚本有这些:

  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],转载和使用请保留此信息
  3. #===============================================================================

  4. BBS_66RPG_DIR = "Save/"  # 储存文件夹名,请制作游戏时自行建立此文件夹

  5. # 若想使用自定义背景图,脚本62行的井号去掉,并放置一张相应图形。

  6. # 在你的Scene_Title中找到这一段(如果使用其他插件脚本,在插件中找):
  7. #    for i in 0..3
  8. #      if FileTest.exist?("Save#{i+1}.rxdata")
  9. # 请自行把0..3改为0..最大进度号,比如0..9
  10. # "Save#{i+1}.rxdata" 改为"Save/Save#{i}.rxdata"

  11. # 增加进度的方法:138,258行,继续添加。你也可以改“进度X”为“回忆X”或者“红/绿/蓝笔记本”

  12. #===============================================================================
  13. module Screen  
  14.   @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
  15.   @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
  16.   @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
  17.   module_function
  18.   #-----------------------------------------------------------------------------
  19.   # here comes the stuff...
  20.   # i add here the stuff for automatic change of the number for the screenshot
  21.   # so it wont overrite the old one...
  22.   # if you want to change so stuff change them in this line below
  23.   # or you can change them in your command line... like
  24.   # Screen::shot("screenshot", 2)
  25.   # this change the name and the type of the screenshot
  26.   # (0 = bmp, 1 = jpg and 2 = png)
  27.   # ----------------------------------------------------------------------------
  28.   def shot(file = "shot", typ = 2)
  29.     # to add the right extension...
  30.     if typ == 0
  31.       typname = ".bmp"
  32.     elsif typ == 1
  33.       typname = ".jpg"
  34.     elsif typ == 2
  35.       typname = ".png"
  36.     end   
  37.     file_index = 0   
  38.     dir = "Save/"   
  39.     # make the filename....
  40.     file_name = dir + file.to_s + typname.to_s   
  41.     # make the screenshot.... Attention dont change anything from here on....
  42.     # @screen.call(0,0,640,480,file_name,handel,typ)
  43.     # 角色在不同的位置,选取不同的截图框
  44.     x = (($game_player.x > $game_map.width - 6)? 1:0) + (($game_player.x < 5)? 0:1)
  45.     y = (($game_player.y > $game_map.height - 4)? 1:0) + (($game_player.y < 4)? 0:1)
  46.     @screen.call(112*x,112*y,416,256,file_name,handel,typ)
  47.   end
  48.   # find the game window...
  49.   def handel
  50.     game_name = "\0" * 256
  51.     @readini.call('Game','Title','',game_name,255,".\\Game.ini")
  52.     game_name.delete!("\0")
  53.     return @findwindow.call('RGSS Player',game_name)
  54.   end
  55.   # 全图截图
  56.   def shot_fast
  57.     dir = "ScreenShot/"   
  58.     # make the filename....   
  59.     file = Time.now.strftime("%Y%m%d_%H%M%S")
  60.     file_name = dir + file + '.png'
  61.     # make the screenshot.... Attention dont change anything from here on....
  62.     @screen.call(0,0,640,480,file_name,handel,2)   
  63.   end
  64. end

  65. class Window_File < Window_Base
  66.   attr_accessor :index
  67.   def initialize(index = 0)
  68.     @backsp = Sprite.new
  69.     #@backsp.bitmap = Bitmap.new("Graphics/Pictures/存盘背景.jpg")
  70.     @backsp.z = 99
  71.     super(160,64,480,416)
  72.     #这行可以不用
  73.     self.contents = Bitmap.new(width - 32, height - 32)
  74.     @index = index
  75.     #这里我要说明一句,之所以用sprite是为了放缩图片
  76.     @sprite = Sprite.new
  77.     @sprite.visible = false
  78.     @sprite.z = 100
  79.     @sp_ch = []
  80.     for i in 0..4
  81.       @sp_ch[i] = Sprite.new
  82.       @sp_ch[i].z = 101
  83.     end
  84.     # 刷新
  85.     refresh
  86.   end
  87.   def refresh
  88.     self.contents.clear
  89.     for i in @sp_ch
  90.       i.visible = false
  91.     end
  92.     @sprite.visible = false
  93.     if FileTest.exist?(BBS_66RPG_DIR+"Save#{@index}.rxdata")         
  94.       @sprite.visible = true
  95.       if FileTest.exist?(BBS_66RPG_DIR+"Save#{@index}.png")
  96.         @sprite.bitmap = Bitmap.new(BBS_66RPG_DIR+"Save#{@index}.png")
  97.       else
  98.         self.contents.draw_text(32,64,400,32,"截图似乎有点问题……")
  99.       end
  100.       @sprite.x = 192
  101.       @sprite.y = 96
  102.       #@sprite.zoom_x = 0.7
  103.       #@sprite.zoom_y = 0.7
  104.       file = File.open(BBS_66RPG_DIR+"Save#{@index}.rxdata", "r")
  105.       @time_stamp = file.mtime
  106.       @characters = Marshal.load(file)
  107.       @frame_count = Marshal.load(file)
  108.       @game_system = Marshal.load(file)
  109.       @game_switches = Marshal.load(file)
  110.       @game_variables = Marshal.load(file)
  111.       Marshal.load(file)
  112.       Marshal.load(file)
  113.       Marshal.load(file)
  114.       @game_party = Marshal.load(file)
  115.       Marshal.load(file)
  116.       @game_map = Marshal.load(file)
  117.       Marshal.load(file)
  118.       @total_sec = @frame_count / Graphics.frame_rate      
  119.       file.close
  120.       # 描绘角色
  121.       i = 0
  122.       @characters.each do |ch_ary|
  123.         character_name, character_hue = ch_ary[0], ch_ary[1]
  124.         bitmap = RPG::Cache.character(character_name, character_hue)
  125.         cw = bitmap.width / 4
  126.         ch = bitmap.height / 4
  127.         @sp_ch[i].bitmap = bitmap
  128.         @sp_ch[i].src_rect = Rect.new(0, 0, cw, ch)
  129.         @sp_ch[i].x = 192 + 40 * i
  130.         @sp_ch[i].y = 456 - ch
  131.         @sp_ch[i].visible = true
  132.         i = i + 1
  133.       end
  134.       # 设置文字颜色
  135.       self.contents.font.color = normal_color
  136.       # 描绘游戏时间
  137.       hour = @total_sec / 60 / 60
  138.       min = @total_sec / 60 % 60
  139.       sec = @total_sec % 60
  140.       time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  141.       self.contents.draw_text(4, 318, 420, 32, time_string, 2)      
  142.       # 描绘时间标记
  143.       time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  144.       self.contents.draw_text(4, 348, 420, 32, time_string, 2)
  145.     else
  146.       self.contents.draw_text(32,32,420,32,"No data")
  147.     end
  148.   end
  149.   def dispose
  150.     super
  151.     @sprite.dispose
  152.     @backsp.dispose
  153.     for i in @sp_ch
  154.       i.dispose
  155.     end
  156.   end
  157. end


  158. class Scene_Save
  159.   def main
  160.     # 档案文件名数组
  161.     ary = ["★SAVE★"]
  162.     for i in 1..70
  163.       ary.push sprintf("%s %02d", "SAVE", i)
  164.     end
  165.     # 创建档案窗口
  166.     @command_window = Window_Command.new(160,ary)
  167.     @command_window.y = 64
  168.     @command_window.height = 416
  169.     @command_window.index = $game_temp.last_file_index
  170.     @content_window = Window_File.new($game_temp.last_file_index)
  171.     # 添加帮助窗口
  172.     @help_window = Window_Help.new
  173.     @help_window.set_text("请选择要存入的SAVE")
  174.     # 执行过渡
  175.     Graphics.transition
  176.     # 主循环
  177.     loop do
  178.       # 刷新游戏画面
  179.       Graphics.update
  180.       # 刷新输入信息
  181.       Input.update
  182.       # 刷新画面
  183.       update
  184.       # 如果画面被切换的话就中断循环
  185.       if $scene != self
  186.         break
  187.       end
  188.     end
  189.     # 准备过渡
  190.     Graphics.freeze
  191.     @command_window.dispose
  192.     @content_window.dispose
  193.     # 释放帮助窗口
  194.     @help_window.dispose
  195.   end
  196.   def update
  197.     @command_window.update   
  198.     if @command_window.index != @content_window.index
  199.       @content_window.index = @command_window.index
  200.       @content_window.refresh
  201.     end   
  202.     #——————下面这一部分是原装脚本——————#
  203.     if Input.trigger?(Input::B)  
  204.       $game_system.se_play($data_system.cancel_se)
  205.       if $game_temp.save_calling
  206.         $game_temp.save_calling = false
  207.         $scene = Scene_Map.new
  208.         return
  209.       end
  210.       $scene = Scene_Menu.new(0)
  211.     end   
  212.     #———————————————————————#   
  213.     if Input.trigger?(Input::C)
  214.       # 演奏存档 SE
  215.       $game_system.se_play($data_system.decision_se)
  216.       # 写入存档数据
  217.       file = File.open(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata", "wb")
  218.       write_save_data(file)
  219.       if FileTest.exist?(BBS_66RPG_DIR+"shot.png")
  220.         File.rename(BBS_66RPG_DIR+"shot.png", BBS_66RPG_DIR+"Save#{@command_window.index}.png")
  221.       end
  222.       file.close
  223.       #----------------------------------------------
  224.       # 将存档数据 Hash 写入 SaveHash
  225.       #----------------------------------------------
  226.       f = Game_Global.new("Save/SaveHash")
  227.       f.set "hash-#{@command_window.index}", File.open("Save/Save#{@command_window.index}.rxdata").read.hash
  228.       #----------------------------------------------
  229.       $game_temp.last_file_index = @command_window.index
  230.       # 如果被事件调用
  231.       if $game_temp.save_calling
  232.         # 清除存档调用标志
  233.         $game_temp.save_calling = false
  234.         # 切换到地图画面
  235.         $scene = Scene_Map.new
  236.         return
  237.       end
  238.       # 切换到菜单画面
  239.       $scene = Scene_Map.new
  240.     end
  241.     #———————————————————————#
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # ● 写入存档数据
  245.   #     file : 写入用文件对像 (已经打开)
  246.   #--------------------------------------------------------------------------
  247.   def write_save_data(file)
  248.     # 生成描绘存档文件用的角色图形
  249.     characters = []
  250.     for i in 0...$game_party.actors.size
  251.       actor = $game_party.actors[i]
  252.       characters.push([actor.character_name, actor.character_hue, actor.id, actor.battler_name, actor.battler_hue])
  253.     end
  254.     # 写入描绘存档文件用的角色数据
  255.     Marshal.dump(characters, file)
  256.     # 写入测量游戏时间用画面计数
  257.     Marshal.dump(Graphics.frame_count, file)
  258.     # 增加 1 次存档次数
  259.     $game_system.save_count += 1
  260.     # 保存魔法编号
  261.     # (将编辑器保存的值以随机值替换)
  262.     $game_system.magic_number = $data_system.magic_number
  263.     # 写入各种游戏对像
  264.     Marshal.dump($game_system, file)
  265.     Marshal.dump($game_switches, file)
  266.     Marshal.dump($game_variables, file)
  267.     Marshal.dump($game_self_switches, file)
  268.     Marshal.dump($game_screen, file)
  269.     Marshal.dump($game_actors, file)
  270.     Marshal.dump($game_party, file)
  271.     Marshal.dump($game_troop, file)
  272.     Marshal.dump($game_map, file)
  273.     Marshal.dump($game_player, file)
  274.   end
  275. end


  276. class Scene_Load
  277.   def initialize
  278.     # 再生成临时对像
  279.     $game_temp = Game_Temp.new
  280.     # 选择存档时间最新的文件
  281.     $game_temp.last_file_index = 0
  282.     latest_time = Time.at(0)
  283.     for i in 0..70
  284.       filename = BBS_66RPG_DIR+"Save#{i}.rxdata"
  285.       if FileTest.exist?(filename)
  286.         file = File.open(filename, "r")
  287.         if file.mtime > latest_time
  288.           latest_time = file.mtime
  289.           $game_temp.last_file_index = i
  290.         end
  291.         file.close
  292.       end
  293.     end
  294.   end  
  295.   def main
  296.     # 档案文件名数组
  297.     ary = ["★SAVE★"]
  298.     for i in 1..70
  299.       ary.push sprintf("%s %02d", "SAVE", i)
  300.     end
  301.     # 创建档案窗口
  302.     @command_window = Window_Command.new(160,ary)
  303.     @command_window.y = 64
  304.     @command_window.height = 416
  305.     @command_window.index = $game_temp.last_file_index
  306.     @content_window = Window_File.new($game_temp.last_file_index)
  307.     # 添加帮助窗口
  308.     @help_window = Window_Help.new
  309.     @help_window.set_text("请选择要读取的SAVE")
  310.     # 执行过渡
  311.     Graphics.transition
  312.     # 主循环
  313.     loop do
  314.       # 刷新游戏画面
  315.       Graphics.update
  316.       # 刷新输入信息
  317.       Input.update
  318.       # 刷新画面
  319.       update
  320.       # 如果画面被切换的话就中断循环
  321.       if $scene != self
  322.         break
  323.       end
  324.     end
  325.     # 准备过渡
  326.     Graphics.freeze
  327.     @command_window.dispose
  328.     @content_window.dispose
  329.     # 释放帮助窗口
  330.     @help_window.dispose
  331.   end
  332.   def update
  333.     @command_window.update   
  334.     if @command_window.index != @content_window.index
  335.       @content_window.index = @command_window.index
  336.       @content_window.refresh
  337.     end   
  338.     #——————下面这一部分是原装脚本——————#
  339.     if Input.trigger?(Input::B)  
  340.     # 演奏取消 SE
  341.     $game_system.se_play($data_system.cancel_se)
  342.     # 切换到标题画面
  343.     $scene = Scene_Title.new
  344.     end   
  345.     #———————————————————————#   
  346.     if Input.trigger?(Input::C)
  347.       # 文件不存在的情况下
  348.       unless FileTest.exist?(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata")
  349.         # 演奏冻结 SE
  350.         $game_system.se_play($data_system.buzzer_se)
  351.         return
  352.       end
  353.       #----------------------------------------------------------
  354.       # 验证存档是否被篡改
  355.       #----------------------------------------------------------
  356.       f = Game_Global.new("Save/SaveHash")
  357.       if f.data["hash-#{@command_window.index}"] != File.open("Save/Save#{@command_window.index}.rxdata").read.hash
  358.         p '存档验证失败!无法读取此存档!'
  359.         return
  360.       end
  361.       #----------------------------------------------------------
  362.       # 演奏读档 SE
  363.       $game_system.se_play($data_system.decision_se)
  364.       # 写入存档数据
  365.       file = File.open(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata", "rb")
  366.       read_save_data(file)
  367.       file.close
  368.       # 还原 BGM、BGS
  369.       $game_system.bgm_play($game_system.playing_bgm)
  370.       $game_system.bgs_play($game_system.playing_bgs)
  371.       # 刷新地图 (执行并行事件)
  372.       $game_map.update
  373.       # 切换到地图画面
  374.       $scene = Scene_Map.new
  375.     end
  376.     #———————————————————————#
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   # ● 写入存档数据
  380.   #     file : 写入用文件对像 (已经打开)
  381.   #--------------------------------------------------------------------------
  382.   def read_save_data(file)
  383.     # 读取描绘存档文件用的角色数据
  384.     characters = Marshal.load(file)
  385.     # 读取测量游戏时间用画面计数
  386.     Graphics.frame_count = Marshal.load(file)
  387.     # 读取各种游戏对像
  388.     $game_system        = Marshal.load(file)
  389.     $game_switches      = Marshal.load(file)
  390.     $game_variables     = Marshal.load(file)
  391.     $game_self_switches = Marshal.load(file)
  392.     $game_screen        = Marshal.load(file)
  393.     $game_actors        = Marshal.load(file)
  394.     $game_party         = Marshal.load(file)
  395.     $game_troop         = Marshal.load(file)
  396.     $game_map           = Marshal.load(file)
  397.     $game_player        = Marshal.load(file)
  398.     # 魔法编号与保存时有差异的情况下
  399.     # (加入编辑器的编辑过的数据)
  400.     if $game_system.magic_number != $data_system.magic_number
  401.       # 重新装载地图
  402.       $game_map.setup($game_map.map_id)
  403.       $game_player.center($game_player.x, $game_player.y)
  404.     end
  405.     # 刷新同伴成员
  406.     $game_party.refresh
  407.   end
  408. end

  409. class Scene_Menu
  410.   alias bbs_66rpg_shotsave_main main
  411.   def main
  412.     if @menu_index == 0
  413.       Screen::shot
  414.     end   
  415.     bbs_66rpg_shotsave_main
  416.   end
  417. end

  418. class Interpreter
  419.   #--------------------------------------------------------------------------
  420.   # ● 调用存档画面
  421.   #--------------------------------------------------------------------------
  422.   def command_352
  423.     # 设置战斗中断标志
  424.     $game_temp.battle_abort = true
  425.     # 设置调用存档标志
  426.     $game_temp.save_calling = true
  427.     # 推进索引
  428.     @index += 1
  429.     # 结束
  430.     Screen::shot
  431.     return false
  432.   end
  433.   # 自动存档
  434.   def command_autosave
  435.     Screen::shot("Save0")
  436.     file = File.open(BBS_66RPG_DIR+"Save0.rxdata", "wb")
  437.     Scene_Save.new.write_save_data(file)
  438.     file.close
  439.     #--------------------------------------------
  440.     # 将存档数据 Hash 写入 SaveHash
  441.     #--------------------------------------------
  442.     f = Game_Global.new("Save/SaveHash")
  443.     f.set "hash-0", File.open('Save/Save0.rxdata').read.hash
  444.     #----------------------------------------------
  445.   end
  446. end
复制代码


  1. #==============================================================================
  2. # ■ 二周目类 v2
  3. #------------------------------------------------------------------------------
  4. #  简单的保存与读取二周目数据的类,其中仅包含了key-value对
  5. #
  6. #   使用方法:
  7. #   0. 在根目录下创建 Global 文件夹,将脚本插到 main 前
  8. #   1. 创建实例 $game_save = Game_Global.new(filename,init_hash)
  9. #   注:filename 参数是存档文件名,init_hash 参数是初始的hash值
  10. #   2. 实例调用 $game_save.set(key, value) 设置key-value对
  11. #   3. 实例调用 $game_save.key 即可获取对应的value值
  12. #
  13. #   对key的值要求是字符串,不是Symbol对象
  14. #   对value的值没有任何限制,任意对象都可以
  15. #
  16. #   特点:
  17. #   创造不同的Global文件分别保存数据,避免对所有的Global内容进行频繁读写
  18. #==============================================================================
  19. class Game_Global
  20.         def initialize(name,init_hash={})
  21.                 @filename = name + '.rxdata'
  22.                 # 初始化 Hash 的各默认值
  23.                 @data = init_hash
  24.                 # 存档文件存在时则读取
  25.                 if exist?
  26.                         read
  27.                 end
  28.         end

  29.         def write
  30.                 file = File.open(@filename, "wb")
  31.     Marshal.dump(Graphics.frame_count, file) # 总帧数
  32.                 Marshal.dump(@data, file)
  33.                 file.close
  34.         end

  35.         def read
  36.                 file = File.open(@filename, "rb")
  37.     Marshal.load(file) # 总帧数
  38.                 @data = Marshal.load(file)
  39.                 file.close
  40.         end

  41.         def exist?
  42.                 return FileTest.exist?(@filename)
  43.         end

  44.         def set(key,value)
  45.                 @data[key] = value
  46.                 write
  47.         end

  48.         def method_missing(name)
  49.                 return @data[name.to_s]
  50.         end

  51.         def data
  52.                 return @data
  53.         end
  54. end
  55. #==============================================================================
  56. # 本脚本由guoxiaomi制作,使用和转载请保留此信息
  57. #==============================================================================
复制代码


  1. #=============================================================================
  2. # Global_Save
  3. #-----------------------------------------------------------------------------
  4. # 管理全局存档的模块
  5. #=============================================================================
  6. module Global_Save
  7.   # 接受全局存档数据的变量 ID
  8.   Global_Save_Var = 59
  9.   #---------------------------------------------------------------------------
  10.   # 将一个对象写入全局存档
  11.   #     object : 要写入的对象
  12.   #---------------------------------------------------------------------------
  13.   def self.write_save_data(object)
  14.     # 全局存档的文件名
  15.     filename = "GSave.rxdata"
  16.     # 打开文件(写入模式)
  17.     file = File.open(filename, "wb")
  18.     # 将 object 写入该文件
  19.     Marshal.dump(object, file)
  20.     # 写入完成,关闭文件
  21.     file.close
  22.   end
  23.   #---------------------------------------------------------------------------
  24.   # 读取全局存档的数据
  25.   #---------------------------------------------------------------------------
  26.   def self.load_save_data
  27.     # 全局存档的文件名
  28.     filename = "GSave.rxdata"
  29.     # 如果存在全局存档,则读取,否则什么也不做
  30.     if FileTest.exist?(filename)
  31.       # 打开文件(读取模式)
  32.       file = File.open(filename, "rb")
  33.       # 读取文件中的数据,并把它放在指定 ID 的变量当中
  34.       $game_variables[Global_Save_Var] = Marshal.load(file)
  35.       # 读取完成,关闭文件
  36.       file.close
  37.     end
  38.   end
  39. end
复制代码




没有脚本编辑能力,我寻思改动脚本,让它退出其它界面时停两帧?(事件脑
图片
梦石
0
星屑
9917
在线时间
582 小时
注册时间
2017-9-28
回帖
207
发表于 2019-1-14 12:19:34 | 显示全部楼层
本帖最后由 hyrious 于 2019-1-14 12:20 编辑

把你的第一段脚本里修改 Scene_Menu 的部分
  1. class Scene_Menu
  2.   alias bbs_66rpg_shotsave_main main
  3.   def main
  4.     if @menu_index == 0
  5.       Screen::shot
  6.     end
  7.     bbs_66rpg_shotsave_main
  8.   end
  9. end
复制代码

替换为如下
  1. class Scene_Map
  2.   alias _shot_before_call_menu call_menu
  3.   def call_menu
  4.     Screen::shot
  5.     _shot_before_call_menu
  6.   end
  7. end
复制代码


另外你这不是“免 dll”,是需要 dll 的啊。。

点评

感谢!ok问题解决了,因为脚本原贴写了免dll所以就直接写上了hhh  发表于 2019-1-14 21:37

评分

参与人数 2星屑 +100 赞 +2 收起 理由
RyanBern + 100 + 1 认可答案
水母书亚 + 1 认可答案

查看全部评分

喵喵喵
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部