Method: RGSS.serialize
- Defined in:
- lib/RGSS/serialize.rb
.serialize(version, direction, directory, options = {}) ⇒ Object
- version
-
one of :ace, :vx, :xp
- direction
-
one of :data_bin_to_text, :data_text_to_bin, :save_bin_to_text, :save_text_to_bin, :scripts_bin_to_text, :scripts_text_to_bin, :all_text_to_bin, :all_bin_to_text
- directory
-
directory that project file is in
- options
-
:force - ignores file dates when converting (default false) :round_trip - create yaml data that matches original marshalled data skips
data cleanup operations (default false):line_width - line width form YAML files, -1 for no line width limit
(default 130):table_width - maximum number of entries per row for table data, -1 for no
table row limit (default 20)
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
# File 'lib/RGSS/serialize.rb', line 293 def self.serialize(version, direction, directory, = {}) raise "#{directory} not found" unless File.exist?(directory) setup_classes(version, ) = .clone() [:sort] = true if [:vx, :xp].include?(version) [:flow_classes] = FLOW_CLASSES [:line_width] ||= 130 table_width = [:table_width] RGSS::reset_const(Table, :MAX_ROW_LENGTH, table_width ? table_width : 20) base = File.realpath(directory) dirs = { :base => base, :data => get_data_directory(base, [:files]), :yaml => get_yaml_directory(base), :script => get_script_directory(base) } dirs.values.each do |d| FileUtils.mkdir(d) unless File.exist?(d) end exts = { :ace => ACE_DATA_EXT, :vx => VX_DATA_EXT, :xp => XP_DATA_EXT } yaml_scripts = SCRIPTS_BASE + YAML_EXT yaml = { :directory => dirs[:yaml], :exclude => [yaml_scripts], :ext => YAML_EXT, :load_file => :load_yaml_file, :dump_file => :dump_yaml_file, :load_save => :load_yaml_file, :dump_save => :dump_yaml_file } scripts = SCRIPTS_BASE + exts[version] data = { :directory => dirs[:data], :exclude => [scripts], :ext => exts[version], :load_file => :load_data_file, :dump_file => :dump_data_file, :load_save => :load_save, :dump_save => :dump_save } convert_saves = [:database][:saves] convert_scripts = [:database][:scripts] case direction # below were not used in rv packer when :data_bin_to_text convert(data, yaml, ) scripts_to_text(dirs, scripts, yaml_scripts, ) if convert_scripts when :data_text_to_bin convert(yaml, data, ) scripts_to_binary(dirs, yaml_scripts, scripts, ) if convert_scripts when :save_bin_to_text convert_saves(base, data, yaml, ) if convert_saves when :save_text_to_bin convert_saves(base, yaml, data, ) if convert_saves when :scripts_bin_to_text scripts_to_text(dirs, scripts, yaml_scripts, ) if convert_scripts when :scripts_text_to_bin scripts_to_binary(dirs, yaml_scripts, scripts, ) if convert_scripts # below are only options used by fusionpacker when :all_bin_to_text convert(data, yaml, ) scripts_to_text(dirs, scripts, yaml_scripts, ) if convert_scripts convert_saves(base, data, yaml, ) if convert_saves when :all_text_to_bin convert(yaml, data, ) scripts_to_binary(dirs, yaml_scripts, scripts, ) if convert_scripts convert_saves(base, yaml, data, ) if convert_saves else raise "Unrecognized direction :#{direction}" end end |