rvpacker-txt 1.9.3 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c9a3067dbcaf3b73ae6f5585a85ab9cfa2df8e278a126912dfc38c2a6b8ef28
4
- data.tar.gz: 2677325c92499d90a253130e5e86710553543aec957ba5d91555fefcfdeff559
3
+ metadata.gz: 5d581405430f6d78e8269bc9f3310903bdc76e889d38c59a67ec6726a6927d33
4
+ data.tar.gz: 8492c8a320492902c0d8696dfcdf9bb1b2191fb6567c92e6086ee143ea6c25a5
5
5
  SHA512:
6
- metadata.gz: 940f7e419d6df9a86dd5b49f3433f033e0b2af6925b3cd6a1e8d9875251e07669771dfab323ab59b87cd9bbd9f6bb3265874487d2929b9f9a150e9cd0af86e3f
7
- data.tar.gz: 5a0156005aaab1ee3c443a862b5be0d2f1c75d410203317af9de038a86734ad5b073fa646d26afa8a065e9e2eac7c002e0c03ad671e91ae5309c215a95b38da6
6
+ metadata.gz: 3b1cdf8a790a950a7669206356542f41697d3c0389df088ba1482fdd4fa83051c15be5883520d5c26a12f0098563545abc4af3e36970e1c5760d63abda493177
7
+ data.tar.gz: 13a78b005d438e8c3d67543de90bb1c5fccb7bfd7845b7b81f10d7487fcad43d71a61588e494e53e3ce8a4a4f4804f92a95f42932a502ab9129c6b22ec5376d0
data/README.md CHANGED
@@ -37,9 +37,7 @@ OPTIONS:
37
37
  Example: --disable-processing=maps,other,system.
38
38
  [Allowed values: maps, other, system, scripts]
39
39
  --disable-custom-processing Disables built-in custom parsing/writing for some games.
40
- -r, --romanize When reading: If you parsing text from a Japanese game, that contains symbols like 「」,
41
- which are just the Japanese quotation marks, it automatically replaces these symbols by their roman equivalents.
42
- When writing: Use to correctly write files back if you have parsed them with --romanize flag.
40
+ This flag will automatically be used when writing if you parsed game text with it.
43
41
  -l, --log Enables logging.
44
42
  -h, --help Prints the program's help message or for the entered subcommand.
