查看: 2908|回复: 7

[已经解决] 有没有大神能抠出截图存档中的截图脚本啊

[复制链接]
梦石
0
星屑
50
在线时间
91 小时
注册时间
2012-3-3
回帖
56
发表于 2013-4-28 14:11:48 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 Mr丶木头 于 2013-5-19 13:25 编辑

这是成就脚本在地球村找到的,但是成就界面孤零零的只有文字和获得时间很难看,
小白我想改进这个界面,加入获得成就时的截图,发现找不到VA截图的脚本,
所以请大神把截图功能抠出来,
如果能整合一下这个荣誉系统和截图脚本再好不过了

这个是地球村荣誉系统的脚本
  1. #==============================================================================
  2. # ★ RGSS3_荣誉系统 Ver1.00
  3. #==============================================================================
  4. #尼玛啊!!!我讨厌日文啊
  5. #使用方法:
  6. #         gain_medal(0)
  7. #==============================================================================
  8. # □ 设定项目
  9. #==============================================================================
  10. module TMMEDAL
  11.   COMMAND_MEDAL = "成就"     # 菜单中的名字
  12.   
  13.   # 一个荣誉也没有时隐藏菜单(true隐藏;false不隐藏)
  14.   HIDE_COMMAND = false
  15.   
  16.   # 荣誉获得时的效果音
  17.   SE_GAIN_MEDAL = RPG::SE.new("Powerup", 90, 140)
  18.   
  19.   # 荣誉名称及简介的设置
  20.   #例如:MEDAL_DATA[0] = ["名字", 187(icon), "简介"]
  21.   MEDAL_DATA = {}
  22.   MEDAL_DATA[0] = ["名字?",       187, "简介?"]
  23.   MEDAL_DATA[1] = ["探索者",       **, "第一次找到隐藏地点"]
  24.   MEDAL_DATA[2] = ["      ",       190, ""]
  25. end

  26. #==============================================================================
  27. # ■ Game_Party
  28. #==============================================================================
  29. class Game_Party
  30.   #--------------------------------------------------------------------------
  31.   # ● 公開インスタンス変数
  32.   #--------------------------------------------------------------------------
  33.   attr_reader   :medals                   # 獲得済みメダル
  34.   attr_reader   :new_medals               # 新規獲得メダル
  35.   attr_accessor :medal_info_count         # メダル情報表示カウント
  36.   attr_accessor :medal_info_opacity       # メダル情報表示不透明度
  37.   #--------------------------------------------------------------------------
  38.   # ● オブジェクト初期化
  39.   #--------------------------------------------------------------------------
  40.   alias tmmedal_game_party_initialize initialize
  41.   def initialize
  42.     tmmedal_game_party_initialize
  43.     @medals = []
  44.     @new_medals = []
  45.     @medal_info_count = 0
  46.     @medal_info_opacity = 0
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # ○ メダルの獲得
  50.   #--------------------------------------------------------------------------
  51.   def gain_medal(medal_id)
  52.     return if @medals.any? {|medal| medal[0] == medal_id }
  53.     t = Time.now.strftime(" (%Y/%m/%d %H:%M)")
  54.     @medals.push([medal_id, t])
  55.     @new_medals.push([medal_id, t])
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ○ 獲得メダル情報の消去
  59.   #--------------------------------------------------------------------------
  60.   def delete_new_medal
  61.     @new_medals.shift
  62.   end
  63. end

  64. #==============================================================================
  65. # ■ Game_Interpreter
  66. #==============================================================================
  67. class Game_Interpreter
  68.   #--------------------------------------------------------------------------
  69.   # ○ メダルの獲得
  70.   #--------------------------------------------------------------------------
  71.   def gain_medal(medal_id)
  72.     $game_party.gain_medal(medal_id)
  73.   end
  74. end

  75. #==============================================================================
  76. # ■ Window_MenuCommand
  77. #==============================================================================
  78. class Window_MenuCommand
  79.   #--------------------------------------------------------------------------
  80.   # ● 独自コマンドの追加用
  81.   #--------------------------------------------------------------------------
  82.   alias tmmedal_window_menucommand_add_original_commands add_original_commands
  83.   def add_original_commands
  84.     tmmedal_window_menucommand_add_original_commands
  85.     unless TMMEDAL::HIDE_COMMAND && !medal_enabled
  86.       add_command(TMMEDAL::COMMAND_MEDAL, :medal, medal_enabled)
  87.     end
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # ○ メダルの有効状態を取得
  91.   #--------------------------------------------------------------------------
  92.   def medal_enabled
  93.     !$game_party.medals.empty?
  94.   end
  95. end

  96. #==============================================================================
  97. # □ Window_MedalInfo
  98. #==============================================================================
  99. class Window_MedalInfo < Window_Base
  100.   #--------------------------------------------------------------------------
  101.   # ● オブジェクト初期化
  102.   #--------------------------------------------------------------------------
  103.   def initialize
  104.     super(Graphics.width - window_width, 0, window_width, fitting_height(1))
  105.     self.opacity = 0
  106.     self.contents_opacity = $game_party.medal_info_opacity
  107.     refresh
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # ● ウィンドウ幅の取得
  111.   #--------------------------------------------------------------------------
  112.   def window_width
  113.     return 240
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # ● フレーム更新
  117.   #--------------------------------------------------------------------------
  118.   def update
  119.     super
  120.     if $game_party.medal_info_count > 0
  121.       self.contents_opacity += 16
  122.       $game_party.medal_info_count -= 1
  123.       $game_party.delete_new_medal if $game_party.medal_info_count == 0
  124.     else
  125.       self.contents_opacity -= 16
  126.       if self.contents_opacity == 0
  127.         open unless $game_party.new_medals.empty?
  128.       end
  129.     end
  130.     $game_party.medal_info_opacity = self.contents_opacity
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # ● ウィンドウを開く
  134.   #--------------------------------------------------------------------------
  135.   def open
  136.     refresh
  137.     TMMEDAL::SE_GAIN_MEDAL.play
  138.     $game_party.medal_info_count = 150
  139.     self.contents_opacity = 0
  140.     self
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ○ リフレッシュ
  144.   #--------------------------------------------------------------------------
  145.   def refresh
  146.     contents.clear
  147.     unless $game_party.new_medals.empty?
  148.       draw_background(contents.rect)
  149.       medal = TMMEDAL::MEDAL_DATA[$game_party.new_medals[0][0]]
  150.       rect = contents.rect.clone
  151.       draw_icon(medal[1], rect.x, rect.y)
  152.       rect.x += 24
  153.       rect.width -= 24
  154.       draw_text(rect, medal[0])
  155.     end
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ○ 背景の描画
  159.   #--------------------------------------------------------------------------
  160.   def draw_background(rect)
  161.     temp_rect = rect.clone
  162.     temp_rect.width /= 2
  163.     contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
  164.     temp_rect.x = temp_rect.width
  165.     contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # ○ 背景色 1 の取得
  169.   #--------------------------------------------------------------------------
  170.   def back_color1
  171.     Color.new(0, 0, 0, 192)
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # ○ 背景色 2 の取得
  175.   #--------------------------------------------------------------------------
  176.   def back_color2
  177.     Color.new(0, 0, 0, 0)
  178.   end
  179. end

  180. #==============================================================================
  181. # □ Window_Medal
  182. #==============================================================================
  183. class Window_Medal < Window_Selectable
  184.   #--------------------------------------------------------------------------
  185.   # ● オブジェクト初期化
  186.   #--------------------------------------------------------------------------
  187.   def initialize(x, y, width, height)
  188.     super
  189.     refresh
  190.     select(0)
  191.     activate
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ● 桁数の取得
  195.   #--------------------------------------------------------------------------
  196.   def col_max
  197.     return 1
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # ● 項目数の取得
  201.   #--------------------------------------------------------------------------
  202.   def item_max
  203.     @data ? @data.size : 1
  204.   end
  205.   #--------------------------------------------------------------------------
  206.   # ● アイテムの取得
  207.   #--------------------------------------------------------------------------
  208.   def item
  209.     @data && index >= 0 ? @data[index] : nil
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ● アイテムリストの作成
  213.   #--------------------------------------------------------------------------
  214.   def make_item_list
  215.     @data = $game_party.medals
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ● 項目の描画
  219.   #--------------------------------------------------------------------------
  220.   def draw_item(index)
  221.     item = @data[index]
  222.     medal = TMMEDAL::MEDAL_DATA[item[0]]
  223.     rect = item_rect(index)
  224.     draw_icon(medal[1], rect.x, rect.y)
  225.     rect.x += 24
  226.     rect.width -= 216
  227.     draw_text(rect, medal[0])
  228.     rect.x = contents.width - 192
  229.     rect.width = 192
  230.     draw_text(rect, item[1], 2)
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ● ヘルプテキスト更新
  234.   #--------------------------------------------------------------------------
  235.   def update_help
  236.     if item
  237.       medal = TMMEDAL::MEDAL_DATA[item[0]]
  238.       text = medal[2]
  239.       @help_window.set_text(text)
  240.     end
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ● リフレッシュ
  244.   #--------------------------------------------------------------------------
  245.   def refresh
  246.     make_item_list
  247.     create_contents
  248.     draw_all_items
  249.   end
  250. end

  251. #==============================================================================
  252. # ■ Scene_Map
  253. #==============================================================================
  254. class Scene_Map
  255.   #--------------------------------------------------------------------------
  256.   # ● 全ウィンドウの作成
  257.   #--------------------------------------------------------------------------
  258.   alias tmmedal_scene_map_create_all_windows create_all_windows
  259.   def create_all_windows
  260.     tmmedal_scene_map_create_all_windows
  261.     create_medal_window
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # ○ メダルウィンドウの作成
  265.   #--------------------------------------------------------------------------
  266.   def create_medal_window
  267.     @medal_window = Window_MedalInfo.new
  268.   end
  269. end

  270. #==============================================================================
  271. # ■ Scene_Menu
  272. #==============================================================================
  273. class Scene_Menu
  274.   #--------------------------------------------------------------------------
  275.   # ● コマンドウィンドウの作成
  276.   #--------------------------------------------------------------------------
  277.   alias tmmedal_scene_menu_create_command_window create_command_window
  278.   def create_command_window
  279.     tmmedal_scene_menu_create_command_window
  280.     @command_window.set_handler(:medal, method(:command_medal))
  281.   end
  282.   #--------------------------------------------------------------------------
  283.   # ○ コマンド[メダル]
  284.   #--------------------------------------------------------------------------
  285.   def command_medal
  286.     SceneManager.call(Scene_Medal)
  287.   end
  288. end

  289. #==============================================================================
  290. # □ Scene_Medal
  291. #==============================================================================
  292. class Scene_Medal < Scene_MenuBase
  293.   #--------------------------------------------------------------------------
  294.   # ● 開始処理
  295.   #--------------------------------------------------------------------------
  296.   def start
  297.     super
  298.     create_help_window
  299.     create_item_window
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ○ アイテムウィンドウの作成
  303.   #--------------------------------------------------------------------------
  304.   def create_item_window
  305.     wy = @help_window.height
  306.     wh = Graphics.height - wy
  307.     @item_window = Window_Medal.new(0, wy, Graphics.width, wh)
  308.     @item_window.viewport = @viewport
  309.     @item_window.help_window = @help_window
  310.     @item_window.set_handler(:cancel, method(:return_scene))
  311.   end
  312. end
复制代码


