mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 14:14:59 +00:00
Redesigned phone.txt (old format isn't supported), added support for contact-specific phone messages, added more phone message components
This commit is contained in:
@@ -757,7 +757,6 @@ module Compiler
|
||||
modify_pbs_file_contents_before_compiling
|
||||
compile_town_map
|
||||
compile_connections
|
||||
compile_phone
|
||||
compile_types
|
||||
compile_abilities
|
||||
compile_moves # Depends on Type
|
||||
@@ -775,6 +774,7 @@ module Compiler
|
||||
compile_trainer_lists # Depends on TrainerType
|
||||
compile_metadata # Depends on TrainerType
|
||||
compile_map_metadata
|
||||
compile_phone # Depends on TrainerType
|
||||
end
|
||||
|
||||
def compile_all(mustCompile)
|
||||
|
||||
@@ -102,37 +102,69 @@ module Compiler
|
||||
def compile_phone(path = "PBS/phone.txt")
|
||||
return if !safeExists?(path)
|
||||
compile_pbs_file_message_start(path)
|
||||
database = PhoneDatabase.new
|
||||
sections = []
|
||||
File.open(path, "rb") { |f|
|
||||
pbEachSection(f) { |section, name|
|
||||
case name
|
||||
when "<Generics>"
|
||||
database.generics = section
|
||||
sections.concat(section)
|
||||
when "<BattleRequests>"
|
||||
database.battleRequests = section
|
||||
sections.concat(section)
|
||||
when "<GreetingsMorning>"
|
||||
database.greetingsMorning = section
|
||||
sections.concat(section)
|
||||
when "<GreetingsEvening>"
|
||||
database.greetingsEvening = section
|
||||
sections.concat(section)
|
||||
when "<Greetings>"
|
||||
database.greetings = section
|
||||
sections.concat(section)
|
||||
when "<Bodies1>"
|
||||
database.bodies1 = section
|
||||
sections.concat(section)
|
||||
when "<Bodies2>"
|
||||
database.bodies2 = section
|
||||
sections.concat(section)
|
||||
GameData::PhoneMessage::DATA.clear
|
||||
schema = GameData::PhoneMessage::SCHEMA
|
||||
messages = []
|
||||
contact_hash = nil
|
||||
# Read each line of phone.txt at a time and compile it as a contact property
|
||||
idx = 0
|
||||
pbCompilerEachPreppedLine(path) { |line, line_no|
|
||||
echo "." if idx % 50 == 0
|
||||
idx += 1
|
||||
Graphics.update if idx % 250 == 0
|
||||
if line[/^\s*\[\s*(.+)\s*\]\s*$/]
|
||||
# New section [trainer_type, name] or [trainer_type, name, version]
|
||||
if contact_hash
|
||||
# Add contact's data to records
|
||||
if contact_hash[:trainer_type] == "default"
|
||||
contact_hash[:id] = contact_hash[:trainer_type]
|
||||
else
|
||||
contact_hash[:id] = [contact_hash[:trainer_type], contact_hash[:name], contact_hash[:version]]
|
||||
end
|
||||
GameData::PhoneMessage.register(contact_hash)
|
||||
end
|
||||
}
|
||||
# Construct contact hash
|
||||
header = $~[1]
|
||||
if header.strip.downcase == "default"
|
||||
contact_hash = {
|
||||
:trainer_type => "default"
|
||||
}
|
||||
else
|
||||
line_data = pbGetCsvRecord($~[1], line_no, [0, "esU", :TrainerType])
|
||||
contact_hash = {
|
||||
:trainer_type => line_data[0],
|
||||
:name => line_data[1],
|
||||
:version => line_data[2] || 0
|
||||
}
|
||||
end
|
||||
elsif line[/^\s*(\w+)\s*=\s*(.*)$/]
|
||||
# XXX=YYY lines
|
||||
if !contact_hash
|
||||
raise _INTL("Expected a section at the beginning of the file.\r\n{1}", FileLineData.linereport)
|
||||
end
|
||||
property_name = $~[1]
|
||||
line_schema = schema[property_name]
|
||||
next if !line_schema
|
||||
property_value = pbGetCsvRecord($~[2], line_no, line_schema)
|
||||
# Record XXX=YYY setting
|
||||
contact_hash[line_schema[0]] ||= []
|
||||
contact_hash[line_schema[0]].push(property_value)
|
||||
messages.push(property_value)
|
||||
end
|
||||
}
|
||||
MessageTypes.setMessagesAsHash(MessageTypes::PhoneMessages, sections)
|
||||
save_data(database, "Data/phone.dat")
|
||||
# Add last contact's data to records
|
||||
if contact_hash
|
||||
# Add contact's data to records
|
||||
if contact_hash[:trainer_type] == "default"
|
||||
contact_hash[:id] = contact_hash[:trainer_type]
|
||||
else
|
||||
contact_hash[:id] = [contact_hash[:trainer_type], contact_hash[:name], contact_hash[:version]]
|
||||
end
|
||||
GameData::PhoneMessage.register(contact_hash)
|
||||
end
|
||||
# Save all data
|
||||
GameData::PhoneMessage.save
|
||||
MessageTypes.setMessagesAsHash(MessageTypes::PhoneMessages, messages)
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
|
||||
|
||||
@@ -103,32 +103,26 @@ module Compiler
|
||||
# Save phone messages to PBS file
|
||||
#=============================================================================
|
||||
def write_phone(path = "PBS/phone.txt")
|
||||
data = load_data("Data/phone.dat") rescue nil
|
||||
return if !data
|
||||
write_pbs_file_message_start(path)
|
||||
keys = GameData::PhoneMessage::SCHEMA.keys
|
||||
File.open(path, "wb") { |f|
|
||||
add_PBS_header_to_file(f)
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[<Generics>]\r\n")
|
||||
f.write(data.generics.join("\r\n") + "\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[<BattleRequests>]\r\n")
|
||||
f.write(data.battleRequests.join("\r\n") + "\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[<GreetingsMorning>]\r\n")
|
||||
f.write(data.greetingsMorning.join("\r\n") + "\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[<GreetingsEvening>]\r\n")
|
||||
f.write(data.greetingsEvening.join("\r\n") + "\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[<Greetings>]\r\n")
|
||||
f.write(data.greetings.join("\r\n") + "\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[<Bodies1>]\r\n")
|
||||
f.write(data.bodies1.join("\r\n") + "\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[<Bodies2>]\r\n")
|
||||
f.write(data.bodies2.join("\r\n") + "\r\n")
|
||||
# Write message sets
|
||||
GameData::PhoneMessage.each do |contact|
|
||||
f.write("\#-------------------------------\r\n")
|
||||
if contact.id == "default"
|
||||
f.write("[Default]\r\n")
|
||||
elsif contact.version > 0
|
||||
f.write(sprintf("[%s,%s,%d]\r\n", contact.trainer_type, contact.real_name, contact.version))
|
||||
else
|
||||
f.write(sprintf("[%s,%s]\r\n", contact.trainer_type, contact.real_name))
|
||||
end
|
||||
keys.each do |key|
|
||||
msgs = contact.property_from_string(key)
|
||||
next if !msgs || msgs.length == 0
|
||||
msgs.each { |msg| f.write(key + " = " + msg + "\r\n") }
|
||||
end
|
||||
end
|
||||
}
|
||||
process_pbs_file_message_end
|
||||
end
|
||||
@@ -886,7 +880,6 @@ module Compiler
|
||||
Console.echo_h1 _INTL("Writing all PBS files")
|
||||
write_town_map
|
||||
write_connections
|
||||
write_phone
|
||||
write_types
|
||||
write_abilities
|
||||
write_moves
|
||||
@@ -904,6 +897,7 @@ module Compiler
|
||||
write_trainer_lists
|
||||
write_metadata
|
||||
write_map_metadata
|
||||
write_phone
|
||||
echoln ""
|
||||
Console.echo_h2("Successfully rewrote all PBS files", text: :green)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user