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

Project1

 找回密码
 注册会员
搜索
查看: 2262|回复: 7
打印 上一主题 下一主题

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
91 小时
注册时间
2012-3-3
帖子
65
跳转到指定楼层
1
发表于 2013-4-28 14:11:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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

这个是地球村荣誉系统的脚本
RUBY 代码复制
  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. #==============================================================================
  28. # ■ Game_Party
  29. #==============================================================================
  30. class Game_Party
  31.   #--------------------------------------------------------------------------
  32.   # ● 公開インスタンス変数
  33.   #--------------------------------------------------------------------------
  34.   attr_reader   :medals                   # 獲得済みメダル
  35.   attr_reader   :new_medals               # 新規獲得メダル
  36.   attr_accessor :medal_info_count         # メダル情報表示カウント
  37.   attr_accessor :medal_info_opacity       # メダル情報表示不透明度
  38.   #--------------------------------------------------------------------------
  39.   # ● オブジェクト初期化
  40.   #--------------------------------------------------------------------------
  41.   alias tmmedal_game_party_initialize initialize
  42.   def initialize
  43.     tmmedal_game_party_initialize
  44.     @medals = []
  45.     @new_medals = []
  46.     @medal_info_count = 0
  47.     @medal_info_opacity = 0
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ○ メダルの獲得
  51.   #--------------------------------------------------------------------------
  52.   def gain_medal(medal_id)
  53.     return if @medals.any? {|medal| medal[0] == medal_id }
  54.     t = Time.now.strftime(" (%Y/%m/%d %H:%M)")
  55.     @medals.push([medal_id, t])
  56.     @new_medals.push([medal_id, t])
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # ○ 獲得メダル情報の消去
  60.   #--------------------------------------------------------------------------
  61.   def delete_new_medal
  62.     @new_medals.shift
  63.   end
  64. end
  65.  
  66. #==============================================================================
  67. # ■ Game_Interpreter
  68. #==============================================================================
  69. class Game_Interpreter
  70.   #--------------------------------------------------------------------------
  71.   # ○ メダルの獲得
  72.   #--------------------------------------------------------------------------
  73.   def gain_medal(medal_id)
  74.     $game_party.gain_medal(medal_id)
  75.   end
  76. end
  77.  
  78. #==============================================================================
  79. # ■ Window_MenuCommand
  80. #==============================================================================
  81. class Window_MenuCommand
  82.   #--------------------------------------------------------------------------
  83.   # ● 独自コマンドの追加用
  84.   #--------------------------------------------------------------------------
  85.   alias tmmedal_window_menucommand_add_original_commands add_original_commands
  86.   def add_original_commands
  87.     tmmedal_window_menucommand_add_original_commands
  88.     unless TMMEDAL::HIDE_COMMAND && !medal_enabled
  89.       add_command(TMMEDAL::COMMAND_MEDAL, :medal, medal_enabled)
  90.     end
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ○ メダルの有効状態を取得
  94.   #--------------------------------------------------------------------------
  95.   def medal_enabled
  96.     !$game_party.medals.empty?
  97.   end
  98. end
  99.  
  100. #==============================================================================
  101. # □ Window_MedalInfo
  102. #==============================================================================
  103. class Window_MedalInfo < Window_Base
  104.   #--------------------------------------------------------------------------
  105.   # ● オブジェクト初期化
  106.   #--------------------------------------------------------------------------
  107.   def initialize
  108.     super(Graphics.width - window_width, 0, window_width, fitting_height(1))
  109.     self.opacity = 0
  110.     self.contents_opacity = $game_party.medal_info_opacity
  111.     refresh
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● ウィンドウ幅の取得
  115.   #--------------------------------------------------------------------------
  116.   def window_width
  117.     return 240
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ● フレーム更新
  121.   #--------------------------------------------------------------------------
  122.   def update
  123.     super
  124.     if $game_party.medal_info_count > 0
  125.       self.contents_opacity += 16
  126.       $game_party.medal_info_count -= 1
  127.       $game_party.delete_new_medal if $game_party.medal_info_count == 0
  128.     else
  129.       self.contents_opacity -= 16
  130.       if self.contents_opacity == 0
  131.         open unless $game_party.new_medals.empty?
  132.       end
  133.     end
  134.     $game_party.medal_info_opacity = self.contents_opacity
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # ● ウィンドウを開く
  138.   #--------------------------------------------------------------------------
  139.   def open
  140.     refresh
  141.     TMMEDAL::SE_GAIN_MEDAL.play
  142.     $game_party.medal_info_count = 150
  143.     self.contents_opacity = 0
  144.     self
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # ○ リフレッシュ
  148.   #--------------------------------------------------------------------------
  149.   def refresh
  150.     contents.clear
  151.     unless $game_party.new_medals.empty?
  152.       draw_background(contents.rect)
  153.       medal = TMMEDAL::MEDAL_DATA[$game_party.new_medals[0][0]]
  154.       rect = contents.rect.clone
  155.       draw_icon(medal[1], rect.x, rect.y)
  156.       rect.x += 24
  157.       rect.width -= 24
  158.       draw_text(rect, medal[0])
  159.     end
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   # ○ 背景の描画
  163.   #--------------------------------------------------------------------------
  164.   def draw_background(rect)
  165.     temp_rect = rect.clone
  166.     temp_rect.width /= 2
  167.     contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
  168.     temp_rect.x = temp_rect.width
  169.     contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ○ 背景色 1 の取得
  173.   #--------------------------------------------------------------------------
  174.   def back_color1
  175.     Color.new(0, 0, 0, 192)
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ○ 背景色 2 の取得
  179.   #--------------------------------------------------------------------------
  180.   def back_color2
  181.     Color.new(0, 0, 0, 0)
  182.   end
  183. end
  184.  
  185. #==============================================================================
  186. # □ Window_Medal
  187. #==============================================================================
  188. class Window_Medal < Window_Selectable
  189.   #--------------------------------------------------------------------------
  190.   # ● オブジェクト初期化
  191.   #--------------------------------------------------------------------------
  192.   def initialize(x, y, width, height)
  193.     super
  194.     refresh
  195.     select(0)
  196.     activate
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ● 桁数の取得
  200.   #--------------------------------------------------------------------------
  201.   def col_max
  202.     return 1
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # ● 項目数の取得
  206.   #--------------------------------------------------------------------------
  207.   def item_max
  208.     @data ? @data.size : 1
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # ● アイテムの取得
  212.   #--------------------------------------------------------------------------
  213.   def item
  214.     @data && index >= 0 ? @data[index] : nil
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # ● アイテムリストの作成
  218.   #--------------------------------------------------------------------------
  219.   def make_item_list
  220.     @data = $game_party.medals
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # ● 項目の描画
  224.   #--------------------------------------------------------------------------
  225.   def draw_item(index)
  226.     item = @data[index]
  227.     medal = TMMEDAL::MEDAL_DATA[item[0]]
  228.     rect = item_rect(index)
  229.     draw_icon(medal[1], rect.x, rect.y)
  230.     rect.x += 24
  231.     rect.width -= 216
  232.     draw_text(rect, medal[0])
  233.     rect.x = contents.width - 192
  234.     rect.width = 192
  235.     draw_text(rect, item[1], 2)
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # ● ヘルプテキスト更新
  239.   #--------------------------------------------------------------------------
  240.   def update_help
  241.     if item
  242.       medal = TMMEDAL::MEDAL_DATA[item[0]]
  243.       text = medal[2]
  244.       @help_window.set_text(text)
  245.     end
  246.   end
  247.   #--------------------------------------------------------------------------
  248.   # ● リフレッシュ
  249.   #--------------------------------------------------------------------------
  250.   def refresh
  251.     make_item_list
  252.     create_contents
  253.     draw_all_items
  254.   end
  255. end
  256.  
  257. #==============================================================================
  258. # ■ Scene_Map
  259. #==============================================================================
  260. class Scene_Map
  261.   #--------------------------------------------------------------------------
  262.   # ● 全ウィンドウの作成
  263.   #--------------------------------------------------------------------------
  264.   alias tmmedal_scene_map_create_all_windows create_all_windows
  265.   def create_all_windows
  266.     tmmedal_scene_map_create_all_windows
  267.     create_medal_window
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # ○ メダルウィンドウの作成
  271.   #--------------------------------------------------------------------------
  272.   def create_medal_window
  273.     @medal_window = Window_MedalInfo.new
  274.   end
  275. end
  276.  
  277. #==============================================================================
  278. # ■ Scene_Menu
  279. #==============================================================================
  280. class Scene_Menu
  281.   #--------------------------------------------------------------------------
  282.   # ● コマンドウィンドウの作成
  283.   #--------------------------------------------------------------------------
  284.   alias tmmedal_scene_menu_create_command_window create_command_window
  285.   def create_command_window
  286.     tmmedal_scene_menu_create_command_window
  287.     @command_window.set_handler(:medal, method(:command_medal))
  288.   end
  289.   #--------------------------------------------------------------------------
  290.   # ○ コマンド[メダル]
  291.   #--------------------------------------------------------------------------
  292.   def command_medal
  293.     SceneManager.call(Scene_Medal)
  294.   end
  295. end
  296.  
  297. #==============================================================================
  298. # □ Scene_Medal
  299. #==============================================================================
  300. class Scene_Medal < Scene_MenuBase
  301.   #--------------------------------------------------------------------------
  302.   # ● 開始処理
  303.   #--------------------------------------------------------------------------
  304.   def start
  305.     super
  306.     create_help_window
  307.     create_item_window
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ○ アイテムウィンドウの作成
  311.   #--------------------------------------------------------------------------
  312.   def create_item_window
  313.     wy = @help_window.height
  314.     wh = Graphics.height - wy
  315.     @item_window = Window_Medal.new(0, wy, Graphics.width, wh)
  316.     @item_window.viewport = @viewport
  317.     @item_window.help_window = @help_window
  318.     @item_window.set_handler(:cancel, method(:return_scene))
  319.   end
  320. end


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

