Project1

标题: 截图存档的问题, [打印本页]

作者: jiahui5592986    时间: 2011-7-5 21:35
标题: 截图存档的问题,
本帖最后由 jiahui5592986 于 2011-7-5 21:38 编辑
  1. #===============================================================================

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

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

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

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

  10. # 注意:这个脚本是兼容亿万星辰的“轩辕剑菜单”的版本,不过用在其他场合貌似也不会出错
  11. #   使用时把这个脚本放在“轩辕剑菜单”脚本的下方,也就是更靠近Main的位置
  12. # 兼容处理:叶子
  13. #===============================================================================
  14. module Screen  
  15. @screen = Win32API.new 'dll\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.   if $shot_guodu == 1
  43.     file_name = "Graphics/Pictures/sys_screen.jpg"
  44.     $shot_guodu = 0
  45.   end
  46.   # make the screenshot.... Attention dont change anything from here on....
  47.   @screen.call(0,0,640,480,file_name,handel,typ)
  48. end
  49. #--------------------------------------------------------------------------
  50. # ● 截图并自动生成名字
  51. #--------------------------------------------------------------------------
  52. def shot1(typ = 1)
  53.   # to add the right extension...
  54.   if typ == 0
  55.     typname = ".bmp"
  56.   elsif typ == 1
  57.     typname = ".jpg"
  58.   elsif typ == 2
  59.     typname = ".png"
  60.   end   
  61.   file_index = 0   
  62.   dir = "Screen/"   
  63.   long = Time.now.tv_usec
  64.   s = Time.now.to_a
  65.   # make the filename....
  66.   file_name = dir + s[5].to_s +  s[4].to_s + s[3].to_s + s[2].to_s +
  67.   s[1].to_s + s[0].to_s + long.to_s + typname.to_s   
  68.   if $shot_guodu == 1
  69.     file_name = "Graphics/Pictures/sys_screen.jpg"
  70.     $shot_guodu = 0
  71.   end
  72.   # make the screenshot.... Attention dont change anything from here on....
  73.   @screen.call(0,0,640,480,file_name,handel,typ)
  74. end
  75. # find the game window...
  76. def handel
  77.   game_name = "\0" * 256
  78.   @readini.call('Game','Title','',game_name,255,".\\Game.ini")
  79.   game_name.delete!("\0")
  80.   return @findwindow.call('RGSS Player',game_name)
  81. end
  82. end

  83. class Window_File < Window_Base
  84. attr_accessor :index
  85. def initialize(index = 0)
  86.   @backsp = Sprite.new
  87.   @backsp.z = 99
  88.   super(160,0,480,480)
  89.   #这行可以不用
  90.   self.contents = Bitmap.new(width - 32, height - 32)
  91.   @index = index
  92.   #这里我要说明一句,之所以用sprite是为了放缩图片
  93.   @sprite = Sprite.new
  94.   @sprite.visible = false
  95.   @sprite.z = 10000
  96.   @sp_ch = []
  97.   @sp_ch[0] = Sprite.new
  98.   refresh
  99. end
  100. def refresh
  101.   self.contents.clear
  102.   for i in @sp_ch
  103.     i.visible = false
  104.   end
  105.   @sprite.visible = false
  106.   if FileTest.exist?(BBS_66RPG_DIR+"Save#{@index}.rxdata")
  107.     @sprite.visible = true
  108.     if FileTest.exist?(BBS_66RPG_DIR+"Save#{@index}.jpg")
  109.       @sprite.bitmap = Bitmap.new(BBS_66RPG_DIR+"Save#{@index}.jpg")
  110.     else
  111.       self.contents.draw_text(32,64,400,32,"截图似乎有点问题……您搞什么了您?")
  112.     end
  113.     @sprite.x = 176
  114.     @sprite.y = 16
  115.     @sprite.zoom_x = 0.7
  116.     @sprite.zoom_y = 0.7
  117.     file = File.open(BBS_66RPG_DIR+"Save#{@index}.rxdata", "r")
  118.     @time_stamp = file.mtime
  119.     @gold = Marshal.load(file)
  120.     @save_map_name = Marshal.load(file)
  121.     @characters = Marshal.load(file)
  122.     @frame_count = Marshal.load(file)
  123.     @game_system = Marshal.load(file)
  124.     @game_switches = Marshal.load(file)
  125.     @game_variables = Marshal.load(file)
  126.     @total_sec = @frame_count / Graphics.frame_rate
  127.     file.close
  128.     for i in [email protected]
  129.       @sp_ch[i] = Sprite.new
  130.       @sp_ch[i].visible = true
  131.       @sp_ch[i].bitmap = Bitmap.new("Graphics/Battlers/" +  "x.png")
  132.       @sp_ch[i].x = 180 + i*42      
  133.       @sp_ch[i].y = 460 - @sp_ch[i].bitmap.height
  134.       @sp_ch[i].z = 101
  135.     end
  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.font.color = normal_color
  142.     self.contents.draw_text(4, 390, 420 + 16, 32, time_string, 2)
  143.     # 描绘时间标记
  144.     self.contents.font.color = normal_color
  145.     time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  146.     self.contents.draw_text(4, 420, 420 + 16, 32, time_string, 2)
  147.     self.contents.draw_text(4, 420 - 64, 420 + 16, 32, "游戏时间", 2)
  148.     #self.contents.draw_text(4, 4, 420 + 16, 32, @gold, 2)
  149.     src_rect = Rect.new(0,0,16,16)
  150.     #bitmap = Bitmap.new("Graphics/system/menu/back/money.png")
  151.     #self.contents.blt(420 + 16 - @gold.size * 16, 4 + 8, bitmap, src_rect)
  152.   else
  153.     self.contents.draw_text(32,32,420 + 16,32,"空白记忆")
  154.   end
  155. end
  156. def dispose
  157.   super
  158.   @sprite.dispose
  159.   @backsp.dispose
  160.   for i in @sp_ch
  161.     i.dispose
  162.   end
  163. end
  164. end


  165. class Scene_Save
  166. def main
  167.   @command_window = Window_Command.new(160,["回忆 1","回忆 2","回忆 3","回忆 4","回忆 5","回忆 6","回忆 7","回忆 8","回忆 9","回忆10","回忆11","回忆12","回忆13","回忆14"])
  168.   @command_window.y = 0
  169.   @command_window.index = $game_temp.last_file_index
  170.   @content_window = Window_File.new($game_temp.last_file_index)
  171.   # 执行过渡
  172.   Graphics.transition
  173.   # 主循环
  174.   loop do
  175.     # 刷新游戏画面
  176.     Graphics.update
  177.     # 刷新输入信息
  178.     Input.update
  179.     # 刷新画面
  180.     update
  181.     # 如果画面被切换的话就中断循环
  182.     if $scene != self
  183.       break
  184.     end
  185.   end
  186.   # 准备过渡
  187.   Graphics.freeze
  188.   @command_window.dispose
  189.   @content_window.dispose
  190. end
  191. def update
  192.   @command_window.update   
  193.   if @command_window.index != @content_window.index
  194.     @content_window.index = @command_window.index
  195.     @content_window.refresh
  196.   end   
  197.   #——————下面这一部分是原装脚本——————#
  198.   if Input.trigger?(Input::B)  
  199.     $game_system.se_play($data_system.cancel_se)
  200.     if $game_temp.save_calling
  201.       $game_temp.save_calling = false
  202.       $scene = Scene_Map.new
  203.       return
  204.     end
  205.     $scene = Scene_Menu.new(4)
  206.   end   
  207.   #———————————————————————#   
  208.   if Input.trigger?(Input::C)
  209.     # 演奏存档 SE
  210.     $game_system.se_play($data_system.save_se)
  211.     # 写入存档数据
  212.     file = File.open(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata", "wb")
  213.     write_save_data(file)
  214.     if FileTest.exist?(BBS_66RPG_DIR+"shot.jpg")
  215.       File.rename(BBS_66RPG_DIR+"shot.jpg", BBS_66RPG_DIR+"Save#{@command_window.index}.jpg")
  216.     end
  217.     file.close
  218.     $game_temp.last_file_index = @command_window.index
  219.     # 如果被事件调用
  220.     if $game_temp.save_calling
  221.       # 清除存档调用标志
  222.       $game_temp.save_calling = false
  223.       # 切换到地图画面
  224.       $scene = Scene_Map.new
  225.       return
  226.     end
  227.     # 切换到菜单画面
  228.     $scene = Scene_Map.new
  229.   end
  230.   #———————————————————————#
  231. end
  232. #--------------------------------------------------------------------------
  233. # ● 写入存档数据
  234. #     file : 写入用文件对像 (已经打开)
  235. #--------------------------------------------------------------------------
  236. def write_save_data(file)
  237.   # 生成描绘存档文件用的角色图形
  238.   characters = []
  239.   for i in 0...$game_party.actors.size
  240.     actor = $game_party.actors[i]
  241.     characters.push([actor.character_name, actor.character_hue, actor.id, actor.battler_name, actor.battler_hue])
  242.   end
  243.   #####################################################################
  244.   id = $game_map.map_id
  245.   name = $data_mapinfos[id].name
  246.   if name.include?("★")
  247.     @save_map_name = name.split(/★/)[0]
  248.   else
  249.     @save_map_name = name
  250.   end
  251.   Marshal.dump($game_party.gold.to_s, file)
  252.   Marshal.dump(@save_map_name, file)
  253.   #####################################################################
  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(force = false)
  278.   @in_game = force
  279.   # 再生成临时对像
  280.   $game_temp = Game_Temp.new
  281.   # 选择存档时间最新的文件
  282.   $game_temp.last_file_index = 0
  283.   latest_time = Time.at(0)
  284.   for i in 0..6
  285.     filename = BBS_66RPG_DIR+"Save#{i}.rxdata"
  286.     if FileTest.exist?(filename)
  287.       file = File.open(filename, "r")
  288.       if file.mtime > latest_time
  289.         latest_time = file.mtime
  290.         $game_temp.last_file_index = i
  291.       end
  292.       file.close
  293.     end
  294.   end
  295. end  
  296. def main
  297.   @command_window = Window_Command.new(160,["回忆 1","回忆 2","回忆 3","回忆 4","回忆 5","回忆 6","回忆 7","回忆 8","回忆 9","回忆10","回忆11","回忆12","回忆13","回忆14"])
  298.   @command_window.y = 0
  299.   @command_window.index = $game_temp.last_file_index
  300.   @content_window = Window_File.new($game_temp.last_file_index)
  301.   # 执行过渡
  302.   Graphics.transition
  303.   # 主循环
  304.   loop do
  305.     # 刷新游戏画面
  306.     Graphics.update
  307.     # 刷新输入信息
  308.     Input.update
  309.     # 刷新画面
  310.     update
  311.     # 如果画面被切换的话就中断循环
  312.     if $scene != self
  313.       break
  314.     end
  315.   end
  316.   # 准备过渡
  317.   Graphics.freeze
  318.   @command_window.dispose
  319.   @content_window.dispose
  320. end
  321. def update
  322.   @command_window.update   
  323.   if @command_window.index != @content_window.index
  324.     @content_window.index = @command_window.index
  325.     @content_window.refresh
  326.   end   
  327.   #——————下面这一部分是原装脚本——————#
  328.   if Input.trigger?(Input::B)  
  329.   # 演奏取消 SE
  330.   $game_system.se_play($data_system.cancel_se)
  331.    if $menu_load == "marimo"
  332.       $scene = Scene_Menu.new
  333.     else
  334.       
  335.       $scene = Scene_Title.new
  336.     end
  337.   end   
  338.   #———————————————————————#   
  339.   if Input.trigger?(Input::C)
  340.     # 文件不存在的情况下
  341.     unless FileTest.exist?(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata")
  342.       # 演奏冻结 SE
  343.       $game_system.se_play($data_system.buzzer_se)
  344.       return
  345.     end
  346.     #..........................................................................
  347.     if $piantou == 1
  348.       case $menu_back_type
  349.       when 0
  350.         for i in 0..46
  351.           $menupicback[i].bitmap.dispose
  352.           $menupicback[i].dispose
  353.         end
  354.       when 1
  355.         for i in 0..69
  356.           $menupicback[i].bitmap.dispose
  357.           $menupicback[i].dispose
  358.         end
  359.       when 2
  360.         for i in 0..49
  361.           $menupicback[i].bitmap.dispose
  362.           $menupicback[i].dispose
  363.         end
  364.       end
  365.     end
  366.     #..........................................................................
  367.     # 演奏读档 SE
  368.     $game_system.se_play($data_system.load_se)
  369.     # 写入存档数据
  370.     file = File.open(BBS_66RPG_DIR+"Save#{@command_window.index}.rxdata", "rb")
  371.     read_save_data(file)
  372.     file.close
  373.     # 还原 BGM、BGS
  374.     $game_system.bgm_play($game_system.playing_bgm)
  375.     $game_system.bgs_play($game_system.playing_bgs)
  376.     # 刷新地图 (执行并行事件)
  377.     $game_map.update
  378.     # 切换到地图画面
  379.     $scene = Scene_Map.new
  380.   end
  381.   #———————————————————————#
  382. end
  383. #--------------------------------------------------------------------------
  384. # ● 写入存档数据
  385. #     file : 写入用文件对像 (已经打开)
  386. #--------------------------------------------------------------------------
  387. def read_save_data(file)
  388.   @gold = Marshal.load(file)
  389.   @save_map_name = Marshal.load(file)
  390.   # 读取描绘存档文件用的角色数据
  391.   characters = Marshal.load(file)
  392.   # 读取测量游戏时间用画面计数
  393.   Graphics.frame_count = Marshal.load(file)
  394.   # 读取各种游戏对像
  395.   $game_system        = Marshal.load(file)
  396.   $game_switches      = Marshal.load(file)
  397.   $game_variables     = Marshal.load(file)
  398.   $game_self_switches = Marshal.load(file)
  399.   $game_screen        = Marshal.load(file)
  400.   $game_actors        = Marshal.load(file)
  401.   $game_party         = Marshal.load(file)
  402.   $game_troop         = Marshal.load(file)
  403.   $game_map           = Marshal.load(file)
  404.   $game_player        = Marshal.load(file)
  405.   # 魔法编号与保存时有差异的情况下
  406.   # (加入编辑器的编辑过的数据)
  407.   if $game_system.magic_number != $data_system.magic_number
  408.     # 重新装载地图
  409.     $game_map.setup($game_map.map_id)
  410.     $game_player.center($game_player.x, $game_player.y)
  411.   end
  412.   # 刷新同伴成员
  413.   $game_party.refresh
  414. end
  415. end

  416. class Scene_Menu
  417. alias bbs_66rpg_shotsave_main main
  418. def main
  419.   if @menu_index == 0
  420.     Screen::shot
  421.   end   
  422.   bbs_66rpg_shotsave_main
  423. end
  424. end

  425. class Interpreter
  426. #--------------------------------------------------------------------------
  427. # ● 调用存档画面
  428. #--------------------------------------------------------------------------
  429. def command_352
  430.   # 设置战斗中断标志
  431.   $game_temp.battle_abort = true
  432.   # 设置调用存档标志
  433.   $game_temp.save_calling = true
  434.   # 推进索引
  435.   @index += 1
  436.   # 结束
  437.   Screen::shot
  438.   return false
  439. end
  440. end
复制代码
我用了截图存档,出现这个问题
求解,或者,那位大侠,上传个脚本范例也行,,我找了许多帖子,没有管用的

未命名.jpg (11.54 KB, 下载次数: 2)

未命名.jpg

作者: 熊猫    时间: 2011-7-5 21:37
你最好上传你的范例。
作者: jiahui5592986    时间: 2011-7-5 21:39
熊猫 发表于 2011-7-5 21:37
你最好上传你的范例。

脚本我上传了,你看下




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