rvpacker-txt 1.5.0 → 1.5.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/lib/read.rb +118 -152
  3. data/lib/write.rb +10 -5
  4. data/rvpacker-txt.gemspec +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b69421e26d7a2a85ce60f482712d941e23946887a3e9b8640752dd4441b4cea
4
- data.tar.gz: 66fdd2d16bbd06ae1210105684805c9ec4a2beefef7f859568ae1faa37f6051e
3
+ metadata.gz: e3cdabd3e6867b3a5736a998345b2df35273565179c720c03acfb294bb121644
4
+ data.tar.gz: dd8ebfa554210a573d6aceef337ae4009759828a6fa53f5d19ad412c936165d0
5
5
  SHA512:
6
- metadata.gz: '068699415ee5fe5faa764a20f66f60b6d359610503aff909dda3b62b42f78c83abfe7e5049cc8aab03b7c4e5f3ff3e77a879ff43f6a059ad021bb97beed0d74d'
7
- data.tar.gz: e78c574fcf21bef8a4216f856ceeea67481281fe20047e78fd7a007c2b274e2e525a5a84a98c7bfcc1db8e4113c11b71837f6cd3f756002fde0c1ad4321811e3
6
+ metadata.gz: 6146633f8ac594f5db5cdc7b9fd1914c3e011e242531f943c2dbcad48c00ee8bda79f06511db125e588be4cc6c6869e3c9bfccc24a7c1820418d4cd7688f5c6d
7
+ data.tar.gz: db7a233da1abe10a24c0c5180a06f022f46cf07685e33e3a7081ac8dc5082210c14042f7605482c7d5ad99a4efabad870a01c55e0efac3f3ec8249aec998d888
data/lib/read.rb CHANGED
@@ -20,6 +20,7 @@ def self.extract_quoted_strings(string)
20
20
  quote_type = nil
21
21
  buffer = []
22
22
 
23
+ # I hope this calculates index correctly
23
24
  current_string_index = 0
24
25
  string.each_line do |line|
25
26
  stripped = line.strip
@@ -70,7 +71,9 @@ def self.parse_parameter(code, parameter, game_type)
70
71
  else
71
72
  nil
72
73
  end
73
- when 102, 356
74
+ when 102
75
+ # Implement some custom parsing
76
+ when 356
74
77
  # Implement some custom parsing
75
78
  else
76
79
  return nil
@@ -103,7 +106,7 @@ def self.read_map(maps_files, output_path, logging, game_type, processing_type)
103
106
  names_trans_output_path = File.join(output_path, 'names_trans.txt')
104
107
 
105
108
  if processing_type == 'default' && (File.exist?(maps_trans_output_path) || File.exist?(names_trans_output_path))
106
- puts 'maps.txt or maps_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.'
109
+ 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.'
107
110
  return
108
111
  end
109
112
 
@@ -111,38 +114,31 @@ def self.read_map(maps_files, output_path, logging, game_type, processing_type)
111
114
  [File.basename(filename), Marshal.load(File.binread(filename))]
112
115
  end]
113
116
 
114
- maps_lines = nil
117
+ maps_lines = IndexSet.new
118
+ names_lines = IndexSet.new
115
119
 
116
- maps_trans_map = nil
117
- names_trans_map = nil
120
+ maps_translation_map = nil
121
+ names_translation_map = nil
118
122
 
119
123
  if processing_type == 'append'
120
124
  if File.exist?(maps_trans_output_path)
121
- maps_trans_map = Hash[File.readlines(maps_output_path, chomp: true).zip(File.readlines(maps_trans_output_path, chomp: true))]
122
- names_trans_map = Hash[File.readlines(names_output_path, chomp: true).zip(File.readlines(names_trans_output_path, chomp: true))]
125
+ maps_translation_map = Hash[File.readlines(maps_output_path, chomp: true).zip(File.readlines(maps_trans_output_path, chomp: true))]
126
+ names_translation_map = Hash[File.readlines(names_output_path, chomp: true).zip(File.readlines(names_trans_output_path, chomp: true))]
123
127
  else
