Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Load RTP File
- # Version : 1.40
- # Original by joe59491, edited by LiTTleDRAgo
- #==============================================================================
- module Load_RTP_File
- RMXP = true
- RMVX = true
- RMVXA = true
- end
- ($imported ||= {})[:load_rtp_file] = 1.40
- $TEST = true # $TEST has to be true in order for the RTP script to work
- #==============================================================================
- # ** Ini
- #------------------------------------------------------------------------------
- #
- #==============================================================================
- module Ini
- #--------------------------------------------------------------------------
- # * self.readIni
- #--------------------------------------------------------------------------
- def self.readIni(item = "Title")
- buf = 0.chr * 256
- @gpps ||= Win32API.new("kernel32","GetPrivateProfileString","pppplp","l")
- @gpps.call("Game",item,"",buf,256,"./Game.ini")
- buf.delete!("\0")
- return buf
- end
- end
- #==============================================================================
- # ** String
- #------------------------------------------------------------------------------
- #
- #==============================================================================
- class String
- #--------------------------------------------------------------------------
- # ● UTF8_to_unicode
- #--------------------------------------------------------------------------
- def to_unicode
- @mbytetowchar ||= Win32API.new("kernel32","MultiByteToWideChar",'ilpipi','I')
- len = @mbytetowchar.call(65001, 0, self, -1, 0, 0) << 1
- @mbytetowchar.call(65001, 0, self, -1, (buf = " " * len), len)
- return buf
- end
- end
- #==============================================================================
- # ** RPG::Path
- #------------------------------------------------------------------------------
- #
- #==============================================================================
- module RPG
- module Path
- #--------------------------------------------------------------------------
- # * Constant
- #--------------------------------------------------------------------------
- FindFirstFile = Win32API.new("kernel32", "FindFirstFileW", "PP", "L")
- FindNextFile = Win32API.new("kernel32", "FindNextFileW", "LP", "I")
- #--------------------------------------------------------------------------
- # * getRTPPath
- #--------------------------------------------------------------------------
- def self.getRTPPath(rgss,rtpname)
- return "" if rtpname == "" or rtpname.nil?
- rp = File.join(ENV['CommonProgramFiles'],'Enterbrain',rgss,rtpname,'/')
- rp = rp.gsub("\\","/")
- rp = rp.gsub("//","/")
- return rp
- end
- #--------------------------------------------------------------------------
- # * Class Variable
- #--------------------------------------------------------------------------
- @@RTP = []
- if Load_RTP_File::RMXP
- @@RTP << self.getRTPPath('RGSS','Standard')
- (0..3).each do |i|
- @@RTP << self.getRTPPath('RGSS',Ini.readIni("RTP#{i.to_s}"))
- end
- end
- @@RTP << self.getRTPPath('RGSS2',"RPGVX") if Load_RTP_File::RMVX
- @@RTP << self.getRTPPath('RGSS3',"RPGVXAce") if Load_RTP_File::RMVXA
- @@RTP.reject! {|rtp| rtp.nil? || rtp.empty?}
- #--------------------------------------------------------------------------
- # * self.findP
- #--------------------------------------------------------------------------
- def self.findP(*paths)
- findFileData = " " * 596
- result = ""
- for file in paths
- unless FindFirstFile.call(file.to_unicode, findFileData) == -1
- name = file.split("/").last.split(".*").first
- result = File.dirname(file) + "/" + name
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # * self.RTP
- #--------------------------------------------------------------------------
- def self.RTP(path)
- @list ||= {}
- return @list[path] if @list.include?(path)
- check = File.extname(path).empty?
- rtp = []
- @@RTP.each do |item|
- unless item.empty?
- rtp.push(item + path)
- rtp.push(item + path + ".*") if check
- end
- end
- rtp.push(path)
- rtp.push(path + ".*") if check
- pa = self.findP(*rtp)
- @list[path] = pa == "" ? path : pa
- return @list[path]
- end
- end
- end
- #==============================================================================
- # ** Audio
- #------------------------------------------------------------------------------
- #
- #==============================================================================
- class << Audio
- #--------------------------------------------------------------------------
- # * Alias Listing
- #--------------------------------------------------------------------------
- [:bgm_play,:bgs_play,:se_play,:me_play].each do |meth|
- $@ || alias_method(:"#{meth}_path", :"#{meth}")
- define_method(:"#{meth}") do |*args|
- args[0] = RPG::Path::RTP(args[0]) if args[0].is_a?(String)
- send(:"#{meth}_path",*args)
- end
- end
- end
- #==============================================================================
- # ** Bitmap
- #------------------------------------------------------------------------------
- #
- #==============================================================================
- class Bitmap
- #--------------------------------------------------------------------------
- # ● Alias Method
- #--------------------------------------------------------------------------
- $@ || alias_method(:rtp_path_init, :initialize)
- #--------------------------------------------------------------------------
- # ● Object Initialization
- #--------------------------------------------------------------------------
- def initialize(*args)
- args[0] = RPG::Path::RTP(args.at(0)) if args.at(0).is_a?(String)
- rtp_path_init(*args)
- end
- end
- #==============================================================================
- # ** Graphics
- #------------------------------------------------------------------------------
- # This module handles all Graphics
- #==============================================================================
- class << Graphics
- #--------------------------------------------------------------------------
- # ● Alias Method
- #--------------------------------------------------------------------------
- $@ || alias_method(:rtp_path_transition, :transition)
- #--------------------------------------------------------------------------
- # ● transition
- #--------------------------------------------------------------------------
- def transition(*args)
- args[1] = RPG::Path::RTP(args.at(1)) if args[1].is_a?(String)
- rtp_path_transition(*args)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement