rvpacker-txt 1.9.0 → 1.9.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23fd06cbc05cc7bb17005d3cdd79cae36a36256007eade05eef6570e157bcf68
4
- data.tar.gz: b8e3e4f7088a6d9e1ef00818b4dc5a8684a51d49e76c40c8fe5076bc9d6a4cae
3
+ metadata.gz: 1c9a3067dbcaf3b73ae6f5585a85ab9cfa2df8e278a126912dfc38c2a6b8ef28
4
+ data.tar.gz: 2677325c92499d90a253130e5e86710553543aec957ba5d91555fefcfdeff559
5
5
  SHA512:
6
- metadata.gz: 580408d4e6e8ae3b0e2d615d522d9a6f78e223e82f8bc5a735e1bd3868f5d0e7a0d7372406c011a7e3f03c18def481b61d00747d6f18d5c354b54568bdf7ee45
7
- data.tar.gz: 6bb93fb3096248a63cba3147a0e9d0bc1b418d98cdae67479eacbbb6d255739c412d28fe3fa301a331b83dc98ababae7c0e850190a8241a4244e663b00043ef2
6
+ metadata.gz: 940f7e419d6df9a86dd5b49f3433f033e0b2af6925b3cd6a1e8d9875251e07669771dfab323ab59b87cd9bbd9f6bb3265874487d2929b9f9a150e9cd0af86e3f
7
+ data.tar.gz: 5a0156005aaab1ee3c443a862b5be0d2f1c75d410203317af9de038a86734ad5b073fa646d26afa8a065e9e2eac7c002e0c03ad671e91ae5309c215a95b38da6
data/bin/rvpacker-txt CHANGED
@@ -17,7 +17,7 @@ def self.parse_options
17
17
  scripts: false
18
18
  },
19
19
  disable_custom_processing: false,
20
- romanize_string: false,
20
+ romanize: false,
21
21
  logging: false,
22
22
  force: false,
23
23
  append: false,
@@ -54,7 +54,7 @@ def self.parse_options
54
54
  ["#{write_command_description}\n\nOPTIONS:\n",
55
55
  ['Input directory, containing folders "original" or "data" and "translation" with original game files and .txt files with translation respectively.'],
56
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.',]]
57
+ ['Use to correctly write files back if you have parsed them with --romanize flag.']]
58
58
  else