124
- puts 'Files aren\'t already parsed. Continuing as if --append flag was omitted.'
128
+ puts "Files aren't already parsed. Continuing as if --append flag was omitted."
125
129
  processing_type = 'default'
126
- maps_lines = [IndexSet.new, IndexSet.new]
127
130
  end
128
- else
129
- maps_lines = [IndexSet.new, IndexSet.new]
130
131
  end
131
132
 
132
- hash_index = 0
133
- names_hash_index = 0
134
-
135
133
  maps_object_map.each do |filename, object|
136
134
  display_name = object.instance_variable_get(:@display_name)
137
135
 
138
136
  if display_name.is_a?(String) && !display_name.empty?
139
- if processing_type == 'append'
140
- insert_at_index(names_trans_map, names_hash_index, display_name, '') unless names_trans_map.include?(display_name)
141
- else
142
- maps_lines[1].add(display_name)
137
+ if processing_type == 'append' && !names_translation_map.include?(display_name)
138
+ insert_at_index(names_translation_map, names_lines.length, display_name, '')
143
139
  end
144
140
 
145
- names_hash_index += 1
141
+ names_lines.add(display_name)
146
142
  end
147
143
 
148
144
  events = object.instance_variable_get(:@events)
@@ -175,16 +171,14 @@ def self.read_map(maps_files, output_path, logging, game_type, processing_type)
175
171
  if in_sequence
176
172
  joined = line.join('\#')
177
173
 
178
- if processing_type == 'append'
179
- insert_at_index(maps_trans_map, hash_index, joined, '') unless maps_trans_map.include?(joined)
180
- else
181
- maps_lines[0].add(joined)
174
+ if processing_type == 'append' && !maps_translation_map.include?(joined)
175
+ insert_at_index(maps_translation_map, maps_lines.length, joined, '')
182
176
  end
183
177
 
178
+ maps_lines.add(joined)
179
+
184
180
  line.clear
185
181
  in_sequence = false
186
-
187
- hash_index += 1
188
182
  end
189
183
 
190
184
  if code == 102 && parameter.is_a?(Array)
@@ -193,13 +187,11 @@ def self.read_map(maps_files, output_path, logging, game_type, processing_type)
193
187
  parsed = parse_parameter(code, subparameter, game_type)
194
188
 
195
189
  unless parsed.nil?
196
- if processing_type == 'append'
197
- insert_at_index(maps_trans_map, hash_index, parsed, '') unless maps_trans_map.include?(parsed)
198
- else
199
- maps_lines[0].add(parsed)
190
+ if processing_type == 'append' && !maps_translation_map.include?(parsed)
191
+ insert_at_index(maps_translation_map, maps_lines.length, parsed, '')
200
192
  end
201
193
 
202
- hash_index += 1
194
+ maps_lines.add(parsed)
203
195
  end
204
196
  end
205
197
  end
@@ -209,13 +201,11 @@ def self.read_map(maps_files, output_path, logging, game_type, processing_type)
209
201
  unless parsed.nil?
210
202
  subbed = parsed.gsub(/\r?\n/, '\#')
211
203
 
212
- if processing_type == 'append'
213
- insert_at_index(maps_trans_map, hash_index, parsed, '') unless maps_trans_map.include?(parsed)
214
- else
215
- maps_lines[0].add(subbed)
204
+ if processing_type == 'append' && !maps_translation_map.include?(parsed)
205
+ insert_at_index(maps_translation_map, maps_lines.length, parsed, '')
216
206
  end
217
207
 
218
- hash_index += 1
208
+ maps_lines.add(subbed)
219
209
  end
220
210
  end
221
211
  end
