设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 5723|回复: 2

[整合系统] 【RMXP】免dll截图存档+覆盖存档提示

[复制链接]

Lv1.梦旅人

路人党员

梦石
0
星屑
51
在线时间
2276 小时
注册时间
2010-12-30
帖子
3225
发表于 2014-3-13 01:30:38 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 英顺的马甲 于 2016-7-31 02:24 编辑

[20160731]抛弃禁术,改用移花接木
[20160723]改善禁术,减少冲突率
[20160617]调整了禁术,解决了会因插入脚本位置而导致的潜在bug
[20160608]稍微调整了API,解决了一些潜在的BUG

此东西乃无聊产物,整合了以下这两只脚本==
免dll截图存档 by lim前辈
覆盖存档提示 by 佚名

整合后的新特色:
  • 人性化的设置
  • 减少并尽量避免重定义
  • 移花接木


整合这货的主要目的是学习交流,与其他脚本有任何冲突本人一概不理==

RUBY 代码复制
  1. #-----------------------------------------------------------------------------#
  2. # 脚本设定                                                                    #
  3. #-----------------------------------------------------------------------------#
  4. # 说明:                                                                      #
  5. # ①主要采用了Snap To Bitmap这脚本省去了DLL。                                  #
  6. # ②采用了禁术,各位不用到处改脚本了,不过冲突率也大增==                       #
  7. # ③脚本当中采用的脚本归原作者所有。                                           #
  8. # ④设置区域的变量请自行更改。                                                 #
  9. # ⑤调整了截图的API,解决一些潜在的截图BUG。                                   #
  10. #-----------------------------------------------------------------------------#
  11. SaveSettings = Struct.new(:max_save_file,:save_file_dir,:slot_name_format,
  12. :save_help,:load_help,:override_question,:snap_no_found,:no_save_file).new
  13. #-----------------------------------------------------------------------------#
  14. # 设置区域
  15. #-----------------------------------------------------------------------------#
  16. # 最大的存档量
  17. SaveSettings.max_save_file = 20
  18. # 存档所在文件夹
  19. SaveSettings.save_file_dir = "Save/"
  20. # 存档槽的名称的格式,具体请参考sprintf
  21. SaveSettings.slot_name_format = "%03d号存档"
  22. # 存档界面所显示的字符串
  23. SaveSettings.save_help = "要保存哪号存档呢?"
  24. # 读档界面所显示的字符串
  25. SaveSettings.load_help = "要读取哪号存档呢?"
  26. # 需要覆盖存档时所发问的问题
  27. SaveSettings.override_question = "存档已在,是否覆盖?新档替代,莫能重来。"
  28. # 找不到截图时的信息
  29. SaveSettings.snap_no_found = "哎哟,截图找不到啦!你都干了啥啊?"
  30. # 存档槽没有存档时显示的信息
  31. SaveSettings.no_save_file = "这里还没存档喔"
  32.  
  33. #-----------------------------------------------------------------------------#
  34. # 创建存档文件夹                                                              #
  35. #-----------------------------------------------------------------------------#
  36. Dir.mkdir(SaveSettings.save_file_dir) unless FileTest.directory?(SaveSettings.save_file_dir)
  37.  
  38. #-----------------------------------------------------------------------------#
  39. # 游戏核心处理类                                                              #
  40. #-----------------------------------------------------------------------------#
  41. class Game_System
  42.   #---------------------------------------------------------------------------#
  43.   # 实例变量                                                                  #
  44.   #---------------------------------------------------------------------------#
  45.   attr_accessor :snap_bitmap
  46. end
  47.  
  48. #-----------------------------------------------------------------------------#
  49. # 强改存档界面                                                                #
  50. #-----------------------------------------------------------------------------#
  51. class Scene_Save
  52.   def self.new(*a)
  53.     return Scene_Save_Load.new
  54.   end
  55. end
  56.  
  57. #-----------------------------------------------------------------------------#
  58. # 强改读档界面                                                                #
  59. #-----------------------------------------------------------------------------#
  60. class Scene_Load
  61.   def self.new(*a)
  62.     return Scene_Save_Load.new(1)
  63.   end
  64. end
  65.  
  66. #-----------------------------------------------------------------------------#
  67. # 地图界面钩子                                                                #
  68. #-----------------------------------------------------------------------------#
  69. Scene_Map = Class.new(Scene_Map) {
  70.   superclass.constants.each{|c|const_set(c, superclass.const_get(c))}
  71.   const_set(:NoDllSLHook, true)
  72.   define_method(:main) do
  73.     super
  74.     $game_system.snap_bitmap = Graphics.snap_to_bitmap if $scene.is_a?(Scene_Menu)
  75.   end
  76. } unless Scene_Map.const_defined?(:NoDllSLHook)
  77.  
  78. #-----------------------------------------------------------------------------#
  79. # 移花接木大法                                                                #
  80. #-----------------------------------------------------------------------------#
  81. class Scene_Title
  82.   attr_accessor :command_window, :continue_enabled
  83.   class Window_Command < ::Window_Command
  84.     def disable_item(*a)
  85.       super(*a) unless $scene.any_save? or a[0] != 1
  86.     end
  87.   end
  88.   module Graphics
  89.     def self.transition(*a)
  90.       $scene.command_window.index = ($scene.continue_enabled = $scene.any_save?) ? 1 : 0
  91.       begin
  92.         ::Graphics.transition(*a)
  93.       rescue Exception
  94.         raise $!.class, $!.message, caller
  95.       end
  96.     end
  97.     def self.method_missing(m, *args, &block)
  98.       begin
  99.         ::Graphics.send(m, *args, &block)
  100.       rescue Exception
  101.         raise $!.class, $!.message, caller
  102.       end
  103.     end
  104.   end
  105.   def any_save?
  106.     for i in 1..SaveSettings.max_save_file
  107.       return true if File.exist?(SaveSettings.save_file_dir + "Save#{i}.rxdata")
  108.     end
  109.     return false
  110.   end
  111. end
  112.  
  113. #-----------------------------------------------------------------------------#
  114. # 存档界面用窗口                                                              #
  115. #-----------------------------------------------------------------------------#
  116. class Window_Save < Window_Base
  117.   #---------------------------------------------------------------------------#
  118.   # 初始化                                                                    #
  119.   #---------------------------------------------------------------------------#
  120.   def initialize
  121.     super(160,64,480,416)
  122.     self.contents = Bitmap.new(width-32,height-32)
  123.     @_index = -1
  124.     refresh(0)
  125.   end
  126.   #---------------------------------------------------------------------------#
  127.   # 刷新                                                                      #
  128.   #---------------------------------------------------------------------------#
  129.   def refresh(index)
  130.     if index != @_index
  131.       # 清除原有资料
  132.       self.contents.clear
  133.       @sprite.dispose if @sprite != nil
  134.       @sprite = nil
  135.       # 开始读取资料
  136.       @file_index = index
  137.       @filename = SaveSettings.save_file_dir + "Save#{@file_index + 1}.rxdata"
  138.       @time_stamp = Time.at(0)
  139.       @file_exist = FileTest.exist?(@filename)
  140.       if @file_exist
  141.         file = File.open(@filename, "r")
  142.         @time_stamp         = file.mtime
  143.         @characters         = Marshal.load(file)
  144.         @frame_count        = Marshal.load(file)
  145.         @game_system        = Marshal.load(file)
  146.         @game_switches      = Marshal.load(file)
  147.         @game_variables     = Marshal.load(file)
  148.         @game_self_switches = Marshal.load(file)
  149.         @game_screen        = Marshal.load(file)
  150.         @game_actors        = Marshal.load(file)
  151.         @game_party         = Marshal.load(file)
  152.         @game_troop         = Marshal.load(file)
  153.         @game_map           = Marshal.load(file)
  154.         @game_player        = Marshal.load(file)
  155.         @bitmap             = @game_system.snap_bitmap
  156.         @total_sec = @frame_count / Graphics.frame_rate
  157.         file.close
  158.         # 描绘截图的框与影子
  159.         self.contents.fill_rect(34,11,400,300,Color.new(0,0,0))
  160.         self.contents.fill_rect(23,0,402,302,system_color)
  161.         self.contents.fill_rect(24,1,400,300,Color.new(0,0,0,0))
  162.         # 如截图不为空的话
  163.         if @bitmap != nil
  164.           # 描绘截图
  165.           @sprite = Sprite.new
  166.           @sprite.bitmap = @bitmap
  167.           @sprite.x = 160+16+24
  168.           @sprite.y = 64+16+1
  169.           @sprite.zoom_x = @sprite.zoom_y = 0.625
  170.           @sprite.z = 99999
  171.         else
  172.           self.contents.draw_text(0,96,448,32,SaveSettings.snap_no_found,1)
  173.         end
  174.         # 描绘角色
  175.         @characters.size.times do |i|
  176.           x = i*56 + 24
  177.           bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
  178.           self.contents.blt(x,328,bitmap,Rect.new(0,0,bitmap.width/4,bitmap.height/4))
  179.         end
  180.         # 描绘游戏时间
  181.         hour = @total_sec / 60 / 60
  182.         min = @total_sec / 60 % 60
  183.         sec = @total_sec % 60
  184.         time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  185.         self.contents.font.color = normal_color
  186.         self.contents.draw_text(0,320,448,32,time_string,2)
  187.         # 描绘时间标记
  188.         self.contents.font.color = normal_color
  189.         time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  190.         self.contents.draw_text(0,352,448,32,time_string, 2)
  191.       else
  192.         self.contents.draw_text(0,320,448,32,SaveSettings.no_save_file,1)
  193.       end
  194.       @_index = index
  195.     end
  196.   end
  197.   #---------------------------------------------------------------------------#
  198.   # 释放                                                                      #
  199.   #---------------------------------------------------------------------------#
  200.   def dispose
  201.     super
  202.     @sprite.dispose if @sprite != nil
  203.     @sprite = nil
  204.   end
  205. end
  206.  
  207. #-----------------------------------------------------------------------------#
  208. # 存档界面                                                                    #
  209. #-----------------------------------------------------------------------------#
  210. class Scene_Save_Load
  211.   #---------------------------------------------------------------------------#
  212.   # 初始化                                                                    #
  213.   #---------------------------------------------------------------------------#
  214.   def initialize(type=0)
  215.     @type = type == 0 ? "save" : "load"
  216.     case @type
  217.     when "save"
  218.       @word = SaveSettings.save_help
  219.     when "load"
  220.       @word = SaveSettings.load_help
  221.       $game_temp = Game_Temp.new
  222.     end
  223.   end
  224.   #---------------------------------------------------------------------------#
  225.   # 主执行                                                                    #
  226.   #---------------------------------------------------------------------------#
  227.   def main
  228.     # 生成帮助窗口
  229.     @help_window = Window_Help.new
  230.     @help_window.set_text(@word)
  231.     # 选项窗口
  232.     choose = []
  233.     for i in 1..SaveSettings.max_save_file
  234.       choose.push(SaveSettings.slot_name_format % i)
  235.     end
  236.     @command_window = Window_Command.new(160,choose)
  237.     @command_window.height = 416
  238.     @command_window.y = 64
  239.     @command_window.active = true
  240.     # 存档资料窗口
  241.     @save_window = Window_Save.new
  242.     # 确认窗口
  243.     @confirm_window = Window_Base.new(80,176,480,128)
  244.     @confirm_window.contents = Bitmap.new(448,96)
  245.     @confirm_window.contents.draw_text(0,0,448,32,SaveSettings.override_question,1)
  246.     @confirm_window.contents.draw_text(0,64,216,32,"确定",1)
  247.     @confirm_window.contents.draw_text(232,64,216,32,"取消",1)
  248.     @confirm_window.cursor_rect.set(232,64,216,32)
  249.     @confirm_window.z = 999999
  250.     @confirm_window.visible = false
  251.     @confirm_ok = false
  252.     # 执行过渡
  253.     Graphics.transition
  254.     # 主循环
  255.     loop do
  256.       # 刷新游戏画面
  257.       Graphics.update
  258.       # 刷新输入信息
  259.       Input.update
  260.       # 刷新画面
  261.       update
  262.       # 如果画面切换的话的就中断循环
  263.       if $scene != self
  264.         break
  265.       end
  266.     end
  267.     # 准备过渡
  268.     Graphics.freeze
  269.     # 释放窗口
  270.     @help_window.dispose
  271.     @save_window.dispose
  272.     @command_window.dispose
  273.     @confirm_window.dispose
  274.   end
  275.   #---------------------------------------------------------------------------#
  276.   # 刷新                                                                      #
  277.   #---------------------------------------------------------------------------#
  278.   def update
  279.     # 选择存档窗口激活
  280.     unless @confirm_window.visible
  281.       update_command
  282.     else
  283.       update_confirm
  284.     end
  285.   end
  286.   #---------------------------------------------------------------------------#
  287.   # 选择存档窗口刷新                                                          #
  288.   #---------------------------------------------------------------------------#
  289.   def update_command
  290.     @command_window.update
  291.     @save_window.refresh(@command_window.index)
  292.     # 按下取消键
  293.     if Input.trigger?(Input::B)
  294.       case @type
  295.       when "save"
  296.         # 演奏取消 SE
  297.         $game_system.se_play($data_system.cancel_se)
  298.         # 如果被事件调用
  299.         if $game_temp.save_calling
  300.           # 清除存档调用标志
  301.           $game_temp.save_calling = false
  302.           # 切换到地图画面
  303.           $scene = Scene_Map.new
  304.           return
  305.         end
  306.         # 切换到菜单画面
  307.         $scene = Scene_Menu.new(4)
  308.       when "load"
  309.         # 演奏取消 SE
  310.         $game_system.se_play($data_system.cancel_se)
  311.         # 切换到标题画面
  312.         $scene = Scene_Title.new
  313.       end
  314.     end
  315.     # 按下确定键
  316.     if Input.trigger?(Input::C)
  317.       # 计算存档编号
  318.       filename = SaveSettings.save_file_dir + "Save#{@command_window.index+1}.rxdata"
  319.       case @type
  320.       when "save"
  321.         if File.exist?(filename)
  322.           @confirm_window.visible = true
  323.           @confirm_window.cursor_rect.set(232,64,216,32)
  324.           @confirm_ok = false
  325.         else
  326.           process_save
  327.         end
  328.       when "load"
  329.         # 文件不存在的情况下
  330.         unless FileTest.exist?(filename)
  331.           # 演奏冻结 SE
  332.           $game_system.se_play($data_system.buzzer_se)
  333.           return
  334.         end
  335.         # 演奏读档 SE
  336.         $game_system.se_play($data_system.load_se)
  337.         # 写入存档数据
  338.         file = File.open(filename, "rb")
  339.         read_save_data(file)
  340.         file.close
  341.         # 还原 BGM、BGS
  342.         $game_system.bgm_play($game_system.playing_bgm)
  343.         $game_system.bgs_play($game_system.playing_bgs)
  344.         # 刷新地图 (执行并行事件)
  345.         $game_map.update
  346.         # 切换到地图画面
  347.         $scene = Scene_Map.new
  348.       end
  349.     end
  350.   end
  351.   #---------------------------------------------------------------------------#
  352.   # 确认窗口刷新                                                              #
  353.   #---------------------------------------------------------------------------#
  354.   def update_confirm
  355.     @confirm_window.update
  356.     if Input.trigger?(Input::LEFT) or Input.trigger?(Input::UP)
  357.       $game_system.se_play($data_system.cursor_se)
  358.       @confirm_ok = true
  359.     elsif Input.trigger?(Input::RIGHT) or Input.trigger?(Input::DOWN)
  360.       $game_system.se_play($data_system.cursor_se)
  361.       @confirm_ok = false
  362.     elsif Input.trigger?(Input::C)
  363.       $game_system.se_play($data_system.decision_se)
  364.       process_save if @confirm_ok
  365.       @confirm_window.visible = false
  366.     elsif Input.trigger?(Input::B)
  367.       $game_system.se_play($data_system.cancel_se)
  368.       @confirm_window.visible = false
  369.     end
  370.     @confirm_window.cursor_rect.set(232,64,216,32)
  371.     @confirm_window.cursor_rect.set(0,64,216,32) if @confirm_ok
  372.   end
  373.   #---------------------------------------------------------------------------#
  374.   # 执行存档                                                                  #
  375.   #---------------------------------------------------------------------------#
  376.   def process_save
  377.     # 计算存档编号
  378.     filename = SaveSettings.save_file_dir + "Save#{@command_window.index+1}.rxdata"
  379.     # 演奏存档 SE
  380.     $game_system.se_play($data_system.save_se)
  381.     # 写入存档数据
  382.     file = File.open(filename, "wb")
  383.     write_save_data(file)
  384.     file.close
  385.     # 如果被事件调用
  386.     if $game_temp.save_calling
  387.       # 清除存档调用标志
  388.       $game_temp.save_calling = false
  389.       # 切换到地图画面
  390.       $scene = Scene_Map.new
  391.       return
  392.     end
  393.     # 切换到菜单画面
  394.     $scene = Scene_Menu.new(4)
  395.   end
  396.   #---------------------------------------------------------------------------#
  397.   # 存档                                                                      #
  398.   #---------------------------------------------------------------------------#
  399.   def write_save_data(file)
  400.     # 生成描绘存档文件用的角色图形
  401.     characters = []
  402.     for i in 0...$game_party.actors.size
  403.       actor = $game_party.actors[i]
  404.       characters.push([actor.character_name, actor.character_hue])
  405.     end
  406.     # 写入描绘存档文件用的角色数据
  407.     Marshal.dump(characters, file)
  408.     # 写入测量游戏时间用画面计数
  409.     Marshal.dump(Graphics.frame_count, file)
  410.     # 增加 1 次存档次数
  411.     $game_system.save_count += 1
  412.     # 保存魔法编号
  413.     # (将编辑器保存的值以随机值替换)
  414.     $game_system.magic_number = $data_system.magic_number
  415.     # 写入各种游戏对像
  416.     Marshal.dump($game_system, file)
  417.     Marshal.dump($game_switches, file)
  418.     Marshal.dump($game_variables, file)
  419.     Marshal.dump($game_self_switches, file)
  420.     Marshal.dump($game_screen, file)
  421.     Marshal.dump($game_actors, file)
  422.     Marshal.dump($game_party, file)
  423.     Marshal.dump($game_troop, file)
  424.     Marshal.dump($game_map, file)
  425.     Marshal.dump($game_player, file)
  426.   end
  427.   #---------------------------------------------------------------------------#
  428.   # 读档                                                                      #
  429.   #---------------------------------------------------------------------------#
  430.   def read_save_data(file)
  431.     # 读取描绘存档文件用的角色数据
  432.     characters = Marshal.load(file)
  433.     # 读取测量游戏时间用画面计数
  434.     Graphics.frame_count = Marshal.load(file)
  435.     # 读取各种游戏对像
  436.     $game_system        = Marshal.load(file)
  437.     $game_switches      = Marshal.load(file)
  438.     $game_variables     = Marshal.load(file)
  439.     $game_self_switches = Marshal.load(file)
  440.     $game_screen        = Marshal.load(file)
  441.     $game_actors        = Marshal.load(file)
  442.     $game_party         = Marshal.load(file)
  443.     $game_troop         = Marshal.load(file)
  444.     $game_map           = Marshal.load(file)
  445.     $game_player        = Marshal.load(file)
  446.     # 魔法编号与保存时有差异的情况下
  447.     # (加入编辑器的编辑过的数据)
  448.     if $game_system.magic_number != $data_system.magic_number
  449.       # 重新装载地图
  450.       $game_map.setup($game_map.map_id)
  451.       $game_player.center($game_player.x, $game_player.y)
  452.     end
  453.     # 刷新同伴成员
  454.     $game_party.refresh
  455.   end
  456. end
  457.  
  458. #-----------------------------------------------------------------------------#
  459. # Graphics.snap_to_bitmap(优化版)                                           #
  460. # 作者:神思                                                                  #
  461. # 优化:釣到一隻猴子@_@  (  AAM@_@  )                                         #
  462. #-----------------------------------------------------------------------------#
  463. #-----------------------------------------------------------------------------#
  464. # Graphics                                                                    #
  465. #-----------------------------------------------------------------------------#
  466. class << Graphics
  467.   SRCCOPY = 0xCC0020
  468.   BitBlt = Win32API.new("gdi32", "BitBlt", "lllllllll", "l")
  469.   CreateCompatibleBitmap = Win32API.new("gdi32", "CreateCompatibleBitmap", "lll", "l")
  470.   CreateCompatibleDC = Win32API.new("gdi32", "CreateCompatibleDC", "l", "l")
  471.   DeleteDC = Win32API.new("gdi32", "DeleteDC", "l", "l")
  472.   DeleteObject = Win32API.new("gdi32", "DeleteObject", "l", "l")
  473.   SelectObject = Win32API.new("gdi32", "SelectObject", "ll", "l")
  474.   GetBitmapBits = Win32API.new("gdi32", "GetBitmapBits", "llp", "l")
  475.  
  476.   GetWindowDC = Win32API.new("user32", "GetWindowDC", "l", "l")
  477.   ReleaseDC = Win32API.new("user32", "ReleaseDC", "ll", "l")
  478.   GetWindowRect = Win32API.new("user32", "GetWindowRect", "lp", "l")
  479.   GetClientRect = Win32API.new("user32", "GetClientRect", "lp", "l")
  480.   ClientToScreen = Win32API.new("user32", "ClientToScreen", "ip", "i")
  481.  
  482.   RtlMoveMemory = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
  483.   HWnd = Win32API.new("user32", "GetActiveWindow", nil, 'l').call
  484.   #---------------------------------------------------------------------------#
  485.   # snap_to_bitmap                                                            #
  486.   #---------------------------------------------------------------------------#
  487.   def snap_to_bitmap
  488.     width, height, rgbs = self.bitmap_data
  489.     hb = Bitmap.new(width, height)
  490.     len = width * 4
  491.     ptr = [rgbs].pack("p").unpack("l")[0]
  492.     ptrs = []
  493.     height.times{|i| ptrs[height -1 -i] = ptr + (len * i)}
  494.     pdest = hb.address
  495.     height.times do |y|
  496.       RtlMoveMemory.call(pdest, ptrs[y], len)
  497.       pdest += len
  498.     end
  499.     return hb
  500.   end
  501.   #---------------------------------------------------------------------------#
  502.   # bitmap_data                                                               #
  503.   #---------------------------------------------------------------------------#
  504.   def bitmap_data
  505.     hdcSrc = GetWindowDC.call(HWnd)
  506.     wrect = [0,0,0,0].pack("l*")
  507.     crect = wrect.clone
  508.     point = [0, 0].pack("l*")
  509.     GetWindowRect.call(HWnd, wrect)
  510.     GetClientRect.call(HWnd, crect)
  511.     ClientToScreen.call(HWnd, point)
  512.     wrect = wrect.unpack("l*")
  513.     crect = crect.unpack("l*")
  514.     point = point.unpack("l*")
  515.     wrect[0] -= point[0]
  516.     wrect[1] -= point[1]
  517.     hdcDest = CreateCompatibleDC.call(hdcSrc)
  518.     hBitmap = CreateCompatibleBitmap.call(hdcSrc, crect[2], crect[3])
  519.     hOld = SelectObject.call(hdcDest, hBitmap)
  520.     BitBlt.call(hdcDest, wrect[0], wrect[1], crect[2] - wrect[0], crect[3] - wrect[1], hdcSrc, 0, 0, SRCCOPY)
  521.     SelectObject.call(hdcDest, hOld)
  522.     DeleteDC.call(hdcDest)
  523.     ReleaseDC.call(HWnd, hdcSrc)
  524.     dwCount = crect[2] * crect[3]
  525.     lpBits = ([0] * dwCount).pack("l*")
  526.     GetBitmapBits.call(hBitmap, dwCount * 4, lpBits)
  527.     DeleteObject.call(hBitmap)
  528.     return crect[2], crect[3], lpBits
  529.   end
  530. end
  531.  
  532. #-----------------------------------------------------------------------------#
  533. # Font                                                                        #
  534. #-----------------------------------------------------------------------------#
  535. class Font
  536.   #---------------------------------------------------------------------------#
  537.   # marshal_dump                                                              #
  538.   #---------------------------------------------------------------------------#
  539.   def marshal_dump
  540.   end
  541.   #---------------------------------------------------------------------------#
  542.   # marshal_load                                                              #
  543.   #---------------------------------------------------------------------------#
  544.   def marshal_load(obj)
  545.   end
  546. end
  547.  
  548. #-----------------------------------------------------------------------------#
  549. # Bitmap                                                                      #
  550. #-----------------------------------------------------------------------------#
  551. class Bitmap
  552.   RtlMoveMemory = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  553.   # 传送到内存的API函数
  554.   RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  555.   RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
  556.   #---------------------------------------------------------------------------#
  557.   # _dump                                                                     #
  558.   #---------------------------------------------------------------------------#
  559.   def _dump(limit)
  560.     data = "rgba" * width * height
  561.     RtlMoveMemory_pi.call(data, address, data.length)
  562.     [width, height, Zlib::Deflate.deflate(data)].pack("LLa*") # 压缩
  563.   end
  564.   #---------------------------------------------------------------------------#
  565.   # _load                                                                     #
  566.   #---------------------------------------------------------------------------#
  567.   def self._load(str)
  568.     w, h, zdata = str.unpack("LLa*")
  569.     b = self.new(w, h)
  570.     RtlMoveMemory_ip.call(b.address, Zlib::Inflate.inflate(zdata), w * h * 4)
  571.     return b
  572.   end
  573.   #---------------------------------------------------------------------------#
  574.   # address                                                                   #
  575.   #---------------------------------------------------------------------------#
  576.   def address
  577.     # [[[bitmap.object_id * 2 + 16] + 8] + 16] == 数据的开头
  578.     buffer, ad = "xxxx", object_id * 2 + 16
  579.     RtlMoveMemory.call(buffer, ad, 4)
  580.     ad = buffer.unpack("L")[0] + 8
  581.     RtlMoveMemory.call(buffer, ad, 4)
  582.     ad = buffer.unpack("L")[0] + 16
  583.     RtlMoveMemory.call(buffer, ad, 4)
  584.     return buffer.unpack("L")[0]
  585.   end
  586. end


由于只是技术交流用,因此不提供截图,所以截图请自行补脑==

评分

参与人数 2星屑 +65 收起 理由
daosi + 20 感谢更新
gonglinyuan + 45 技术贴竟然没人塞糖,真是心寒…….

查看全部评分

本人擅长XP,如果有脚本或者Ruby方面的问题欢迎发电邮到[email protected]咨询,本人很少检查电邮所以不一定会及时回复,本人不会直接出手解决问题只会提供一个方向,所以谢绝伸手党

Lv5.捕梦者 (管理员)

老黄鸡

梦石
0
星屑
39352
在线时间
7470 小时
注册时间
2009-7-6
帖子
13482

开拓者贵宾

发表于 2014-5-15 10:35:16 | 显示全部楼层
不同屏幕分辨率比如16位色和32位色一个像素所占字节数不同,所以这个脚本只能在32位色下正常工作。

点评

额,这就不关我的事了==  发表于 2014-5-15 10:36
RGDirect - DirectX驱动的RGSS,点我了解.
RM全系列成套系统定制请联系QQ1213237796
不接受对其他插件维护的委托
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
28 小时
注册时间
2016-9-30
帖子
9
发表于 2016-12-16 23:52:47 | 显示全部楼层
额,看起来还不错
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-3-28 21:39

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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