59
59
  [banner_text,
60
60
  ['When reading: Input directory, containing folders "original" or "data" with original game files.',
@@ -96,7 +96,7 @@ def self.parse_options
96
96
 
97
97
  cmd.on('-r', '--romanize',
98
98
  *romanize_description) do
99
- options[:romanize_string] = true
99
+ options[:romanize] = true
100
100
  end
101
101
 
102
102
  if options[:action] == 'read'
@@ -165,7 +165,7 @@ force = options[:force]
165
165
  # @type [Boolean]
166
166
  append = options[:append]
167
167
  # @type [Boolean]
168
- romanize = options[:romanize_string]
168
+ romanize = options[:romanize]
169
169
 
170
170
  extensions = { xp: 'rxdata', vx: 'rvdata', ace: 'rvdata2' }
171
171
 
@@ -214,7 +214,7 @@ $wait_time = 0
214
214
  if options[:action] == 'read'
215
215
  require 'read'
216
216
 
217
- processing_type = if force
217
+ processing_mode = if force
218
218
  wait_time_start = Time.now
219
219
 
220
220
  puts "WARNING! You're about to forcefully rewrite all your translation files, including _trans files.",
@@ -230,10 +230,10 @@ if options[:action] == 'read'
230
230
  :default
231
231
  end
232
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]
233
+ read_map(maps_files_paths, maps_path, romanize, logging, game_type, processing_mode) unless disable_processing[:maps]
234
+ read_other(other_files_paths, other_path, romanize, logging, game_type, processing_mode) unless disable_processing[:other]
235
+ read_system(system_file_path, ini_file_path, other_path, romanize, logging, processing_mode) unless disable_processing[:system]
236
+ read_scripts(scripts_file_path, other_path, romanize, logging, processing_mode) unless disable_processing[:scripts]
237
237
  else
238
238
  require 'write'
239
239
 
data/lib/classes.rb CHANGED
@@ -188,7 +188,9 @@ module RGSS
188
188
  end
189
189
  end
190
190
 
191
- classes_nested_array = [
191
+ # All used Ruby classes inside RPG Maker XP, VX, VX Ace games, that must be initialized to properly
192
+ # Marshal.load() files from these games
193
+ CLASSES_NESTED_ARRAY = [
192
194
  # RGSS data structures
193
195
  %i[RPG Actor],
194
196
  %i[RPG Animation],
@@ -239,7 +241,7 @@ module RGSS
239
241
  %i[RPG Weapon]
240
242
  ].freeze
241
243
 
242
- classes_nested_array.each do |symbol_array|
244
+ CLASSES_NESTED_ARRAY.each do |symbol_array|
243
245
  process(Object, *symbol_array)
244
246
  end
245
247
  end
data/lib/extensions.rb ADDED
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @param [String] string
4
+ # @return [String]
5
+ def self.romanize_string(string)
6
+ string.each_char.each_with_index do |char, i|
7
+ case char
8
+ when '。'
9
+ string[i] = '.'
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, 3] = '...'
20
+ when '「', '」', '〈', '〉'
21
+ string[i] = "'"
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
+ when ':'
41
+ string[i] = ':'
42
+ when '!'
43
+ string[i] = '!'
44
+ else
45
+ nil
46
+ end
47
+ end
48
+
49
+ string
50
+ end
data/lib/read.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'zlib'
4
+ require_relative 'extensions'
4
5
 
5
6
  STRING_IS_ONLY_SYMBOLS_RE = /^[.()+-:;\[\]^~%&!*\/→×??x%▼| ]+$/
6
7
  APPEND_FLAG_OMIT_MSG = "Files aren't already parsed. Continuing as if --append flag was omitted."
@@ -15,51 +16,6 @@ class Hash
15
16
  end
16
17
  end
17
18
 
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
-
63
19
  # @param [String] string A parsed scripts code string, containing raw Ruby code
64
20
  # @return [IndexSet<String>] Set of extracted strings
65
21
  def self.extract_quoted_strings(string)
@@ -158,19 +114,19 @@ def self.parse_variable(variable, _game_type)
158
114
  variable
159
115
  end
160
116
 
161
- # @param [Array<String>] maps_files_paths
162
- # @param [String] output_path
163
- # @param [Boolean] romanize
164
- # @param [Boolean] logging
165
- # @param [String] game_type
166
- # @param [String] processing_type
167
- def self.read_map(maps_files_paths, output_path, romanize, logging, game_type, processing_type)
117
+ # @param [Array<String>] maps_files_paths Array of paths to original maps files
118
+ # @param [String] output_path Path to output directory
119
+ # @param [Boolean] romanize Whether to romanize text
120
+ # @param [Boolean] logging Whether to log
121
+ # @param [String] game_type Game type for custom processing
122
+ # @param [String] processing_mode Whether to read in default mode, force rewrite or append new text to existing files
123
+ def self.read_map(maps_files_paths, output_path, romanize, logging, game_type, processing_mode)
168
124
  maps_output_path = File.join(output_path, 'maps.txt')
169
125
  names_output_path = File.join(output_path, 'names.txt')
170
126
  maps_trans_output_path = File.join(output_path, 'maps_trans.txt')
171
127
  names_trans_output_path = File.join(output_path, 'names_trans.txt')
172
128
 
173
- if processing_type == :default && (File.exist?(maps_trans_output_path) || File.exist?(names_trans_output_path))
129
+ if processing_mode == :default && (File.exist?(maps_trans_output_path) || File.exist?(names_trans_output_path))
174
130
  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.'
175
131
  return
176
132
  end
@@ -183,7 +139,7 @@ def self.read_map(maps_files_paths, output_path, romanize, logging, game_type, p
183
139
  maps_translation_map = nil
184
140
  names_translation_map = nil
185
141
 
186
- if processing_type == :append
142
+ if processing_mode == :append
187
143
  if File.exist?(maps_trans_output_path)
188
144
  maps_translation_map = Hash[File.readlines(maps_output_path, chomp: true)
189
145
  .zip(File.readlines(maps_trans_output_path, chomp: true))]
@@ -191,7 +147,7 @@ def self.read_map(maps_files_paths, output_path, romanize, logging, game_type, p
191
147
  .zip(File.readlines(names_trans_output_path, chomp: true))]
192
148
  else
193
149
  puts APPEND_FLAG_OMIT_MSG
194
- processing_type = :default
150
+ processing_mode = :default
195
151
  end
196
152
  end
197
153
 
@@ -209,7 +165,7 @@ def self.read_map(maps_files_paths, output_path, romanize, logging, game_type, p
209
165
  unless display_name.empty?
210
166
  display_name = romanize_string(display_name) if romanize
211
167
 
212
- names_translation_map.insert_at_index(names_lines.length, display_name, '') if processing_type == :append &&
168
+ names_translation_map.insert_at_index(names_lines.length, display_name, '') if processing_mode == :append &&
213
169
  !names_translation_map.include?(display_name)
214
170
 
215
171
  names_lines.add(display_name)
@@ -241,7 +197,7 @@ def self.read_map(maps_files_paths, output_path, romanize, logging, game_type, p
241
197
  unless parsed.nil?
242
198
  parsed = romanize_string(parsed) if romanize
243
199
 
244
- maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
200
+ maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_mode == :append &&
245
201
  !maps_translation_map.include?(parsed)
246
202
 
247
203
  maps_lines.add(parsed)
@@ -272,7 +228,7 @@ def self.read_map(maps_files_paths, output_path, romanize, logging, game_type, p
272
228
 
273
229
  parsed = romanize_string(parsed) if romanize
274
230
 
275
- maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
231
+ maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_mode == :append &&
276
232
  !maps_translation_map.include?(parsed)
277
233
 
278
234
  maps_lines.add(parsed)
@@ -287,7 +243,7 @@ def self.read_map(maps_files_paths, output_path, romanize, logging, game_type, p
287
243
  parsed = parsed.gsub(/\r?\n/, '\#')
288
244
  parsed = romanize_string(parsed) if romanize
289
245
 
290
- maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_type == :append &&
246
+ maps_translation_map.insert_at_index(maps_lines.length, parsed, '') if processing_mode == :append &&
291
247
  !maps_translation_map.include?(parsed)
292
248
 
293
249
  maps_lines.add(parsed)
@@ -302,7 +258,7 @@ def self.read_map(maps_files_paths, output_path, romanize, logging, game_type, p
302
258
  maps_original_content,
303
259
  maps_translated_content,
304
260
  names_original_content,
305
- names_translated_content = if processing_type == :append
261
+ names_translated_content = if processing_mode == :append
306
262
  [maps_translation_map.keys.join("\n"),
307
263
  maps_translation_map.values.join("\n"),
308
264
  names_translation_map.keys.join("\n"),
@@ -322,14 +278,14 @@ end
322
278
 
323
279
  # @param [Array<String>] other_files_paths
324
280
  # @param [String] output_path
325
- # @param [Boolean] romanize
326
- # @param [Boolean] logging
327
- # @param [String] game_type
328
- # @param [String] processing_type
329
- def self.read_other(other_files_paths, output_path, romanize, logging, game_type, processing_type)
281
+ # @param [Boolean] romanize Whether to romanize text
282
+ # @param [Boolean] logging Whether to log
283
+ # @param [String] game_type Game type for custom processing
284
+ # @param [String] processing_mode Whether to read in default mode, force rewrite or append new text to existing files
285
+ def self.read_other(other_files_paths, output_path, romanize, logging, game_type, processing_mode)
330
286
  other_object_array_map = Hash[other_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
331
287
 
332
- inner_processing_type = processing_type
288
+ inner_processing_type = processing_mode
333
289
  # 401 - dialogue lines
334
290
  # 405 - credits lines
335
291
  # 102 - dialogue choices array
@@ -342,7 +298,7 @@ def self.read_other(other_files_paths, output_path, romanize, logging, game_type
342
298
  other_output_path = File.join(output_path, "#{processed_filename}.txt")
343
299
  other_trans_output_path = File.join(output_path, "#{processed_filename}_trans.txt")
344
300
 
345
- if processing_type == :default && File.exist?(other_trans_output_path)
301
+ if processing_mode == :default && File.exist?(other_trans_output_path)
346
302
  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."
347
303
  next
348
304
  end
@@ -350,7 +306,7 @@ def self.read_other(other_files_paths, output_path, romanize, logging, game_type
350
306
  other_lines = IndexSet.new
351
307
  other_translation_map = nil
352
308
 
353
- if processing_type == :append
309
+ if processing_mode == :append
354
310
  if File.exist?(other_trans_output_path)
355
311
  inner_processing_type == :append
356
312
  other_translation_map = Hash[File.readlines(other_output_path, chomp: true)
@@ -476,7 +432,7 @@ def self.read_other(other_files_paths, output_path, romanize, logging, game_type
476
432
 
477
433
  puts "Parsed #{filename}" if logging
478
434
 
479
- original_content, translated_content = if processing_type == :append
435
+ original_content, translated_content = if processing_mode == :append
480
436
  [other_translation_map.keys.join("\n"),
481
437
  other_translation_map.values.join("\n")]
482
438
  else
@@ -503,17 +459,17 @@ end
503
459
  # @param [String] system_file_path
504
460
  # @param [String] ini_file_path
505
461
  # @param [String] output_path
506
- # @param [Boolean] romanize
507
- # @param [Boolean] logging
508
- # @param [String] processing_type
509
- def self.read_system(system_file_path, ini_file_path, output_path, romanize, logging, processing_type)
462
+ # @param [Boolean] romanize Whether to romanize text
463
+ # @param [Boolean] logging Whether to log
464
+ # @param [String] processing_mode Whether to read in default mode, force rewrite or append new text to existing files
465
+ def self.read_system(system_file_path, ini_file_path, output_path, romanize, logging, processing_mode)
510
466
  system_filename = File.basename(system_file_path)
511
467
  system_basename = File.basename(system_file_path, '.*').downcase
512
468
 
513
469
  system_output_path = File.join(output_path, "#{system_basename}.txt")
514
470
  system_trans_output_path = File.join(output_path, "#{system_basename}_trans.txt")
515
471
 
516
- if processing_type == :default && File.exist?(system_trans_output_path)
472
+ if processing_mode == :default && File.exist?(system_trans_output_path)
517
473
  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.'
518
474
  return
519
475
  end
@@ -523,13 +479,13 @@ def self.read_system(system_file_path, ini_file_path, output_path, romanize, log
523
479
  system_lines = IndexSet.new
524
480
  system_translation_map = nil
525
481
 
526
- if processing_type == :append
482
+ if processing_mode == :append
527
483
  if File.exist?(system_trans_output_path)
528
484
  system_translation_map = Hash[File.readlines(system_output_path, chomp: true)
529
485
  .zip(File.readlines(system_trans_output_path, chomp: true))]
530
486
  else
531
487
  puts APPEND_FLAG_OMIT_MSG
532
- processing_type = :default
488
+ processing_mode = :default
533
489
  end
534
490
  end
535
491
 
@@ -551,7 +507,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, romanize, log
551
507
 
552
508
  string = romanize_string(string) if romanize
553
509
 
554
- system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
510
+ system_translation_map.insert_at_index(system_lines.length, string, '') if processing_mode == :append &&
555
511
  !system_translation_map.include?(string)
556
512
 
557
513
  system_lines.add(string)
@@ -564,7 +520,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, romanize, log
564
520
  unless currency_unit.empty?
565
521
  currency_unit = romanize_string(currency_unit) if romanize
566
522
 
567
- system_translation_map.insert_at_index(system_lines.length, currency_unit, '') if processing_type == :append &&
523
+ system_translation_map.insert_at_index(system_lines.length, currency_unit, '') if processing_mode == :append &&
568
524
  !system_translation_map.include?(currency_unit)
569
525
 
570
526
  system_lines.add(currency_unit)
@@ -580,7 +536,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, romanize, log
580
536
  unless value.empty?
581
537
  value = romanize_string(string) if romanize
582
538
 
583
- system_translation_map.insert_at_index(system_lines.length, value, '') if processing_type == :append &&
539
+ system_translation_map.insert_at_index(system_lines.length, value, '') if processing_mode == :append &&
584
540
  !system_translation_map.include?(value)
585
541
 
586
542
  system_lines.add(value)
@@ -594,7 +550,7 @@ def self.read_system(system_file_path, ini_file_path, output_path, romanize, log
594
550
 
595
551
  string = romanize_string(string) if romanize
596
552
 
597
- system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
553
+ system_translation_map.insert_at_index(system_lines.length, string, '') if processing_mode == :append &&
598
554
  !system_translation_map.include?(string)
599
555
 
600
556
  system_lines.add(string)
@@ -607,14 +563,14 @@ def self.read_system(system_file_path, ini_file_path, output_path, romanize, log
607
563
  ini_game_title = read_ini_title(ini_file_path).strip
608
564
  ini_game_title = romanize_string(ini_game_title) if romanize
609
565
 
610
- system_translation_map.insert_at_index(system_lines.length, ini_game_title, '') if processing_type == :append &&
566
+ system_translation_map.insert_at_index(system_lines.length, ini_game_title, '') if processing_mode == :append &&
611
567
  !system_translation_map.include?(ini_game_title)
612
568
 
613
569
  system_lines.add(ini_game_title)
614
570
 
615
571
  puts "Parsed #{system_filename}" if logging
616
572
 
617
- original_content, translated_content = if processing_type == :append
573
+ original_content, translated_content = if processing_mode == :append
618
574
  [system_translation_map.keys.join("\n"),
619
575
  system_translation_map.values.join("\n")]
620
576
  else
@@ -628,10 +584,10 @@ end
628
584
 
629
585
  # @param [String] scripts_file_path
630
586
  # @param [String] output_path
631
- # @param [Boolean] romanize
632
- # @param [Boolean] logging
633
- # @param [String] processing_type
634
- def self.read_scripts(scripts_file_path, output_path, romanize, logging, processing_type)
587
+ # @param [Boolean] romanize Whether to romanize text
588
+ # @param [Boolean] logging Whether to log
589
+ # @param [String] processing_mode Whether to read in default mode, force rewrite or append new text to existing files
590
+ def self.read_scripts(scripts_file_path, output_path, romanize, logging, processing_mode)
635
591
  scripts_filename = File.basename(scripts_file_path)
636
592
  scripts_basename = File.basename(scripts_file_path, '.*').downcase
637
593
 
@@ -639,7 +595,7 @@ def self.read_scripts(scripts_file_path, output_path, romanize, logging, process
639
595
  scripts_output_path = File.join(output_path, "#{scripts_basename}.txt")
640
596
  scripts_trans_output_path = File.join(output_path, "#{scripts_basename}_trans.txt")
641
597
 
642
- if processing_type == :default && File.exist?(scripts_trans_output_path)
598
+ if processing_mode == :default && File.exist?(scripts_trans_output_path)
643
599
  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.'
644
600
  return
645
601
  end
@@ -649,13 +605,13 @@ def self.read_scripts(scripts_file_path, output_path, romanize, logging, process
649
605
  scripts_lines = IndexSet.new
650
606
  scripts_translation_map = nil
651
607
 
652
- if processing_type == :append
608
+ if processing_mode == :append
653
609
  if File.exist?(scripts_trans_output_path)
654
610
  scripts_translation_map = Hash[File.readlines(scripts_output_path, chomp: true)
655
611
  .zip(File.readlines(scripts_trans_output_path, chomp: true))]
656
612
  else
657
613
  puts APPEND_FLAG_OMIT_MSG
658
- processing_type = :default
614
+ processing_mode = :default
659
615
  end
660
616
  end
661
617
 
@@ -692,7 +648,7 @@ def self.read_scripts(scripts_file_path, output_path, romanize, logging, process
692
648
  string.match?(/^[^\p{L}]+$/) ||
693
649
  string.match?(/^\d+$/) ||
694
650
  string.match?(/%.*(\d|\+|\*)d\]?:?$/) ||
695
- string.match?(/^\[(ON|OFF)\]$/) ||
651
+ string.match?(/^\[((ON|OFF)|P[EMRT])\]$/) ||
696
652
  string.match?(/^\[\]$/) ||
697
653
  string.match?(/^(.)\1{2,}$/) ||
698
654
  string.match?(/^(false|true)$/) ||
@@ -704,6 +660,9 @@ def self.read_scripts(scripts_file_path, output_path, romanize, logging, process
704
660
  string.match?(/^Tile.*[A-Z]$/) ||
705
661
  string.match?(/^[a-zA-Z][a-z]+([A-Z][a-z]*)+$/) ||
706
662
  string.match?(/^Cancel Action$|^Invert$|^End$|^Individual$|^Missed File$|^Bitmap$|^Audio$/) ||
663
+ string.match?(/^(?=.*%d)(?=.*%m)(?=.*%Y).*$/) ||
664
+ string.match?(/^\\\\ALPHAC/) ||
665
+ string.match?(/^[A-Z]{,3}-[A-Z][A-Za-z]+/) ||
707
666
  string.match?(/\.(mp3|ogg|jpg|png|ini|txt)$/i) ||
708
667
  string.match?(/\/(\d.*)?$/) ||
709
668
  string.match?(/FILE$/) ||
@@ -729,7 +688,7 @@ def self.read_scripts(scripts_file_path, output_path, romanize, logging, process
729
688
 
730
689
  string = romanize_string(string) if romanize
731
690
 
732
- scripts_translation_map.insert_at_index(scripts_lines.length, string, '') if processing_type == :append &&
691
+ scripts_translation_map.insert_at_index(scripts_lines.length, string, '') if processing_mode == :append &&
733
692
  !scripts_translation_map.include?(string)
734
693
 
735
694
  scripts_lines.add(string)
@@ -740,7 +699,7 @@ def self.read_scripts(scripts_file_path, output_path, romanize, logging, process
740
699
 
741
700
  File.binwrite(scripts_plain_output_path, codes_content.join("\n"))
742
701
 
743
- original_content, translated_content = if processing_type == :append
702
+ original_content, translated_content = if processing_mode == :append
744
703
  [scripts_translation_map.keys.join("\n"),
745
704
  scripts_translation_map.values.join("\n")]
746
705
  else
data/lib/write.rb CHANGED
@@ -1,49 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'zlib'
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
4
+ require_relative 'extensions'
47
5
 
48
6
  # @param [String] string A parsed scripts code string, containing raw Ruby code
49
7
  # @return [Array<Array<String, Integer>>] Hash of parsed from code strings and their start indices
@@ -101,8 +59,8 @@ def self.extract_quoted_strings(string)
101
59
  [strings_array, indices_array]
102
60
  end
103
61
 
104
- # @param [Array<String>] array
105
- # @return [Array<String>]
62
+ # @param [Array<String>] array Array of strings
63
+ # @return [Array<String>] Array of shuffled strings
106
64
  def self.shuffle_words(array)
107
65
  array.each do |string|
108
66
  select_words_re = /\S+/
@@ -113,7 +71,7 @@ end
113
71
 
114
72
  # @param [Integer] code
115
73
  # @param [String] parameter
116
- # @param [Hash{String => String}] hashmap
74
+ # @param [Hash{String => String}] hashmap Translation hashmap (as everything in Ruby passed by reference, this pass is free!)
117
75
  # @param [String] game_type
118
76
  def self.get_parameter_translated(code, parameter, hashmap, game_type)
119
77
  unless game_type.nil?
@@ -158,20 +116,20 @@ def self.get_parameter_translated(code, parameter, hashmap, game_type)
158
116
  end
159
117
 
160
118
  # @param [String] variable
161
- # @param [Hash{String => String}] hashmap
119
+ # @param [Hash{String => String}] hashmap Translation hashmap (as everything in Ruby passed by reference, this pass is free!)
162
120
  # @param [String] _game_type
163
121
  # @return [String]
164
122
  def self.get_variable_translated(variable, hashmap, _game_type)
165
123
  hashmap[variable]
166
124
  end
167
125
 
168
- # @param [Array<String>] original_files_paths
169
- # @param [String] maps_path
170
- # @param [String] output_path
171
- # @param [Integer] shuffle_level
172
- # @param [Boolean] romanize
173
- # @param [Boolean] logging
174
- # @param [String] game_type
126
+ # @param [Array<String>] original_files_paths Array of paths to original files
127
+ # @param [String] maps_path Path to directory containing .txt maps files
128
+ # @param [String] output_path Path to output directory
129
+ # @param [Integer] shuffle_level Level of shuffle
130
+ # @param [Boolean] romanize If files were read with romanize, this option will romanize original game text to compare with parsed
131
+ # @param [Boolean] logging Whether to log
132
+ # @param [String] game_type Game type for custom parsing
175
133
  def self.write_map(original_files_paths, maps_path, output_path, shuffle_level, romanize, logging, game_type)
176
134
  maps_object_map = Hash[original_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
177
135
 
@@ -316,10 +274,10 @@ end
316
274
  # @param [Array<String>] original_files
317
275
  # @param [String] other_path
318
276
  # @param [String] output_path
319
- # @param [Integer] shuffle_level
320
- # @param [Boolean] romanize
321
- # @param [Boolean] logging
322
- # @param [String] game_type
277
+ # @param [Integer] shuffle_level Level of shuffle
278
+ # @param [Boolean] romanize If files were read with romanize, this option will romanize original game text to compare with parsed
279
+ # @param [Boolean] logging Whether to log
280
+ # @param [String] game_type Game type for custom parsing
323
281
  def self.write_other(original_files_paths, other_path, output_path, shuffle_level, romanize, logging, game_type)
324
282
  other_object_array_map = Hash[original_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
325
283
 
@@ -494,9 +452,9 @@ end
494
452
  # @param [String] ini_file_path
495
453
  # @param [String] other_path
496
454
  # @param [String] output_path
497
- # @param [Integer] shuffle_level
498
- # @param [Boolean] romanize
499
- # @param [Boolean] logging
455
+ # @param [Integer] shuffle_level Level of shuffle
456
+ # @param [Boolean] romanize If files were read with romanize, this option will romanize original game text to compare with parsed
457
+ # @param [Boolean] logging Whether to log
500
458
  def self.write_system(system_file_path, ini_file_path, other_path, output_path, shuffle_level, romanize, logging)
501
459
  system_basename = File.basename(system_file_path)
502
460
  system_object = Marshal.load(File.binread(system_file_path))
@@ -597,7 +555,7 @@ end
597
555
  # @param [String] scripts_file_path Path to Scripts.*data file
598
556
  # @param [String] other_path Path to translation/other directory containing .txt files
599
557
  # @param [String] output_path Path to the output directory
600
- # @param [Boolean] romanize
558
+ # @param [Boolean] romanize If files were read with romanize, this option will romanize original game text to compare with parsed
601
559
  # @param [Boolean] logging Whether to log
602
560
  def self.write_scripts(scripts_file_path, other_path, output_path, romanize, logging)
603
561
  scripts_basename = File.basename(scripts_file_path)
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.9.0'
5
+ spec.version = '1.9.3'
6
6
  spec.authors = ['Howard Jeng', 'Andrew Kesterson', 'Solistra', 'Darkness9724', 'savannstm']
7
7
  spec.email = ['savannstm@gmail.com']
8
8
  spec.summary = 'Reads RPG Maker XP/VX/VXAce game text to .txt files and writes them to their initial form.'
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
 
13
13
  spec.metadata = { 'homepage_uri' => 'https://github.com/savannstm/rvpacker-txt' }
14
14
 
15
- spec.files = %w[bin/rvpacker-txt lib/classes.rb lib/read.rb lib/write.rb Gemfile LICENSE README.md rvpacker-txt.gemspec]
15
+ spec.files = %w[bin/rvpacker-txt lib/classes.rb lib/read.rb lib/write.rb lib/extensions.rb Gemfile LICENSE README.md rvpacker-txt.gemspec]
16
16
  spec.executables = ['rvpacker-txt']
17
17
  spec.require_paths = ['lib']
18
18
  end
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.9.0
4
+ version: 1.9.3
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-24 00:00:00.000000000 Z
15
+ date: 2024-07-25 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description:
18
18
  email:
@@ -27,6 +27,7 @@ files:
27
27
  - README.md
28
28
  - bin/rvpacker-txt
29
29
  - lib/classes.rb
30
+ - lib/extensions.rb
30
31
  - lib/read.rb
31
32
  - lib/write.rb
32
33
  - rvpacker-txt.gemspec