rvpacker-txt 1.7.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/lib/read.rb +64 -64
- data/lib/write.rb +50 -56
- 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/lib/read.rb
CHANGED
|
@@ -199,42 +199,40 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
199
199
|
end
|
|
200
200
|
|
|
201
201
|
parameters = item.parameters
|
|
202
|
-
parameters.each do |parameter|
|
|
203
|
-
if code == 401
|
|
204
|
-
next unless parameter.is_a?(String) && !parameter.empty?
|
|
205
202
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
elsif code == 102 && parameter.is_a?(Array)
|
|
209
|
-
|
|
210
|
-
parameter.each do |subparameter|
|
|
211
|
-
next unless subparameter.is_a?(String)
|
|
212
|
-
|
|
213
|
-
subparameter = subparameter.strip
|
|
214
|
-
next if subparameter.empty?
|
|
203
|
+
if code == 401
|
|
204
|
+
next unless parameters[0].is_a?(String) && !parameters[0].empty?
|
|
215
205
|
|
|
216
|
-
|
|
217
|
-
|
|
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)
|
|
218
211
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
maps_lines.add(parsed)
|
|
223
|
-
end
|
|
224
|
-
elsif code == 356 && parameter.is_a?(String)
|
|
225
|
-
parameter = parameter.strip
|
|
226
|
-
next if parameter.empty?
|
|
212
|
+
subparameter = subparameter.strip
|
|
213
|
+
next if subparameter.empty?
|
|
227
214
|
|
|
228
|
-
parsed = parse_parameter(code,
|
|
215
|
+
parsed = parse_parameter(code, subparameter, game_type)
|
|
229
216
|
next if parsed.nil?
|
|
230
217
|
|
|
231
|
-
parsed = parsed.gsub(/\r?\n/, '\#')
|
|
232
|
-
|
|
233
218
|
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
|
|
234
219
|
!maps_translation_map.include?(parsed)
|
|
235
220
|
|
|
236
221
|
maps_lines.add(parsed)
|
|
237
222
|
end
|
|
223
|
+
elsif parameters[0].is_a?(String)
|
|
224
|
+
parameter = parameters[0].strip
|
|
225
|
+
next if parameter.empty?
|
|
226
|
+
|
|
227
|
+
parsed = parse_parameter(code, parameter, game_type)
|
|
228
|
+
next if parsed.nil?
|
|
229
|
+
|
|
230
|
+
parsed = parsed.gsub(/\r?\n/, '\#')
|
|
231
|
+
|
|
232
|
+
maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
|
|
233
|
+
!maps_translation_map.include?(parsed)
|
|
234
|
+
|
|
235
|
+
maps_lines.add(parsed)
|
|
238
236
|
end
|
|
239
237
|
end
|
|
240
238
|
end
|
|
@@ -366,45 +364,44 @@ def self.read_other(other_files_paths, output_path, logging, game_type, processi
|
|
|
366
364
|
end
|
|
367
365
|
|
|
368
366
|
parameters = item.parameters
|
|
369
|
-
parameters.each do |parameter|
|
|
370
|
-
if [401, 405].include?(code)
|
|
371
|
-
next unless parameter.is_a?(String) && !parameter.empty?
|
|
372
367
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
else
|
|
368
|
+
if [401, 405].include?(code)
|
|
369
|
+
next unless parameters[0].is_a?(String) && !parameters[0].empty?
|
|
376
370
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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)
|
|
382
376
|
|
|
383
|
-
|
|
384
|
-
|
|
377
|
+
subparameter = subparameter.strip
|
|
378
|
+
next if subparameter.empty?
|
|
379
|
+
|
|
380
|
+
other_translation_map.insert_at_index(other_lines.length, subparameter, '') if inner_processing_type == :append &&
|
|
381
|
+
!other_translation_map.include?(subparameter)
|
|
382
|
+
|
|
383
|
+
other_lines.add(subparameter)
|
|
384
|
+
end
|
|
385
|
+
elsif parameters[0].is_a?(String)
|
|
386
|
+
parameter = parameters[0].strip
|
|
387
|
+
next if parameter.empty?
|
|
385
388
|
|
|
386
|
-
|
|
387
|
-
!other_translation_map.include?(subparameter)
|
|
389
|
+
parameter = parameter.gsub(/\r?\n/, '\#')
|
|
388
390
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
end
|
|
392
|
-
when 356
|
|
393
|
-
next unless parameter.is_a?(String)
|
|
391
|
+
other_translation_map.insert_at_index(other_lines.length, parameter, '') if inner_processing_type == :append &&
|
|
392
|
+
!other_translation_map.include?(parameter)
|
|
394
393
|
|
|
395
|
-
|
|
396
|
-
|
|
394
|
+
other_lines.add(parameter)
|
|
395
|
+
elsif parameters[1].is_a?(String)
|
|
396
|
+
parameter = parameters[1].strip
|
|
397
|
+
next if parameter.empty?
|
|
397
398
|
|
|
398
|
-
|
|
399
|
+
parameter = parameter.gsub(/\r?\n/, '\#')
|
|
399
400
|
|
|
400
|
-
|
|
401
|
-
|
|
401
|
+
other_translation_map.insert_at_index(other_lines.length, parameter, '') if inner_processing_type == :append &&
|
|
402
|
+
!other_translation_map.include?(parameter)
|
|
402
403
|
|
|
403
|
-
|
|
404
|
-
else
|
|
405
|
-
nil
|
|
406
|
-
end
|
|
407
|
-
end
|
|
404
|
+
other_lines.add(parameter)
|
|
408
405
|
end
|
|
409
406
|
end
|
|
410
407
|
end
|
|
@@ -483,7 +480,6 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
483
480
|
next unless string.is_a?(String)
|
|
484
481
|
|
|
485
482
|
string = string.strip
|
|
486
|
-
|
|
487
483
|
next if string.empty?
|
|
488
484
|
|
|
489
485
|
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
|
|
@@ -524,7 +520,6 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
524
520
|
next unless string.is_a?(String)
|
|
525
521
|
|
|
526
522
|
string = string.strip
|
|
527
|
-
|
|
528
523
|
next if string.empty?
|
|
529
524
|
|
|
530
525
|
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
|
|
@@ -597,14 +592,19 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
597
592
|
# we're fucking cloning because of encoding issue
|
|
598
593
|
codes_content.push(code.clone)
|
|
599
594
|
|
|
595
|
+
# I figured how String#encode works - now everything is good
|
|
600
596
|
unless code.valid_encoding?
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
# fucking degree symbol from windows-1252 when trying to encode
|
|
604
|
-
code.force_encoding('Windows-1252')
|
|
605
|
-
end
|
|
597
|
+
[Encoding::UTF_8, Encoding::WINDOWS_1252, Encoding::SHIFT_JIS].each do |encoding|
|
|
598
|
+
encoded = code.encode(code.encoding, encoding)
|
|
606
599
|
|
|
607
|
-
|
|
600
|
+
if encoded.valid_encoding?
|
|
601
|
+
code.force_encoding(encoding)
|
|
602
|
+
break
|
|
603
|
+
end
|
|
604
|
+
rescue Encoding::InvalidByteSequenceError
|
|
605
|
+
next
|
|
606
|
+
end
|
|
607
|
+
end
|
|
608
608
|
|
|
609
609
|
extract_quoted_strings(code).each do |string|
|
|
610
610
|
# Removes the U+3000 Japanese typographical space to check if string, when stripped, is truly empty
|
|
@@ -614,7 +614,7 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
614
614
|
|
|
615
615
|
# Maybe this mess will remove something that mustn't be removed, but it needs to be tested
|
|
616
616
|
next if string.start_with?(/([#!?$@]|(\.\/)?(Graphics|Data|Audio|CG|Movies|Save)\/)/) ||
|
|
617
|
-
string.match(/^[^\p{L}]+$/) ||
|
|
617
|
+
string.match?(/^[^\p{L}]+$/) ||
|
|
618
618
|
string.match?(/^\d+$/) ||
|
|
619
619
|
string.match?(/%.*(\d|\+|\*)d\]?:?$/) ||
|
|
620
620
|
string.match?(/^\[(ON|OFF)\]$/) ||
|
data/lib/write.rb
CHANGED
|
@@ -219,25 +219,7 @@ def self.write_map(original_files_paths, maps_path, output_path, shuffle_level,
|
|
|
219
219
|
in_sequence = true
|
|
220
220
|
line.push(parameters[0])
|
|
221
221
|
item_indices.push(it)
|
|
222
|
-
elsif
|
|
223
|
-
parameter = parameters[0]
|
|
224
|
-
next unless parameter.is_a?(String)
|
|
225
|
-
|
|
226
|
-
parameter = parameter.strip
|
|
227
|
-
next if parameter.empty?
|
|
228
|
-
|
|
229
|
-
translated = get_parameter_translated(code, parameter, maps_translation_map, game_type)
|
|
230
|
-
parameters[0] = translated unless translated.nil? || translated.empty?
|
|
231
|
-
elsif code == 402
|
|
232
|
-
parameter = parameters[1]
|
|
233
|
-
next unless parameter.is_a?(String)
|
|
234
|
-
|
|
235
|
-
parameter = parameter.strip
|
|
236
|
-
next if parameter.empty?
|
|
237
|
-
|
|
238
|
-
translated = get_parameter_translated(code, parameter, maps_translation_map, game_type)
|
|
239
|
-
parameters[1] = translated unless translated.nil? || translated.empty?
|
|
240
|
-
elsif code == 102 && parameters[0].is_a?(Array)
|
|
222
|
+
elsif parameters[0].is_a?(Array)
|
|
241
223
|
parameters[0].each_with_index do |subparameter, sp|
|
|
242
224
|
next unless subparameter.is_a?(String)
|
|
243
225
|
|
|
@@ -247,6 +229,18 @@ def self.write_map(original_files_paths, maps_path, output_path, shuffle_level,
|
|
|
247
229
|
translated = get_parameter_translated(code, subparameter, maps_translation_map, game_type)
|
|
248
230
|
parameters[0][sp] = translated unless translated.nil? || translated.empty?
|
|
249
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?
|
|
250
244
|
end
|
|
251
245
|
|
|
252
246
|
item.parameters = parameters
|
|
@@ -268,10 +262,7 @@ end
|
|
|
268
262
|
# @param [String] game_type
|
|
269
263
|
def self.write_other(original_files_paths, other_path, output_path, shuffle_level, logging, game_type)
|
|
270
264
|
other_object_array_map = Hash[original_files_paths.map do |filename|
|
|
271
|
-
basename
|
|
272
|
-
object = Marshal.load(File.binread(filename))
|
|
273
|
-
|
|
274
|
-
[basename, object]
|
|
265
|
+
[File.basename(filename), Marshal.load(File.binread(filename))]
|
|
275
266
|
end]
|
|
276
267
|
|
|
277
268
|
# 401 - dialogue lines
|
|
@@ -313,17 +304,18 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
|
|
|
313
304
|
next if variable.empty?
|
|
314
305
|
|
|
315
306
|
variable = variable.gsub(/\r\n/, "\n")
|
|
316
|
-
|
|
317
307
|
translated = get_variable_translated(variable, other_translation_map, game_type)
|
|
318
308
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
|
327
319
|
end
|
|
328
320
|
end
|
|
329
321
|
end
|
|
@@ -374,25 +366,7 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
|
|
|
374
366
|
in_sequence = true
|
|
375
367
|
line.push(parameters[0])
|
|
376
368
|
item_indices.push(it)
|
|
377
|
-
elsif
|
|
378
|
-
parameter = parameters[0]
|
|
379
|
-
next unless parameter.is_a?(String)
|
|
380
|
-
|
|
381
|
-
parameter = parameter.strip
|
|
382
|
-
next if parameter.empty?
|
|
383
|
-
|
|
384
|
-
translated = get_parameter_translated(code, parameter, other_translation_map, game_type)
|
|
385
|
-
parameters[0] = translated unless translated.nil? || translated.empty?
|
|
386
|
-
elsif code == 402
|
|
387
|
-
parameter = parameters[1]
|
|
388
|
-
next unless parameter.is_a?(String)
|
|
389
|
-
|
|
390
|
-
parameter = parameter.strip
|
|
391
|
-
next if parameter.empty?
|
|
392
|
-
|
|
393
|
-
translated = get_parameter_translated(code, parameter, other_translation_map, game_type)
|
|
394
|
-
parameters[1] = translated unless translated.nil? || translated.empty?
|
|
395
|
-
elsif code == 102 && parameters[0].is_a?(Array)
|
|
369
|
+
elsif parameters[0].is_a?(Array)
|
|
396
370
|
parameters[0].each_with_index do |subparameter, sp|
|
|
397
371
|
next unless subparameter.is_a?(String)
|
|
398
372
|
|
|
@@ -402,6 +376,18 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
|
|
|
402
376
|
translated = get_parameter_translated(code, subparameter, other_translation_map, game_type)
|
|
403
377
|
parameters[0][sp] = translated unless translated.nil? || translated.empty?
|
|
404
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?
|
|
405
391
|
end
|
|
406
392
|
|
|
407
393
|
item.parameters = parameters
|
|
@@ -540,13 +526,21 @@ def self.write_scripts(scripts_file_path, other_path, output_path, logging)
|
|
|
540
526
|
|
|
541
527
|
# This code was fun before `that` game used Windows-1252 degree symbol
|
|
542
528
|
script_entries.each do |script|
|
|
543
|
-
code = Zlib::Inflate.inflate(script[2])
|
|
529
|
+
code = Zlib::Inflate.inflate(script[2])
|
|
530
|
+
code.force_encoding('UTF-8')
|
|
544
531
|
|
|
532
|
+
# I figured how String#encode works - now everything is good
|
|
545
533
|
unless code.valid_encoding?
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
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
|
|
550
544
|
end
|
|
551
545
|
|
|
552
546
|
# this shit finally works and requires NO further changes
|
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.7.
|
|
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.7.
|
|
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:
|