查看: 2723|回复: 2

[已经解决] 存档页背景更替

[复制链接]

迷途知返,恍如隔世

梦石
0
星屑
488
在线时间
1355 小时
注册时间
2011-2-17
回帖
1173

开拓者

发表于 2015-9-6 14:12:03 | 显示全部楼层 |阅读模式

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

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

×
已经根据自己的需求更改了部分脚本。

save.jpg

↑图片大概是这样,10个框,选项在第一个,显示"1.jpg"是第一个亮,以此类推"10.jpg"是第十个亮。


想要实现的效果是默认显示背景是“1.jpg"(且左边的save00X的字显示着,隐藏掉默认的选框)

按下键,背景切换到"2.jpg"……依次类推,到第10个存档显示“10.jpg”

但因为存档位 >10个,10个后会下拉,所以到第十个往下按应该都显示的是"10.jpg",往上按会显示"9.jpg"


大概就是根据展示出来的10个存档位显示相应的背景,选中哪个显示的是哪个选项亮的背景,且隐藏command默认的选框,只显示字。

有点繁琐的感觉……自己修改无果,只能再来求大神相助。


使用的是这段脚本:

  1. #-----------------------------------------------------------------------------#
  2. # 脚本设定                                                                    #
  3. #-----------------------------------------------------------------------------#
  4. # 说明:                                                                      #
  5. # ①主要采用了Snap To Bitmap这脚本省去了DLL。                                 #
  6. # ②采用了禁术,各位不用到处改脚本了,不过冲突率也大增==                      #
  7. # ③脚本当中采用的脚本归原作者所有。                                          #
  8. # ④设置区域的变量请自行更改。                                                #
  9. #-----------------------------------------------------------------------------#
  10. SaveSettings = Struct.new(:max_save_file,:save_file_dir,:slot_name_format,
  11. :save_help,:load_help,:override_question,:snap_no_found,:no_save_file).new
  12. #-----------------------------------------------------------------------------#
  13. # 设置区域
  14. #-----------------------------------------------------------------------------#
  15. # 最大的存档量
  16. SaveSettings.max_save_file = 20
  17. # 存档所在文件夹
  18. SaveSettings.save_file_dir = "Save/"
  19. # 存档槽的名称的格式,具体请参考sprintf
  20. SaveSettings.slot_name_format = "Save%03d"
  21. # 存档界面所显示的字符串
  22. SaveSettings.save_help = ""
  23. # 读档界面所显示的字符串
  24. SaveSettings.load_help = ""
  25. # 需要覆盖存档时所发问的问题
  26. SaveSettings.override_question = "该档位已有存档,是否覆盖?"
  27. # 找不到截图时的信息
  28. SaveSettings.snap_no_found = "截图似乎有点问题……你都做了啥啊?"
  29. # 存档槽没有存档时显示的信息
  30. SaveSettings.no_save_file = "这里还没有存档哦"

  31. #-----------------------------------------------------------------------------#
  32. # 创建存档文件夹                                                              #
  33. #-----------------------------------------------------------------------------#
  34. Dir.mkdir(SaveSettings.save_file_dir) unless FileTest.directory?(SaveSettings.save_file_dir)

  35. #-----------------------------------------------------------------------------#
  36. # 游戏核心处理类                                                              #
  37. #-----------------------------------------------------------------------------#
  38. class Game_System
  39.   #---------------------------------------------------------------------------#
  40.   # 实例变量                                                                  #
  41.   #---------------------------------------------------------------------------#
  42.   attr_accessor:snap_bitmap
  43. end

  44. #-----------------------------------------------------------------------------#
  45. # 拦截读档与存档界面的打开与地图进入菜单前截图                                #
  46. #-----------------------------------------------------------------------------#
  47. trace_var :$scene do
  48.   if $scene.is_a?(Scene_Save)
  49.     $scene = Scene_Save_Load.new
  50.   elsif $scene.is_a?(Scene_Load)
  51.     $scene = Scene_Save_Load.new(1)
  52.   end
  53.   if $scene.is_a?(Scene_Menu) and $_prev_scene == "Scene_Map"
  54.     $game_system.snap_bitmap = Graphics.snap_to_bitmap
  55.   end
  56.   $_prev_scene = $scene.class.name
  57. end

  58. #-----------------------------------------------------------------------------#
  59. # 强改Scene_Title(禁术)                                                       #
  60. #-----------------------------------------------------------------------------#
  61. Scene_Title.class_eval do
  62.   instance_methods(false).each do |meth|
  63.     remove_method(meth)
  64.   end
  65.   def __found_save_file
  66.     for i in 1..SaveSettings.max_save_file
  67.       return true if File.exist?(SaveSettings.save_file_dir + "Save#{i}.rxdata")
  68.     end
  69.     return false
  70.   end
  71. end
  72. for i in 0...$RGSS_SCRIPTS.size
  73.   next if ("Section%03d" % i) == __FILE__
  74.   ary = $RGSS_SCRIPTS[i]
  75.   if ary[3][/class\s+Scene_Title/]
  76.     script = ary[3].clone.gsub(/(if|unless)\s+@continue_enabled/){"#{$1} __found_save_file"}
  77.     eval script, TOPLEVEL_BINDING, ("Section%03d" % i)
  78.   end
  79. end

  80. #-----------------------------------------------------------------------------#
  81. # 存档界面用窗口                                                              #
  82. #-----------------------------------------------------------------------------#
  83. class Window_Save < Window_Base
  84.   #---------------------------------------------------------------------------#
  85.   # 初始化                                                                    #
  86.   #---------------------------------------------------------------------------#
  87.   def initialize
  88.     super(160,64,480,416)
  89.     self.contents = Bitmap.new(width-32,height-32)
  90.     self.opacity=0
  91.     @_index = -1
  92.     refresh(0)
  93.   end
  94.   #---------------------------------------------------------------------------#
  95.   # 刷新                                                                      #
  96.   #---------------------------------------------------------------------------#
  97.   def refresh(index)
  98.     if index != @_index
  99.       # 清除原有资料
  100.       self.contents.clear
  101.       @sprite.dispose if @sprite != nil
  102.       @sprite = nil
  103.       # 开始读取资料
  104.       @file_index = index
  105.       @filename = SaveSettings.save_file_dir + "Save#{@file_index + 1}.rxdata"
  106.       @time_stamp = Time.at(0)
  107.       @file_exist = FileTest.exist?(@filename)
  108.       if @file_exist
  109.         file = File.open(@filename, "r")
  110.         @time_stamp         = file.mtime
  111.         @characters         = Marshal.load(file)
  112.         @frame_count        = Marshal.load(file)
  113.         @game_system        = Marshal.load(file)
  114.         @game_switches      = Marshal.load(file)
  115.         @game_variables     = Marshal.load(file)
  116.         @game_self_switches = Marshal.load(file)
  117.         @game_screen        = Marshal.load(file)
  118.         @game_actors        = Marshal.load(file)
  119.         @game_party         = Marshal.load(file)
  120.         @game_troop         = Marshal.load(file)
  121.         @game_map           = Marshal.load(file)
  122.         @game_player        = Marshal.load(file)
  123.         @bitmap             = @game_system.snap_bitmap
  124.         @total_sec = @frame_count / Graphics.frame_rate
  125.         file.close
  126.         # 描绘截图的框与影子
  127.         self.contents.fill_rect(38,11,400,300,Color.new(0,0,0))
  128.         self.contents.fill_rect(27,0,402,302,system_color)
  129.         self.contents.fill_rect(28,1,400,300,Color.new(0,0,0,0))
  130.         # 如截图不为空的话
  131.         if @bitmap != nil
  132.           # 描绘截图
  133.           @sprite = Sprite.new
  134.           @sprite.bitmap = @bitmap
  135.           @sprite.x = 160+16+28
  136.           @sprite.y = 64+16+1
  137.           @sprite.zoom_x = @sprite.zoom_y = 0.625
  138.           @sprite.z = 99999
  139.         else
  140.           self.contents.draw_text(0,96,448,32,SaveSettings.snap_no_found,1)
  141.         end
  142.         # 描绘角色
  143.         for i in [url=mailto:0...@characters.size]0...@characters.size[/url]
  144.           x = i*35 +30
  145.           bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
  146.           self.contents.blt(x,310,bitmap,Rect.new(0,0,bitmap.width/4,bitmap.height/4))
  147.         end
  148.         # 描绘游戏时间
  149.         hour = @total_sec / 60 / 60
  150.         min = @total_sec / 60 % 60
  151.         sec = @total_sec % 60
  152.         time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  153.         self.contents.font.color = normal2_color
  154.         self.contents.draw_text(0-25,316,448,32,time_string,2)
  155.         # 描绘时间标记
  156.         self.contents.font.color = normal2_color
  157.         time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  158.         self.contents.draw_text(0-25,341,448,32,time_string, 2)
  159.       else
  160.         self.contents.draw_text(0,320,448,32,SaveSettings.no_save_file,1)
  161.       end
  162.       @_index = index
  163.     end
  164.   end
  165.   #---------------------------------------------------------------------------#
  166.   # 释放                                                                      #
  167.   #---------------------------------------------------------------------------#
  168.   def dispose
  169.     super
  170.     @sprite.dispose if @sprite != nil
  171.     @sprite = nil
  172.   end
  173. end

  174. #-----------------------------------------------------------------------------#
  175. # 存档界面                                                                    #
  176. #-----------------------------------------------------------------------------#
  177. class Scene_Save_Load
  178.   #---------------------------------------------------------------------------#
  179.   # 初始化                                                                    #
  180.   #---------------------------------------------------------------------------#
  181.   def initialize(type=0)
  182.     @type = type == 0 ? "save" : "load"
  183.     case @type
  184.     when "save"
  185.       @word = SaveSettings.save_help
  186.     when "load"
  187.       @word = SaveSettings.load_help
  188.       $game_temp = Game_Temp.new
  189.     end
  190.   end
  191.   #---------------------------------------------------------------------------#
  192.   # 主执行                                                                    #
  193.   #---------------------------------------------------------------------------#
  194.   def main
  195.     # 生成帮助窗口
  196.     @help_window = Window_Help.new
  197.     @help_window.set_text(@word)
  198.     @help_window.opacity =0
  199.     # 选项窗口
  200.     choose = []
  201.     for i in 1..SaveSettings.max_save_file
  202.       choose.push(SaveSettings.slot_name_format % i)
  203.     end
  204.     @command_window = Window_Command.new(110,choose)
  205.     @command_window.width =110
  206.     @command_window.height = 350
  207.     @command_window.x = 53
  208.     @command_window.y = 85
  209.     @command_window.opacity=0
  210.     @command_window.active = true
  211.     # 存档资料窗口
  212.     @save_window = Window_Save.new
  213.     # 确认窗口
  214.     @confirm_window = Window_Base.new(80,176,480,128)
  215.     @confirm_window.contents = Bitmap.new(448,96)
  216.     @confirm_window.contents.draw_text(0,0,448,32,SaveSettings.override_question,1)
  217.     @confirm_window.contents.draw_text(0,64,216,32,"确定",1)
  218.     @confirm_window.contents.draw_text(232,64,216,32,"取消",1)
  219.     @confirm_window.cursor_rect.set(232,64,216,32)
  220.     @confirm_window.z = 999999
  221.     @confirm_window.visible = false
  222.     @confirm_ok = false
  223.     # 执行过渡
  224.     Graphics.transition
  225.     # 主循环
  226.     loop do
  227.       # 刷新游戏画面
  228.       Graphics.update
  229.       # 刷新输入信息
  230.       Input.update
  231.       # 刷新画面
  232.       update
  233.       # 如果画面切换的话的就中断循环
  234.       if $scene != self
  235.         break
  236.       end
  237.     end
  238.     # 准备过渡
  239.     Graphics.freeze
  240.     # 释放窗口
  241.     @help_window.dispose
  242.     @save_window.dispose
  243.     @command_window.dispose
  244.     @confirm_window.dispose
  245.     @sprite2.dispose
  246.   end
  247.   #---------------------------------------------------------------------------#
  248.   # 刷新                                                                      #
  249.   #---------------------------------------------------------------------------#
  250.   def update
  251.     # 选择存档窗口激活
  252.     unless @confirm_window.visible
  253.       update_command
  254.     else
  255.       update_confirm
  256.     end
  257.   end
  258.   #---------------------------------------------------------------------------#
  259.   # 选择存档窗口刷新                                                          #
  260.   #---------------------------------------------------------------------------#
  261.   def update_command
  262.     @command_window.update
  263.     @save_window.refresh(@command_window.index)
  264.     # 按下取消键
  265.     if Input.trigger?(Input::B)
  266.       case @type
  267.       when "save"
  268.         # 演奏取消 SE
  269.         $game_system.se_play($data_system.cancel_se)
  270.         # 如果被事件调用
  271.         if $game_temp.save_calling
  272.           # 清除存档调用标志
  273.           $game_temp.save_calling = false
  274.           # 切换到地图画面
  275.           $scene = Scene_Map.new
  276.           return
  277.         end
  278.         # 切换到菜单画面
  279.         $scene = Scene_Menu.new(4)
  280.       when "load"
  281.         # 演奏取消 SE
  282.         $game_system.se_play($data_system.cancel_se)
  283.         # 切换到标题画面
  284.         $scene = Scene_Title.new
  285.       end
  286.     end
  287.     # 按下确定键
  288.     if Input.trigger?(Input::C)
  289.       # 计算存档编号
  290.       filename = SaveSettings.save_file_dir + "Save#{@command_window.index+1}.rxdata"
  291.       case @type
  292.       when "save"
  293.         if File.exist?(filename)
  294.           @confirm_window.visible = true
  295.           @confirm_window.cursor_rect.set(232,64,216,32)
  296.           @confirm_ok = false
  297.         else
  298.           process_save
  299.         end
  300.       when "load"
  301.         # 文件不存在的情况下
  302.         unless FileTest.exist?(filename)
  303.           # 演奏冻结 SE
  304.           $game_system.se_play($data_system.buzzer_se)
  305.           return
  306.         end
  307.         # 演奏读档 SE
  308.         $game_system.se_play($data_system.load_se)
  309.         # 写入存档数据
  310.         file = File.open(filename, "rb")
  311.         read_save_data(file)
  312.         file.close
  313.         # 还原 BGM、BGS
  314.         $game_system.bgm_play($game_system.playing_bgm)
  315.         $game_system.bgs_play($game_system.playing_bgs)
  316.         # 刷新地图 (执行并行事件)
  317.         $game_map.update
  318.         # 切换到地图画面
  319.         $scene = Scene_Map.new
  320.       end
  321.     end
  322.   end
  323.   #---------------------------------------------------------------------------#
  324.   # 确认窗口刷新                                                              #
  325.   #---------------------------------------------------------------------------#
  326.   def update_confirm
  327.     @confirm_window.update
  328.     if Input.trigger?(Input::LEFT) or Input.trigger?(Input::UP)
  329.       $game_system.se_play($data_system.cursor_se)
  330.       @confirm_ok = true
  331.     elsif Input.trigger?(Input::RIGHT) or Input.trigger?(Input::DOWN)
  332.       $game_system.se_play($data_system.cursor_se)
  333.       @confirm_ok = false
  334.     elsif Input.trigger?(Input::C)
  335.       $game_system.se_play($data_system.decision_se)
  336.       process_save if @confirm_ok
  337.       @confirm_window.visible = false
  338.     elsif Input.trigger?(Input::B)
  339.       $game_system.se_play($data_system.cancel_se)
  340.       @confirm_window.visible = false
  341.     end
  342.     @confirm_window.cursor_rect.set(232,64,216,32)
  343.     @confirm_window.cursor_rect.set(0,64,216,32) if @confirm_ok
  344.   end
  345.   #---------------------------------------------------------------------------#
  346.   # 执行存档                                                                  #
  347.   #---------------------------------------------------------------------------#
  348.   def process_save
  349.     # 计算存档编号
  350.     filename = SaveSettings.save_file_dir + "Save#{@command_window.index+1}.rxdata"
  351.     # 演奏存档 SE
  352.     $game_system.se_play($data_system.save_se)
  353.     # 写入存档数据
  354.     file = File.open(filename, "wb")
  355.     write_save_data(file)
  356.     file.close
  357.     # 如果被事件调用
  358.     if $game_temp.save_calling
  359.       # 清除存档调用标志
  360.       $game_temp.save_calling = false
  361.       # 切换到地图画面
  362.       $scene = Scene_Map.new
  363.       return
  364.     end
  365.     # 切换到菜单画面
  366.     $scene = Scene_Menu.new(4)
  367.   end
  368.   #---------------------------------------------------------------------------#
  369.   # 存档                                                                      #
  370.   #---------------------------------------------------------------------------#
  371.   def write_save_data(file)
  372.     # 生成描绘存档文件用的角色图形
  373.     characters = []
  374.     for i in 0...$game_party.actors.size
  375.       actor = $game_party.actors[i]
  376.       characters.push([actor.character_name, actor.character_hue])
  377.     end
  378.     # 写入描绘存档文件用的角色数据
  379.     Marshal.dump(characters, file)
  380.     # 写入测量游戏时间用画面计数
  381.     Marshal.dump(Graphics.frame_count, file)
  382.     # 增加 1 次存档次数
  383.     $game_system.save_count += 1
  384.     # 保存魔法编号
  385.     # (将编辑器保存的值以随机值替换)
  386.     $game_system.magic_number = $data_system.magic_number
  387.     # 写入各种游戏对像
  388.     Marshal.dump($game_system, file)
  389.     Marshal.dump($game_switches, file)
  390.     Marshal.dump($game_variables, file)
  391.     Marshal.dump($game_self_switches, file)
  392.     Marshal.dump($game_screen, file)
  393.     Marshal.dump($game_actors, file)
  394.     Marshal.dump($game_party, file)
  395.     Marshal.dump($game_troop, file)
  396.     Marshal.dump($game_map, file)
  397.     Marshal.dump($game_player, file)
  398.   end
  399.   #---------------------------------------------------------------------------#
  400.   # 读档                                                                      #
  401.   #---------------------------------------------------------------------------#
  402.   def read_save_data(file)
  403.     # 读取描绘存档文件用的角色数据
  404.     characters = Marshal.load(file)
  405.     # 读取测量游戏时间用画面计数
  406.     Graphics.frame_count = Marshal.load(file)
  407.     # 读取各种游戏对像
  408.     $game_system        = Marshal.load(file)
  409.     $game_switches      = Marshal.load(file)
  410.     $game_variables     = Marshal.load(file)
  411.     $game_self_switches = Marshal.load(file)
  412.     $game_screen        = Marshal.load(file)
  413.     $game_actors        = Marshal.load(file)
  414.     $game_party         = Marshal.load(file)
  415.     $game_troop         = Marshal.load(file)
  416.     $game_map           = Marshal.load(file)
  417.     $game_player        = Marshal.load(file)
  418.     # 魔法编号与保存时有差异的情况下
  419.     # (加入编辑器的编辑过的数据)
  420.     if $game_system.magic_number != $data_system.magic_number
  421.       # 重新装载地图
  422.       $game_map.setup($game_map.map_id)
  423.       $game_player.center($game_player.x, $game_player.y)
  424.     end
  425.     # 刷新同伴成员
  426.     $game_party.refresh
  427.   end
  428. end

  429. #-----------------------------------------------------------------------------#
  430. # Graphics.snap_to_bitmap(优化版)                                           #
  431. # 作者:神思                                                                  #
  432. # 优化:釣到一隻猴子@_@  (  AAM@_@  )                                         #
  433. # 出处:[url=www.66rpg.com]www.66rpg.com[/url]
  434. #-----------------------------------------------------------------------------#
  435. #-----------------------------------------------------------------------------#
  436. # Graphics                                                                    #
  437. #-----------------------------------------------------------------------------#
  438. class << Graphics
  439.   CreateDC = Win32API.new("gdi32", "CreateDC", "pppl", "l")
  440.   CreateCompatibleBitmap = Win32API.new("gdi32", "CreateCompatibleBitmap", "lll", "l")
  441.   CreateCompatibleDC = Win32API.new("gdi32", "CreateCompatibleDC", "l", "l")
  442.   SelectObject = Win32API.new("gdi32", "SelectObject", "ll", "l")
  443.   BitBlt = Win32API.new("gdi32", "BitBlt", "lllllllll", "l")
  444.   GetBitmapBits = Win32API.new("gdi32", "GetBitmapBits", "llp", "l")
  445.   ScreenToClient = Win32API.new("user32", "ScreenToClient", "ip", "i")
  446.   SRCCOPY = 0xCC0020
  447.   RtlMoveMemory = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
  448.   HWnd = Win32API.new("user32", "GetActiveWindow", nil, 'l').call
  449.   DwCount = (640 * 480 * 4) * 2
  450.   @@lpBits = "\000" * DwCount
  451.   #---------------------------------------------------------------------------#
  452.   # snap_to_bitmap                                                            #
  453.   #---------------------------------------------------------------------------#
  454.   def snap_to_bitmap
  455.     width, height = 640,480
  456.     hb = Bitmap.new(width, height)
  457.     rgbs = self.bitmap_data
  458.     len = width * 4
  459.     for y in 0...height
  460.       break if 2*y >= height - 1
  461.       nth1 = y * len
  462.       nth2 = (height - 1 - y) * len
  463.       tStr = rgbs[nth1,len]
  464.       rgbs[nth1, len] = rgbs[nth2, len]
  465.       rgbs[nth2, len] = tStr
  466.     end
  467.     RtlMoveMemory.call(hb.address, rgbs, 640 * 480 * 4)
  468.     return hb
  469.   end
  470.   #---------------------------------------------------------------------------#
  471.   # bitmap_data                                                          #
  472.   #---------------------------------------------------------------------------#
  473.   def bitmap_data
  474.     hScrDC = CreateDC.call("DISPLAY", "", "", 0)
  475.     hMemDC = CreateCompatibleDC.call(hScrDC)
  476.     hBitmap = CreateCompatibleBitmap.call(hScrDC, 640, 480)
  477.     hOldBitmap = SelectObject.call(hMemDC, hBitmap)
  478.     BitBlt.call(hMemDC, xsrc, ysrc, 640*2, 480*2, hScrDC, 0, 0, SRCCOPY)
  479.     hBitmap = SelectObject.call(hMemDC, hOldBitmap)
  480.     GetBitmapBits.call(hBitmap, DwCount, @@lpBits)
  481.     return @@lpBits
  482.   end
  483.   #---------------------------------------------------------------------------#
  484.   # 用户窗口的位置                                                            #
  485.   #---------------------------------------------------------------------------#
  486.   def xsrc
  487.     return self.point[0]
  488.   end
  489.   #---------------------------------------------------------------------------#
  490.   # 用户窗口的位置                                                            #
  491.   #---------------------------------------------------------------------------#
  492.   def ysrc
  493.     return self.point[1]
  494.   end
  495.   #---------------------------------------------------------------------------#
  496.   # 那个点                                                                    #
  497.   #---------------------------------------------------------------------------#
  498.   def point
  499.     point = [0,0].pack("LL")
  500.     ScreenToClient.call(HWnd, point)
  501.     return point.unpack("LL")
  502.   end
  503. end

  504. #-----------------------------------------------------------------------------#
  505. # Font                                                                        #
  506. #-----------------------------------------------------------------------------#
  507. class Font
  508.   #---------------------------------------------------------------------------#
  509.   # marshal_dump                                                              #
  510.   #---------------------------------------------------------------------------#
  511.   def marshal_dump
  512.   end
  513.   #---------------------------------------------------------------------------#
  514.   # marshal_load                                                              #
  515.   #---------------------------------------------------------------------------#
  516.   def marshal_load(obj)
  517.   end
  518. end

  519. #-----------------------------------------------------------------------------#
  520. # Bitmap                                                                      #
  521. #-----------------------------------------------------------------------------#
  522. class Bitmap
  523.   RtlMoveMemory = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  524.   # 传送到内存的API函数
  525.   RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  526.   RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
  527.   #---------------------------------------------------------------------------#
  528.   # _dump                                                                     #
  529.   #---------------------------------------------------------------------------#
  530.   def _dump(limit)
  531.     data = "rgba" * width * height
  532.     RtlMoveMemory_pi.call(data, address, data.length)
  533.     [width, height, Zlib::Deflate.deflate(data)].pack("LLa*") # 压缩
  534.   end
  535.   #---------------------------------------------------------------------------#
  536.   # _load                                                                     #
  537.   #---------------------------------------------------------------------------#
  538.   def self._load(str)
  539.     w, h, zdata = str.unpack("LLa*")
  540.     b = self.new(w, h)
  541.     RtlMoveMemory_ip.call(b.address, Zlib::Inflate.inflate(zdata), w * h * 4)
  542.     return b
  543.   end
  544.   #---------------------------------------------------------------------------#
  545.   # address                                                                   #
  546.   #---------------------------------------------------------------------------#
  547.   def address
  548.     # [[[bitmap.object_id * 2 + 16] + 8] + 16] == 数据的开头
  549.     buffer, ad = "xxxx", object_id * 2 + 16
  550.     RtlMoveMemory.call(buffer, ad, 4)
  551.     ad = buffer.unpack("L")[0] + 8
  552.     RtlMoveMemory.call(buffer, ad, 4)
  553.     ad = buffer.unpack("L")[0] + 16
  554.     RtlMoveMemory.call(buffer, ad, 4)
  555.     return buffer.unpack("L")[0]
  556.   end
  557. end
