rvpacker-txt 1.8.4 → 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 +148 -64
- data/lib/classes.rb +1 -1
- data/lib/read.rb +111 -27
- data/lib/write.rb +90 -13
- data/rvpacker-txt.gemspec +2 -2
- metadata +4 -3
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,21 +7,81 @@ 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
|
-
|
|
13
|
-
|
|
38
|
+
read_command_description = 'Parses files from "original" or "data" folders of input directory to "translation" folder of output directory.'
|
|
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.'
|
|
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
|
|
14
68
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
69
|
+
OptionParser.new(banner) do |cmd|
|
|
70
|
+
cmd.on('-i', '--input-dir PATH', String,
|
|
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]
|
|
18
74
|
end
|
|
19
75
|
|
|
20
|
-
cmd.on('-o', '--output-dir
|
|
21
|
-
|
|
76
|
+
cmd.on('-o', '--output-dir PATH', String,
|
|
77
|
+
*output_dir_description) do |dir|
|
|
78
|
+
options[:output_path] = File.exist?(dir) ? File.realpath(dir) : (raise "#{dir} not found")
|
|
22
79
|
end
|
|
23
80
|
|
|
24
|
-
cmd.on('--disable-processing FILES', Array,
|
|
81
|
+
cmd.on('--disable-processing FILES', Array,
|
|
82
|
+
'Skips processing specified files.',
|
|
83
|
+
'Example: --disable-processing=maps,other,system.',
|
|
84
|
+
'[Allowed values: maps, other, system, scripts]') do |files|
|
|
25
85
|
files.each do |file|
|
|
26
86
|
files = %w[maps other system scripts]
|
|
27
87
|
index = files.find_index(file)
|
|
@@ -29,39 +89,51 @@ def self.parse_options
|
|
|
29
89
|
end
|
|
30
90
|
end
|
|
31
91
|
|
|
32
|
-
cmd.on('-
|
|
33
|
-
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
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
|
|
37
94
|
options[:disable_custom_processing] = true
|
|
38
95
|
end
|
|
39
96
|
|
|
40
|
-
cmd.on('-
|
|
41
|
-
|
|
97
|
+
cmd.on('-r', '--romanize',
|
|
98
|
+
*romanize_description) do
|
|
99
|
+
options[:romanize_string] = true
|
|
42
100
|
end
|
|
43
101
|
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
46
125
|
end
|
|
47
126
|
|
|
48
|
-
cmd.on('-
|
|
49
|
-
|
|
50
|
-
'Cannot be used with --force') do
|
|
51
|
-
raise '--append cannot be used with --force.' if options[:force]
|
|
52
|
-
options[:append] = true
|
|
127
|
+
cmd.on('-l', '--log', 'Enables logging.') do
|
|
128
|
+
options[:logging] = true
|
|
53
129
|
end
|
|
54
130
|
|
|
55
|
-
cmd.on('-h', '--help', '
|
|
131
|
+
cmd.on('-h', '--help', "Prints the program's help message or for the entered subcommand.") do
|
|
56
132
|
puts cmd
|
|
57
133
|
exit
|
|
58
134
|
end
|
|
59
135
|
end.parse!
|
|
60
136
|
|
|
61
|
-
options[:action] = ARGV.shift
|
|
62
|
-
raise 'COMMAND argument is required. Use rvpacker-txt -h for help.' if options[:action].nil?
|
|
63
|
-
raise 'Invalid command. Allowed commands are: read, write.' unless %w[read write].include?(options[:action])
|
|
64
|
-
|
|
65
137
|
options
|
|
66
138
|
end
|
|
67
139
|
|
|
@@ -69,34 +141,44 @@ end
|
|
|
69
141
|
# @return [String, nil]
|
|
70
142
|
def self.get_game_type(system_file_path)
|
|
71
143
|
object = Marshal.load(File.binread(system_file_path))
|
|
72
|
-
game_title = object.
|
|
144
|
+
game_title = object.game_title.to_s.downcase
|
|
73
145
|
game_title.include?('lisa') ? 'lisa' : nil
|
|
74
146
|
end
|
|
75
147
|
|
|
76
148
|
start_time = Time.now
|
|
77
149
|
|
|
78
150
|
options = parse_options
|
|
79
|
-
|
|
80
|
-
|
|
151
|
+
# @type [String]
|
|
152
|
+
input_path = options[:input_path]
|
|
153
|
+
# @type [String]
|
|
154
|
+
output_path = options[:output_path]
|
|
155
|
+
# @type [Boolean]
|
|
81
156
|
disable_custom_processing = options[:disable_custom_processing]
|
|
157
|
+
# @type [Integer]
|
|
82
158
|
shuffle_level = options[:shuffle_level]
|
|
159
|
+
# @type [Boolean]
|
|
83
160
|
logging = options[:logging]
|
|
161
|
+
# @type [Hash{Symbol => Boolean}]
|
|
84
162
|
disable_processing = options[:disable_processing]
|
|
163
|
+
# @type [Boolean]
|
|
85
164
|
force = options[:force]
|
|
165
|
+
# @type [Boolean]
|
|
86
166
|
append = options[:append]
|
|
167
|
+
# @type [Boolean]
|
|
168
|
+
romanize = options[:romanize_string]
|
|
87
169
|
|
|
88
170
|
extensions = { xp: 'rxdata', vx: 'rvdata', ace: 'rvdata2' }
|
|
89
171
|
|
|
90
|
-
original_directory = Dir.glob(File.join(
|
|
172
|
+
original_directory = Dir.glob(File.join(input_path, '{data,original}'), File::FNM_CASEFOLD).first
|
|
91
173
|
raise '"Data" or "original" directory not found within input directory.' unless original_directory
|
|
92
174
|
|
|
93
|
-
maps_path = File.join(
|
|
94
|
-
other_path = File.join(
|
|
175
|
+
maps_path = File.join(input_path, 'translation', 'maps')
|
|
176
|
+
other_path = File.join(input_path, 'translation', 'other')
|
|
95
177
|
|
|
96
178
|
FileUtils.mkdir_p(maps_path)
|
|
97
179
|
FileUtils.mkdir_p(other_path)
|
|
98
180
|
|
|
99
|
-
engine = extensions.
|
|
181
|
+
engine = extensions.each_pair { |sym, ext| break sym if File.exist?(File.join(original_directory, "System.#{ext}")) } ||
|
|
100
182
|
(raise "Couldn't determine project engine.")
|
|
101
183
|
|
|
102
184
|
files = Dir.glob("#{original_directory}/*#{extensions[engine]}")
|
|
@@ -121,45 +203,47 @@ files.each do |file|
|
|
|
121
203
|
end
|
|
122
204
|
end
|
|
123
205
|
|
|
124
|
-
ini_file_path = File.join(
|
|
206
|
+
ini_file_path = File.join(input_path, 'Game.ini')
|
|
125
207
|
|
|
126
208
|
game_type = disable_custom_processing ? nil : get_game_type(system_file_path)
|
|
127
209
|
|
|
128
|
-
wait_time = 0
|
|
129
|
-
processing_type = if force
|
|
130
|
-
wait_time_start = Time.now
|
|
131
|
-
|
|
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."
|
|
135
|
-
exit unless gets.chomp == 'Y'
|
|
136
|
-
|
|
137
|
-
wait_time = Time.now - wait_time_start
|
|
138
|
-
:force
|
|
139
|
-
else
|
|
140
|
-
append ? :append : :default
|
|
141
|
-
end
|
|
142
|
-
|
|
143
210
|
puts 'Custom processing for this game is enabled. Use --disable-custom-processing to disable it.' unless game_type.nil?
|
|
144
211
|
|
|
212
|
+
$wait_time = 0
|
|
213
|
+
|
|
145
214
|
if options[:action] == 'read'
|
|
146
215
|
require 'read'
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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]
|
|
151
237
|
else
|
|
152
238
|
require 'write'
|
|
153
|
-
|
|
239
|
+
|
|
240
|
+
output_path = File.join(output_path, 'output')
|
|
154
241
|
FileUtils.mkdir_p(output_path)
|
|
155
242
|
|
|
156
|
-
write_map(maps_files_paths, maps_path, output_path, shuffle_level, logging, game_type) unless disable_processing[:maps]
|
|
157
|
-
write_other(other_files_paths, other_path, output_path, shuffle_level, logging, game_type) unless disable_processing[:other]
|
|
158
|
-
write_system(system_file_path, ini_file_path, other_path, output_path, shuffle_level, logging) unless disable_processing[:system]
|
|
159
|
-
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]
|
|
160
247
|
end
|
|
161
248
|
|
|
162
|
-
|
|
163
|
-
elapsed_time = Time.now - start_time - wait_time - $wait_time
|
|
164
|
-
|
|
165
|
-
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,6 +118,8 @@ end
|
|
|
70
118
|
# @param [String] game_type
|
|
71
119
|
# @return [String]
|
|
72
120
|
def self.parse_parameter(code, parameter, game_type)
|
|
121
|
+
return nil if parameter.match?(STRING_IS_ONLY_SYMBOLS_RE)
|
|
122
|
+
|
|
73
123
|
unless game_type.nil?
|
|
74
124
|
case code
|
|
75
125
|
when 401, 405
|
|
@@ -97,6 +147,7 @@ end
|
|
|
97
147
|
# @param [String] _game_type
|
|
98
148
|
# @return [String]
|
|
99
149
|
def self.parse_variable(variable, _game_type)
|
|
150
|
+
return nil if variable.match?(STRING_IS_ONLY_SYMBOLS_RE)
|
|
100
151
|
variable = variable.gsub(/\r?\n/, '\#') if variable.count("\n").positive?
|
|
101
152
|
|
|
102
153
|
return nil if variable.split('\#').all? { |line| line.strip.match?(/(^#? ?<.*>\.?$)|^$/) }
|
|
@@ -109,10 +160,11 @@ end
|
|
|
109
160
|
|
|
110
161
|
# @param [Array<String>] maps_files_paths
|
|
111
162
|
# @param [String] output_path
|
|
163
|
+
# @param [Boolean] romanize
|
|
112
164
|
# @param [Boolean] logging
|
|
113
165
|
# @param [String] game_type
|
|
114
166
|
# @param [String] processing_type
|
|
115
|
-
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)
|
|
116
168
|
maps_output_path = File.join(output_path, 'maps.txt')
|
|
117
169
|
names_output_path = File.join(output_path, 'names.txt')
|
|
118
170
|
maps_trans_output_path = File.join(output_path, 'maps_trans.txt')
|
|
@@ -138,7 +190,7 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
138
190
|
names_translation_map = Hash[File.readlines(names_output_path, chomp: true)
|
|
139
191
|
.zip(File.readlines(names_trans_output_path, chomp: true))]
|
|
140
192
|
else
|
|
141
|
-
puts
|
|
193
|
+
puts APPEND_FLAG_OMIT_MSG
|
|
142
194
|
processing_type = :default
|
|
143
195
|
end
|
|
144
196
|
end
|
|
@@ -155,6 +207,8 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
155
207
|
display_name = display_name.strip
|
|
156
208
|
|
|
157
209
|
unless display_name.empty?
|
|
210
|
+
display_name = romanize_string(display_name) if romanize
|
|
211
|
+
|
|
158
212
|
names_translation_map.insert_at_index(names_lines.length, display_name, '') if processing_type == :append &&
|
|
159
213
|
!names_translation_map.include?(display_name)
|
|
160
214
|
|
|
@@ -184,13 +238,17 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
184
238
|
joined = line.join('\#').strip
|
|
185
239
|
parsed = parse_parameter(401, joined, game_type)
|
|
186
240
|
|
|
187
|
-
|
|
188
|
-
|
|
241
|
+
unless parsed.nil?
|
|
242
|
+
parsed = romanize_string(parsed) if romanize
|
|
189
243
|
|
|
190
|
-
|
|
244
|
+
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
|
|
245
|
+
!maps_translation_map.include?(parsed)
|
|
191
246
|
|
|
192
|
-
|
|
193
|
-
|
|
247
|
+
maps_lines.add(parsed)
|
|
248
|
+
|
|
249
|
+
line.clear
|
|
250
|
+
in_sequence = false
|
|
251
|
+
end
|
|
194
252
|
end
|
|
195
253
|
next
|
|
196
254
|
end
|
|
@@ -212,6 +270,8 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
212
270
|
parsed = parse_parameter(code, subparameter, game_type)
|
|
213
271
|
next if parsed.nil?
|
|
214
272
|
|
|
273
|
+
parsed = romanize_string(parsed) if romanize
|
|
274
|
+
|
|
215
275
|
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
|
|
216
276
|
!maps_translation_map.include?(parsed)
|
|
217
277
|
|
|
@@ -225,6 +285,7 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
225
285
|
next if parsed.nil?
|
|
226
286
|
|
|
227
287
|
parsed = parsed.gsub(/\r?\n/, '\#')
|
|
288
|
+
parsed = romanize_string(parsed) if romanize
|
|
228
289
|
|
|
229
290
|
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
|
|
230
291
|
!maps_translation_map.include?(parsed)
|
|
@@ -261,10 +322,11 @@ end
|
|
|
261
322
|
|
|
262
323
|
# @param [Array<String>] other_files_paths
|
|
263
324
|
# @param [String] output_path
|
|
325
|
+
# @param [Boolean] romanize
|
|
264
326
|
# @param [Boolean] logging
|
|
265
327
|
# @param [String] game_type
|
|
266
328
|
# @param [String] processing_type
|
|
267
|
-
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)
|
|
268
330
|
other_object_array_map = Hash[other_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
269
331
|
|
|
270
332
|
inner_processing_type = processing_type
|
|
@@ -294,7 +356,7 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
294
356
|
other_translation_map = Hash[File.readlines(other_output_path, chomp: true)
|
|
295
357
|
.zip(File.readlines(other_trans_output_path, chomp: true))]
|
|
296
358
|
else
|
|
297
|
-
puts
|
|
359
|
+
puts APPEND_FLAG_OMIT_MSG
|
|
298
360
|
inner_processing_type = :default
|
|
299
361
|
end
|
|
300
362
|
end
|
|
@@ -318,6 +380,7 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
318
380
|
next if parsed.nil?
|
|
319
381
|
|
|
320
382
|
parsed = parsed.gsub(/\r?\n/, '\#')
|
|
383
|
+
parsed = romanize_string(parsed) if romanize
|
|
321
384
|
|
|
322
385
|
other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
|
|
323
386
|
!other_translation_map.include?(parsed)
|
|
@@ -347,13 +410,17 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
347
410
|
joined = line.join('\#').strip
|
|
348
411
|
parsed = parse_parameter(401, joined, game_type)
|
|
349
412
|
|
|
350
|
-
|
|
351
|
-
|
|
413
|
+
unless parsed.nil?
|
|
414
|
+
parsed = romanize_string(parsed) if romanize
|
|
352
415
|
|
|
353
|
-
|
|
416
|
+
other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
|
|
417
|
+
!other_translation_map.include?(parsed)
|
|
354
418
|
|
|
355
|
-
|
|
356
|
-
|
|
419
|
+
other_lines.add(parsed)
|
|
420
|
+
|
|
421
|
+
line.clear
|
|
422
|
+
in_sequence = false
|
|
423
|
+
end
|
|
357
424
|
end
|
|
358
425
|
next
|
|
359
426
|
end
|
|
@@ -372,6 +439,8 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
372
439
|
subparameter = subparameter.strip
|
|
373
440
|
next if subparameter.empty?
|
|
374
441
|
|
|
442
|
+
subparameter = romanize_string(subparameter) if romanize
|
|
443
|
+
|
|
375
444
|
other_translation_map.insert_at_index(other_lines.length, subparameter, '') if inner_processing_type == :append &&
|
|
376
445
|
!other_translation_map.include?(subparameter)
|
|
377
446
|
|
|
@@ -382,6 +451,7 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
382
451
|
next if parameter.empty?
|
|
383
452
|
|
|
384
453
|
parameter = parameter.gsub(/\r?\n/, '\#')
|
|
454
|
+
parameter = romanize_string(parameter) if romanize
|
|
385
455
|
|
|
386
456
|
other_translation_map.insert_at_index(other_lines.length, parameter, '') if inner_processing_type == :append &&
|
|
387
457
|
!other_translation_map.include?(parameter)
|
|
@@ -392,6 +462,7 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
392
462
|
next if parameter.empty?
|
|
393
463
|
|
|
394
464
|
parameter = parameter.gsub(/\r?\n/, '\#')
|
|
465
|
+
parameter = romanize_string(parameter) if romanize
|
|
395
466
|
|
|
396
467
|
other_translation_map.insert_at_index(other_lines.length, parameter, '') if inner_processing_type == :append &&
|
|
397
468
|
!other_translation_map.include?(parameter)
|
|
@@ -432,9 +503,10 @@ end
|
|
|
432
503
|
# @param [String] system_file_path
|
|
433
504
|
# @param [String] ini_file_path
|
|
434
505
|
# @param [String] output_path
|
|
506
|
+
# @param [Boolean] romanize
|
|
435
507
|
# @param [Boolean] logging
|
|
436
508
|
# @param [String] processing_type
|
|
437
|
-
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)
|
|
438
510
|
system_filename = File.basename(system_file_path)
|
|
439
511
|
system_basename = File.basename(system_file_path, '.*').downcase
|
|
440
512
|
|
|
@@ -456,7 +528,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
456
528
|
system_translation_map = Hash[File.readlines(system_output_path, chomp: true)
|
|
457
529
|
.zip(File.readlines(system_trans_output_path, chomp: true))]
|
|
458
530
|
else
|
|
459
|
-
puts
|
|
531
|
+
puts APPEND_FLAG_OMIT_MSG
|
|
460
532
|
processing_type = :default
|
|
461
533
|
end
|
|
462
534
|
end
|
|
@@ -477,6 +549,8 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
477
549
|
string = string.strip
|
|
478
550
|
next if string.empty?
|
|
479
551
|
|
|
552
|
+
string = romanize_string(string) if romanize
|
|
553
|
+
|
|
480
554
|
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
|
|
481
555
|
!system_translation_map.include?(string)
|
|
482
556
|
|
|
@@ -488,6 +562,8 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
488
562
|
currency_unit = currency_unit.strip
|
|
489
563
|
|
|
490
564
|
unless currency_unit.empty?
|
|
565
|
+
currency_unit = romanize_string(currency_unit) if romanize
|
|
566
|
+
|
|
491
567
|
system_translation_map.insert_at_index(system_lines.length, currency_unit, '') if processing_type == :append &&
|
|
492
568
|
!system_translation_map.include?(currency_unit)
|
|
493
569
|
|
|
@@ -502,6 +578,8 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
502
578
|
value = value.strip
|
|
503
579
|
|
|
504
580
|
unless value.empty?
|
|
581
|
+
value = romanize_string(string) if romanize
|
|
582
|
+
|
|
505
583
|
system_translation_map.insert_at_index(system_lines.length, value, '') if processing_type == :append &&
|
|
506
584
|
!system_translation_map.include?(value)
|
|
507
585
|
|
|
@@ -514,6 +592,8 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
514
592
|
string = string.strip
|
|
515
593
|
next if string.empty?
|
|
516
594
|
|
|
595
|
+
string = romanize_string(string) if romanize
|
|
596
|
+
|
|
517
597
|
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
|
|
518
598
|
!system_translation_map.include?(string)
|
|
519
599
|
|
|
@@ -525,6 +605,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
525
605
|
# Game title from System file and ini file may differ, but requesting user request to determine which line do they want is LAME
|
|
526
606
|
# So just throw that ini ass and continue
|
|
527
607
|
ini_game_title = read_ini_title(ini_file_path).strip
|
|
608
|
+
ini_game_title = romanize_string(ini_game_title) if romanize
|
|
528
609
|
|
|
529
610
|
system_translation_map.insert_at_index(system_lines.length, ini_game_title, '') if processing_type == :append &&
|
|
530
611
|
!system_translation_map.include?(ini_game_title)
|
|
@@ -547,9 +628,10 @@ end
|
|
|
547
628
|
|
|
548
629
|
# @param [String] scripts_file_path
|
|
549
630
|
# @param [String] output_path
|
|
631
|
+
# @param [Boolean] romanize
|
|
550
632
|
# @param [Boolean] logging
|
|
551
633
|
# @param [String] processing_type
|
|
552
|
-
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)
|
|
553
635
|
scripts_filename = File.basename(scripts_file_path)
|
|
554
636
|
scripts_basename = File.basename(scripts_file_path, '.*').downcase
|
|
555
637
|
|
|
@@ -572,7 +654,7 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
572
654
|
scripts_translation_map = Hash[File.readlines(scripts_output_path, chomp: true)
|
|
573
655
|
.zip(File.readlines(scripts_trans_output_path, chomp: true))]
|
|
574
656
|
else
|
|
575
|
-
puts
|
|
657
|
+
puts APPEND_FLAG_OMIT_MSG
|
|
576
658
|
processing_type = :default
|
|
577
659
|
end
|
|
578
660
|
end
|
|
@@ -618,7 +700,7 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
618
700
|
string.match?(/^(?=.*\d)[A-Za-z0-9\-]+$/) ||
|
|
619
701
|
string.match?(/^[a-z\-()\/ +'&]*$/) ||
|
|
620
702
|
string.match?(/^[A-Za-z]+[+-]$/) ||
|
|
621
|
-
string.match?(
|
|
703
|
+
string.match?(STRING_IS_ONLY_SYMBOLS_RE) ||
|
|
622
704
|
string.match?(/^Tile.*[A-Z]$/) ||
|
|
623
705
|
string.match?(/^[a-zA-Z][a-z]+([A-Z][a-z]*)+$/) ||
|
|
624
706
|
string.match?(/^Cancel Action$|^Invert$|^End$|^Individual$|^Missed File$|^Bitmap$|^Audio$/) ||
|
|
@@ -645,6 +727,8 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
645
727
|
string.match?(/Clear image/) ||
|
|
646
728
|
string.match?(/Can Collapse/)
|
|
647
729
|
|
|
730
|
+
string = romanize_string(string) if romanize
|
|
731
|
+
|
|
648
732
|
scripts_translation_map.insert_at_index(scripts_lines.length, string, '') if processing_type == :append &&
|
|
649
733
|
!scripts_translation_map.include?(string)
|
|
650
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,10 +2,10 @@
|
|
|
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
|
-
spec.summary = 'Reads
|
|
8
|
+
spec.summary = 'Reads RPG Maker XP/VX/VXAce game text to .txt files and writes them to their initial form.'
|
|
9
9
|
spec.homepage = 'https://github.com/savannstm/rvpacker-txt'
|
|
10
10
|
spec.license = 'MIT'
|
|
11
11
|
spec.required_ruby_version = Gem::Requirement.new('>= 3.0.0')
|
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:
|
|
@@ -53,5 +53,6 @@ requirements: []
|
|
|
53
53
|
rubygems_version: 3.5.14
|
|
54
54
|
signing_key:
|
|
55
55
|
specification_version: 4
|
|
56
|
-
summary: Reads
|
|
56
|
+
summary: Reads RPG Maker XP/VX/VXAce game text to .txt files and writes them to their
|
|
57
|
+
initial form.
|
|
57
58
|
test_files: []
|