rvpacker-txt 1.7.0 → 1.8.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 +4 -4
- data/lib/classes.rb +7 -7
- data/lib/read.rb +65 -65
- data/lib/write.rb +92 -80
- 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: 2668e8728bac13732103b447b33f2a3e3b699f408e6e214255abb7a0fa4718c1
|
|
4
|
+
data.tar.gz: 9214274068189272243df485f52d0d53063316a749590e7f1e708f05613cfeca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c646537c1a24ee6341e3d2904c952644bd78054f17d624d21c69627b3972c9741a3989bf8b4ae711f8ebb592ddadfc1d52da3b52faacecd875f031fc1f839f3
|
|
7
|
+
data.tar.gz: 480402b6423c51245cb431f7fba7324f2895b79f5c3d13ab8f38614a1d3aad026e3f6eabe74b0d2a2992df3f695f81bf91a5f05c93c2566d3f480111a4bdcdf9
|
data/lib/classes.rb
CHANGED
|
@@ -134,31 +134,31 @@ module RPG
|
|
|
134
134
|
end
|
|
135
135
|
|
|
136
136
|
class Armor
|
|
137
|
-
attr_accessor :name, :
|
|
137
|
+
attr_accessor :name, :description, :note
|
|
138
138
|
end
|
|
139
139
|
|
|
140
140
|
class Class
|
|
141
|
-
attr_accessor :name, :
|
|
141
|
+
attr_accessor :name, :description, :note
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
class Enemy
|
|
145
|
-
attr_accessor :name, :
|
|
145
|
+
attr_accessor :name, :description, :note
|
|
146
146
|
end
|
|
147
147
|
|
|
148
148
|
class Item
|
|
149
|
-
attr_accessor :name, :
|
|
149
|
+
attr_accessor :name, :description, :note
|
|
150
150
|
end
|
|
151
151
|
|
|
152
152
|
class Skill
|
|
153
|
-
attr_accessor :name, :
|
|
153
|
+
attr_accessor :name, :description, :note
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
class State
|
|
157
|
-
attr_accessor :name, :
|
|
157
|
+
attr_accessor :name, :description, :note
|
|
158
158
|
end
|
|
159
159
|
|
|
160
160
|
class Weapon
|
|
161
|
-
attr_accessor :name, :
|
|
161
|
+
attr_accessor :name, :description, :note
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
class CommonEvent
|
data/lib/read.rb
CHANGED
|
@@ -13,7 +13,7 @@ class Hash
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
# @param [String] string A parsed scripts code string, containing raw Ruby code
|
|
16
|
-
# @return [IndexSet<String>]
|
|
16
|
+
# @return [IndexSet<String>] Set of extracted strings
|
|
17
17
|
def self.extract_quoted_strings(string)
|
|
18
18
|
result = IndexSet.new
|
|
19
19
|
|
|
@@ -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
|
@@ -5,7 +5,6 @@ require 'zlib'
|
|
|
5
5
|
# @param [String] string A parsed scripts code string, containing raw Ruby code
|
|
6
6
|
# @return [[Array<String>, Array<Integer>]] Hash of parsed from code strings and their start indices
|
|
7
7
|
def self.extract_quoted_strings(string)
|
|
8
|
-
# Hash of string-index key-value pairs
|
|
9
8
|
strings_array = []
|
|
10
9
|
indices_array = []
|
|
11
10
|
|
|
@@ -140,7 +139,7 @@ def self.write_map(original_files_paths, maps_path, output_path, shuffle_level,
|
|
|
140
139
|
line.gsub('\#', "\n").strip
|
|
141
140
|
end.freeze
|
|
142
141
|
|
|
143
|
-
maps_translated_text = File.readlines(File.join(maps_path, '
|
|
142
|
+
maps_translated_text = File.readlines(File.join(maps_path, 'maps_trans.txt'), encoding: 'UTF-8', chomp: true).map do |line|
|
|
144
143
|
line.gsub('\#', "\n").strip
|
|
145
144
|
end
|
|
146
145
|
|
|
@@ -175,11 +174,11 @@ def self.write_map(original_files_paths, maps_path, output_path, shuffle_level,
|
|
|
175
174
|
events = object.events
|
|
176
175
|
next if events.nil?
|
|
177
176
|
|
|
178
|
-
events.
|
|
177
|
+
events.each do |ev, event|
|
|
179
178
|
pages = event.pages
|
|
180
179
|
next if pages.nil?
|
|
181
180
|
|
|
182
|
-
pages.
|
|
181
|
+
pages.each_with_index do |page, pg|
|
|
183
182
|
list = page.list
|
|
184
183
|
next if list.nil?
|
|
185
184
|
|
|
@@ -219,25 +218,7 @@ def self.write_map(original_files_paths, maps_path, output_path, shuffle_level,
|
|
|
219
218
|
in_sequence = true
|
|
220
219
|
line.push(parameters[0])
|
|
221
220
|
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)
|
|
221
|
+
elsif parameters[0].is_a?(Array)
|
|
241
222
|
parameters[0].each_with_index do |subparameter, sp|
|
|
242
223
|
next unless subparameter.is_a?(String)
|
|
243
224
|
|
|
@@ -247,16 +228,36 @@ def self.write_map(original_files_paths, maps_path, output_path, shuffle_level,
|
|
|
247
228
|
translated = get_parameter_translated(code, subparameter, maps_translation_map, game_type)
|
|
248
229
|
parameters[0][sp] = translated unless translated.nil? || translated.empty?
|
|
249
230
|
end
|
|
231
|
+
elsif parameters[0].is_a?(String)
|
|
232
|
+
parameter = parameters[0].strip
|
|
233
|
+
next if parameter.empty?
|
|
234
|
+
|
|
235
|
+
translated = get_parameter_translated(code, parameter, maps_translation_map, game_type)
|
|
236
|
+
parameters[0] = translated unless translated.nil? || translated.empty?
|
|
237
|
+
elsif parameters[1].is_a?(String)
|
|
238
|
+
parameter = parameters[1].strip
|
|
239
|
+
next if parameter.empty?
|
|
240
|
+
|
|
241
|
+
translated = get_parameter_translated(code, parameter, maps_translation_map, game_type)
|
|
242
|
+
parameters[1] = translated unless translated.nil? || translated.empty?
|
|
250
243
|
end
|
|
251
244
|
|
|
252
245
|
item.parameters = parameters
|
|
246
|
+
list[it] = item
|
|
253
247
|
end
|
|
248
|
+
|
|
249
|
+
page.list = list
|
|
250
|
+
pages[pg] = page
|
|
254
251
|
end
|
|
252
|
+
|
|
253
|
+
event.pages = pages
|
|
254
|
+
events[ev] = event
|
|
255
255
|
end
|
|
256
256
|
|
|
257
|
-
|
|
257
|
+
object.events = events
|
|
258
258
|
|
|
259
259
|
File.binwrite(File.join(output_path, filename), Marshal.dump(object))
|
|
260
|
+
puts "Written #{filename}" if logging
|
|
260
261
|
end
|
|
261
262
|
end
|
|
262
263
|
|
|
@@ -268,10 +269,7 @@ end
|
|
|
268
269
|
# @param [String] game_type
|
|
269
270
|
def self.write_other(original_files_paths, other_path, output_path, shuffle_level, logging, game_type)
|
|
270
271
|
other_object_array_map = Hash[original_files_paths.map do |filename|
|
|
271
|
-
basename
|
|
272
|
-
object = Marshal.load(File.binread(filename))
|
|
273
|
-
|
|
274
|
-
[basename, object]
|
|
272
|
+
[File.basename(filename), Marshal.load(File.binread(filename))]
|
|
275
273
|
end]
|
|
276
274
|
|
|
277
275
|
# 401 - dialogue lines
|
|
@@ -313,22 +311,23 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
|
|
|
313
311
|
next if variable.empty?
|
|
314
312
|
|
|
315
313
|
variable = variable.gsub(/\r\n/, "\n")
|
|
316
|
-
|
|
317
314
|
translated = get_variable_translated(variable, other_translation_map, game_type)
|
|
318
315
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
316
|
+
unless translated.nil? || translated.empty?
|
|
317
|
+
if i.zero?
|
|
318
|
+
object.name = translated
|
|
319
|
+
elsif i == 1
|
|
320
|
+
object.nickname = translated
|
|
321
|
+
elsif i == 2
|
|
322
|
+
object.description = translated
|
|
323
|
+
else
|
|
324
|
+
object.note = translated
|
|
325
|
+
end
|
|
327
326
|
end
|
|
328
327
|
end
|
|
329
328
|
end
|
|
330
329
|
else
|
|
331
|
-
other_object_array.
|
|
330
|
+
other_object_array.each_with_index do |object, obj|
|
|
332
331
|
next if object.nil?
|
|
333
332
|
|
|
334
333
|
pages = object.pages
|
|
@@ -374,25 +373,7 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
|
|
|
374
373
|
in_sequence = true
|
|
375
374
|
line.push(parameters[0])
|
|
376
375
|
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)
|
|
376
|
+
elsif parameters[0].is_a?(Array)
|
|
396
377
|
parameters[0].each_with_index do |subparameter, sp|
|
|
397
378
|
next unless subparameter.is_a?(String)
|
|
398
379
|
|
|
@@ -402,17 +383,38 @@ def self.write_other(original_files_paths, other_path, output_path, shuffle_leve
|
|
|
402
383
|
translated = get_parameter_translated(code, subparameter, other_translation_map, game_type)
|
|
403
384
|
parameters[0][sp] = translated unless translated.nil? || translated.empty?
|
|
404
385
|
end
|
|
386
|
+
elsif parameters[0].is_a?(String)
|
|
387
|
+
parameter = parameters[0].strip
|
|
388
|
+
next if parameter.empty?
|
|
389
|
+
|
|
390
|
+
translated = get_parameter_translated(code, parameter, other_translation_map, game_type)
|
|
391
|
+
parameters[0] = translated unless translated.nil? || translated.empty?
|
|
392
|
+
elsif parameters[1].is_a?(String)
|
|
393
|
+
parameter = parameters[1].strip
|
|
394
|
+
next if parameter.empty?
|
|
395
|
+
|
|
396
|
+
translated = get_parameter_translated(code, parameter, other_translation_map, game_type)
|
|
397
|
+
parameters[1] = translated unless translated.nil? || translated.empty?
|
|
405
398
|
end
|
|
406
399
|
|
|
407
400
|
item.parameters = parameters
|
|
401
|
+
list[it] = item
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
if pages.nil?
|
|
405
|
+
object.list = list
|
|
406
|
+
else
|
|
407
|
+
pages[pg].instance_variable_set(:@list, list)
|
|
408
|
+
object.pages = pages
|
|
408
409
|
end
|
|
409
410
|
end
|
|
411
|
+
|
|
412
|
+
other_object_array[obj] = object
|
|
410
413
|
end
|
|
411
414
|
end
|
|
412
415
|
|
|
413
|
-
puts "Written #{filename}" if logging
|
|
414
|
-
|
|
415
416
|
File.binwrite(File.join(output_path, filename), Marshal.dump(other_object_array))
|
|
417
|
+
puts "Written #{filename}" if logging
|
|
416
418
|
end
|
|
417
419
|
end
|
|
418
420
|
|
|
@@ -459,15 +461,15 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
|
|
|
459
461
|
currency_unit = system_object.currency_unit
|
|
460
462
|
terms = system_object.terms || system_object.words
|
|
461
463
|
|
|
462
|
-
[elements, skill_types, weapon_types, armor_types].each_with_index
|
|
464
|
+
[elements, skill_types, weapon_types, armor_types].each_with_index do |array, i|
|
|
463
465
|
next unless array.is_a?(Array)
|
|
464
466
|
|
|
465
|
-
array.
|
|
466
|
-
|
|
467
|
-
|
|
467
|
+
array.each_with_index do |string, i|
|
|
468
|
+
string = string.strip
|
|
469
|
+
next if string.empty?
|
|
468
470
|
|
|
469
|
-
translated = system_translation_map[
|
|
470
|
-
|
|
471
|
+
translated = system_translation_map[string]
|
|
472
|
+
array[i] = translated unless translated.nil? || translated.empty?
|
|
471
473
|
end
|
|
472
474
|
|
|
473
475
|
if i.zero?
|
|
@@ -493,14 +495,14 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
|
|
|
493
495
|
next if value.empty?
|
|
494
496
|
|
|
495
497
|
translated = system_translation_map[stripped]
|
|
496
|
-
value =
|
|
498
|
+
value = translated unless translated.nil? || translated.empty?
|
|
497
499
|
elsif value.is_a?(Array)
|
|
498
|
-
value.
|
|
499
|
-
|
|
500
|
-
|
|
500
|
+
value.each_with_index do |string, i|
|
|
501
|
+
string = string.strip
|
|
502
|
+
next if string.empty?
|
|
501
503
|
|
|
502
|
-
translated = system_translation_map[
|
|
503
|
-
value =
|
|
504
|
+
translated = system_translation_map[string]
|
|
505
|
+
value[i] = translated unless translated.nil? || translated.empty?
|
|
504
506
|
end
|
|
505
507
|
end
|
|
506
508
|
|
|
@@ -512,8 +514,11 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
|
|
|
512
514
|
system_object.terms = terms
|
|
513
515
|
|
|
514
516
|
game_title_translated = system_translated_text[-1]
|
|
515
|
-
|
|
516
|
-
|
|
517
|
+
|
|
518
|
+
unless game_title_translated.nil? || game_title_translated.empty?
|
|
519
|
+
system_object.game_title = game_title_translated
|
|
520
|
+
write_ini_title(ini_file_path, game_title_translated)
|
|
521
|
+
end
|
|
517
522
|
|
|
518
523
|
puts "Written #{system_basename}" if logging
|
|
519
524
|
|
|
@@ -540,13 +545,21 @@ def self.write_scripts(scripts_file_path, other_path, output_path, logging)
|
|
|
540
545
|
|
|
541
546
|
# This code was fun before `that` game used Windows-1252 degree symbol
|
|
542
547
|
script_entries.each do |script|
|
|
543
|
-
code = Zlib::Inflate.inflate(script[2])
|
|
548
|
+
code = Zlib::Inflate.inflate(script[2])
|
|
549
|
+
code.force_encoding('UTF-8')
|
|
544
550
|
|
|
551
|
+
# I figured how String#encode works - now everything is good
|
|
545
552
|
unless code.valid_encoding?
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
553
|
+
[Encoding::UTF_8, Encoding::WINDOWS_1252, Encoding::SHIFT_JIS].each do |encoding|
|
|
554
|
+
encoded = code.encode(code.encoding, encoding)
|
|
555
|
+
|
|
556
|
+
if encoded.valid_encoding?
|
|
557
|
+
code.force_encoding(encoding)
|
|
558
|
+
break
|
|
559
|
+
end
|
|
560
|
+
rescue Encoding::InvalidByteSequenceError
|
|
561
|
+
next
|
|
562
|
+
end
|
|
550
563
|
end
|
|
551
564
|
|
|
552
565
|
# this shit finally works and requires NO further changes
|
|
@@ -564,8 +577,7 @@ def self.write_scripts(scripts_file_path, other_path, output_path, logging)
|
|
|
564
577
|
script[2] = Zlib::Deflate.deflate(code, Zlib::BEST_COMPRESSION)
|
|
565
578
|
end
|
|
566
579
|
|
|
567
|
-
puts "Written #{scripts_basename}" if logging
|
|
568
|
-
|
|
569
580
|
# File.binwrite(File.join(output_path, 'scripts_plain.txt'), codes.join("\n")) - debug line
|
|
570
581
|
File.binwrite(File.join(output_path, scripts_basename), Marshal.dump(script_entries))
|
|
582
|
+
puts "Written #{scripts_basename}" if logging
|
|
571
583
|
end
|
data/rvpacker-txt.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = 'rvpacker-txt'
|
|
5
|
-
spec.version = '1.
|
|
5
|
+
spec.version = '1.8.0'
|
|
6
6
|
spec.authors = ['Howard Jeng', 'Andrew Kesterson', 'Solistra', 'Darkness9724', 'savannstm']
|
|
7
7
|
spec.email = ['savannstm@gmail.com']
|
|
8
8
|
spec.summary = 'Reads or writes RPG Maker XP/VX/VXAce game text to .txt files'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rvpacker-txt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.8.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-
|
|
15
|
+
date: 2024-07-18 00:00:00.000000000 Z
|
|
16
16
|
dependencies: []
|
|
17
17
|
description:
|
|
18
18
|
email:
|