Project1

标题: 截图存档脚本和截图脚本一起用就出现问题了。 [打印本页]

作者: 爆焰    时间: 2013-2-13 22:48
标题: 截图存档脚本和截图脚本一起用就出现问题了。
就是说这两个脚本一起用不会出现冲突,但是却无法一起使用。会出现诡异的效果,请问是怎么回事?请高手帮帮忙。

截屏脚本:
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #============================================================================== #
  4. # Screenshot V2
  5. #
  6. # Screenshot Script v1 & screenshot.dll v1            created by: Andreas21
  7. # Screenshot Script v2                                created/edit by: cybersam
  8. # the autor is found on a german board...
  9. # the comments are added by me...
  10. # since the autor didnt want to add any comment...
  11. # so thats it from here...
  12. # have fund with it... ^-^
  13. #
  14. # oh yea.. the needed command line is found in "Scene_Map" in "def update"
  15. #
  16. #===============================================================================
  17. module Screen  
  18.   @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
  19.   @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
  20.   @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
  21.   module_function
  22.   #-----------------------------------------------------------------------------
  23.   # here comes the stuff...
  24.   # i add here the stuff for automatic change of the number for the screenshot
  25.   # so it wont overrite the old one...
  26.   # if you want to change so stuff change them in this line below
  27.   # or you can change them in your command line... like
  28.   # Screen::shot("screenshot", 2)
  29.   # this change the name and the type of the screenshot
  30.   # (0 = bmp, 1 = jpg and 2 = png)
  31.   # ----------------------------------------------------------------------------
  32.   def shot(file = "screenshot", typ = 2)
  33.     # to add the right extension...
  34.     if typ == 0
  35.       typname = ".bmp"
  36.     elsif typ == 1
  37.       typname = ".jpg"
  38.     elsif typ == 2
  39.       typname = ".png"
  40.     end   
  41.     file_index = 0   
  42.     dir = "Graphics/Pictures/"   
  43.     # make the filename....
  44.     file_name = dir + file.to_s + typname.to_s   
  45.     # make the screenshot.... Attention dont change anything from here on....
  46.     @screen.call(0,0,640,480,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. end

  56. #==============================================================================
  57. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  58. #==============================================================================
复制代码
截图存档:
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,转载和使用请保留此信息
  3. #===============================================================================
  4. BBS_66RPG_DIR = "Save/"  # 储存文件夹名,请制作游戏时自行建立此文件夹
  5. $data_mapinfo ||= load_data("Data/MapInfos.rxdata")

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

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

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

  13. #===============================================================================
  14. module Screen  
  15.   @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
  16.   @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
  17.   @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
  18.   module_function
  19.   #-----------------------------------------------------------------------------
  20.   # here comes the stuff...
  21.   # i add here the stuff for automatic change of the number for the screenshot
  22.   # so it wont overrite the old one...
  23.   # if you want to change so stuff change them in this line below
  24.   # or you can change them in your command line... like
  25.   # Screen::shot("screenshot", 2)
  26.   # this change the name and the type of the screenshot
  27.   # (0 = bmp, 1 = jpg and 2 = png)
  28.   # ----------------------------------------------------------------------------
  29.   def shot(file = "shot", typ = 1)
  30.     # to add the right extension...
  31.     if typ == 0
  32.       typname = ".bmp"
  33.     elsif typ == 1
  34.       typname = ".jpg"
  35.     elsif typ == 2
  36.       typname = ".png"
  37.     end   
  38.     file_index = 0   
  39.     dir = "Save/"   
  40.     # make the filename....
  41.     file_name = dir + file.to_s + typname.to_s   
  42.     # make the screenshot.... Attention dont change anything from here on....
  43.     @screen.call(0,0,640,480,file_name,handel,typ)
  44.   end
  45.   # find the game window...
  46.   def handel
  47.     game_name = "\0" * 256
  48.     @readini.call('Game','Title','',game_name,255,".\\Game.ini")
  49.     game_name.delete!("\0")
  50.     return @findwindow.call('RGSS Player',game_name)
  51.   end
  52. end

  53. class Window_File < Window_Base
  54.   attr_accessor :index
  55.   def initialize(index = 0)
  56.     @backsp = Sprite.new
  57.     #@backsp.bitmap = Bitmap.new("Graphics/Pictures/存盘背景.jpg")
  58.     @backsp.z = 99
  59.     super(160,0,480,480)
  60.     #这行可以不用
  61.     self.contents = Bitmap.new(width - 32, height - 32)
  62.     @index = index
  63.     #这里我要说明一句,之所以用sprite是为了放缩图片
  64.     [url=home.php?mod=space&uid=114926]@sprite[/url] = Sprite.new
  65.     @sprite.visible = false
  66.     @sprite.z = 100
  67.     @sp_ch = []
  68.     @sp_ch[0] = Sprite.new
  69.     refresh
  70.   end
  71.   def refresh
  72.     self.contents.clear
  73.     for i in @sp_ch
  74.       i.visible = false
  75.     end
  76.     @sprite.visible = false
  77.     if FileTest.exist?(BBS_66RPG_DIR+"Save#{@index}.rxdata")
  78.       @sprite.visible = true
  79.       if FileTest.exist?(BBS_66RPG_DIR+"Save#{@index}.jpg")
  80.         @sprite.bitmap = Bitmap.new(BBS_66RPG_DIR+"Save#{@index}.jpg")
  81.       else
  82.         self.contents.draw_text(32,64,400,32,"截图似乎有点问题……您搞什么了您?")
  83.       end
  84.       @sprite.x = 176
  85.       @sprite.y = 16
  86.       @sprite.zoom_x = 0.7
  87.       @sprite.zoom_y = 0.7
  88.       file = File.open(BBS_66RPG_DIR+"Save#{@index}.rxdata", "r")
  89.       @time_stamp = file.mtime
  90.       @characters = Marshal.load(file)
  91.       @frame_count = Marshal.load(file)
  92.       @game_system = Marshal.load(file)
  93.       @game_switches = Marshal.load(file)
  94.       @game_variables = Marshal.load(file)
  95.       @game_self_switches = Marshal.load(file)
  96.       @game_screen        = Marshal.load(file)
  97.       @game_actors        = Marshal.load(file)
  98.       @game_party         = Marshal.load(file)
  99.       @game_troop         = Marshal.load(file)
  100.       @game_map           = Marshal.load(file)
  101.       map_name = $data_mapinfo[@game_map.map_id].name
  102.       @total_sec = @frame_count / Graphics.frame_rate
  103.       file.close
  104.       for i in [email protected]
  105.         @sp_ch[i] = Sprite.new
  106.         @sp_ch[i].visible = true
  107.         @sp_ch[i].bitmap = RPG::Cache.battler(@characters[i][3], @characters[i][4])
  108.         @sp_ch[i].x = 180 + i*100      
  109.         @sp_ch[i].y = 460 - @sp_ch[i].bitmap.height
  110.         @sp_ch[i].z = 101
  111.       end
  112.       # 描绘游戏时间
  113.       hour = @total_sec / 60 / 60
  114.       min = @total_sec / 60 % 60
  115.       sec = @total_sec % 60
  116.       time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  117.       self.contents.font.color = normal_color
  118.       self.contents.draw_text(4, 390, 420, 32, time_string, 2)
  119.       # 描绘时间标记
  120.       self.contents.font.color = normal_color
  121.       time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  122.       self.contents.draw_text(4,420-64,420,32,map_name,2)
  123.       self.contents.draw_text(4, 420, 420, 32, time_string, 2)
  124.     else
  125.       self.contents.draw_text(32,32,420,32,"这个存档是空的")
  126.     end
  127.   end
  128.   def dispose
  129.     super
  130.     @sprite.dispose
  131.     @backsp.dispose
  132.     for i in @sp_ch
  133.       i.dispose
  134.     end
  135.   end
  136. end


  137. class Scene_Save
  138.   def main
  139.     @command_window = Window_Command.new(160,["存档一","存档二","存档三","存档四","存档五","存档六","存档七","存档八","存档九","存档十","存档十一","存档十二","存档十三","存档十四"])
  140.     @command_window.y = 0
  141.     @command_window.index = $game_temp.last_file_index
  142.     @content_window = Window_File.new($game_temp.last_file_index)
  143.     # 执行过渡
  144.     Graphics.transition
  145.     # 主循环
  146.     loop do
  147.       # 刷新游戏画面
  148.       Graphics.update
  149.       # 刷新输入信息
  150.       Input.update
  151.       # 刷新画面
  152.       update
  153.       # 如果画面被切换的话就中断循环
  154.       if $scene != self
  155.         break
  156.       end
  157.     end
  158.     # 准备过渡
  159.     Graphics.freeze
  160.     @command_window.dispose
  161.     @content_window.dispose
  162.   end
  163.   def update
  164.     @command_window.update   
  165.     if @command_window.index != @content_window.index
  166.       @content_window.index = @command_window.index
  167.       @content_window.refresh
  168.     end   
  169.     #——————下面这一部分是原装脚本——————#
  170.     if Input.trigger?(Input::B)  
  171.       $game_system.se_play($data_system.cancel_se)
  172.       if $game_temp.save_calling
  173.         $game_temp.save_calling = false
  174.         $scene = Scene_Map.new
  175.         return
  176.       end
  177.       $scene = Scene_Menu.new(3)
  178.     end   
  179.     #———————————————————————#   
  180.     if Input.trigger?(Input::C)
  181.       # 演奏存档 SE
  182.       $game_system.se_play($data_system.save_se)
  183.       # 写入存档数据
  184.       file = File.open(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata", "wb")
  185.       write_save_data(file)
  186.       if FileTest.exist?(BBS_66RPG_DIR+"shot.jpg")
  187.         File.rename(BBS_66RPG_DIR+"shot.jpg", BBS_66RPG_DIR+"Save#{@command_window.index}.jpg")
  188.       end
  189.       file.close
  190.       $game_temp.last_file_index = @command_window.index
  191.       # 如果被事件调用
  192.       if $game_temp.save_calling
  193.         # 清除存档调用标志
  194.         $game_temp.save_calling = false
  195.         # 切换到地图画面
  196.         $scene = Scene_Map.new
  197.         return
  198.       end
  199.       # 切换到菜单画面
  200.       $scene = Scene_Map.new
  201.     end
  202.     #———————————————————————#
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # ● 写入存档数据
  206.   #     file : 写入用文件对像 (已经打开)
  207.   #--------------------------------------------------------------------------
  208.   def write_save_data(file)
  209.     # 生成描绘存档文件用的角色图形
  210.     characters = []
  211.     for i in 0...$game_party.actors.size
  212.       actor = $game_party.actors[i]
  213.       characters.push([actor.character_name, actor.character_hue, actor.id, actor.battler_name, actor.battler_hue])
  214.     end
  215.     # 写入描绘存档文件用的角色数据
  216.     Marshal.dump(characters, file)
  217.     # 写入测量游戏时间用画面计数
  218.     Marshal.dump(Graphics.frame_count, file)
  219.     # 增加 1 次存档次数
  220.     $game_system.save_count += 1
  221.     # 保存魔法编号
  222.     # (将编辑器保存的值以随机值替换)
  223.     $game_system.magic_number = $data_system.magic_number
  224.     # 写入各种游戏对像
  225.     Marshal.dump($game_system, file)
  226.     Marshal.dump($game_switches, file)
  227.     Marshal.dump($game_variables, file)
  228.     Marshal.dump($game_self_switches, file)
  229.     Marshal.dump($game_screen, file)
  230.     Marshal.dump($game_actors, file)
  231.     Marshal.dump($game_party, file)
  232.     Marshal.dump($game_troop, file)
  233.     Marshal.dump($game_map, file)
  234.     Marshal.dump($game_player, file)
  235.   end
  236. end


  237. class Scene_Load
  238.   def initialize
  239.     # 再生成临时对像
  240.     $game_temp = Game_Temp.new
  241.     # 选择存档时间最新的文件
  242.     $game_temp.last_file_index = 0
  243.     latest_time = Time.at(0)
  244.     for i in 0..6
  245.       filename = BBS_66RPG_DIR+"Save#{i}.rxdata"
  246.       if FileTest.exist?(filename)
  247.         file = File.open(filename, "r")
  248.         if file.mtime > latest_time
  249.           latest_time = file.mtime
  250.           $game_temp.last_file_index = i
  251.         end
  252.         file.close
  253.       end
  254.     end
  255.   end  
  256.   def main
  257.     @command_window = Window_Command.new(160,["存档一","存档二","存档三","存档四","存档五","存档六","存档七","存档八","存档九","存档十","存档十一","存档十二","存档十三","存档十四"])
  258.     @command_window.y = 0
  259.     @command_window.index = $game_temp.last_file_index
  260.     @content_window = Window_File.new($game_temp.last_file_index)
  261.     # 执行过渡
  262.     Graphics.transition
  263.     # 主循环
  264.     loop do
  265.       # 刷新游戏画面
  266.       Graphics.update
  267.       # 刷新输入信息
  268.       Input.update
  269.       # 刷新画面
  270.       update
  271.       # 如果画面被切换的话就中断循环
  272.       if $scene != self
  273.         break
  274.       end
  275.     end
  276.     # 准备过渡
  277.     Graphics.freeze
  278.     @command_window.dispose
  279.     @content_window.dispose
  280.   end
  281.   def update
  282.     @command_window.update   
  283.     if @command_window.index != @content_window.index
  284.       @content_window.index = @command_window.index
  285.       @content_window.refresh
  286.     end   
  287.     #——————下面这一部分是原装脚本——————#
  288.     if Input.trigger?(Input::B)  
  289.     # 演奏取消 SE
  290.     $game_system.se_play($data_system.cancel_se)
  291.     # 切换到标题画面
  292.     $scene = Scene_Title.new
  293.   end   

  294.    #——————下面这一部分是原装脚本——————#
  295.     if Input.trigger?(Input::B)  
  296.     # 演奏取消 SE
  297.     $game_system.se_play($data_system.cancel_se)
  298.     # 切换到标题画面
  299.     $scene = Scene_Map.new
  300.   end  
  301.     #———————————————————————#   
  302.     if Input.trigger?(Input::C)
  303.       # 文件不存在的情况下
  304.       unless FileTest.exist?(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata")
  305.         # 演奏冻结 SE
  306.         $game_system.se_play($data_system.buzzer_se)
  307.         return
  308.       end
  309.       # 演奏读档 SE
  310.       $game_system.se_play($data_system.load_se)
  311.       # 写入存档数据
  312.       file = File.open(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata", "rb")
  313.       read_save_data(file)
  314.       file.close
  315.       # 还原 BGM、BGS
  316.       $game_system.bgm_play($game_system.playing_bgm)
  317.       $game_system.bgs_play($game_system.playing_bgs)
  318.       # 刷新地图 (执行并行事件)
  319.       $game_map.update
  320.       # 切换到地图画面
  321.       $scene = Scene_Map.new
  322.     end
  323.     #———————————————————————#
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● 写入存档数据
  327.   #     file : 写入用文件对像 (已经打开)
  328.   #--------------------------------------------------------------------------
  329.   def read_save_data(file)
  330.     # 读取描绘存档文件用的角色数据
  331.     characters = Marshal.load(file)
  332.     # 读取测量游戏时间用画面计数
  333.     Graphics.frame_count = Marshal.load(file)
  334.     # 读取各种游戏对像
  335.     $game_system        = Marshal.load(file)
  336.     $game_switches      = Marshal.load(file)
  337.     $game_variables     = Marshal.load(file)
  338.     $game_self_switches = Marshal.load(file)
  339.     $game_screen        = Marshal.load(file)
  340.     $game_actors        = Marshal.load(file)
  341.     $game_party         = Marshal.load(file)
  342.     $game_troop         = Marshal.load(file)
  343.     $game_map           = Marshal.load(file)
  344.     $game_player        = Marshal.load(file)
  345.     # 魔法编号与保存时有差异的情况下
  346.     # (加入编辑器的编辑过的数据)
  347.     if $game_system.magic_number != $data_system.magic_number
  348.       # 重新装载地图
  349.       $game_map.setup($game_map.map_id)
  350.       $game_player.center($game_player.x, $game_player.y)
  351.     end
  352.     # 刷新同伴成员
  353.     $game_party.refresh
  354.   end
  355. end

  356. class Scene_Menu
  357.   alias bbs_66rpg_shotsave_main main
  358.   def main
  359.     if @menu_index == 0
  360.       Screen::shot
  361.     end   
  362.     bbs_66rpg_shotsave_main
  363.   end
  364. end
  365. class Interpreter
  366.   #--------------------------------------------------------------------------
  367.   # ● 调用存档画面
  368.   #--------------------------------------------------------------------------
  369.   def command_352
  370.     # 设置战斗中断标志
  371.     $game_temp.battle_abort = true
  372.     # 设置调用存档标志
  373.     $game_temp.save_calling = true
  374.     # 推进索引
  375.     @index += 1
  376.     # 结束
  377.     Screen::shot
  378.     return false
  379.   end
  380. end
复制代码

作者: 美丽晨露    时间: 2013-2-13 23:04
诡异的现象指的是?
应该功能重新被定义取代了吧
作者: 爆焰    时间: 2013-2-16 01:20
没人帮我吗?
作者: zhangbanxian    时间: 2013-2-16 16:42
这两个不就是一模一样的脚本么?无非路径不同,存到save文件夹里而已,你要指定路径可以改成
  1. def shot(file = "shot", typ = 1,dir = "Save/")
  2. ...
  3. #dir="Save/"(这行注释掉)
  4. ...
  5. end
复制代码
然后Screen.shot(file = "screenshot", typ = 2,dir = "Graphics/Pictures/" )截图




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1