Rewrote Town Map screen

This commit is contained in:
Maruno17
2025-01-16 00:09:59 +00:00
parent fcb4a1cec3
commit d03f012162
21 changed files with 1446 additions and 118 deletions

View File

@@ -107,7 +107,57 @@ module Compiler
# Save Town Map data to PBS file.
#-----------------------------------------------------------------------------
def write_town_map
write_PBS_file_generic(GameData::TownMap)
paths = get_all_PBS_file_paths(GameData::TownMap)
schema = GameData::TownMap.schema
sub_schema = GameData::TownMap.sub_schema
idx = 0
paths.each do |path|
write_pbs_file_message_start(path[0])
File.open(path[0], "wb") do |f|
add_PBS_header_to_file(f)
# Write each element in turn
GameData::TownMap.each do |element|
next if element.pbs_file_suffix != path[1]
echo "." if idx % 100 == 0
Graphics.update if idx % 500 == 0
idx += 1
f.write("\#-------------------------------\r\n")
if schema["SectionName"]
f.write("[")
pbWriteCsvRecord(element.get_property_for_PBS("SectionName"), f, schema["SectionName"])
f.write("]\r\n")
else
f.write("[#{element.id}]\r\n")
end
# Write each town map property
schema.each_key do |key|
next if ["SectionName", "Point"].include?(key)
val = element.get_property_for_PBS(key)
next if val.nil?
f.write(sprintf("%s = ", key))
pbWriteCsvRecord(val, f, schema[key])
f.write("\r\n")
end
# Write each point in turn
element.points.each_with_index do |point, i|
# Write position/name
val = element.get_point_property_for_PBS("Point", i)
f.write("Point = ")
pbWriteCsvRecord(val, f, schema["Point"])
f.write("\r\n")
# Write other point properties
sub_schema.each_key do |key|
val = element.get_point_property_for_PBS(key, i)
next if val.nil?
f.write(sprintf(" %s = ", key))
pbWriteCsvRecord(val, f, sub_schema[key])
f.write("\r\n")
end
end
end
end
process_pbs_file_message_end
end
end
#-----------------------------------------------------------------------------