这个是压力君的截图存档脚本
  1. #==============================================================================
  2. # [PS0]截图存档
  3. #      Window_SaveFile_Plus
  4. #------------------------------------------------------------------------------
  5. #     一种带有截图的存档,同时可以自定义存档数量。
  6. #==============================================================================
  7. # [核心脚本]
  8. #    - 快速储存Bitmap的Marshal         By 柳之一
  9. #------------------------------------------------------------------------------
  10. # [更新记录]
  11. #    - 2012.02.16 By 各种压力的猫君
  12. #      * 修正地图边缘时截图不完整的错误
  13. #    - 2012.01.28 By 各种压力的猫君
  14. #      * 去掉效率较差的双线性缩放算法;
  15. #      * 新增存档管理功能(F5键,复制/移动/删除存档)
  16. #    - 2011.12.27 By 各种压力的猫君
  17. #      * 补上截图阴影;
  18. #      * 新增“不缩放”截图(推荐使用,尤其是大分辨率);
  19. #      * 修正选择不存在的存档时存档列表窗口卡死以及奇怪的SE;
  20. #      * 新增“存档中”提示窗口、覆盖存档提示、删除存档功能(Z键,对应键盘D)
  21. #    - 2011.12.26 By 各种压力的猫君
  22. #      * 功能齐全的测试版
  23. #    - 2011.12.16 By 各种压力的猫君
  24. #      * 移植至RGSS3,遵循PS0协议;
  25. #      * 丰富自定义选项,整合双线性插值算法精简版
  26. #    - 2008.05.26 By 沉影不器
  27. #      * 蓝本(VX新截图存档)
  28. #------------------------------------------------------------------------------
  29. # [使用方法]
  30. #    - 删除原Scene_File、Window_SaveFile 并将本脚本插入到原Scene_File位置。
  31. #    - 或者直接将本脚本插入到MAIN以上,并确保本脚本位于上述两个脚本以下。
  32. #==============================================================================
  33. $_PS0 = {} if $_PS0 == nil  
  34. $_PS0["Window_SaveFile_Plus"] = 20120216
  35. #==============================================================================
  36. # [PS0] 通用配置模块  
  37. #==============================================================================
  38. module PS0
  39.   module Window_SaveFile_Plus

  40.     # 最大存档数(范围正整数)
  41.     MAX_SAVE = 18

  42.     # 存档目录(默认值 "Saves/";根目录 "")
  43.     SAVE_DIR = "Saves/"   

  44.     # 无存档时显示的文字
  45.     NO_DATA  = "无存档"

  46.     # 保存时显示的信息
  47.     SAVE_NOW = "存档中..."

  48.     # 复制存档时的帮助文字
  49.     HELP_COPY = "要复制到哪个位置?"

  50.     # 移动存档时的帮助文字
  51.     HELP_MOVE = "要移动到哪个位置?"

  52.     # 是否显示存档中窗口(true:显示;false:不显示)
  53.     # - 分辨率较大时建议显示
  54.     SHOW_SAVE_NOW = false

  55.     # 截图缩放使用的插值算法
  56.     # - "NN" 最邻近(速度最快,质量最差,RM默认算法)
  57.     # - "NZ" 不缩放(速度快,质量好,以主角为中心切边,非全屏)
  58.     Zoom_Type = "NZ"

  59.     # 双线性插值能获得更好的截图缩放质量,但所需时间较最邻近插值更长。
  60.     # 缩略图尺寸(范围整数,单位像素)
  61.     # - VA默认分辨率(544×416)推荐使用340×260
  62.     # - VA最大分辨率(640×480)推荐使用425×325
  63.     # - 本脚本兼容分辨率解放,窗口大小将自动计算。
  64.     #   请自行计算截图分辨率,注意要确保宽高比一致,
  65.     #   若使用“不缩放”模式则可以不保持一致。
  66.     Thumbnail_Width  = 340  # 宽度
  67.     Thumbnail_Height = 260  # 高度

  68.     # 缩略图位置微调(范围整数,单位像素)
  69.     Thumbnail_ox = -2    # 横向
  70.     Thumbnail_oy = -2-32 # 纵向

  71.     # 各窗口切换时的渐变帧数
  72.     TRANS_DURATION = 5

  73.   end
  74. end
  75. #==============================================================================
  76. # [核心脚本] 快速储存Bitmap的Marshal By 柳之一
  77. #==============================================================================
  78. class Font
  79.   def marshal_dump
  80.   end
  81.   def marshal_load(obj)
  82.   end
  83. end
  84. class Bitmap
  85.   RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  86.   RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
  87.   def _dump(limit)
  88.     data = "rgba" * width * height
  89.     RtlMoveMemory_pi.call(data, address, data.length)
  90.     [width, height, Zlib::Deflate.deflate(data)].pack("LLa*")
  91.   end
  92.   def self._load(str)
  93.     w, h, zdata = str.unpack("LLa*")
  94.     b = self.new(w, h)
  95.     RtlMoveMemory_ip.call(b.address, Zlib::Inflate.inflate(zdata), w * h * 4)
  96.     return b
  97.   end
  98.   def address
  99.     buffer, ad = "rgba", object_id * 2 + 16
  100.     RtlMoveMemory_pi.call(buffer, ad, 4)
  101.     ad = buffer.unpack("L")[0] + 8
  102.     RtlMoveMemory_pi.call(buffer, ad, 4)
  103.     ad = buffer.unpack("L")[0] + 16
  104.     RtlMoveMemory_pi.call(buffer, ad, 4)
  105.     return buffer.unpack("L")[0]
  106.   end
  107. end
  108. #==============================================================================
  109. # ■ Game_Temp
  110. #==============================================================================
  111. class Game_Temp
  112.   attr_accessor :save_bitmap
  113.   attr_accessor :save_snapshoot
  114.   alias new_initialize initialize
  115.   def initialize
  116.     new_initialize
  117.     @save_bitmap = Bitmap.new(1, 1)
  118.     @save_snapshoot = Bitmap.new(1, 1)
  119.   end
  120. end
  121. #==============================================================================
  122. # ■ SceneManager
  123. #==============================================================================
  124. module SceneManager
  125.   def self.snapshot_for_save
  126.     $game_temp.save_bitmap = Graphics.snap_to_bitmap
  127.     unless FileTest.exist?(PS0::Window_SaveFile_Plus::SAVE_DIR)
  128.       Dir.mkdir(PS0::Window_SaveFile_Plus::SAVE_DIR)
  129.     end
  130.   end
  131. end
  132. #==============================================================================
  133. # ■ Scene_Map
  134. #==============================================================================
  135. class Scene_Map < Scene_Base
  136.   alias save_terminate terminate
  137.   def terminate
  138.     SceneManager.snapshot_for_save
  139.     save_terminate
  140.   end
  141. end
  142. #==============================================================================
  143. # ■ DataManager
  144. #==============================================================================
  145. module DataManager
  146.   def self.save_file_exists?
  147.     !Dir.glob(PS0::Window_SaveFile_Plus::SAVE_DIR + 'Save*.rvdata2').empty?
  148.   end
  149.   def self.make_filename(index)
  150.     sprintf(PS0::Window_SaveFile_Plus::SAVE_DIR + "Save%02d.rvdata2", index + 1)
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● セーブヘッダの作成
  154.   #--------------------------------------------------------------------------
  155.   def self.make_save_header
  156.     d_rect = Rect.new(0, 0, PS0::Window_SaveFile_Plus::Thumbnail_Width,
  157.                             PS0::Window_SaveFile_Plus::Thumbnail_Height)
  158.     case PS0::Window_SaveFile_Plus::Zoom_Type
  159.     when "NN"
  160.       s_rect = $game_temp.save_bitmap.rect
  161.       $game_temp.save_snapshoot = Bitmap.new(d_rect.width, d_rect.height)
  162.       $game_temp.save_snapshoot.stretch_blt(d_rect, $game_temp.save_bitmap, s_rect)
  163.     when "NZ"
  164.       x = [$game_player.screen_x - d_rect.width/2, 0].max
  165.       x = [x, Graphics.width - d_rect.width].min
  166.       y = [$game_player.screen_y - d_rect.height/2, 0].max
  167.       y = [y, Graphics.height - d_rect.height].min
  168.       s_rect = Rect.new(x, y, d_rect.width, d_rect.height)
  169.       $game_temp.save_snapshoot = Bitmap.new(d_rect.width, d_rect.height)
  170.       $game_temp.save_snapshoot.blt(0, 0, $game_temp.save_bitmap, s_rect)
  171.     end
  172.     header = {}
  173.     header[:characters] = $game_party.characters_for_savefile
  174.     header[:playtime_s] = $game_system.playtime_s
  175.     header[:snapshoot]  = $game_temp.save_snapshoot
  176.     header
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● セーブの実行
  180.   #--------------------------------------------------------------------------
  181.   def self.save_game(index)
  182.     saving_window = Window_Saving.new
  183.     Graphics.update
  184.     begin
  185.       save_game_without_rescue(index)
  186.     rescue
  187.        delete_save_file(index)
  188.        false
  189.     end
  190.     saving_window.dispose
  191.     return true
  192.   end
  193. end
  194. #==============================================================================
  195. # ■ Window_Yes_Or_No
  196. #------------------------------------------------------------------------------
  197. #  提供“是”、“否”两个选项的窗口(替换、删除存档用)
  198. #==============================================================================
  199. class Window_Yes_Or_No < Window_HorzCommand
  200.   #--------------------------------------------------------------------------
  201.   # ● オブジェクト初期化
  202.   #--------------------------------------------------------------------------
  203.   def initialize(yes, no)
  204.     [url=home.php?mod=space&uid=40913]@yes[/url] = yes
  205.     @no = no
  206.     super(130, 0)
  207.     self.visible = false
  208.     self.active = false
  209.     @index = 0
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ● 桁数の取得
  213.   #--------------------------------------------------------------------------
  214.   def col_max
  215.     return 2
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ● コマンドリストの作成
  219.   #--------------------------------------------------------------------------
  220.   def make_command_list
  221.     add_command(@yes,   :yes)
  222.     add_command(@no,    :cancel)
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● 決定ボタンが押されたときの処理
  226.   #--------------------------------------------------------------------------
  227.   def process_ok
  228.     Input.update
  229.     call_ok_handler
  230.   end
  231.   #--------------------------------------------------------------------------
  232.   # ● 按下取消键时的处理
  233.   #--------------------------------------------------------------------------
  234.   def process_cancel
  235.     Input.update
  236.     call_cancel_handler
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● 启用窗口
  240.   #--------------------------------------------------------------------------
  241.   def activate
  242.     temp = self.y + self.height - Graphics.height
  243.     if temp > 0
  244.       self.y -= (temp + 12)
  245.     end
  246.     self.active = true
  247.     self
  248.   end
  249. end
  250. #==============================================================================
  251. # ■ Window_Saving
  252. #------------------------------------------------------------------------------
  253. #  显示保存信息的窗口
  254. #==============================================================================
  255. class Window_Saving < Window_Base
  256.   #--------------------------------------------------------------------------
  257.   # ● オブジェクト初期化
  258.   #--------------------------------------------------------------------------
  259.   def initialize
  260.     w = PS0::Window_SaveFile_Plus::SAVE_NOW.length * 16 + 32
  261.     x = (Graphics.width - w)/2
  262.     y = (Graphics.height - fitting_height(1))/2
  263.     super(x, y, w, fitting_height(1))
  264.     self.visible = PS0::Window_SaveFile_Plus::SHOW_SAVE_NOW
  265.     draw_text_ex(4, 0, PS0::Window_SaveFile_Plus::SAVE_NOW)
  266.   end
  267. end
  268. #==============================================================================
  269. # ■ Window_SaveManagerCommand
  270. #------------------------------------------------------------------------------
  271. #  存档管理窗口
  272. #==============================================================================
  273. class Window_SaveManagerCommand < Window_Command
  274.   #--------------------------------------------------------------------------
  275.   # ● 初始化对象
  276.   #--------------------------------------------------------------------------
  277.   def initialize(*args)
  278.     @copy, @move, @delete, [url=home.php?mod=space&uid=9053]@cancel[/url] = args[0..3]
  279.     super(130, 0)
  280.     self.visible = false
  281.     self.active = false
  282.     @index = 0
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # ● 获取窗口的宽度
  286.   #--------------------------------------------------------------------------
  287.   def window_width
  288.     return 100
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # ● 获取项目数
  292.   #--------------------------------------------------------------------------
  293.   def item_max
  294.     return 4
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ● 生成指令列表
  298.   #--------------------------------------------------------------------------
  299.   def make_command_list
  300.     add_command(@copy,   :copy  )
  301.     add_command(@move,   :move  )
  302.     add_command(@delete, :delete)
  303.     add_command(@cancel, :cancel)
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ● 按下确定键时的处理
  307.   #--------------------------------------------------------------------------
  308.   def process_ok
  309.     Input.update
  310.     call_ok_handler
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● 启用窗口
  314.   #--------------------------------------------------------------------------
  315.   def activate
  316.     temp = self.y + self.height - Graphics.height
  317.     if temp > 0
  318.       self.y -= (temp + 12)
  319.     end
  320.     self.active = true
  321.     self
  322.   end
  323. end
  324. #==============================================================================
  325. # ■ Window_FileCommand
  326. #------------------------------------------------------------------------------
  327. #  截图存档左侧的选择窗口。
  328. #==============================================================================
  329. class Window_FileCommand < Window_Command
  330.   #--------------------------------------------------------------------------
  331.   # ● オブジェクト初期化
  332.   #--------------------------------------------------------------------------
  333.   def initialize
  334.     super(0, 0)
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ● ウィンドウ幅の取得
  338.   #--------------------------------------------------------------------------
  339.   def window_height
  340.     return Graphics.height-fitting_height(1)
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● 表示行数の取得
  344.   #--------------------------------------------------------------------------
  345.   def visible_line_number
  346.     item_max
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   # ● コマンドリストの作成
  350.   #--------------------------------------------------------------------------
  351.   def make_command_list
  352.     add_main_commands
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   # ● 主要コマンドをリストに追加
  356.   #--------------------------------------------------------------------------
  357.   def add_main_commands
  358.     for i in 1..PS0::Window_SaveFile_Plus::MAX_SAVE
  359.       if i < 10
  360.         text = Vocab::File + " 0" + i.to_s
  361.       else
  362.         text = Vocab::File + " " + i.to_s
  363.       end
  364.       add_command(text, :file)
  365.     end
  366.   end
  367.   #--------------------------------------------------------------------------
  368.   # ● 決定ボタンが押されたときの処理
  369.   #--------------------------------------------------------------------------
  370.   def process_ok
  371.   end
  372. end
  373. #==============================================================================
  374. # ■ Window_SaveFile
  375. #------------------------------------------------------------------------------
  376. #  セーブ画面およびロード画面で表示する、セーブファイルのウィンドウです。
  377. #==============================================================================
  378. class Window_SaveFile < Window_Base
  379.   #--------------------------------------------------------------------------
  380.   # ● オブジェクト初期化
  381.   #     index : セーブファイルのインデックス
  382.   #--------------------------------------------------------------------------
  383.   def initialize(index)
  384.     super(160, 0, Graphics.width-160, Graphics.height-fitting_height(1))
  385.     @file_index = index
  386.     @selected = true
  387.     refresh
  388.   end
  389.   #--------------------------------------------------------------------------
  390.   # ● リフレッシュ
  391.   #--------------------------------------------------------------------------
  392.   def refresh
  393.     contents.clear
  394.     change_color(normal_color)
  395.     w = (self.width-PS0::Window_SaveFile_Plus::Thumbnail_Width-16)/2
  396.     h = (self.height-PS0::Window_SaveFile_Plus::Thumbnail_Height-16)/2
  397.     width  = w + PS0::Window_SaveFile_Plus::Thumbnail_ox
  398.     height = h + PS0::Window_SaveFile_Plus::Thumbnail_oy
  399.     draw_shadow(width+5, height+5)
  400.     draw_text((self.width-32-PS0::Window_SaveFile_Plus::NO_DATA.length*16)/2,
  401.               self.height/2-32, PS0::Window_SaveFile_Plus::NO_DATA.length*32,
  402.               line_height, PS0::Window_SaveFile_Plus::NO_DATA)
  403.     draw_party_characters(32, Graphics.height-fitting_height(1)-32)
  404.     draw_playtime(-10, contents.height - line_height-10, contents.width - 4, 2)
  405.     draw_snapshoot(width, height)
  406.   end
  407.   #--------------------------------------------------------------------------
  408.   # ● パーティキャラの描画
  409.   #--------------------------------------------------------------------------
  410.   def draw_party_characters(x, y)
  411.     header = DataManager.load_header(@file_index)
  412.     return unless header
  413.     header[:characters].each_with_index do |data, i|
  414.       draw_character(data[0], data[1], x + i * 48, y)
  415.     end
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # ● プレイ時間の描画
  419.   #--------------------------------------------------------------------------
  420.   def draw_playtime(x, y, width, align)
  421.     header = DataManager.load_header(@file_index)
  422.     return unless header
  423.     draw_text(x, y, width, line_height, header[:playtime_s], 2)
  424.   end
  425.   #--------------------------------------------------------------------------
  426.   # ● 绘制截图
  427.   #--------------------------------------------------------------------------
  428.   def draw_snapshoot(x, y)
  429.     header = DataManager.load_header(@file_index)
  430.     return unless header
  431.     bitmap = header[:snapshoot]
  432.     contents.blt(x, y, bitmap, bitmap.rect)
  433.     bitmap.dispose
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   # ● 绘制阴影
  437.   #--------------------------------------------------------------------------
  438.   def draw_shadow(x, y)
  439.     header = DataManager.load_header(@file_index)
  440.     return unless header
  441.     contents.fill_rect(x, y, PS0::Window_SaveFile_Plus::Thumbnail_Width,
  442.                              PS0::Window_SaveFile_Plus::Thumbnail_Height, Color.new(0, 0, 0))
  443.     contents.blur
  444.   end
  445. end
  446. #==============================================================================
  447. # ■ Scene_File
  448. #------------------------------------------------------------------------------
  449. #  セーブ画面とロード画面の共通処理を行うクラスです。
  450. #==============================================================================
  451. class Scene_File < Scene_MenuBase
  452.   #--------------------------------------------------------------------------
  453.   # ● 開始処理
  454.   #--------------------------------------------------------------------------
  455.   def start
  456.     super
  457.     create_help_window
  458.     create_savefile_viewport
  459.     create_command_window
  460.     create_savefile_window
  461.     create_manager_window
  462.     create_replace_window
  463.     create_delete_window
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # ● 終了処理
  467.   #--------------------------------------------------------------------------
  468.   def terminate
  469.     super
  470.     @savefile_viewport.dispose
  471.     @savefile_window.dispose
  472.     @command_window.dispose
  473.     @window_manager.dispose
  474.     @window_replace.dispose
  475.     @window_delete.dispose
  476.   end
  477.   #--------------------------------------------------------------------------
  478.   # ● フレーム更新
  479.   #--------------------------------------------------------------------------
  480.   def update
  481.     super
  482.     update_savefile_selection
  483.   end
  484.   #--------------------------------------------------------------------------
  485.   # ● 创建替换窗口
  486.   #--------------------------------------------------------------------------
  487.   def create_replace_window
  488.     @window_replace = Window_Yes_Or_No.new("替换", "取消")
  489.     @window_replace.set_handler(:yes,    method(:do_replace))
  490.     @window_replace.set_handler(:cancel, method(:do_cancel))
  491.   end
  492.   #--------------------------------------------------------------------------
  493.   # ● 创建删除窗口
  494.   #--------------------------------------------------------------------------
  495.   def create_delete_window
  496.     @window_delete  = Window_Yes_Or_No.new("删除", "取消")
  497.     @window_delete.set_handler(:yes,    method(:do_delete))
  498.     @window_delete.set_handler(:cancel, method(:do_return_manager))
  499.     @window_delete.x += 40
  500.   end
  501.   #--------------------------------------------------------------------------
  502.   # ● 创建管理窗口
  503.   #--------------------------------------------------------------------------
  504.   def create_manager_window
  505.     @window_manager = Window_SaveManagerCommand.new("复制", "移动", "删除", "取消")
  506.     @window_manager.set_handler(:copy  , method(:on_copy?))
  507.     @window_manager.set_handler(:move  , method(:on_move?))
  508.     @window_manager.set_handler(:delete, method(:on_delete?))
  509.     @window_manager.set_handler(:cancel, method(:do_cancel))
  510.   end
  511.   #--------------------------------------------------------------------------
  512.   # ● ヘルプウィンドウの作成
  513.   #--------------------------------------------------------------------------
  514.   def create_help_window
  515.     @help_window = Window_Help.new(1)
  516.     @help_window.set_text(help_window_text)
  517.   end
  518.   #--------------------------------------------------------------------------
  519.   # ● ヘルプウィンドウのテキストを取得
  520.   #--------------------------------------------------------------------------
  521.   def help_window_text
  522.     return ""
  523.   end
  524.   #--------------------------------------------------------------------------
  525.   # ● セーブファイルビューポートの作成
  526.   #--------------------------------------------------------------------------
  527.   def create_savefile_viewport
  528.     @savefile_viewport = Viewport.new
  529.     @savefile_viewport.rect.y = @help_window.height
  530.     @savefile_viewport.rect.height -= @help_window.height
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # ● セーブファイルウィンドウの作成
  534.   #--------------------------------------------------------------------------
  535.   def create_savefile_window
  536.     @savefile_window = Window_SaveFile.new(@index)
  537.     @savefile_window.viewport = @savefile_viewport
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # ● 生成存档列表窗口
  541.   #--------------------------------------------------------------------------
  542.   def create_command_window
  543.     @command_window = Window_FileCommand.new
  544.     @command_window.index = first_savefile_index
  545.     @index = @command_window.index
  546.     @command_window.viewport = @savefile_viewport
  547.     @command_window.set_handler(:file,      method(:on_savefile_ok))
  548.   end
  549.   #--------------------------------------------------------------------------
  550.   # ● セーブファイル選択の更新
  551.   #--------------------------------------------------------------------------
  552.   def update_savefile_selection
  553.     if @source_index != nil
  554.       if Input.trigger?(:C)
  555.         if @index == @source_index
  556.           Sound.play_buzzer
  557.         elsif FileTest.exist?(DataManager.make_filename(@index))
  558.           Graphics.freeze
  559.           @command_window.deactivate
  560.           @window_replace.y = 72 + @index * 24
  561.           @window_replace.activate
  562.           @window_replace.visible = true
  563.           @window_replace.refresh
  564.           Sound.play_ok
  565.           Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  566.         else
  567.           return on_copy_ok
  568.         end
  569.       elsif Input.trigger?(:B)
  570.         return do_return_manager
  571.       end
  572.     else
  573.       if Input.trigger?(:C)
  574.         if self.is_a?(Scene_Save) and FileTest.exist?(DataManager.make_filename(@index))
  575.           Graphics.freeze
  576.           @command_window.deactivate
  577.           @window_replace.y = 72 + @index * 24
  578.           @window_replace.activate
  579.           @window_replace.visible = true
  580.           @window_replace.refresh
  581.           Sound.play_ok
  582.           Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  583.         else
  584.           return on_savefile_ok
  585.         end
  586.       elsif Input.trigger?(:B)
  587.         return on_savefile_cancel
  588.       elsif Input.trigger?(:F5)
  589.         unless @window_manager.active == true or
  590.                @window_delete.active == true or
  591.                @window_replace.active == true
  592.           return on_manager?
  593.         end
  594.       end
  595.     end
  596.     @need_refresh = true if @index != @command_window.index
  597.     if @need_refresh
  598.       Graphics.freeze
  599.       @index = @command_window.index
  600.       @savefile_window.dispose
  601.       create_savefile_window
  602.       @need_refresh = false
  603.       Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  604.     end
  605.   end
  606.   #--------------------------------------------------------------------------
  607.   # ● セーブファイル[決定]
  608.   #--------------------------------------------------------------------------
  609.   def on_savefile_ok
  610.   end
  611.   #--------------------------------------------------------------------------
  612.   # ● セーブファイル[キャンセル]
  613.   #--------------------------------------------------------------------------
  614.   def on_savefile_cancel
  615.     Sound.play_cancel
  616.     return_scene
  617.   end
  618.   #--------------------------------------------------------------------------
  619.   # ● セーブファイル[決定]
  620.   #--------------------------------------------------------------------------
  621.   def on_copy_ok
  622.     Graphics.freeze
  623.     source_name = DataManager.make_filename(@source_index)
  624.     new_name    = DataManager.make_filename(@index)
  625.     case @source_type
  626.     when "copy"
  627.       # 复制存档文件(API)
  628.       Win32API.new('kernel32',"CopyFileA",'ppl','').call(source_name,new_name,0)
  629.     when "move"
  630.       # 重命名存档
  631.       File.rename(source_name, new_name)
  632.     end
  633.     # 返回
  634.     @help_window.set_text(help_window_text)
  635.     @source_index = nil
  636.     do_return_savelist
  637.   end
  638.   #--------------------------------------------------------------------------
  639.   # ● セーブファイル[复制]
  640.   #--------------------------------------------------------------------------
  641.   def on_copy?
  642.     Graphics.freeze
  643.     @help_window.set_text(PS0::Window_SaveFile_Plus::HELP_COPY)
  644.     @source_index = @index
  645.     @source_type = "copy"
  646.     do_return_savelist
  647.   end
  648.   #--------------------------------------------------------------------------
  649.   # ● セーブファイル[移动]
  650.   #--------------------------------------------------------------------------
  651.   def on_move?
  652.     Graphics.freeze
  653.     @help_window.set_text(PS0::Window_SaveFile_Plus::HELP_MOVE)
  654.     @source_index = @index
  655.     @source_type = "move"
  656.     do_return_savelist
  657.   end
  658.   #--------------------------------------------------------------------------
  659.   # ● セーブファイル[管理]
  660.   #--------------------------------------------------------------------------
  661.   def on_manager?
  662.     if FileTest.exist?(DataManager.make_filename(@index))
  663.       Graphics.freeze
  664.       @command_window.deactivate
  665.       @window_manager.y = 72 + @index * 24
  666.       @window_manager.activate
  667.       @window_manager.visible = true
  668.       @window_manager.refresh
  669.       Sound.play_ok
  670.       Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  671.     else
  672.       Sound.play_buzzer
  673.     end
  674.   end
  675.   #--------------------------------------------------------------------------
  676.   # ● セーブファイル[删除]
  677.   #--------------------------------------------------------------------------
  678.   def on_delete?
  679.     Graphics.freeze
  680.     @window_manager.deactivate
  681.     @command_window.deactivate
  682.     @window_delete.y = 72 + 72 + @index * 24
  683.     @window_delete.activate
  684.     @window_delete.visible = true
  685.     @window_delete.refresh
  686.     Sound.play_ok
  687.     Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  688.   end
  689.   #--------------------------------------------------------------------------
  690.   # ● 删除
  691.   #--------------------------------------------------------------------------
  692.   def do_delete
  693.     Graphics.freeze
  694.     File.delete(DataManager.make_filename(@index))
  695.     @window_delete.index  = 0
  696.     @window_manager.index = 0
  697.     @window_delete.visible  = false
  698.     @window_manager.visible = false
  699.     @window_delete.deactivate
  700.     @window_manager.deactivate
  701.     @command_window.activate
  702.     @need_refresh = true
  703.     Sound.play_save
  704.     if DataManager.save_file_exists?
  705.       Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  706.     else
  707.       return_scene
  708.     end
  709.   end
  710.   #--------------------------------------------------------------------------
  711.   # ● 替换
  712.   #--------------------------------------------------------------------------
  713.   def do_replace
  714.     Graphics.freeze
  715.     if @source_index != nil
  716.       return on_copy_ok
  717.     else
  718.       return on_savefile_ok
  719.     end
  720.     @window_replace.visible = false
  721.     @window_replace.deactivate
  722.     @need_refresh = true
  723.   end
  724.   #--------------------------------------------------------------------------
  725.   # ● 取消
  726.   #--------------------------------------------------------------------------
  727.   def do_cancel
  728.     Graphics.freeze
  729.     Sound.play_cancel
  730.     @window_delete.index  = 0
  731.     @window_replace.index = 0
  732.     @window_manager.index = 0
  733.     @window_delete.visible  = false
  734.     @window_replace.visible = false
  735.     @window_manager.visible = false
  736.     @window_delete.deactivate
  737.     @window_replace.deactivate
  738.     @window_manager.deactivate
  739.     @command_window.activate
  740.     Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  741.   end
  742.   #--------------------------------------------------------------------------
  743.   # ● 返回管理菜单
  744.   #--------------------------------------------------------------------------
  745.   def do_return_manager
  746.     Graphics.freeze
  747.     @help_window.set_text(help_window_text)
  748.     @command_window.index = @source_index unless @source_index == nil
  749.     @source_index = nil
  750.     @source_type = nil
  751.     @command_window.deactivate
  752.     @window_delete.index  = 0
  753.     @window_replace.index = 0
  754.     @window_delete.visible  = false
  755.     @window_replace.visible = false
  756.     @window_delete.deactivate
  757.     @window_replace.deactivate
  758.     @window_manager.y = 72 + @index * 24
  759.     @window_manager.activate
  760.     @window_manager.visible = true
  761.     @window_manager.refresh
  762.     Sound.play_cancel
  763.     Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  764.   end
  765.   #--------------------------------------------------------------------------
  766.   # ● 返回文件列表(复制、移动 用)
  767.   #--------------------------------------------------------------------------
  768.   def do_return_savelist
  769.     @window_manager.visible = false
  770.     @window_manager.deactivate
  771.     @command_window.activate
  772.     @need_refresh = true
  773.     Sound.play_ok
  774.   end
  775. end
  776. #==============================================================================
  777. # [PS0] End of Script
  778. #==============================================================================
复制代码
梦石
0
星屑
70
在线时间
1083 小时
注册时间
2013-3-29
回帖
2158
发表于 2013-4-28 15:08:16 | 显示全部楼层
是截图存档的代码把:
  1. #==============================================================================
  2. # [PS0]截图存档
  3. #      Window_SaveFile_Plus
  4. #------------------------------------------------------------------------------
  5. #     一种带有截图的存档,同时可以自定义存档数量。
  6. #==============================================================================
  7. # [核心脚本]
  8. #    - 快速储存Bitmap的Marshal         By 柳之一
  9. #------------------------------------------------------------------------------
  10. # [更新记录]
  11. #    - 2012.02.16 By 各种压力的猫君
  12. #      * 修正地图边缘时截图不完整的错误
  13. #    - 2012.01.28 By 各种压力的猫君
  14. #      * 去掉效率较差的双线性缩放算法;
  15. #      * 新增存档管理功能(F5键,复制/移动/删除存档)
  16. #    - 2011.12.27 By 各种压力的猫君
  17. #      * 补上截图阴影;
  18. #      * 新增“不缩放”截图(推荐使用,尤其是大分辨率);
  19. #      * 修正选择不存在的存档时存档列表窗口卡死以及奇怪的SE;
  20. #      * 新增“存档中”提示窗口、覆盖存档提示、删除存档功能(Z键,对应键盘D)
  21. #    - 2011.12.26 By 各种压力的猫君
  22. #      * 功能齐全的测试版
  23. #    - 2011.12.16 By 各种压力的猫君
  24. #      * 移植至RGSS3,遵循PS0协议;
  25. #      * 丰富自定义选项,整合双线性插值算法精简版
  26. #    - 2008.05.26 By 沉影不器
  27. #      * 蓝本(VX新截图存档)
  28. #------------------------------------------------------------------------------
  29. # [使用方法]
  30. #    - 删除原Scene_File、Window_SaveFile 并将本脚本插入到原Scene_File位置。
  31. #    - 或者直接将本脚本插入到MAIN以上,并确保本脚本位于上述两个脚本以下。
  32. #==============================================================================
  33. $_PS0 = {} if $_PS0 == nil  
  34. $_PS0["Window_SaveFile_Plus"] = 20120216
  35. #==============================================================================
  36. # [PS0] 通用配置模块  
  37. #==============================================================================
  38. module PS0
  39.   module Window_SaveFile_Plus

  40.     # 最大存档数(范围正整数)
  41.     MAX_SAVE = 18

  42.     # 存档目录(默认值 "Saves/";根目录 "")
  43.     SAVE_DIR = "Saves/"   

  44.     # 无存档时显示的文字
  45.     NO_DATA  = "无存档"

  46.     # 保存时显示的信息
  47.     SAVE_NOW = "存档中..."

  48.     # 复制存档时的帮助文字
  49.     HELP_COPY = "要复制到哪个位置?"

  50.     # 移动存档时的帮助文字
  51.     HELP_MOVE = "要移动到哪个位置?"

  52.     # 是否显示存档中窗口(true:显示;false:不显示)
  53.     # - 分辨率较大时建议显示
  54.     SHOW_SAVE_NOW = false

  55.     # 截图缩放使用的插值算法
  56.     # - "NN" 最邻近(速度最快,质量最差,RM默认算法)
  57.     # - "NZ" 不缩放(速度快,质量好,以主角为中心切边,非全屏)
  58.     Zoom_Type = "NZ"

  59.     # 双线性插值能获得更好的截图缩放质量,但所需时间较最邻近插值更长。
  60.     # 缩略图尺寸(范围整数,单位像素)
  61.     # - VA默认分辨率(544×416)推荐使用340×260
  62.     # - VA最大分辨率(640×480)推荐使用425×325
  63.     # - 本脚本兼容分辨率解放,窗口大小将自动计算。
  64.     #   请自行计算截图分辨率,注意要确保宽高比一致,
  65.     #   若使用“不缩放”模式则可以不保持一致。
  66.     Thumbnail_Width  = 340  # 宽度
  67.     Thumbnail_Height = 260  # 高度

  68.     # 缩略图位置微调(范围整数,单位像素)
  69.     Thumbnail_ox = -2    # 横向
  70.     Thumbnail_oy = -2-32 # 纵向

  71.     # 各窗口切换时的渐变帧数
  72.     TRANS_DURATION = 5

  73.   end
  74. end
  75. #==============================================================================
  76. # [核心脚本] 快速储存Bitmap的Marshal By 柳之一
  77. #==============================================================================
  78. class Font
  79.   def marshal_dump
  80.   end
  81.   def marshal_load(obj)
  82.   end
  83. end
  84. class Bitmap
  85.   RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  86.   RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
  87.   def _dump(limit)
  88.     data = "rgba" * width * height
  89.     RtlMoveMemory_pi.call(data, address, data.length)
  90.     [width, height, Zlib::Deflate.deflate(data)].pack("LLa*")
  91.   end
  92.   def self._load(str)
  93.     w, h, zdata = str.unpack("LLa*")
  94.     b = self.new(w, h)
  95.     RtlMoveMemory_ip.call(b.address, Zlib::Inflate.inflate(zdata), w * h * 4)
  96.     return b
  97.   end
  98.   def address
  99.     buffer, ad = "rgba", object_id * 2 + 16
  100.     RtlMoveMemory_pi.call(buffer, ad, 4)
  101.     ad = buffer.unpack("L")[0] + 8
  102.     RtlMoveMemory_pi.call(buffer, ad, 4)
  103.     ad = buffer.unpack("L")[0] + 16
  104.     RtlMoveMemory_pi.call(buffer, ad, 4)
  105.     return buffer.unpack("L")[0]
  106.   end
  107. end
  108. #==============================================================================
  109. # ■ Game_Temp
  110. #==============================================================================
  111. class Game_Temp
  112.   attr_accessor :save_bitmap
  113.   attr_accessor :save_snapshoot
  114.   alias new_initialize initialize
  115.   def initialize
  116.     new_initialize
  117.     @save_bitmap = Bitmap.new(1, 1)
  118.     @save_snapshoot = Bitmap.new(1, 1)
  119.   end
  120. end
  121. #==============================================================================
  122. # ■ SceneManager
  123. #==============================================================================
  124. module SceneManager
  125.   def self.snapshot_for_save
  126.     $game_temp.save_bitmap = Graphics.snap_to_bitmap
  127.     unless FileTest.exist?(PS0::Window_SaveFile_Plus::SAVE_DIR)
  128.       Dir.mkdir(PS0::Window_SaveFile_Plus::SAVE_DIR)
  129.     end
  130.   end
  131. end
  132. #==============================================================================
  133. # ■ Scene_Map
  134. #==============================================================================
  135. class Scene_Map < Scene_Base
  136.   alias save_terminate terminate
  137.   def terminate
  138.     SceneManager.snapshot_for_save
  139.     save_terminate
  140.   end
  141. end
  142. #==============================================================================
  143. # ■ DataManager
  144. #==============================================================================
  145. module DataManager
  146.   def self.save_file_exists?
  147.     !Dir.glob(PS0::Window_SaveFile_Plus::SAVE_DIR + 'Save*.rvdata2').empty?
  148.   end
  149.   def self.make_filename(index)
  150.     sprintf(PS0::Window_SaveFile_Plus::SAVE_DIR + "Save%02d.rvdata2", index + 1)
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● セーブヘッダの作成
  154.   #--------------------------------------------------------------------------
  155.   def self.make_save_header
  156.     d_rect = Rect.new(0, 0, PS0::Window_SaveFile_Plus::Thumbnail_Width,
  157.                             PS0::Window_SaveFile_Plus::Thumbnail_Height)
  158.     case PS0::Window_SaveFile_Plus::Zoom_Type
  159.     when "NN"
  160.       s_rect = $game_temp.save_bitmap.rect
  161.       $game_temp.save_snapshoot = Bitmap.new(d_rect.width, d_rect.height)
  162.       $game_temp.save_snapshoot.stretch_blt(d_rect, $game_temp.save_bitmap, s_rect)
  163.     when "NZ"
  164.       x = [$game_player.screen_x - d_rect.width/2, 0].max
  165.       x = [x, Graphics.width - d_rect.width].min
  166.       y = [$game_player.screen_y - d_rect.height/2, 0].max
  167.       y = [y, Graphics.height - d_rect.height].min
  168.       s_rect = Rect.new(x, y, d_rect.width, d_rect.height)
  169.       $game_temp.save_snapshoot = Bitmap.new(d_rect.width, d_rect.height)
  170.       $game_temp.save_snapshoot.blt(0, 0, $game_temp.save_bitmap, s_rect)
  171.     end
  172.     header = {}
  173.     header[:characters] = $game_party.characters_for_savefile
  174.     header[:playtime_s] = $game_system.playtime_s
  175.     header[:snapshoot]  = $game_temp.save_snapshoot
  176.     header
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● セーブの実行
  180.   #--------------------------------------------------------------------------
  181.   def self.save_game(index)
  182.     saving_window = Window_Saving.new
  183.     Graphics.update
  184.     begin
  185.       save_game_without_rescue(index)
  186.     rescue
  187.        delete_save_file(index)
  188.        false
  189.     end
  190.     saving_window.dispose
  191.     return true
  192.   end
  193. end
  194. #==============================================================================
  195. # ■ Window_Yes_Or_No
  196. #------------------------------------------------------------------------------
  197. #  提供“是”、“否”两个选项的窗口(替换、删除存档用)
  198. #==============================================================================
  199. class Window_Yes_Or_No < Window_HorzCommand
  200.   #--------------------------------------------------------------------------
  201.   # ● オブジェクト初期化
  202.   #--------------------------------------------------------------------------
  203.   def initialize(yes, no)
  204.     [url=home.php?mod=space&uid=40913]@yes[/url] = yes
  205.     @no = no
  206.     super(130, 0)
  207.     self.visible = false
  208.     self.active = false
  209.     @index = 0
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ● 桁数の取得
  213.   #--------------------------------------------------------------------------
  214.   def col_max
  215.     return 2
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ● コマンドリストの作成
  219.   #--------------------------------------------------------------------------
  220.   def make_command_list
  221.     add_command(@yes,   :yes)
  222.     add_command(@no,    :cancel)
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● 決定ボタンが押されたときの処理
  226.   #--------------------------------------------------------------------------
  227.   def process_ok
  228.     Input.update
  229.     call_ok_handler
  230.   end
  231.   #--------------------------------------------------------------------------
  232.   # ● 按下取消键时的处理
  233.   #--------------------------------------------------------------------------
  234.   def process_cancel
  235.     Input.update
  236.     call_cancel_handler
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● 启用窗口
  240.   #--------------------------------------------------------------------------
  241.   def activate
  242.     temp = self.y + self.height - Graphics.height
  243.     if temp > 0
  244.       self.y -= (temp + 12)
  245.     end
  246.     self.active = true
  247.     self
  248.   end
  249. end
  250. #==============================================================================
  251. # ■ Window_Saving
  252. #------------------------------------------------------------------------------
  253. #  显示保存信息的窗口
  254. #==============================================================================
  255. class Window_Saving < Window_Base
  256.   #--------------------------------------------------------------------------
  257.   # ● オブジェクト初期化
  258.   #--------------------------------------------------------------------------
  259.   def initialize
  260.     w = PS0::Window_SaveFile_Plus::SAVE_NOW.length * 16 + 32
  261.     x = (Graphics.width - w)/2
  262.     y = (Graphics.height - fitting_height(1))/2
  263.     super(x, y, w, fitting_height(1))
  264.     self.visible = PS0::Window_SaveFile_Plus::SHOW_SAVE_NOW
  265.     draw_text_ex(4, 0, PS0::Window_SaveFile_Plus::SAVE_NOW)
  266.   end
  267. end
  268. #==============================================================================
  269. # ■ Window_SaveManagerCommand
  270. #------------------------------------------------------------------------------
  271. #  存档管理窗口
  272. #==============================================================================
  273. class Window_SaveManagerCommand < Window_Command
  274.   #--------------------------------------------------------------------------
  275.   # ● 初始化对象
  276.   #--------------------------------------------------------------------------
  277.   def initialize(*args)
  278.     @copy, @move, @delete, [url=home.php?mod=space&uid=9053]@cancel[/url] = args[0..3]
  279.     super(130, 0)
  280.     self.visible = false
  281.     self.active = false
  282.     @index = 0
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # ● 获取窗口的宽度
  286.   #--------------------------------------------------------------------------
  287.   def window_width
  288.     return 100
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # ● 获取项目数
  292.   #--------------------------------------------------------------------------
  293.   def item_max
  294.     return 4
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ● 生成指令列表
  298.   #--------------------------------------------------------------------------
  299.   def make_command_list
  300.     add_command(@copy,   :copy  )
  301.     add_command(@move,   :move  )
  302.     add_command(@delete, :delete)
  303.     add_command(@cancel, :cancel)
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ● 按下确定键时的处理
  307.   #--------------------------------------------------------------------------
  308.   def process_ok
  309.     Input.update
  310.     call_ok_handler
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● 启用窗口
  314.   #--------------------------------------------------------------------------
  315.   def activate
  316.     temp = self.y + self.height - Graphics.height
  317.     if temp > 0
  318.       self.y -= (temp + 12)
  319.     end
  320.     self.active = true
  321.     self
  322.   end
  323. end
  324. #==============================================================================
  325. # ■ Window_FileCommand
  326. #------------------------------------------------------------------------------
  327. #  截图存档左侧的选择窗口。
  328. #==============================================================================
  329. class Window_FileCommand < Window_Command
  330.   #--------------------------------------------------------------------------
  331.   # ● オブジェクト初期化
  332.   #--------------------------------------------------------------------------
  333.   def initialize
  334.     super(0, 0)
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ● ウィンドウ幅の取得
  338.   #--------------------------------------------------------------------------
  339.   def window_height
  340.     return Graphics.height-fitting_height(1)
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● 表示行数の取得
  344.   #--------------------------------------------------------------------------
  345.   def visible_line_number
  346.     item_max
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   # ● コマンドリストの作成
  350.   #--------------------------------------------------------------------------
  351.   def make_command_list
  352.     add_main_commands
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   # ● 主要コマンドをリストに追加
  356.   #--------------------------------------------------------------------------
  357.   def add_main_commands
  358.     for i in 1..PS0::Window_SaveFile_Plus::MAX_SAVE
  359.       if i < 10
  360.         text = Vocab::File + " 0" + i.to_s
  361.       else
  362.         text = Vocab::File + " " + i.to_s
  363.       end
  364.       add_command(text, :file)
  365.     end
  366.   end
  367.   #--------------------------------------------------------------------------
  368.   # ● 決定ボタンが押されたときの処理
  369.   #--------------------------------------------------------------------------
  370.   def process_ok
  371.   end
  372. end
  373. #==============================================================================
  374. # ■ Window_SaveFile
  375. #------------------------------------------------------------------------------
  376. #  セーブ画面およびロード画面で表示する、セーブファイルのウィンドウです。
  377. #==============================================================================
  378. class Window_SaveFile < Window_Base
  379.   #--------------------------------------------------------------------------
  380.   # ● オブジェクト初期化
  381.   #     index : セーブファイルのインデックス
  382.   #--------------------------------------------------------------------------
  383.   def initialize(index)
  384.     super(160, 0, Graphics.width-160, Graphics.height-fitting_height(1))
  385.     @file_index = index
  386.     @selected = true
  387.     refresh
  388.   end
  389.   #--------------------------------------------------------------------------
  390.   # ● リフレッシュ
  391.   #--------------------------------------------------------------------------
  392.   def refresh
  393.     contents.clear
  394.     change_color(normal_color)
  395.     w = (self.width-PS0::Window_SaveFile_Plus::Thumbnail_Width-16)/2
  396.     h = (self.height-PS0::Window_SaveFile_Plus::Thumbnail_Height-16)/2
  397.     width  = w + PS0::Window_SaveFile_Plus::Thumbnail_ox
  398.     height = h + PS0::Window_SaveFile_Plus::Thumbnail_oy
  399.     draw_shadow(width+5, height+5)
  400.     draw_text((self.width-32-PS0::Window_SaveFile_Plus::NO_DATA.length*16)/2,
  401.               self.height/2-32, PS0::Window_SaveFile_Plus::NO_DATA.length*32,
  402.               line_height, PS0::Window_SaveFile_Plus::NO_DATA)
  403.     draw_party_characters(32, Graphics.height-fitting_height(1)-32)
  404.     draw_playtime(-10, contents.height - line_height-10, contents.width - 4, 2)
  405.     draw_snapshoot(width, height)
  406.   end
  407.   #--------------------------------------------------------------------------
  408.   # ● パーティキャラの描画
  409.   #--------------------------------------------------------------------------
  410.   def draw_party_characters(x, y)
  411.     header = DataManager.load_header(@file_index)
  412.     return unless header
  413.     header[:characters].each_with_index do |data, i|
  414.       draw_character(data[0], data[1], x + i * 48, y)
  415.     end
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # ● プレイ時間の描画
  419.   #--------------------------------------------------------------------------
  420.   def draw_playtime(x, y, width, align)
  421.     header = DataManager.load_header(@file_index)
  422.     return unless header
  423.     draw_text(x, y, width, line_height, header[:playtime_s], 2)
  424.   end
  425.   #--------------------------------------------------------------------------
  426.   # ● 绘制截图
  427.   #--------------------------------------------------------------------------
  428.   def draw_snapshoot(x, y)
  429.     header = DataManager.load_header(@file_index)
  430.     return unless header
  431.     bitmap = header[:snapshoot]
  432.     contents.blt(x, y, bitmap, bitmap.rect)
  433.     bitmap.dispose
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   # ● 绘制阴影
  437.   #--------------------------------------------------------------------------
  438.   def draw_shadow(x, y)
  439.     header = DataManager.load_header(@file_index)
  440.     return unless header
  441.     contents.fill_rect(x, y, PS0::Window_SaveFile_Plus::Thumbnail_Width,
  442.                              PS0::Window_SaveFile_Plus::Thumbnail_Height, Color.new(0, 0, 0))
  443.     contents.blur
  444.   end
  445. end
  446. #==============================================================================
  447. # ■ Scene_File
  448. #------------------------------------------------------------------------------
  449. #  セーブ画面とロード画面の共通処理を行うクラスです。
  450. #==============================================================================
  451. class Scene_File < Scene_MenuBase
  452.   #--------------------------------------------------------------------------
  453.   # ● 開始処理
  454.   #--------------------------------------------------------------------------
  455.   def start
  456.     super
  457.     create_help_window
  458.     create_savefile_viewport
  459.     create_command_window
  460.     create_savefile_window
  461.     create_manager_window
  462.     create_replace_window
  463.     create_delete_window
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # ● 終了処理
  467.   #--------------------------------------------------------------------------
  468.   def terminate
  469.     super
  470.     @savefile_viewport.dispose
  471.     @savefile_window.dispose
  472.     @command_window.dispose
  473.     @window_manager.dispose
  474.     @window_replace.dispose
  475.     @window_delete.dispose
  476.   end
  477.   #--------------------------------------------------------------------------
  478.   # ● フレーム更新
  479.   #--------------------------------------------------------------------------
  480.   def update
  481.     super
  482.     update_savefile_selection
  483.   end
  484.   #--------------------------------------------------------------------------
  485.   # ● 创建替换窗口
  486.   #--------------------------------------------------------------------------
  487.   def create_replace_window
  488.     @window_replace = Window_Yes_Or_No.new("替换", "取消")
  489.     @window_replace.set_handler(:yes,    method(:do_replace))
  490.     @window_replace.set_handler(:cancel, method(:do_cancel))
  491.   end
  492.   #--------------------------------------------------------------------------
  493.   # ● 创建删除窗口
  494.   #--------------------------------------------------------------------------
  495.   def create_delete_window
  496.     @window_delete  = Window_Yes_Or_No.new("删除", "取消")
  497.     @window_delete.set_handler(:yes,    method(:do_delete))
  498.     @window_delete.set_handler(:cancel, method(:do_return_manager))
  499.     @window_delete.x += 40
  500.   end
  501.   #--------------------------------------------------------------------------
  502.   # ● 创建管理窗口
  503.   #--------------------------------------------------------------------------
  504.   def create_manager_window
  505.     @window_manager = Window_SaveManagerCommand.new("复制", "移动", "删除", "取消")
  506.     @window_manager.set_handler(:copy  , method(:on_copy?))
  507.     @window_manager.set_handler(:move  , method(:on_move?))
  508.     @window_manager.set_handler(:delete, method(:on_delete?))
  509.     @window_manager.set_handler(:cancel, method(:do_cancel))
  510.   end
  511.   #--------------------------------------------------------------------------
  512.   # ● ヘルプウィンドウの作成
  513.   #--------------------------------------------------------------------------
  514.   def create_help_window
  515.     @help_window = Window_Help.new(1)
  516.     @help_window.set_text(help_window_text)
  517.   end
  518.   #--------------------------------------------------------------------------
  519.   # ● ヘルプウィンドウのテキストを取得
  520.   #--------------------------------------------------------------------------
  521.   def help_window_text
  522.     return ""
  523.   end
  524.   #--------------------------------------------------------------------------
  525.   # ● セーブファイルビューポートの作成
  526.   #--------------------------------------------------------------------------
  527.   def create_savefile_viewport
  528.     @savefile_viewport = Viewport.new
  529.     @savefile_viewport.rect.y = @help_window.height
  530.     @savefile_viewport.rect.height -= @help_window.height
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # ● セーブファイルウィンドウの作成
  534.   #--------------------------------------------------------------------------
  535.   def create_savefile_window
  536.     @savefile_window = Window_SaveFile.new(@index)
  537.     @savefile_window.viewport = @savefile_viewport
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # ● 生成存档列表窗口
  541.   #--------------------------------------------------------------------------
  542.   def create_command_window
  543.     @command_window = Window_FileCommand.new
  544.     @command_window.index = first_savefile_index
  545.     @index = @command_window.index
  546.     @command_window.viewport = @savefile_viewport
  547.     @command_window.set_handler(:file,      method(:on_savefile_ok))
  548.   end
  549.   #--------------------------------------------------------------------------
  550.   # ● セーブファイル選択の更新
  551.   #--------------------------------------------------------------------------
  552.   def update_savefile_selection
  553.     if @source_index != nil
  554.       if Input.trigger?(:C)
  555.         if @index == @source_index
  556.           Sound.play_buzzer
  557.         elsif FileTest.exist?(DataManager.make_filename(@index))
  558.           Graphics.freeze
  559.           @command_window.deactivate
  560.           @window_replace.y = 72 + @index * 24
  561.           @window_replace.activate
  562.           @window_replace.visible = true
  563.           @window_replace.refresh
  564.           Sound.play_ok
  565.           Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  566.         else
  567.           return on_copy_ok
  568.         end
  569.       elsif Input.trigger?(:B)
  570.         return do_return_manager
  571.       end
  572.     else
  573.       if Input.trigger?(:C)
  574.         if self.is_a?(Scene_Save) and FileTest.exist?(DataManager.make_filename(@index))
  575.           Graphics.freeze
  576.           @command_window.deactivate
  577.           @window_replace.y = 72 + @index * 24
  578.           @window_replace.activate
  579.           @window_replace.visible = true
  580.           @window_replace.refresh
  581.           Sound.play_ok
  582.           Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  583.         else
  584.           return on_savefile_ok
  585.         end
  586.       elsif Input.trigger?(:B)
  587.         return on_savefile_cancel
  588.       elsif Input.trigger?(:F5)
  589.         unless @window_manager.active == true or
  590.                @window_delete.active == true or
  591.                @window_replace.active == true
  592.           return on_manager?
  593.         end
  594.       end
  595.     end
  596.     @need_refresh = true if @index != @command_window.index
  597.     if @need_refresh
  598.       Graphics.freeze
  599.       @index = @command_window.index
  600.       @savefile_window.dispose
  601.       create_savefile_window
  602.       @need_refresh = false
  603.       Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  604.     end
  605.   end
  606.   #--------------------------------------------------------------------------
  607.   # ● セーブファイル[決定]
  608.   #--------------------------------------------------------------------------
  609.   def on_savefile_ok
  610.   end
  611.   #--------------------------------------------------------------------------
  612.   # ● セーブファイル[キャンセル]
  613.   #--------------------------------------------------------------------------
  614.   def on_savefile_cancel
  615.     Sound.play_cancel
  616.     return_scene
  617.   end
  618.   #--------------------------------------------------------------------------
  619.   # ● セーブファイル[決定]
  620.   #--------------------------------------------------------------------------
  621.   def on_copy_ok
  622.     Graphics.freeze
  623.     source_name = DataManager.make_filename(@source_index)
  624.     new_name    = DataManager.make_filename(@index)
  625.     case @source_type
  626.     when "copy"
  627.       # 复制存档文件(API)
  628.       Win32API.new('kernel32',"CopyFileA",'ppl','').call(source_name,new_name,0)
  629.     when "move"
  630.       # 重命名存档
  631.       File.rename(source_name, new_name)
  632.     end
  633.     # 返回
  634.     @help_window.set_text(help_window_text)
  635.     @source_index = nil
  636.     do_return_savelist
  637.   end
  638.   #--------------------------------------------------------------------------
  639.   # ● セーブファイル[复制]
  640.   #--------------------------------------------------------------------------
  641.   def on_copy?
  642.     Graphics.freeze
  643.     @help_window.set_text(PS0::Window_SaveFile_Plus::HELP_COPY)
  644.     @source_index = @index
  645.     @source_type = "copy"
  646.     do_return_savelist
  647.   end
  648.   #--------------------------------------------------------------------------
  649.   # ● セーブファイル[移动]
  650.   #--------------------------------------------------------------------------
  651.   def on_move?
  652.     Graphics.freeze
  653.     @help_window.set_text(PS0::Window_SaveFile_Plus::HELP_MOVE)
  654.     @source_index = @index
  655.     @source_type = "move"
  656.     do_return_savelist
  657.   end
  658.   #--------------------------------------------------------------------------
  659.   # ● セーブファイル[管理]
  660.   #--------------------------------------------------------------------------
  661.   def on_manager?
  662.     if FileTest.exist?(DataManager.make_filename(@index))
  663.       Graphics.freeze
  664.       @command_window.deactivate
  665.       @window_manager.y = 72 + @index * 24
  666.       @window_manager.activate
  667.       @window_manager.visible = true
  668.       @window_manager.refresh
  669.       Sound.play_ok
  670.       Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  671.     else
  672.       Sound.play_buzzer
  673.     end
  674.   end
  675.   #--------------------------------------------------------------------------
  676.   # ● セーブファイル[删除]
  677.   #--------------------------------------------------------------------------
  678.   def on_delete?
  679.     Graphics.freeze
  680.     @window_manager.deactivate
  681.     @command_window.deactivate
  682.     @window_delete.y = 72 + 72 + @index * 24
  683.     @window_delete.activate
  684.     @window_delete.visible = true
  685.     @window_delete.refresh
  686.     Sound.play_ok
  687.     Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  688.   end
  689.   #--------------------------------------------------------------------------
  690.   # ● 删除
  691.   #--------------------------------------------------------------------------
  692.   def do_delete
  693.     Graphics.freeze
  694.     File.delete(DataManager.make_filename(@index))
  695.     @window_delete.index  = 0
  696.     @window_manager.index = 0
  697.     @window_delete.visible  = false
  698.     @window_manager.visible = false
  699.     @window_delete.deactivate
  700.     @window_manager.deactivate
  701.     @command_window.activate
  702.     @need_refresh = true
  703.     Sound.play_save
  704.     if DataManager.save_file_exists?
  705.       Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  706.     else
  707.       return_scene
  708.     end
  709.   end
  710.   #--------------------------------------------------------------------------
  711.   # ● 替换
  712.   #--------------------------------------------------------------------------
  713.   def do_replace
  714.     Graphics.freeze
  715.     if @source_index != nil
  716.       return on_copy_ok
  717.     else
  718.       return on_savefile_ok
  719.     end
  720.     @window_replace.visible = false
  721.     @window_replace.deactivate
  722.     @need_refresh = true
  723.   end
  724.   #--------------------------------------------------------------------------
  725.   # ● 取消
  726.   #--------------------------------------------------------------------------
  727.   def do_cancel
  728.     Graphics.freeze
  729.     Sound.play_cancel
  730.     @window_delete.index  = 0
  731.     @window_replace.index = 0
  732.     @window_manager.index = 0
  733.     @window_delete.visible  = false
  734.     @window_replace.visible = false
  735.     @window_manager.visible = false
  736.     @window_delete.deactivate
  737.     @window_replace.deactivate
  738.     @window_manager.deactivate
  739.     @command_window.activate
  740.     Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  741.   end
  742.   #--------------------------------------------------------------------------
  743.   # ● 返回管理菜单
  744.   #--------------------------------------------------------------------------
  745.   def do_return_manager
  746.     Graphics.freeze
  747.     @help_window.set_text(help_window_text)
  748.     @command_window.index = @source_index unless @source_index == nil
  749.     @source_index = nil
  750.     @source_type = nil
  751.     @command_window.deactivate
  752.     @window_delete.index  = 0
  753.     @window_replace.index = 0
  754.     @window_delete.visible  = false
  755.     @window_replace.visible = false
  756.     @window_delete.deactivate
  757.     @window_replace.deactivate
  758.     @window_manager.y = 72 + @index * 24
  759.     @window_manager.activate
  760.     @window_manager.visible = true
  761.     @window_manager.refresh
  762.     Sound.play_cancel
  763.     Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
  764.   end
  765.   #--------------------------------------------------------------------------
  766.   # ● 返回文件列表(复制、移动 用)
  767.   #--------------------------------------------------------------------------
  768.   def do_return_savelist
  769.     @window_manager.visible = false
  770.     @window_manager.deactivate
  771.     @command_window.activate
  772.     @need_refresh = true
  773.     Sound.play_ok
  774.   end
  775. end
  776. #==============================================================================
  777. # [PS0] End of Script
  778. #==============================================================================
复制代码

坑的进度如上                                                                                                        点击↑
回复

使用道具 举报

梦石
0
星屑
50
在线时间
91 小时
注册时间
2012-3-3
回帖
56
 楼主| 发表于 2013-5-5 12:50:39 | 显示全部楼层
黄濑凉太 发表于 2013-4-28 15:08
是截图存档的代码把:

我是只想要截图功能,大神给的脚本怎么用呢?
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2013-5-5 13:23:20 | 显示全部楼层
Mapshot_Button = Input::F7
Screenshot_Button = Input::F6


  1. =begin
  2.   
  3. #===============================================================================

  4. Title: Map Screenshot

  5. Author: Tsukihime

  6. Date: Apr 15, 2013

  7. --------------------------------------------------------------------------------

  8. ** Change log

  9. Apr 15, 2013

  10.    - updated script to use GDI+ interface

  11.    - added support for region map overlay and passage map overlay

  12. Apr 6, 2013

  13.    - fixed bug where drawing events crashed the game

  14. Apr 2, 2013

  15.    - map data is now setup by an instance of Game_Map, to account for custom

  16.      map scripts adding to the map

  17. Jul 27

  18.    - Export dirNames are now optional

  19. May 28

  20.    - updated overlay mapping compatibility to draw the overlays

  21.      based on the player's current position

  22.    - fixed issue where import hash was commented out

  23.    - Added support for Yami's overlay mapping

  24. May 24, 2012

  25.    - fixed large characters

  26.    - some optimizations for calculating bounds and dimensions

  27. May 5, 2012

  28.    - fixed waterfall autotile

  29.    - added screenshot feature

  30. May 4, 2012

  31.    - fixed tiles with alpha channel

  32.    - fixed shadows

  33.    - fixed wall autotiles

  34. May 1, 2012

  35.    - fixed wall autotile, although there is still an issue with some tiles

  36. Apr 29, 2012

  37.    - fixed shadow map drawing

  38.    - added region highlighting

  39.    - added damage tile highlighting

  40. Apr 28, 2012

  41.    - Initial Release

  42. ------------------------------------------------------------------------------

  43. ** Description



  44. This script allows you to take a full image of any of your game's maps

  45. and export. An image of the map is referred to as a "mapshot" (as opposed to

  46. screenshot).



  47. The script provides various configuration options to control what kinds of

  48. things you want to see on your map, such as events, vehicles, region ID's, or

  49. specific tile properties.



  50. ------------------------------------------------------------------------------

  51. ** Usage



  52. The default key for taking a mapshot is F7. This can be changed in the

  53. configuration section.



  54. To take a mapshot, first start the game, and then hit F7.

  55. A message will appear informing you that a mapshot was successfully taken.



  56. Alternatively, you can use script calls to take mapshots.



  57.     Map_Saver.new(map_id).export

  58.    

  59. Aside from exporting images, you are able to use the image that the

  60. map saver captures.



  61.    ms = Map_Saver.new(map_id)

  62.    bmp = ms.map_image

  63.    

  64. This gives you a reference to a Bitmap object that contains an image of

  65. your map.

  66. --------------------------------------------------------------------------------

  67.   ** Credits



  68.   Cremno

  69.     -GDI+ interface code

  70.   Cidiomar

  71.     -for drawing autotiles and shadows,

  72.     -providing efficient bmp and png exporters

  73.   Moon

  74.     -auto-tile related info

  75.   Mephistox

  76.     -testing and suggestions

  77. ================================================================================

  78. =end

  79. $imported = {} if $imported.nil?

  80. $imported["TH_MapSaver"] = true

  81. #===============================================================================

  82. # ** Configuration

  83. #===============================================================================

  84. module TH

  85.   module Map_Saver

  86.    

  87.     #Mapshot options. This takes an image of the entire map

  88.     Mapshot_Button = Input::F7

  89.     Mapshot_Scale = 1

  90.    

  91.     #Screenshot options. This takes an image of the visible map

  92.     Screenshot_Button = Input::F6

  93.     Screenshot_Scale = 1

  94.    

  95.     #Folder that the map will be exported to

  96.     Mapshot_Directory = "Mapshots"

  97.     Screenshot_Directory = "Screenshots"

  98.    

  99.     # format you want to export to. You should stick with png.

  100.     # Options: [bmp, png]

  101.     Export_Format = "png"

  102.    

  103.     # Sprite draw options

  104.     Draw_Events = false

  105.     Draw_Player = false

  106.     Draw_Followers = false

  107.     Draw_Vehicles = false

  108.    

  109.     #Should shadows be drawn? What color?

  110.     Draw_Shadow = true

  111.     Shadow_Color = Color.new(0, 0, 0, 128)

  112.    

  113.     # Should regions be drawn? Requires "Region Overlay Map" script

  114.     Draw_Regions = false

  115.    

  116.     # Should passage settings be drawn? Requires "Passage Overlay Map" script

  117.     Draw_Passages = false

  118.    

  119.     #Should damage tiles be highlighted? What color?

  120.     Highlight_Damage = true

  121.     Damage_Color = Color.new(128, 0, 0, 128)

  122.   end

  123. end



  124. #==============================================================================

  125. # ** Module: Map_Tiles

  126. # Contains data and methods useful for working with maps and tiles

  127. #==============================================================================



  128. module Map_Tiles

  129.   AUTOTILE_PARTS = [[18,17,14,13], [ 2,14,17,18], [13, 3,17,18], [ 2, 3,17,18],

  130.                     [13,14,17, 7], [ 2,14,17, 7], [13, 3,17, 7], [ 2, 3,17, 7],

  131.                     [13,14, 6,18], [ 2,14, 6,18], [13, 3, 6,18], [ 2, 3, 6,18],

  132.                     [13,14, 6, 7], [ 2,14, 6, 7], [13, 3, 6, 7], [ 2, 3, 6, 7],

  133.                     [16,17,12,13], [16, 3,12,13], [16,17,12, 7], [12, 3,16, 7],

  134.                     [10, 9,14,13], [10, 9,14, 7], [10, 9, 6,13], [10, 9, 6, 7],

  135.                     [18,19,14,15], [18,19, 6,15], [ 2,19,14,15], [ 2,19, 6,15],

  136.                     [18,17,22,21], [ 2,17,22,21], [18, 3,22,21], [ 2, 3,21,22],

  137.                     [16,19,12,15], [10, 9,22,21], [ 8, 9,12,13], [ 8, 9,12, 7],

  138.                     [10,11,14,15], [10,11, 6,15], [18,19,22,23], [ 2,19,22,23],

  139.                     [16,17,20,21], [16, 3,20,21], [ 8,11,12,15], [ 8, 9,20,21],

  140.                     [16,19,20,23], [10,11,22,23], [ 8,11,20,23], [ 0, 1, 4, 5]]

  141.   WATERFALL_PIECES = [[ 2, 1, 6, 5], [ 0, 1, 4, 5], [ 2, 3, 6, 7], [0, 3, 4, 7]]

  142.   WALL_PIECES =  [[10, 9, 6, 5], [ 8, 9, 4, 5], [ 2, 1, 6, 5], [ 0, 1, 4, 5],

  143.                   [10,11, 6, 7], [ 8,11, 4, 7], [ 2, 3, 6, 7], [ 0, 3, 4, 7],

  144.                   [10, 9,14,13], [ 8, 9,12,13], [ 2, 1,14,13], [ 0, 1,12,13],

  145.                   [10,11,14,15], [8, 11,12,15], [ 2, 3,14,15], [ 0, 3,12,15]]



  146.   A1_TILES = [[0, 0], [0, 96], [192, 0], [192, 96],

  147.                [256, 0], [448, 0], [256, 96], [448, 96],

  148.                [0, 192], [192, 192], [0, 288], [192, 288],

  149.                [256, 192], [448, 192], [256, 288], [448, 288]]

  150.    

  151.   

  152.   #--------------------------------------------------------------------------

  153.   # * Checks if a tile is a wall

  154.   #--------------------------------------------------------------------------

  155.   def is_wall?(data)

  156.     return true if data.between?(2288, 2335)

  157.     return true if data.between?(2384, 2431)

  158.     return true if data.between?(2480, 2527)

  159.     return true if data.between?(2576, 2623)

  160.     return true if data.between?(2672, 2719)

  161.     return true if data.between?(2768, 2815)

  162.     return true if data.between?(4736, 5119)

  163.     return true if data.between?(5504, 5887)

  164.     return true if data.between?(6272, 6655)

  165.     return true if data.between?(7040, 7423)

  166.     return true if data > 7807

  167.     false

  168.   end

  169.   #--------------------------------------------------------------------------

  170.   # * Checks if a tile is roof

  171.   #--------------------------------------------------------------------------

  172.   def is_roof?(data)

  173.     return true if data.between?(4352, 4735)

  174.     return true if data.between?(5120, 5503)

  175.     return true if data.between?(5888, 6271)

  176.     return true if data.between?(6656, 7039)

  177.     return true if data.between?(7424, 7807)

  178.     false

  179.   end  

  180.   #--------------------------------------------------------------------------

  181.   # * Checks if a tile is soil

  182.   #--------------------------------------------------------------------------

  183.   def is_soil?(data)

  184.     return true if data.between?(2816, 4351) && !is_table?(data)

  185.     return true if data > 1663 && !is_stair?(data)

  186.     false

  187.   end   

  188.   #--------------------------------------------------------------------------

  189.   # * Checks if a tile is a stair

  190.   #--------------------------------------------------------------------------

  191.   def is_stair?(data)

  192.      return true if data.between?(1541, 1542)

  193.      return true if data.between?(1549, 1550)

  194.      return true if data.between?(1600, 1615)

  195.      false

  196.   end

  197.   #--------------------------------------------------------------------------

  198.   # * Checks if a tile is a table

  199.   #--------------------------------------------------------------------------

  200.   def is_table?(data)

  201.     return true if data.between?(3152, 3199)

  202.     return true if data.between?(3536, 3583)

  203.     return true if data.between?(3920, 3967)

  204.     return true if data.between?(4304, 4351)

  205.     false

  206.   end



  207.   #--------------------------------------------------------------------------

  208.   # * The tileset to be used

  209.   #--------------------------------------------------------------------------

  210.   def tileset

  211.     $data_tilesets[@tileset_id]

  212.   end

  213.   

  214.   #--------------------------------------------------------------------------

  215.   # * Region ID

  216.   #--------------------------------------------------------------------------

  217.   def region_id(x, y)

  218.     valid?(x, y) ? @map.data[x, y, 3] >> 8 : 0

  219.   end

  220.   

  221.   #--------------------------------------------------------------------------

  222.   # * Gets all of the tiles for each layer at position x,y

  223.   #--------------------------------------------------------------------------

  224.   def layered_tiles(x, y)

  225.     [2, 1, 0].collect {|z| @map.data[x, y, z] }

  226.   end

  227.   

  228.   def layered_tiles_flag?(x, y, bit)

  229.     layered_tiles(x, y).any? {|tile_id| tileset.flags[tile_id] & bit != 0 }

  230.   end

  231.    

  232.   def valid?(x, y)

  233.     x >= 0 && x < width && y >= 0 && y < height

  234.   end

  235.   

  236.   def damage_floor?(x, y)

  237.     valid?(x, y) && layered_tiles_flag?(x, y, 0x100)

  238.   end

  239.   

  240.   #--------------------------------------------------------------------------

  241.   # * Specifies which type of autotile is used

  242.   #--------------------------------------------------------------------------

  243.   def auto_tile(id)

  244.     id / 48

  245.   end

  246.   

  247.   #--------------------------------------------------------------------------

  248.   # * Specifies the specific arrangement of autotiles used

  249.   #--------------------------------------------------------------------------

  250.   def auto_index(id)

  251.     id % 48

  252.   end

  253.   

  254.   #--------------------------------------------------------------------------

  255.   # * Put the auto-tile pieces together

  256.   #--------------------------------------------------------------------------

  257.   def make_autotile(rects, sx, sy)

  258.     @tile.clear

  259.     for i in 0...4

  260.       @auto_rect.x = (rects[i] % 4) * 16 + sx

  261.       @auto_rect.y = (rects[i] / 4) * 16 + sy

  262.       @tile.blt((i % 2) * 16,(i / 2) * 16, @tilemap, @auto_rect)

  263.     end

  264.   end

  265.      

  266.   #--------------------------------------------------------------------------

  267.   # * Get auto-tile A1 tiles

  268.   #--------------------------------------------------------------------------

  269.   def autotile_A1(tile_id)

  270.     @tilemap = @bitmaps[0]

  271.     autotile = tile_id / 48

  272.     auto_id = tile_id % 48

  273.     sx, sy = A1_TILES[autotile]

  274.     if is_wall?(tile_id + 2048)

  275.       rects = WATERFALL_PIECES[auto_id]

  276.     else  

  277.       rects = AUTOTILE_PARTS[auto_id]

  278.     end

  279.     make_autotile(rects, sx, sy)

  280.   end

  281.   

  282.   #--------------------------------------------------------------------------

  283.   # * Get auto-tile A2 tiles.

  284.   # 64x96 tiles, 8 per row, 4 rows

  285.   #--------------------------------------------------------------------------

  286.   def autotile_A2(tile_id)

  287.     autotile = tile_id / 48

  288.     auto_id = tile_id % 48

  289.     @tilemap = @bitmaps[1]

  290.     sx = (autotile % 8) * 64

  291.     sy = (autotile / 8 % 4) * 96

  292.     rects = AUTOTILE_PARTS[auto_id]

  293.     make_autotile(rects, sx, sy)

  294.   end

  295.   

  296.   #--------------------------------------------------------------------------

  297.   # * Get auto-tile A3 tiles.

  298.   # 64x64 tiles, 8 per row, 4 rows

  299.   #--------------------------------------------------------------------------

  300.   def autotile_A3(tid)

  301.     @tilemap = @bitmaps[2]

  302.     sx = (auto_tile(tid) % 8) * 64

  303.     sy = (auto_tile(tid) / 8 % 4) * 64

  304.     rects = WALL_PIECES[auto_index(tid)]

  305.     make_autotile(rects, sx, sy)

  306.   end

  307.   

  308.   #--------------------------------------------------------------------------

  309.   # * Get auto-tile A4 tiles (walls)

  310.   #--------------------------------------------------------------------------

  311.   def autotile_A4(tile_id)

  312.     @tilemap = @bitmaps[3]

  313.     autotile = tile_id / 48

  314.     auto_id = tile_id % 48

  315.     sx = (autotile % 8) * 64

  316.     sy = (autotile / 16 * 160) + (autotile / 8 % 2) * 96

  317.     if is_wall?(tile_id + 5888)

  318.       rects = WALL_PIECES[auto_id]

  319.     else

  320.       rects = AUTOTILE_PARTS[auto_id]

  321.     end

  322.     make_autotile(rects, sx, sy)

  323.   end

  324.   

  325.   #--------------------------------------------------------------------------

  326.   # * Get auto-tile A5 tiles (normal)

  327.   #--------------------------------------------------------------------------

  328.   def autotile_A5(tile_id)

  329.     @tilemap = @bitmaps[4]

  330.     sx = (tile_id) % 8 * tilesize

  331.     sy = (tile_id) / 8 * tilesize

  332.     @src_rect.set(sx, sy, tilesize, tilesize)

  333.     @tile.clear

  334.     @tile.blt(0, 0, @tilemap, @src_rect)

  335.   end

  336.   

  337.   #--------------------------------------------------------------------------

  338.   # * Get normal tiles B, C, D, E

  339.   #--------------------------------------------------------------------------

  340.   def normal_tile(tile_id)

  341.     @tilemap = @bitmaps[5 + tile_id / 256]

  342.     sx = (tile_id / 128 % 2 * 8 + tile_id % 8) * tilesize;

  343.     sy = (tile_id % 256 / 8 % 16) * tilesize;

  344.     @src_rect.set(sx, sy, tilesize, tilesize)

  345.     @tile.clear

  346.     @tile.blt(0, 0, @tilemap, @src_rect)

  347.   end

  348.    

  349.   #--------------------------------------------------------------------------

  350.   # * Get bitmap for the specified tile id

  351.   #--------------------------------------------------------------------------

  352.   def get_bitmap(id)

  353.     if id < 1024

  354.       normal_tile(id)

  355.     elsif id < 1664

  356.       autotile_A5(id - 1536)

  357.     elsif id < 2816

  358.       autotile_A1(id - 2048)

  359.     elsif id < 4352

  360.       autotile_A2(id - 2816)

  361.     elsif id < 5888

  362.       autotile_A3(id - 4352)

  363.     else

  364.       autotile_A4(id - 5888)

  365.     end

  366.   end

  367. end



  368. #==============================================================================

  369. # **

  370. #==============================================================================



  371. class Game_Player < Game_Character

  372.   

  373.   alias :th_mapsaver_update :update

  374.   def update

  375.     th_mapsaver_update

  376.     if Input.trigger?(TH::Map_Saver::Mapshot_Button)

  377.       s = Map_Saver.new($game_map.map_id)

  378.       s.set_scale(TH::Map_Saver::Mapshot_Scale)

  379.       s.mapshot

  380.     end

  381.     if Input.trigger?(TH::Map_Saver::Screenshot_Button)

  382.       s = Map_Saver.new($game_map.map_id)

  383.       s.set_scale(TH::Map_Saver::Screenshot_Scale)

  384.       s.screenshot

  385.     end

  386.   end

  387. end



  388. class Game_Vehicle < Game_Character

  389.   attr_reader :map_id

  390. end



  391. class Game_Map

  392.   attr_reader :map

  393. end



  394. #==============================================================================

  395. # **

  396. #==============================================================================



  397. class Map_Saver

  398.   include TH::Map_Saver

  399.   include Map_Tiles

  400.   #--------------------------------------------------------------------------

  401.   # * Constants

  402.   #--------------------------------------------------------------------------



  403.   SHADOW_COLOR = TH::Map_Saver::Shadow_Color

  404.   DAMAGE_COLOR = TH::Map_Saver::Damage_Color



  405.   #--------------------------------------------------------------------------

  406.   # * Public instance variables

  407.   #--------------------------------------------------------------------------

  408.   attr_reader :map_image

  409.   

  410.   def initialize(map_id=$game_map.map_id, x=$game_player.x, y=$game_player.y)

  411.     @scale = 1

  412.     @local_x = x

  413.     @local_y = y

  414.     @screen_local = false

  415.     @shadow_bitmap = Bitmap.new(128, 128)

  416.     @draw_layer0 = true

  417.     @draw_layer1 = true

  418.     @draw_layer2 = true

  419.     @draw_events = Draw_Events

  420.     @draw_vehicles = Draw_Vehicles

  421.     @draw_player = Draw_Player

  422.     @draw_followers = Draw_Followers

  423.     @draw_shadow = Draw_Shadow

  424.     @draw_damage = Highlight_Damage

  425.     @draw_regions = Draw_Regions

  426.     @draw_passages = Draw_Passages

  427.     @tile = Bitmap.new(32, 32) #stores the current tile to be drawn

  428.     @tilemap = nil

  429.     @src_rect = Rect.new

  430.     @auto_rect = Rect.new(0, 0, tilesize / 2, tilesize/ 2) #constant

  431.     @tile_rect = Rect.new(0, 0, tilesize, tilesize)        #constant

  432.   end

  433.   

  434.   def load_tilesets

  435.     bitmaps = []

  436.     tileset.tileset_names.each_with_index do |name, i|

  437.       bitmaps[i] = Cache.tileset(name)

  438.     end

  439.     return bitmaps

  440.   end

  441.   

  442.   #--------------------------------------------------------------------------

  443.   # * Refresh, possibly with a new map

  444.   #--------------------------------------------------------------------------

  445.   def redraw(map_id=$game_map.map_id, x=$game_player.x, y=$game_player.y)

  446.     @map_image.dispose if @map_image

  447.     @map_id = map_id

  448.     @local_x = x

  449.     @local_y = y

  450.     @game_map = Game_Map.new

  451.     @game_map.setup(map_id)

  452.     @map = @game_map.map

  453.     @map_info = $data_mapinfos[map_id]

  454.     @screen = $game_map.screen

  455.     @tileset_id = @game_map.tileset.id

  456.     @bitmaps = load_tilesets

  457.    

  458.     get_bounds

  459.     @map_image = Bitmap.new(@width * tilesize, [url=home.php?mod=space&uid=291977]@height[/url] * tilesize)

  460.     draw_map

  461.     scale_map if @scale != 1

  462.   end

  463.   

  464.   #--------------------------------------------------------------------------

  465.   # * Pre-process. These will never change when drawing the map.

  466.   #--------------------------------------------------------------------------

  467.   def get_bounds

  468.     @start_x = start_x

  469.     @start_y = start_y

  470.     @end_x = end_x

  471.     @end_y = end_y

  472.     @width = width

  473.     @height = height

  474.     @tilesize = tilesize

  475.   end

  476.   

  477.   def screen_tile_x

  478.     Graphics.width / 32

  479.   end

  480.   

  481.   def screen_tile_y

  482.     Graphics.height / 32

  483.   end

  484.   

  485.   #--------------------------------------------------------------------------

  486.   # * Sets the scale for the map

  487.   #--------------------------------------------------------------------------

  488.   def set_scale(scale)

  489.     @scale = scale

  490.   end

  491.   

  492.   #--------------------------------------------------------------------------

  493.   # * Size of a tile

  494.   #--------------------------------------------------------------------------

  495.   def tilesize

  496.     32

  497.   end

  498.   

  499.   #--------------------------------------------------------------------------

  500.   # * Width and height of the map, both locally and globally

  501.   #--------------------------------------------------------------------------

  502.   def width

  503.     end_x - @start_x

  504.   end

  505.   

  506.   def height

  507.     end_y - @start_y

  508.   end

  509.   

  510.   #--------------------------------------------------------------------------

  511.   # * Starting and end positions, relative to the screen or map

  512.   #--------------------------------------------------------------------------

  513.   def start_x

  514.     @screen_local ? [[$game_player.x - screen_tile_x / 2, @map.width - screen_tile_x].min, 0].max : 0

  515.   end



  516.   def start_y

  517.     @screen_local ? [[$game_player.y - screen_tile_y / 2, @map.height - screen_tile_y].min, 0].max : 0

  518.   end

  519.   

  520.   def end_x

  521.     @screen_local ? [[screen_tile_x, @local_x + screen_tile_x / 2 + 1].max, @map.width].min : @map.width

  522.   end

  523.   

  524.   def end_y

  525.     @screen_local ? [[screen_tile_y, @local_y + screen_tile_y / 2 + 1].max, @map.height].min : @map.height

  526.   end



  527.   #--------------------------------------------------------------------------

  528.   # * Draw tile onto image. x and y values are absolute coords. They should

  529.   # be re-mapped based on the start_x and start_y values

  530.   #--------------------------------------------------------------------------

  531.   def draw_tile(x, y, tile, rect)

  532.     ox = (x - @start_x) * tilesize

  533.     oy = (y - @start_y) * tilesize

  534.     @map_image.blt(ox, oy, tile, rect)

  535.   end

  536.   

  537.   #--------------------------------------------------------------------------

  538.   # * Get bitmap for the specified character

  539.   #--------------------------------------------------------------------------

  540.   def get_character_bitmap(name)

  541.     charmap = Cache.character(name)

  542.     sign = name[/^[\!\$]./]

  543.     if sign && sign.include?('$')

  544.       cw = charmap.width / 3

  545.       ch = charmap.height / 4

  546.     else

  547.       cw = charmap.width / 12

  548.       ch = charmap.height / 8

  549.     end

  550.     return charmap, cw, ch

  551.   end

  552.   

  553.   #--------------------------------------------------------------------------

  554.   # * Draw the character onto the tile

  555.   #--------------------------------------------------------------------------

  556.   def set_character_bitmap(character, x, y)

  557.     charmap, cw, ch = get_character_bitmap(character.character_name)

  558.     index = character.character_index

  559.     pattern = character.pattern < 3 ? character.pattern : 1

  560.     sx = (index % 4 * 3 + pattern) * cw

  561.     sy = (index / 4 * 4 + (character.direction - 2) / 2) * ch

  562.     @src_rect.set(sx, sy, cw, ch)

  563.     x -= cw / (@tilesize * 2) if cw >= @tilesize

  564.     y -= ch / (@tilesize * 2) if ch >= @tilesize  

  565.     draw_tile(x, y, charmap, @src_rect)

  566.   end

  567.   

  568.   #--------------------------------------------------------------------------

  569.   # * create the shadow map

  570.   #--------------------------------------------------------------------------

  571.   def make_shadow_map

  572.     for s in 0 ... 16

  573.       x = s % 4

  574.       y = s / 4

  575.       if s & 0b1000 == 0b1000

  576.         @shadow_bitmap.fill_rect(x*tilesize+16, y*@tilesize+16, 16, 16, SHADOW_COLOR)

  577.       end

  578.       if s & 0b0100 == 0b0100

  579.         @shadow_bitmap.fill_rect(x*tilesize, y*@tilesize+16, 16, 16, SHADOW_COLOR)

  580.       end

  581.       if s & 0b0010 == 0b0010

  582.         @shadow_bitmap.fill_rect(x*tilesize+16, y*@tilesize, 16, 16, SHADOW_COLOR)

  583.       end

  584.       if s & 0b0001 == 0b0001

  585.         @shadow_bitmap.fill_rect(x*tilesize, y*@tilesize, 16, 16, SHADOW_COLOR)

  586.       end

  587.     end

  588.   end

  589.   

  590.   def draw_parallax

  591.     image = Cache.parallax(@map.parallax_name)

  592.     @src_rect.set(0, 0, image.width, image.height)

  593.     @map_image.blt(0, 0, image, @src_rect)

  594.   end

  595.   

  596.   #--------------------------------------------------------------------------

  597.   # * Draw the shadow map

  598.   #--------------------------------------------------------------------------

  599.   def draw_shadow_map

  600.     for x in @start_x ... @end_x

  601.       for y in @start_y ... @end_y

  602.       _x, _y = x*@tilesize, y*@tilesize

  603.         s = @map.data[x, y, 3]  & 0b1111

  604.         if s != 0

  605.           x_ = (s % 4) * @tilesize

  606.           y_ = (s / 4) * @tilesize

  607.           @src_rect.set(x_, y_, @tilesize, @tilesize)

  608.           draw_tile(x, y, @shadow_bitmap, @src_rect)

  609.         end

  610.       end

  611.     end

  612.   end

  613.   

  614.   #--------------------------------------------------------------------------

  615.   # * Draw the specified layer

  616.   #--------------------------------------------------------------------------

  617.   def draw_layer(layer)

  618.     for x in @start_x ... @end_x

  619.       for y in @start_y ... @end_y

  620.         _x, _y = x*@tilesize, y*@tilesize

  621.         tile_id = @map.data[x, y, layer]

  622.         next if tile_id == 0

  623.         get_bitmap(tile_id)

  624.         draw_tile(x, y, @tile, @tile_rect)

  625.       end

  626.     end

  627.   end

  628.   

  629.   #-----------------------------------------------------------------------------

  630.   # Draw game regions

  631.   #-----------------------------------------------------------------------------

  632.   def draw_regions

  633.     if $imported["TH_RegionOverlay"]

  634.       image = SceneManager.scene.instance_variable_get(:@spriteset).instance_variable_get(:@region_map).bitmap

  635.       @src_rect.set(@start_x * tilesize, @start_y * tilesize, image.width, image.height)

  636.       @map_image.blt(0, 0, image, @src_rect, 255)

  637.     end

  638.   end

  639.   

  640.   def draw_passages

  641.     if $imported["TH_OverlayPassageMap"]

  642.       image = SceneManager.scene.instance_variable_get(:@spriteset).instance_variable_get(:@passage_map).bitmap

  643.       @src_rect.set(@start_x * tilesize, @start_y * tilesize, image.width, image.height)

  644.       @map_image.blt(0, 0, image, @src_rect, 255)

  645.     end

  646.   end



  647.   #--------------------------------------------------------------------------

  648.   # * Draw the game player

  649.   #--------------------------------------------------------------------------

  650.   def draw_player

  651.     set_character_bitmap($game_player, $game_player.x, $game_player.y) if @map_id == $game_map.map_id

  652.   end

  653.   

  654.   def draw_followers

  655.   end

  656.   

  657.   #--------------------------------------------------------------------------

  658.   # * Draw map events

  659.   #--------------------------------------------------------------------------

  660.   def draw_events

  661.     @map.events.values.each do |event|

  662.       id = event.pages[0].graphic.tile_id

  663.       char_name = event.pages[0].graphic.character_name

  664.       if id > 0

  665.         normal_tile(id)

  666.         draw_tile(event.x, event.y, @tilemap, @src_rect)

  667.       elsif char_name != ""

  668.         set_character_bitmap(event.pages[0].graphic, event.x, event.y)

  669.       end

  670.     end

  671.   end

  672.   

  673.   #--------------------------------------------------------------------------

  674.   # * Draw map vehicles

  675.   #--------------------------------------------------------------------------

  676.   def draw_vehicles

  677.     $game_map.vehicles.each do |vehicle|

  678.       set_character_bitmap(vehicle, vehicle.x, vehicle.y,) if @map_id == vehicle.map_id

  679.     end

  680.   end

  681.   

  682.   #--------------------------------------------------------------------------

  683.   # * Draw map sprites

  684.   #--------------------------------------------------------------------------

  685.   def draw_sprites

  686.     draw_events if @draw_events

  687.     draw_vehicles if @draw_vehicles

  688.     draw_player if @draw_player

  689.     draw_followers if @draw_followers

  690.   end

  691.   

  692.   #--------------------------------------------------------------------------

  693.   # * Highlight damage tiles

  694.   #--------------------------------------------------------------------------

  695.   def draw_damage

  696.     @tile.clear

  697.     @tile.fill_rect(0, 0, @tilesize, @tilesize, DAMAGE_COLOR)

  698.     @src_rect.set(0, 0, @tilesize, @tilesize)

  699.     for x in @start_x ... @end_x

  700.       for y in @start_y ... @end_y

  701.         _x, _y = x*@tilesize, y*@tilesize

  702.         if damage_floor?(x, y)

  703.           draw_tile(x, y, @tile, @src_rect)

  704.         end

  705.       end

  706.     end

  707.   end

  708.   

  709.   def draw_screen_effects

  710.   end

  711.   #--------------------------------------------------------------------------

  712.   # * Draw the map

  713.   #--------------------------------------------------------------------------

  714.   def draw_map

  715.     make_shadow_map if @draw_shadow

  716.     draw_parallax

  717.     draw_layer(0)

  718.     draw_layer(1)

  719.     draw_shadow_map

  720.     draw_layer(2)

  721.     draw_damage if @draw_damage

  722.     draw_regions if @draw_regions

  723.     draw_passages if @draw_passages

  724.     draw_sprites

  725.     draw_screen_effects

  726.   end

  727.   

  728.   #--------------------------------------------------------------------------

  729.   # * Scale the map

  730.   #--------------------------------------------------------------------------

  731.   def scale_map

  732.     nw = @width * @scale

  733.     nh = @height * @scale

  734.     @src_rect.set(0, 0, @width, @height)

  735.     scaled_map = Bitmap.new(nw, nh)

  736.     scaled_rect = Rect.new(0, 0, nw, nh)

  737.     scaled_map.stretch_blt(scaled_rect, @map_image, @src_rect)

  738.     @map_image = scaled_map

  739.   end

  740.   

  741.   #--------------------------------------------------------------------------

  742.   # * Take a mapshot of the map

  743.   #--------------------------------------------------------------------------

  744.   def mapshot

  745.     @screen_local = false

  746.     redraw

  747.     export(TH::Map_Saver::Mapshot_Directory)

  748.     $game_message.add("Mapshot taken")

  749.   end

  750.    

  751.   #--------------------------------------------------------------------------

  752.   # * Take a screenshot of the map

  753.   #--------------------------------------------------------------------------

  754.   def screenshot

  755.     @screen_local = true

  756.     redraw

  757.     export(TH::Map_Saver::Screenshot_Directory)

  758.     $game_message.add("Screenshot taken")

  759.   end

  760.   

  761.   #--------------------------------------------------------------------------

  762.   # * Get the format to export to

  763.   #--------------------------------------------------------------------------

  764.   def get_format

  765.     TH::Map_Saver::Export_Format

  766.   end

  767.   

  768.   #--------------------------------------------------------------------------

  769.   # * Export the map to a file

  770.   #--------------------------------------------------------------------------

  771.   def export(dirName="")

  772.     format = get_format

  773.     name = @map.display_name != "" ? @map.display_name : @map_info.name

  774.     Dir.mkdir(dirName) unless File.directory?(dirName)

  775.     filename = "%s\\%s.%s" %[dirName, name, format]

  776.     t1 = Time.now

  777.     @map_image.save(filename)

  778.     t2 = Time.now

  779.     $game_message.add("Exported in %f seconds" %[t2 - t1])

  780.   end

  781. end



  782. class Bitmap



  783.   def save(filename, options = {})

  784.     options.merge!(format: File.extname(filename)[1..-1].to_sym)

  785.     retval = false

  786.     #bitmap = Gdiplus::Bitmap.new(:hbitmap, hbitmap)

  787.     #bitmap = Gdiplus::Bitmap.new(:gdidib, *gdidib)

  788.     # this seems to be the fastest one (RGSS 3.0.1, Windows 8 64-bit)

  789.     bitmap = Gdiplus::Bitmap.new(:scan0, width, height, scan0)

  790.     if bitmap

  791.       retval = bitmap.save(:file, filename, options[:format])

  792.       bitmap.dispose

  793.     end

  794.     retval

  795.   end



  796. private



  797.   def _data_struct(offset = 0)

  798.     @_data_struct ||= (DL::CPtr.new((object_id << 1) + 16).ptr + 8).ptr

  799.     (@_data_struct + offset).ptr.to_i

  800.   end



  801.   def gdidib

  802.      [_data_struct(8), _data_struct(16)]

  803.   end



  804.   def hbitmap

  805.     _data_struct(44)

  806.   end



  807.   def scan0

  808.     _data_struct(12)

  809.   end



  810. end



  811. # ★ GDI+ interface

  812. # ★★★★★★★★★★★★

  813. #

  814. # Author : Cremno

  815. #



  816. module Gdiplus

  817.   DLL = 'gdiplus.dll'



  818.   def self.get_function name, import, export = 'L'

  819.     Win32API.new DLL, name, import, export

  820.   end



  821.   FUNCTIONS = {

  822.     GdiplusStartup: get_function('GdiplusStartup', 'PPP'),

  823.     GdiplusShutdown: get_function('GdiplusShutdown', 'P', 'V'),

  824.     GdipDisposeImage: get_function('GdipDisposeImage', 'P'),

  825.     GdipSaveImageToFile: get_function('GdipSaveImageToFile', 'PPPP'),

  826.     GdipCreateBitmapFromGdiDib: get_function('GdipCreateBitmapFromGdiDib', 'LLP'),

  827.     GdipCreateBitmapFromHBITMAP: get_function('GdipCreateBitmapFromHBITMAP', 'LLP'),

  828.     GdipCreateBitmapFromScan0: get_function('GdipCreateBitmapFromScan0', 'LLLLPP')

  829.   }



  830.   @@token = [0].pack('I')

  831.   def self.token

  832.     @@token

  833.   end



  834.   @@clsids = {}

  835.   def self.clsids

  836.     @@clsids

  837.   end



  838.   def self.gen_clsids

  839.     return unless @@clsids.empty?

  840.     func = Win32API.new('rpcrt4.dll', 'UuidFromString', 'PP', 'L')

  841.     {

  842.       bmp:  '557cf400-1a04-11d3-9a73-0000f81ef32e',

  843.       jpeg: '557cf401-1a04-11d3-9a73-0000f81ef32e',

  844.       gif:  '557cf402-1a04-11d3-9a73-0000f81ef32e',

  845.       tiff: '557cf405-1a04-11d3-9a73-0000f81ef32e',

  846.       png:  '557cf406-1a04-11d3-9a73-0000f81ef32e'

  847.     }.each_pair do |k, v|

  848.       clsid = [0].pack('I')

  849.       func.call(v, clsid)

  850.       @@clsids[k] = clsid

  851.     end

  852.     @@clsids[:jpg] = @@clsids[:jpeg]

  853.     @@clsids[:tif] = @@clsids[:tiff]

  854.   end



  855.   # TODO: prepend prefix (Gdip or Gdiplus) automatically

  856.   def self.call(*args)

  857.     name = args.shift

  858.     func = FUNCTIONS[name]

  859.     v = func.call(*args)

  860.     if v && v != 0

  861.       msgbox "GDI+ error: #{v}\n\nFunction: #{name}\nArguments: #{args.inspect}"

  862.       false

  863.     else

  864.       true

  865.     end

  866.   end



  867.   def self.startup

  868.     call :GdiplusStartup, @@token, [1, 0, 0, 0].pack('L4'), 0

  869.   end



  870.   def self.shutdown

  871.     call :GdiplusShutdown, @@token

  872.   end



  873.   class Image



  874.     attr_reader :instance

  875.     def initialize

  876.       @instance = 0

  877.       true

  878.     end



  879.     def save(destination, *args)

  880.       case destination

  881.       when :file

  882.         filename = args.shift << "\0"

  883.         filename.encode!('UTF-16LE')

  884.         argv = [:GdipSaveImageToFile, filename, Gdiplus.clsids[args.shift], 0]

  885.       else

  886.         raise ArgumentError, "unknown GDI+ image destination: #{source}"

  887.       end

  888.       argv.insert(1, @instance)

  889.       Gdiplus.call *argv

  890.     end



  891.     def dispose

  892.       Gdiplus.call :GdipDisposeImage, @instance

  893.     end

  894.   end



  895.   class Bitmap < Image



  896.     def initialize source, *args

  897.       case source

  898.       when :gdidib

  899.         argv = [:GdipCreateBitmapFromGdiDib, args.shift, args.shift]

  900.       when :hbitmap

  901.         argv = [:GdipCreateBitmapFromHBITMAP, args.shift, 0]

  902.       when :scan0

  903.         w = args.shift

  904.         h = args.shift

  905.         argv = [:GdipCreateBitmapFromScan0, w, h, w * -4, 0x26200a, args.shift]

  906.       else

  907.         raise ArgumentError, "unknown GDI+ bitmap source: #{source}"

  908.       end

  909.       argv.push([0].pack('I'))

  910.       retval = Gdiplus.call *argv

  911.       @instance = retval ? argv.last.unpack('I').first : 0

  912.       retval

  913.     end

  914.   end

  915. end



  916. if Gdiplus.startup

  917.   Gdiplus.gen_clsids

  918.   class << SceneManager

  919.     alias_method :run_wo_gdip_shutdown, :run

  920.     def run

  921.       run_wo_gdip_shutdown

  922.       Gdiplus.shutdown

  923.     end

  924.   end

  925. end



  926. #==============================================================================

  927. # * Compatibility add-ons

  928. #==============================================================================

  929. #Yami overlays

  930. if $imported["YSE-OverlayMapping"]

  931.   class Map_Saver

  932.     def draw_overlay_map_ground

  933.       filename = YSA::OVERLAY::GROUND

  934.       filename += $game_map.map_id.to_s

  935.       filename += "-" + $game_variables[YSA::OVERLAY::GROUND_VARIABLE].to_s

  936.       p filename

  937.       image = Cache.overlay(filename)

  938.       @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)

  939.       @map_image.blt(0, 0, image, @src_rect)

  940.     end

  941.    

  942.     def draw_overlay_map_parallax

  943.       filename = YSA::OVERLAY::PARALLAX

  944.       filename += $game_map.map_id.to_s

  945.       filename += "-" + $game_variables[YSA::OVERLAY::PARALLAX_VARIABLE].to_s

  946.       image = Cache.overlay(filename)

  947.       @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)

  948.       @map_image.blt(0, 0, image, @src_rect)

  949.     end

  950.    

  951.     def draw_overlay_map_light

  952.       filename = YSA::OVERLAY::LIGHT

  953.       filename += $game_map.map_id.to_s

  954.       filename += "-" + $game_variables[YSA::OVERLAY::LIGHT_VARIABLE].to_s

  955.       image = Cache.overlay(filename)

  956.       @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)

  957.       @map_image.blt(0, 0, image, @src_rect, 10)

  958.     end

  959.    

  960.     def draw_overlay_map_shadow

  961.       filename = YSA::OVERLAY::SHADOW

  962.       filename += $game_map.map_id.to_s

  963.       filename += "-" + $game_variables[YSA::OVERLAY::SHADOW_VARIABLE].to_s

  964.       image = Cache.overlay(filename)

  965.       @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)

  966.       @map_image.blt(0, 0, image, @src_rect, 10)

  967.     end

  968.   

  969.     alias :th_map_overlay_draw_map :draw_map

  970.     def draw_map

  971.       th_map_overlay_draw_map

  972.       draw_overlay_map_ground if $game_switches[YSA::OVERLAY::GROUND_SWITCH]

  973.       draw_overlay_map_parallax if $game_switches[YSA::OVERLAY::PARALLAX_SWITCH]

  974.       draw_overlay_map_shadow if $game_switches[YSA::OVERLAY::SHADOW_SWITCH]

  975.       draw_overlay_map_light if $game_switches[YSA::OVERLAY::LIGHT_SWITCH]

  976.     end

  977.   end

  978. end



  979. if $imported["TH_AreaOverlay"]

  980.   class Map_Saver

  981.     def draw_overlay_area_map

  982.       image = SceneManager.scene.instance_variable_get(:@spriteset).instance_variable_get(:@area_map).bitmap

  983.       @src_rect.set(@start_x * tilesize, @start_y * tilesize, image.width, image.height)

  984.       @map_image.blt(0, 0, image, @src_rect, 255)

  985.     end

  986.    

  987.     alias :th_area_overlay_draw_map :draw_map

  988.     def draw_map

  989.       th_area_overlay_draw_map

  990.       draw_overlay_area_map

  991.     end

  992.   end

  993. end
