mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Added decent spacing to all scripts thanks to Rubocop
This commit is contained in:
@@ -79,7 +79,7 @@ def safeExists?(f)
|
||||
return FileTest.exist?(f) if f[/\A[\x20-\x7E]*\z/]
|
||||
ret = false
|
||||
begin
|
||||
File.open(f,"rb") { ret = true }
|
||||
File.open(f, "rb") { ret = true }
|
||||
rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES
|
||||
ret = false
|
||||
end
|
||||
@@ -89,13 +89,13 @@ end
|
||||
# Similar to "Dir.glob", but designed to work around a problem with accessing
|
||||
# files if a path contains accent marks.
|
||||
# "dir" is the directory path, "wildcard" is the filename pattern to match.
|
||||
def safeGlob(dir,wildcard)
|
||||
def safeGlob(dir, wildcard)
|
||||
ret = []
|
||||
afterChdir = false
|
||||
begin
|
||||
Dir.chdir(dir) {
|
||||
afterChdir = true
|
||||
Dir.glob(wildcard) { |f| ret.push(dir+"/"+f) }
|
||||
Dir.glob(wildcard) { |f| ret.push(dir + "/" + f) }
|
||||
}
|
||||
rescue Errno::ENOENT
|
||||
raise if afterChdir
|
||||
@@ -118,18 +118,18 @@ end
|
||||
# archives. Returns nil if the path can't be found.
|
||||
def pbResolveBitmap(x)
|
||||
return nil if !x
|
||||
noext = x.gsub(/\.(bmp|png|gif|jpg|jpeg)$/,"")
|
||||
noext = x.gsub(/\.(bmp|png|gif|jpg|jpeg)$/, "")
|
||||
filename = nil
|
||||
# RTP.eachPathFor(x) { |path|
|
||||
# filename = pbTryString(path) if !filename
|
||||
# filename = pbTryString(path+".gif") if !filename
|
||||
# filename = pbTryString(path + ".gif") if !filename
|
||||
# }
|
||||
RTP.eachPathFor(noext) { |path|
|
||||
filename = pbTryString(path+".png") if !filename
|
||||
filename = pbTryString(path+".gif") if !filename
|
||||
# filename = pbTryString(path+".jpg") if !filename
|
||||
# filename = pbTryString(path+".jpeg") if !filename
|
||||
# filename = pbTryString(path+".bmp") if !filename
|
||||
filename = pbTryString(path + ".png") if !filename
|
||||
filename = pbTryString(path + ".gif") if !filename
|
||||
# filename = pbTryString(path + ".jpg") if !filename
|
||||
# filename = pbTryString(path + ".jpeg") if !filename
|
||||
# filename = pbTryString(path + ".bmp") if !filename
|
||||
}
|
||||
return filename
|
||||
end
|
||||
@@ -180,31 +180,31 @@ end
|
||||
module RTP
|
||||
@rtpPaths = nil
|
||||
|
||||
def self.exists?(filename,extensions = [])
|
||||
def self.exists?(filename, extensions = [])
|
||||
return false if nil_or_empty?(filename)
|
||||
eachPathFor(filename) { |path|
|
||||
return true if safeExists?(path)
|
||||
for ext in extensions
|
||||
return true if safeExists?(path+ext)
|
||||
return true if safeExists?(path + ext)
|
||||
end
|
||||
}
|
||||
return false
|
||||
end
|
||||
|
||||
def self.getImagePath(filename)
|
||||
return self.getPath(filename,["",".png",".gif"]) # ".jpg", ".jpeg", ".bmp"
|
||||
return self.getPath(filename, ["", ".png", ".gif"]) # ".jpg", ".jpeg", ".bmp"
|
||||
end
|
||||
|
||||
def self.getAudioPath(filename)
|
||||
return self.getPath(filename,["",".wav",".wma",".mid",".ogg",".midi"]) # ".mp3"
|
||||
return self.getPath(filename, ["", ".wav", ".wma", ".mid", ".ogg", ".midi"]) # ".mp3"
|
||||
end
|
||||
|
||||
def self.getPath(filename,extensions = [])
|
||||
def self.getPath(filename, extensions = [])
|
||||
return filename if nil_or_empty?(filename)
|
||||
eachPathFor(filename) { |path|
|
||||
return path if safeExists?(path)
|
||||
for ext in extensions
|
||||
file = path+ext
|
||||
file = path + ext
|
||||
return file if safeExists?(file)
|
||||
end
|
||||
}
|
||||
@@ -220,10 +220,10 @@ module RTP
|
||||
else
|
||||
# relative path
|
||||
RTP.eachPath { |path|
|
||||
if path=="./"
|
||||
if path == "./"
|
||||
yield filename
|
||||
else
|
||||
yield path+filename
|
||||
yield path + filename
|
||||
end
|
||||
}
|
||||
end
|
||||
@@ -237,7 +237,7 @@ module RTP
|
||||
def self.eachPath
|
||||
# XXX: Use "." instead of Dir.pwd because of problems retrieving files if
|
||||
# the current directory contains an accent mark
|
||||
yield ".".gsub(/[\/\\]/,"/").gsub(/[\/\\]$/,"")+"/"
|
||||
yield ".".gsub(/[\/\\]/, "/").gsub(/[\/\\]$/, "") + "/"
|
||||
end
|
||||
|
||||
private
|
||||
@@ -264,11 +264,11 @@ module FileTest
|
||||
Audio_ext = ['.mid', '.midi', '.ogg', '.wav', '.wma'] # '.mp3'
|
||||
|
||||
def self.audio_exist?(filename)
|
||||
return RTP.exists?(filename,Audio_ext)
|
||||
return RTP.exists?(filename, Audio_ext)
|
||||
end
|
||||
|
||||
def self.image_exist?(filename)
|
||||
return RTP.exists?(filename,Image_ext)
|
||||
return RTP.exists?(filename, Image_ext)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -281,7 +281,7 @@ end
|
||||
# and matching mount points added through System.mount
|
||||
def pbRgssExists?(filename)
|
||||
if safeExists?("./Game.rgssad")
|
||||
return pbGetFileChar(filename)!=nil
|
||||
return pbGetFileChar(filename) != nil
|
||||
else
|
||||
filename = canonicalize(filename)
|
||||
return safeExists?(filename)
|
||||
@@ -293,14 +293,14 @@ end
|
||||
|
||||
# NOTE: load_data checks anything added in MKXP's RTP setting,
|
||||
# and matching mount points added through System.mount
|
||||
def pbRgssOpen(file,mode = nil)
|
||||
def pbRgssOpen(file, mode = nil)
|
||||
# File.open("debug.txt","ab") { |fw| fw.write([file,mode,Time.now.to_f].inspect+"\r\n") }
|
||||
if !safeExists?("./Game.rgssad")
|
||||
if block_given?
|
||||
File.open(file,mode) { |f| yield f }
|
||||
File.open(file, mode) { |f| yield f }
|
||||
return nil
|
||||
else
|
||||
return File.open(file,mode)
|
||||
return File.open(file, mode)
|
||||
end
|
||||
end
|
||||
file = canonicalize(file)
|
||||
@@ -338,7 +338,7 @@ end
|
||||
|
||||
def pbTryString(x)
|
||||
ret = pbGetFileChar(x)
|
||||
return (ret!=nil && ret!="") ? x : nil
|
||||
return (ret != nil && ret != "") ? x : nil
|
||||
end
|
||||
|
||||
# Gets the contents of a file. Doesn't check RTP, but does check
|
||||
@@ -351,7 +351,7 @@ def pbGetFileString(file)
|
||||
if !safeExists?("./Game.rgssad")
|
||||
return nil if !safeExists?(file)
|
||||
begin
|
||||
File.open(file,"rb") { |f| return f.read } # read all data
|
||||
File.open(file, "rb") { |f| return f.read } # read all data
|
||||
rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES
|
||||
return nil
|
||||
end
|
||||
@@ -396,10 +396,10 @@ class StringInput
|
||||
@lineno = 0
|
||||
end
|
||||
|
||||
attr_reader :lineno,:string
|
||||
attr_reader :lineno, :string
|
||||
|
||||
def inspect
|
||||
return "#<#{self.class}:#{@closed ? 'closed' : 'open'},src=#{@string[0,30].inspect}>"
|
||||
return "#<#{self.class}:#{@closed ? 'closed' : 'open'},src=#{@string[0, 30].inspect}>"
|
||||
end
|
||||
|
||||
def close
|
||||
|
||||
Reference in New Issue
Block a user