mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Added decent spacing to all scripts thanks to Rubocop
This commit is contained in:
@@ -15,7 +15,7 @@ module PBDebug
|
||||
end
|
||||
|
||||
def self.flush
|
||||
if $DEBUG && $INTERNAL && @@log.length>0
|
||||
if $DEBUG && $INTERNAL && @@log.length > 0
|
||||
File.open("Data/debuglog.txt", "a+b") { |f| f.write(@@log.to_s) }
|
||||
end
|
||||
@@log.clear
|
||||
|
||||
@@ -13,7 +13,7 @@ class EventScriptError < Exception
|
||||
end
|
||||
end
|
||||
|
||||
def pbGetExceptionMessage(e,_script = "")
|
||||
def pbGetExceptionMessage(e, _script = "")
|
||||
return e.event_message.dup if e.is_a?(EventScriptError) # Message with map/event ID generated elsewhere
|
||||
emessage = e.message.dup
|
||||
emessage.force_encoding(Encoding::UTF_8)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -7,7 +7,7 @@ def pbPostData(url, postdata, filename = nil, depth = 0)
|
||||
if url[/^http:\/\/([^\/]+)(.*)$/]
|
||||
host = $1
|
||||
path = $2
|
||||
path = "/" if path.length==0
|
||||
path = "/" if path.length == 0
|
||||
userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14"
|
||||
body = postdata.map { |key, value|
|
||||
keyString = key.to_s
|
||||
@@ -63,7 +63,7 @@ end
|
||||
|
||||
def pbDownloadToFile(url, file)
|
||||
begin
|
||||
pbDownloadData(url,file)
|
||||
pbDownloadData(url, file)
|
||||
rescue
|
||||
end
|
||||
end
|
||||
@@ -79,7 +79,7 @@ end
|
||||
|
||||
def pbPostToFile(url, postdata, file)
|
||||
begin
|
||||
pbPostData(url, postdata,file)
|
||||
pbPostData(url, postdata, file)
|
||||
rescue
|
||||
end
|
||||
end
|
||||
|
||||
@@ -89,7 +89,7 @@ end
|
||||
#===============================================================================
|
||||
class Array
|
||||
def ^(other) # xor of two arrays
|
||||
return (self|other) - (self&other)
|
||||
return (self | other) - (self & other)
|
||||
end
|
||||
|
||||
def swap(val1, val2)
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
def pbAddScriptTexts(items,script)
|
||||
def pbAddScriptTexts(items, script)
|
||||
script.scan(/(?:_I)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) { |s|
|
||||
string=s[0]
|
||||
string.gsub!(/\\\"/,"\"")
|
||||
string.gsub!(/\\\\/,"\\")
|
||||
string = s[0]
|
||||
string.gsub!(/\\\"/, "\"")
|
||||
string.gsub!(/\\\\/, "\\")
|
||||
items.push(string)
|
||||
}
|
||||
end
|
||||
|
||||
def pbAddRgssScriptTexts(items,script)
|
||||
def pbAddRgssScriptTexts(items, script)
|
||||
script.scan(/(?:_INTL|_ISPRINTF)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) { |s|
|
||||
string=s[0]
|
||||
string.gsub!(/\\r/,"\r")
|
||||
string.gsub!(/\\n/,"\n")
|
||||
string.gsub!(/\\1/,"\1")
|
||||
string.gsub!(/\\\"/,"\"")
|
||||
string.gsub!(/\\\\/,"\\")
|
||||
string = s[0]
|
||||
string.gsub!(/\\r/, "\r")
|
||||
string.gsub!(/\\n/, "\n")
|
||||
string.gsub!(/\\1/, "\1")
|
||||
string.gsub!(/\\\"/, "\"")
|
||||
string.gsub!(/\\\\/, "\\")
|
||||
items.push(string)
|
||||
}
|
||||
end
|
||||
@@ -23,14 +23,14 @@ def pbSetTextMessages
|
||||
Graphics.update
|
||||
begin
|
||||
t = Time.now.to_i
|
||||
texts=[]
|
||||
texts = []
|
||||
for script in $RGSS_SCRIPTS
|
||||
if Time.now.to_i - t >= 5
|
||||
t = Time.now.to_i
|
||||
Graphics.update
|
||||
end
|
||||
scr=Zlib::Inflate.inflate(script[2])
|
||||
pbAddRgssScriptTexts(texts,scr)
|
||||
scr = Zlib::Inflate.inflate(script[2])
|
||||
pbAddRgssScriptTexts(texts, scr)
|
||||
end
|
||||
if safeExists?("Data/PluginScripts.rxdata")
|
||||
plugin_scripts = load_data("Data/PluginScripts.rxdata")
|
||||
@@ -41,62 +41,62 @@ def pbSetTextMessages
|
||||
Graphics.update
|
||||
end
|
||||
scr = Zlib::Inflate.inflate(script[1]).force_encoding(Encoding::UTF_8)
|
||||
pbAddRgssScriptTexts(texts,scr)
|
||||
pbAddRgssScriptTexts(texts, scr)
|
||||
end
|
||||
end
|
||||
end
|
||||
# Must add messages because this code is used by both game system and Editor
|
||||
MessageTypes.addMessagesAsHash(MessageTypes::ScriptTexts,texts)
|
||||
MessageTypes.addMessagesAsHash(MessageTypes::ScriptTexts, texts)
|
||||
commonevents = load_data("Data/CommonEvents.rxdata")
|
||||
items=[]
|
||||
choices=[]
|
||||
items = []
|
||||
choices = []
|
||||
for event in commonevents.compact
|
||||
if Time.now.to_i - t >= 5
|
||||
t = Time.now.to_i
|
||||
Graphics.update
|
||||
end
|
||||
begin
|
||||
neednewline=false
|
||||
lastitem=""
|
||||
neednewline = false
|
||||
lastitem = ""
|
||||
for j in 0...event.list.size
|
||||
list = event.list[j]
|
||||
if neednewline && list.code!=401
|
||||
if lastitem!=""
|
||||
lastitem.gsub!(/([^\.\!\?])\s\s+/) { |m| $1+" " }
|
||||
if neednewline && list.code != 401
|
||||
if lastitem != ""
|
||||
lastitem.gsub!(/([^\.\!\?])\s\s+/) { |m| $1 + " " }
|
||||
items.push(lastitem)
|
||||
lastitem=""
|
||||
lastitem = ""
|
||||
end
|
||||
neednewline=false
|
||||
neednewline = false
|
||||
end
|
||||
if list.code == 101
|
||||
lastitem+="#{list.parameters[0]}"
|
||||
neednewline=true
|
||||
lastitem += "#{list.parameters[0]}"
|
||||
neednewline = true
|
||||
elsif list.code == 102
|
||||
for k in 0...list.parameters[0].length
|
||||
choices.push(list.parameters[0][k])
|
||||
end
|
||||
neednewline=false
|
||||
neednewline = false
|
||||
elsif list.code == 401
|
||||
lastitem+=" " if lastitem!=""
|
||||
lastitem+="#{list.parameters[0]}"
|
||||
neednewline=true
|
||||
lastitem += " " if lastitem != ""
|
||||
lastitem += "#{list.parameters[0]}"
|
||||
neednewline = true
|
||||
elsif list.code == 355 || list.code == 655
|
||||
pbAddScriptTexts(items,list.parameters[0])
|
||||
elsif list.code == 111 && list.parameters[0]==12
|
||||
pbAddScriptTexts(items,list.parameters[1])
|
||||
pbAddScriptTexts(items, list.parameters[0])
|
||||
elsif list.code == 111 && list.parameters[0] == 12
|
||||
pbAddScriptTexts(items, list.parameters[1])
|
||||
elsif list.code == 209
|
||||
route=list.parameters[1]
|
||||
route = list.parameters[1]
|
||||
for k in 0...route.list.size
|
||||
if route.list[k].code == 45
|
||||
pbAddScriptTexts(items,route.list[k].parameters[0])
|
||||
pbAddScriptTexts(items, route.list[k].parameters[0])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if neednewline
|
||||
if lastitem!=""
|
||||
if lastitem != ""
|
||||
items.push(lastitem)
|
||||
lastitem=""
|
||||
lastitem = ""
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -105,21 +105,21 @@ def pbSetTextMessages
|
||||
t = Time.now.to_i
|
||||
Graphics.update
|
||||
end
|
||||
items|=[]
|
||||
choices|=[]
|
||||
items |= []
|
||||
choices |= []
|
||||
items.concat(choices)
|
||||
MessageTypes.setMapMessagesAsHash(0,items)
|
||||
MessageTypes.setMapMessagesAsHash(0, items)
|
||||
mapinfos = pbLoadMapInfos
|
||||
for id in mapinfos.keys
|
||||
if Time.now.to_i - t >= 5
|
||||
t = Time.now.to_i
|
||||
Graphics.update
|
||||
end
|
||||
filename=sprintf("Data/Map%03d.rxdata",id)
|
||||
filename = sprintf("Data/Map%03d.rxdata", id)
|
||||
next if !pbRgssExists?(filename)
|
||||
map = load_data(filename)
|
||||
items=[]
|
||||
choices=[]
|
||||
items = []
|
||||
choices = []
|
||||
for event in map.events.values
|
||||
if Time.now.to_i - t >= 5
|
||||
t = Time.now.to_i
|
||||
@@ -127,47 +127,47 @@ def pbSetTextMessages
|
||||
end
|
||||
begin
|
||||
for i in 0...event.pages.size
|
||||
neednewline=false
|
||||
lastitem=""
|
||||
neednewline = false
|
||||
lastitem = ""
|
||||
for j in 0...event.pages[i].list.size
|
||||
list = event.pages[i].list[j]
|
||||
if neednewline && list.code!=401
|
||||
if lastitem!=""
|
||||
lastitem.gsub!(/([^\.\!\?])\s\s+/) { |m| $1+" " }
|
||||
if neednewline && list.code != 401
|
||||
if lastitem != ""
|
||||
lastitem.gsub!(/([^\.\!\?])\s\s+/) { |m| $1 + " " }
|
||||
items.push(lastitem)
|
||||
lastitem=""
|
||||
lastitem = ""
|
||||
end
|
||||
neednewline=false
|
||||
neednewline = false
|
||||
end
|
||||
if list.code == 101
|
||||
lastitem+="#{list.parameters[0]}"
|
||||
neednewline=true
|
||||
lastitem += "#{list.parameters[0]}"
|
||||
neednewline = true
|
||||
elsif list.code == 102
|
||||
for k in 0...list.parameters[0].length
|
||||
choices.push(list.parameters[0][k])
|
||||
end
|
||||
neednewline=false
|
||||
neednewline = false
|
||||
elsif list.code == 401
|
||||
lastitem+=" " if lastitem!=""
|
||||
lastitem+="#{list.parameters[0]}"
|
||||
neednewline=true
|
||||
elsif list.code == 355 || list.code==655
|
||||
pbAddScriptTexts(items,list.parameters[0])
|
||||
elsif list.code == 111 && list.parameters[0]==12
|
||||
pbAddScriptTexts(items,list.parameters[1])
|
||||
elsif list.code==209
|
||||
route=list.parameters[1]
|
||||
lastitem += " " if lastitem != ""
|
||||
lastitem += "#{list.parameters[0]}"
|
||||
neednewline = true
|
||||
elsif list.code == 355 || list.code == 655
|
||||
pbAddScriptTexts(items, list.parameters[0])
|
||||
elsif list.code == 111 && list.parameters[0] == 12
|
||||
pbAddScriptTexts(items, list.parameters[1])
|
||||
elsif list.code == 209
|
||||
route = list.parameters[1]
|
||||
for k in 0...route.list.size
|
||||
if route.list[k].code==45
|
||||
pbAddScriptTexts(items,route.list[k].parameters[0])
|
||||
if route.list[k].code == 45
|
||||
pbAddScriptTexts(items, route.list[k].parameters[0])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if neednewline
|
||||
if lastitem!=""
|
||||
if lastitem != ""
|
||||
items.push(lastitem)
|
||||
lastitem=""
|
||||
lastitem = ""
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -177,10 +177,10 @@ def pbSetTextMessages
|
||||
t = Time.now.to_i
|
||||
Graphics.update
|
||||
end
|
||||
items|=[]
|
||||
choices|=[]
|
||||
items |= []
|
||||
choices |= []
|
||||
items.concat(choices)
|
||||
MessageTypes.setMapMessagesAsHash(id,items)
|
||||
MessageTypes.setMapMessagesAsHash(id, items)
|
||||
if Time.now.to_i - t >= 5
|
||||
t = Time.now.to_i
|
||||
Graphics.update
|
||||
@@ -192,92 +192,92 @@ def pbSetTextMessages
|
||||
end
|
||||
|
||||
def pbEachIntlSection(file)
|
||||
lineno=1
|
||||
re=/^\s*\[\s*([^\]]+)\s*\]\s*$/
|
||||
havesection=false
|
||||
sectionname=nil
|
||||
lastsection=[]
|
||||
lineno = 1
|
||||
re = /^\s*\[\s*([^\]]+)\s*\]\s*$/
|
||||
havesection = false
|
||||
sectionname = nil
|
||||
lastsection = []
|
||||
file.each_line { |line|
|
||||
if lineno==1 && line[0].ord==0xEF && line[1].ord==0xBB && line[2].ord==0xBF
|
||||
line=line[3,line.length-3]
|
||||
if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF
|
||||
line = line[3, line.length - 3]
|
||||
end
|
||||
if !line[/^\#/] && !line[/^\s*$/]
|
||||
if line[re]
|
||||
if havesection
|
||||
yield lastsection,sectionname
|
||||
yield lastsection, sectionname
|
||||
end
|
||||
lastsection.clear
|
||||
sectionname=$~[1]
|
||||
havesection=true
|
||||
sectionname = $~[1]
|
||||
havesection = true
|
||||
else
|
||||
if sectionname==nil
|
||||
raise _INTL("Expected a section at the beginning of the file (line {1})",lineno)
|
||||
if sectionname == nil
|
||||
raise _INTL("Expected a section at the beginning of the file (line {1})", lineno)
|
||||
end
|
||||
lastsection.push(line.gsub(/\s+$/,""))
|
||||
lastsection.push(line.gsub(/\s+$/, ""))
|
||||
end
|
||||
end
|
||||
lineno+=1
|
||||
if lineno%500==0
|
||||
lineno += 1
|
||||
if lineno % 500 == 0
|
||||
Graphics.update
|
||||
end
|
||||
}
|
||||
if havesection
|
||||
yield lastsection,sectionname
|
||||
yield lastsection, sectionname
|
||||
end
|
||||
end
|
||||
|
||||
def pbGetText(infile)
|
||||
begin
|
||||
file=File.open(infile,"rb")
|
||||
file = File.open(infile, "rb")
|
||||
rescue
|
||||
raise _INTL("Can't find {1}",infile)
|
||||
raise _INTL("Can't find {1}", infile)
|
||||
end
|
||||
intldat=[]
|
||||
intldat = []
|
||||
begin
|
||||
pbEachIntlSection(file) { |section,name|
|
||||
next if section.length==0
|
||||
pbEachIntlSection(file) { |section, name|
|
||||
next if section.length == 0
|
||||
if !name[/^([Mm][Aa][Pp])?(\d+)$/]
|
||||
raise _INTL("Invalid section name {1}",name)
|
||||
raise _INTL("Invalid section name {1}", name)
|
||||
end
|
||||
ismap=$~[1] && $~[1]!=""
|
||||
id=$~[2].to_i
|
||||
itemlength=0
|
||||
ismap = $~[1] && $~[1] != ""
|
||||
id = $~[2].to_i
|
||||
itemlength = 0
|
||||
if section[0][/^\d+$/]
|
||||
intlhash=[]
|
||||
itemlength=3
|
||||
intlhash = []
|
||||
itemlength = 3
|
||||
if ismap
|
||||
raise _INTL("Section {1} can't be an ordered list (section was recognized as an ordered list because its first line is a number)",name)
|
||||
raise _INTL("Section {1} can't be an ordered list (section was recognized as an ordered list because its first line is a number)", name)
|
||||
end
|
||||
if section.length%3!=0
|
||||
raise _INTL("Section {1}'s line count is not divisible by 3 (section was recognized as an ordered list because its first line is a number)",name)
|
||||
if section.length % 3 != 0
|
||||
raise _INTL("Section {1}'s line count is not divisible by 3 (section was recognized as an ordered list because its first line is a number)", name)
|
||||
end
|
||||
else
|
||||
intlhash=OrderedHash.new
|
||||
itemlength=2
|
||||
if section.length%2!=0
|
||||
raise _INTL("Section {1} has an odd number of entries (section was recognized as a hash because its first line is not a number)",name)
|
||||
intlhash = OrderedHash.new
|
||||
itemlength = 2
|
||||
if section.length % 2 != 0
|
||||
raise _INTL("Section {1} has an odd number of entries (section was recognized as a hash because its first line is not a number)", name)
|
||||
end
|
||||
end
|
||||
i=0
|
||||
i = 0
|
||||
loop do
|
||||
break unless i < section.length
|
||||
if itemlength==3
|
||||
if itemlength == 3
|
||||
if !section[i][/^\d+$/]
|
||||
raise _INTL("Expected a number in section {1}, got {2} instead",name,section[i])
|
||||
raise _INTL("Expected a number in section {1}, got {2} instead", name, section[i])
|
||||
end
|
||||
key=section[i].to_i
|
||||
i+=1
|
||||
key = section[i].to_i
|
||||
i += 1
|
||||
else
|
||||
key=MessageTypes.denormalizeValue(section[i])
|
||||
key = MessageTypes.denormalizeValue(section[i])
|
||||
end
|
||||
intlhash[key]=MessageTypes.denormalizeValue(section[i+1])
|
||||
i+=2
|
||||
intlhash[key] = MessageTypes.denormalizeValue(section[i + 1])
|
||||
i += 2
|
||||
end
|
||||
if ismap
|
||||
intldat[0]=[] if !intldat[0]
|
||||
intldat[0][id]=intlhash
|
||||
intldat[0] = [] if !intldat[0]
|
||||
intldat[0][id] = intlhash
|
||||
else
|
||||
intldat[id]=intlhash
|
||||
intldat[id] = intlhash
|
||||
end
|
||||
}
|
||||
ensure
|
||||
@@ -287,10 +287,10 @@ def pbGetText(infile)
|
||||
end
|
||||
|
||||
def pbCompileText
|
||||
outfile=File.open("intl.dat","wb")
|
||||
outfile = File.open("intl.dat", "wb")
|
||||
begin
|
||||
intldat=pbGetText("intl.txt")
|
||||
Marshal.dump(intldat,outfile)
|
||||
intldat = pbGetText("intl.txt")
|
||||
Marshal.dump(intldat, outfile)
|
||||
rescue
|
||||
raise
|
||||
ensure
|
||||
@@ -302,7 +302,7 @@ end
|
||||
|
||||
class OrderedHash < Hash
|
||||
def initialize
|
||||
@keys=[]
|
||||
@keys = []
|
||||
super
|
||||
end
|
||||
|
||||
@@ -311,54 +311,54 @@ class OrderedHash < Hash
|
||||
end
|
||||
|
||||
def inspect
|
||||
str="{"
|
||||
str = "{"
|
||||
for i in 0...@keys.length
|
||||
str+=", " if i>0
|
||||
str+=@keys[i].inspect+"=>"+self[@keys[i]].inspect
|
||||
str += ", " if i > 0
|
||||
str += @keys[i].inspect + "=>" + self[@keys[i]].inspect
|
||||
end
|
||||
str+="}"
|
||||
str += "}"
|
||||
return str
|
||||
end
|
||||
|
||||
alias :to_s :inspect
|
||||
|
||||
def []=(key,value)
|
||||
oldvalue=self[key]
|
||||
def []=(key, value)
|
||||
oldvalue = self[key]
|
||||
if !oldvalue && value
|
||||
@keys.push(key)
|
||||
elsif !value
|
||||
@keys|=[]
|
||||
@keys-=[key]
|
||||
@keys |= []
|
||||
@keys -= [key]
|
||||
end
|
||||
return super(key,value)
|
||||
return super(key, value)
|
||||
end
|
||||
|
||||
def self._load(string)
|
||||
ret=self.new
|
||||
keysvalues=Marshal.load(string)
|
||||
keys=keysvalues[0]
|
||||
values=keysvalues[1]
|
||||
ret = self.new
|
||||
keysvalues = Marshal.load(string)
|
||||
keys = keysvalues[0]
|
||||
values = keysvalues[1]
|
||||
for i in 0...keys.length
|
||||
ret[keys[i]]=values[i]
|
||||
ret[keys[i]] = values[i]
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def _dump(_depth = 100)
|
||||
values=[]
|
||||
values = []
|
||||
for key in @keys
|
||||
values.push(self[key])
|
||||
end
|
||||
return Marshal.dump([@keys,values])
|
||||
return Marshal.dump([@keys, values])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Messages
|
||||
def initialize(filename = nil,delayLoad = false)
|
||||
@messages=nil
|
||||
@filename=filename
|
||||
def initialize(filename = nil, delayLoad = false)
|
||||
@messages = nil
|
||||
@filename = filename
|
||||
if @filename && !delayLoad
|
||||
loadMessageFile(@filename)
|
||||
end
|
||||
@@ -367,7 +367,7 @@ class Messages
|
||||
def delayedLoad
|
||||
if @filename && !@messages
|
||||
loadMessageFile(@filename)
|
||||
@filename=nil
|
||||
@filename = nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -384,13 +384,13 @@ class Messages
|
||||
|
||||
def self.normalizeValue(value)
|
||||
if value[/[\r\n\t\x01]|^[\[\]]/]
|
||||
ret=value.clone
|
||||
ret.gsub!(/\r/,"<<r>>")
|
||||
ret.gsub!(/\n/,"<<n>>")
|
||||
ret.gsub!(/\t/,"<<t>>")
|
||||
ret.gsub!(/\[/,"<<[>>")
|
||||
ret.gsub!(/\]/,"<<]>>")
|
||||
ret.gsub!(/\x01/,"<<1>>")
|
||||
ret = value.clone
|
||||
ret.gsub!(/\r/, "<<r>>")
|
||||
ret.gsub!(/\n/, "<<n>>")
|
||||
ret.gsub!(/\t/, "<<t>>")
|
||||
ret.gsub!(/\[/, "<<[>>")
|
||||
ret.gsub!(/\]/, "<<]>>")
|
||||
ret.gsub!(/\x01/, "<<1>>")
|
||||
return ret
|
||||
end
|
||||
return value
|
||||
@@ -398,45 +398,45 @@ class Messages
|
||||
|
||||
def self.denormalizeValue(value)
|
||||
if value[/<<[rnt1\[\]]>>/]
|
||||
ret=value.clone
|
||||
ret.gsub!(/<<1>>/,"\1")
|
||||
ret.gsub!(/<<r>>/,"\r")
|
||||
ret.gsub!(/<<n>>/,"\n")
|
||||
ret.gsub!(/<<\[>>/,"[")
|
||||
ret.gsub!(/<<\]>>/,"]")
|
||||
ret.gsub!(/<<t>>/,"\t")
|
||||
ret = value.clone
|
||||
ret.gsub!(/<<1>>/, "\1")
|
||||
ret.gsub!(/<<r>>/, "\r")
|
||||
ret.gsub!(/<<n>>/, "\n")
|
||||
ret.gsub!(/<<\[>>/, "[")
|
||||
ret.gsub!(/<<\]>>/, "]")
|
||||
ret.gsub!(/<<t>>/, "\t")
|
||||
return ret
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
def self.writeObject(f,msgs,secname,origMessages = nil)
|
||||
def self.writeObject(f, msgs, secname, origMessages = nil)
|
||||
return if !msgs
|
||||
if msgs.is_a?(Array)
|
||||
f.write("[#{secname}]\r\n")
|
||||
for j in 0...msgs.length
|
||||
next if nil_or_empty?(msgs[j])
|
||||
value=Messages.normalizeValue(msgs[j])
|
||||
origValue=""
|
||||
value = Messages.normalizeValue(msgs[j])
|
||||
origValue = ""
|
||||
if origMessages
|
||||
origValue=Messages.normalizeValue(origMessages.get(secname,j))
|
||||
origValue = Messages.normalizeValue(origMessages.get(secname, j))
|
||||
else
|
||||
origValue=Messages.normalizeValue(MessageTypes.get(secname,j))
|
||||
origValue = Messages.normalizeValue(MessageTypes.get(secname, j))
|
||||
end
|
||||
f.write("#{j}\r\n")
|
||||
f.write(origValue+"\r\n")
|
||||
f.write(value+"\r\n")
|
||||
f.write(origValue + "\r\n")
|
||||
f.write(value + "\r\n")
|
||||
end
|
||||
elsif msgs.is_a?(OrderedHash)
|
||||
f.write("[#{secname}]\r\n")
|
||||
keys=msgs.keys
|
||||
keys = msgs.keys
|
||||
for key in keys
|
||||
next if nil_or_empty?(msgs[key])
|
||||
value=Messages.normalizeValue(msgs[key])
|
||||
valkey=Messages.normalizeValue(key)
|
||||
value = Messages.normalizeValue(msgs[key])
|
||||
valkey = Messages.normalizeValue(key)
|
||||
# key is already serialized
|
||||
f.write(valkey+"\r\n")
|
||||
f.write(value+"\r\n")
|
||||
f.write(valkey + "\r\n")
|
||||
f.write(value + "\r\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -447,8 +447,8 @@ class Messages
|
||||
|
||||
def extract(outfile)
|
||||
# return if !@messages
|
||||
origMessages=Messages.new("Data/messages.dat")
|
||||
File.open(outfile,"wb") { |f|
|
||||
origMessages = Messages.new("Data/messages.dat")
|
||||
File.open(outfile, "wb") { |f|
|
||||
f.write(0xef.chr)
|
||||
f.write(0xbb.chr)
|
||||
f.write(0xbf.chr)
|
||||
@@ -456,103 +456,103 @@ class Messages
|
||||
f.write("# translate every second line of this file.\r\n")
|
||||
if origMessages.messages[0]
|
||||
for i in 0...origMessages.messages[0].length
|
||||
msgs=origMessages.messages[0][i]
|
||||
Messages.writeObject(f,msgs,"Map#{i}",origMessages)
|
||||
msgs = origMessages.messages[0][i]
|
||||
Messages.writeObject(f, msgs, "Map#{i}", origMessages)
|
||||
end
|
||||
end
|
||||
for i in 1...origMessages.messages.length
|
||||
msgs=origMessages.messages[i]
|
||||
Messages.writeObject(f,msgs,i,origMessages)
|
||||
msgs = origMessages.messages[i]
|
||||
Messages.writeObject(f, msgs, i, origMessages)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def setMessages(type,array)
|
||||
@messages=[] if !@messages
|
||||
arr=[]
|
||||
def setMessages(type, array)
|
||||
@messages = [] if !@messages
|
||||
arr = []
|
||||
for i in 0...array.length
|
||||
arr[i]=(array[i]) ? array[i] : ""
|
||||
arr[i] = (array[i]) ? array[i] : ""
|
||||
end
|
||||
@messages[type]=arr
|
||||
@messages[type] = arr
|
||||
end
|
||||
|
||||
def addMessages(type,array)
|
||||
@messages=[] if !@messages
|
||||
arr=(@messages[type]) ? @messages[type] : []
|
||||
def addMessages(type, array)
|
||||
@messages = [] if !@messages
|
||||
arr = (@messages[type]) ? @messages[type] : []
|
||||
for i in 0...array.length
|
||||
arr[i]=(array[i]) ? array[i] : (arr[i]) ? arr[i] : ""
|
||||
arr[i] = (array[i]) ? array[i] : (arr[i]) ? arr[i] : ""
|
||||
end
|
||||
@messages[type]=arr
|
||||
@messages[type] = arr
|
||||
end
|
||||
|
||||
def self.createHash(_type,array)
|
||||
arr=OrderedHash.new
|
||||
def self.createHash(_type, array)
|
||||
arr = OrderedHash.new
|
||||
for i in 0...array.length
|
||||
if array[i]
|
||||
key=Messages.stringToKey(array[i])
|
||||
arr[key]=array[i]
|
||||
key = Messages.stringToKey(array[i])
|
||||
arr[key] = array[i]
|
||||
end
|
||||
end
|
||||
return arr
|
||||
end
|
||||
|
||||
def self.addToHash(_type,array,hash)
|
||||
hash=OrderedHash.new if !hash
|
||||
def self.addToHash(_type, array, hash)
|
||||
hash = OrderedHash.new if !hash
|
||||
for i in 0...array.length
|
||||
if array[i]
|
||||
key=Messages.stringToKey(array[i])
|
||||
hash[key]=array[i]
|
||||
key = Messages.stringToKey(array[i])
|
||||
hash[key] = array[i]
|
||||
end
|
||||
end
|
||||
return hash
|
||||
end
|
||||
|
||||
def setMapMessagesAsHash(type,array)
|
||||
@messages=[] if !@messages
|
||||
@messages[0]=[] if !@messages[0]
|
||||
@messages[0][type]=Messages.createHash(type,array)
|
||||
def setMapMessagesAsHash(type, array)
|
||||
@messages = [] if !@messages
|
||||
@messages[0] = [] if !@messages[0]
|
||||
@messages[0][type] = Messages.createHash(type, array)
|
||||
end
|
||||
|
||||
def addMapMessagesAsHash(type,array)
|
||||
@messages=[] if !@messages
|
||||
@messages[0]=[] if !@messages[0]
|
||||
@messages[0][type]=Messages.addToHash(type,array,@messages[0][type])
|
||||
def addMapMessagesAsHash(type, array)
|
||||
@messages = [] if !@messages
|
||||
@messages[0] = [] if !@messages[0]
|
||||
@messages[0][type] = Messages.addToHash(type, array, @messages[0][type])
|
||||
end
|
||||
|
||||
def setMessagesAsHash(type,array)
|
||||
@messages=[] if !@messages
|
||||
@messages[type]=Messages.createHash(type,array)
|
||||
def setMessagesAsHash(type, array)
|
||||
@messages = [] if !@messages
|
||||
@messages[type] = Messages.createHash(type, array)
|
||||
end
|
||||
|
||||
def addMessagesAsHash(type,array)
|
||||
@messages=[] if !@messages
|
||||
@messages[type]=Messages.addToHash(type,array,@messages[type])
|
||||
def addMessagesAsHash(type, array)
|
||||
@messages = [] if !@messages
|
||||
@messages[type] = Messages.addToHash(type, array, @messages[type])
|
||||
end
|
||||
|
||||
def saveMessages(filename = nil)
|
||||
filename="Data/messages.dat" if !filename
|
||||
File.open(filename,"wb") { |f| Marshal.dump(@messages,f) }
|
||||
filename = "Data/messages.dat" if !filename
|
||||
File.open(filename, "wb") { |f| Marshal.dump(@messages, f) }
|
||||
end
|
||||
|
||||
def loadMessageFile(filename)
|
||||
begin
|
||||
pbRgssOpen(filename,"rb") { |f| @messages=Marshal.load(f) }
|
||||
pbRgssOpen(filename, "rb") { |f| @messages = Marshal.load(f) }
|
||||
if !@messages.is_a?(Array)
|
||||
@messages=nil
|
||||
@messages = nil
|
||||
raise "Corrupted data"
|
||||
end
|
||||
return @messages
|
||||
rescue
|
||||
@messages=nil
|
||||
@messages = nil
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def set(type,id,value)
|
||||
def set(type, id, value)
|
||||
delayedLoad
|
||||
return if !@messages
|
||||
return if !@messages[type]
|
||||
@messages[type][id]=value
|
||||
@messages[type][id] = value
|
||||
end
|
||||
|
||||
def getCount(type)
|
||||
@@ -562,7 +562,7 @@ class Messages
|
||||
return @messages[type].length
|
||||
end
|
||||
|
||||
def get(type,id)
|
||||
def get(type, id)
|
||||
delayedLoad
|
||||
return "" if !@messages
|
||||
return "" if !@messages[type]
|
||||
@@ -570,21 +570,21 @@ class Messages
|
||||
return @messages[type][id]
|
||||
end
|
||||
|
||||
def getFromHash(type,key)
|
||||
def getFromHash(type, key)
|
||||
delayedLoad
|
||||
return key if !@messages || !@messages[type] || !key
|
||||
id=Messages.stringToKey(key)
|
||||
id = Messages.stringToKey(key)
|
||||
return key if !@messages[type][id]
|
||||
return @messages[type][id]
|
||||
end
|
||||
|
||||
def getFromMapHash(type,key)
|
||||
def getFromMapHash(type, key)
|
||||
delayedLoad
|
||||
return key if !@messages
|
||||
return key if !@messages[0]
|
||||
return key if !@messages[0][type] && !@messages[0][0]
|
||||
id=Messages.stringToKey(key)
|
||||
if @messages[0][type] && @messages[0][type][id]
|
||||
id = Messages.stringToKey(key)
|
||||
if @messages[0][type] && @messages[0][type][id]
|
||||
return @messages[0][type][id]
|
||||
elsif @messages[0][0] && @messages[0][0][id]
|
||||
return @messages[0][0][id]
|
||||
@@ -625,7 +625,7 @@ module MessageTypes
|
||||
RibbonDescriptions = 26
|
||||
StorageCreator = 27
|
||||
@@messages = Messages.new
|
||||
@@messagesFallback = Messages.new("Data/messages.dat",true)
|
||||
@@messagesFallback = Messages.new("Data/messages.dat", true)
|
||||
|
||||
def self.stringToKey(str)
|
||||
return Messages.stringToKey(str)
|
||||
@@ -639,7 +639,7 @@ module MessageTypes
|
||||
Messages.denormalizeValue(value)
|
||||
end
|
||||
|
||||
def self.writeObject(f,msgs,secname)
|
||||
def self.writeObject(f, msgs, secname)
|
||||
Messages.denormalizeValue(str)
|
||||
end
|
||||
|
||||
@@ -647,32 +647,32 @@ module MessageTypes
|
||||
@@messages.extract(outfile)
|
||||
end
|
||||
|
||||
def self.setMessages(type,array)
|
||||
@@messages.setMessages(type,array)
|
||||
def self.setMessages(type, array)
|
||||
@@messages.setMessages(type, array)
|
||||
end
|
||||
|
||||
def self.addMessages(type,array)
|
||||
@@messages.addMessages(type,array)
|
||||
def self.addMessages(type, array)
|
||||
@@messages.addMessages(type, array)
|
||||
end
|
||||
|
||||
def self.createHash(type,array)
|
||||
Messages.createHash(type,array)
|
||||
def self.createHash(type, array)
|
||||
Messages.createHash(type, array)
|
||||
end
|
||||
|
||||
def self.addMapMessagesAsHash(type,array)
|
||||
@@messages.addMapMessagesAsHash(type,array)
|
||||
def self.addMapMessagesAsHash(type, array)
|
||||
@@messages.addMapMessagesAsHash(type, array)
|
||||
end
|
||||
|
||||
def self.setMapMessagesAsHash(type,array)
|
||||
@@messages.setMapMessagesAsHash(type,array)
|
||||
def self.setMapMessagesAsHash(type, array)
|
||||
@@messages.setMapMessagesAsHash(type, array)
|
||||
end
|
||||
|
||||
def self.addMessagesAsHash(type,array)
|
||||
@@messages.addMessagesAsHash(type,array)
|
||||
def self.addMessagesAsHash(type, array)
|
||||
@@messages.addMessagesAsHash(type, array)
|
||||
end
|
||||
|
||||
def self.setMessagesAsHash(type,array)
|
||||
@@messages.setMessagesAsHash(type,array)
|
||||
def self.setMessagesAsHash(type, array)
|
||||
@@messages.setMessagesAsHash(type, array)
|
||||
end
|
||||
|
||||
def self.saveMessages(filename = nil)
|
||||
@@ -683,30 +683,30 @@ module MessageTypes
|
||||
@@messages.loadMessageFile(filename)
|
||||
end
|
||||
|
||||
def self.get(type,id)
|
||||
ret=@@messages.get(type,id)
|
||||
if ret==""
|
||||
ret=@@messagesFallback.get(type,id)
|
||||
def self.get(type, id)
|
||||
ret = @@messages.get(type, id)
|
||||
if ret == ""
|
||||
ret = @@messagesFallback.get(type, id)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def self.getCount(type)
|
||||
c1=@@messages.getCount(type)
|
||||
c2=@@messagesFallback.getCount(type)
|
||||
return c1>c2 ? c1 : c2
|
||||
c1 = @@messages.getCount(type)
|
||||
c2 = @@messagesFallback.getCount(type)
|
||||
return c1 > c2 ? c1 : c2
|
||||
end
|
||||
|
||||
def self.getOriginal(type,id)
|
||||
return @@messagesFallback.get(type,id)
|
||||
def self.getOriginal(type, id)
|
||||
return @@messagesFallback.get(type, id)
|
||||
end
|
||||
|
||||
def self.getFromHash(type,key)
|
||||
@@messages.getFromHash(type,key)
|
||||
def self.getFromHash(type, key)
|
||||
@@messages.getFromHash(type, key)
|
||||
end
|
||||
|
||||
def self.getFromMapHash(type,key)
|
||||
@@messages.getFromMapHash(type,key)
|
||||
def self.getFromMapHash(type, key)
|
||||
@@messages.getFromMapHash(type, key)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -720,25 +720,25 @@ def pbGetMessageCount(type)
|
||||
return MessageTypes.getCount(type)
|
||||
end
|
||||
|
||||
def pbGetMessage(type,id)
|
||||
return MessageTypes.get(type,id)
|
||||
def pbGetMessage(type, id)
|
||||
return MessageTypes.get(type, id)
|
||||
end
|
||||
|
||||
def pbGetMessageFromHash(type,id)
|
||||
return MessageTypes.getFromHash(type,id)
|
||||
def pbGetMessageFromHash(type, id)
|
||||
return MessageTypes.getFromHash(type, id)
|
||||
end
|
||||
|
||||
# Replaces first argument with a localized version and formats the other
|
||||
# parameters by replacing {1}, {2}, etc. with those placeholders.
|
||||
def _INTL(*arg)
|
||||
begin
|
||||
string=MessageTypes.getFromHash(MessageTypes::ScriptTexts,arg[0])
|
||||
string = MessageTypes.getFromHash(MessageTypes::ScriptTexts, arg[0])
|
||||
rescue
|
||||
string=arg[0]
|
||||
string = arg[0]
|
||||
end
|
||||
string=string.clone
|
||||
string = string.clone
|
||||
for i in 1...arg.length
|
||||
string.gsub!(/\{#{i}\}/,"#{arg[i]}")
|
||||
string.gsub!(/\{#{i}\}/, "#{arg[i]}")
|
||||
end
|
||||
return string
|
||||
end
|
||||
@@ -748,38 +748,38 @@ end
|
||||
# This version acts more like sprintf, supports e.g. {1:d} or {2:s}
|
||||
def _ISPRINTF(*arg)
|
||||
begin
|
||||
string=MessageTypes.getFromHash(MessageTypes::ScriptTexts,arg[0])
|
||||
string = MessageTypes.getFromHash(MessageTypes::ScriptTexts, arg[0])
|
||||
rescue
|
||||
string=arg[0]
|
||||
string = arg[0]
|
||||
end
|
||||
string=string.clone
|
||||
string = string.clone
|
||||
for i in 1...arg.length
|
||||
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m|
|
||||
next sprintf("%"+$1,arg[i])
|
||||
next sprintf("%" + $1, arg[i])
|
||||
}
|
||||
end
|
||||
return string
|
||||
end
|
||||
|
||||
def _I(str)
|
||||
return _MAPINTL($game_map.map_id,str)
|
||||
return _MAPINTL($game_map.map_id, str)
|
||||
end
|
||||
|
||||
def _MAPINTL(mapid,*arg)
|
||||
string=MessageTypes.getFromMapHash(mapid,arg[0])
|
||||
string=string.clone
|
||||
def _MAPINTL(mapid, *arg)
|
||||
string = MessageTypes.getFromMapHash(mapid, arg[0])
|
||||
string = string.clone
|
||||
for i in 1...arg.length
|
||||
string.gsub!(/\{#{i}\}/,"#{arg[i]}")
|
||||
string.gsub!(/\{#{i}\}/, "#{arg[i]}")
|
||||
end
|
||||
return string
|
||||
end
|
||||
|
||||
def _MAPISPRINTF(mapid,*arg)
|
||||
string=MessageTypes.getFromMapHash(mapid,arg[0])
|
||||
string=string.clone
|
||||
def _MAPISPRINTF(mapid, *arg)
|
||||
string = MessageTypes.getFromMapHash(mapid, arg[0])
|
||||
string = string.clone
|
||||
for i in 1...arg.length
|
||||
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m|
|
||||
next sprintf("%"+$1,arg[i])
|
||||
next sprintf("%" + $1, arg[i])
|
||||
}
|
||||
end
|
||||
return string
|
||||
|
||||
@@ -588,7 +588,7 @@ module PluginManager
|
||||
optional = false
|
||||
# clean the name to a simple string
|
||||
if dname.is_a?(Array)
|
||||
optional = [:optional,:optional_exact].include?(dname[0])
|
||||
optional = [:optional, :optional_exact].include?(dname[0])
|
||||
dname = dname[dname.length - 2]
|
||||
end
|
||||
# catch missing dependency
|
||||
@@ -710,7 +710,7 @@ module PluginManager
|
||||
# get rid of tabs
|
||||
code.gsub!("\t", " ")
|
||||
# construct filename
|
||||
sname = scr[0].gsub("\\","/").split("/")[-1]
|
||||
sname = scr[0].gsub("\\", "/").split("/")[-1]
|
||||
fname = "[#{name}] #{sname}"
|
||||
# try to run the code
|
||||
begin
|
||||
|
||||
@@ -199,16 +199,16 @@ class SpriteAnimation
|
||||
sprite.visible = false if sprite != nil
|
||||
next
|
||||
end
|
||||
sprite.x = sprite_x + cell_data[i, 1]
|
||||
sprite.y = sprite_y + cell_data[i, 2]
|
||||
sprite.x = sprite_x + cell_data[i, 1]
|
||||
sprite.y = sprite_y + cell_data[i, 2]
|
||||
next if quick_update
|
||||
sprite.visible = true
|
||||
sprite.visible = true
|
||||
sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
|
||||
case @_animation_height
|
||||
when 0 then sprite.z = 1
|
||||
when 1 then sprite.z = sprite.y+32+15
|
||||
when 2 then sprite.z = sprite.y+32+32+17
|
||||
else sprite.z = 2000
|
||||
when 0 then sprite.z = 1
|
||||
when 1 then sprite.z = sprite.y + 32 + 15
|
||||
when 2 then sprite.z = sprite.y + 32 + 32 + 17
|
||||
else sprite.z = 2000
|
||||
end
|
||||
sprite.ox = 96
|
||||
sprite.oy = 96
|
||||
@@ -299,9 +299,9 @@ module RPG
|
||||
end
|
||||
|
||||
def whiten
|
||||
self.blend_type = 0
|
||||
self.blend_type = 0
|
||||
self.color.set(255, 255, 255, 128)
|
||||
self.opacity = 255
|
||||
self.opacity = 255
|
||||
@_whiten_duration = 16
|
||||
@_appear_duration = 0
|
||||
@_escape_duration = 0
|
||||
@@ -345,10 +345,10 @@ module RPG
|
||||
bitmap.font.name = "Arial Black"
|
||||
bitmap.font.size = 32
|
||||
bitmap.font.color.set(0, 0, 0)
|
||||
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
|
||||
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
|
||||
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
|
||||
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
|
||||
bitmap.draw_text(-1, 12 - 1, 160, 36, damage_string, 1)
|
||||
bitmap.draw_text(+1, 12 - 1, 160, 36, damage_string, 1)
|
||||
bitmap.draw_text(-1, 12 + 1, 160, 36, damage_string, 1)
|
||||
bitmap.draw_text(+1, 12 + 1, 160, 36, damage_string, 1)
|
||||
if value.is_a?(Numeric) && value < 0
|
||||
bitmap.font.color.set(176, 255, 144)
|
||||
else
|
||||
@@ -386,14 +386,14 @@ module RPG
|
||||
|
||||
def animation(animation, hit, height = 3)
|
||||
anim = SpriteAnimation.new(self)
|
||||
anim.animation(animation,hit,height)
|
||||
pushAnimation(@animations,anim)
|
||||
anim.animation(animation, hit, height)
|
||||
pushAnimation(@animations, anim)
|
||||
end
|
||||
|
||||
def loop_animation(animation)
|
||||
anim = SpriteAnimation.new(self)
|
||||
anim.loop_animation(animation)
|
||||
pushAnimation(@loopAnimations,anim)
|
||||
pushAnimation(@loopAnimations, anim)
|
||||
end
|
||||
|
||||
def dispose_damage
|
||||
|
||||
Reference in New Issue
Block a user