Lv1.梦旅人

梦石
0
星屑
70
在线时间
1083 小时
注册时间
2013-3-29
帖子
2394
2
发表于 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. #==============================================================================
复制代码

坑的进度如上                                                                                                        点击↑
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
91 小时
注册时间
2012-3-3
帖子
65
3
 楼主| 发表于 2013-5-5 12:50:39 | 只看该作者
黄濑凉太 发表于 2013-4-28 15:08
是截图存档的代码把:

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

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
21957
在线时间
8567 小时
注册时间
2011-12-31
帖子
3362
4
发表于 2013-5-5 13:23:20 | 只看该作者
Mapshot_Button = Input::F7
Screenshot_Button = Input::F6


RUBY 代码复制
  1. =begin
  2.  
  3. #===============================================================================
  4.  
  5.  Title: Map Screenshot
  6.  
  7.  Author: Tsukihime
  8.  
  9.  Date: Apr 15, 2013
  10.  
  11. --------------------------------------------------------------------------------
  12.  
  13.  ** Change log
  14.  
  15.  Apr 15, 2013
  16.  
  17.    - updated script to use GDI+ interface
  18.  
  19.    - added support for region map overlay and passage map overlay
  20.  
  21.  Apr 6, 2013
  22.  
  23.    - fixed bug where drawing events crashed the game
  24.  
  25.  Apr 2, 2013
  26.  
  27.    - map data is now setup by an instance of Game_Map, to account for custom
  28.  
  29.      map scripts adding to the map
  30.  
  31.  Jul 27
  32.  
  33.    - Export dirNames are now optional
  34.  
  35.  May 28
  36.  
  37.    - updated overlay mapping compatibility to draw the overlays
  38.  
  39.      based on the player's current position
  40.  
  41.    - fixed issue where import hash was commented out
  42.  
  43.    - Added support for Yami's overlay mapping
  44.  
  45.  May 24, 2012
  46.  
  47.    - fixed large characters
  48.  
  49.    - some optimizations for calculating bounds and dimensions
  50.  
  51.  May 5, 2012
  52.  
  53.    - fixed waterfall autotile
  54.  
  55.    - added screenshot feature
  56.  
  57.  May 4, 2012
  58.  
  59.    - fixed tiles with alpha channel
  60.  
  61.    - fixed shadows
  62.  
  63.    - fixed wall autotiles
  64.  
  65.  May 1, 2012
  66.  
  67.    - fixed wall autotile, although there is still an issue with some tiles
  68.  
  69.  Apr 29, 2012
  70.  
  71.    - fixed shadow map drawing
  72.  
  73.    - added region highlighting
  74.  
  75.    - added damage tile highlighting
  76.  
  77.  Apr 28, 2012
  78.  
  79.    - Initial Release
  80.  
  81. ------------------------------------------------------------------------------
  82.  
  83.  ** Description
  84.  
  85.  
  86.  
  87.  This script allows you to take a full image of any of your game's maps
  88.  
  89.  and export. An image of the map is referred to as a "mapshot" (as opposed to
  90.  
  91.  screenshot).
  92.  
  93.  
  94.  
  95.  The script provides various configuration options to control what kinds of
  96.  
  97.  things you want to see on your map, such as events, vehicles, region ID's, or
  98.  
  99.  specific tile properties.
  100.  
  101.  
  102.  
  103. ------------------------------------------------------------------------------
  104.  
  105.  ** Usage
  106.  
  107.  
  108.  
  109.  The default key for taking a mapshot is F7. This can be changed in the
  110.  
  111.  configuration section.
  112.  
  113.  
  114.  
  115.  To take a mapshot, first start the game, and then hit F7.
  116.  
  117.  A message will appear informing you that a mapshot was successfully taken.
  118.  
  119.  
  120.  
  121.  Alternatively, you can use script calls to take mapshots.
  122.  
  123.  
  124.  
  125.     Map_Saver.new(map_id).export
  126.  
  127.     
  128.  
  129.  Aside from exporting images, you are able to use the image that the
  130.  
  131.  map saver captures.
  132.  
  133.  
  134.  
  135.    ms = Map_Saver.new(map_id)
  136.  
  137.    bmp = ms.map_image
  138.  
  139.    
  140.  
  141.  This gives you a reference to a Bitmap object that contains an image of
  142.  
  143.  your map.
  144.  
  145. --------------------------------------------------------------------------------
  146.  
  147.   ** Credits
  148.  
  149.  
  150.  
  151.   Cremno
  152.  
  153.     -GDI+ interface code
  154.  
  155.   Cidiomar
  156.  
  157.     -for drawing autotiles and shadows,
  158.  
  159.     -providing efficient bmp and png exporters
  160.  
  161.   Moon
  162.  
  163.     -auto-tile related info
  164.  
  165.   Mephistox
  166.  
  167.     -testing and suggestions
  168.  
  169. ================================================================================
  170.  
  171. =end
  172.  
  173. $imported = {} if $imported.nil?
  174.  
  175. $imported["TH_MapSaver"] = true
  176.  
  177. #===============================================================================
  178.  
  179. # ** Configuration
  180.  
  181. #===============================================================================
  182.  
  183. module TH
  184.  
  185.   module Map_Saver
  186.  
  187.  
  188.  
  189.     #Mapshot options. This takes an image of the entire map
  190.  
  191.     Mapshot_Button = Input::F7
  192.  
  193.     Mapshot_Scale = 1
  194.  
  195.  
  196.  
  197.     #Screenshot options. This takes an image of the visible map
  198.  
  199.     Screenshot_Button = Input::F6
  200.  
  201.     Screenshot_Scale = 1
  202.  
  203.  
  204.  
  205.     #Folder that the map will be exported to
  206.  
  207.     Mapshot_Directory = "Mapshots"
  208.  
  209.     Screenshot_Directory = "Screenshots"
  210.  
  211.  
  212.  
  213.     # format you want to export to. You should stick with png.
  214.  
  215.     # Options: [bmp, png]
  216.  
  217.     Export_Format = "png"
  218.  
  219.  
  220.  
  221.     # Sprite draw options
  222.  
  223.     Draw_Events = false
  224.  
  225.     Draw_Player = false
  226.  
  227.     Draw_Followers = false
  228.  
  229.     Draw_Vehicles = false
  230.  
  231.  
  232.  
  233.     #Should shadows be drawn? What color?
  234.  
  235.     Draw_Shadow = true
  236.  
  237.     Shadow_Color = Color.new(0, 0, 0, 128)
  238.  
  239.  
  240.  
  241.     # Should regions be drawn? Requires "Region Overlay Map" script
  242.  
  243.     Draw_Regions = false
  244.  
  245.  
  246.  
  247.     # Should passage settings be drawn? Requires "Passage Overlay Map" script
  248.  
  249.     Draw_Passages = false
  250.  
  251.  
  252.  
  253.     #Should damage tiles be highlighted? What color?
  254.  
  255.     Highlight_Damage = true
  256.  
  257.     Damage_Color = Color.new(128, 0, 0, 128)
  258.  
  259.   end
  260.  
  261. end
  262.  
  263.  
  264.  
  265. #==============================================================================
  266.  
  267. # ** Module: Map_Tiles
  268.  
  269. # Contains data and methods useful for working with maps and tiles
  270.  
  271. #==============================================================================
  272.  
  273.  
  274.  
  275. module Map_Tiles
  276.  
  277.   AUTOTILE_PARTS = [[18,17,14,13], [ 2,14,17,18], [13, 3,17,18], [ 2, 3,17,18],
  278.  
  279.                     [13,14,17, 7], [ 2,14,17, 7], [13, 3,17, 7], [ 2, 3,17, 7],
  280.  
  281.                     [13,14, 6,18], [ 2,14, 6,18], [13, 3, 6,18], [ 2, 3, 6,18],
  282.  
  283.                     [13,14, 6, 7], [ 2,14, 6, 7], [13, 3, 6, 7], [ 2, 3, 6, 7],
  284.  
  285.                     [16,17,12,13], [16, 3,12,13], [16,17,12, 7], [12, 3,16, 7],
  286.  
  287.                     [10, 9,14,13], [10, 9,14, 7], [10, 9, 6,13], [10, 9, 6, 7],
  288.  
  289.                     [18,19,14,15], [18,19, 6,15], [ 2,19,14,15], [ 2,19, 6,15],
  290.  
  291.                     [18,17,22,21], [ 2,17,22,21], [18, 3,22,21], [ 2, 3,21,22],
  292.  
  293.                     [16,19,12,15], [10, 9,22,21], [ 8, 9,12,13], [ 8, 9,12, 7],
  294.  
  295.                     [10,11,14,15], [10,11, 6,15], [18,19,22,23], [ 2,19,22,23],
  296.  
  297.                     [16,17,20,21], [16, 3,20,21], [ 8,11,12,15], [ 8, 9,20,21],
  298.  
  299.                     [16,19,20,23], [10,11,22,23], [ 8,11,20,23], [ 0, 1, 4, 5]]
  300.  
  301.   WATERFALL_PIECES = [[ 2, 1, 6, 5], [ 0, 1, 4, 5], [ 2, 3, 6, 7], [0, 3, 4, 7]]
  302.  
  303.   WALL_PIECES =  [[10, 9, 6, 5], [ 8, 9, 4, 5], [ 2, 1, 6, 5], [ 0, 1, 4, 5],
  304.  
  305.                   [10,11, 6, 7], [ 8,11, 4, 7], [ 2, 3, 6, 7], [ 0, 3, 4, 7],
  306.  
  307.                   [10, 9,14,13], [ 8, 9,12,13], [ 2, 1,14,13], [ 0, 1,12,13],
  308.  
  309.                   [10,11,14,15], [8, 11,12,15], [ 2, 3,14,15], [ 0, 3,12,15]]
  310.  
  311.  
  312.  
  313.   A1_TILES = [[0, 0], [0, 96], [192, 0], [192, 96],
  314.  
  315.                [256, 0], [448, 0], [256, 96], [448, 96],
  316.  
  317.                [0, 192], [192, 192], [0, 288], [192, 288],
  318.  
  319.                [256, 192], [448, 192], [256, 288], [448, 288]]
  320.  
  321.  
  322.  
  323.  
  324.  
  325.   #--------------------------------------------------------------------------
  326.  
  327.   # * Checks if a tile is a wall
  328.  
  329.   #--------------------------------------------------------------------------
  330.  
  331.   def is_wall?(data)
  332.  
  333.     return true if data.between?(2288, 2335)
  334.  
  335.     return true if data.between?(2384, 2431)
  336.  
  337.     return true if data.between?(2480, 2527)
  338.  
  339.     return true if data.between?(2576, 2623)
  340.  
  341.     return true if data.between?(2672, 2719)
  342.  
  343.     return true if data.between?(2768, 2815)
  344.  
  345.     return true if data.between?(4736, 5119)
  346.  
  347.     return true if data.between?(5504, 5887)
  348.  
  349.     return true if data.between?(6272, 6655)
  350.  
  351.     return true if data.between?(7040, 7423)
  352.  
  353.     return true if data > 7807
  354.  
  355.     false
  356.  
  357.   end
  358.  
  359.   #--------------------------------------------------------------------------
  360.  
  361.   # * Checks if a tile is roof
  362.  
  363.   #--------------------------------------------------------------------------
  364.  
  365.   def is_roof?(data)
  366.  
  367.     return true if data.between?(4352, 4735)
  368.  
  369.     return true if data.between?(5120, 5503)
  370.  
  371.     return true if data.between?(5888, 6271)
  372.  
  373.     return true if data.between?(6656, 7039)
  374.  
  375.     return true if data.between?(7424, 7807)
  376.  
  377.     false
  378.  
  379.   end  
  380.  
  381.   #--------------------------------------------------------------------------
  382.  
  383.   # * Checks if a tile is soil
  384.  
  385.   #--------------------------------------------------------------------------
  386.  
  387.   def is_soil?(data)
  388.  
  389.     return true if data.between?(2816, 4351) && !is_table?(data)
  390.  
  391.     return true if data > 1663 && !is_stair?(data)
  392.  
  393.     false
  394.  
  395.   end   
  396.  
  397.   #--------------------------------------------------------------------------
  398.  
  399.   # * Checks if a tile is a stair
  400.  
  401.   #--------------------------------------------------------------------------
  402.  
  403.   def is_stair?(data)
  404.  
  405.      return true if data.between?(1541, 1542)
  406.  
  407.      return true if data.between?(1549, 1550)
  408.  
  409.      return true if data.between?(1600, 1615)
  410.  
  411.      false
  412.  
  413.   end
  414.  
  415.   #--------------------------------------------------------------------------
  416.  
  417.   # * Checks if a tile is a table
  418.  
  419.   #--------------------------------------------------------------------------
  420.  
  421.   def is_table?(data)
  422.  
  423.     return true if data.between?(3152, 3199)
  424.  
  425.     return true if data.between?(3536, 3583)
  426.  
  427.     return true if data.between?(3920, 3967)
  428.  
  429.     return true if data.between?(4304, 4351)
  430.  
  431.     false
  432.  
  433.   end
  434.  
  435.  
  436.  
  437.   #--------------------------------------------------------------------------
  438.  
  439.   # * The tileset to be used
  440.  
  441.   #--------------------------------------------------------------------------
  442.  
  443.   def tileset
  444.  
  445.     $data_tilesets[@tileset_id]
  446.  
  447.   end
  448.  
  449.  
  450.  
  451.   #--------------------------------------------------------------------------
  452.  
  453.   # * Region ID
  454.  
  455.   #--------------------------------------------------------------------------
  456.  
  457.   def region_id(x, y)
  458.  
  459.     valid?(x, y) ? @map.data[x, y, 3] >> 8 : 0
  460.  
  461.   end
  462.  
  463.  
  464.  
  465.   #--------------------------------------------------------------------------
  466.  
  467.   # * Gets all of the tiles for each layer at position x,y
  468.  
  469.   #--------------------------------------------------------------------------
  470.  
  471.   def layered_tiles(x, y)
  472.  
  473.     [2, 1, 0].collect {|z| @map.data[x, y, z] }
  474.  
  475.   end
  476.  
  477.  
  478.  
  479.   def layered_tiles_flag?(x, y, bit)
  480.  
  481.     layered_tiles(x, y).any? {|tile_id| tileset.flags[tile_id] & bit != 0 }
  482.  
  483.   end
  484.  
  485.  
  486.  
  487.   def valid?(x, y)
  488.  
  489.     x >= 0 && x < width && y >= 0 && y < height
  490.  
  491.   end
  492.  
  493.  
  494.  
  495.   def damage_floor?(x, y)
  496.  
  497.     valid?(x, y) && layered_tiles_flag?(x, y, 0x100)
  498.  
  499.   end
  500.  
  501.  
  502.  
  503.   #--------------------------------------------------------------------------
  504.  
  505.   # * Specifies which type of autotile is used
  506.  
  507.   #--------------------------------------------------------------------------
  508.  
  509.   def auto_tile(id)
  510.  
  511.     id / 48
  512.  
  513.   end
  514.  
  515.  
  516.  
  517.   #--------------------------------------------------------------------------
  518.  
  519.   # * Specifies the specific arrangement of autotiles used
  520.  
  521.   #--------------------------------------------------------------------------
  522.  
  523.   def auto_index(id)
  524.  
  525.     id % 48
  526.  
  527.   end
  528.  
  529.  
  530.  
  531.   #--------------------------------------------------------------------------
  532.  
  533.   # * Put the auto-tile pieces together
  534.  
  535.   #--------------------------------------------------------------------------
  536.  
  537.   def make_autotile(rects, sx, sy)
  538.  
  539.     @tile.clear
  540.  
  541.     for i in 0...4
  542.  
  543.       @auto_rect.x = (rects[i] % 4) * 16 + sx
  544.  
  545.       @auto_rect.y = (rects[i] / 4) * 16 + sy
  546.  
  547.       @tile.blt((i % 2) * 16,(i / 2) * 16, @tilemap, @auto_rect)
  548.  
  549.     end
  550.  
  551.   end
  552.  
  553.  
  554.  
  555.   #--------------------------------------------------------------------------
  556.  
  557.   # * Get auto-tile A1 tiles
  558.  
  559.   #--------------------------------------------------------------------------
  560.  
  561.   def autotile_A1(tile_id)
  562.  
  563.     @tilemap = @bitmaps[0]
  564.  
  565.     autotile = tile_id / 48
  566.  
  567.     auto_id = tile_id % 48
  568.  
  569.     sx, sy = A1_TILES[autotile]
  570.  
  571.     if is_wall?(tile_id + 2048)
  572.  
  573.       rects = WATERFALL_PIECES[auto_id]
  574.  
  575.     else  
  576.  
  577.       rects = AUTOTILE_PARTS[auto_id]
  578.  
  579.     end
  580.  
  581.     make_autotile(rects, sx, sy)
  582.  
  583.   end
  584.  
  585.  
  586.  
  587.   #--------------------------------------------------------------------------
  588.  
  589.   # * Get auto-tile A2 tiles.
  590.  
  591.   # 64x96 tiles, 8 per row, 4 rows
  592.  
  593.   #--------------------------------------------------------------------------
  594.  
  595.   def autotile_A2(tile_id)
  596.  
  597.     autotile = tile_id / 48
  598.  
  599.     auto_id = tile_id % 48
  600.  
  601.     @tilemap = @bitmaps[1]
  602.  
  603.     sx = (autotile % 8) * 64
  604.  
  605.     sy = (autotile / 8 % 4) * 96
  606.  
  607.     rects = AUTOTILE_PARTS[auto_id]
  608.  
  609.     make_autotile(rects, sx, sy)
  610.  
  611.   end
  612.  
  613.  
  614.  
  615.   #--------------------------------------------------------------------------
  616.  
  617.   # * Get auto-tile A3 tiles.
  618.  
  619.   # 64x64 tiles, 8 per row, 4 rows
  620.  
  621.   #--------------------------------------------------------------------------
  622.  
  623.   def autotile_A3(tid)
  624.  
  625.     @tilemap = @bitmaps[2]
  626.  
  627.     sx = (auto_tile(tid) % 8) * 64
  628.  
  629.     sy = (auto_tile(tid) / 8 % 4) * 64
  630.  
  631.     rects = WALL_PIECES[auto_index(tid)]
  632.  
  633.     make_autotile(rects, sx, sy)
  634.  
  635.   end
  636.  
  637.  
  638.  
  639.   #--------------------------------------------------------------------------
  640.  
  641.   # * Get auto-tile A4 tiles (walls)
  642.  
  643.   #--------------------------------------------------------------------------
  644.  
  645.   def autotile_A4(tile_id)
  646.  
  647.     @tilemap = @bitmaps[3]
  648.  
  649.     autotile = tile_id / 48
  650.  
  651.     auto_id = tile_id % 48
  652.  
  653.     sx = (autotile % 8) * 64
  654.  
  655.     sy = (autotile / 16 * 160) + (autotile / 8 % 2) * 96
  656.  
  657.     if is_wall?(tile_id + 5888)
  658.  
  659.       rects = WALL_PIECES[auto_id]
  660.  
  661.     else
  662.  
  663.       rects = AUTOTILE_PARTS[auto_id]
  664.  
  665.     end
  666.  
  667.     make_autotile(rects, sx, sy)
  668.  
  669.   end
  670.  
  671.  
  672.  
  673.   #--------------------------------------------------------------------------
  674.  
  675.   # * Get auto-tile A5 tiles (normal)
  676.  
  677.   #--------------------------------------------------------------------------
  678.  
  679.   def autotile_A5(tile_id)
  680.  
  681.     @tilemap = @bitmaps[4]
  682.  
  683.     sx = (tile_id) % 8 * tilesize
  684.  
  685.     sy = (tile_id) / 8 * tilesize
  686.  
  687.     @src_rect.set(sx, sy, tilesize, tilesize)
  688.  
  689.     @tile.clear
  690.  
  691.     @tile.blt(0, 0, @tilemap, @src_rect)
  692.  
  693.   end
  694.  
  695.  
  696.  
  697.   #--------------------------------------------------------------------------
  698.  
  699.   # * Get normal tiles B, C, D, E
  700.  
  701.   #--------------------------------------------------------------------------
  702.  
  703.   def normal_tile(tile_id)
  704.  
  705.     @tilemap = @bitmaps[5 + tile_id / 256]
  706.  
  707.     sx = (tile_id / 128 % 2 * 8 + tile_id % 8) * tilesize;
  708.  
  709.     sy = (tile_id % 256 / 8 % 16) * tilesize;
  710.  
  711.     @src_rect.set(sx, sy, tilesize, tilesize)
  712.  
  713.     @tile.clear
  714.  
  715.     @tile.blt(0, 0, @tilemap, @src_rect)
  716.  
  717.   end
  718.  
  719.  
  720.  
  721.   #--------------------------------------------------------------------------
  722.  
  723.   # * Get bitmap for the specified tile id
  724.  
  725.   #--------------------------------------------------------------------------
  726.  
  727.   def get_bitmap(id)
  728.  
  729.     if id < 1024
  730.  
  731.       normal_tile(id)
  732.  
  733.     elsif id < 1664
  734.  
  735.       autotile_A5(id - 1536)
  736.  
  737.     elsif id < 2816
  738.  
  739.       autotile_A1(id - 2048)
  740.  
  741.     elsif id < 4352
  742.  
  743.       autotile_A2(id - 2816)
  744.  
  745.     elsif id < 5888
  746.  
  747.       autotile_A3(id - 4352)
  748.  
  749.     else
  750.  
  751.       autotile_A4(id - 5888)
  752.  
  753.     end
  754.  
  755.   end
  756.  
  757. end
  758.  
  759.  
  760.  
  761. #==============================================================================
  762.  
  763. # **
  764.  
  765. #==============================================================================
  766.  
  767.  
  768.  
  769. class Game_Player < Game_Character
  770.  
  771.  
  772.  
  773.   alias :th_mapsaver_update :update
  774.  
  775.   def update
  776.  
  777.     th_mapsaver_update
  778.  
  779.     if Input.trigger?(TH::Map_Saver::Mapshot_Button)
  780.  
  781.       s = Map_Saver.new($game_map.map_id)
  782.  
  783.       s.set_scale(TH::Map_Saver::Mapshot_Scale)
  784.  
  785.       s.mapshot
  786.  
  787.     end
  788.  
  789.     if Input.trigger?(TH::Map_Saver::Screenshot_Button)
  790.  
  791.       s = Map_Saver.new($game_map.map_id)
  792.  
  793.       s.set_scale(TH::Map_Saver::Screenshot_Scale)
  794.  
  795.       s.screenshot
  796.  
  797.     end
  798.  
  799.   end
  800.  
  801. end
  802.  
  803.  
  804.  
  805. class Game_Vehicle < Game_Character
  806.  
  807.   attr_reader :map_id
  808.  
  809. end
  810.  
  811.  
  812.  
  813. class Game_Map
  814.  
  815.   attr_reader :map
  816.  
  817. end
  818.  
  819.  
  820.  
  821. #==============================================================================
  822.  
  823. # **
  824.  
  825. #==============================================================================
  826.  
  827.  
  828.  
  829. class Map_Saver
  830.  
  831.   include TH::Map_Saver
  832.  
  833.   include Map_Tiles
  834.  
  835.   #--------------------------------------------------------------------------
  836.  
  837.   # * Constants
  838.  
  839.   #--------------------------------------------------------------------------
  840.  
  841.  
  842.  
  843.   SHADOW_COLOR = TH::Map_Saver::Shadow_Color
  844.  
  845.   DAMAGE_COLOR = TH::Map_Saver::Damage_Color
  846.  
  847.  
  848.  
  849.   #--------------------------------------------------------------------------
  850.  
  851.   # * Public instance variables
  852.  
  853.   #--------------------------------------------------------------------------
  854.  
  855.   attr_reader :map_image
  856.  
  857.  
  858.  
  859.   def initialize(map_id=$game_map.map_id, x=$game_player.x, y=$game_player.y)
  860.  
  861.     @scale = 1
  862.  
  863.     @local_x = x
  864.  
  865.     @local_y = y
  866.  
  867.     @screen_local = false
  868.  
  869.     @shadow_bitmap = Bitmap.new(128, 128)
  870.  
  871.     @draw_layer0 = true
  872.  
  873.     @draw_layer1 = true
  874.  
  875.     @draw_layer2 = true
  876.  
  877.     @draw_events = Draw_Events
  878.  
  879.     @draw_vehicles = Draw_Vehicles
  880.  
  881.     @draw_player = Draw_Player
  882.  
  883.     @draw_followers = Draw_Followers
  884.  
  885.     @draw_shadow = Draw_Shadow
  886.  
  887.     @draw_damage = Highlight_Damage
  888.  
  889.     @draw_regions = Draw_Regions
  890.  
  891.     @draw_passages = Draw_Passages
  892.  
  893.     @tile = Bitmap.new(32, 32) #stores the current tile to be drawn
  894.  
  895.     @tilemap = nil
  896.  
  897.     @src_rect = Rect.new
  898.  
  899.     @auto_rect = Rect.new(0, 0, tilesize / 2, tilesize/ 2) #constant
  900.  
  901.     @tile_rect = Rect.new(0, 0, tilesize, tilesize)        #constant
  902.  
  903.   end
  904.  
  905.  
  906.  
  907.   def load_tilesets
  908.  
  909.     bitmaps = []
  910.  
  911.     tileset.tileset_names.each_with_index do |name, i|
  912.  
  913.       bitmaps[i] = Cache.tileset(name)
  914.  
  915.     end
  916.  
  917.     return bitmaps
  918.  
  919.   end
  920.  
  921.  
  922.  
  923.   #--------------------------------------------------------------------------
  924.  
  925.   # * Refresh, possibly with a new map
  926.  
  927.   #--------------------------------------------------------------------------
  928.  
  929.   def redraw(map_id=$game_map.map_id, x=$game_player.x, y=$game_player.y)
  930.  
  931.     @map_image.dispose if @map_image
  932.  
  933.     @map_id = map_id
  934.  
  935.     @local_x = x
  936.  
  937.     @local_y = y
  938.  
  939.     @game_map = Game_Map.new
  940.  
  941.     @game_map.setup(map_id)
  942.  
  943.     @map = @game_map.map
  944.  
  945.     @map_info = $data_mapinfos[map_id]
  946.  
  947.     @screen = $game_map.screen
  948.  
  949.     @tileset_id = @game_map.tileset.id
  950.  
  951.     @bitmaps = load_tilesets
  952.  
  953.  
  954.  
  955.     get_bounds
  956.  
  957.     @map_image = Bitmap.new(@width * tilesize, [url=home.php?mod=space&uid=291977]@height[/url] * tilesize)
  958.  
  959.     draw_map
  960.  
  961.     scale_map if @scale != 1
  962.  
  963.   end
  964.  
  965.  
  966.  
  967.   #--------------------------------------------------------------------------
  968.  
  969.   # * Pre-process. These will never change when drawing the map.
  970.  
  971.   #--------------------------------------------------------------------------
  972.  
  973.   def get_bounds
  974.  
  975.     @start_x = start_x
  976.  
  977.     @start_y = start_y
  978.  
  979.     @end_x = end_x
  980.  
  981.     @end_y = end_y
  982.  
  983.     @width = width
  984.  
  985.     @height = height
  986.  
  987.     @tilesize = tilesize
  988.  
  989.   end
  990.  
  991.  
  992.  
  993.   def screen_tile_x
  994.  
  995.     Graphics.width / 32
  996.  
  997.   end
  998.  
  999.  
  1000.  
  1001.   def screen_tile_y
  1002.  
  1003.     Graphics.height / 32
  1004.  
  1005.   end
  1006.  
  1007.  
  1008.  
  1009.   #--------------------------------------------------------------------------
  1010.  
  1011.   # * Sets the scale for the map
  1012.  
  1013.   #--------------------------------------------------------------------------
  1014.  
  1015.   def set_scale(scale)
  1016.  
  1017.     @scale = scale
  1018.  
  1019.   end
  1020.  
  1021.  
  1022.  
  1023.   #--------------------------------------------------------------------------
  1024.  
  1025.   # * Size of a tile
  1026.  
  1027.   #--------------------------------------------------------------------------
  1028.  
  1029.   def tilesize
  1030.  
  1031.     32
  1032.  
  1033.   end
  1034.  
  1035.  
  1036.  
  1037.   #--------------------------------------------------------------------------
  1038.  
  1039.   # * Width and height of the map, both locally and globally
  1040.  
  1041.   #--------------------------------------------------------------------------
  1042.  
  1043.   def width
  1044.  
  1045.     end_x - @start_x
  1046.  
  1047.   end
  1048.  
  1049.  
  1050.  
  1051.   def height
  1052.  
  1053.     end_y - @start_y
  1054.  
  1055.   end
  1056.  
  1057.  
  1058.  
  1059.   #--------------------------------------------------------------------------
  1060.  
  1061.   # * Starting and end positions, relative to the screen or map
  1062.  
  1063.   #--------------------------------------------------------------------------
  1064.  
  1065.   def start_x
  1066.  
  1067.     @screen_local ? [[$game_player.x - screen_tile_x / 2, @map.width - screen_tile_x].min, 0].max : 0
  1068.  
  1069.   end
  1070.  
  1071.  
  1072.  
  1073.   def start_y
  1074.  
  1075.     @screen_local ? [[$game_player.y - screen_tile_y / 2, @map.height - screen_tile_y].min, 0].max : 0
  1076.  
  1077.   end
  1078.  
  1079.  
  1080.  
  1081.   def end_x
  1082.  
  1083.     @screen_local ? [[screen_tile_x, @local_x + screen_tile_x / 2 + 1].max, @map.width].min : @map.width
  1084.  
  1085.   end
  1086.  
  1087.  
  1088.  
  1089.   def end_y
  1090.  
  1091.     @screen_local ? [[screen_tile_y, @local_y + screen_tile_y / 2 + 1].max, @map.height].min : @map.height
  1092.  
  1093.   end
  1094.  
  1095.  
  1096.  
  1097.   #--------------------------------------------------------------------------
  1098.  
  1099.   # * Draw tile onto image. x and y values are absolute coords. They should
  1100.  
  1101.   # be re-mapped based on the start_x and start_y values
  1102.  
  1103.   #--------------------------------------------------------------------------
  1104.  
  1105.   def draw_tile(x, y, tile, rect)
  1106.  
  1107.     ox = (x - @start_x) * tilesize
  1108.  
  1109.     oy = (y - @start_y) * tilesize
  1110.  
  1111.     @map_image.blt(ox, oy, tile, rect)
  1112.  
  1113.   end
  1114.  
  1115.  
  1116.  
  1117.   #--------------------------------------------------------------------------
  1118.  
  1119.   # * Get bitmap for the specified character
  1120.  
  1121.   #--------------------------------------------------------------------------
  1122.  
  1123.   def get_character_bitmap(name)
  1124.  
  1125.     charmap = Cache.character(name)
  1126.  
  1127.     sign = name[/^[\!\$]./]
  1128.  
  1129.     if sign && sign.include?('$')
  1130.  
  1131.       cw = charmap.width / 3
  1132.  
  1133.       ch = charmap.height / 4
  1134.  
  1135.     else
  1136.  
  1137.       cw = charmap.width / 12
  1138.  
  1139.       ch = charmap.height / 8
  1140.  
  1141.     end
  1142.  
  1143.     return charmap, cw, ch
  1144.  
  1145.   end
  1146.  
  1147.  
  1148.  
  1149.   #--------------------------------------------------------------------------
  1150.  
  1151.   # * Draw the character onto the tile
  1152.  
  1153.   #--------------------------------------------------------------------------
  1154.  
  1155.   def set_character_bitmap(character, x, y)
  1156.  
  1157.     charmap, cw, ch = get_character_bitmap(character.character_name)
  1158.  
  1159.     index = character.character_index
  1160.  
  1161.     pattern = character.pattern < 3 ? character.pattern : 1
  1162.  
  1163.     sx = (index % 4 * 3 + pattern) * cw
  1164.  
  1165.     sy = (index / 4 * 4 + (character.direction - 2) / 2) * ch
  1166.  
  1167.     @src_rect.set(sx, sy, cw, ch)
  1168.  
  1169.     x -= cw / (@tilesize * 2) if cw >= @tilesize
  1170.  
  1171.     y -= ch / (@tilesize * 2) if ch >= @tilesize  
  1172.  
  1173.     draw_tile(x, y, charmap, @src_rect)
  1174.  
  1175.   end
  1176.  
  1177.  
  1178.  
  1179.   #--------------------------------------------------------------------------
  1180.  
  1181.   # * create the shadow map
  1182.  
  1183.   #--------------------------------------------------------------------------
  1184.  
  1185.   def make_shadow_map
  1186.  
  1187.     for s in 0 ... 16
  1188.  
  1189.       x = s % 4
  1190.  
  1191.       y = s / 4
  1192.  
  1193.       if s & 0b1000 == 0b1000
  1194.  
  1195.         @shadow_bitmap.fill_rect(x*tilesize+16, y*@tilesize+16, 16, 16, SHADOW_COLOR)
  1196.  
  1197.       end
  1198.  
  1199.       if s & 0b0100 == 0b0100
  1200.  
  1201.         @shadow_bitmap.fill_rect(x*tilesize, y*@tilesize+16, 16, 16, SHADOW_COLOR)
  1202.  
  1203.       end
  1204.  
  1205.       if s & 0b0010 == 0b0010
  1206.  
  1207.         @shadow_bitmap.fill_rect(x*tilesize+16, y*@tilesize, 16, 16, SHADOW_COLOR)
  1208.  
  1209.       end
  1210.  
  1211.       if s & 0b0001 == 0b0001
  1212.  
  1213.         @shadow_bitmap.fill_rect(x*tilesize, y*@tilesize, 16, 16, SHADOW_COLOR)
  1214.  
  1215.       end
  1216.  
  1217.     end
  1218.  
  1219.   end
  1220.  
  1221.  
  1222.  
  1223.   def draw_parallax
  1224.  
  1225.     image = Cache.parallax(@map.parallax_name)
  1226.  
  1227.     @src_rect.set(0, 0, image.width, image.height)
  1228.  
  1229.     @map_image.blt(0, 0, image, @src_rect)
  1230.  
  1231.   end
  1232.  
  1233.  
  1234.  
  1235.   #--------------------------------------------------------------------------
  1236.  
  1237.   # * Draw the shadow map
  1238.  
  1239.   #--------------------------------------------------------------------------
  1240.  
  1241.   def draw_shadow_map
  1242.  
  1243.     for x in @start_x ... @end_x
  1244.  
  1245.       for y in @start_y ... @end_y
  1246.  
  1247.       _x, _y = x*@tilesize, y*@tilesize
  1248.  
  1249.         s = @map.data[x, y, 3]  & 0b1111
  1250.  
  1251.         if s != 0
  1252.  
  1253.           x_ = (s % 4) * @tilesize
  1254.  
  1255.           y_ = (s / 4) * @tilesize
  1256.  
  1257.           @src_rect.set(x_, y_, @tilesize, @tilesize)
  1258.  
  1259.           draw_tile(x, y, @shadow_bitmap, @src_rect)
  1260.  
  1261.         end
  1262.  
  1263.       end
  1264.  
  1265.     end
  1266.  
  1267.   end
  1268.  
  1269.  
  1270.  
  1271.   #--------------------------------------------------------------------------
  1272.  
  1273.   # * Draw the specified layer
  1274.  
  1275.   #--------------------------------------------------------------------------
  1276.  
  1277.   def draw_layer(layer)
  1278.  
  1279.     for x in @start_x ... @end_x
  1280.  
  1281.       for y in @start_y ... @end_y
  1282.  
  1283.         _x, _y = x*@tilesize, y*@tilesize
  1284.  
  1285.         tile_id = @map.data[x, y, layer]
  1286.  
  1287.         next if tile_id == 0
  1288.  
  1289.         get_bitmap(tile_id)
  1290.  
  1291.         draw_tile(x, y, @tile, @tile_rect)
  1292.  
  1293.       end
  1294.  
  1295.     end
  1296.  
  1297.   end
  1298.  
  1299.  
  1300.  
  1301.   #-----------------------------------------------------------------------------
  1302.  
  1303.   # Draw game regions
  1304.  
  1305.   #-----------------------------------------------------------------------------
  1306.  
  1307.   def draw_regions
  1308.  
  1309.     if $imported["TH_RegionOverlay"]
  1310.  
  1311.       image = SceneManager.scene.instance_variable_get(:@spriteset).instance_variable_get(:@region_map).bitmap
  1312.  
  1313.       @src_rect.set(@start_x * tilesize, @start_y * tilesize, image.width, image.height)
  1314.  
  1315.       @map_image.blt(0, 0, image, @src_rect, 255)
  1316.  
  1317.     end
  1318.  
  1319.   end
  1320.  
  1321.  
  1322.  
  1323.   def draw_passages
  1324.  
  1325.     if $imported["TH_OverlayPassageMap"]
  1326.  
  1327.       image = SceneManager.scene.instance_variable_get(:@spriteset).instance_variable_get(:@passage_map).bitmap
  1328.  
  1329.       @src_rect.set(@start_x * tilesize, @start_y * tilesize, image.width, image.height)
  1330.  
  1331.       @map_image.blt(0, 0, image, @src_rect, 255)
  1332.  
  1333.     end
  1334.  
  1335.   end
  1336.  
  1337.  
  1338.  
  1339.   #--------------------------------------------------------------------------
  1340.  
  1341.   # * Draw the game player
  1342.  
  1343.   #--------------------------------------------------------------------------
  1344.  
  1345.   def draw_player
  1346.  
  1347.     set_character_bitmap($game_player, $game_player.x, $game_player.y) if @map_id == $game_map.map_id
  1348.  
  1349.   end
  1350.  
  1351.  
  1352.  
  1353.   def draw_followers
  1354.  
  1355.   end
  1356.  
  1357.  
  1358.  
  1359.   #--------------------------------------------------------------------------
  1360.  
  1361.   # * Draw map events
  1362.  
  1363.   #--------------------------------------------------------------------------
  1364.  
  1365.   def draw_events
  1366.  
  1367.     @map.events.values.each do |event|
  1368.  
  1369.       id = event.pages[0].graphic.tile_id
  1370.  
  1371.       char_name = event.pages[0].graphic.character_name
  1372.  
  1373.       if id > 0
  1374.  
  1375.         normal_tile(id)
  1376.  
  1377.         draw_tile(event.x, event.y, @tilemap, @src_rect)
  1378.  
  1379.       elsif char_name != ""
  1380.  
  1381.         set_character_bitmap(event.pages[0].graphic, event.x, event.y)
  1382.  
  1383.       end
  1384.  
  1385.     end
  1386.  
  1387.   end
  1388.  
  1389.  
  1390.  
  1391.   #--------------------------------------------------------------------------
  1392.  
  1393.   # * Draw map vehicles
  1394.  
  1395.   #--------------------------------------------------------------------------
  1396.  
  1397.   def draw_vehicles
  1398.  
  1399.     $game_map.vehicles.each do |vehicle|
  1400.  
  1401.       set_character_bitmap(vehicle, vehicle.x, vehicle.y,) if @map_id == vehicle.map_id
  1402.  
  1403.     end
  1404.  
  1405.   end
  1406.  
  1407.  
  1408.  
  1409.   #--------------------------------------------------------------------------
  1410.  
  1411.   # * Draw map sprites
  1412.  
  1413.   #--------------------------------------------------------------------------
  1414.  
  1415.   def draw_sprites
  1416.  
  1417.     draw_events if @draw_events
  1418.  
  1419.     draw_vehicles if @draw_vehicles
  1420.  
  1421.     draw_player if @draw_player
  1422.  
  1423.     draw_followers if @draw_followers
  1424.  
  1425.   end
  1426.  
  1427.  
  1428.  
  1429.   #--------------------------------------------------------------------------
  1430.  
  1431.   # * Highlight damage tiles
  1432.  
  1433.   #--------------------------------------------------------------------------
  1434.  
  1435.   def draw_damage
  1436.  
  1437.     @tile.clear
  1438.  
  1439.     @tile.fill_rect(0, 0, @tilesize, @tilesize, DAMAGE_COLOR)
  1440.  
  1441.     @src_rect.set(0, 0, @tilesize, @tilesize)
  1442.  
  1443.     for x in @start_x ... @end_x
  1444.  
  1445.       for y in @start_y ... @end_y
  1446.  
  1447.         _x, _y = x*@tilesize, y*@tilesize
  1448.  
  1449.         if damage_floor?(x, y)
  1450.  
  1451.           draw_tile(x, y, @tile, @src_rect)
  1452.  
  1453.         end
  1454.  
  1455.       end
  1456.  
  1457.     end
  1458.  
  1459.   end
  1460.  
  1461.  
  1462.  
  1463.   def draw_screen_effects
  1464.  
  1465.   end
  1466.  
  1467.   #--------------------------------------------------------------------------
  1468.  
  1469.   # * Draw the map
  1470.  
  1471.   #--------------------------------------------------------------------------
  1472.  
  1473.   def draw_map
  1474.  
  1475.     make_shadow_map if @draw_shadow
  1476.  
  1477.     draw_parallax
  1478.  
  1479.     draw_layer(0)
  1480.  
  1481.     draw_layer(1)
  1482.  
  1483.     draw_shadow_map
  1484.  
  1485.     draw_layer(2)
  1486.  
  1487.     draw_damage if @draw_damage
  1488.  
  1489.     draw_regions if @draw_regions
  1490.  
  1491.     draw_passages if @draw_passages
  1492.  
  1493.     draw_sprites
  1494.  
  1495.     draw_screen_effects
  1496.  
  1497.   end
  1498.  
  1499.  
  1500.  
  1501.   #--------------------------------------------------------------------------
  1502.  
  1503.   # * Scale the map
  1504.  
  1505.   #--------------------------------------------------------------------------
  1506.  
  1507.   def scale_map
  1508.  
  1509.     nw = @width * @scale
  1510.  
  1511.     nh = @height * @scale
  1512.  
  1513.     @src_rect.set(0, 0, @width, @height)
  1514.  
  1515.     scaled_map = Bitmap.new(nw, nh)
  1516.  
  1517.     scaled_rect = Rect.new(0, 0, nw, nh)
  1518.  
  1519.     scaled_map.stretch_blt(scaled_rect, @map_image, @src_rect)
  1520.  
  1521.     @map_image = scaled_map
  1522.  
  1523.   end
  1524.  
  1525.  
  1526.  
  1527.   #--------------------------------------------------------------------------
  1528.  
  1529.   # * Take a mapshot of the map
  1530.  
  1531.   #--------------------------------------------------------------------------
  1532.  
  1533.   def mapshot
  1534.  
  1535.     @screen_local = false
  1536.  
  1537.     redraw
  1538.  
  1539.     export(TH::Map_Saver::Mapshot_Directory)
  1540.  
  1541.     $game_message.add("Mapshot taken")
  1542.  
  1543.   end
  1544.  
  1545.  
  1546.  
  1547.   #--------------------------------------------------------------------------
  1548.  
  1549.   # * Take a screenshot of the map
  1550.  
  1551.   #--------------------------------------------------------------------------
  1552.  
  1553.   def screenshot
  1554.  
  1555.     @screen_local = true
  1556.  
  1557.     redraw
  1558.  
  1559.     export(TH::Map_Saver::Screenshot_Directory)
  1560.  
  1561.     $game_message.add("Screenshot taken")
  1562.  
  1563.   end
  1564.  
  1565.  
  1566.  
  1567.   #--------------------------------------------------------------------------
  1568.  
  1569.   # * Get the format to export to
  1570.  
  1571.   #--------------------------------------------------------------------------
  1572.  
  1573.   def get_format
  1574.  
  1575.     TH::Map_Saver::Export_Format
  1576.  
  1577.   end
  1578.  
  1579.  
  1580.  
  1581.   #--------------------------------------------------------------------------
  1582.  
  1583.   # * Export the map to a file
  1584.  
  1585.   #--------------------------------------------------------------------------
  1586.  
  1587.   def export(dirName="")
  1588.  
  1589.     format = get_format
  1590.  
  1591.     name = @map.display_name != "" ? @map.display_name : @map_info.name
  1592.  
  1593.     Dir.mkdir(dirName) unless File.directory?(dirName)
  1594.  
  1595.     filename = "%s\\%s.%s" %[dirName, name, format]
  1596.  
  1597.     t1 = Time.now
  1598.  
  1599.     @map_image.save(filename)
  1600.  
  1601.     t2 = Time.now
  1602.  
  1603.     $game_message.add("Exported in %f seconds" %[t2 - t1])
  1604.  
  1605.   end
  1606.  
  1607. end
  1608.  
  1609.  
  1610.  
  1611. class Bitmap
  1612.  
  1613.  
  1614.  
  1615.   def save(filename, options = {})
  1616.  
  1617.     options.merge!(format: File.extname(filename)[1..-1].to_sym)
  1618.  
  1619.     retval = false
  1620.  
  1621.     #bitmap = Gdiplus::Bitmap.new(:hbitmap, hbitmap)
  1622.  
  1623.     #bitmap = Gdiplus::Bitmap.new(:gdidib, *gdidib)
  1624.  
  1625.     # this seems to be the fastest one (RGSS 3.0.1, Windows 8 64-bit)
  1626.  
  1627.     bitmap = Gdiplus::Bitmap.new(:scan0, width, height, scan0)
  1628.  
  1629.     if bitmap
  1630.  
  1631.       retval = bitmap.save(:file, filename, options[:format])
  1632.  
  1633.       bitmap.dispose
  1634.  
  1635.     end
  1636.  
  1637.     retval
  1638.  
  1639.   end
  1640.  
  1641.  
  1642.  
  1643. private
  1644.  
  1645.  
  1646.  
  1647.   def _data_struct(offset = 0)
  1648.  
  1649.     @_data_struct ||= (DL::CPtr.new((object_id << 1) + 16).ptr + 8).ptr
  1650.  
  1651.     (@_data_struct + offset).ptr.to_i
  1652.  
  1653.   end
  1654.  
  1655.  
  1656.  
  1657.   def gdidib
  1658.  
  1659.      [_data_struct(8), _data_struct(16)]
  1660.  
  1661.   end
  1662.  
  1663.  
  1664.  
  1665.   def hbitmap
  1666.  
  1667.     _data_struct(44)
  1668.  
  1669.   end
  1670.  
  1671.  
  1672.  
  1673.   def scan0
  1674.  
  1675.     _data_struct(12)
  1676.  
  1677.   end
  1678.  
  1679.  
  1680.  
  1681. end
  1682.  
  1683.  
  1684.  
  1685. # ★ GDI+ interface
  1686.  
  1687. # ★★★★★★★★★★★★
  1688.  
  1689. #
  1690.  
  1691. # Author : Cremno
  1692.  
  1693. #
  1694.  
  1695.  
  1696.  
  1697. module Gdiplus
  1698.  
  1699.   DLL = 'gdiplus.dll'
  1700.  
  1701.  
  1702.  
  1703.   def self.get_function name, import, export = 'L'
  1704.  
  1705.     Win32API.new DLL, name, import, export
  1706.  
  1707.   end
  1708.  
  1709.  
  1710.  
  1711.   FUNCTIONS = {
  1712.  
  1713.     GdiplusStartup: get_function('GdiplusStartup', 'PPP'),
  1714.  
  1715.     GdiplusShutdown: get_function('GdiplusShutdown', 'P', 'V'),
  1716.  
  1717.     GdipDisposeImage: get_function('GdipDisposeImage', 'P'),
  1718.  
  1719.     GdipSaveImageToFile: get_function('GdipSaveImageToFile', 'PPPP'),
  1720.  
  1721.     GdipCreateBitmapFromGdiDib: get_function('GdipCreateBitmapFromGdiDib', 'LLP'),
  1722.  
  1723.     GdipCreateBitmapFromHBITMAP: get_function('GdipCreateBitmapFromHBITMAP', 'LLP'),
  1724.  
  1725.     GdipCreateBitmapFromScan0: get_function('GdipCreateBitmapFromScan0', 'LLLLPP')
  1726.  
  1727.   }
  1728.  
  1729.  
  1730.  
  1731.   @@token = [0].pack('I')
  1732.  
  1733.   def self.token
  1734.  
  1735.     @@token
  1736.  
  1737.   end
  1738.  
  1739.  
  1740.  
  1741.   @@clsids = {}
  1742.  
  1743.   def self.clsids
  1744.  
  1745.     @@clsids
  1746.  
  1747.   end
  1748.  
  1749.  
  1750.  
  1751.   def self.gen_clsids
  1752.  
  1753.     return unless @@clsids.empty?
  1754.  
  1755.     func = Win32API.new('rpcrt4.dll', 'UuidFromString', 'PP', 'L')
  1756.  
  1757.     {
  1758.  
  1759.       bmp:  '557cf400-1a04-11d3-9a73-0000f81ef32e',
  1760.  
  1761.       jpeg: '557cf401-1a04-11d3-9a73-0000f81ef32e',
  1762.  
  1763.       gif:  '557cf402-1a04-11d3-9a73-0000f81ef32e',
  1764.  
  1765.       tiff: '557cf405-1a04-11d3-9a73-0000f81ef32e',
  1766.  
  1767.       png:  '557cf406-1a04-11d3-9a73-0000f81ef32e'
  1768.  
  1769.     }.each_pair do |k, v|
  1770.  
  1771.       clsid = [0].pack('I')
  1772.  
  1773.       func.call(v, clsid)
  1774.  
  1775.       @@clsids[k] = clsid
  1776.  
  1777.     end
  1778.  
  1779.     @@clsids[:jpg] = @@clsids[:jpeg]
  1780.  
  1781.     @@clsids[:tif] = @@clsids[:tiff]
  1782.  
  1783.   end
  1784.  
  1785.  
  1786.  
  1787.   # TODO: prepend prefix (Gdip or Gdiplus) automatically
  1788.  
  1789.   def self.call(*args)
  1790.  
  1791.     name = args.shift
  1792.  
  1793.     func = FUNCTIONS[name]
  1794.  
  1795.     v = func.call(*args)
  1796.  
  1797.     if v && v != 0
  1798.  
  1799.       msgbox "GDI+ error: #{v}\n\nFunction: #{name}\nArguments: #{args.inspect}"
  1800.  
  1801.       false
  1802.  
  1803.     else
  1804.  
  1805.       true
  1806.  
  1807.     end
  1808.  
  1809.   end
  1810.  
  1811.  
  1812.  
  1813.   def self.startup
  1814.  
  1815.     call :GdiplusStartup, @@token, [1, 0, 0, 0].pack('L4'), 0
  1816.  
  1817.   end
  1818.  
  1819.  
  1820.  
  1821.   def self.shutdown
  1822.  
  1823.     call :GdiplusShutdown, @@token
  1824.  
  1825.   end
  1826.  
  1827.  
  1828.  
  1829.   class Image
  1830.  
  1831.  
  1832.  
  1833.     attr_reader :instance
  1834.  
  1835.     def initialize
  1836.  
  1837.       @instance = 0
  1838.  
  1839.       true
  1840.  
  1841.     end
  1842.  
  1843.  
  1844.  
  1845.     def save(destination, *args)
  1846.  
  1847.       case destination
  1848.  
  1849.       when :file
  1850.  
  1851.         filename = args.shift << "\0"
  1852.  
  1853.         filename.encode!('UTF-16LE')
  1854.  
  1855.         argv = [:GdipSaveImageToFile, filename, Gdiplus.clsids[args.shift], 0]
  1856.  
  1857.       else
  1858.  
  1859.         raise ArgumentError, "unknown GDI+ image destination: #{source}"
  1860.  
  1861.       end
  1862.  
  1863.       argv.insert(1, @instance)
  1864.  
  1865.       Gdiplus.call *argv
  1866.  
  1867.     end
  1868.  
  1869.  
  1870.  
  1871.     def dispose
  1872.  
  1873.       Gdiplus.call :GdipDisposeImage, @instance
  1874.  
  1875.     end
  1876.  
  1877.   end
  1878.  
  1879.  
  1880.  
  1881.   class Bitmap < Image
  1882.  
  1883.  
  1884.  
  1885.     def initialize source, *args
  1886.  
  1887.       case source
  1888.  
  1889.       when :gdidib
  1890.  
  1891.         argv = [:GdipCreateBitmapFromGdiDib, args.shift, args.shift]
  1892.  
  1893.       when :hbitmap
  1894.  
  1895.         argv = [:GdipCreateBitmapFromHBITMAP, args.shift, 0]
  1896.  
  1897.       when :scan0
  1898.  
  1899.         w = args.shift
  1900.  
  1901.         h = args.shift
  1902.  
  1903.         argv = [:GdipCreateBitmapFromScan0, w, h, w * -4, 0x26200a, args.shift]
  1904.  
  1905.       else
  1906.  
  1907.         raise ArgumentError, "unknown GDI+ bitmap source: #{source}"
  1908.  
  1909.       end
  1910.  
  1911.       argv.push([0].pack('I'))
  1912.  
  1913.       retval = Gdiplus.call *argv
  1914.  
  1915.       @instance = retval ? argv.last.unpack('I').first : 0
  1916.  
  1917.       retval
  1918.  
  1919.     end
  1920.  
  1921.   end
  1922.  
  1923. end
  1924.  
  1925.  
  1926.  
  1927. if Gdiplus.startup
  1928.  
  1929.   Gdiplus.gen_clsids
  1930.  
  1931.   class << SceneManager
  1932.  
  1933.     alias_method :run_wo_gdip_shutdown, :run
  1934.  
  1935.     def run
  1936.  
  1937.       run_wo_gdip_shutdown
  1938.  
  1939.       Gdiplus.shutdown
  1940.  
  1941.     end
  1942.  
  1943.   end
  1944.  
  1945. end
  1946.  
  1947.  
  1948.  
  1949. #==============================================================================
  1950.  
  1951. # * Compatibility add-ons
  1952.  
  1953. #==============================================================================
  1954.  
  1955. #Yami overlays
  1956.  
  1957. if $imported["YSE-OverlayMapping"]
  1958.  
  1959.   class Map_Saver
  1960.  
  1961.     def draw_overlay_map_ground
  1962.  
  1963.       filename = YSA::OVERLAY::GROUND
  1964.  
  1965.       filename += $game_map.map_id.to_s
  1966.  
  1967.       filename += "-" + $game_variables[YSA::OVERLAY::GROUND_VARIABLE].to_s
  1968.  
  1969.       p filename
  1970.  
  1971.       image = Cache.overlay(filename)
  1972.  
  1973.       @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)
  1974.  
  1975.       @map_image.blt(0, 0, image, @src_rect)
  1976.  
  1977.     end
  1978.  
  1979.  
  1980.  
  1981.     def draw_overlay_map_parallax
  1982.  
  1983.       filename = YSA::OVERLAY::PARALLAX
  1984.  
  1985.       filename += $game_map.map_id.to_s
  1986.  
  1987.       filename += "-" + $game_variables[YSA::OVERLAY::PARALLAX_VARIABLE].to_s
  1988.  
  1989.       image = Cache.overlay(filename)
  1990.  
  1991.       @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)
  1992.  
  1993.       @map_image.blt(0, 0, image, @src_rect)
  1994.  
  1995.     end
  1996.  
  1997.  
  1998.  
  1999.     def draw_overlay_map_light
  2000.  
  2001.       filename = YSA::OVERLAY::LIGHT
  2002.  
  2003.       filename += $game_map.map_id.to_s
  2004.  
  2005.       filename += "-" + $game_variables[YSA::OVERLAY::LIGHT_VARIABLE].to_s
  2006.  
  2007.       image = Cache.overlay(filename)
  2008.  
  2009.       @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)
  2010.  
  2011.       @map_image.blt(0, 0, image, @src_rect, 10)
  2012.  
  2013.     end
  2014.  
  2015.  
  2016.  
  2017.     def draw_overlay_map_shadow
  2018.  
  2019.       filename = YSA::OVERLAY::SHADOW
  2020.  
  2021.       filename += $game_map.map_id.to_s
  2022.  
  2023.       filename += "-" + $game_variables[YSA::OVERLAY::SHADOW_VARIABLE].to_s
  2024.  
  2025.       image = Cache.overlay(filename)
  2026.  
  2027.       @src_rect.set(@start_x*tilesize, @start_y*tilesize, image.width, image.height)
  2028.  
  2029.       @map_image.blt(0, 0, image, @src_rect, 10)
  2030.  
  2031.     end
  2032.  
  2033.  
  2034.  
  2035.     alias :th_map_overlay_draw_map :draw_map
  2036.  
  2037.     def draw_map
  2038.  
  2039.       th_map_overlay_draw_map
  2040.  
  2041.       draw_overlay_map_ground if $game_switches[YSA::OVERLAY::GROUND_SWITCH]
  2042.  
  2043.       draw_overlay_map_parallax if $game_switches[YSA::OVERLAY::PARALLAX_SWITCH]
  2044.  
  2045.       draw_overlay_map_shadow if $game_switches[YSA::OVERLAY::SHADOW_SWITCH]
  2046.  
  2047.       draw_overlay_map_light if $game_switches[YSA::OVERLAY::LIGHT_SWITCH]
  2048.  
  2049.     end
  2050.  
  2051.   end
  2052.  
  2053. end
  2054.  
  2055.  
  2056.  
  2057. if $imported["TH_AreaOverlay"]
  2058.  
  2059.   class Map_Saver
  2060.  
  2061.     def draw_overlay_area_map
  2062.  
  2063.       image = SceneManager.scene.instance_variable_get(:@spriteset).instance_variable_get(:@area_map).bitmap
  2064.  
  2065.       @src_rect.set(@start_x * tilesize, @start_y * tilesize, image.width, image.height)
  2066.  
  2067.       @map_image.blt(0, 0, image, @src_rect, 255)
  2068.  
  2069.     end
  2070.  
  2071.  
  2072.  
  2073.     alias :th_area_overlay_draw_map :draw_map
  2074.  
  2075.     def draw_map
  2076.  
  2077.       th_area_overlay_draw_map
  2078.  
  2079.       draw_overlay_area_map
  2080.  
  2081.     end
  2082.  
  2083.   end
  2084.  
  2085. end
回复 支持 反对

使用道具 举报

Lv1.梦旅人

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

使用道具 举报

Lv1.梦旅人

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

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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
687 小时
注册时间
2012-10-29
帖子
1543
7
发表于 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
修改劇本中,仔細審查原來的劇情大綱,覺得有點不太滿意,嘗試編寫不同主角不同主線的劇情,希望能寫得出來。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-4 06:03

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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