复制代码
回复

使用道具 举报

梦石
0
星屑
50
在线时间
687 小时
注册时间
2012-10-29
回帖
1526
发表于 2013-5-6 07:51:46 | 显示全部楼层
楼主的意思不是要截图脚本,而是截图的程式码,或者说,他想知道怎么配合荣誉系统,把当前画面存成图档,然后可以在那个荣誉系统中显示图档画面。
修改劇本中,仔細審查原來的劇情大綱,覺得有點不太滿意,嘗試編寫不同主角不同主線的劇情,希望能寫得出來。
回复

使用道具 举报

梦石
0
星屑
50
在线时间
91 小时
注册时间
2012-3-3
回帖
56
 楼主| 发表于 2013-5-11 22:26:57 | 显示全部楼层
j433463 发表于 2013-5-6 07:51
楼主的意思不是要截图脚本,而是截图的程式码,或者说,他想知道怎么配合荣誉系统,把当前画面存成图档,然 ...

是啊,迫于高考压力,近期上不了网了,如果没有什么好的回复的话,这个贴请斑竹帮忙结了吧,等高考完自己研究研究
回复

使用道具 举报

梦石
0
星屑
50
在线时间
687 小时
注册时间
2012-10-29
回帖
1526
发表于 2013-5-12 02:27:47 | 显示全部楼层
我觉得您不必想要从截图存档脚本中去抠截图代码,可以考虑用这个存图脚本:

http://cacaosoft.web.fc2.com/tkool/script/rgss3/save_bitmap.html

它可以用 Bitmap 方式从图档取得的位图内容存到指定的图档中,也可以直接将当前游戏画面存成图档,图档格式可以是 BITMAP, JPEG, PNG, GIF 四种,
实际方式在该页中有介绍。

其实您要的只是截取当时画面,这个在 VA 本身的 Graphics.snap_to_bitmap 就可以做到,开启主菜单时截取地图背景就是用它来做的,
在 SceneManager 默认脚本的最底下,生成背景用的场景截图 def self.snapshot_for_background 那边,您自己去参看它的写法,
但截图后关键在于截取到的画面要存到 png 时的方式,这个复杂了点,我也只能照抄着代码来用,并不怎么懂这个东西,说不清楚,
您有空再去找一下吧,vx 和 xp 有谈到 bitmap to png 的一些帖子。

点评

好的,我研究一下,谢谢了!  发表于 2013-5-19 13:26
修改劇本中,仔細審查原來的劇情大綱,覺得有點不太滿意,嘗試編寫不同主角不同主線的劇情,希望能寫得出來。
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部