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

Project1

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

[RMVX发布] [FSL] 让RMVX有多重RTP (mutiRTP)

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
462 小时
注册时间
2007-7-30
帖子
643
跳转到指定楼层
1
发表于 2010-11-14 12:13:14 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 david50407 于 2010-11-14 12:14 编辑

关于RTP请参照 : http://rpg.blue/thread-160800-1-1.html
因为 VX 没有多重 RTP 的设置
于是我用脚本来实现个
基本上脚本是遵循 FSL 协议的
不过 String 转码模块是不遵循的 (介于本人懒惰...)
  1. #==============================================================================
  2. # ■ String
  3. #------------------------------------------------------------------------------
  4. #  字符串类。可处理任意长度的字节串。 (追加编码转换的定义)
  5. #==============================================================================

  6. class String
  7.   #--------------------------------------------------------------------------
  8.   # ● 用来编码Ruby 字符串、解码unicode 的两个Windows API 函数
  9.   #--------------------------------------------------------------------------
  10.   @@MultiByteToWideChar = Win32API.new("kernel32", "MultiByteToWideChar", ['I', 'L', 'P', 'I', 'P', 'I'], 'I')
  11.   @@WideCharToMultiByte = Win32API.new("kernel32", "WideCharToMultiByte", ['I', 'L', 'P', 'I', 'P', 'I', 'P', 'P'], 'I')
  12.   #--------------------------------------------------------------------------
  13.   # ● 返回将Ruby UTF-8 字符串对象(本身)编码为unicode 后的字符串
  14.   #--------------------------------------------------------------------------
  15.   def to_unicode
  16.     len = @@MultiByteToWideChar.call(65001, 0, self, -1, 0, 0) << 1
  17.     buf =" " * len
  18.     # 65001: UTF-8 字符集编码(代码页)
  19.     @@MultiByteToWideChar.call(65001, 0, self, -1, buf, len)
  20.     return buf
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 返回将编码为unicode 的字符串对象(本身)解码为UTF-8 后的字符串
  24.   #--------------------------------------------------------------------------
  25.   def to_UTF8
  26.     len = @@WideCharToMultiByte.call(65001, 0, self, -1, 0, 0, 0, 0)
  27.     buf =" " * len
  28.     @@WideCharToMultiByte.call(65001, 0, self, -1, buf, len, 0, 0)
  29.     # 去掉'\0' 字符串结束符(因为转换之后仅仅用于Ruby 字符串)
  30.     buf.slice!(-1, 1)
  31.     return buf
  32.   end
  33. end