复制代码
  

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

梦石
0
星屑
9557
在线时间
5074 小时
注册时间
2013-6-21
回帖
3459

开拓者贵宾剧作品鉴家

发表于 2015-9-6 16:01:19 | 显示全部楼层
稍稍修改了一下脚本,由于没有制作好的图片无法完整测试。
去掉了窗口的光标(但是保留了滚屏的功能)。
ps原来窗口的宽高设置得有点问题,我给稍微调整了一下。
做好的图片请放到Graphics/Pictures/文件夹下,并命名为0.png~9.png
  1. #-----------------------------------------------------------------------------#
  2. # 脚本设定                                                                    #
  3. #-----------------------------------------------------------------------------#
  4. # 说明:                                                                      #
  5. # ①主要采用了Snap To Bitmap这脚本省去了DLL。                                 #
  6. # ②采用了禁术,各位不用到处改脚本了,不过冲突率也大增==                      #
  7. # ③脚本当中采用的脚本归原作者所有。                                          #
  8. # ④设置区域的变量请自行更改。                                                #
  9. #-----------------------------------------------------------------------------#
  10. SaveSettings = Struct.new(:max_save_file,:save_file_dir,:slot_name_format,
  11. :save_help,:load_help,:override_question,:snap_no_found,:no_save_file).new
  12. #-----------------------------------------------------------------------------#
  13. # 设置区域
  14. #-----------------------------------------------------------------------------#
  15. # 最大的存档量
  16. SaveSettings.max_save_file = 20
  17. # 存档所在文件夹
  18. SaveSettings.save_file_dir = "Save/"
  19. # 存档槽的名称的格式,具体请参考sprintf
  20. SaveSettings.slot_name_format = "Save%03d"
  21. # 存档界面所显示的字符串
  22. SaveSettings.save_help = ""
  23. # 读档界面所显示的字符串
  24. SaveSettings.load_help = ""
  25. # 需要覆盖存档时所发问的问题
  26. SaveSettings.override_question = "该档位已有存档,是否覆盖?"
  27. # 找不到截图时的信息
  28. SaveSettings.snap_no_found = "截图似乎有点问题……你都做了啥啊?"
  29. # 存档槽没有存档时显示的信息
  30. SaveSettings.no_save_file = "这里还没有存档哦"

  31. #-----------------------------------------------------------------------------#
  32. # 创建存档文件夹                                                              #
  33. #-----------------------------------------------------------------------------#
  34. Dir.mkdir(SaveSettings.save_file_dir) unless FileTest.directory?(SaveSettings.save_file_dir)

  35. #-----------------------------------------------------------------------------#
  36. # 游戏核心处理类                                                              #
  37. #-----------------------------------------------------------------------------#
  38. class Game_System
  39.   #---------------------------------------------------------------------------#
  40.   # 实例变量                                                                  #
  41.   #---------------------------------------------------------------------------#
  42.   attr_accessor:snap_bitmap
  43. end

  44. #-----------------------------------------------------------------------------#
  45. # 拦截读档与存档界面的打开与地图进入菜单前截图                                #
  46. #-----------------------------------------------------------------------------#
  47. trace_var :$scene do
  48.   if $scene.is_a?(Scene_Save)
  49.     $scene = Scene_Save_Load.new
  50.   elsif $scene.is_a?(Scene_Load)
  51.     $scene = Scene_Save_Load.new(1)
  52.   end
  53.   if $scene.is_a?(Scene_Menu) and $_prev_scene == "Scene_Map"
  54.     $game_system.snap_bitmap = Graphics.snap_to_bitmap
  55.   end
  56.   $_prev_scene = $scene.class.name
  57. end

  58. #-----------------------------------------------------------------------------#
  59. # 强改Scene_Title(禁术)                                                       #
  60. #-----------------------------------------------------------------------------#
  61. Scene_Title.class_eval do
  62.   instance_methods(false).each do |meth|
  63.     remove_method(meth)
  64.   end
  65.   def __found_save_file
  66.     for i in 1..SaveSettings.max_save_file
  67.       return true if File.exist?(SaveSettings.save_file_dir + "Save#{i}.rxdata")
  68.     end
  69.     return false
  70.   end
  71. end
  72. for i in 0...$RGSS_SCRIPTS.size
  73.   next if ("Section%03d" % i) == __FILE__
  74.   ary = $RGSS_SCRIPTS[i]
  75.   if ary[3][/class\s+Scene_Title/]
  76.     script = ary[3].clone.gsub(/(if|unless)\s+@continue_enabled/){"#{$1} __found_save_file"}
  77.     eval script, TOPLEVEL_BINDING, ("Section%03d" % i)
  78.   end
  79. end

  80. #-----------------------------------------------------------------------------#
  81. # 存档界面用窗口                                                              #
  82. #-----------------------------------------------------------------------------#
  83. class Window_Save < Window_Base
  84.   #---------------------------------------------------------------------------#
  85.   # 初始化                                                                    #
  86.   #---------------------------------------------------------------------------#
  87.   def initialize
  88.     super(160,64,480,416)
  89.     self.contents = Bitmap.new(width-32,height-32)
  90.     self.opacity=0
  91.     @_index = -1
  92.     refresh(0)
  93.   end
  94.   #---------------------------------------------------------------------------#
  95.   # 刷新                                                                      #
  96.   #---------------------------------------------------------------------------#
  97.   def refresh(index)
  98.     if index != @_index
  99.       # 清除原有资料
  100.       self.contents.clear
  101.       @sprite.dispose if @sprite != nil
  102.       @sprite = nil
  103.       # 开始读取资料
  104.       @file_index = index
  105.       @filename = SaveSettings.save_file_dir + "Save#{@file_index + 1}.rxdata"
  106.       @time_stamp = Time.at(0)
  107.       @file_exist = FileTest.exist?(@filename)
  108.       if @file_exist
  109.         file = File.open(@filename, "r")
  110.         @time_stamp         = file.mtime
  111.         @characters         = Marshal.load(file)
  112.         @frame_count        = Marshal.load(file)
  113.         @game_system        = Marshal.load(file)
  114.         @game_switches      = Marshal.load(file)
  115.         @game_variables     = Marshal.load(file)
  116.         @game_self_switches = Marshal.load(file)
  117.         @game_screen        = Marshal.load(file)
  118.         @game_actors        = Marshal.load(file)
  119.         @game_party         = Marshal.load(file)
  120.         @game_troop         = Marshal.load(file)
  121.         @game_map           = Marshal.load(file)
  122.         @game_player        = Marshal.load(file)
  123.         @bitmap             = @game_system.snap_bitmap
  124.         @total_sec = @frame_count / Graphics.frame_rate
  125.         file.close
  126.         # 描绘截图的框与影子
  127.         self.contents.fill_rect(38,11,400,300,Color.new(0,0,0))
  128.         self.contents.fill_rect(27,0,402,302,system_color)
  129.         self.contents.fill_rect(28,1,400,300,Color.new(0,0,0,0))
  130.         # 如截图不为空的话
  131.         if @bitmap != nil
  132.           # 描绘截图
  133.           @sprite = Sprite.new
  134.           @sprite.bitmap = @bitmap
  135.           @sprite.x = 160+16+28
  136.           @sprite.y = 64+16+1
  137.           @sprite.zoom_x = @sprite.zoom_y = 0.625
  138.           @sprite.z = 99999
  139.         else
  140.           self.contents.draw_text(0,96,448,32,SaveSettings.snap_no_found,1)
  141.         end
  142.         # 描绘角色
  143.         for i in [email]0...@characters.size[/email]
  144.           x = i*35 +30
  145.           bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
  146.           self.contents.blt(x,310,bitmap,Rect.new(0,0,bitmap.width/4,bitmap.height/4))
  147.         end
  148.         # 描绘游戏时间
  149.         hour = @total_sec / 60 / 60
  150.         min = @total_sec / 60 % 60
  151.         sec = @total_sec % 60
  152.         time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  153.         self.contents.font.color = normal2_color
  154.         self.contents.draw_text(0-25,316,448,32,time_string,2)
  155.         # 描绘时间标记
  156.         self.contents.font.color = normal2_color
  157.         time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  158.         self.contents.draw_text(0-25,341,448,32,time_string, 2)
  159.       else
  160.         self.contents.draw_text(0,320,448,32,SaveSettings.no_save_file,1)
  161.       end
  162.       @_index = index
  163.     end
  164.   end
  165.   #---------------------------------------------------------------------------#
  166.   # 释放                                                                      #
  167.   #---------------------------------------------------------------------------#
  168.   def dispose
  169.     super
  170.     @sprite.dispose if @sprite != nil
  171.     @sprite = nil
  172.   end
  173. end

  174. #-----------------------------------------------------------------------------#
  175. # 自定义 Window_Command_R : 不显示光标,但是可以滚动                          #
  176. #-----------------------------------------------------------------------------#
  177. class Window_Command_R < Window_Command
  178.   #---------------------------------------------------------------------------#
  179.   # 初始化 : 去掉光标                                                         #
  180.   #---------------------------------------------------------------------------#
  181.   def initialize(width, commands)
  182.     super(width, commands)
  183.     self.cursor_rect.empty
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ● 更新光标矩形 : 去掉设置光标的部分
  187.   #--------------------------------------------------------------------------
  188.   def update_cursor_rect
  189.     # 获取当前的行
  190.     row = @index / @column_max
  191.     # 当前行被显示开头行前面的情况下
  192.     if row < self.top_row
  193.       # 从当前行向开头行滚动
  194.       self.top_row = row
  195.     end
  196.     # 当前行被显示末尾行之后的情况下
  197.     if row > self.top_row + (self.page_row_max - 1)
  198.       # 从当前行向末尾滚动
  199.       self.top_row = row - (self.page_row_max - 1)
  200.     end
  201.   end
  202.   #---------------------------------------------------------------------------#
  203.   # 获取光标当前位置行                                                        #
  204.   #---------------------------------------------------------------------------#
  205.   def cursor_row
  206.     self.index / @column_max - top_row
  207.   end
  208. end

  209. #-----------------------------------------------------------------------------#
  210. # 存档界面                                                                    #
  211. #-----------------------------------------------------------------------------#
  212. class Scene_Save_Load
  213.   #---------------------------------------------------------------------------#
  214.   # 初始化                                                                    #
  215.   #---------------------------------------------------------------------------#
  216.   def initialize(type=0)
  217.     @type = type == 0 ? "save" : "load"
  218.     case @type
  219.     when "save"
  220.       @word = SaveSettings.save_help
  221.     when "load"
  222.       @word = SaveSettings.load_help
  223.       $game_temp = Game_Temp.new
  224.     end
  225.   end
  226.   #---------------------------------------------------------------------------#
  227.   # 主执行                                                                    #
  228.   #---------------------------------------------------------------------------#
  229.   def main
  230.     # 生成帮助窗口
  231.     @help_window = Window_Help.new
  232.     @help_window.set_text(@word)
  233.     @help_window.opacity =0
  234.     # 选项窗口
  235.     choose = []
  236.     for i in 1..SaveSettings.max_save_file
  237.       choose.push(SaveSettings.slot_name_format % i)
  238.     end
  239.     @command_window = Window_Command_R.new(120,choose)
  240.     @command_window.height = 352
  241.     @command_window.x = 53
  242.     @command_window.y = 85
  243.     @command_window.opacity=0
  244.     @command_window.active = true
  245.     @command_window.cursor_rect.empty
  246.     # 存档资料窗口
  247.     @save_window = Window_Save.new
  248.     # 确认窗口
  249.     @confirm_window = Window_Base.new(80,176,480,128)
  250.     @confirm_window.contents = Bitmap.new(448,96)
  251.     @confirm_window.contents.draw_text(0,0,448,32,SaveSettings.override_question,1)
  252.     @confirm_window.contents.draw_text(0,64,216,32,"确定",1)
  253.     @confirm_window.contents.draw_text(232,64,216,32,"取消",1)
  254.     @confirm_window.cursor_rect.set(232,64,216,32)
  255.     @confirm_window.z = 999999
  256.     @confirm_window.visible = false
  257.     @confirm_ok = false
  258.     # 背景选框
  259.     @pic_index = @command_window.cursor_row
  260.     @sprite_back_choice = Sprite.new
  261.     @sprite_back_choice.bitmap = RPG::Cache.picture("#{@pic_index}.png")
  262.     # 执行过渡
  263.     Graphics.transition
  264.     # 主循环
  265.     loop do
  266.       # 刷新游戏画面
  267.       Graphics.update
  268.       # 刷新输入信息
  269.       Input.update
  270.       # 刷新画面
  271.       update
  272.       # 如果画面切换的话的就中断循环
  273.       if $scene != self
  274.         break
  275.       end
  276.     end
  277.     # 准备过渡
  278.     Graphics.freeze
  279.     # 释放窗口
  280.     @help_window.dispose
  281.     @save_window.dispose
  282.     @command_window.dispose
  283.     @confirm_window.dispose
  284.     @sprite_back_choice.dispose
  285.   end
  286.   #---------------------------------------------------------------------------#
  287.   # 刷新                                                                      #
  288.   #---------------------------------------------------------------------------#
  289.   def update
  290.     # 选择存档窗口激活
  291.     unless @confirm_window.visible
  292.       update_command
  293.     else
  294.       update_confirm
  295.     end
  296.   end
  297.   #---------------------------------------------------------------------------#
  298.   # 选择存档窗口刷新                                                          #
  299.   #---------------------------------------------------------------------------#
  300.   def update_command
  301.     @command_window.update
  302.     @save_window.refresh(@command_window.index)
  303.     # 刷新背景选框
  304.     if @pic_index != @command_window.cursor_row
  305.       @pic_index = @command_window.cursor_row
  306.       @sprite_back_choice.bitmap = RPG::Cache.picture("#{@pic_index}.png")
  307.     end
  308.     # 按下取消键
  309.     if Input.trigger?(Input::B)
  310.       case @type
  311.       when "save"
  312.         # 演奏取消 SE
  313.         $game_system.se_play($data_system.cancel_se)
  314.         # 如果被事件调用
  315.         if $game_temp.save_calling
  316.           # 清除存档调用标志
  317.           $game_temp.save_calling = false
  318.           # 切换到地图画面
  319.           $scene = Scene_Map.new
  320.           return
  321.         end
  322.         # 切换到菜单画面
  323.         $scene = Scene_Menu.new(4)
  324.       when "load"
  325.         # 演奏取消 SE
  326.         $game_system.se_play($data_system.cancel_se)
  327.         # 切换到标题画面
  328.         $scene = Scene_Title.new
  329.       end
  330.     end
  331.     # 按下确定键
  332.     if Input.trigger?(Input::C)
  333.       # 计算存档编号
  334.       filename = SaveSettings.save_file_dir + "Save#{@command_window.index+1}.rxdata"
  335.       case @type
  336.       when "save"
  337.         if File.exist?(filename)
  338.           @confirm_window.visible = true
  339.           @confirm_window.cursor_rect.set(232,64,216,32)
  340.           @confirm_ok = false
  341.         else
  342.           process_save
  343.         end
  344.       when "load"
  345.         # 文件不存在的情况下
  346.         unless FileTest.exist?(filename)
  347.           # 演奏冻结 SE
  348.           $game_system.se_play($data_system.buzzer_se)
  349.           return
  350.         end
  351.         # 演奏读档 SE
  352.         $game_system.se_play($data_system.load_se)
  353.         # 写入存档数据
  354.         file = File.open(filename, "rb")
  355.         read_save_data(file)
  356.         file.close
  357.         # 还原 BGM、BGS
  358.         $game_system.bgm_play($game_system.playing_bgm)
  359.         $game_system.bgs_play($game_system.playing_bgs)
  360.         # 刷新地图 (执行并行事件)
  361.         $game_map.update
  362.         # 切换到地图画面
  363.         $scene = Scene_Map.new
  364.       end
  365.     end
  366.   end
  367.   #---------------------------------------------------------------------------#
  368.   # 确认窗口刷新                                                              #
  369.   #---------------------------------------------------------------------------#
  370.   def update_confirm
  371.     @confirm_window.update
  372.     if Input.trigger?(Input::LEFT) or Input.trigger?(Input::UP)
  373.       $game_system.se_play($data_system.cursor_se)
  374.       @confirm_ok = true
  375.     elsif Input.trigger?(Input::RIGHT) or Input.trigger?(Input::DOWN)
  376.       $game_system.se_play($data_system.cursor_se)
  377.       @confirm_ok = false
  378.     elsif Input.trigger?(Input::C)
  379.       $game_system.se_play($data_system.decision_se)
  380.       process_save if @confirm_ok
  381.       @confirm_window.visible = false
  382.     elsif Input.trigger?(Input::B)
  383.       $game_system.se_play($data_system.cancel_se)
  384.       @confirm_window.visible = false
  385.     end
  386.     @confirm_window.cursor_rect.set(232,64,216,32)
  387.     @confirm_window.cursor_rect.set(0,64,216,32) if @confirm_ok
  388.   end
  389.   #---------------------------------------------------------------------------#
  390.   # 执行存档                                                                  #
  391.   #---------------------------------------------------------------------------#
  392.   def process_save
  393.     # 计算存档编号
  394.     filename = SaveSettings.save_file_dir + "Save#{@command_window.index+1}.rxdata"
  395.     # 演奏存档 SE
  396.     $game_system.se_play($data_system.save_se)
  397.     # 写入存档数据
  398.     file = File.open(filename, "wb")
  399.     write_save_data(file)
  400.     file.close
  401.     # 如果被事件调用
  402.     if $game_temp.save_calling
  403.       # 清除存档调用标志
  404.       $game_temp.save_calling = false
  405.       # 切换到地图画面
  406.       $scene = Scene_Map.new
  407.       return
  408.     end
  409.     # 切换到菜单画面
  410.     $scene = Scene_Menu.new(4)
  411.   end
  412.   #---------------------------------------------------------------------------#
  413.   # 存档                                                                      #
  414.   #---------------------------------------------------------------------------#
  415.   def write_save_data(file)
  416.     # 生成描绘存档文件用的角色图形
  417.     characters = []
  418.     for i in 0...$game_party.actors.size
  419.       actor = $game_party.actors[i]
  420.       characters.push([actor.character_name, actor.character_hue])
  421.     end
  422.     # 写入描绘存档文件用的角色数据
  423.     Marshal.dump(characters, file)
  424.     # 写入测量游戏时间用画面计数
  425.     Marshal.dump(Graphics.frame_count, file)
  426.     # 增加 1 次存档次数
  427.     $game_system.save_count += 1
  428.     # 保存魔法编号
  429.     # (将编辑器保存的值以随机值替换)
  430.     $game_system.magic_number = $data_system.magic_number
  431.     # 写入各种游戏对像
  432.     Marshal.dump($game_system, file)
  433.     Marshal.dump($game_switches, file)
  434.     Marshal.dump($game_variables, file)
  435.     Marshal.dump($game_self_switches, file)
  436.     Marshal.dump($game_screen, file)
  437.     Marshal.dump($game_actors, file)
  438.     Marshal.dump($game_party, file)
  439.     Marshal.dump($game_troop, file)
  440.     Marshal.dump($game_map, file)
  441.     Marshal.dump($game_player, file)
  442.   end
  443.   #---------------------------------------------------------------------------#
  444.   # 读档                                                                      #
  445.   #---------------------------------------------------------------------------#
  446.   def read_save_data(file)
  447.     # 读取描绘存档文件用的角色数据
  448.     characters = Marshal.load(file)
  449.     # 读取测量游戏时间用画面计数
  450.     Graphics.frame_count = Marshal.load(file)
  451.     # 读取各种游戏对像
  452.     $game_system        = Marshal.load(file)
  453.     $game_switches      = Marshal.load(file)
  454.     $game_variables     = Marshal.load(file)
  455.     $game_self_switches = Marshal.load(file)
  456.     $game_screen        = Marshal.load(file)
  457.     $game_actors        = Marshal.load(file)
  458.     $game_party         = Marshal.load(file)
  459.     $game_troop         = Marshal.load(file)
  460.     $game_map           = Marshal.load(file)
  461.     $game_player        = Marshal.load(file)
  462.     # 魔法编号与保存时有差异的情况下
  463.     # (加入编辑器的编辑过的数据)
  464.     if $game_system.magic_number != $data_system.magic_number
  465.       # 重新装载地图
  466.       $game_map.setup($game_map.map_id)
  467.       $game_player.center($game_player.x, $game_player.y)
  468.     end
  469.     # 刷新同伴成员
  470.     $game_party.refresh
  471.   end
  472. end

  473. #-----------------------------------------------------------------------------#
  474. # Graphics.snap_to_bitmap(优化版)                                           #
  475. # 作者:神思                                                                  #
  476. # 优化:釣到一隻猴子@_@  (  AAM@_@  )                                         #
  477. # 出处:[url=www.66rpg.com]www.66rpg.com[/url]
  478. #-----------------------------------------------------------------------------#
  479. #-----------------------------------------------------------------------------#
  480. # Graphics                                                                    #
  481. #-----------------------------------------------------------------------------#
  482. class << Graphics
  483.   CreateDC = Win32API.new("gdi32", "CreateDC", "pppl", "l")
  484.   CreateCompatibleBitmap = Win32API.new("gdi32", "CreateCompatibleBitmap", "lll", "l")
  485.   CreateCompatibleDC = Win32API.new("gdi32", "CreateCompatibleDC", "l", "l")
  486.   SelectObject = Win32API.new("gdi32", "SelectObject", "ll", "l")
  487.   BitBlt = Win32API.new("gdi32", "BitBlt", "lllllllll", "l")
  488.   GetBitmapBits = Win32API.new("gdi32", "GetBitmapBits", "llp", "l")
  489.   ScreenToClient = Win32API.new("user32", "ScreenToClient", "ip", "i")
  490.   SRCCOPY = 0xCC0020
  491.   RtlMoveMemory = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
  492.   HWnd = Win32API.new("user32", "GetActiveWindow", nil, 'l').call
  493.   DwCount = (640 * 480 * 4) * 2
  494.   @@lpBits = "\000" * DwCount
  495.   #---------------------------------------------------------------------------#
  496.   # snap_to_bitmap                                                            #
  497.   #---------------------------------------------------------------------------#
  498.   def snap_to_bitmap
  499.     width, height = 640,480
  500.     hb = Bitmap.new(width, height)
  501.     rgbs = self.bitmap_data
  502.     len = width * 4
  503.     for y in 0...height
  504.       break if 2*y >= height - 1
  505.       nth1 = y * len
  506.       nth2 = (height - 1 - y) * len
  507.       tStr = rgbs[nth1,len]
  508.       rgbs[nth1, len] = rgbs[nth2, len]
  509.       rgbs[nth2, len] = tStr
  510.     end
  511.     RtlMoveMemory.call(hb.address, rgbs, 640 * 480 * 4)
  512.     return hb
  513.   end
  514.   #---------------------------------------------------------------------------#
  515.   # bitmap_data                                                          #
  516.   #---------------------------------------------------------------------------#
  517.   def bitmap_data
  518.     hScrDC = CreateDC.call("DISPLAY", "", "", 0)
  519.     hMemDC = CreateCompatibleDC.call(hScrDC)
  520.     hBitmap = CreateCompatibleBitmap.call(hScrDC, 640, 480)
  521.     hOldBitmap = SelectObject.call(hMemDC, hBitmap)
  522.     BitBlt.call(hMemDC, xsrc, ysrc, 640*2, 480*2, hScrDC, 0, 0, SRCCOPY)
  523.     hBitmap = SelectObject.call(hMemDC, hOldBitmap)
  524.     GetBitmapBits.call(hBitmap, DwCount, @@lpBits)
  525.     return @@lpBits
  526.   end
  527.   #---------------------------------------------------------------------------#
  528.   # 用户窗口的位置                                                            #
  529.   #---------------------------------------------------------------------------#
  530.   def xsrc
  531.     return self.point[0]
  532.   end
  533.   #---------------------------------------------------------------------------#
  534.   # 用户窗口的位置                                                            #
  535.   #---------------------------------------------------------------------------#
  536.   def ysrc
  537.     return self.point[1]
  538.   end
  539.   #---------------------------------------------------------------------------#
  540.   # 那个点                                                                    #
  541.   #---------------------------------------------------------------------------#
  542.   def point
  543.     point = [0,0].pack("LL")
  544.     ScreenToClient.call(HWnd, point)
  545.     return point.unpack("LL")
  546.   end
  547. end

  548. #-----------------------------------------------------------------------------#
  549. # Font                                                                        #
  550. #-----------------------------------------------------------------------------#
  551. class Font
  552.   #---------------------------------------------------------------------------#
  553.   # marshal_dump                                                              #
  554.   #---------------------------------------------------------------------------#
  555.   def marshal_dump
  556.   end
  557.   #---------------------------------------------------------------------------#
  558.   # marshal_load                                                              #
  559.   #---------------------------------------------------------------------------#
  560.   def marshal_load(obj)
  561.   end
  562. end

  563. #-----------------------------------------------------------------------------#
  564. # Bitmap                                                                      #
  565. #-----------------------------------------------------------------------------#
  566. class Bitmap
  567.   RtlMoveMemory = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  568.   # 传送到内存的API函数
  569.   RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  570.   RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
  571.   #---------------------------------------------------------------------------#
  572.   # _dump                                                                     #
  573.   #---------------------------------------------------------------------------#
  574.   def _dump(limit)
  575.     data = "rgba" * width * height
  576.     RtlMoveMemory_pi.call(data, address, data.length)
  577.     [width, height, Zlib::Deflate.deflate(data)].pack("LLa*") # 压缩
  578.   end
  579.   #---------------------------------------------------------------------------#
  580.   # _load                                                                     #
  581.   #---------------------------------------------------------------------------#
  582.   def self._load(str)
  583.     w, h, zdata = str.unpack("LLa*")
  584.     b = self.new(w, h)
  585.     RtlMoveMemory_ip.call(b.address, Zlib::Inflate.inflate(zdata), w * h * 4)
  586.     return b
  587.   end
  588.   #---------------------------------------------------------------------------#
  589.   # address                                                                   #
  590.   #---------------------------------------------------------------------------#
  591.   def address
  592.     # [[[bitmap.object_id * 2 + 16] + 8] + 16] == 数据的开头
  593.     buffer, ad = "xxxx", object_id * 2 + 16
  594.     RtlMoveMemory.call(buffer, ad, 4)
  595.     ad = buffer.unpack("L")[0] + 8
  596.     RtlMoveMemory.call(buffer, ad, 4)
  597.     ad = buffer.unpack("L")[0] + 16
  598.     RtlMoveMemory.call(buffer, ad, 4)
  599.     return buffer.unpack("L")[0]
  600.   end
  601. end
复制代码

评分

参与人数 1星屑 +50 收起 理由
Anson + 50 认可答案

查看全部评分

回复

使用道具 举报

迷途知返,恍如隔世

梦石
0
星屑
488
在线时间
1355 小时
注册时间
2011-2-17
回帖
1173

开拓者

 楼主| 发表于 2015-9-6 16:55:13 | 显示全部楼层
RyanBern 发表于 2015-9-6 16:01
稍稍修改了一下脚本,由于没有制作好的图片无法完整测试。
去掉了窗口的光标(但是保留了滚屏的功能)。
ps ...


再次感谢!非常符合预期效果。
不过滚屏光标好像有点漂移,想让其居中应该调试何处?
QQ截图20150906165109.png

点评

宽度在我脚本246行调节(原来为120),x坐标是248行  发表于 2015-9-6 17:28
适当调整@command_window的x坐标和宽度(目测宽度应该为110~120之间),x坐标也要相应变化一些  发表于 2015-9-6 17:26

评分

参与人数 1星屑 +23 收起 理由
kuerlulu + 23 前辈诈尸啦

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部