rvpacker-txt 1.6.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/rvpacker-txt +9 -8
- data/lib/classes.rb +63 -0
- data/lib/read.rb +166 -141
- data/lib/write.rb +162 -153
- 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: 74aada023c293bbfcc7d1f6ae5938daadaf3fd0b021df0828d9ac6cd7b6c2ff5
|
|
4
|
+
data.tar.gz: 609a0d4ebb873b9162f3999d3620419757c60724a316c6716311b3f6268fe32e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 94d500defcefee3f20a86b8ff7adc7b25379cec0561b0ef675e00b4c1153fc23e00f8e897a425848c2be77bdcb59fa3931fb8ec647a64a6b0d768d231f3161cd
|
|
7
|
+
data.tar.gz: 00b7582689da125e19e2ec21d9b8543e40ea1d2c19a382e719a0d81a42dfd4069f65bf4ec2cee7da4ad9a8fc635bfb79747f5c6201437f20c3d4a6746348a295
|
data/bin/rvpacker-txt
CHANGED
|
@@ -45,7 +45,8 @@ def self.parse_options
|
|
|
45
45
|
options[:force] = true
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
cmd.on('-a', '--append', 'When you update the rvpacker-txt, you probably should re-read',
|
|
48
|
+
cmd.on('-a', '--append', 'When you update the rvpacker-txt, you probably should re-read',
|
|
49
|
+
'your files with append, as some new text might be added to parser', 'Cannot be used with --force') do
|
|
49
50
|
raise '--append cannot be used beside --force.' if options[:force]
|
|
50
51
|
options[:append] = true
|
|
51
52
|
end
|
|
@@ -83,7 +84,7 @@ disable_processing = options[:disable_processing]
|
|
|
83
84
|
force = options[:force]
|
|
84
85
|
append = options[:append]
|
|
85
86
|
|
|
86
|
-
extensions = { xp: '
|
|
87
|
+
extensions = { xp: 'rxdata', vx: 'rvdata', ace: 'rvdata2' }
|
|
87
88
|
|
|
88
89
|
original_directory = Dir.glob(File.join(input_dir, '{data,original}'), File::FNM_CASEFOLD).first
|
|
89
90
|
raise '"Data" or "original" directory not found within input directory.' unless original_directory
|
|
@@ -94,11 +95,11 @@ other_path = File.join(input_dir, 'translation', 'other')
|
|
|
94
95
|
FileUtils.mkdir_p(maps_path)
|
|
95
96
|
FileUtils.mkdir_p(other_path)
|
|
96
97
|
|
|
97
|
-
engine = extensions.
|
|
98
|
-
File.exist?(File.join(original_directory, "System.#{extension}"))
|
|
98
|
+
engine = extensions.each do |symbol, extension|
|
|
99
|
+
break symbol if File.exist?(File.join(original_directory, "System.#{extension}"))
|
|
99
100
|
end || (raise "Couldn't determine project engine.")
|
|
100
101
|
|
|
101
|
-
files = Dir.glob("#{original_directory}/*#{extensions[engine
|
|
102
|
+
files = Dir.glob("#{original_directory}/*#{extensions[engine]}")
|
|
102
103
|
|
|
103
104
|
maps_files_paths = []
|
|
104
105
|
other_files_paths = []
|
|
@@ -107,7 +108,7 @@ scripts_file_path = nil
|
|
|
107
108
|
|
|
108
109
|
files.each do |file|
|
|
109
110
|
basename = File.basename(file)
|
|
110
|
-
next unless basename.end_with?(extensions[engine
|
|
111
|
+
next unless basename.end_with?(extensions[engine])
|
|
111
112
|
|
|
112
113
|
if basename.start_with?(/Map[0-9]/)
|
|
113
114
|
maps_files_paths.push(file)
|
|
@@ -132,9 +133,9 @@ processing_type = if force
|
|
|
132
133
|
exit unless gets.chomp == 'Y'
|
|
133
134
|
|
|
134
135
|
wait_time = Time.now - wait_time_start
|
|
135
|
-
|
|
136
|
+
:force
|
|
136
137
|
else
|
|
137
|
-
append ?
|
|
138
|
+
append ? :append : :default
|
|
138
139
|
end
|
|
139
140
|
|
|
140
141
|
puts 'Custom processing for this game is enabled. Use --disable-custom-processing to disable it.' unless game_type.nil?
|
data/lib/classes.rb
CHANGED
|
@@ -113,6 +113,69 @@ class IndexSet
|
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
module RPG
|
|
116
|
+
class Map
|
|
117
|
+
attr_accessor :display_name, :events
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
class Event
|
|
121
|
+
attr_accessor :pages
|
|
122
|
+
|
|
123
|
+
class Page
|
|
124
|
+
attr_accessor :list
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
class EventCommand
|
|
129
|
+
attr_accessor :code, :parameters
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
class Actor
|
|
133
|
+
attr_accessor :name, :nickname, :description, :note
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
class Armor
|
|
137
|
+
attr_accessor :name, :nickname, :description, :note
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
class Class
|
|
141
|
+
attr_accessor :name, :nickname, :description, :note
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
class Enemy
|
|
145
|
+
attr_accessor :name, :nickname, :description, :note
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
class Item
|
|
149
|
+
attr_accessor :name, :nickname, :description, :note
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
class Skill
|
|
153
|
+
attr_accessor :name, :nickname, :description, :note
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
class State
|
|
157
|
+
attr_accessor :name, :nickname, :description, :note
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
class Weapon
|
|
161
|
+
attr_accessor :name, :nickname, :description, :note
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
class CommonEvent
|
|
165
|
+
attr_accessor :pages, :list
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
class Troop
|
|
169
|
+
attr_accessor :pages
|
|
170
|
+
|
|
171
|
+
class Page
|
|
172
|
+
attr_accessor :list
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
class System
|
|
177
|
+
attr_accessor :elements, :skill_types, :weapon_types, :armor_types, :currency_unit, :terms, :words, :game_title
|
|
178
|
+
end
|
|
116
179
|
end
|
|
117
180
|
|
|
118
181
|
module RGSS
|
data/lib/read.rb
CHANGED
|
@@ -25,7 +25,10 @@ def self.extract_quoted_strings(string)
|
|
|
25
25
|
string.each_line do |line|
|
|
26
26
|
stripped = line.strip
|
|
27
27
|
|
|
28
|
-
next if stripped[0] == '#' ||
|
|
28
|
+
next if stripped[0] == '#' ||
|
|
29
|
+
!stripped.match?(/["']/) ||
|
|
30
|
+
stripped.start_with?(/(Win|Lose)|_Fanfare/) ||
|
|
31
|
+
stripped.match?(/eval\(/)
|
|
29
32
|
|
|
30
33
|
skip_block = true if stripped.start_with?('=begin')
|
|
31
34
|
skip_block = false if stripped.start_with?('=end')
|
|
@@ -34,7 +37,7 @@ def self.extract_quoted_strings(string)
|
|
|
34
37
|
|
|
35
38
|
buffer.push('\#') if in_quotes
|
|
36
39
|
|
|
37
|
-
line.each_char
|
|
40
|
+
line.each_char do |char|
|
|
38
41
|
if %w[' "].include?(char)
|
|
39
42
|
unless quote_type.nil? || char == quote_type
|
|
40
43
|
buffer.push(char)
|
|
@@ -115,7 +118,7 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
115
118
|
maps_trans_output_path = File.join(output_path, 'maps_trans.txt')
|
|
116
119
|
names_trans_output_path = File.join(output_path, 'names_trans.txt')
|
|
117
120
|
|
|
118
|
-
if processing_type ==
|
|
121
|
+
if processing_type == :default && (File.exist?(maps_trans_output_path) || File.exist?(names_trans_output_path))
|
|
119
122
|
puts 'maps_trans.txt or names_trans.txt file already exists. If you want to forcefully re-read all files, use --force flag, or --append if you want append new text to already existing files.'
|
|
120
123
|
return
|
|
121
124
|
end
|
|
@@ -130,7 +133,7 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
130
133
|
maps_translation_map = nil
|
|
131
134
|
names_translation_map = nil
|
|
132
135
|
|
|
133
|
-
if processing_type ==
|
|
136
|
+
if processing_type == :append
|
|
134
137
|
if File.exist?(maps_trans_output_path)
|
|
135
138
|
maps_translation_map = Hash[File.readlines(maps_output_path, chomp: true)
|
|
136
139
|
.zip(File.readlines(maps_trans_output_path, chomp: true))]
|
|
@@ -138,96 +141,98 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
138
141
|
.zip(File.readlines(names_trans_output_path, chomp: true))]
|
|
139
142
|
else
|
|
140
143
|
puts "Files aren't already parsed. Continuing as if --append flag was omitted."
|
|
141
|
-
processing_type =
|
|
144
|
+
processing_type = :default
|
|
142
145
|
end
|
|
143
146
|
end
|
|
144
147
|
|
|
148
|
+
# 401 - dialogue lines
|
|
149
|
+
# 102 - dialogue choices array
|
|
150
|
+
# 402 - one of the dialogue choices from the array
|
|
151
|
+
# 356 - system lines/special texts (do they even exist before mv?)
|
|
152
|
+
allowed_codes = [401, 102, 402, 356].freeze
|
|
153
|
+
|
|
145
154
|
maps_object_map.each do |filename, object|
|
|
146
|
-
display_name = object.
|
|
155
|
+
display_name = object.display_name
|
|
147
156
|
|
|
148
157
|
if display_name.is_a?(String)
|
|
149
158
|
display_name = display_name.strip
|
|
150
159
|
|
|
151
160
|
unless display_name.empty?
|
|
152
|
-
names_translation_map.insert_at_index(names_lines.length, display_name, '') if processing_type ==
|
|
161
|
+
names_translation_map.insert_at_index(names_lines.length, display_name, '') if processing_type == :append &&
|
|
153
162
|
!names_translation_map.include?(display_name)
|
|
154
163
|
|
|
155
164
|
names_lines.add(display_name)
|
|
156
165
|
end
|
|
157
166
|
end
|
|
158
167
|
|
|
159
|
-
events = object.
|
|
168
|
+
events = object.events
|
|
160
169
|
next if events.nil?
|
|
161
170
|
|
|
162
171
|
events.each_value do |event|
|
|
163
|
-
pages = event.
|
|
172
|
+
pages = event.pages
|
|
164
173
|
next if pages.nil?
|
|
165
174
|
|
|
166
175
|
pages.each do |page|
|
|
167
|
-
list = page.
|
|
176
|
+
list = page.list
|
|
168
177
|
next if list.nil?
|
|
169
178
|
|
|
170
179
|
in_sequence = false
|
|
171
180
|
line = []
|
|
172
181
|
|
|
173
182
|
list.each do |item|
|
|
174
|
-
code = item.
|
|
175
|
-
parameters = item.instance_variable_get(:@parameters)
|
|
176
|
-
|
|
177
|
-
parameters.each do |parameter|
|
|
178
|
-
if code == 401
|
|
179
|
-
next unless parameter.is_a?(String) && !parameter.empty?
|
|
180
|
-
|
|
181
|
-
in_sequence = true
|
|
182
|
-
line.push(parameter)
|
|
183
|
-
else
|
|
184
|
-
if in_sequence
|
|
185
|
-
joined = line.join('\#').strip
|
|
186
|
-
parsed = parse_parameter(401, joined, game_type)
|
|
187
|
-
|
|
188
|
-
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == 'append' &&
|
|
189
|
-
!maps_translation_map.include?(parsed)
|
|
183
|
+
code = item.code
|
|
190
184
|
|
|
191
|
-
|
|
185
|
+
unless allowed_codes.include?(code)
|
|
186
|
+
if in_sequence
|
|
187
|
+
joined = line.join('\#').strip
|
|
188
|
+
parsed = parse_parameter(401, joined, game_type)
|
|
192
189
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
end
|
|
190
|
+
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
|
|
191
|
+
!maps_translation_map.include?(parsed)
|
|
196
192
|
|
|
197
|
-
|
|
198
|
-
parameter.each do |subparameter|
|
|
199
|
-
next unless subparameter.is_a?(String)
|
|
193
|
+
maps_lines.add(parsed)
|
|
200
194
|
|
|
201
|
-
|
|
195
|
+
line.clear
|
|
196
|
+
in_sequence = false
|
|
197
|
+
end
|
|
198
|
+
next
|
|
199
|
+
end
|
|
202
200
|
|
|
203
|
-
|
|
201
|
+
parameters = item.parameters
|
|
204
202
|
|
|
205
|
-
|
|
203
|
+
if code == 401
|
|
204
|
+
next unless parameters[0].is_a?(String) && !parameters[0].empty?
|
|
206
205
|
|
|
207
|
-
|
|
206
|
+
in_sequence = true
|
|
207
|
+
line.push(parameters[0])
|
|
208
|
+
elsif parameters[0].is_a?(Array)
|
|
209
|
+
parameters[0].each do |subparameter|
|
|
210
|
+
next unless subparameter.is_a?(String)
|
|
208
211
|
|
|
209
|
-
|
|
210
|
-
|
|
212
|
+
subparameter = subparameter.strip
|
|
213
|
+
next if subparameter.empty?
|
|
211
214
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
elsif code == 356 && parameter.is_a?(String)
|
|
215
|
-
parameter = parameter.strip
|
|
215
|
+
parsed = parse_parameter(code, subparameter, game_type)
|
|
216
|
+
next if parsed.nil?
|
|
216
217
|
|
|
217
|
-
|
|
218
|
+
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
|
|
219
|
+
!maps_translation_map.include?(parsed)
|
|
218
220
|
|
|
219
|
-
|
|
221
|
+
maps_lines.add(parsed)
|
|
222
|
+
end
|
|
223
|
+
elsif parameters[0].is_a?(String)
|
|
224
|
+
parameter = parameters[0].strip
|
|
225
|
+
next if parameter.empty?
|
|
220
226
|
|
|
221
|
-
|
|
227
|
+
parsed = parse_parameter(code, parameter, game_type)
|
|
228
|
+
next if parsed.nil?
|
|
222
229
|
|
|
223
|
-
|
|
230
|
+
parsed = parsed.gsub(/\r?\n/, '\#')
|
|
224
231
|
|
|
225
|
-
|
|
226
|
-
|
|
232
|
+
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
|
|
233
|
+
!maps_translation_map.include?(parsed)
|
|
227
234
|
|
|
228
|
-
|
|
229
|
-
end
|
|
230
|
-
end
|
|
235
|
+
maps_lines.add(parsed)
|
|
231
236
|
end
|
|
232
237
|
end
|
|
233
238
|
end
|
|
@@ -239,7 +244,7 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
239
244
|
maps_original_content,
|
|
240
245
|
maps_translated_content,
|
|
241
246
|
names_original_content,
|
|
242
|
-
names_translated_content = if processing_type ==
|
|
247
|
+
names_translated_content = if processing_type == :append
|
|
243
248
|
[maps_translation_map.keys.join("\n"),
|
|
244
249
|
maps_translation_map.values.join("\n"),
|
|
245
250
|
names_translation_map.keys.join("\n"),
|
|
@@ -268,6 +273,12 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
268
273
|
end]
|
|
269
274
|
|
|
270
275
|
inner_processing_type = processing_type
|
|
276
|
+
# 401 - dialogue lines
|
|
277
|
+
# 405 - credits lines
|
|
278
|
+
# 102 - dialogue choices array
|
|
279
|
+
# 402 - one of the dialogue choices from the array
|
|
280
|
+
# 356 - system lines/special texts (do they even exist before mv?)
|
|
281
|
+
allowed_codes = [401, 405, 102, 402, 356].freeze
|
|
271
282
|
|
|
272
283
|
other_object_array_map.each do |filename, other_object_array|
|
|
273
284
|
processed_filename = File.basename(filename, '.*').downcase
|
|
@@ -275,7 +286,7 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
275
286
|
other_output_path = File.join(output_path, "#{processed_filename}.txt")
|
|
276
287
|
other_trans_output_path = File.join(output_path, "#{processed_filename}_trans.txt")
|
|
277
288
|
|
|
278
|
-
if processing_type ==
|
|
289
|
+
if processing_type == :default && File.exist?(other_trans_output_path)
|
|
279
290
|
puts "#{processed_filename}_trans.txt file already exists. If you want to forcefully re-read all files, use --force flag, or --append if you want append new text to already existing files."
|
|
280
291
|
next
|
|
281
292
|
end
|
|
@@ -283,38 +294,38 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
283
294
|
other_lines = IndexSet.new
|
|
284
295
|
other_translation_map = nil
|
|
285
296
|
|
|
286
|
-
if processing_type ==
|
|
297
|
+
if processing_type == :append
|
|
287
298
|
if File.exist?(other_trans_output_path)
|
|
288
|
-
inner_processing_type ==
|
|
299
|
+
inner_processing_type == :append
|
|
289
300
|
other_translation_map = Hash[File.readlines(other_output_path, chomp: true)
|
|
290
301
|
.zip(File.readlines(other_trans_output_path, chomp: true))]
|
|
291
302
|
else
|
|
292
303
|
puts "Files aren't already parsed. Continuing as if --append flag was omitted."
|
|
293
|
-
inner_processing_type =
|
|
304
|
+
inner_processing_type = :default
|
|
294
305
|
end
|
|
295
306
|
end
|
|
296
307
|
|
|
297
308
|
if !filename.start_with?(/Common|Troops/)
|
|
298
309
|
other_object_array.each do |object|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
310
|
+
next if object.nil?
|
|
311
|
+
|
|
312
|
+
name = object.name
|
|
313
|
+
nickname = object.nickname
|
|
314
|
+
description = object.description
|
|
315
|
+
note = object.note
|
|
303
316
|
|
|
304
317
|
[name, nickname, description, note].each do |variable|
|
|
305
318
|
next unless variable.is_a?(String)
|
|
306
319
|
|
|
307
320
|
variable = variable.strip
|
|
308
|
-
|
|
309
321
|
next if variable.empty?
|
|
310
322
|
|
|
311
323
|
parsed = parse_variable(variable, game_type)
|
|
312
|
-
|
|
313
324
|
next if parsed.nil?
|
|
314
325
|
|
|
315
326
|
parsed = parsed.gsub(/\r?\n/, '\#')
|
|
316
327
|
|
|
317
|
-
other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type ==
|
|
328
|
+
other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
|
|
318
329
|
!other_translation_map.include?(parsed)
|
|
319
330
|
|
|
320
331
|
other_lines.add(parsed)
|
|
@@ -322,72 +333,75 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
322
333
|
end
|
|
323
334
|
else
|
|
324
335
|
other_object_array.each do |object|
|
|
325
|
-
|
|
336
|
+
next if object.nil?
|
|
337
|
+
|
|
338
|
+
pages = object.pages
|
|
326
339
|
pages_length = pages.nil? ? 1 : pages.length
|
|
327
340
|
|
|
328
341
|
(0..pages_length).each do |i|
|
|
329
|
-
list = pages.nil? ? object.
|
|
342
|
+
list = pages.nil? ? object.list : pages[i].instance_variable_get(:@list)
|
|
330
343
|
next if list.nil?
|
|
331
344
|
|
|
332
345
|
in_sequence = false
|
|
333
346
|
line = []
|
|
334
347
|
|
|
335
348
|
list.each do |item|
|
|
336
|
-
code = item.
|
|
337
|
-
parameters = item.instance_variable_get(:@parameters)
|
|
349
|
+
code = item.code
|
|
338
350
|
|
|
339
|
-
|
|
340
|
-
if
|
|
341
|
-
|
|
351
|
+
unless allowed_codes.include?(code)
|
|
352
|
+
if in_sequence
|
|
353
|
+
joined = line.join('\#').strip
|
|
354
|
+
|
|
355
|
+
other_translation_map.insert_at_index(other_lines.length, joined, '') if inner_processing_type == :append &&
|
|
356
|
+
!other_translation_map.include?(joined)
|
|
342
357
|
|
|
343
|
-
|
|
344
|
-
line.push(parameter.gsub(/\r?\n/, '\#'))
|
|
345
|
-
else
|
|
346
|
-
if in_sequence
|
|
347
|
-
joined = line.join('\#').strip
|
|
358
|
+
other_lines.add(joined)
|
|
348
359
|
|
|
349
|
-
|
|
350
|
-
|
|
360
|
+
line.clear
|
|
361
|
+
in_sequence = false
|
|
362
|
+
end
|
|
363
|
+
next
|
|
364
|
+
end
|
|
351
365
|
|
|
352
|
-
|
|
366
|
+
parameters = item.parameters
|
|
353
367
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
end
|
|
368
|
+
if [401, 405].include?(code)
|
|
369
|
+
next unless parameters[0].is_a?(String) && !parameters[0].empty?
|
|
357
370
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
371
|
+
in_sequence = true
|
|
372
|
+
line.push(parameters[0].gsub(/\r?\n/, '\#'))
|
|
373
|
+
elsif parameters[0].is_a?(Array)
|
|
374
|
+
parameters[0].each do |subparameter|
|
|
375
|
+
next unless subparameter.is_a?(String)
|
|
363
376
|
|
|
364
|
-
|
|
377
|
+
subparameter = subparameter.strip
|
|
378
|
+
next if subparameter.empty?
|
|
365
379
|
|
|
366
|
-
|
|
380
|
+
other_translation_map.insert_at_index(other_lines.length, subparameter, '') if inner_processing_type == :append &&
|
|
381
|
+
!other_translation_map.include?(subparameter)
|
|
367
382
|
|
|
368
|
-
|
|
369
|
-
|
|
383
|
+
other_lines.add(subparameter)
|
|
384
|
+
end
|
|
385
|
+
elsif parameters[0].is_a?(String)
|
|
386
|
+
parameter = parameters[0].strip
|
|
387
|
+
next if parameter.empty?
|
|
370
388
|
|
|
371
|
-
|
|
372
|
-
end
|
|
373
|
-
end
|
|
374
|
-
when 356
|
|
375
|
-
next unless parameter.is_a?(String)
|
|
389
|
+
parameter = parameter.gsub(/\r?\n/, '\#')
|
|
376
390
|
|
|
377
|
-
|
|
391
|
+
other_translation_map.insert_at_index(other_lines.length, parameter, '') if inner_processing_type == :append &&
|
|
392
|
+
!other_translation_map.include?(parameter)
|
|
378
393
|
|
|
379
|
-
|
|
394
|
+
other_lines.add(parameter)
|
|
395
|
+
elsif parameters[1].is_a?(String)
|
|
396
|
+
parameter = parameters[1].strip
|
|
397
|
+
next if parameter.empty?
|
|
380
398
|
|
|
381
|
-
|
|
399
|
+
parameter = parameter.gsub(/\r?\n/, '\#')
|
|
382
400
|
|
|
383
|
-
|
|
384
|
-
|
|
401
|
+
other_translation_map.insert_at_index(other_lines.length, parameter, '') if inner_processing_type == :append &&
|
|
402
|
+
!other_translation_map.include?(parameter)
|
|
385
403
|
|
|
386
|
-
|
|
387
|
-
else
|
|
388
|
-
nil
|
|
389
|
-
end
|
|
390
|
-
end
|
|
404
|
+
other_lines.add(parameter)
|
|
391
405
|
end
|
|
392
406
|
end
|
|
393
407
|
end
|
|
@@ -396,7 +410,7 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
396
410
|
|
|
397
411
|
puts "Parsed #{filename}" if logging
|
|
398
412
|
|
|
399
|
-
original_content, translated_content = if processing_type ==
|
|
413
|
+
original_content, translated_content = if processing_type == :append
|
|
400
414
|
[other_translation_map.keys.join("\n"),
|
|
401
415
|
other_translation_map.values.join("\n")]
|
|
402
416
|
else
|
|
@@ -413,7 +427,7 @@ end
|
|
|
413
427
|
def self.read_ini_title(ini_file_path)
|
|
414
428
|
file_lines = File.readlines(ini_file_path, chomp: true)
|
|
415
429
|
file_lines.each do |line|
|
|
416
|
-
if line.start_with?('title')
|
|
430
|
+
if line.downcase.start_with?('title')
|
|
417
431
|
parts = line.partition('=')
|
|
418
432
|
break parts[2].strip
|
|
419
433
|
end
|
|
@@ -432,7 +446,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
432
446
|
system_output_path = File.join(output_path, "#{system_basename}.txt")
|
|
433
447
|
system_trans_output_path = File.join(output_path, "#{system_basename}_trans.txt")
|
|
434
448
|
|
|
435
|
-
if processing_type ==
|
|
449
|
+
if processing_type == :default && File.exist?(system_trans_output_path)
|
|
436
450
|
puts 'system_trans.txt file already exists. If you want to forcefully re-read all files, use --force flag, or --append if you want append new text to already existing files.'
|
|
437
451
|
return
|
|
438
452
|
end
|
|
@@ -442,22 +456,22 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
442
456
|
system_lines = IndexSet.new
|
|
443
457
|
system_translation_map = nil
|
|
444
458
|
|
|
445
|
-
if processing_type ==
|
|
459
|
+
if processing_type == :append
|
|
446
460
|
if File.exist?(system_trans_output_path)
|
|
447
461
|
system_translation_map = Hash[File.readlines(system_output_path, chomp: true)
|
|
448
462
|
.zip(File.readlines(system_trans_output_path, chomp: true))]
|
|
449
463
|
else
|
|
450
464
|
puts "Files aren't already parsed. Continuing as if --append flag was omitted."
|
|
451
|
-
processing_type =
|
|
465
|
+
processing_type = :default
|
|
452
466
|
end
|
|
453
467
|
end
|
|
454
468
|
|
|
455
|
-
elements = system_object.
|
|
456
|
-
skill_types = system_object.
|
|
457
|
-
weapon_types = system_object.
|
|
458
|
-
armor_types = system_object.
|
|
459
|
-
currency_unit = system_object.
|
|
460
|
-
terms = system_object.
|
|
469
|
+
elements = system_object.elements
|
|
470
|
+
skill_types = system_object.skill_types
|
|
471
|
+
weapon_types = system_object.weapon_types
|
|
472
|
+
armor_types = system_object.armor_types
|
|
473
|
+
currency_unit = system_object.currency_unit
|
|
474
|
+
terms = system_object.terms || system_object.words
|
|
461
475
|
|
|
462
476
|
[elements, skill_types, weapon_types, armor_types].each do |array|
|
|
463
477
|
next if array.nil?
|
|
@@ -466,10 +480,9 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
466
480
|
next unless string.is_a?(String)
|
|
467
481
|
|
|
468
482
|
string = string.strip
|
|
469
|
-
|
|
470
483
|
next if string.empty?
|
|
471
484
|
|
|
472
|
-
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type ==
|
|
485
|
+
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
|
|
473
486
|
!system_translation_map.include?(string)
|
|
474
487
|
|
|
475
488
|
system_lines.add(string)
|
|
@@ -480,7 +493,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
480
493
|
currency_unit = currency_unit.strip
|
|
481
494
|
|
|
482
495
|
unless currency_unit.empty?
|
|
483
|
-
system_translation_map.insert_at_index(system_lines.length, currency_unit, '') if processing_type ==
|
|
496
|
+
system_translation_map.insert_at_index(system_lines.length, currency_unit, '') if processing_type == :append &&
|
|
484
497
|
!system_translation_map.include?(currency_unit)
|
|
485
498
|
|
|
486
499
|
system_lines.add(currency_unit)
|
|
@@ -494,7 +507,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
494
507
|
value = value.strip
|
|
495
508
|
|
|
496
509
|
unless value.empty?
|
|
497
|
-
system_translation_map.insert_at_index(system_lines.length, value, '') if processing_type ==
|
|
510
|
+
system_translation_map.insert_at_index(system_lines.length, value, '') if processing_type == :append &&
|
|
498
511
|
!system_translation_map.include?(value)
|
|
499
512
|
|
|
500
513
|
system_lines.add(value)
|
|
@@ -507,10 +520,9 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
507
520
|
next unless string.is_a?(String)
|
|
508
521
|
|
|
509
522
|
string = string.strip
|
|
510
|
-
|
|
511
523
|
next if string.empty?
|
|
512
524
|
|
|
513
|
-
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type ==
|
|
525
|
+
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
|
|
514
526
|
!system_translation_map.include?(string)
|
|
515
527
|
|
|
516
528
|
system_lines.add(string)
|
|
@@ -519,17 +531,16 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
519
531
|
|
|
520
532
|
# Game title from System file and ini file may differ, but requesting user request to determine which line do they want is LAME
|
|
521
533
|
# So just throw that ini ass and continue
|
|
522
|
-
_game_title = system_object.instance_variable_get(:@game_title)
|
|
523
534
|
ini_game_title = read_ini_title(ini_file_path).strip
|
|
524
535
|
|
|
525
|
-
system_translation_map.insert_at_index(system_lines.length, ini_game_title, '') if processing_type ==
|
|
536
|
+
system_translation_map.insert_at_index(system_lines.length, ini_game_title, '') if processing_type == :append &&
|
|
526
537
|
!system_translation_map.include?(ini_game_title)
|
|
527
538
|
|
|
528
539
|
system_lines.add(ini_game_title)
|
|
529
540
|
|
|
530
541
|
puts "Parsed #{system_filename}" if logging
|
|
531
542
|
|
|
532
|
-
original_content, translated_content = if processing_type ==
|
|
543
|
+
original_content, translated_content = if processing_type == :append
|
|
533
544
|
[system_translation_map.keys.join("\n"),
|
|
534
545
|
system_translation_map.values.join("\n")]
|
|
535
546
|
else
|
|
@@ -553,7 +564,7 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
553
564
|
scripts_output_path = File.join(output_path, "#{scripts_basename}.txt")
|
|
554
565
|
scripts_trans_output_path = File.join(output_path, "#{scripts_basename}_trans.txt")
|
|
555
566
|
|
|
556
|
-
if processing_type ==
|
|
567
|
+
if processing_type == :default && File.exist?(scripts_trans_output_path)
|
|
557
568
|
puts 'scripts_trans.txt file already exists. If you want to forcefully re-read all files, use --force flag, or --append if you want append new text to already existing files.'
|
|
558
569
|
return
|
|
559
570
|
end
|
|
@@ -563,21 +574,37 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
563
574
|
scripts_lines = IndexSet.new
|
|
564
575
|
scripts_translation_map = nil
|
|
565
576
|
|
|
566
|
-
if processing_type ==
|
|
577
|
+
if processing_type == :append
|
|
567
578
|
if File.exist?(scripts_trans_output_path)
|
|
568
579
|
scripts_translation_map = Hash[File.readlines(scripts_output_path, chomp: true)
|
|
569
580
|
.zip(File.readlines(scripts_trans_output_path, chomp: true))]
|
|
570
581
|
else
|
|
571
582
|
puts "Files aren't already parsed. Continuing as if --append flag was omitted."
|
|
572
|
-
processing_type =
|
|
583
|
+
processing_type = :default
|
|
573
584
|
end
|
|
574
585
|
end
|
|
575
586
|
|
|
576
587
|
codes_content = []
|
|
577
588
|
|
|
589
|
+
# This code was fun before `that` game used Windows-1252 degree symbol
|
|
578
590
|
script_entries.each do |script|
|
|
579
591
|
code = Zlib::Inflate.inflate(script[2]).force_encoding('UTF-8')
|
|
580
|
-
|
|
592
|
+
# we're fucking cloning because of encoding issue
|
|
593
|
+
codes_content.push(code.clone)
|
|
594
|
+
|
|
595
|
+
# I figured how String#encode works - now everything is good
|
|
596
|
+
unless code.valid_encoding?
|
|
597
|
+
[Encoding::UTF_8, Encoding::WINDOWS_1252, Encoding::SHIFT_JIS].each do |encoding|
|
|
598
|
+
encoded = code.encode(code.encoding, encoding)
|
|
599
|
+
|
|
600
|
+
if encoded.valid_encoding?
|
|
601
|
+
code.force_encoding(encoding)
|
|
602
|
+
break
|
|
603
|
+
end
|
|
604
|
+
rescue Encoding::InvalidByteSequenceError
|
|
605
|
+
next
|
|
606
|
+
end
|
|
607
|
+
end
|
|
581
608
|
|
|
582
609
|
extract_quoted_strings(code).each do |string|
|
|
583
610
|
# Removes the U+3000 Japanese typographical space to check if string, when stripped, is truly empty
|
|
@@ -586,9 +613,12 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
586
613
|
next if string.empty?
|
|
587
614
|
|
|
588
615
|
# Maybe this mess will remove something that mustn't be removed, but it needs to be tested
|
|
589
|
-
|
|
590
616
|
next if string.start_with?(/([#!?$@]|(\.\/)?(Graphics|Data|Audio|CG|Movies|Save)\/)/) ||
|
|
617
|
+
string.match?(/^[^\p{L}]+$/) ||
|
|
591
618
|
string.match?(/^\d+$/) ||
|
|
619
|
+
string.match?(/%.*(\d|\+|\*)d\]?:?$/) ||
|
|
620
|
+
string.match?(/^\[(ON|OFF)\]$/) ||
|
|
621
|
+
string.match?(/^\[\]$/) ||
|
|
592
622
|
string.match?(/^(.)\1{2,}$/) ||
|
|
593
623
|
string.match?(/^(false|true)$/) ||
|
|
594
624
|
string.match?(/^[wr]b$/) ||
|
|
@@ -599,22 +629,17 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
599
629
|
string.match?(/^Tile.*[A-Z]$/) ||
|
|
600
630
|
string.match?(/^[a-zA-Z][a-z]+([A-Z][a-z]*)+$/) ||
|
|
601
631
|
string.match?(/^Cancel Action$|^Invert$|^End$|^Individual$|^Missed File$|^Bitmap$|^Audio$/) ||
|
|
602
|
-
string.match?(/\.(mp3|ogg|jpg|png|ini)$/) ||
|
|
632
|
+
string.match?(/\.(mp3|ogg|jpg|png|ini|txt)$/i) ||
|
|
603
633
|
string.match?(/\/(\d.*)?$/) ||
|
|
604
634
|
string.match?(/FILE$/) ||
|
|
605
635
|
string.match?(/#\{/) ||
|
|
606
|
-
string.match?(/(?<!\\)\\(
|
|
636
|
+
string.match?(/(?<!\\)\\(?![\\G#])/) ||
|
|
607
637
|
string.match?(/\+?=?=/) ||
|
|
608
638
|
string.match?(/[}{_<>]/) ||
|
|
609
639
|
string.match?(/r[vx]data/) ||
|
|
610
640
|
string.match?(/No such file or directory/) ||
|
|
611
641
|
string.match?(/level \*\*/) ||
|
|
612
|
-
string.match?(/Courier New/) ||
|
|
613
|
-
string.match?(/Comic Sans/) ||
|
|
614
|
-
string.match?(/Lucida/) ||
|
|
615
|
-
string.match?(/Verdana/) ||
|
|
616
|
-
string.match?(/Tahoma/) ||
|
|
617
|
-
string.match?(/Arial/) ||
|
|
642
|
+
string.match?(/Courier New|Comic Sans|Lucida|Verdana|Tahoma|Arial|Times New Roman/) ||
|
|
618
643
|
string.match?(/Player start location/) ||
|
|
619
644
|
string.match?(/Common event call has exceeded/) ||
|
|
620
645
|
string.match?(/se-/) ||
|
|
@@ -627,7 +652,7 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
627
652
|
string.match?(/Clear image/) ||
|
|
628
653
|
string.match?(/Can Collapse/)
|
|
629
654
|
|
|
630
|
-
scripts_translation_map.insert_at_index(scripts_lines.length, string, '') if processing_type ==
|
|
655
|
+
scripts_translation_map.insert_at_index(scripts_lines.length, string, '') if processing_type == :append &&
|
|
631
656
|
!scripts_translation_map.include?(string)
|
|
632
657
|
|
|
633
658
|
scripts_lines.add(string)
|
|
@@ -638,7 +663,7 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
638
663
|
|
|
639
664
|
File.binwrite(scripts_plain_output_path, codes_content.join("\n"))
|
|
640
665
|
|
|
641
|
-
original_content, translated_content = if processing_type ==
|
|
666
|
+
original_content, translated_content = if processing_type == :append
|
|
642
667
|
[scripts_translation_map.keys.join("\n"),
|
|
643
668
|
scripts_translation_map.values.join("\n")]
|
|
644
669
|
else
|
data/lib/write.rb
CHANGED
|
@@ -161,98 +161,89 @@ def self.write_map(original_files_paths, maps_path, output_path, shuffle_level,
|
|
|
161
161
|
maps_translation_map = Hash[maps_original_text.zip(maps_translated_text)].freeze
|
|
162
162
|
names_translation_map = Hash[names_original_text.zip(names_translated_text)].freeze
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
# 401 - dialogue lines
|
|
165
|
+
# 102 - dialogue choices array
|
|
166
|
+
# 402 - one of the dialogue choices from the array
|
|
167
|
+
# 356 - system lines/special texts (do they even exist before mv?)
|
|
168
|
+
allowed_codes = [401, 102, 402, 356].freeze
|
|
165
169
|
|
|
166
170
|
maps_object_map.each do |filename, object|
|
|
167
|
-
display_name = object.
|
|
171
|
+
display_name = object.display_name
|
|
168
172
|
display_name_gotten = names_translation_map[display_name]
|
|
169
|
-
object.
|
|
173
|
+
object.display_name = display_name_gotten unless display_name_gotten.nil?
|
|
170
174
|
|
|
171
|
-
events = object.
|
|
175
|
+
events = object.events
|
|
172
176
|
next if events.nil?
|
|
173
177
|
|
|
174
178
|
events.each_value do |event|
|
|
175
|
-
pages = event.
|
|
179
|
+
pages = event.pages
|
|
176
180
|
next if pages.nil?
|
|
177
181
|
|
|
178
182
|
pages.each do |page|
|
|
179
|
-
list = page.
|
|
183
|
+
list = page.list
|
|
180
184
|
next if list.nil?
|
|
181
185
|
|
|
182
186
|
in_sequence = false
|
|
183
187
|
line = []
|
|
184
188
|
item_indices = []
|
|
185
|
-
parameter_indices = []
|
|
186
189
|
|
|
187
190
|
list.each_with_index do |item, it|
|
|
188
|
-
code = item.
|
|
189
|
-
next unless allowed_codes.include?(code)
|
|
191
|
+
code = item.code
|
|
190
192
|
|
|
191
|
-
|
|
193
|
+
unless allowed_codes.include?(code)
|
|
194
|
+
if in_sequence
|
|
195
|
+
joined = line.join('\#').strip
|
|
196
|
+
translated = get_parameter_translated(401, joined, maps_translation_map, game_type)
|
|
192
197
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
next unless parameter.is_a?(String) && !parameter.empty?
|
|
198
|
+
unless translated.nil? || translated.empty?
|
|
199
|
+
split = translated.split('\#')
|
|
196
200
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
item_indices.push(it)
|
|
200
|
-
parameter_indices.push(pr)
|
|
201
|
-
else
|
|
202
|
-
if in_sequence
|
|
203
|
-
joined = line.join('\#').strip
|
|
204
|
-
translated = get_parameter_translated(401, joined, maps_translation_map, game_type)
|
|
201
|
+
split_length = split.length
|
|
202
|
+
line_length = line.length
|
|
205
203
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
(0..line.length - 1).each do |i|
|
|
210
|
-
list[item_indices[i]].instance_variable_get(:@parameters)[parameter_indices[i]] = split[i]
|
|
211
|
-
end
|
|
204
|
+
item_indices.each_with_index do |index, i|
|
|
205
|
+
list[index].parameters[0] = i < split_length ? split[i] : ''
|
|
212
206
|
end
|
|
213
207
|
|
|
214
|
-
|
|
215
|
-
item_indices.clear
|
|
216
|
-
parameter_indices.clear
|
|
217
|
-
in_sequence = false
|
|
208
|
+
list[item_indices.last].parameters[0] = split[line_length..].join("\n") if split_length > line_length
|
|
218
209
|
end
|
|
210
|
+
end
|
|
211
|
+
next
|
|
212
|
+
end
|
|
219
213
|
|
|
220
|
-
|
|
221
|
-
when 402
|
|
222
|
-
next unless parameter.is_a?(String)
|
|
223
|
-
|
|
224
|
-
parameter = parameter.strip
|
|
225
|
-
next if parameter.empty?
|
|
226
|
-
|
|
227
|
-
translated = get_parameter_translated(code, parameter, maps_translation_map, game_type)
|
|
228
|
-
parameters[pr] = translated unless translated.nil? || translated.empty?
|
|
229
|
-
when 102
|
|
230
|
-
next unless parameter.is_a?(Array)
|
|
231
|
-
|
|
232
|
-
parameter.each_with_index do |subparameter, sp|
|
|
233
|
-
next unless subparameter.is_a?(String)
|
|
214
|
+
parameters = item.parameters
|
|
234
215
|
|
|
235
|
-
|
|
236
|
-
|
|
216
|
+
if code == 401
|
|
217
|
+
next unless parameters[0].is_a?(String) && !parameters[0].empty?
|
|
237
218
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
219
|
+
in_sequence = true
|
|
220
|
+
line.push(parameters[0])
|
|
221
|
+
item_indices.push(it)
|
|
222
|
+
elsif parameters[0].is_a?(Array)
|
|
223
|
+
parameters[0].each_with_index do |subparameter, sp|
|
|
224
|
+
next unless subparameter.is_a?(String)
|
|
243
225
|
|
|
244
|
-
|
|
245
|
-
|
|
226
|
+
subparameter = subparameter.strip
|
|
227
|
+
next if subparameter.empty?
|
|
246
228
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
else
|
|
250
|
-
nil
|
|
251
|
-
end
|
|
229
|
+
translated = get_parameter_translated(code, subparameter, maps_translation_map, game_type)
|
|
230
|
+
parameters[0][sp] = translated unless translated.nil? || translated.empty?
|
|
252
231
|
end
|
|
232
|
+
elsif parameters[0].is_a?(String)
|
|
233
|
+
parameter = parameters[0].strip
|
|
234
|
+
next if parameter.empty?
|
|
235
|
+
|
|
236
|
+
translated = get_parameter_translated(code, parameter, maps_translation_map, game_type)
|
|
237
|
+
parameters[0] = translated unless translated.nil? || translated.empty?
|
|
238
|
+
elsif parameters[1].is_a?(String)
|
|
239
|
+
parameter = parameters[1].strip
|
|
240
|
+
next if parameter.empty?
|
|
241
|
+
|
|
242
|
+
translated = get_parameter_translated(code, parameter, maps_translation_map, game_type)
|
|
243
|
+
parameters[1] = translated unless translated.nil? || translated.empty?
|
|
253
244
|
end
|
|
254
245
|
|
|
255
|
-
item.
|
|
246
|
+
item.parameters = parameters
|
|
256
247
|
end
|
|
257
248
|
end
|
|
258
249
|
end
|
|
@@ -271,13 +262,15 @@ end
|
|
|
271
262
|
# @param [String] game_type
|
|
272
263
|
def self.write_other(original_files_paths, other_path, output_path, shuffle_level, logging, game_type)
|
|
273
264
|
other_object_array_map = Hash[original_files_paths.map do |filename|
|
|
274
|
-
basename
|
|
275
|
-
object = Marshal.load(File.binread(filename))
|
|
276
|
-
|
|
277
|
-
[basename, object]
|
|
265
|
+
[File.basename(filename), Marshal.load(File.binread(filename))]
|
|
278
266
|
end]
|
|
279
267
|
|
|
280
|
-
|
|
268
|
+
# 401 - dialogue lines
|
|
269
|
+
# 405 - credits lines
|
|
270
|
+
# 102 - dialogue choices array
|
|
271
|
+
# 402 - one of the dialogue choices from the array
|
|
272
|
+
# 356 - system lines/special texts (do they even exist before mv?)
|
|
273
|
+
allowed_codes = [401, 405, 102, 402, 356].freeze
|
|
281
274
|
|
|
282
275
|
other_object_array_map.each do |filename, other_object_array|
|
|
283
276
|
other_filename = File.basename(filename, '.*').downcase
|
|
@@ -299,111 +292,105 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
|
|
|
299
292
|
other_object_array.each do |object|
|
|
300
293
|
next if object.nil?
|
|
301
294
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
description = object.instance_variable_get(variables_symbols[2])
|
|
307
|
-
note = object.instance_variable_get(variables_symbols[3])
|
|
295
|
+
name = object.name
|
|
296
|
+
nickname = object.nickname
|
|
297
|
+
description = object.description
|
|
298
|
+
note = object.note
|
|
308
299
|
|
|
309
|
-
[
|
|
310
|
-
[variables_symbols[1], nickname],
|
|
311
|
-
[variables_symbols[2], description],
|
|
312
|
-
[variables_symbols[3], note]].each do |symbol, variable|
|
|
300
|
+
[name, nickname, description, note].each_with_index do |variable, i|
|
|
313
301
|
next unless variable.is_a?(String)
|
|
314
302
|
|
|
315
303
|
variable = variable.strip
|
|
316
304
|
next if variable.empty?
|
|
317
305
|
|
|
318
306
|
variable = variable.gsub(/\r\n/, "\n")
|
|
319
|
-
|
|
320
307
|
translated = get_variable_translated(variable, other_translation_map, game_type)
|
|
321
|
-
|
|
308
|
+
|
|
309
|
+
unless translated.nil? || translated.empty?
|
|
310
|
+
if i.zero?
|
|
311
|
+
object.name = translated
|
|
312
|
+
elsif i == 1
|
|
313
|
+
object.nickname = translated
|
|
314
|
+
elsif i == 2
|
|
315
|
+
object.description = translated
|
|
316
|
+
else
|
|
317
|
+
object.note = translated
|
|
318
|
+
end
|
|
319
|
+
end
|
|
322
320
|
end
|
|
323
321
|
end
|
|
324
322
|
else
|
|
325
323
|
other_object_array.each do |object|
|
|
326
|
-
|
|
324
|
+
next if object.nil?
|
|
325
|
+
|
|
326
|
+
pages = object.pages
|
|
327
327
|
pages_length = pages.nil? ? 1 : pages.length
|
|
328
328
|
|
|
329
329
|
(0..pages_length).each do |pg|
|
|
330
|
-
list = pages.nil? ? object.
|
|
330
|
+
list = pages.nil? ? object.list : pages[pg].instance_variable_get(:@list) # for some reason .list access doesn't work (wtf?)
|
|
331
331
|
next if list.nil?
|
|
332
332
|
|
|
333
333
|
in_sequence = false
|
|
334
334
|
line = []
|
|
335
335
|
item_indices = []
|
|
336
|
-
parameter_indices = []
|
|
337
336
|
|
|
338
337
|
list.each_with_index do |item, it|
|
|
339
|
-
code = item.
|
|
340
|
-
next unless allowed_codes.include?(code)
|
|
341
|
-
|
|
342
|
-
parameters = item.instance_variable_get(:@parameters)
|
|
343
|
-
|
|
344
|
-
parameters.each_with_index do |parameter, pr|
|
|
345
|
-
if [401, 405].include?(code)
|
|
346
|
-
next unless parameter.is_a?(String) && !parameter.empty?
|
|
347
|
-
|
|
348
|
-
in_sequence = true
|
|
349
|
-
line.push(parameter)
|
|
350
|
-
item_indices.push(it)
|
|
351
|
-
parameter_indices.push(pr)
|
|
352
|
-
else
|
|
353
|
-
if in_sequence
|
|
354
|
-
joined = line.join('\#').strip
|
|
355
|
-
translated = get_parameter_translated(401, joined, other_translation_map, game_type)
|
|
356
|
-
|
|
357
|
-
unless translated.nil? || translated.empty?
|
|
358
|
-
split = translated.split('\#')
|
|
359
|
-
|
|
360
|
-
(0..line.length - 1).each do |i|
|
|
361
|
-
list[item_indices[i]].instance_variable_get(:@parameters)[parameter_indices[i]] = split[i]
|
|
362
|
-
end
|
|
363
|
-
end
|
|
338
|
+
code = item.code
|
|
364
339
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
340
|
+
unless allowed_codes.include?(code)
|
|
341
|
+
if in_sequence
|
|
342
|
+
joined = line.join('\#').strip
|
|
343
|
+
translated = get_parameter_translated(401, joined, other_translation_map, game_type)
|
|
344
|
+
|
|
345
|
+
unless translated.nil? || translated.empty?
|
|
346
|
+
split = translated.split('\#')
|
|
370
347
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
next unless parameter.is_a?(String)
|
|
348
|
+
split_length = split.length
|
|
349
|
+
line_length = line.length
|
|
374
350
|
|
|
375
|
-
|
|
376
|
-
|
|
351
|
+
item_indices.each_with_index do |index, i|
|
|
352
|
+
list[index].parameters[0] = i < split_length ? split[i] : ''
|
|
353
|
+
end
|
|
377
354
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
355
|
+
list[item_indices.last].parameters[0] = split[line_length..].join("\n") if split_length > line_length
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
next
|
|
359
|
+
end
|
|
382
360
|
|
|
383
|
-
|
|
384
|
-
next unless subparameter.is_a?(String)
|
|
361
|
+
parameters = item.parameters
|
|
385
362
|
|
|
386
|
-
|
|
387
|
-
|
|
363
|
+
if [401, 405].include?(code)
|
|
364
|
+
next unless parameters[0].is_a?(String) && !parameters[0].empty?
|
|
388
365
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
366
|
+
in_sequence = true
|
|
367
|
+
line.push(parameters[0])
|
|
368
|
+
item_indices.push(it)
|
|
369
|
+
elsif parameters[0].is_a?(Array)
|
|
370
|
+
parameters[0].each_with_index do |subparameter, sp|
|
|
371
|
+
next unless subparameter.is_a?(String)
|
|
394
372
|
|
|
395
|
-
|
|
396
|
-
|
|
373
|
+
subparameter = subparameter.strip
|
|
374
|
+
next if subparameter.empty?
|
|
397
375
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
else
|
|
401
|
-
nil
|
|
402
|
-
end
|
|
376
|
+
translated = get_parameter_translated(code, subparameter, other_translation_map, game_type)
|
|
377
|
+
parameters[0][sp] = translated unless translated.nil? || translated.empty?
|
|
403
378
|
end
|
|
379
|
+
elsif parameters[0].is_a?(String)
|
|
380
|
+
parameter = parameters[0].strip
|
|
381
|
+
next if parameter.empty?
|
|
382
|
+
|
|
383
|
+
translated = get_parameter_translated(code, parameter, other_translation_map, game_type)
|
|
384
|
+
parameters[0] = translated unless translated.nil? || translated.empty?
|
|
385
|
+
elsif parameters[1].is_a?(String)
|
|
386
|
+
parameter = parameters[1].strip
|
|
387
|
+
next if parameter.empty?
|
|
388
|
+
|
|
389
|
+
translated = get_parameter_translated(code, parameter, other_translation_map, game_type)
|
|
390
|
+
parameters[1] = translated unless translated.nil? || translated.empty?
|
|
404
391
|
end
|
|
405
392
|
|
|
406
|
-
item.
|
|
393
|
+
item.parameters = parameters
|
|
407
394
|
end
|
|
408
395
|
end
|
|
409
396
|
end
|
|
@@ -420,7 +407,7 @@ end
|
|
|
420
407
|
def self.write_ini_title(ini_file_path, translated)
|
|
421
408
|
file_lines = File.readlines(ini_file_path, chomp: true)
|
|
422
409
|
title_line_index = file_lines.each_with_index do |line, i|
|
|
423
|
-
break i if line.start_with?('title')
|
|
410
|
+
break i if line.downcase.start_with?('title')
|
|
424
411
|
end
|
|
425
412
|
|
|
426
413
|
file_lines[title_line_index] = translated
|
|
@@ -451,14 +438,12 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
|
|
|
451
438
|
|
|
452
439
|
system_translation_map = Hash[system_original_text.zip(system_translated_text)].freeze
|
|
453
440
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
currency_unit = system_object.instance_variable_get(system_symbols[4])
|
|
461
|
-
terms = system_object.instance_variable_get(system_symbols[5]) || system_object.instance_variable_get(system_symbols[6])
|
|
441
|
+
elements = system_object.elements
|
|
442
|
+
skill_types = system_object.skill_types
|
|
443
|
+
weapon_types = system_object.weapon_types
|
|
444
|
+
armor_types = system_object.armor_types
|
|
445
|
+
currency_unit = system_object.currency_unit
|
|
446
|
+
terms = system_object.terms || system_object.words
|
|
462
447
|
|
|
463
448
|
[elements, skill_types, weapon_types, armor_types].each_with_index.each do |array, i|
|
|
464
449
|
next unless array.is_a?(Array)
|
|
@@ -471,11 +456,19 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
|
|
|
471
456
|
!translated.nil? && !translated.empty? ? translated : stripped
|
|
472
457
|
end
|
|
473
458
|
|
|
474
|
-
|
|
459
|
+
if i.zero?
|
|
460
|
+
system_object.elements = array
|
|
461
|
+
elsif i == 1
|
|
462
|
+
system_object.skill_types = array
|
|
463
|
+
elsif i == 2
|
|
464
|
+
system_object.weapon_types = array
|
|
465
|
+
else
|
|
466
|
+
system_object.armor_types = array
|
|
467
|
+
end
|
|
475
468
|
end
|
|
476
469
|
|
|
477
470
|
currency_unit_translated = system_translation_map[currency_unit]
|
|
478
|
-
system_object.
|
|
471
|
+
system_object.currency_unit = currency_unit_translated if currency_unit.is_a?(String) &&
|
|
479
472
|
(!currency_unit_translated.nil? && !currency_unit_translated.empty?)
|
|
480
473
|
|
|
481
474
|
terms.instance_variables.each do |variable|
|
|
@@ -500,12 +493,12 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
|
|
|
500
493
|
terms.instance_variable_set(variable, value)
|
|
501
494
|
end
|
|
502
495
|
|
|
503
|
-
system_object.
|
|
504
|
-
system_object.
|
|
505
|
-
system_object.
|
|
496
|
+
system_object.terms.nil? ?
|
|
497
|
+
system_object.words = terms :
|
|
498
|
+
system_object.terms = terms
|
|
506
499
|
|
|
507
500
|
game_title_translated = system_translated_text[-1]
|
|
508
|
-
system_object.
|
|
501
|
+
system_object.game_title = game_title_translated
|
|
509
502
|
write_ini_title(ini_file_path, game_title_translated)
|
|
510
503
|
|
|
511
504
|
puts "Written #{system_basename}" if logging
|
|
@@ -531,8 +524,24 @@ def self.write_scripts(scripts_file_path, other_path, output_path, logging)
|
|
|
531
524
|
# Shuffle can possibly break the game in scripts, so no shuffling
|
|
532
525
|
codes = []
|
|
533
526
|
|
|
527
|
+
# This code was fun before `that` game used Windows-1252 degree symbol
|
|
534
528
|
script_entries.each do |script|
|
|
535
|
-
code = Zlib::Inflate.inflate(script[2])
|
|
529
|
+
code = Zlib::Inflate.inflate(script[2])
|
|
530
|
+
code.force_encoding('UTF-8')
|
|
531
|
+
|
|
532
|
+
# I figured how String#encode works - now everything is good
|
|
533
|
+
unless code.valid_encoding?
|
|
534
|
+
[Encoding::UTF_8, Encoding::WINDOWS_1252, Encoding::SHIFT_JIS].each do |encoding|
|
|
535
|
+
encoded = code.encode(code.encoding, encoding)
|
|
536
|
+
|
|
537
|
+
if encoded.valid_encoding?
|
|
538
|
+
code.force_encoding(encoding)
|
|
539
|
+
break
|
|
540
|
+
end
|
|
541
|
+
rescue Encoding::InvalidByteSequenceError
|
|
542
|
+
next
|
|
543
|
+
end
|
|
544
|
+
end
|
|
536
545
|
|
|
537
546
|
# this shit finally works and requires NO further changes
|
|
538
547
|
string_array, index_array = extract_quoted_strings(code)
|
|
@@ -551,6 +560,6 @@ def self.write_scripts(scripts_file_path, other_path, output_path, logging)
|
|
|
551
560
|
|
|
552
561
|
puts "Written #{scripts_basename}" if logging
|
|
553
562
|
|
|
554
|
-
File.binwrite(File.join(output_path, 'scripts_plain.txt'), codes.join("\n"))
|
|
563
|
+
# File.binwrite(File.join(output_path, 'scripts_plain.txt'), codes.join("\n")) - debug line
|
|
555
564
|
File.binwrite(File.join(output_path, scripts_basename), Marshal.dump(script_entries))
|
|
556
565
|
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.7.1'
|
|
6
6
|
spec.authors = ['Howard Jeng', 'Andrew Kesterson', 'Solistra', 'Darkness9724', 'savannstm']
|
|
7
7
|
spec.email = ['savannstm@gmail.com']
|
|
8
8
|
spec.summary = 'Reads or writes RPG Maker XP/VX/VXAce game text to .txt files'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rvpacker-txt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.7.1
|
|
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-17 00:00:00.000000000 Z
|
|
16
16
|
dependencies: []
|
|
17
17
|
description:
|
|
18
18
|
email:
|