rvpacker-txt 1.8.2 → 1.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/rvpacker-txt +11 -9
- data/lib/read.rb +25 -37
- data/lib/write.rb +8 -13
- data/rvpacker-txt.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b61d150da547df7d50d3920d89812ccbd4f238fd49b17524693ac78870018818
|
|
4
|
+
data.tar.gz: 8bdcf3ec6fef656d1b8e883a485f29d9ff56466c53bfbb1d5208adee13fb218d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6fe8e5c012762b40c85b843f428b966d24fadd5129fce757ce8f164f0779c27affda5959e85914f0d3e98dd920a85c4b50a4384004685558e6d2bd032b3916eb
|
|
7
|
+
data.tar.gz: b36cd1b4af5a0ec1e0fccfd520472ecc4596ac6a93bc88d30c51170f690d4269bd8bb0d9d0414b26b16e3301fec7b78943202b826bd2d91f6cff4faafc24d815
|
data/bin/rvpacker-txt
CHANGED
|
@@ -24,12 +24,12 @@ def self.parse_options
|
|
|
24
24
|
cmd.on('--disable-processing FILES', Array, "Don't process specified files (maps, other, system, scripts)") do |files|
|
|
25
25
|
files.each do |file|
|
|
26
26
|
files = %w[maps other system scripts]
|
|
27
|
-
index = files.
|
|
27
|
+
index = files.find_index(file)
|
|
28
28
|
options[:disable_processing][files[index]] = true if index
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
cmd.on('-s', '--shuffle NUM', Integer, 'Shuffle level (1: lines, 2: lines and words)') do |num|
|
|
32
|
+
cmd.on('-s', '--shuffle NUM', Integer, 'Shuffle level when writing (1: lines, 2: lines and words)') do |num|
|
|
33
33
|
options[:shuffle_level] = num
|
|
34
34
|
end
|
|
35
35
|
|
|
@@ -45,9 +45,10 @@ def self.parse_options
|
|
|
45
45
|
options[:force] = true
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
cmd.on('-a', '--append',
|
|
49
|
-
'
|
|
50
|
-
|
|
48
|
+
cmd.on('-a', '--append', "When the rvpacker-txt or the game which files you've parsed receives an update,",
|
|
49
|
+
'you probably should re-read game files with --append, which will append any new text to your files without overwriting the progress',
|
|
50
|
+
'Cannot be used with --force') do
|
|
51
|
+
raise '--append cannot be used with --force.' if options[:force]
|
|
51
52
|
options[:append] = true
|
|
52
53
|
end
|
|
53
54
|
|
|
@@ -95,9 +96,8 @@ other_path = File.join(input_dir, 'translation', 'other')
|
|
|
95
96
|
FileUtils.mkdir_p(maps_path)
|
|
96
97
|
FileUtils.mkdir_p(other_path)
|
|
97
98
|
|
|
98
|
-
engine = extensions.each
|
|
99
|
-
|
|
100
|
-
end || (raise "Couldn't determine project engine.")
|
|
99
|
+
engine = extensions.each { |sym, ext| break sym if File.exist?(File.join(original_directory, "System.#{ext}")) } ||
|
|
100
|
+
(raise "Couldn't determine project engine.")
|
|
101
101
|
|
|
102
102
|
files = Dir.glob("#{original_directory}/*#{extensions[engine]}")
|
|
103
103
|
|
|
@@ -129,7 +129,9 @@ wait_time = 0
|
|
|
129
129
|
processing_type = if force
|
|
130
130
|
wait_time_start = Time.now
|
|
131
131
|
|
|
132
|
-
puts "WARNING! You're about to forcefully rewrite all your translation files, including _trans files
|
|
132
|
+
puts "WARNING! You're about to forcefully rewrite all your translation files, including _trans files.",
|
|
133
|
+
"If you really want to do it, make sure you've made a backup of your _trans files, if you made some changes in them already.",
|
|
134
|
+
"Input 'Y' to continue."
|
|
133
135
|
exit unless gets.chomp == 'Y'
|
|
134
136
|
|
|
135
137
|
wait_time = Time.now - wait_time_start
|
data/lib/read.rb
CHANGED
|
@@ -75,8 +75,9 @@ def self.parse_parameter(code, parameter, game_type)
|
|
|
75
75
|
when 401, 405
|
|
76
76
|
case game_type
|
|
77
77
|
when 'lisa'
|
|
78
|
-
match = parameter.scan(
|
|
79
|
-
|
|
78
|
+
match = parameter.scan(/^\\et\[[0-9]+\]/)
|
|
79
|
+
match = parameter.scan(/^\\nbt/) if match.empty?
|
|
80
|
+
parameter = parameter[match[0].length..] unless match.empty?
|
|
80
81
|
else
|
|
81
82
|
nil
|
|
82
83
|
end
|
|
@@ -93,23 +94,15 @@ def self.parse_parameter(code, parameter, game_type)
|
|
|
93
94
|
end
|
|
94
95
|
|
|
95
96
|
# @param [String] variable
|
|
96
|
-
# @param [String]
|
|
97
|
+
# @param [String] _game_type
|
|
97
98
|
# @return [String]
|
|
98
|
-
def self.parse_variable(variable,
|
|
99
|
-
|
|
100
|
-
lines_count = variable.count("\n")
|
|
99
|
+
def self.parse_variable(variable, _game_type)
|
|
100
|
+
variable = variable.gsub(/\r?\n/, '\#') if variable.count("\n").positive?
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
when 'lisa'
|
|
107
|
-
return nil unless variable.split('\#').all? { |line| line.match?(/^<.*>\.?$/) || line.empty? }
|
|
108
|
-
else
|
|
109
|
-
nil
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
end
|
|
102
|
+
return nil if variable.split('\#').all? { |line| line.strip.match?(/(^#? ?<.*>\.?$)|^$/) }
|
|
103
|
+
return nil if variable.match?(/^[+-]?[0-9]*$/) ||
|
|
104
|
+
variable.match?(/---/) ||
|
|
105
|
+
variable.match?(/restrict eval/)
|
|
113
106
|
|
|
114
107
|
variable
|
|
115
108
|
end
|
|
@@ -130,9 +123,7 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
130
123
|
return
|
|
131
124
|
end
|
|
132
125
|
|
|
133
|
-
maps_object_map = Hash[maps_files_paths.map
|
|
134
|
-
[File.basename(filename), Marshal.load(File.binread(filename))]
|
|
135
|
-
end]
|
|
126
|
+
maps_object_map = Hash[maps_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
136
127
|
|
|
137
128
|
maps_lines = IndexSet.new
|
|
138
129
|
names_lines = IndexSet.new
|
|
@@ -274,9 +265,7 @@ end
|
|
|
274
265
|
# @param [String] game_type
|
|
275
266
|
# @param [String] processing_type
|
|
276
267
|
def self.read_other(other_files_paths, output_path, logging, game_type, processing_type)
|
|
277
|
-
other_object_array_map = Hash[other_files_paths.map
|
|
278
|
-
[File.basename(filename), Marshal.load(File.binread(filename))]
|
|
279
|
-
end]
|
|
268
|
+
other_object_array_map = Hash[other_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
280
269
|
|
|
281
270
|
inner_processing_type = processing_type
|
|
282
271
|
# 401 - dialogue lines
|
|
@@ -356,11 +345,12 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
356
345
|
unless allowed_codes.include?(code)
|
|
357
346
|
if in_sequence
|
|
358
347
|
joined = line.join('\#').strip
|
|
348
|
+
parsed = parse_parameter(401, joined, game_type)
|
|
359
349
|
|
|
360
|
-
other_translation_map.insert_at_index(other_lines.length,
|
|
361
|
-
!other_translation_map.include?(
|
|
350
|
+
other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
|
|
351
|
+
!other_translation_map.include?(parsed)
|
|
362
352
|
|
|
363
|
-
other_lines.add(
|
|
353
|
+
other_lines.add(parsed)
|
|
364
354
|
|
|
365
355
|
line.clear
|
|
366
356
|
in_sequence = false
|
|
@@ -517,20 +507,18 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
517
507
|
|
|
518
508
|
system_lines.add(value)
|
|
519
509
|
end
|
|
510
|
+
elsif value.is_a?(Array)
|
|
511
|
+
value.each do |string|
|
|
512
|
+
next unless string.is_a?(String)
|
|
520
513
|
|
|
521
|
-
|
|
522
|
-
|
|
514
|
+
string = string.strip
|
|
515
|
+
next if string.empty?
|
|
523
516
|
|
|
524
|
-
|
|
525
|
-
|
|
517
|
+
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
|
|
518
|
+
!system_translation_map.include?(string)
|
|
526
519
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
|
|
531
|
-
!system_translation_map.include?(string)
|
|
532
|
-
|
|
533
|
-
system_lines.add(string)
|
|
520
|
+
system_lines.add(string)
|
|
521
|
+
end
|
|
534
522
|
end
|
|
535
523
|
end
|
|
536
524
|
|
data/lib/write.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require 'zlib'
|
|
4
4
|
|
|
5
5
|
# @param [String] string A parsed scripts code string, containing raw Ruby code
|
|
6
|
-
# @return [
|
|
6
|
+
# @return [Array<Array<String, Integer>>] Hash of parsed from code strings and their start indices
|
|
7
7
|
def self.extract_quoted_strings(string)
|
|
8
8
|
strings_array = []
|
|
9
9
|
indices_array = []
|
|
@@ -80,7 +80,8 @@ def self.get_parameter_translated(code, parameter, hashmap, game_type)
|
|
|
80
80
|
when 401, 405
|
|
81
81
|
case game_type
|
|
82
82
|
when 'lisa'
|
|
83
|
-
match = parameter.scan(
|
|
83
|
+
match = parameter.scan(/^\\et\[[0-9]+\]/)
|
|
84
|
+
match = parameter.scan(/^\\nbt/) if match.empty?
|
|
84
85
|
|
|
85
86
|
unless match.empty?
|
|
86
87
|
lisa_start = match[0]
|
|
@@ -98,6 +99,7 @@ def self.get_parameter_translated(code, parameter, hashmap, game_type)
|
|
|
98
99
|
end
|
|
99
100
|
|
|
100
101
|
gotten = hashmap[parameter]
|
|
102
|
+
return nil if gotten.nil?
|
|
101
103
|
|
|
102
104
|
case game_type
|
|
103
105
|
when 'lisa'
|
|
@@ -127,9 +129,7 @@ end
|
|
|
127
129
|
# @param [Boolean] logging
|
|
128
130
|
# @param [String] game_type
|
|
129
131
|
def self.write_map(original_files_paths, maps_path, output_path, shuffle_level, logging, game_type)
|
|
130
|
-
maps_object_map = Hash[original_files_paths.map
|
|
131
|
-
[File.basename(filename), Marshal.load(File.binread(filename))]
|
|
132
|
-
end]
|
|
132
|
+
maps_object_map = Hash[original_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
133
133
|
|
|
134
134
|
maps_original_text = File.readlines(File.join(maps_path, 'maps.txt'), encoding: 'UTF-8', chomp: true).map do |line|
|
|
135
135
|
line.gsub('\#', "\n").strip
|
|
@@ -268,9 +268,7 @@ end
|
|
|
268
268
|
# @param [Boolean] logging
|
|
269
269
|
# @param [String] game_type
|
|
270
270
|
def self.write_other(original_files_paths, other_path, output_path, shuffle_level, logging, game_type)
|
|
271
|
-
other_object_array_map = Hash[original_files_paths.map
|
|
272
|
-
[File.basename(filename), Marshal.load(File.binread(filename))]
|
|
273
|
-
end]
|
|
271
|
+
other_object_array_map = Hash[original_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
274
272
|
|
|
275
273
|
# 401 - dialogue lines
|
|
276
274
|
# 405 - credits lines
|
|
@@ -422,9 +420,7 @@ end
|
|
|
422
420
|
# @param [String] translated
|
|
423
421
|
def self.write_ini_title(ini_file_path, translated)
|
|
424
422
|
file_lines = File.readlines(ini_file_path, chomp: true)
|
|
425
|
-
title_line_index = file_lines.each_with_index
|
|
426
|
-
break i if line.downcase.start_with?('title')
|
|
427
|
-
end
|
|
423
|
+
title_line_index = file_lines.each_with_index { |line, i| break i if line.downcase.start_with?('title') }
|
|
428
424
|
|
|
429
425
|
file_lines[title_line_index] = translated
|
|
430
426
|
File.binwrite(ini_file_path, file_lines.join("\n"))
|
|
@@ -520,9 +516,8 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
|
|
|
520
516
|
write_ini_title(ini_file_path, game_title_translated)
|
|
521
517
|
end
|
|
522
518
|
|
|
523
|
-
puts "Written #{system_basename}" if logging
|
|
524
|
-
|
|
525
519
|
File.binwrite(File.join(output_path, system_basename), Marshal.dump(system_object))
|
|
520
|
+
puts "Written #{system_basename}" if logging
|
|
526
521
|
end
|
|
527
522
|
|
|
528
523
|
# @param [String] scripts_file_path Path to Scripts.*data file
|
data/rvpacker-txt.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = 'rvpacker-txt'
|
|
5
|
-
spec.version = '1.8.
|
|
5
|
+
spec.version = '1.8.4'
|
|
6
6
|
spec.authors = ['Howard Jeng', 'Andrew Kesterson', 'Solistra', 'Darkness9724', 'savannstm']
|
|
7
7
|
spec.email = ['savannstm@gmail.com']
|
|
8
8
|
spec.summary = 'Reads or writes RPG Maker XP/VX/VXAce game text to .txt files'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rvpacker-txt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.8.
|
|
4
|
+
version: 1.8.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Howard Jeng
|
|
@@ -12,7 +12,7 @@ authors:
|
|
|
12
12
|
autorequire:
|
|
13
13
|
bindir: bin
|
|
14
14
|
cert_chain: []
|
|
15
|
-
date: 2024-07-
|
|
15
|
+
date: 2024-07-21 00:00:00.000000000 Z
|
|
16
16
|
dependencies: []
|
|
17
17
|
description:
|
|
18
18
|
email:
|