@@ -227,17 +217,25 @@ def self.read_map(maps_files, output_path, logging, game_type, processing_type)
227
217
  puts "Parsed #{filename}" if logging
228
218
  end
229
219
 
230
- if processing_type == 'append'
231
- File.binwrite(maps_output_path, maps_trans_map.keys.join("\n"))
232
- File.binwrite(maps_trans_output_path, maps_trans_map.values.join("\n"))
233
- File.binwrite(names_output_path, names_trans_map.keys.join("\n"))
234
- File.binwrite(names_trans_output_path, names_trans_map.values.join("\n"))
235
- else
236
- File.binwrite(maps_output_path, maps_lines[0].join("\n"))
237
- File.binwrite(maps_trans_output_path, "\n" * (maps_lines[0].empty? ? 0 : maps_lines[0].length - 1))
238
- File.binwrite(names_output_path, maps_lines[1].join("\n"))
239
- File.binwrite(names_trans_output_path, "\n" * (maps_lines[1].empty? ? 0 : maps_lines[1].length - 1))
240
- end
220
+ maps_original_content,
221
+ maps_translated_content,
222
+ names_original_content,
223
+ names_translated_content = if processing_type == 'append'
224
+ [maps_translation_map.keys.join("\n"),
225
+ maps_translation_map.values.join("\n"),
226
+ names_translation_map.keys.join("\n"),
227
+ names_translation_map.values.join("\n")]
228
+ else
229
+ [maps_lines.join("\n"),
230
+ "\n" * (maps_lines.empty? ? 0 : maps_lines.length - 1),
231
+ names_lines.join("\n"),
232
+ "\n" * (names_lines.empty? ? 0 : names_lines.length - 1)]
233
+ end
234
+
235
+ File.binwrite(maps_output_path, maps_original_content)
236
+ File.binwrite(maps_trans_output_path, maps_translated_content)
237
+ File.binwrite(names_output_path, names_original_content)
238
+ File.binwrite(names_trans_output_path, names_translated_content)
241
239
  end
242
240
 
243
241
  def self.read_other(other_files, output_path, logging, game_type, processing_type)