复制代码
这是String转码模块
  1. #===============================================================================
  2. # ■ 多重 RTP
  3. # mutiRTP
  4. #-------------------------------------------------------------------------------
  5. # 基于 VX 没有多 RTP 供选择的缘故
  6. # 这是个多 RTP 设置的实现
  7. #
  8. # 在配置区可以随意设置要使用的RTP 名称
  9. # 在找不到该 RTP 时也能设置是否忽略
  10. # (不过若是资源找不着时还是采用 VX 默认的报错)
  11. #-------------------------------------------------------------------------------
  12. #    更新作者: David Kuo (david50407 @ 66rpg.com)
  13. #    许可协议: FSL
  14. #    项目版本: 1.00.0000
  15. #    引用网址:
  16. #-------------------------------------------------------------------------------
  17. #    - *1.00.0000 * By David Kuo (david50407 @ 66rpg.com)
  18. #      * 初版
  19. #===============================================================================
  20. $fscript = {} if $fscript == nil
  21. $fscript["mutiRTP"] = "1.00.0000"
  22. #-------------------------------------------------------------------------------
  23. # ▼ 通用配置模块
  24. #-------------------------------------------------------------------------------
  25. module FSL
  26.   module MutiRTP
  27.     ERROR = false # 找不到 RTP 时是否导致 致命错误(程序退出)
  28.     # 以下设置 RTP 的名称
  29.     RTPs = ["RPGVX"]
  30.   end
  31. end
  32. #-------------------------------------------------------------------------------
  33. # ▼ 多重 RTP
  34. #-------------------------------------------------------------------------------
  35. module MutiRTP
  36.   include FSL::MutiRTP # 引入设置
  37.   # 定义 API
  38.   RegOpenKeyEx = Win32API.new('advapi32', 'RegOpenKeyEx', 'lpiip', 'l')
  39.   RegQueryValueEx = Win32API.new('advapi32', 'RegQueryValueExW', 'lppppp', 'l')
  40.   RegCloseKey = Win32API.new('advapi32', 'RegCloseKey', 'l', 'l')
  41.   
  42.   # 定义模块方法
  43.   module_function
  44.   
  45.   def findRTPs(*args)
  46.     rtpPath = []
  47.     hKey = '    '
  48.     RegOpenKeyEx.call(-2147483646, 'SOFTWARE\Enterbrain\RGSS2\RTP', 0, 0x20019 | 0x0200, hKey)
  49.     hKey = hKey.unpack('l')[0]

  50.     for rtp in args
  51.       data, cbData = '    ' * 32, [128].pack('l')
  52.       RegQueryValueEx.call(hKey, rtp.to_unicode, 0, 0, data, cbData)
  53.       if data == '    ' * 32
  54.         if ERROR
  55.           p "找不到 RTP : \"#{rtp}\""
  56.           exit
  57.         end
  58.       else
  59.         rtpPath.push(File.expand_path(data.to_UTF8) + '/')
  60.       end
  61.     end
  62.    
  63.     RegCloseKey.call(hKey)
  64.     return rtpPath
  65.   end
  66.   
  67.   def init
  68.     rtpPath = findRTPs(*RTPs)
  69.     for p in rtpPath
  70.       $: << p
  71.     end
  72.     $mutiRTP = rtpPath
  73.   end
  74. end

  75. #-------------------------------------------------------------------------------
  76. # ▼ 修正路径
  77. #-------------------------------------------------------------------------------
  78. module RPG
  79.   module Path
  80.     FindFirstFile = Win32API.new("kernel32", "FindFirstFileW", "PP", "L")
  81.     FindNextFile = Win32API.new("kernel32", "FindNextFileW", "LP", "I")
  82.     def self.findP(*paths)
  83.       findFileData = " " * 592
  84.       for p in paths
  85.         unless FindFirstFile.call(p.to_unicode, findFileData) == -1 # INVALID_HANDLE_VALUE
  86.           return File.dirname(p) + "/" + findFileData[44, 45 + 260 * 2].to_UTF8
  87.         end
  88.       end
  89.       return ""
  90.     end
  91.    
  92.     @list = {}
  93.     def self.Get(path)
  94.       return @list[path] if @list.include?(path)
  95.       check = File.extname(path).empty?
  96.       rtp = []
  97.       for i in 0...$mutiRTP.length
  98.         unless $mutiRTP[i].empty?
  99.           rtp.push($mutiRTP[i] + path)
  100.           if check
  101.             rtp.push($mutiRTP[i] + path + ".*")
  102.           end
  103.         end
  104.       end
  105.       pa = self.findP(*rtp)
  106.       if pa == ""
  107.         @list[path] = path
  108.       else
  109.         @list[path] = pa
  110.       end
  111.       return @list[path]
  112.     end
  113.   end
  114. end

  115. #-------------------------------------------------------------------------------
  116. # ▼ 修正 Cache
  117. #-------------------------------------------------------------------------------
  118. module Cache
  119.   class << self
  120.     alias_method :old_load_bitmap, :load_bitmap
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # * 载入图档
  124.   #--------------------------------------------------------------------------
  125.   def self.load_bitmap(folder_name, filename, hue = 0)
  126.     self.old_load_bitmap(File.dirname(RPG::Path.Get(folder_name+filename))+'/', filename, hue)
  127.   end
  128. end

  129. #-------------------------------------------------------------------------------
  130. # ▼ 修正 Audio
  131. #-------------------------------------------------------------------------------
  132. module Audio
  133.   class << self
  134.     alias_method :old_bgm_play, :bgm_play
  135.     alias_method :old_bgs_play, :bgs_play
  136.     alias_method :old_me_play,  :me_play
  137.     alias_method :old_se_play,  :se_play
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # * 播放背景音乐
  141.   #--------------------------------------------------------------------------
  142.   def self.bgm_play(*args)
  143.     args[0] = RPG::Path.Get(args[0])
  144.     return self.old_bgm_play(*args)
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # * 播放背景音效
  148.   #--------------------------------------------------------------------------
  149.   def self.bgs_play(*args)
  150.     args[0] = RPG::Path.Get(args[0])
  151.     return self.old_bgs_play(*args)
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # * 播放事件音乐
  155.   #--------------------------------------------------------------------------
  156.   def self.me_play(*args)
  157.     args[0] = RPG::Path.Get(args[0])
  158.     return self.old_me_play(*args)
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # * 播放事件音效
  162.   #--------------------------------------------------------------------------
  163.   def self.se_play(*args)
  164.     args[0] = RPG::Path.Get(args[0])
  165.     return self.old_se_play(*args)
  166.   end
  167. end

  168. MutiRTP.init
复制代码
这是我们的主角~~ 请放置于Cache模块之后
RTPs = ["RPGVX"] # 这就是RTP设置

有BUG请回报

至于图嘛...还是上个几张好了...
没设置RTP
RMVX游戏照样运行~~

范例:
Project1.rar (1.05 MB, 下载次数: 925)

评分

参与人数 1+2 收起 理由
夕阳武士 + 2 技术活

查看全部评分

RGE这万年大坑 啥时填起来@@

Lv1.梦旅人

战国美少年森兰丸

梦石
0
星屑
204
在线时间
852 小时
注册时间
2008-7-20
帖子
3705
2
发表于 2010-11-14 12:27:59 | 只看该作者
前辈好~

点评

好~  发表于 2010-11-14 12:37
回复 支持 反对

使用道具 举报

Lv3.寻梦者 (暗夜天使)

名侦探小柯

梦石
0
星屑
3263
在线时间
3616 小时
注册时间
2006-9-6
帖子
37399

开拓者贵宾第3届短篇游戏大赛主流游戏组亚军第5届短篇游戏比赛亚军

3
发表于 2010-11-14 13:30:25 | 只看该作者
以后出一个小柯RTP = =b

点评

表示支持~  发表于 2010-11-14 13:49
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
90 小时
注册时间
2009-5-25
帖子
73
4
发表于 2010-12-13 12:38:21 | 只看该作者
本帖最后由 domencasio 于 2010-12-14 08:55 编辑

我想问下,如果要设置2套RTP的话文件名应该怎么打?
直接在
#     RTPs = ["RPGVX"]这个后面加上?


domencasio于2010-12-14 08:09补充以下内容:
多谢~


domencasio于2010-12-14 08:51补充以下内容:
貌似还是不行诶,我的系统是64位的WIN7,和这个有关系么?我把脚本中的路径从32位的那个按照XP的那个帖子改成了64位的路径,还是没用,需要修改工程文件里德GAME.ini么?
注册表里

游戏脚本编辑器里设置

自己的RTP目录

点评

RTPs = ["RTP1", "RTP2", "RTP3", "..."]  发表于 2010-12-13 18:41
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
202 小时
注册时间
2009-9-6
帖子
307
5
发表于 2010-12-14 13:32:07 | 只看该作者
看到了win7,表示机子无能,偶用的是XP,VX的纯粹打酱油
   .black-box//
-------------制作准备中
小血的百度博客
小血的腾讯博客
小血的新浪微博
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-25 04:32

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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