mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 14:14:59 +00:00
Merge branch 'dev' into ai
This commit is contained in:
@@ -2,9 +2,7 @@
|
||||
# Reads files of certain format from a directory
|
||||
#===============================================================================
|
||||
class Dir
|
||||
#-----------------------------------------------------------------------------
|
||||
# Reads all files in a directory
|
||||
#-----------------------------------------------------------------------------
|
||||
# Reads all files in a directory
|
||||
def self.get(dir, filters = "*", full = true)
|
||||
files = []
|
||||
filters = [filters] if !filters.is_a?(Array)
|
||||
@@ -15,9 +13,8 @@ class Dir
|
||||
end
|
||||
return files.sort
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
# Generates entire file/folder tree from a certain directory
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Generates entire file/folder tree from a certain directory
|
||||
def self.all(dir, filters = "*", full = true)
|
||||
# sets variables for starting
|
||||
files = []
|
||||
@@ -33,81 +30,67 @@ class Dir
|
||||
# returns all found files
|
||||
return files + subfolders
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
# Checks for existing directory, gets around accents
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Checks for existing directory, gets around accents
|
||||
def self.safe?(dir)
|
||||
return false if !FileTest.directory?(dir)
|
||||
ret = false
|
||||
self.chdir(dir) { ret = true } rescue nil
|
||||
return ret
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
# Creates all the required directories for filename path
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Creates all the required directories for filename path
|
||||
def self.create(path)
|
||||
path.gsub!("\\", "/") # Windows compatibility
|
||||
# get path tree
|
||||
dirs = path.split("/")
|
||||
full = ""
|
||||
for dir in dirs
|
||||
dirs.each do |dir|
|
||||
full += dir + "/"
|
||||
# creates directories
|
||||
self.mkdir(full) if !self.safe?(full)
|
||||
end
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
# Generates entire folder tree from a certain directory
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Generates entire folder tree from a certain directory
|
||||
def self.all_dirs(dir)
|
||||
# sets variables for starting
|
||||
dirs = []
|
||||
for file in self.get(dir, "*", true)
|
||||
self.get(dir, "*", true).each do |file|
|
||||
# engages in recursion to read the entire folder tree
|
||||
dirs += self.all_dirs(file) if self.safe?(file)
|
||||
end
|
||||
# returns all found directories
|
||||
return dirs.length > 0 ? (dirs + [dir]) : [dir]
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
# Deletes all the files in a directory and all the sub directories (allows for non-empty dirs)
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Deletes all the files in a directory and all the sub directories (allows for non-empty dirs)
|
||||
def self.delete_all(dir)
|
||||
# delete all files in dir
|
||||
self.all(dir).each { |f| File.delete(f) }
|
||||
# delete all dirs in dir
|
||||
self.all_dirs(dir).each { |f| Dir.delete(f) }
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# extensions for file class
|
||||
# Extensions for file class
|
||||
#===============================================================================
|
||||
class File
|
||||
#-----------------------------------------------------------------------------
|
||||
# Checks for existing file, gets around accents
|
||||
#-----------------------------------------------------------------------------
|
||||
# Checks for existing file, gets around accents
|
||||
def self.safe?(file)
|
||||
ret = false
|
||||
self.open(file, "rb") { ret = true } rescue nil
|
||||
return ret
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
# Checks for existing .rxdata file
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Checks for existing .rxdata file
|
||||
def self.safeData?(file)
|
||||
ret = false
|
||||
ret = (load_data(file) ? true : false) rescue false
|
||||
return ret
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Checking for files and directories
|
||||
#===============================================================================
|
||||
@@ -137,10 +120,10 @@ def safeGlob(dir, wildcard)
|
||||
ret = []
|
||||
afterChdir = false
|
||||
begin
|
||||
Dir.chdir(dir) {
|
||||
Dir.chdir(dir) do
|
||||
afterChdir = true
|
||||
Dir.glob(wildcard) { |f| ret.push(dir + "/" + f) }
|
||||
}
|
||||
end
|
||||
rescue Errno::ENOENT
|
||||
raise if afterChdir
|
||||
end
|
||||
@@ -168,13 +151,13 @@ def pbResolveBitmap(x)
|
||||
# filename = pbTryString(path) if !filename
|
||||
# filename = pbTryString(path + ".gif") if !filename
|
||||
# }
|
||||
RTP.eachPathFor(noext) { |path|
|
||||
RTP.eachPathFor(noext) do |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
|
||||
}
|
||||
end
|
||||
return filename
|
||||
end
|
||||
|
||||
@@ -219,19 +202,20 @@ def canonicalize(c)
|
||||
return retstr
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
module RTP
|
||||
@rtpPaths = nil
|
||||
|
||||
def self.exists?(filename, extensions = [])
|
||||
return false if nil_or_empty?(filename)
|
||||
eachPathFor(filename) { |path|
|
||||
eachPathFor(filename) do |path|
|
||||
return true if safeExists?(path)
|
||||
extensions.each do |ext|
|
||||
return true if safeExists?(path + ext)
|
||||
end
|
||||
}
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -245,17 +229,17 @@ module RTP
|
||||
|
||||
def self.getPath(filename, extensions = [])
|
||||
return filename if nil_or_empty?(filename)
|
||||
eachPathFor(filename) { |path|
|
||||
eachPathFor(filename) do |path|
|
||||
return path if safeExists?(path)
|
||||
extensions.each do |ext|
|
||||
file = path + ext
|
||||
return file if safeExists?(file)
|
||||
end
|
||||
}
|
||||
end
|
||||
return filename
|
||||
end
|
||||
|
||||
# Gets the absolute RGSS paths for the given file name
|
||||
# Gets the absolute RGSS paths for the given file name
|
||||
def self.eachPathFor(filename)
|
||||
return if !filename
|
||||
if filename[/^[A-Za-z]\:[\/\\]/] || filename[/^[\/\\]/]
|
||||
@@ -263,13 +247,13 @@ module RTP
|
||||
yield filename
|
||||
else
|
||||
# relative path
|
||||
RTP.eachPath { |path|
|
||||
RTP.eachPath do |path|
|
||||
if path == "./"
|
||||
yield filename
|
||||
else
|
||||
yield path + filename
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -299,8 +283,9 @@ module RTP
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
module FileTest
|
||||
IMAGE_EXTENSIONS = [".png", ".gif"] # ".jpg", ".jpeg", ".bmp",
|
||||
AUDIO_EXTENSIONS = [".mid", ".midi", ".ogg", ".wav", ".wma"] # ".mp3"
|
||||
@@ -314,27 +299,23 @@ module FileTest
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
# Used to determine whether a data file exists (rather than a graphics or
|
||||
# audio file). Doesn't check RTP, but does check encrypted archives.
|
||||
|
||||
# NOTE: pbGetFileChar checks anything added in MKXP's RTP setting,
|
||||
# and matching mount points added through System.mount
|
||||
# NOTE: pbGetFileChar checks anything added in MKXP's RTP setting, and matching
|
||||
# mount points added through System.mount.
|
||||
def pbRgssExists?(filename)
|
||||
if safeExists?("./Game.rgssad")
|
||||
return pbGetFileChar(filename) != nil
|
||||
else
|
||||
filename = canonicalize(filename)
|
||||
return safeExists?(filename)
|
||||
end
|
||||
return !pbGetFileChar(filename).nil? if safeExists?("./Game.rgssad")
|
||||
filename = canonicalize(filename)
|
||||
return safeExists?(filename)
|
||||
end
|
||||
|
||||
# Opens an IO, even if the file is in an encrypted archive.
|
||||
# Doesn't check RTP for the file.
|
||||
|
||||
# NOTE: load_data checks anything added in MKXP's RTP setting,
|
||||
# and matching mount points added through System.mount
|
||||
# NOTE: load_data checks anything added in MKXP's RTP setting, and matching
|
||||
# mount points added through System.mount.
|
||||
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")
|
||||
@@ -385,9 +366,8 @@ end
|
||||
|
||||
# Gets the contents of a file. Doesn't check RTP, but does check
|
||||
# encrypted archives.
|
||||
|
||||
# NOTE: load_data will check anything added in MKXP's RTP setting,
|
||||
# and matching mount points added through System.mount
|
||||
# NOTE: load_data will check anything added in MKXP's RTP setting, and matching
|
||||
# mount points added through System.mount.
|
||||
def pbGetFileString(file)
|
||||
file = canonicalize(file)
|
||||
if !safeExists?("./Game.rgssad")
|
||||
@@ -407,14 +387,14 @@ def pbGetFileString(file)
|
||||
return str
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class StringInput
|
||||
include Enumerable
|
||||
|
||||
attr_reader :lineno, :string
|
||||
|
||||
class << self
|
||||
def new(str)
|
||||
if block_given?
|
||||
@@ -438,8 +418,6 @@ class StringInput
|
||||
@lineno = 0
|
||||
end
|
||||
|
||||
attr_reader :lineno, :string
|
||||
|
||||
def inspect
|
||||
return "#<#{self.class}:#{@closed ? 'closed' : 'open'},src=#{@string[0, 30].inspect}>"
|
||||
end
|
||||
|
||||
@@ -109,22 +109,21 @@ module FileOutputMixin
|
||||
end
|
||||
|
||||
class File < IO
|
||||
=begin
|
||||
unless defined?(debugopen)
|
||||
class << self
|
||||
alias debugopen open
|
||||
end
|
||||
end
|
||||
# unless defined?(debugopen)
|
||||
# class << self
|
||||
# alias debugopen open
|
||||
# end
|
||||
# end
|
||||
|
||||
# def open(f, m = "r")
|
||||
# debugopen("debug.txt", "ab") { |file| file.write([f, m, Time.now.to_f].inspect + "\r\n") }
|
||||
# if block_given?
|
||||
# debugopen(f, m) { |file| yield file }
|
||||
# else
|
||||
# return debugopen(f, m)
|
||||
# end
|
||||
# end
|
||||
|
||||
def open(f, m = "r")
|
||||
debugopen("debug.txt", "ab") { |file| file.write([f, m, Time.now.to_f].inspect + "\r\n") }
|
||||
if block_given?
|
||||
debugopen(f, m) { |file| yield file }
|
||||
else
|
||||
return debugopen(f, m)
|
||||
end
|
||||
end
|
||||
=end
|
||||
include FileInputMixin
|
||||
include FileOutputMixin
|
||||
end
|
||||
|
||||
@@ -9,13 +9,13 @@ def pbPostData(url, postdata, filename = nil, depth = 0)
|
||||
# path = $2
|
||||
# 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|
|
||||
body = postdata.map do |key, value|
|
||||
keyString = key.to_s
|
||||
valueString = value.to_s
|
||||
keyString.gsub!(/[^a-zA-Z0-9_\.\-]/n) { |s| sprintf("%%%02x", s[0]) }
|
||||
valueString.gsub!(/[^a-zA-Z0-9_\.\-]/n) { |s| sprintf("%%%02x", s[0]) }
|
||||
next "#{keyString}=#{valueString}"
|
||||
}.join("&")
|
||||
end.join("&")
|
||||
ret = HTTPLite.post_body(
|
||||
url,
|
||||
body,
|
||||
|
||||
@@ -168,24 +168,26 @@ class Color
|
||||
|
||||
# New constructor, accepts RGB values as well as a hex number or string value.
|
||||
def initialize(*args)
|
||||
pbPrintException("Wrong number of arguments! At least 1 is needed!") if args.length < 1
|
||||
if args.length == 1
|
||||
if args.first.is_a?(Fixnum)
|
||||
pbPrintException("Wrong number of arguments! At least 1 is needed!") if args.length < 1
|
||||
case args.length
|
||||
when 1
|
||||
case args.first
|
||||
when Integer
|
||||
hex = args.first.to_s(16)
|
||||
elsif args.first.is_a?(String)
|
||||
when String
|
||||
try_rgb_format = args.first.split(",")
|
||||
return init_original(*try_rgb_format.map(&:to_i)) if try_rgb_format.length.between?(3, 4)
|
||||
init_original(*try_rgb_format.map(&:to_i)) if try_rgb_format.length.between?(3, 4)
|
||||
hex = args.first.delete("#")
|
||||
end
|
||||
pbPrintException("Wrong type of argument given!") if !hex
|
||||
r = hex[0...2].to_i(16)
|
||||
g = hex[2...4].to_i(16)
|
||||
b = hex[4...6].to_i(16)
|
||||
elsif args.length == 3
|
||||
when 3
|
||||
r, g, b = *args
|
||||
end
|
||||
return init_original(r, g, b) if r && g && b
|
||||
return init_original(*args)
|
||||
end
|
||||
init_original(r, g, b) if r && g && b
|
||||
init_original(*args)
|
||||
end
|
||||
|
||||
def self.new_from_rgb(param)
|
||||
@@ -242,7 +244,9 @@ class Color
|
||||
|
||||
# @return [String] this color in the format "RRGGBBAA" (or "RRGGBB" if this color's alpha is 255)
|
||||
def to_rgb32(always_include_alpha = false)
|
||||
return sprintf("%02X%02X%02X", self.red.to_i, self.green.to_i, self.blue.to_i) if self.alpha.to_i == 255 && !always_include_alpha
|
||||
if self.alpha.to_i == 255 && !always_include_alpha
|
||||
return sprintf("%02X%02X%02X", self.red.to_i, self.green.to_i, self.blue.to_i)
|
||||
end
|
||||
return sprintf("%02X%02X%02X%02X", self.red.to_i, self.green.to_i, self.blue.to_i, self.alpha.to_i)
|
||||
end
|
||||
|
||||
@@ -253,7 +257,7 @@ class Color
|
||||
|
||||
# @return [Integer] this color in RGB format converted to an integer
|
||||
def to_i
|
||||
return self.to_rgb24.to_i(16)
|
||||
return self.to_rgb24.to_i(16)
|
||||
end
|
||||
|
||||
# @return [Color] the contrasting color to this one
|
||||
@@ -282,11 +286,11 @@ class Color
|
||||
# Converts the provided hex string/24-bit integer to RGB values.
|
||||
def self.hex_to_rgb(hex)
|
||||
hex = hex.delete("#") if hex.is_a?(String)
|
||||
hex = hex.to_s(16) if hex.is_a?(Numeric)
|
||||
r = hex[0...2].to_i(16)
|
||||
g = hex[2...4].to_i(16)
|
||||
b = hex[4...6].to_i(16)
|
||||
return r, g, b
|
||||
hex = hex.to_s(16) if hex.is_a?(Numeric)
|
||||
r = hex[0...2].to_i(16)
|
||||
g = hex[2...4].to_i(16)
|
||||
b = hex[4...6].to_i(16)
|
||||
return r, g, b
|
||||
end
|
||||
|
||||
# Parses the input as a Color and returns a Color object made from it.
|
||||
|
||||
@@ -45,7 +45,7 @@ module Translator
|
||||
end
|
||||
end
|
||||
end
|
||||
MessageTypes.addMessagesAsHash(MessageTypes::ScriptTexts, texts)
|
||||
MessageTypes.addMessagesAsHash(MessageTypes::SCRIPT_TEXTS, texts)
|
||||
# Find all text in common events and add them to messages
|
||||
commonevents = load_data("Data/CommonEvents.rxdata")
|
||||
items = []
|
||||
@@ -87,7 +87,7 @@ module Translator
|
||||
elsif list.code == 209 # Set Move Route
|
||||
route = list.parameters[1]
|
||||
route.list.size.times do |k|
|
||||
if route.list[k].code == PBMoveRoute::Script
|
||||
if route.list[k].code == PBMoveRoute::SCRIPT
|
||||
find_translatable_text_from_event_script(items, route.list[k].parameters[0])
|
||||
end
|
||||
end
|
||||
@@ -157,7 +157,7 @@ module Translator
|
||||
elsif list.code == 209 # Set Move Route
|
||||
route = list.parameters[1]
|
||||
route.list.size.times do |k|
|
||||
if route.list[k].code == PBMoveRoute::Script
|
||||
if route.list[k].code == PBMoveRoute::SCRIPT
|
||||
find_translatable_text_from_event_script(items, route.list[k].parameters[0])
|
||||
end
|
||||
end
|
||||
@@ -190,7 +190,7 @@ module Translator
|
||||
|
||||
def find_translatable_text_from_RGSS_script(items, script)
|
||||
script.force_encoding(Encoding::UTF_8)
|
||||
script.scan(/(?:_INTL|_ISPRINTF)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) { |s|
|
||||
script.scan(/(?:_INTL|_ISPRINTF)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) do |s|
|
||||
string = s[0]
|
||||
string.gsub!(/\\r/, "\r")
|
||||
string.gsub!(/\\n/, "\n")
|
||||
@@ -198,17 +198,17 @@ module Translator
|
||||
string.gsub!(/\\\"/, "\"")
|
||||
string.gsub!(/\\\\/, "\\")
|
||||
items.push(string)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def find_translatable_text_from_event_script(items, script)
|
||||
script.force_encoding(Encoding::UTF_8)
|
||||
script.scan(/(?:_I)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) { |s|
|
||||
script.scan(/(?:_I)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) do |s|
|
||||
string = s[0]
|
||||
string.gsub!(/\\\"/, "\"")
|
||||
string.gsub!(/\\\\/, "\\")
|
||||
items.push(string)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def normalize_value(value)
|
||||
@@ -239,7 +239,7 @@ module Translator
|
||||
return value
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
def extract_text(language_name = "default", core_text = false, separate_map_files = false)
|
||||
dir_name = sprintf("Text_%s_%s", language_name, (core_text) ? "core" : "game")
|
||||
@@ -267,7 +267,10 @@ module Translator
|
||||
# existing destination folder
|
||||
if Dir.safe?(dir_name)
|
||||
has_files = false
|
||||
Dir.all(dir_name).each { |f| has_files = true; break }
|
||||
Dir.all(dir_name).each do |f|
|
||||
has_files = true
|
||||
break
|
||||
end
|
||||
if has_files && !pbConfirmMessageSerious(_INTL("Replace all text files in folder '{1}'?", dir_name))
|
||||
pbDisposeMessageWindow(msg_window)
|
||||
return
|
||||
@@ -293,18 +296,18 @@ module Translator
|
||||
max_section_id.times do |i|
|
||||
section_name = getConstantName(MessageTypes, i, false)
|
||||
next if !section_name
|
||||
if i == MessageTypes::EventTexts
|
||||
if i == MessageTypes::EVENT_TEXTS
|
||||
if separate_map_files
|
||||
map_infos = pbLoadMapInfos
|
||||
default_messages[i].each_with_index do |map_msgs, map_id|
|
||||
next if !map_msgs || map_msgs.length == 0
|
||||
filename = sprintf("Map%03d", map_id)
|
||||
filename += " " + map_infos[map_id].name if map_infos[map_id]
|
||||
File.open(dir_name + "/" + filename + ".txt", "wb") { |f|
|
||||
File.open(dir_name + "/" + filename + ".txt", "wb") do |f|
|
||||
write_header.call(f, true)
|
||||
translated_msgs = language_messages[i][map_id] if language_messages && language_messages[i]
|
||||
write_section_texts_to_file(f, sprintf("Map%03d", map_id), translated_msgs, map_msgs)
|
||||
}
|
||||
end
|
||||
end
|
||||
else
|
||||
next if !default_messages[i] || default_messages[i].length == 0
|
||||
@@ -314,7 +317,7 @@ module Translator
|
||||
break if !map_msgs
|
||||
end
|
||||
next if no_difference
|
||||
File.open(dir_name + "/" + section_name + ".txt", "wb") { |f|
|
||||
File.open(dir_name + "/" + section_name + ".txt", "wb") do |f|
|
||||
write_header.call(f, false)
|
||||
default_messages[i].each_with_index do |map_msgs, map_id|
|
||||
next if !map_msgs || map_msgs.length == 0
|
||||
@@ -322,15 +325,15 @@ module Translator
|
||||
translated_msgs = (language_messages && language_messages[i]) ? language_messages[i][map_id] : nil
|
||||
write_section_texts_to_file(f, sprintf("Map%03d", map_id), translated_msgs, map_msgs)
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
else # MessageTypes sections
|
||||
next if !default_messages[i] || default_messages[i].length == 0
|
||||
File.open(dir_name + "/" + section_name + ".txt", "wb") { |f|
|
||||
File.open(dir_name + "/" + section_name + ".txt", "wb") do |f|
|
||||
write_header.call(f, true)
|
||||
translated_msgs = (language_messages) ? language_messages[i] : nil
|
||||
write_section_texts_to_file(f, section_name, translated_msgs, default_messages[i])
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
msg_window.textspeed = MessageConfig.pbSettingToTextSpeed($PokemonSystem.textspeed)
|
||||
@@ -368,7 +371,7 @@ module Translator
|
||||
end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
def compile_text(dir_name, dat_filename)
|
||||
msg_window = pbCreateMessageWindow
|
||||
@@ -449,16 +452,16 @@ module Translator
|
||||
break if i >= contents.length
|
||||
end
|
||||
# Add ordered list/hash (text_hash) to array of all text (all_text)
|
||||
all_text[MessageTypes::EventTexts] = [] if is_map && !all_text[MessageTypes::EventTexts]
|
||||
target_section = (is_map) ? all_text[MessageTypes::EventTexts][section_id] : all_text[section_id]
|
||||
all_text[MessageTypes::EVENT_TEXTS] = [] if is_map && !all_text[MessageTypes::EVENT_TEXTS]
|
||||
target_section = (is_map) ? all_text[MessageTypes::EVENT_TEXTS][section_id] : all_text[section_id]
|
||||
if target_section
|
||||
if text_hash.is_a?(Hash)
|
||||
text_hash.keys.each { |key| target_section[key] = text_hash[key] if text_hash[key] }
|
||||
text_hash.each_key { |key| target_section[key] = text_hash[key] if text_hash[key] }
|
||||
else # text_hash is an array
|
||||
text_hash.each_with_index { |line, i| target_section[i] = line if line }
|
||||
text_hash.each_with_index { |line, j| target_section[j] = line if line }
|
||||
end
|
||||
elsif is_map
|
||||
all_text[MessageTypes::EventTexts][section_id] = text_hash
|
||||
all_text[MessageTypes::EVENT_TEXTS][section_id] = text_hash
|
||||
else
|
||||
all_text[section_id] = text_hash
|
||||
end
|
||||
@@ -567,15 +570,16 @@ class Translation
|
||||
|
||||
def setMapMessagesAsHash(map_id, array)
|
||||
load_default_messages
|
||||
@default_game_messages[MessageTypes::EventTexts] ||= []
|
||||
@default_game_messages[MessageTypes::EventTexts][map_id] = priv_add_to_hash(MessageTypes::EventTexts, array, nil, map_id)
|
||||
@default_game_messages[MessageTypes::EVENT_TEXTS] ||= []
|
||||
@default_game_messages[MessageTypes::EVENT_TEXTS][map_id] = priv_add_to_hash(MessageTypes::EVENT_TEXTS,
|
||||
array, nil, map_id)
|
||||
end
|
||||
|
||||
def addMapMessagesAsHash(map_id, array)
|
||||
load_default_messages
|
||||
@default_game_messages[MessageTypes::EventTexts] ||= []
|
||||
@default_game_messages[MessageTypes::EventTexts][map_id] = priv_add_to_hash(
|
||||
MessageTypes::EventTexts, array, @default_game_messages[MessageTypes::EventTexts][map_id], map_id)
|
||||
@default_game_messages[MessageTypes::EVENT_TEXTS] ||= []
|
||||
@default_game_messages[MessageTypes::EVENT_TEXTS][map_id] = priv_add_to_hash(MessageTypes::EVENT_TEXTS,
|
||||
array, @default_game_messages[MessageTypes::EVENT_TEXTS][map_id], map_id)
|
||||
end
|
||||
|
||||
def get(type, id)
|
||||
@@ -606,23 +610,25 @@ class Translation
|
||||
delayed_load_message_files
|
||||
key = Translation.stringToKey(text)
|
||||
return text if nil_or_empty?(key)
|
||||
if @game_messages && @game_messages[MessageTypes::EventTexts]
|
||||
if @game_messages[MessageTypes::EventTexts][map_id] && @game_messages[MessageTypes::EventTexts][map_id][key]
|
||||
return @game_messages[MessageTypes::EventTexts][map_id][key]
|
||||
elsif @game_messages[MessageTypes::EventTexts][0] && @game_messages[MessageTypes::EventTexts][0][key]
|
||||
return @game_messages[MessageTypes::EventTexts][0][key]
|
||||
if @game_messages && @game_messages[MessageTypes::EVENT_TEXTS]
|
||||
if @game_messages[MessageTypes::EVENT_TEXTS][map_id] && @game_messages[MessageTypes::EVENT_TEXTS][map_id][key]
|
||||
return @game_messages[MessageTypes::EVENT_TEXTS][map_id][key]
|
||||
elsif @game_messages[MessageTypes::EVENT_TEXTS][0] && @game_messages[MessageTypes::EVENT_TEXTS][0][key]
|
||||
return @game_messages[MessageTypes::EVENT_TEXTS][0][key]
|
||||
end
|
||||
end
|
||||
if @core_messages && @core_messages[MessageTypes::EventTexts]
|
||||
if @core_messages[MessageTypes::EventTexts][map_id] && @core_messages[MessageTypes::EventTexts][map_id][key]
|
||||
return @core_messages[MessageTypes::EventTexts][map_id][key]
|
||||
elsif @core_messages[MessageTypes::EventTexts][0] && @core_messages[MessageTypes::EventTexts][0][key]
|
||||
return @core_messages[MessageTypes::EventTexts][0][key]
|
||||
if @core_messages && @core_messages[MessageTypes::EVENT_TEXTS]
|
||||
if @core_messages[MessageTypes::EVENT_TEXTS][map_id] && @core_messages[MessageTypes::EVENT_TEXTS][map_id][key]
|
||||
return @core_messages[MessageTypes::EVENT_TEXTS][map_id][key]
|
||||
elsif @core_messages[MessageTypes::EVENT_TEXTS][0] && @core_messages[MessageTypes::EVENT_TEXTS][0][key]
|
||||
return @core_messages[MessageTypes::EVENT_TEXTS][0][key]
|
||||
end
|
||||
end
|
||||
return text
|
||||
end
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
private
|
||||
|
||||
def delayed_load_message_files
|
||||
@@ -641,7 +647,7 @@ class Translation
|
||||
end
|
||||
|
||||
def priv_add_to_hash(type, array, ret, map_id = 0)
|
||||
if type == MessageTypes::EventTexts
|
||||
if type == MessageTypes::EVENT_TEXTS
|
||||
@default_core_messages[type] ||= []
|
||||
@default_core_messages[type][map_id] ||= {}
|
||||
default_keys = @default_core_messages[type][map_id].keys
|
||||
@@ -666,36 +672,36 @@ module MessageTypes
|
||||
# NOTE: These constants aren't numbered in any particular order, but these
|
||||
# numbers are retained for backwards compatibility with older extracted
|
||||
# text files.
|
||||
EventTexts = 0 # Used for text in both common events and map events
|
||||
Species = 1
|
||||
SpeciesCategories = 2
|
||||
PokedexEntries = 3
|
||||
SpeciesForms = 4
|
||||
Moves = 5
|
||||
MoveDescriptions = 6
|
||||
Items = 7
|
||||
ItemPlurals = 8
|
||||
ItemDescriptions = 9
|
||||
Abilities = 10
|
||||
AbilityDescriptions = 11
|
||||
Types = 12
|
||||
TrainerTypes = 13
|
||||
TrainerNames = 14
|
||||
FrontierIntroSpeeches = 15
|
||||
FrontierEndSpeechesWin = 16
|
||||
FrontierEndSpeechesLose = 17
|
||||
Regions = 18
|
||||
RegionLocations = 19
|
||||
RegionDescriptions = 20
|
||||
MapNames = 21
|
||||
PhoneMessages = 22
|
||||
TrainerLoseTexts = 23
|
||||
ScriptTexts = 24
|
||||
RibbonNames = 25
|
||||
RibbonDescriptions = 26
|
||||
StorageCreator = 27
|
||||
ItemPortions = 28
|
||||
ItemPortionPlurals = 29
|
||||
EVENT_TEXTS = 0 # Used for text in both common events and map events
|
||||
SPECIES_NAMES = 1
|
||||
SPECIES_CATEGORIES = 2
|
||||
POKEDEX_ENTRIES = 3
|
||||
SPECIES_FORM_NAMES = 4
|
||||
MOVE_NAMES = 5
|
||||
MOVE_DESCRIPTIONS = 6
|
||||
ITEM_NAMES = 7
|
||||
ITEM_NAME_PLURALS = 8
|
||||
ITEM_DESCRIPTIONS = 9
|
||||
ABILITY_NAMES = 10
|
||||
ABILITY_DESCRIPTIONS = 11
|
||||
TYPE_NAMES = 12
|
||||
TRAINER_TYPE_NAMES = 13
|
||||
TRAINER_NAMES = 14
|
||||
FRONTIER_INTRO_SPEECHES = 15
|
||||
FRONTIER_END_SPEECHES_WIN = 16
|
||||
FRONTIER_END_SPEECHES_LOSE = 17
|
||||
REGION_NAMES = 18
|
||||
REGION_LOCATION_NAMES = 19
|
||||
REGION_LOCATION_DESCRIPTIONS = 20
|
||||
MAP_NAMES = 21
|
||||
PHONE_MESSAGES = 22
|
||||
TRAINER_SPEECHES_LOSE = 23
|
||||
SCRIPT_TEXTS = 24
|
||||
RIBBON_NAMES = 25
|
||||
RIBBON_DESCRIPTIONS = 26
|
||||
STORAGE_CREATOR_NAME = 27
|
||||
ITEM_PORTION_NAMES = 28
|
||||
ITEM_PORTION_NAME_PLURALS = 29
|
||||
@@messages = Translation.new
|
||||
|
||||
def self.load_default_messages
|
||||
@@ -762,7 +768,7 @@ end
|
||||
# parameters by replacing {1}, {2}, etc. with those placeholders.
|
||||
def _INTL(*arg)
|
||||
begin
|
||||
string = MessageTypes.getFromHash(MessageTypes::ScriptTexts, arg[0])
|
||||
string = MessageTypes.getFromHash(MessageTypes::SCRIPT_TEXTS, arg[0])
|
||||
rescue
|
||||
string = arg[0]
|
||||
end
|
||||
@@ -778,15 +784,13 @@ 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::SCRIPT_TEXTS, arg[0])
|
||||
rescue
|
||||
string = arg[0]
|
||||
end
|
||||
string = string.clone
|
||||
(1...arg.length).each do |i|
|
||||
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m|
|
||||
next sprintf("%" + $1, arg[i])
|
||||
}
|
||||
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| next sprintf("%" + $1, arg[i]) }
|
||||
end
|
||||
return string
|
||||
end
|
||||
@@ -808,9 +812,7 @@ def _MAPISPRINTF(mapid, *arg)
|
||||
string = MessageTypes.getFromMapHash(mapid, arg[0])
|
||||
string = string.clone
|
||||
(1...arg.length).each do |i|
|
||||
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m|
|
||||
next sprintf("%" + $1, arg[i])
|
||||
}
|
||||
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| next sprintf("%" + $1, arg[i]) }
|
||||
end
|
||||
return string
|
||||
end
|
||||
|
||||
@@ -16,9 +16,7 @@ module Input
|
||||
|
||||
def self.update
|
||||
update_KGC_ScreenCapture
|
||||
if trigger?(Input::F8)
|
||||
pbScreenCapture
|
||||
end
|
||||
pbScreenCapture if trigger?(Input::F8)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -106,9 +106,8 @@
|
||||
module PluginManager
|
||||
# Holds all registered plugin data.
|
||||
@@Plugins = {}
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Registers a plugin and tests its dependencies and incompatibilities.
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.register(options)
|
||||
name = nil
|
||||
version = nil
|
||||
@@ -137,9 +136,7 @@ module PluginManager
|
||||
end
|
||||
name = value
|
||||
when :version # Plugin version
|
||||
if nil_or_empty?(value)
|
||||
self.error("Plugin version must be a string.")
|
||||
end
|
||||
self.error("Plugin version must be a string.") if nil_or_empty?(value)
|
||||
version = value
|
||||
when :essentials
|
||||
essentials = value
|
||||
@@ -289,9 +286,8 @@ module PluginManager
|
||||
:credits => credits
|
||||
}
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Throws a pure error message without stack trace or any other useless info.
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.error(msg)
|
||||
Graphics.update
|
||||
t = Thread.new do
|
||||
@@ -304,11 +300,10 @@ module PluginManager
|
||||
end
|
||||
Kernel.exit! true
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Returns true if the specified plugin is installed.
|
||||
# If the version is specified, this version is taken into account.
|
||||
# If mustequal is true, the version must be a match with the specified version.
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.installed?(plugin_name, plugin_version = nil, mustequal = false)
|
||||
plugin = @@Plugins[plugin_name]
|
||||
return false if plugin.nil?
|
||||
@@ -317,41 +312,36 @@ module PluginManager
|
||||
return true if !mustequal && comparison >= 0
|
||||
return true if mustequal && comparison == 0
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Returns the string names of all installed plugins.
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.plugins
|
||||
return @@Plugins.keys
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Returns the installed version of the specified plugin.
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.version(plugin_name)
|
||||
return if !installed?(plugin_name)
|
||||
return @@Plugins[plugin_name][:version]
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Returns the link of the specified plugin.
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.link(plugin_name)
|
||||
return if !installed?(plugin_name)
|
||||
return @@Plugins[plugin_name][:link]
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Returns the credits of the specified plugin.
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.credits(plugin_name)
|
||||
return if !installed?(plugin_name)
|
||||
return @@Plugins[plugin_name][:credits]
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Compares two versions given in string form. v1 should be the plugin version
|
||||
# you actually have, and v2 should be the minimum/desired plugin version.
|
||||
# Return values:
|
||||
# 1 if v1 is higher than v2
|
||||
# 0 if v1 is equal to v2
|
||||
# -1 if v1 is lower than v2
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.compare_versions(v1, v2)
|
||||
d1 = v1.chars
|
||||
d1.insert(0, "0") if d1[0] == "." # Turn ".123" into "0.123"
|
||||
@@ -376,9 +366,8 @@ module PluginManager
|
||||
end
|
||||
return 0
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
# formats the error message
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Formats the error message
|
||||
def self.pluginErrorMsg(name, script)
|
||||
e = $!
|
||||
# begin message formatting
|
||||
@@ -415,14 +404,13 @@ module PluginManager
|
||||
end
|
||||
end
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Used to read the metadata file
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.readMeta(dir, file)
|
||||
filename = "#{dir}/#{file}"
|
||||
meta = {}
|
||||
# read file
|
||||
Compiler.pbCompilerEachPreppedLine(filename) { |line, line_no|
|
||||
Compiler.pbCompilerEachPreppedLine(filename) do |line, line_no|
|
||||
# split line up into property name and values
|
||||
if !line[/^\s*(\w+)\s*=\s*(.*)$/]
|
||||
raise _INTL("Bad line syntax (expected syntax like XXX=YYY)\r\n{1}", FileLineData.linereport)
|
||||
@@ -466,7 +454,7 @@ module PluginManager
|
||||
else
|
||||
meta[property.downcase.to_sym] = data[0]
|
||||
end
|
||||
}
|
||||
end
|
||||
# generate a list of all script files to be loaded, in the order they are to
|
||||
# be loaded (files listed in the meta file are loaded first)
|
||||
meta[:scripts] = [] if !meta[:scripts]
|
||||
@@ -480,9 +468,8 @@ module PluginManager
|
||||
# return meta hash
|
||||
return meta
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Get a list of all the plugin directories to inspect
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.listAll
|
||||
return [] if !$DEBUG || safeExists?("Game.rgssad") || !Dir.safe?("Plugins")
|
||||
# get a list of all directories in the `Plugins/` folder
|
||||
@@ -491,9 +478,8 @@ module PluginManager
|
||||
# return all plugins
|
||||
return dirs
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Catch any potential loop with dependencies and raise an error
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.validateDependencies(name, meta, og = nil)
|
||||
# exit if no registered dependency
|
||||
return nil if !meta[name] || !meta[name][:dependencies]
|
||||
@@ -511,9 +497,8 @@ module PluginManager
|
||||
end
|
||||
return name
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Sort load order based on dependencies (this ends up in reverse order)
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.sortLoadOrder(order, plugins)
|
||||
# go through the load order
|
||||
order.each do |o|
|
||||
@@ -540,9 +525,8 @@ module PluginManager
|
||||
end
|
||||
return order
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Get the order in which to load plugins
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.getPluginOrder
|
||||
plugins = {}
|
||||
order = []
|
||||
@@ -568,9 +552,8 @@ module PluginManager
|
||||
# sort the load order
|
||||
return self.sortLoadOrder(order, plugins).reverse, plugins
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Check if plugins need compiling
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.needCompiling?(order, plugins)
|
||||
# fixed actions
|
||||
return false if !$DEBUG || safeExists?("Game.rgssad")
|
||||
@@ -590,9 +573,8 @@ module PluginManager
|
||||
end
|
||||
return false
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Check if plugins need compiling
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.compilePlugins(order, plugins)
|
||||
Console.echo_li("Compiling plugin scripts...")
|
||||
scripts = []
|
||||
@@ -618,9 +600,8 @@ module PluginManager
|
||||
GC.start
|
||||
Console.echo_done(true)
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Check if plugins need compiling
|
||||
#-----------------------------------------------------------------------------
|
||||
def self.runPlugins
|
||||
Console.echo_h1("Checking plugins")
|
||||
# get the order of plugins to interpret
|
||||
@@ -668,9 +649,8 @@ module PluginManager
|
||||
Console.echoln_li_done("No plugins found")
|
||||
end
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
# Get plugin dir from name based on meta entries
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Get plugin dir from name based on meta entries
|
||||
def self.findDirectory(name)
|
||||
# go through the plugins folder
|
||||
Dir.get("Plugins").each do |dir|
|
||||
@@ -683,5 +663,4 @@ module PluginManager
|
||||
# return nil if no plugin dir found
|
||||
return nil
|
||||
end
|
||||
#-----------------------------------------------------------------------------
|
||||
end
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SpriteAnimation
|
||||
@@_animations = []
|
||||
@@_reference_count = {}
|
||||
@@ -53,9 +56,7 @@ class SpriteAnimation
|
||||
sprite.visible = false
|
||||
@_animation_sprites.push(sprite)
|
||||
end
|
||||
unless @@_animations.include?(animation)
|
||||
@@_animations.push(animation)
|
||||
end
|
||||
@@_animations.push(animation) unless @@_animations.include?(animation)
|
||||
end
|
||||
update_animation
|
||||
end
|
||||
@@ -94,13 +95,9 @@ class SpriteAnimation
|
||||
sprite = @_animation_sprites[0]
|
||||
if sprite
|
||||
@@_reference_count[sprite.bitmap] -= 1
|
||||
if @@_reference_count[sprite.bitmap] == 0
|
||||
sprite.bitmap.dispose
|
||||
end
|
||||
end
|
||||
@_animation_sprites.each do |sprite|
|
||||
sprite.dispose
|
||||
sprite.bitmap.dispose if @@_reference_count[sprite.bitmap] == 0
|
||||
end
|
||||
@_animation_sprites.each { |s| s.dispose }
|
||||
@_animation_sprites = nil
|
||||
@_animation = nil
|
||||
end
|
||||
@@ -110,13 +107,9 @@ class SpriteAnimation
|
||||
sprite = @_loop_animation_sprites[0]
|
||||
if sprite
|
||||
@@_reference_count[sprite.bitmap] -= 1
|
||||
if @@_reference_count[sprite.bitmap] == 0
|
||||
sprite.bitmap.dispose
|
||||
end
|
||||
end
|
||||
@_loop_animation_sprites.each do |sprite|
|
||||
sprite.dispose
|
||||
sprite.bitmap.dispose if @@_reference_count[sprite.bitmap] == 0
|
||||
end
|
||||
@_loop_animation_sprites.each { |s| s.dispose }
|
||||
@_loop_animation_sprites = nil
|
||||
@_loop_animation = nil
|
||||
end
|
||||
@@ -262,8 +255,9 @@ class SpriteAnimation
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
module RPG
|
||||
class Sprite < ::Sprite
|
||||
def initialize(viewport = nil)
|
||||
@@ -465,9 +459,7 @@ module RPG
|
||||
@_damage_sprite.y += 4
|
||||
end
|
||||
@_damage_sprite.opacity = 256 - ((12 - @_damage_duration) * 32)
|
||||
if @_damage_duration == 0
|
||||
dispose_damage
|
||||
end
|
||||
dispose_damage if @_damage_duration == 0
|
||||
end
|
||||
@animations.each do |a|
|
||||
a.update
|
||||
|
||||
Reference in New Issue
Block a user