45
43
  ```
data/bin/rvpacker-txt CHANGED
@@ -21,9 +21,11 @@ def self.parse_options
21
21
  logging: false,
22
22
  force: false,
23
23
  append: false,
24
- shuffle_level: 0 }
24
+ shuffle_level: 0,
25
+ silent: false }
25
26
 
26
27
  options[:action] = ARGV[0]
28
+ options[:silent] = true unless ARGV.delete('--silent').nil?
27
29
 
28
30
  unless %w[read write].include?(options[:action])
29
31
  if %w[-h --help].include?(options[:action])
@@ -41,29 +43,22 @@ def self.parse_options
41
43
 
42
44
  banner,
43
45
  input_dir_description,
44
- output_dir_description,
45
- romanize_description =
46
+ output_dir_description, =
46
47
  case options[:action]
47
48
  when 'read'
48
49
  ["#{read_command_description}\n\nOPTIONS:\n",
49
50
  ['Input directory, containing folders "original" or "data" with original game files.'],
50
- ['Output directory, where a "translation" folder will be created, containing parsed .txt files with the text from the game.'],
51
- ['If you parsing text from a Japanese game, that contains symbols like 「」, which are just the Japanese quotation marks,',
52
- 'it automatically replaces these symbols by their roman equivalents.']]
51
+ ['Output directory, where a "translation" folder will be created, containing parsed .txt files with the text from the game.']]
53
52
  when 'write'
54
53
  ["#{write_command_description}\n\nOPTIONS:\n",
55
54
  ['Input directory, containing folders "original" or "data" and "translation" with original game files and .txt files with translation respectively.'],
56
- ['Output directory, where an "output" folder will be created, containing compiled RPG Maker files with your translation.'],
57
- ['Use to correctly write files back if you have parsed them with --romanize flag.']]
55
+ ['Output directory, where an "output" folder will be created, containing compiled RPG Maker files with your translation.']]
58
56
  else
59
57
  [banner_text,
60
58
  ['When reading: Input directory, containing folders "original" or "data" with original game files.',
61
59
  'When writing: Input directory, containing folders "original" or "data" and "translation" with original game files and .txt files with translation respectively.'],
62
60
  ['When reading: Output directory, where a "translation" folder will be created, containing parsed .txt files with the text from the game.',
63
- 'When writing: Output directory, where an "output" folder will be created, containing compiled RPG Maker files with your translation.'],
64
- ['When reading: If you parsing text from a Japanese game, that contains symbols like 「」,',
65
- 'which are just the Japanese quotation marks, it automatically replaces these symbols by their roman equivalents.',
66
- 'When writing: Use to correctly write files back if you have parsed them with --romanize flag.']]
61
+ 'When writing: Output directory, where an "output" folder will be created, containing compiled RPG Maker files with your translation.']]
67
62
  end
68
63
 
69
64
  OptionParser.new(banner) do |cmd|
@@ -90,16 +85,19 @@ def self.parse_options
90
85
  end
91
86
 
92
87
  cmd.on('--disable-custom-processing',
93
- 'Disables built-in custom parsing/writing for some games.') do
88
+ 'Disables built-in custom parsing/writing for some games.',
89
+ 'This flag will automatically be used when writing if you parsed game text with it.') do
94
90
  options[:disable_custom_processing] = true
95
91
  end
96
92
 
97
- cmd.on('-r', '--romanize',
98
- *romanize_description) do
99
- options[:romanize] = true
100
- end
101
-
102
93
  if options[:action] == 'read'
94
+ cmd.on('-r', '--romanize',
95
+ 'If you parsing text from a Japanese game, that contains symbols like 「」,',
96
+ 'which are just the Japanese quotation marks, it automatically replaces these symbols by their roman equivalents.',
97
+ 'This flag will automatically be used when writing if you parsed game text with it.') do
98
+ options[:romanize] = true
99
+ end
100
+
103
101
  cmd.on('-f', '--force',
104
102
  'Force rewrite all files. Cannot be used with --append.',
105
103
  'USE WITH CAUTION!') do
@@ -108,7 +106,7 @@ def self.parse_options
108
106
 
109
107
  cmd.on('-a', '--append',
110
108
  "When the rvpacker-txt or the game which files you've parsed receives an update, you probably should re-read game files with --append,",
111
- ' which will append any new text to your files without overwriting the progress.',
109
+ 'which will append any new text to your files without overwriting the progress.',
112
110
  'Cannot be used with --force.') do
113
111
  raise '--append cannot be used with --force.' if options[:force]
114
112
  options[:append] = true
@@ -124,11 +122,13 @@ def self.parse_options
124
122
  end
125
123
  end
126
124
 
127
- cmd.on('-l', '--log', 'Enables logging.') do
125
+ cmd.on('-l', '--log',
126
+ 'Enables logging.') do
128
127
  options[:logging] = true
129
128
  end
130
129
 
131
- cmd.on('-h', '--help', "Prints the program's help message or for the entered subcommand.") do
130
+ cmd.on('-h', '--help',
131
+ "Prints the program's help message or for the entered subcommand.") do
132
132
  puts cmd
133
133
  exit
134
134
  end
@@ -166,6 +166,8 @@ force = options[:force]
166
166
  append = options[:append]
167
167
  # @type [Boolean]
168
168
  romanize = options[:romanize]
169
+ # @type [Boolean]
170
+ silent = options[:silent]
169
171
 
170
172
  extensions = { xp: 'rxdata', vx: 'rvdata', ace: 'rvdata2' }
171
173
 
@@ -174,6 +176,7 @@ raise '"Data" or "original" directory not found within input directory.' unless
174
176
 
175
177
  maps_path = File.join(input_path, 'translation', 'maps')
176
178
  other_path = File.join(input_path, 'translation', 'other')
179
+ metadata_file_path = File.join(input_path, 'translation', '.rvpacker-txt-metadata.marshal')
177
180
 
178
181
  FileUtils.mkdir_p(maps_path)
179
182
  FileUtils.mkdir_p(other_path)
@@ -215,14 +218,16 @@ if options[:action] == 'read'
215
218
  require 'read'
216
219
 
217
220
  processing_mode = if force
218
- wait_time_start = Time.now
221
+ unless silent
222
+ wait_time_start = Time.now
219
223
 
220
- puts "WARNING! You're about to forcefully rewrite all your translation files, including _trans files.",
221
- "If you really want to do it, make sure you've made a backup of your _trans files, if you made some changes in them already.",
222
- "Input 'Y' to continue."
223
- exit unless $stdin.gets.chomp == 'Y'
224
+ puts "WARNING! You're about to forcefully rewrite all your translation files, including _trans files.",
225
+ "If you really want to do it, make sure you've made a backup of your _trans files, if you made some changes in them already.",
226
+ "Input 'Y' to continue."
227
+ exit unless $stdin.gets.chomp == 'Y'
224
228
 
225
- $wait_time += Time.now - wait_time_start
229
+ $wait_time += Time.now - wait_time_start
230
+ end
226
231
  :force
227
232
  elsif append
228
233
  :append
@@ -230,6 +235,8 @@ if options[:action] == 'read'
230
235
  :default
231
236
  end
232
237
 
238
+ File.binwrite(metadata_file_path, Marshal.dump({ romanize: romanize, disable_custom_processing: disable_custom_processing }))
239
+
233
240
  read_map(maps_files_paths, maps_path, romanize, logging, game_type, processing_mode) unless disable_processing[:maps]
234
241
  read_other(other_files_paths, other_path, romanize, logging, game_type, processing_mode) unless disable_processing[:other]
235
242
  read_system(system_file_path, ini_file_path, other_path, romanize, logging, processing_mode) unless disable_processing[:system]
@@ -240,6 +247,20 @@ else
240
247
  output_path = File.join(output_path, 'output')
241
248
  FileUtils.mkdir_p(output_path)
242
249
 
250
+ if File.exist?(metadata_file_path)
251
+ metadata = Marshal.load(File.binread(metadata_file_path))
252
+
253
+ if metadata[:romanize]
254
+ puts 'Enabling romanize according to the metadata from previous read.'
255
+ romanize = metadata[:romanize]
256
+ end
257
+
258
+ if metadata[:disable_custom_processing] && !game_type.nil?
259
+ puts 'Disabling custom parsing according to the metadata from previous read.'
260
+ game_type = nil
261
+ end
262
+ end
263
+
243
264
  write_map(maps_files_paths, maps_path, output_path, shuffle_level, romanize, logging, game_type) unless disable_processing[:maps]
244
265
  write_other(other_files_paths, other_path, output_path, shuffle_level, romanize, logging, game_type) unless disable_processing[:other]
245
266
  write_system(system_file_path, ini_file_path, other_path, output_path, shuffle_level, romanize, logging) unless disable_processing[:system]
data/lib/extensions.rb CHANGED
@@ -7,13 +7,13 @@ def self.romanize_string(string)
7
7
  case char
8
8
  when '。'
9
9
  string[i] = '.'
10
- when '、'
10
+ when '、', ','
11
11
  string[i] = ','
12
12
  when '・'
13
13
  string[i] = '·'
14
14
  when '゠'
15
15
  string[i] = '–'
16
- when '='
16
+ when '=', 'ー'
17
17
  string[i] = '—'
18
18
  when '…', '‥'
19
19
  string[i, 3] = '...'
@@ -41,6 +41,72 @@ def self.romanize_string(string)
41
41
  string[i] = ':'
42
42
  when '!'
43
43
  string[i] = '!'
44
+ when '※'
45
+ string[i] = '*'
46
+ when 'Ⅰ'
47
+ string[i] = 'I'
48
+ when 'ⅰ'
49
+ string[i] = 'i'
50
+ when 'Ⅱ'
51
+ string[i, 2] = 'II'
52
+ when 'ⅱ'
53
+ string[i, 2] = 'ii'
54
+ when 'Ⅲ'
55
+ string[i, 3] = 'III'
56
+ when 'ⅲ'
57
+ string[i, 3] = 'iii'
58
+ when 'Ⅳ'
59
+ string[i, 2] = 'IV'
60
+ when 'ⅳ'
61
+ string[i, 2] = 'iv'
62
+ when 'Ⅴ'
63
+ string[i] = 'V'
64
+ when 'ⅴ'
65
+ string[i] = 'v'
66
+ when 'Ⅵ'
67
+ string[i, 2] = 'VI'
68
+ when 'ⅵ'
69
+ string[i, 2] = 'vi'
70
+ when 'Ⅶ'
71
+ string[i, 3] = 'VII'
72
+ when 'ⅶ'
73
+ string[i, 3] = 'vii'
74
+ when 'Ⅷ'
75
+ string[i, 4] = 'VIII'
76
+ when 'ⅷ'
77
+ string[i, 4] = 'viii'
78
+ when 'Ⅸ'
79
+ string[i, 2] = 'IX'
80
+ when 'ⅸ'
81
+ string[i, 2] = 'ix'
82
+ when 'Ⅹ'
83
+ string[i] = 'X'
84
+ when 'ⅹ'
85
+ string[i] = 'x'
86
+ when 'Ⅺ'
87
+ string[i, 2] = 'XI'
88
+ when 'ⅺ'
89
+ string[i, 2] = 'xi'
90
+ when 'Ⅻ'
91
+ string[i, 3] = 'XII'
92
+ when 'ⅻ'
93
+ string[i, 3] = 'xii'
94
+ when 'Ⅼ'
95
+ string[i] = 'L'
96
+ when 'ⅼ'
97
+ string[i] = 'l'
98
+ when 'Ⅽ'
99
+ string[i] = 'C'
100
+ when 'ⅽ'
101
+ string[i] = 'c'
102
+ when 'Ⅾ'
103
+ string[i] = 'D'
104
+ when 'ⅾ'
105
+ string[i] = 'd'
106
+ when 'Ⅿ'
107
+ string[i] = 'M'
108
+ when 'ⅿ'
109
+ string[i] = 'm'
44
110
  else
45
111
  nil
46
112
  end
data/lib/read.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'zlib'
4
4
  require_relative 'extensions'
5
5
 
6
- STRING_IS_ONLY_SYMBOLS_RE = /^[.()+-:;\[\]^~%&!*\/→×??x%▼| ]+$/
6
+ STRING_IS_ONLY_SYMBOLS_RE = /^[.()+\-:;\[\]^~%&!№$@`*\/→×??x%▼|♥♪!:〜『』「」〽。…‥=゠、,【】[]{}()〔〕⦅⦆〘〙〈〉《》・\\#'"<>=_ー※▶ⅠⅰⅡⅱⅢⅲⅣⅳⅤⅴⅥⅵⅦⅶⅧⅷⅨⅸⅩⅹⅪⅺⅫⅻⅬⅼⅭⅽⅮⅾⅯⅿ\s]+$/
7
7
  APPEND_FLAG_OMIT_MSG = "Files aren't already parsed. Continuing as if --append flag was omitted."