@@ -262,24 +260,20 @@ def self.read_other(other_files, output_path, logging, game_type, processing_typ
262
260
  next
263
261
  end
264
262
 
265
- other_lines = nil
266
- other_trans_map = nil
263
+ other_lines = IndexSet.new
264
+ other_translation_map = nil
267
265
 
268
266
  if processing_type == 'append'
269
267
  if File.exist?(other_trans_output_path)
270
268
  internal_processing_type == 'append'
271
- other_trans_map = Hash[File.readlines(other_output_path, chomp: true).zip(File.readlines(other_trans_output_path, chomp: true))]
269
+ other_translation_map = Hash[File.readlines(other_output_path, chomp: true).zip(File.readlines(other_trans_output_path, chomp: true))]
272
270
  else
273
- puts 'Files aren\'t already parsed. Continuing as if --append flag was omitted.'
271
+ puts "Files aren't already parsed. Continuing as if --append flag was omitted."
274
272
  internal_processing_type = 'default'
275
- other_lines = IndexSet.new
276
273
  end
277
- else
278
- other_lines = IndexSet.new
279
274
  end
280
275
 
281
276
  if !filename.start_with?(/Common|Troops/)
282
- hash_index = 0
283
277
  other_object_array.each do |object|
284
278
  name = object.instance_variable_get(:@name)
285
279
  nickname = object.instance_variable_get(:@nickname)
@@ -291,19 +285,16 @@ def self.read_other(other_files, output_path, logging, game_type, processing_typ
291
285
  parsed = parse_variable(variable, game_type)
292
286
 
293
287
  unless parsed.nil?
294
- if internal_processing_type == 'append'
295
- insert_at_index(other_trans_map, hash_index, parsed, '') unless other_trans_map.include?(parsed)
296
- else
297
- other_lines.add(parsed)
288
+ if internal_processing_type == 'append' && !other_translation_map.include?(parsed)
289
+ insert_at_index(other_translation_map, other_lines.length, parsed, '')
298
290
  end
299
291
 
300
- hash_index += 1
292
+ other_lines.add(parsed)
301
293
  end
302
294
  end
303
295
  end
304
296
  end
305
297
  else
306
- hash_index = 0
307
298
  other_object_array.each do |object|
308
299
  pages = object.instance_variable_get(:@pages)
309
300
  pages_length = pages.nil? ? 1 : pages.length
@@ -327,16 +318,14 @@ def self.read_other(other_files, output_path, logging, game_type, processing_typ
327
318
  if in_sequence
328
319
  joined = line.join('\#')
329
320
 
330
- if internal_processing_type == 'append'
331
- insert_at_index(other_trans_map, hash_index, joined, '') unless other_trans_map.include?(joined)
332
- else
333
- other_lines.add(joined)
321
+ if internal_processing_type == 'append' && !other_translation_map.include?(joined)
322
+ insert_at_index(other_translation_map, other_lines.length, joined, '')
334
323
  end
335
324
 
325
+ other_lines.add(joined)
326
+
336
327
  line.clear
337
328
  in_sequence = false
338
-
339
- hash_index += 1
340
329
  end
341
330
 
342
331
  case code
@@ -344,13 +333,11 @@ def self.read_other(other_files, output_path, logging, game_type, processing_typ
344
333
  if parameter.is_a?(Array)
345
334
  parameter.each do |subparameter|
346
335
  if subparameter.is_a?(String) && !subparameter.empty?
347
- if internal_processing_type == 'append'
348
- insert_at_index(other_trans_map, hash_index, subparameter, '') unless other_trans_map.include?(subparameter)
349
- else
350
- other_lines.add(subparameter)
336
+ if internal_processing_type == 'append' && !other_translation_map.include?(subparameter)
337
+ insert_at_index(other_translation_map, other_lines.length, subparameter, '')
351
338
  end
352
339
 
353
- hash_index += 1
340
+ other_lines.add(subparameter)
354
341
  end
355
342
  end
356
343
  end
@@ -359,12 +346,10 @@ def self.read_other(other_files, output_path, logging, game_type, processing_typ
359
346
  subbed = parameter.gsub(/\r?\n/, '\#')
360
347
 
361
348
  if internal_processing_type == 'append'
362
- insert_at_index(other_trans_map, hash_index, subbed, '')
363
- else
364
- other_lines.add(subbed)
349
+ insert_at_index(other_translation_map, other_lines.length, subbed, '')
365
350
  end
366
351
 
367
- hash_index += 1
352
+ other_lines.add(subbed)
368
353
  end
369
354
  else
370
355
  nil
@@ -378,13 +363,14 @@ def self.read_other(other_files, output_path, logging, game_type, processing_typ
378
363
 
379
364
  puts "Parsed #{filename}" if logging
380
365
 
381
- if processing_type == 'append'
382
- File.binwrite(other_output_path, other_trans_map.keys.join("\n"))
383
- File.binwrite(other_trans_output_path, other_trans_map.values.join("\n"))
384
- else
385
- File.binwrite(other_output_path, other_lines.join("\n"))
386
- File.binwrite(other_trans_output_path, "\n" * (other_lines.empty? ? 0 : other_lines.length - 1))
387
- end
366
+ original_content, translated_content = if processing_type == 'append'
367
+ [other_translation_map.keys.join("\n"), other_translation_map.values.join("\n")]
368
+ else
369
+ [other_lines.join("\n"), "\n" * (other_lines.empty? ? 0 : other_lines.length - 1)]
370
+ end
371
+
372
+ File.binwrite(other_output_path, original_content)
373
+ File.binwrite(other_trans_output_path, translated_content)
388
374
  end
389
375
  end
390
376
 
@@ -412,19 +398,16 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
412
398
 
413
399
  system_object = Marshal.load(File.binread(system_file_path))
414
400
 
415
- system_lines = nil
416
- system_trans_map = nil
401
+ system_lines = IndexSet.new
402
+ system_translation_map = nil
417
403
 
418
404
  if processing_type == 'append'
419
405
  if File.exist?(system_trans_output_path)
420
- system_trans_map = Hash[File.readlines(system_output_path, chomp: true).zip(File.readlines(system_trans_output_path, chomp: true))]
406
+ system_translation_map = Hash[File.readlines(system_output_path, chomp: true).zip(File.readlines(system_trans_output_path, chomp: true))]
421
407
  else
422
- puts 'Files aren\'t already parsed. Continuing as if --append flag was omitted.'
423
- system_lines = IndexSet.new
408
+ puts "Files aren't already parsed. Continuing as if --append flag was omitted."
424
409
  processing_type = 'default'
425
410
  end
426
- else
427
- system_lines = IndexSet.new
428
411
  end
429
412
 
430
413
  elements = system_object.instance_variable_get(:@elements)
@@ -435,32 +418,26 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
435
418
  terms = system_object.instance_variable_get(:@terms) || system_object.instance_variable_get(:@words)
436
419
  game_title = system_object.instance_variable_get(:@game_title)
437
420
 
438
- hash_index = 0
439
-
440
421
  [elements, skill_types, weapon_types, armor_types].each do |array|
441
422
  next if array.nil?
442
423
 
443
424
  array.each do |string|
444
425
  if string.is_a?(String) && !string.empty?
445
- if processing_type == 'append'
446
- insert_at_index(system_trans_map, hash_index, string, '') unless system_trans_map.include?(string)
447
- else
448
- system_lines.add(string)
426
+ if processing_type == 'append' && !system_translation_map.include?(string)
427
+ insert_at_index(system_translation_map, system_lines.length, string, '')
449
428
  end
450
429
 
451
- hash_index += 1
430
+ system_lines.add(string)
452
431
  end
453
432
  end
454
433
  end
455
434
 
456
435
  if currency_unit.is_a?(String) && !currency_unit.empty?
457
- if processing_type == 'append'
458
- insert_at_index(system_trans_map, hash_index, currency_unit, '') unless system_trans_map.include?(currency_unit)
459
- else
460
- system_lines.add(currency_unit)
436
+ if processing_type == 'append' && !system_translation_map.include?(currency_unit)
437
+ insert_at_index(system_translation_map, system_lines.length, currency_unit, '')
461
438
  end
462
439
 
463
- hash_index += 1
440
+ system_lines.add(currency_unit)
464
441
  end
465
442
 
466
443
  terms.instance_variables.each do |variable|
@@ -468,13 +445,11 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
468
445
 
469
446
  if value.is_a?(String)
470
447
  unless value.empty?
471
- if processing_type == 'append'
472
- insert_at_index(system_trans_map, hash_index, value, '') unless system_trans_map.include?(value)
473
- else
474
- system_lines.add(value)
448
+ if processing_type == 'append' && !system_translation_map.include?(value)
449
+ insert_at_index(system_translation_map, system_lines.length, value, '')
475
450
  end
476
451
 
477
- hash_index += 1
452
+ system_lines.add(value)
478
453
  end
479
454
 
480
455
  next
@@ -482,13 +457,11 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
482
457
 
483
458
  value.each do |string|
484
459
  if string.is_a?(String) && !string.empty?
485
- if processing_type == 'append'
486
- insert_at_index(system_trans_map, hash_index, string, '') unless system_trans_map.include?(string)
487
- else
488
- system_lines.add(string)
460
+ if processing_type == 'append' && !system_translation_map.include?(string)
461
+ insert_at_index(system_translation_map, system_lines.length, string, '')
489
462
  end
490
463
 
491
- hash_index += 1
464
+ system_lines.add(string)
492
465
  end
493
466
  end
494
467
  end
@@ -507,39 +480,37 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
507
480
  $wait_time = Time.now - wait_time_start
508
481
 
509
482
  if choice == 0
510
- if processing_type == 'append'
511
- insert_at_index(system_trans_map, hash_index, game_title, '') unless system_trans_map.include?(game_title)
512
- else
513
- system_lines.add(game_title)
483
+ if processing_type == 'append' && !system_translation_map.include?(game_title)
484
+ insert_at_index(system_translation_map, system_lines.length, game_title, '')
514
485
  end
486
+
487
+ system_lines.add(game_title)
515
488
  else
516
- if processing_type == 'append'
517
- insert_at_index(system_trans_map, hash_index, ini_game_title, '') unless system_trans_map.include?(ini_game_title)
518
- else
519
- system_lines.add(ini_game_title)
489
+ if processing_type == 'append' && !system_translation_map.include?(ini_game_title)
490
+ insert_at_index(system_translation_map, system_lines.length, ini_game_title, '')
520
491
  end
492
+
493
+ system_lines.add(ini_game_title)
521
494
  end
522
495
  else
523
- if processing_type == 'append'
524
- insert_at_index(system_trans_map, hash_index, ini_game_title, '') unless system_trans_map.include?(ini_game_title)
525
- else
526
- system_lines.add(ini_game_title)
496
+ if processing_type == 'append' && !system_translation_map.include?(ini_game_title)
497
+ insert_at_index(system_translation_map, system_lines.length, ini_game_title, '')
527
498
  end
528
- end
529
499
 
530
- hash_index += 1
500
+ system_lines.add(ini_game_title)
501
+ end
531
502
  end
532
503
 
533
504
  puts "Parsed #{system_filename}" if logging
534
505
 
535
- if processing_type == 'append'
536
- File.binwrite(system_output_path, system_trans_map.keys.join("\n"))
537
- File.binwrite(system_trans_output_path, system_trans_map.values.join("\n"))
538
- else
539
- File.binwrite(system_output_path, system_lines.join("\n"))
540
- File.binwrite(system_trans_output_path, "\n" * (system_lines.empty? ? 0 : system_lines.length - 1))
541
- end
506
+ original_content, translated_content = if processing_type == 'append'
507
+ [system_translation_map.keys.join("\n"), system_translation_map.values.join("\n")]
508
+ else
509
+ [system_lines.join("\n"), "\n" * (system_lines.empty? ? 0 : system_lines.length - 1)]
510
+ end
542
511
 
512
+ File.binwrite(system_output_path, original_content)
513
+ File.binwrite(system_trans_output_path, translated_content)
543
514
  end
544
515
 
545
516
  def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
@@ -557,23 +528,19 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
557
528
 
558
529
  script_entries = Marshal.load(File.binread(scripts_file_path))
559
530
 
560
- scripts_lines = nil
561
- scripts_trans_map = nil
531
+ scripts_lines = IndexSet.new
532
+ scripts_translation_map = nil
562
533
 
563
534
  if processing_type == 'append'
564
535
  if File.exist?(scripts_trans_output_path)
565
- scripts_trans_map = Hash[File.readlines(scripts_output_path, chomp: true).zip(File.readlines(scripts_trans_output_path, chomp: true))]
536
+ scripts_translation_map = Hash[File.readlines(scripts_output_path, chomp: true).zip(File.readlines(scripts_trans_output_path, chomp: true))]
566
537
  else
567
- puts 'Files aren\'t already parsed. Continuing as if --append flag was omitted.'
538
+ puts "Files aren't already parsed. Continuing as if --append flag was omitted."
568
539
  processing_type = 'default'
569
- scripts_lines = IndexSet.new
570
540
  end
571
- else
572
- scripts_lines = IndexSet.new
573
541
  end
574
542
 
575
543
  codes_content = []
576
- hash_index = 0
577
544
 
578
545
  script_entries.each do |script|
579
546
  code = Zlib::Inflate.inflate(script[2]).force_encoding('UTF-8')
@@ -628,13 +595,11 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
628
595
  string.match?(/Clear image/) ||
629
596
  string.match?(/Can Collapse/)
630
597
 
631
- if processing_type == 'append'
632
- insert_at_index(scripts_trans_map, hash_index, string, '') unless scripts_trans_map.include?(string)
633
- else
634
- scripts_lines.add(string)
598
+ if processing_type == 'append' && !scripts_translation_map.include?(string)
599
+ insert_at_index(scripts_translation_map, scripts_lines.length, string, '')
635
600
  end
636
601
 
637
- hash_index += 1
602
+ scripts_lines.add(string)
638
603
  end
639
604
  end
640
605
 
@@ -642,11 +607,12 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
642
607
 
643
608
  File.binwrite(scripts_plain_output_path, codes_content.join("\n"))
644
609
 
645
- if processing_type == 'append'
646
- File.binwrite(scripts_output_path, scripts_trans_map.keys.join("\n"))
647
- File.binwrite(scripts_trans_output_path, scripts_trans_map.values.join("\n"))
648
- else
649
- File.binwrite(scripts_output_path, scripts_lines.join("\n"))
650
- File.binwrite(scripts_trans_output_path, "\n" * (scripts_lines.empty? ? 0 : scripts_lines.length - 1))
651
- end
610
+ original_content, translated_content = if processing_type == 'append'
611
+ [scripts_translation_map.keys.join("\n"), scripts_translation_map.values.join("\n")]
612
+ else
613
+ [scripts_lines.join("\n"), "\n" * (scripts_lines.empty? ? 0 : scripts_lines.length - 1)]
614
+ end
615
+
616
+ File.binwrite(scripts_output_path, original_content)
617
+ File.binwrite(scripts_trans_output_path, translated_content)
652
618
  end
data/lib/write.rb CHANGED
@@ -11,6 +11,7 @@ def self.extract_quoted_strings(string)
11
11
  quote_type = nil
12
12
  buffer = []
13
13
 
14
+ # I hope this calculates index correctly
14
15
  current_string_index = 0
15
16
  string.each_line do |line|
16
17
  stripped = line.strip
@@ -51,9 +52,11 @@ def self.extract_quoted_strings(string)
51
52
  result
52
53
  end
53
54
 
54
- def shuffle_words_in_array(array)
55
- array.map do |string|
56
- string.split.shuffle.join(' ')
55
+ def shuffle_words(array)
56
+ array.each do |string|
57
+ words = string.scan(/\S+/)
58
+ shuffled_words = words.shuffle
59
+ string.gsub(/\S+/) { shuffled_words.pop || "" }
57
60
  end
58
61
  end
59
62
 
@@ -144,7 +147,7 @@ def self.get_parameter_translated(code, parameter, hashmap, game_type)
144
147
  lisa_start = nil
145
148
 
146
149
  case code
147
- when 401, 356, 405
150
+ when 401, 405
148
151
  case game_type
149
152
  when 'lisa'
150
153
  match = parameter.scan(/^(\\et\[[0-9]+\]|\\nbt)/)
@@ -154,7 +157,9 @@ def self.get_parameter_translated(code, parameter, hashmap, game_type)
154
157
  nil
155
158
  end
156
159
  when 102, 402
157
- nil
160
+ # Implement some custom parsing
161
+ when 356
162
+ # Implement some custom parsing
158
163
  else
159
164
  nil
160
165
  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.0'
5
+ spec.version = '1.5.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.5.0
4
+ version: 1.5.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-12 00:00:00.000000000 Z
15
+ date: 2024-07-13 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description:
18
18
  email: