rvpacker-txt 1.8.5 → 1.9.0
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/README.md +17 -16
- data/bin/rvpacker-txt +141 -77
- data/lib/classes.rb +1 -1
- data/lib/read.rb +110 -29
- data/lib/write.rb +90 -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: 23fd06cbc05cc7bb17005d3cdd79cae36a36256007eade05eef6570e157bcf68
|
|
4
|
+
data.tar.gz: b8e3e4f7088a6d9e1ef00818b4dc5a8684a51d49e76c40c8fe5076bc9d6a4cae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 580408d4e6e8ae3b0e2d615d522d9a6f78e223e82f8bc5a735e1bd3868f5d0e7a0d7372406c011a7e3f03c18def481b61d00747d6f18d5c354b54568bdf7ee45
|
|
7
|
+
data.tar.gz: 6bb93fb3096248a63cba3147a0e9d0bc1b418d98cdae67479eacbbb6d255739c412d28fe3fa301a331b83dc98ababae7c0e850190a8241a4244e663b00043ef2
|
data/README.md
CHANGED
|
@@ -21,26 +21,27 @@ You can get a help message on usage using `rvpacker-txt -h`.
|
|
|
21
21
|
|
|
22
22
|
```
|
|
23
23
|
$ rvpacker-txt -h
|
|
24
|
-
This tool allows to parse RPG Maker
|
|
24
|
+
This tool allows to parse RPG Maker games to .txt files and write them back to their initial form.
|
|
25
25
|
|
|
26
|
-
Usage: rvpacker-txt COMMAND [
|
|
26
|
+
Usage: rvpacker-txt COMMAND [OPTIONS]
|
|
27
27
|
|
|
28
28
|
COMMANDS:
|
|
29
|
-
read - Parses
|
|
30
|
-
write - Writes
|
|
29
|
+
read - Parses files from "original" or "data" folders of input directory to "translation" folder of output directory.
|
|
30
|
+
write - Writes translated files using original files from "original" or "data" folder of input directory and writes results to "output" folder of output directory.
|
|
31
31
|
OPTIONS:
|
|
32
|
-
-i, --input-dir
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
--disable-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
-
|
|
32
|
+
-i, --input-dir PATH When reading: Input directory, containing folders "original" or "data" with original game files.
|
|
33
|
+
When writing: Input directory, containing folders "original" or "data" and "translation" with original game files and .txt files with translation respectively.
|
|
34
|
+
-o, --output-dir PATH When reading: Output directory, where a "translation" folder will be created, containing parsed .txt files with the text from the game.
|
|
35
|
+
When writing: Output directory, where an "output" folder will be created, containing compiled RPG Maker files with your translation.
|
|
36
|
+
--disable-processing FILES Skips processing specified files.
|
|
37
|
+
Example: --disable-processing=maps,other,system.
|
|
38
|
+
[Allowed values: maps, other, system, scripts]
|
|
39
|
+
--disable-custom-processing Disables built-in custom parsing/writing for some games.
|
|
40
|
+
-r, --romanize When reading: If you parsing text from a Japanese game, that contains symbols like 「」,
|
|
41
|
+
which are just the Japanese quotation marks, it automatically replaces these symbols by their roman equivalents.
|
|
42
|
+
When writing: Use to correctly write files back if you have parsed them with --romanize flag.
|
|
43
|
+
-l, --log Enables logging.
|
|
44
|
+
-h, --help Prints the program's help message or for the entered subcommand.
|
|
44
45
|
```
|
|
45
46
|
|
|
46
47
|
For example, to read a RPG Maker VX Ace project in E:/Documents/RPGMakerGame to .txt files:
|
data/bin/rvpacker-txt
CHANGED
|
@@ -7,28 +7,79 @@ require 'fileutils'
|
|
|
7
7
|
require 'classes'
|
|
8
8
|
|
|
9
9
|
def self.parse_options
|
|
10
|
-
options = {
|
|
10
|
+
options = { action: nil,
|
|
11
|
+
input_path: './',
|
|
12
|
+
output_path: './',
|
|
13
|
+
disable_processing: {
|
|
14
|
+
maps: false,
|
|
15
|
+
other: false,
|
|
16
|
+
system: false,
|
|
17
|
+
scripts: false
|
|
18
|
+
},
|
|
19
|
+
disable_custom_processing: false,
|
|
20
|
+
romanize_string: false,
|
|
21
|
+
logging: false,
|
|
22
|
+
force: false,
|
|
23
|
+
append: false,
|
|
24
|
+
shuffle_level: 0 }
|
|
25
|
+
|
|
26
|
+
options[:action] = ARGV[0]
|
|
27
|
+
|
|
28
|
+
unless %w[read write].include?(options[:action])
|
|
29
|
+
if %w[-h --help].include?(options[:action])
|
|
30
|
+
options[:action] = 'none'
|
|
31
|
+
elsif options[:action].nil?
|
|
32
|
+
raise 'COMMAND argument is required. Use rvpacker-txt -h for help.'
|
|
33
|
+
else
|
|
34
|
+
raise 'Invalid command. Allowed commands: read, write.'
|
|
35
|
+
end
|
|
36
|
+
end
|
|
11
37
|
|
|
12
38
|
read_command_description = 'Parses files from "original" or "data" folders of input directory to "translation" folder of output directory.'
|
|
13
39
|
write_command_description = 'Writes translated files using original files from "original" or "data" folder of input directory and writes results to "output" folder of output directory.'
|
|
14
|
-
banner_text = "This tool allows to parse RPG Maker games to .txt files and write them back to their initial form.\n\nUsage: rvpacker-txt COMMAND [
|
|
40
|
+
banner_text = "This tool allows to parse RPG Maker games to .txt files and write them back to their initial form.\n\nUsage: rvpacker-txt COMMAND [OPTIONS]\n\nCOMMANDS:\n read - #{read_command_description}\n write - #{write_command_description}\nOPTIONS:"
|
|
41
|
+
|
|
42
|
+
banner,
|
|
43
|
+
input_dir_description,
|
|
44
|
+
output_dir_description,
|
|
45
|
+
romanize_description =
|
|
46
|
+
case options[:action]
|
|
47
|
+
when 'read'
|
|
48
|
+
["#{read_command_description}\n\nOPTIONS:\n",
|
|
49
|
+
['Input directory, containing folders "original" or "data" with original game files.'],
|
|
50
|
+
['Output directory, where a "translation" folder will be created, containing parsed .txt files with the text from the game.'],
|
|
51
|
+
['If you parsing text from a Japanese game, that contains symbols like 「」, which are just the Japanese quotation marks,',
|
|
52
|
+
'it automatically replaces these symbols by their roman equivalents.']]
|
|
53
|
+
when 'write'
|
|
54
|
+
["#{write_command_description}\n\nOPTIONS:\n",
|
|
55
|
+
['Input directory, containing folders "original" or "data" and "translation" with original game files and .txt files with translation respectively.'],
|
|
56
|
+
['Output directory, where an "output" folder will be created, containing compiled RPG Maker files with your translation.'],
|
|
57
|
+
['Use to correctly write files back if you have parsed them with --romanize flag.',]]
|
|
58
|
+
else
|
|
59
|
+
[banner_text,
|
|
60
|
+
['When reading: Input directory, containing folders "original" or "data" with original game files.',
|
|
61
|
+
'When writing: Input directory, containing folders "original" or "data" and "translation" with original game files and .txt files with translation respectively.'],
|
|
62
|
+
['When reading: Output directory, where a "translation" folder will be created, containing parsed .txt files with the text from the game.',
|
|
63
|
+
'When writing: Output directory, where an "output" folder will be created, containing compiled RPG Maker files with your translation.'],
|
|
64
|
+
['When reading: If you parsing text from a Japanese game, that contains symbols like 「」,',
|
|
65
|
+
'which are just the Japanese quotation marks, it automatically replaces these symbols by their roman equivalents.',
|
|
66
|
+
'When writing: Use to correctly write files back if you have parsed them with --romanize flag.']]
|
|
67
|
+
end
|
|
15
68
|
|
|
16
|
-
OptionParser.new(
|
|
69
|
+
OptionParser.new(banner) do |cmd|
|
|
17
70
|
cmd.on('-i', '--input-dir PATH', String,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
options[:
|
|
21
|
-
options[:output_dir] = options[:input_dir]
|
|
71
|
+
*input_dir_description) do |dir|
|
|
72
|
+
options[:input_path] = File.exist?(dir) ? File.realpath(dir) : (raise "#{dir} not found")
|
|
73
|
+
options[:output_path] = options[:input_path]
|
|
22
74
|
end
|
|
23
75
|
|
|
24
76
|
cmd.on('-o', '--output-dir PATH', String,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
options[:output_dir] = File.exist?(dir) ? File.realpath(dir) : (raise "#{dir} not found")
|
|
77
|
+
*output_dir_description) do |dir|
|
|
78
|
+
options[:output_path] = File.exist?(dir) ? File.realpath(dir) : (raise "#{dir} not found")
|
|
28
79
|
end
|
|
29
80
|
|
|
30
81
|
cmd.on('--disable-processing FILES', Array,
|
|
31
|
-
'Skips processing
|
|
82
|
+
'Skips processing specified files.',
|
|
32
83
|
'Example: --disable-processing=maps,other,system.',
|
|
33
84
|
'[Allowed values: maps, other, system, scripts]') do |files|
|
|
34
85
|
files.each do |file|
|
|
@@ -38,50 +89,51 @@ def self.parse_options
|
|
|
38
89
|
end
|
|
39
90
|
end
|
|
40
91
|
|
|
41
|
-
cmd.on('
|
|
42
|
-
'
|
|
43
|
-
'Example: --shuffle-level 1.',
|
|
44
|
-
'[Allowed values: 0, 1, 2]',
|
|
45
|
-
'[Default value: 0]',
|
|
46
|
-
'[Write flag]') do |num|
|
|
47
|
-
raise 'Allowed values: 0, 1, 2' if num > 2
|
|
48
|
-
options[:shuffle_level] = num
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
cmd.on('--disable-custom-processing', 'Disables built-in custom parsing/writing for some games.') do
|
|
92
|
+
cmd.on('--disable-custom-processing',
|
|
93
|
+
'Disables built-in custom parsing/writing for some games.') do
|
|
52
94
|
options[:disable_custom_processing] = true
|
|
53
95
|
end
|
|
54
96
|
|
|
55
|
-
cmd.on('-
|
|
56
|
-
|
|
97
|
+
cmd.on('-r', '--romanize',
|
|
98
|
+
*romanize_description) do
|
|
99
|
+
options[:romanize_string] = true
|
|
57
100
|
end
|
|
58
101
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
102
|
+
if options[:action] == 'read'
|
|
103
|
+
cmd.on('-f', '--force',
|
|
104
|
+
'Force rewrite all files. Cannot be used with --append.',
|
|
105
|
+
'USE WITH CAUTION!') do
|
|
106
|
+
options[:force] = true
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
cmd.on('-a', '--append',
|
|
110
|
+
"When the rvpacker-txt or the game which files you've parsed receives an update, you probably should re-read game files with --append,",
|
|
111
|
+
' which will append any new text to your files without overwriting the progress.',
|
|
112
|
+
'Cannot be used with --force.') do
|
|
113
|
+
raise '--append cannot be used with --force.' if options[:force]
|
|
114
|
+
options[:append] = true
|
|
115
|
+
end
|
|
116
|
+
elsif options[:action] == 'write'
|
|
117
|
+
cmd.on('-s', '--shuffle-level NUMBER', Integer,
|
|
118
|
+
'With value 1, shuffles all translation lines. With value 2, shuffles all words and lines in translation text.',
|
|
119
|
+
'Example: --shuffle-level 1.',
|
|
120
|
+
'[Allowed values: 0, 1, 2]',
|
|
121
|
+
'[Default value: 0]') do |num|
|
|
122
|
+
raise 'Allowed values: 0, 1, 2.' if num > 2
|
|
123
|
+
options[:shuffle_level] = num
|
|
124
|
+
end
|
|
64
125
|
end
|
|
65
126
|
|
|
66
|
-
cmd.on('-
|
|
67
|
-
|
|
68
|
-
'you probably should re-read game files with --append, which will append any new text to your files without overwriting the progress',
|
|
69
|
-
'Cannot be used with --force',
|
|
70
|
-
'[Read flag]') do
|
|
71
|
-
raise '--append cannot be used with --force.' if options[:force]
|
|
72
|
-
options[:append] = true
|
|
127
|
+
cmd.on('-l', '--log', 'Enables logging.') do
|
|
128
|
+
options[:logging] = true
|
|
73
129
|
end
|
|
74
130
|
|
|
75
|
-
cmd.on('-h', '--help', '
|
|
131
|
+
cmd.on('-h', '--help', "Prints the program's help message or for the entered subcommand.") do
|
|
76
132
|
puts cmd
|
|
77
133
|
exit
|
|
78
134
|
end
|
|
79
135
|
end.parse!
|
|
80
136
|
|
|
81
|
-
options[:action] = ARGV.shift
|
|
82
|
-
raise 'COMMAND argument is required. Use rvpacker-txt -h for help.' if options[:action].nil?
|
|
83
|
-
raise 'Invalid command. Allowed commands are: read, write.' unless %w[read write].include?(options[:action])
|
|
84
|
-
|
|
85
137
|
options
|
|
86
138
|
end
|
|
87
139
|
|
|
@@ -89,34 +141,44 @@ end
|
|
|
89
141
|
# @return [String, nil]
|
|
90
142
|
def self.get_game_type(system_file_path)
|
|
91
143
|
object = Marshal.load(File.binread(system_file_path))
|
|
92
|
-
game_title = object.
|
|
144
|
+
game_title = object.game_title.to_s.downcase
|
|
93
145
|
game_title.include?('lisa') ? 'lisa' : nil
|
|
94
146
|
end
|
|
95
147
|
|
|
96
148
|
start_time = Time.now
|
|
97
149
|
|
|
98
150
|
options = parse_options
|
|
99
|
-
|
|
100
|
-
|
|
151
|
+
# @type [String]
|
|
152
|
+
input_path = options[:input_path]
|
|
153
|
+
# @type [String]
|
|
154
|
+
output_path = options[:output_path]
|
|
155
|
+
# @type [Boolean]
|
|
101
156
|
disable_custom_processing = options[:disable_custom_processing]
|
|
157
|
+
# @type [Integer]
|
|
102
158
|
shuffle_level = options[:shuffle_level]
|
|
159
|
+
# @type [Boolean]
|
|
103
160
|
logging = options[:logging]
|
|
161
|
+
# @type [Hash{Symbol => Boolean}]
|
|
104
162
|
disable_processing = options[:disable_processing]
|
|
163
|
+
# @type [Boolean]
|
|
105
164
|
force = options[:force]
|
|
165
|
+
# @type [Boolean]
|
|
106
166
|
append = options[:append]
|
|
167
|
+
# @type [Boolean]
|
|
168
|
+
romanize = options[:romanize_string]
|
|
107
169
|
|
|
108
170
|
extensions = { xp: 'rxdata', vx: 'rvdata', ace: 'rvdata2' }
|
|
109
171
|
|
|
110
|
-
original_directory = Dir.glob(File.join(
|
|
172
|
+
original_directory = Dir.glob(File.join(input_path, '{data,original}'), File::FNM_CASEFOLD).first
|
|
111
173
|
raise '"Data" or "original" directory not found within input directory.' unless original_directory
|
|
112
174
|
|
|
113
|
-
maps_path = File.join(
|
|
114
|
-
other_path = File.join(
|
|
175
|
+
maps_path = File.join(input_path, 'translation', 'maps')
|
|
176
|
+
other_path = File.join(input_path, 'translation', 'other')
|
|
115
177
|
|
|
116
178
|
FileUtils.mkdir_p(maps_path)
|
|
117
179
|
FileUtils.mkdir_p(other_path)
|
|
118
180
|
|
|
119
|
-
engine = extensions.
|
|
181
|
+
engine = extensions.each_pair { |sym, ext| break sym if File.exist?(File.join(original_directory, "System.#{ext}")) } ||
|
|
120
182
|
(raise "Couldn't determine project engine.")
|
|
121
183
|
|
|
122
184
|
files = Dir.glob("#{original_directory}/*#{extensions[engine]}")
|
|
@@ -141,45 +203,47 @@ files.each do |file|
|
|
|
141
203
|
end
|
|
142
204
|
end
|
|
143
205
|
|
|
144
|
-
ini_file_path = File.join(
|
|
206
|
+
ini_file_path = File.join(input_path, 'Game.ini')
|
|
145
207
|
|
|
146
208
|
game_type = disable_custom_processing ? nil : get_game_type(system_file_path)
|
|
147
209
|
|
|
148
|
-
wait_time = 0
|
|
149
|
-
processing_type = if force
|
|
150
|
-
wait_time_start = Time.now
|
|
151
|
-
|
|
152
|
-
puts "WARNING! You're about to forcefully rewrite all your translation files, including _trans files.",
|
|
153
|
-
"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.",
|
|
154
|
-
"Input 'Y' to continue."
|
|
155
|
-
exit unless gets.chomp == 'Y'
|
|
156
|
-
|
|
157
|
-
wait_time = Time.now - wait_time_start
|
|
158
|
-
:force
|
|
159
|
-
else
|
|
160
|
-
append ? :append : :default
|
|
161
|
-
end
|
|
162
|
-
|
|
163
210
|
puts 'Custom processing for this game is enabled. Use --disable-custom-processing to disable it.' unless game_type.nil?
|
|
164
211
|
|
|
212
|
+
$wait_time = 0
|
|
213
|
+
|
|
165
214
|
if options[:action] == 'read'
|
|
166
215
|
require 'read'
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
216
|
+
|
|
217
|
+
processing_type = if force
|
|
218
|
+
wait_time_start = Time.now
|
|
219
|
+
|
|
220
|
+
puts "WARNING! You're about to forcefully rewrite all your translation files, including _trans files.",
|
|
221
|
+
"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.",
|
|
222
|
+
"Input 'Y' to continue."
|
|
223
|
+
exit unless $stdin.gets.chomp == 'Y'
|
|
224
|
+
|
|
225
|
+
$wait_time += Time.now - wait_time_start
|
|
226
|
+
:force
|
|
227
|
+
elsif append
|
|
228
|
+
:append
|
|
229
|
+
else
|
|
230
|
+
:default
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
read_map(maps_files_paths, maps_path, romanize, logging, game_type, processing_type) unless disable_processing[:maps]
|
|
234
|
+
read_other(other_files_paths, other_path, romanize, logging, game_type, processing_type) unless disable_processing[:other]
|
|
235
|
+
read_system(system_file_path, ini_file_path, other_path, romanize, logging, processing_type) unless disable_processing[:system]
|
|
236
|
+
read_scripts(scripts_file_path, other_path, romanize, logging, processing_type) unless disable_processing[:scripts]
|
|
171
237
|
else
|
|
172
238
|
require 'write'
|
|
173
|
-
|
|
239
|
+
|
|
240
|
+
output_path = File.join(output_path, 'output')
|
|
174
241
|
FileUtils.mkdir_p(output_path)
|
|
175
242
|
|
|
176
|
-
write_map(maps_files_paths, maps_path, output_path, shuffle_level, logging, game_type) unless disable_processing[:maps]
|
|
177
|
-
write_other(other_files_paths, other_path, output_path, shuffle_level, logging, game_type) unless disable_processing[:other]
|
|
178
|
-
write_system(system_file_path, ini_file_path, other_path, output_path, shuffle_level, logging) unless disable_processing[:system]
|
|
179
|
-
write_scripts(scripts_file_path, other_path, output_path, logging) unless disable_processing[:scripts]
|
|
243
|
+
write_map(maps_files_paths, maps_path, output_path, shuffle_level, romanize, logging, game_type) unless disable_processing[:maps]
|
|
244
|
+
write_other(other_files_paths, other_path, output_path, shuffle_level, romanize, logging, game_type) unless disable_processing[:other]
|
|
245
|
+
write_system(system_file_path, ini_file_path, other_path, output_path, shuffle_level, romanize, logging) unless disable_processing[:system]
|
|
246
|
+
write_scripts(scripts_file_path, other_path, output_path, romanize, logging) unless disable_processing[:scripts]
|
|
180
247
|
end
|
|
181
248
|
|
|
182
|
-
|
|
183
|
-
elapsed_time = Time.now - start_time - wait_time - $wait_time
|
|
184
|
-
|
|
185
|
-
puts "Done in #{elapsed_time}"
|
|
249
|
+
puts "Done in #{Time.now - start_time - $wait_time}"
|
data/lib/classes.rb
CHANGED
data/lib/read.rb
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
require 'zlib'
|
|
4
4
|
|
|
5
|
+
STRING_IS_ONLY_SYMBOLS_RE = /^[.()+-:;\[\]^~%&!*\/→×??x%▼| ]+$/
|
|
6
|
+
APPEND_FLAG_OMIT_MSG = "Files aren't already parsed. Continuing as if --append flag was omitted."
|
|
7
|
+
|
|
5
8
|
class Hash
|
|
6
9
|
def insert_at_index(index, key, value)
|
|
7
10
|
return self[key] = value if index >= size
|
|
@@ -12,6 +15,51 @@ class Hash
|
|
|
12
15
|
end
|
|
13
16
|
end
|
|
14
17
|
|
|
18
|
+
# @param [String] string
|
|
19
|
+
# @return [String]
|
|
20
|
+
def self.romanize_string(string)
|
|
21
|
+
string.each_char.each_with_index do |char, i|
|
|
22
|
+
case char
|
|
23
|
+
when '。'
|
|
24
|
+
string[i] = '.'
|
|
25
|
+
when '、'
|
|
26
|
+
string[i] = ','
|
|
27
|
+
when '・'
|
|
28
|
+
string[i] = '·'
|
|
29
|
+
when '゠'
|
|
30
|
+
string[i] = '–'
|
|
31
|
+
when '='
|
|
32
|
+
string[i] = '—'
|
|
33
|
+
when '…'
|
|
34
|
+
string[i, 3] = '...'
|
|
35
|
+
when '「', '」', '〈', '〉'
|
|
36
|
+
string[i] = "'"
|
|
37
|
+
when '『', '』', '《', '》'
|
|
38
|
+
string[i] = '"'
|
|
39
|
+
when '(', '〔', '⦅', '〘'
|
|
40
|
+
string[i] = '('
|
|
41
|
+
when ')', '〕', '⦆', '〙'
|
|
42
|
+
string[i] = ')'
|
|
43
|
+
when '{'
|
|
44
|
+
string[i] = '{'
|
|
45
|
+
when '}'
|
|
46
|
+
string[i] = '}'
|
|
47
|
+
when '[', '【', '〖', '〚'
|
|
48
|
+
string[i] = '['
|
|
49
|
+
when ']', '】', '〗', '〛'
|
|
50
|
+
string[i] = ']'
|
|
51
|
+
when '〜'
|
|
52
|
+
string[i] = '~'
|
|
53
|
+
when '?'
|
|
54
|
+
string[i] = '?'
|
|
55
|
+
else
|
|
56
|
+
nil
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
string
|
|
61
|
+
end
|
|
62
|
+
|
|
15
63
|
# @param [String] string A parsed scripts code string, containing raw Ruby code
|
|
16
64
|
# @return [IndexSet<String>] Set of extracted strings
|
|
17
65
|
def self.extract_quoted_strings(string)
|
|
@@ -49,16 +97,16 @@ def self.extract_quoted_strings(string)
|
|
|
49
97
|
next
|
|
50
98
|
end
|
|
51
99
|
|
|
52
|
-
|
|
53
|
-
if char == "\r"
|
|
54
|
-
next
|
|
55
|
-
elsif char == "\n"
|
|
56
|
-
buffer.push('\#')
|
|
57
|
-
next
|
|
58
|
-
end
|
|
100
|
+
next unless in_quotes
|
|
59
101
|
|
|
60
|
-
|
|
102
|
+
if char == "\r"
|
|
103
|
+
next
|
|
104
|
+
elsif char == "\n"
|
|
105
|
+
buffer.push('\#')
|
|
106
|
+
next
|
|
61
107
|
end
|
|
108
|
+
|
|
109
|
+
buffer.push(char)
|
|
62
110
|
end
|
|
63
111
|
end
|
|
64
112
|
|
|
@@ -70,7 +118,7 @@ end
|
|
|
70
118
|
# @param [String] game_type
|
|
71
119
|
# @return [String]
|
|
72
120
|
def self.parse_parameter(code, parameter, game_type)
|
|
73
|
-
return nil if parameter.match?(
|
|
121
|
+
return nil if parameter.match?(STRING_IS_ONLY_SYMBOLS_RE)
|
|
74
122
|
|
|
75
123
|
unless game_type.nil?
|
|
76
124
|
case code
|
|
@@ -99,7 +147,7 @@ end
|
|
|
99
147
|
# @param [String] _game_type
|
|
100
148
|
# @return [String]
|
|
101
149
|
def self.parse_variable(variable, _game_type)
|
|
102
|
-
return nil if
|
|
150
|
+
return nil if variable.match?(STRING_IS_ONLY_SYMBOLS_RE)
|
|
103
151
|
variable = variable.gsub(/\r?\n/, '\#') if variable.count("\n").positive?
|
|
104
152
|
|
|
105
153
|
return nil if variable.split('\#').all? { |line| line.strip.match?(/(^#? ?<.*>\.?$)|^$/) }
|
|
@@ -112,10 +160,11 @@ end
|
|
|
112
160
|
|
|
113
161
|
# @param [Array<String>] maps_files_paths
|
|
114
162
|
# @param [String] output_path
|
|
163
|
+
# @param [Boolean] romanize
|
|
115
164
|
# @param [Boolean] logging
|
|
116
165
|
# @param [String] game_type
|
|
117
166
|
# @param [String] processing_type
|
|
118
|
-
def self.read_map(maps_files_paths, output_path, logging, game_type, processing_type)
|
|
167
|
+
def self.read_map(maps_files_paths, output_path, romanize, logging, game_type, processing_type)
|
|
119
168
|
maps_output_path = File.join(output_path, 'maps.txt')
|
|
120
169
|
names_output_path = File.join(output_path, 'names.txt')
|
|
121
170
|
maps_trans_output_path = File.join(output_path, 'maps_trans.txt')
|
|
@@ -141,7 +190,7 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
141
190
|
names_translation_map = Hash[File.readlines(names_output_path, chomp: true)
|
|
142
191
|
.zip(File.readlines(names_trans_output_path, chomp: true))]
|
|
143
192
|
else
|
|
144
|
-
puts
|
|
193
|
+
puts APPEND_FLAG_OMIT_MSG
|
|
145
194
|
processing_type = :default
|
|
146
195
|
end
|
|
147
196
|
end
|
|
@@ -158,6 +207,8 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
158
207
|
display_name = display_name.strip
|
|
159
208
|
|
|
160
209
|
unless display_name.empty?
|
|
210
|
+
display_name = romanize_string(display_name) if romanize
|
|
211
|
+
|
|
161
212
|
names_translation_map.insert_at_index(names_lines.length, display_name, '') if processing_type == :append &&
|
|
162
213
|
!names_translation_map.include?(display_name)
|
|
163
214
|
|
|
@@ -187,13 +238,17 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
187
238
|
joined = line.join('\#').strip
|
|
188
239
|
parsed = parse_parameter(401, joined, game_type)
|
|
189
240
|
|
|
190
|
-
|
|
191
|
-
|
|
241
|
+
unless parsed.nil?
|
|
242
|
+
parsed = romanize_string(parsed) if romanize
|
|
192
243
|
|
|
193
|
-
|
|
244
|
+
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
|
|
245
|
+
!maps_translation_map.include?(parsed)
|
|
194
246
|
|
|
195
|
-
|
|
196
|
-
|
|
247
|
+
maps_lines.add(parsed)
|
|
248
|
+
|
|
249
|
+
line.clear
|
|
250
|
+
in_sequence = false
|
|
251
|
+
end
|
|
197
252
|
end
|
|
198
253
|
next
|
|
199
254
|
end
|
|
@@ -215,6 +270,8 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
215
270
|
parsed = parse_parameter(code, subparameter, game_type)
|
|
216
271
|
next if parsed.nil?
|
|
217
272
|
|
|
273
|
+
parsed = romanize_string(parsed) if romanize
|
|
274
|
+
|
|
218
275
|
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
|
|
219
276
|
!maps_translation_map.include?(parsed)
|
|
220
277
|
|
|
@@ -228,6 +285,7 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
228
285
|
next if parsed.nil?
|
|
229
286
|
|
|
230
287
|
parsed = parsed.gsub(/\r?\n/, '\#')
|
|
288
|
+
parsed = romanize_string(parsed) if romanize
|
|
231
289
|
|
|
232
290
|
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
|
|
233
291
|
!maps_translation_map.include?(parsed)
|
|
@@ -264,10 +322,11 @@ end
|
|
|
264
322
|
|
|
265
323
|
# @param [Array<String>] other_files_paths
|
|
266
324
|
# @param [String] output_path
|
|
325
|
+
# @param [Boolean] romanize
|
|
267
326
|
# @param [Boolean] logging
|
|
268
327
|
# @param [String] game_type
|
|
269
328
|
# @param [String] processing_type
|
|
270
|
-
def self.read_other(other_files_paths, output_path, logging, game_type, processing_type)
|
|
329
|
+
def self.read_other(other_files_paths, output_path, romanize, logging, game_type, processing_type)
|
|
271
330
|
other_object_array_map = Hash[other_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
272
331
|
|
|
273
332
|
inner_processing_type = processing_type
|
|
@@ -297,7 +356,7 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
297
356
|
other_translation_map = Hash[File.readlines(other_output_path, chomp: true)
|
|
298
357
|
.zip(File.readlines(other_trans_output_path, chomp: true))]
|
|
299
358
|
else
|
|
300
|
-
puts
|
|
359
|
+
puts APPEND_FLAG_OMIT_MSG
|
|
301
360
|
inner_processing_type = :default
|
|
302
361
|
end
|
|
303
362
|
end
|
|
@@ -321,6 +380,7 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
321
380
|
next if parsed.nil?
|
|
322
381
|
|
|
323
382
|
parsed = parsed.gsub(/\r?\n/, '\#')
|
|
383
|
+
parsed = romanize_string(parsed) if romanize
|
|
324
384
|
|
|
325
385
|
other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
|
|
326
386
|
!other_translation_map.include?(parsed)
|
|
@@ -350,13 +410,17 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
350
410
|
joined = line.join('\#').strip
|
|
351
411
|
parsed = parse_parameter(401, joined, game_type)
|
|
352
412
|
|
|
353
|
-
|
|
354
|
-
|
|
413
|
+
unless parsed.nil?
|
|
414
|
+
parsed = romanize_string(parsed) if romanize
|
|
355
415
|
|
|
356
|
-
|
|
416
|
+
other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
|
|
417
|
+
!other_translation_map.include?(parsed)
|
|
357
418
|
|
|
358
|
-
|
|
359
|
-
|
|
419
|
+
other_lines.add(parsed)
|
|
420
|
+
|
|
421
|
+
line.clear
|
|
422
|
+
in_sequence = false
|
|
423
|
+
end
|
|
360
424
|
end
|
|
361
425
|
next
|
|
362
426
|
end
|
|
@@ -375,6 +439,8 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
375
439
|
subparameter = subparameter.strip
|
|
376
440
|
next if subparameter.empty?
|
|
377
441
|
|
|
442
|
+
subparameter = romanize_string(subparameter) if romanize
|
|
443
|
+
|
|
378
444
|
other_translation_map.insert_at_index(other_lines.length, subparameter, '') if inner_processing_type == :append &&
|
|
379
445
|
!other_translation_map.include?(subparameter)
|
|
380
446
|
|
|
@@ -385,6 +451,7 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
385
451
|
next if parameter.empty?
|
|
386
452
|
|
|
387
453
|
parameter = parameter.gsub(/\r?\n/, '\#')
|
|
454
|
+
parameter = romanize_string(parameter) if romanize
|
|
388
455
|
|
|
389
456
|
other_translation_map.insert_at_index(other_lines.length, parameter, '') if inner_processing_type == :append &&
|
|
390
457
|
!other_translation_map.include?(parameter)
|
|
@@ -395,6 +462,7 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
395
462
|
next if parameter.empty?
|
|
396
463
|
|
|
397
464
|
parameter = parameter.gsub(/\r?\n/, '\#')
|
|
465
|
+
parameter = romanize_string(parameter) if romanize
|
|
398
466
|
|
|
399
467
|
other_translation_map.insert_at_index(other_lines.length, parameter, '') if inner_processing_type == :append &&
|
|
400
468
|
!other_translation_map.include?(parameter)
|
|
@@ -435,9 +503,10 @@ end
|
|
|
435
503
|
# @param [String] system_file_path
|
|
436
504
|
# @param [String] ini_file_path
|
|
437
505
|
# @param [String] output_path
|
|
506
|
+
# @param [Boolean] romanize
|
|
438
507
|
# @param [Boolean] logging
|
|
439
508
|
# @param [String] processing_type
|
|
440
|
-
def self.read_system(system_file_path, ini_file_path, output_path, logging, processing_type)
|
|
509
|
+
def self.read_system(system_file_path, ini_file_path, output_path, romanize, logging, processing_type)
|
|
441
510
|
system_filename = File.basename(system_file_path)
|
|
442
511
|
system_basename = File.basename(system_file_path, '.*').downcase
|
|
443
512
|
|
|
@@ -459,7 +528,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
459
528
|
system_translation_map = Hash[File.readlines(system_output_path, chomp: true)
|
|
460
529
|
.zip(File.readlines(system_trans_output_path, chomp: true))]
|
|
461
530
|
else
|
|
462
|
-
puts
|
|
531
|
+
puts APPEND_FLAG_OMIT_MSG
|
|
463
532
|
processing_type = :default
|
|
464
533
|
end
|
|
465
534
|
end
|
|
@@ -480,6 +549,8 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
480
549
|
string = string.strip
|
|
481
550
|
next if string.empty?
|
|
482
551
|
|
|
552
|
+
string = romanize_string(string) if romanize
|
|
553
|
+
|
|
483
554
|
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
|
|
484
555
|
!system_translation_map.include?(string)
|
|
485
556
|
|
|
@@ -491,6 +562,8 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
491
562
|
currency_unit = currency_unit.strip
|
|
492
563
|
|
|
493
564
|
unless currency_unit.empty?
|
|
565
|
+
currency_unit = romanize_string(currency_unit) if romanize
|
|
566
|
+
|
|
494
567
|
system_translation_map.insert_at_index(system_lines.length, currency_unit, '') if processing_type == :append &&
|
|
495
568
|
!system_translation_map.include?(currency_unit)
|
|
496
569
|
|
|
@@ -505,6 +578,8 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
505
578
|
value = value.strip
|
|
506
579
|
|
|
507
580
|
unless value.empty?
|
|
581
|
+
value = romanize_string(string) if romanize
|
|
582
|
+
|
|
508
583
|
system_translation_map.insert_at_index(system_lines.length, value, '') if processing_type == :append &&
|
|
509
584
|
!system_translation_map.include?(value)
|
|
510
585
|
|
|
@@ -517,6 +592,8 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
517
592
|
string = string.strip
|
|
518
593
|
next if string.empty?
|
|
519
594
|
|
|
595
|
+
string = romanize_string(string) if romanize
|
|
596
|
+
|
|
520
597
|
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
|
|
521
598
|
!system_translation_map.include?(string)
|
|
522
599
|
|
|
@@ -528,6 +605,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
528
605
|
# Game title from System file and ini file may differ, but requesting user request to determine which line do they want is LAME
|
|
529
606
|
# So just throw that ini ass and continue
|
|
530
607
|
ini_game_title = read_ini_title(ini_file_path).strip
|
|
608
|
+
ini_game_title = romanize_string(ini_game_title) if romanize
|
|
531
609
|
|
|
532
610
|
system_translation_map.insert_at_index(system_lines.length, ini_game_title, '') if processing_type == :append &&
|
|
533
611
|
!system_translation_map.include?(ini_game_title)
|
|
@@ -550,9 +628,10 @@ end
|
|
|
550
628
|
|
|
551
629
|
# @param [String] scripts_file_path
|
|
552
630
|
# @param [String] output_path
|
|
631
|
+
# @param [Boolean] romanize
|
|
553
632
|
# @param [Boolean] logging
|
|
554
633
|
# @param [String] processing_type
|
|
555
|
-
def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
634
|
+
def self.read_scripts(scripts_file_path, output_path, romanize, logging, processing_type)
|
|
556
635
|
scripts_filename = File.basename(scripts_file_path)
|
|
557
636
|
scripts_basename = File.basename(scripts_file_path, '.*').downcase
|
|
558
637
|
|
|
@@ -575,7 +654,7 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
575
654
|
scripts_translation_map = Hash[File.readlines(scripts_output_path, chomp: true)
|
|
576
655
|
.zip(File.readlines(scripts_trans_output_path, chomp: true))]
|
|
577
656
|
else
|
|
578
|
-
puts
|
|
657
|
+
puts APPEND_FLAG_OMIT_MSG
|
|
579
658
|
processing_type = :default
|
|
580
659
|
end
|
|
581
660
|
end
|
|
@@ -621,7 +700,7 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
621
700
|
string.match?(/^(?=.*\d)[A-Za-z0-9\-]+$/) ||
|
|
622
701
|
string.match?(/^[a-z\-()\/ +'&]*$/) ||
|
|
623
702
|
string.match?(/^[A-Za-z]+[+-]$/) ||
|
|
624
|
-
string.match?(
|
|
703
|
+
string.match?(STRING_IS_ONLY_SYMBOLS_RE) ||
|
|
625
704
|
string.match?(/^Tile.*[A-Z]$/) ||
|
|
626
705
|
string.match?(/^[a-zA-Z][a-z]+([A-Z][a-z]*)+$/) ||
|
|
627
706
|
string.match?(/^Cancel Action$|^Invert$|^End$|^Individual$|^Missed File$|^Bitmap$|^Audio$/) ||
|
|
@@ -648,6 +727,8 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
648
727
|
string.match?(/Clear image/) ||
|
|
649
728
|
string.match?(/Can Collapse/)
|
|
650
729
|
|
|
730
|
+
string = romanize_string(string) if romanize
|
|
731
|
+
|
|
651
732
|
scripts_translation_map.insert_at_index(scripts_lines.length, string, '') if processing_type == :append &&
|
|
652
733
|
!scripts_translation_map.include?(string)
|
|
653
734
|
|
data/lib/write.rb
CHANGED
|
@@ -2,6 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
require 'zlib'
|
|
4
4
|
|
|
5
|
+
# @param [String] string
|
|
6
|
+
# @return [String]
|
|
7
|
+
def self.romanize_string(string)
|
|
8
|
+
string.each_char.each_with_index do |char, i|
|
|
9
|
+
case char
|
|
10
|
+
when '。'
|
|
11
|
+
string[i] = '.'
|
|
12
|
+
when '、'
|
|
13
|
+
string[i] = ','
|
|
14
|
+
when '・'
|
|
15
|
+
string[i] = '·'
|
|
16
|
+
when '゠'
|
|
17
|
+
string[i] = '–'
|
|
18
|
+
when '='
|
|
19
|
+
string[i] = '—'
|
|
20
|
+
when '…'
|
|
21
|
+
string[i, 3] = '...'
|
|
22
|
+
when '「', '」', '〈', '〉'
|
|
23
|
+
string[i] = "'"
|
|
24
|
+
when '『', '』', '《', '》'
|
|
25
|
+
string[i] = '"'
|
|
26
|
+
when '(', '〔', '⦅', '〘'
|
|
27
|
+
string[i] = '('
|
|
28
|
+
when ')', '〕', '⦆', '〙'
|
|
29
|
+
string[i] = ')'
|
|
30
|
+
when '{'
|
|
31
|
+
string[i] = '{'
|
|
32
|
+
when '}'
|
|
33
|
+
string[i] = '}'
|
|
34
|
+
when '[', '【', '〖', '〚'
|
|
35
|
+
string[i] = '['
|
|
36
|
+
when ']', '】', '〗', '〛'
|
|
37
|
+
string[i] = ']'
|
|
38
|
+
when '〜'
|
|
39
|
+
string[i] = '~'
|
|
40
|
+
else
|
|
41
|
+
nil
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
string
|
|
46
|
+
end
|
|
47
|
+
|
|
5
48
|
# @param [String] string A parsed scripts code string, containing raw Ruby code
|
|
6
49
|
# @return [Array<Array<String, Integer>>] Hash of parsed from code strings and their start indices
|
|
7
50
|
def self.extract_quoted_strings(string)
|
|
@@ -126,9 +169,10 @@ end
|
|
|
126
169
|
# @param [String] maps_path
|
|
127
170
|
# @param [String] output_path
|
|
128
171
|
# @param [Integer] shuffle_level
|
|
172
|
+
# @param [Boolean] romanize
|
|
129
173
|
# @param [Boolean] logging
|
|
130
174
|
# @param [String] game_type
|
|
131
|
-
def self.write_map(original_files_paths, maps_path, output_path, shuffle_level, logging, game_type)
|
|
175
|
+
def self.write_map(original_files_paths, maps_path, output_path, shuffle_level, romanize, logging, game_type)
|
|
132
176
|
maps_object_map = Hash[original_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
133
177
|
|
|
134
178
|
maps_original_text = File.readlines(File.join(maps_path, 'maps.txt'), encoding: 'UTF-8', chomp: true).map do |line|
|
|
@@ -192,6 +236,8 @@ def self.write_map(original_files_paths, maps_path, output_path, shuffle_level,
|
|
|
192
236
|
unless allowed_codes.include?(code)
|
|
193
237
|
if in_sequence
|
|
194
238
|
joined = line.join('\#').strip
|
|
239
|
+
joined = romanize_string(joined) if romanize
|
|
240
|
+
|
|
195
241
|
translated = get_parameter_translated(401, joined, maps_translation_map, game_type)
|
|
196
242
|
|
|
197
243
|
unless translated.nil? || translated.empty?
|
|
@@ -225,6 +271,8 @@ def self.write_map(original_files_paths, maps_path, output_path, shuffle_level,
|
|
|
225
271
|
subparameter = subparameter.strip
|
|
226
272
|
next if subparameter.empty?
|
|
227
273
|
|
|
274
|
+
subparameter = romanize_string(subparameter) if romanize
|
|
275
|
+
|
|
228
276
|
translated = get_parameter_translated(code, subparameter, maps_translation_map, game_type)
|
|
229
277
|
parameters[0][sp] = translated unless translated.nil? || translated.empty?
|
|
230
278
|
end
|
|
@@ -232,12 +280,16 @@ def self.write_map(original_files_paths, maps_path, output_path, shuffle_level,
|
|
|
232
280
|
parameter = parameters[0].strip
|
|
233
281
|
next if parameter.empty?
|
|
234
282
|
|
|
283
|
+
parameter = romanize_string(parameter) if romanize
|
|
284
|
+
|
|
235
285
|
translated = get_parameter_translated(code, parameter, maps_translation_map, game_type)
|
|
236
286
|
parameters[0] = translated unless translated.nil? || translated.empty?
|
|
237
287
|
elsif parameters[1].is_a?(String)
|
|
238
288
|
parameter = parameters[1].strip
|
|
239
289
|
next if parameter.empty?
|
|
240
290
|
|
|
291
|
+
parameter = romanize_string(parameter) if romanize
|
|
292
|
+
|
|
241
293
|
translated = get_parameter_translated(code, parameter, maps_translation_map, game_type)
|
|
242
294
|
parameters[1] = translated unless translated.nil? || translated.empty?
|
|
243
295
|
end
|
|
@@ -265,9 +317,10 @@ end
|
|
|
265
317
|
# @param [String] other_path
|
|
266
318
|
# @param [String] output_path
|
|
267
319
|
# @param [Integer] shuffle_level
|
|
320
|
+
# @param [Boolean] romanize
|
|
268
321
|
# @param [Boolean] logging
|
|
269
322
|
# @param [String] game_type
|
|
270
|
-
def self.write_other(original_files_paths, other_path, output_path, shuffle_level, logging, game_type)
|
|
323
|
+
def self.write_other(original_files_paths, other_path, output_path, shuffle_level, romanize, logging, game_type)
|
|
271
324
|
other_object_array_map = Hash[original_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
272
325
|
|
|
273
326
|
# 401 - dialogue lines
|
|
@@ -309,6 +362,8 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
|
|
|
309
362
|
next if variable.empty?
|
|
310
363
|
|
|
311
364
|
variable = variable.gsub(/\r\n/, "\n")
|
|
365
|
+
variable = romanize_string(variable) if romanize
|
|
366
|
+
|
|
312
367
|
translated = get_variable_translated(variable, other_translation_map, game_type)
|
|
313
368
|
|
|
314
369
|
unless translated.nil? || translated.empty?
|
|
@@ -345,6 +400,8 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
|
|
|
345
400
|
unless allowed_codes.include?(code)
|
|
346
401
|
if in_sequence
|
|
347
402
|
joined = line.join('\#').strip
|
|
403
|
+
joined = romanize_string(joined) if romanize
|
|
404
|
+
|
|
348
405
|
translated = get_parameter_translated(401, joined, other_translation_map, game_type)
|
|
349
406
|
|
|
350
407
|
unless translated.nil? || translated.empty?
|
|
@@ -378,6 +435,8 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
|
|
|
378
435
|
subparameter = subparameter.strip
|
|
379
436
|
next if subparameter.empty?
|
|
380
437
|
|
|
438
|
+
subparameter = romanize_string(subparameter) if romanize
|
|
439
|
+
|
|
381
440
|
translated = get_parameter_translated(code, subparameter, other_translation_map, game_type)
|
|
382
441
|
parameters[0][sp] = translated unless translated.nil? || translated.empty?
|
|
383
442
|
end
|
|
@@ -385,12 +444,16 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
|
|
|
385
444
|
parameter = parameters[0].strip
|
|
386
445
|
next if parameter.empty?
|
|
387
446
|
|
|
447
|
+
parameter = romanize_string(parameter) if romanize
|
|
448
|
+
|
|
388
449
|
translated = get_parameter_translated(code, parameter, other_translation_map, game_type)
|
|
389
450
|
parameters[0] = translated unless translated.nil? || translated.empty?
|
|
390
451
|
elsif parameters[1].is_a?(String)
|
|
391
452
|
parameter = parameters[1].strip
|
|
392
453
|
next if parameter.empty?
|
|
393
454
|
|
|
455
|
+
parameter = romanize_string(parameter) if romanize
|
|
456
|
+
|
|
394
457
|
translated = get_parameter_translated(code, parameter, other_translation_map, game_type)
|
|
395
458
|
parameters[1] = translated unless translated.nil? || translated.empty?
|
|
396
459
|
end
|
|
@@ -421,6 +484,7 @@ end
|
|
|
421
484
|
def self.write_ini_title(ini_file_path, translated)
|
|
422
485
|
file_lines = File.readlines(ini_file_path, chomp: true)
|
|
423
486
|
title_line_index = file_lines.each_with_index { |line, i| break i if line.downcase.start_with?('title') }
|
|
487
|
+
return if title_line_index.is_a?(Array)
|
|
424
488
|
|
|
425
489
|
file_lines[title_line_index] = translated
|
|
426
490
|
File.binwrite(ini_file_path, file_lines.join("\n"))
|
|
@@ -431,8 +495,9 @@ end
|
|
|
431
495
|
# @param [String] other_path
|
|
432
496
|
# @param [String] output_path
|
|
433
497
|
# @param [Integer] shuffle_level
|
|
498
|
+
# @param [Boolean] romanize
|
|
434
499
|
# @param [Boolean] logging
|
|
435
|
-
def self.write_system(system_file_path, ini_file_path, other_path, output_path, shuffle_level, logging)
|
|
500
|
+
def self.write_system(system_file_path, ini_file_path, other_path, output_path, shuffle_level, romanize, logging)
|
|
436
501
|
system_basename = File.basename(system_file_path)
|
|
437
502
|
system_object = Marshal.load(File.binread(system_file_path))
|
|
438
503
|
|
|
@@ -455,7 +520,7 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
|
|
|
455
520
|
weapon_types = system_object.weapon_types
|
|
456
521
|
armor_types = system_object.armor_types
|
|
457
522
|
currency_unit = system_object.currency_unit
|
|
458
|
-
|
|
523
|
+
terms_vocabulary = system_object.terms || system_object.words
|
|
459
524
|
|
|
460
525
|
[elements, skill_types, weapon_types, armor_types].each_with_index do |array, i|
|
|
461
526
|
next unless array.is_a?(Array)
|
|
@@ -464,6 +529,8 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
|
|
|
464
529
|
string = string.strip
|
|
465
530
|
next if string.empty?
|
|
466
531
|
|
|
532
|
+
string = romanize_string(string) if romanize
|
|
533
|
+
|
|
467
534
|
translated = system_translation_map[string]
|
|
468
535
|
array[i] = translated unless translated.nil? || translated.empty?
|
|
469
536
|
end
|
|
@@ -479,35 +546,42 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
|
|
|
479
546
|
end
|
|
480
547
|
end
|
|
481
548
|
|
|
549
|
+
currency_unit = romanize_string(currency_unit) if romanize
|
|
482
550
|
currency_unit_translated = system_translation_map[currency_unit]
|
|
483
551
|
system_object.currency_unit = currency_unit_translated if currency_unit.is_a?(String) &&
|
|
484
552
|
(!currency_unit_translated.nil? && !currency_unit_translated.empty?)
|
|
485
553
|
|
|
486
|
-
|
|
487
|
-
value =
|
|
554
|
+
terms_vocabulary.instance_variables.each do |variable|
|
|
555
|
+
value = terms_vocabulary.instance_variable_get(variable)
|
|
488
556
|
|
|
489
557
|
if value.is_a?(String)
|
|
490
|
-
|
|
558
|
+
value = value.strip
|
|
491
559
|
next if value.empty?
|
|
492
560
|
|
|
493
|
-
|
|
561
|
+
value = romanize_string(value) if romanize
|
|
562
|
+
|
|
563
|
+
translated = system_translation_map[value]
|
|
494
564
|
value = translated unless translated.nil? || translated.empty?
|
|
495
565
|
elsif value.is_a?(Array)
|
|
496
566
|
value.each_with_index do |string, i|
|
|
497
567
|
string = string.strip
|
|
498
568
|
next if string.empty?
|
|
499
569
|
|
|
570
|
+
string = romanize_string(string) if romanize
|
|
571
|
+
|
|
500
572
|
translated = system_translation_map[string]
|
|
501
573
|
value[i] = translated unless translated.nil? || translated.empty?
|
|
502
574
|
end
|
|
503
575
|
end
|
|
504
576
|
|
|
505
|
-
|
|
577
|
+
terms_vocabulary.instance_variable_set(variable, value)
|
|
506
578
|
end
|
|
507
579
|
|
|
508
|
-
system_object.terms.nil?
|
|
509
|
-
system_object.words =
|
|
510
|
-
|
|
580
|
+
if system_object.terms.nil?
|
|
581
|
+
system_object.words = terms_vocabulary
|
|
582
|
+
else
|
|
583
|
+
system_object.terms = terms_vocabulary
|
|
584
|
+
end
|
|
511
585
|
|
|
512
586
|
game_title_translated = system_translated_text[-1]
|
|
513
587
|
|
|
@@ -523,8 +597,9 @@ end
|
|
|
523
597
|
# @param [String] scripts_file_path Path to Scripts.*data file
|
|
524
598
|
# @param [String] other_path Path to translation/other directory containing .txt files
|
|
525
599
|
# @param [String] output_path Path to the output directory
|
|
600
|
+
# @param [Boolean] romanize
|
|
526
601
|
# @param [Boolean] logging Whether to log
|
|
527
|
-
def self.write_scripts(scripts_file_path, other_path, output_path, logging)
|
|
602
|
+
def self.write_scripts(scripts_file_path, other_path, output_path, romanize, logging)
|
|
528
603
|
scripts_basename = File.basename(scripts_file_path)
|
|
529
604
|
script_entries = Marshal.load(File.binread(scripts_file_path))
|
|
530
605
|
|
|
@@ -564,6 +639,8 @@ def self.write_scripts(scripts_file_path, other_path, output_path, logging)
|
|
|
564
639
|
string = string.strip.delete(' ')
|
|
565
640
|
next if string.empty? || !scripts_translation_map.include?(string)
|
|
566
641
|
|
|
642
|
+
string = romanize_string(string) if romanize
|
|
643
|
+
|
|
567
644
|
gotten = scripts_translation_map[string]
|
|
568
645
|
code[index - string.length, string.length] = gotten unless gotten.nil? || gotten.empty?
|
|
569
646
|
end
|
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.
|
|
5
|
+
spec.version = '1.9.0'
|
|
6
6
|
spec.authors = ['Howard Jeng', 'Andrew Kesterson', 'Solistra', 'Darkness9724', 'savannstm']
|
|
7
7
|
spec.email = ['savannstm@gmail.com']
|
|
8
8
|
spec.summary = 'Reads RPG Maker XP/VX/VXAce game text to .txt files and writes them to their initial form.'
|
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.
|
|
4
|
+
version: 1.9.0
|
|
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-24 00:00:00.000000000 Z
|
|
16
16
|
dependencies: []
|
|
17
17
|
description:
|
|
18
18
|
email:
|