8
8
 
9
9
  class Hash
@@ -76,41 +76,65 @@ end
76
76
  def self.parse_parameter(code, parameter, game_type)
77
77
  return nil if parameter.match?(STRING_IS_ONLY_SYMBOLS_RE)
78
78
 
79
+ ends_with_if = parameter[/ if\(.*\)$/]
80
+ parameter = parameter.chomp(ends_with_if) if ends_with_if
81
+
79
82
  unless game_type.nil?
80
- case code
81
- when 401, 405
82
- case game_type
83
- when 'lisa'
84
- match = parameter.scan(/^\\et\[[0-9]+\]/)
85
- match = parameter.scan(/^\\nbt/) if match.empty?
86
- parameter = parameter[match[0].length..] unless match.empty?
83
+ case game_type
84
+ when 'lisa'
85
+ case code
86
+ when 401, 405
87
+ prefix = parameter[/^(\\et\[[0-9]+\]|\\nbt)/]
88
+ parameter = parameter.sub(prefix, '') if prefix
89
+ when 102
90
+ # Implement some custom parsing
91
+ when 356
92
+ # Implement some custom parsing
87
93
  else
88
- nil
94
+ return nil
89
95
  end
90
- when 102
91
- # Implement some custom parsing
92
- when 356
93
- # Implement some custom parsing
96
+ # Implement cases for other games
94
97
  else
95
- return nil
98
+ nil
96
99
  end
100
+
97
101
  end
98
102
 
99
103
  parameter
100
104
  end
101
105
 
102
106
  # @param [String] variable
107
+ # @param [Integer] type
103
108
  # @param [String] _game_type
104
109
  # @return [String]
105
- def self.parse_variable(variable, _game_type)
106
- return nil if variable.match?(STRING_IS_ONLY_SYMBOLS_RE)
107
- variable = variable.gsub(/\r?\n/, '\#') if variable.count("\n").positive?
110
+ def self.parse_variable(variable, type, _game_type)
111
+ variable = variable.gsub(/\r?\n/, '\#')
112
+ return nil if variable.match?(STRING_IS_ONLY_SYMBOLS_RE) # for some reason it returns true if multi-line string contains carriage returns (wtf?)
113
+
114
+ only_html_elements = true
115
+
116
+ variable.split('\#').each do |line|
117
+ unless line.strip.match?(/^(#? ?<.*>\.?)$|^$/)
118
+ only_html_elements = false
119
+ break
120
+ end
121
+ end
122
+
123
+ return nil if only_html_elements
108
124
 
109
- return nil if variable.split('\#').all? { |line| line.strip.match?(/(^#? ?<.*>\.?$)|^$/) }
110
125
  return nil if variable.match?(/^[+-]?[0-9]*$/) ||
111
126
  variable.match?(/---/) ||
112
127
  variable.match?(/restrict eval/)
113
128
 
129
+ case type
130
+ when 0 # name
131
+ when 1 # nickname
132
+ when 2 # description
133
+ when 3 # note
134
+ else
135
+ nil
136
+ end
137
+
114
138
  variable
115
139
  end
116
140
 
@@ -326,13 +350,13 @@ def self.read_other(other_files_paths, output_path, romanize, logging, game_type
326
350
  description = object.description
327
351
  note = object.note
328
352
 
329
- [name, nickname, description, note].each do |variable|
353
+ [name, nickname, description, note].each_with_index do |variable, type|
330
354
  next unless variable.is_a?(String)
331
355
 
332
356
  variable = variable.strip
333
357
  next if variable.empty?
334
358
 
335
- parsed = parse_variable(variable, game_type)
359
+ parsed = parse_variable(variable, type, game_type)
336
360
  next if parsed.nil?
337
361
 
338
362
  parsed = parsed.gsub(/\r?\n/, '\#')
@@ -395,35 +419,44 @@ def self.read_other(other_files_paths, output_path, romanize, logging, game_type
395
419
  subparameter = subparameter.strip
396
420
  next if subparameter.empty?
397
421
 
398
- subparameter = romanize_string(subparameter) if romanize
422
+ parsed = parse_parameter(code, subparameter, game_type)
423
+ next if parsed.nil?
424
+
425
+ parsed = romanize_string(parsed) if romanize
399
426
 
400
- other_translation_map.insert_at_index(other_lines.length, subparameter, '') if inner_processing_type == :append &&
401
- !other_translation_map.include?(subparameter)
427
+ other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
428
+ !other_translation_map.include?(parsed)
402
429
 
403
- other_lines.add(subparameter)
430
+ other_lines.add(parsed)
404
431
  end
405
432
  elsif parameters[0].is_a?(String)
406
433
  parameter = parameters[0].strip
407
434
  next if parameter.empty?
408
435
 
409
- parameter = parameter.gsub(/\r?\n/, '\#')
410
- parameter = romanize_string(parameter) if romanize
436
+ parsed = parse_parameter(code, parameter, game_type)
437
+ next if parsed.nil?
411
438
 
412
- other_translation_map.insert_at_index(other_lines.length, parameter, '') if inner_processing_type == :append &&
413
- !other_translation_map.include?(parameter)
439
+ parsed = parsed.gsub(/\r?\n/, '\#')
440
+ parsed = romanize_string(parsed) if romanize
414
441
 
415
- other_lines.add(parameter)
442
+ other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
443
+ !other_translation_map.include?(parsed)
444
+
445
+ other_lines.add(parsed)
416
446
  elsif parameters[1].is_a?(String)
417
447
  parameter = parameters[1].strip
418
448
  next if parameter.empty?
419
449
 
420
- parameter = parameter.gsub(/\r?\n/, '\#')
421
- parameter = romanize_string(parameter) if romanize
450
+ parsed = parse_parameter(code, parameter, game_type)
451
+ next if parsed.nil?
452
+
453
+ parsed = parsed.gsub(/\r?\n/, '\#')
454
+ parsed = romanize_string(parsed) if romanize
422
455
 
423
- other_translation_map.insert_at_index(other_lines.length, parameter, '') if inner_processing_type == :append &&
424
- !other_translation_map.include?(parameter)
456
+ other_translation_map.insert_at_index(other_lines.length, parsed, '') if inner_processing_type == :append &&
457
+ !other_translation_map.include?(parsed)
425
458
 
426
- other_lines.add(parameter)
459
+ other_lines.add(parsed)
427
460
  end
428
461
  end
429
462
  end
@@ -653,7 +686,7 @@ def self.read_scripts(scripts_file_path, output_path, romanize, logging, process
653
686
  string.match?(/^(.)\1{2,}$/) ||
654
687
  string.match?(/^(false|true)$/) ||
655
688
  string.match?(/^[wr]b$/) ||
656
- string.match?(/^(?=.*\d)[A-Za-z0-9\-]+$/) ||
689
+ string.match?(/^(?=.*\d)[A-Za-z0-9-]+$/) ||
657
690
  string.match?(/^[a-z\-()\/ +'&]*$/) ||
658
691
  string.match?(/^[A-Za-z]+[+-]$/) ||
659
692
  string.match?(STRING_IS_ONLY_SYMBOLS_RE) ||
data/lib/write.rb CHANGED
@@ -74,52 +74,58 @@ end
74
74
  # @param [Hash{String => String}] hashmap Translation hashmap (as everything in Ruby passed by reference, this pass is free!)
75
75
  # @param [String] game_type
76
76
  def self.get_parameter_translated(code, parameter, hashmap, game_type)
77
+ ends_with_if = parameter[/ if\(.*\)$/]
78
+ parameter = parameter.chomp(ends_with_if) if ends_with_if
79
+
77
80
  unless game_type.nil?
78
- lisa_start = nil
79
-
80
- case code
81
- when 401, 405
82
- case game_type
83
- when 'lisa'
84
- match = parameter.scan(/^\\et\[[0-9]+\]/)
85
- match = parameter.scan(/^\\nbt/) if match.empty?
86
-
87
- unless match.empty?
88
- lisa_start = match[0]
89
- parameter = parameter.slice((match[0].length)..)
90
- end
81
+ case game_type
82
+ when 'lisa'
83
+ case code
84
+ when 401, 405
85
+ prefix = parameter[/^(\\et\[[0-9]+\]|\\nbt)/]
86
+ parameter = parameter.sub(prefix, '') if prefix
87
+
88
+ translated = hashmap[parameter]
89
+ return nil if translated.nil? || translated.empty?
90
+
91
+ translated = prefix + translated if prefix
92
+ return translated
93
+ when 102, 402
94
+ # Implement some custom parsing
95
+ when 356
96
+ # Implement some custom parsing
91
97
  else
92
98
  nil
93
99
  end
94
- when 102, 402
95
- # Implement some custom parsing
96
- when 356
97
- # Implement some custom parsing
98
- else
99
- nil
100
- end
101
-
102
- gotten = hashmap[parameter]
103
- return nil if gotten.nil?
104
-
105
- case game_type
106
- when 'lisa'
107
- gotten = lisa_start + gotten unless lisa_start.nil?
100
+ # Implement cases for other games
108
101
  else
109
102
  nil
110
103
  end
111
-
112
- return gotten
113
104
  end
114
105
 
115
- hashmap[parameter]
106
+ translated = hashmap[parameter]
107
+ return nil if translated.nil? || translated.empty?
108
+ translated += ends_with_if if ends_with_if
109
+ translated
116
110
  end
117
111
 
118
112
  # @param [String] variable
113
+ # # @param [Integer] type
119
114
  # @param [Hash{String => String}] hashmap Translation hashmap (as everything in Ruby passed by reference, this pass is free!)
120
115
  # @param [String] _game_type
121
116
  # @return [String]
122
- def self.get_variable_translated(variable, hashmap, _game_type)
117
+ def self.get_variable_translated(variable, type, hashmap, _game_type)
118
+ variable = variable.gsub(/\r?\n/, "\n")
119
+
120
+ case type
121
+ when 0 # name
122
+ when 1 # nickname
123
+ when 2 # description
124
+ when 3 # note
125
+ else
126
+ nil
127
+ end
128
+
123
129
  hashmap[variable]
124
130
  end
125
131
 
@@ -208,7 +214,9 @@ def self.write_map(original_files_paths, maps_path, output_path, shuffle_level,
208
214
  list[index].parameters[0] = i < split_length ? split[i] : ''
209
215
  end
210
216
 
211
- list[item_indices.last].parameters[0] = split[line_length..].join("\n") if split_length > line_length
217
+ if split_length > line_length
218
+ list[item_indices.last].parameters[0] = split[line_length..].join("\n")
219
+ end
212
220
  end
213
221
  end
214
222
  next
@@ -313,23 +321,21 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
313
321
  description = object.description
314
322
  note = object.note
315
323
 
316
- [name, nickname, description, note].each_with_index do |variable, i|
324
+ [name, nickname, description, note].each_with_index do |variable, type|
317
325
  next unless variable.is_a?(String)
318
326
 
319
327
  variable = variable.strip
320
328
  next if variable.empty?
321
329
 
322
- variable = variable.gsub(/\r\n/, "\n")
323
330
  variable = romanize_string(variable) if romanize
324
-
325
- translated = get_variable_translated(variable, other_translation_map, game_type)
331
+ translated = get_variable_translated(variable, type, other_translation_map, game_type)
326
332
 
327
333
  unless translated.nil? || translated.empty?
328
- if i.zero?
334
+ if type.zero?
329
335
  object.name = translated
330
- elsif i == 1
336
+ elsif type == 1
331
337
  object.nickname = translated if object.is_a?(RPG::Actor)
332
- elsif i == 2
338
+ elsif type == 2
333
339
  object.description = translated
334
340
  else
335
341
  object.note = translated
@@ -372,7 +378,9 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
372
378
  list[index].parameters[0] = i < split_length ? split[i] : ''
373
379
  end
374
380
 
375
- list[item_indices.last].parameters[0] = split[line_length..].join("\n") if split_length > line_length
381
+ if split_length > line_length
382
+ list[item_indices.last].parameters[0] = split[line_length..].join("\n")
383
+ end
376
384
  end
377
385
  end
378
386
  next
@@ -444,7 +452,7 @@ def self.write_ini_title(ini_file_path, translated)
444
452
  title_line_index = file_lines.each_with_index { |line, i| break i if line.downcase.start_with?('title') }
445
453
  return if title_line_index.is_a?(Array)
446
454
 
447
- file_lines[title_line_index] = translated
455
+ file_lines[title_line_index] = "title =#{translated}"
448
456
  File.binwrite(ini_file_path, file_lines.join("\n"))
449
457
  end
450
458
 
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.3'
5
+ spec.version = '1.10.0'
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.'
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.3
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Howard Jeng
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2024-07-25 00:00:00.000000000 Z
15
+ date: 2024-07-27 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description:
18
18
  email: