rvpacker-txt 1.8.3 → 1.8.5
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/bin/rvpacker-txt +40 -18
- data/lib/read.rb +16 -18
- data/lib/write.rb +5 -12
- data/rvpacker-txt.gemspec +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4be9adddaac27a84654c48292e0fa8949daf9b48a6b97520585e5bc9678c4593
|
|
4
|
+
data.tar.gz: a108f9445ec1e2151c39eeda9f262c2505e763efbbc790b8c7a788bf9ffdd1bf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 318bedbdef111ee55225cb8cc71c5cb9f0751c186daa314722f6f09900e69ee2ffaedf11850185d484189c7879630c900d19a586dad6b0c948daa023991c8d45
|
|
7
|
+
data.tar.gz: ffb4a43103686e875a3de87964c53f2d7ae81b1d64f06433164992bc25a7f31a603837a8358a8e33b7b84be9fb3343e4690f5f9c901d1c50cfbe9c3192bdc243
|
data/bin/rvpacker-txt
CHANGED
|
@@ -9,45 +9,66 @@ require 'classes'
|
|
|
9
9
|
def self.parse_options
|
|
10
10
|
options = { disable_processing: {}, input_dir: './', output_dir: './', shuffle_level: 0 }
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
read_command_description = 'Parses files from "original" or "data" folders of input directory to "translation" folder of output directory.'
|
|
13
|
+
write_command_description = 'Writes translated files using original files from "original" or "data" folder of input directory and writes results to "output" folder of output directory.'
|
|
14
|
+
banner_text = "This tool allows to parse RPG Maker games to .txt files and write them back to their initial form.\n\nUsage: rvpacker-txt COMMAND [options]\n\nCOMMANDS:\n read - #{read_command_description}\n write - #{write_command_description}\nOPTIONS:\n"
|
|
15
|
+
|
|
16
|
+
OptionParser.new(banner_text) do |cmd|
|
|
17
|
+
cmd.on('-i', '--input-dir PATH', String,
|
|
18
|
+
'When reading: Input directory, containing folders "original" or "data" with original game files.',
|
|
19
|
+
'When writing: Input directory, containing folders "original" or "data" and "translation" with original game files and .txt files with translation respectively.') do |dir|
|
|
16
20
|
options[:input_dir] = File.exist?(dir) ? File.realpath(dir) : (raise "#{dir} not found")
|
|
17
21
|
options[:output_dir] = options[:input_dir]
|
|
18
22
|
end
|
|
19
23
|
|
|
20
|
-
cmd.on('-o', '--output-dir
|
|
24
|
+
cmd.on('-o', '--output-dir PATH', String,
|
|
25
|
+
'When reading: Output directory, where an "output" folder will be created, containing compiled RPG Maker files with your translation.',
|
|
26
|
+
'When writing: Output directory, where a "translation" folder will be created, containing parsed .txt files with the text from the game.') do |dir|
|
|
21
27
|
options[:output_dir] = File.exist?(dir) ? File.realpath(dir) : (raise "#{dir} not found")
|
|
22
28
|
end
|
|
23
29
|
|
|
24
|
-
cmd.on('--disable-processing FILES', Array,
|
|
30
|
+
cmd.on('--disable-processing FILES', Array,
|
|
31
|
+
'Skips processing the specified files.',
|
|
32
|
+
'Example: --disable-processing=maps,other,system.',
|
|
33
|
+
'[Allowed values: maps, other, system, scripts]') do |files|
|
|
25
34
|
files.each do |file|
|
|
26
35
|
files = %w[maps other system scripts]
|
|
27
|
-
index = files.
|
|
36
|
+
index = files.find_index(file)
|
|
28
37
|
options[:disable_processing][files[index]] = true if index
|
|
29
38
|
end
|
|
30
39
|
end
|
|
31
40
|
|
|
32
|
-
cmd.on('-s', '--shuffle
|
|
41
|
+
cmd.on('-s', '--shuffle-level NUMBER', Integer,
|
|
42
|
+
'With value 1, shuffles all translation lines. With value 2, shuffles all words and lines in translation text.',
|
|
43
|
+
'Example: --shuffle-level 1.',
|
|
44
|
+
'[Allowed values: 0, 1, 2]',
|
|
45
|
+
'[Default value: 0]',
|
|
46
|
+
'[Write flag]') do |num|
|
|
47
|
+
raise 'Allowed values: 0, 1, 2' if num > 2
|
|
33
48
|
options[:shuffle_level] = num
|
|
34
49
|
end
|
|
35
50
|
|
|
36
|
-
cmd.on('--disable-custom-processing', 'Disables built-in custom parsing/writing for some games') do
|
|
51
|
+
cmd.on('--disable-custom-processing', 'Disables built-in custom parsing/writing for some games.') do
|
|
37
52
|
options[:disable_custom_processing] = true
|
|
38
53
|
end
|
|
39
54
|
|
|
40
|
-
cmd.on('-l', '--log', '
|
|
55
|
+
cmd.on('-l', '--log', 'Enables logging.') do
|
|
41
56
|
options[:logging] = true
|
|
42
57
|
end
|
|
43
58
|
|
|
44
|
-
cmd.on('-f', '--force',
|
|
59
|
+
cmd.on('-f', '--force',
|
|
60
|
+
'Force rewrite all files. Cannot be used with --append.',
|
|
61
|
+
'USE WITH CAUTION!',
|
|
62
|
+
'[Read flag]') do
|
|
45
63
|
options[:force] = true
|
|
46
64
|
end
|
|
47
65
|
|
|
48
|
-
cmd.on('-a', '--append',
|
|
49
|
-
|
|
50
|
-
|
|
66
|
+
cmd.on('-a', '--append',
|
|
67
|
+
"When the rvpacker-txt or the game which files you've parsed receives an update,",
|
|
68
|
+
'you probably should re-read game files with --append, which will append any new text to your files without overwriting the progress',
|
|
69
|
+
'Cannot be used with --force',
|
|
70
|
+
'[Read flag]') do
|
|
71
|
+
raise '--append cannot be used with --force.' if options[:force]
|
|
51
72
|
options[:append] = true
|
|
52
73
|
end
|
|
53
74
|
|
|
@@ -95,9 +116,8 @@ other_path = File.join(input_dir, 'translation', 'other')
|
|
|
95
116
|
FileUtils.mkdir_p(maps_path)
|
|
96
117
|
FileUtils.mkdir_p(other_path)
|
|
97
118
|
|
|
98
|
-
engine = extensions.each
|
|
99
|
-
|
|
100
|
-
end || (raise "Couldn't determine project engine.")
|
|
119
|
+
engine = extensions.each { |sym, ext| break sym if File.exist?(File.join(original_directory, "System.#{ext}")) } ||
|
|
120
|
+
(raise "Couldn't determine project engine.")
|
|
101
121
|
|
|
102
122
|
files = Dir.glob("#{original_directory}/*#{extensions[engine]}")
|
|
103
123
|
|
|
@@ -129,7 +149,9 @@ wait_time = 0
|
|
|
129
149
|
processing_type = if force
|
|
130
150
|
wait_time_start = Time.now
|
|
131
151
|
|
|
132
|
-
puts "WARNING! You're about to forcefully rewrite all your translation files, including _trans files
|
|
152
|
+
puts "WARNING! You're about to forcefully rewrite all your translation files, including _trans files.",
|
|
153
|
+
"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.",
|
|
154
|
+
"Input 'Y' to continue."
|
|
133
155
|
exit unless gets.chomp == 'Y'
|
|
134
156
|
|
|
135
157
|
wait_time = Time.now - wait_time_start
|
data/lib/read.rb
CHANGED
|
@@ -70,6 +70,8 @@ end
|
|
|
70
70
|
# @param [String] game_type
|
|
71
71
|
# @return [String]
|
|
72
72
|
def self.parse_parameter(code, parameter, game_type)
|
|
73
|
+
return nil if parameter.match?(/^[.()+-:;\[\]^~%&!*\/→×??x%▼| ]+$/)
|
|
74
|
+
|
|
73
75
|
unless game_type.nil?
|
|
74
76
|
case code
|
|
75
77
|
when 401, 405
|
|
@@ -97,7 +99,9 @@ end
|
|
|
97
99
|
# @param [String] _game_type
|
|
98
100
|
# @return [String]
|
|
99
101
|
def self.parse_variable(variable, _game_type)
|
|
102
|
+
return nil if parameter.match?(/^[.()+-:;\[\]^~%&!*\/→×??x%▼| ]+$/)
|
|
100
103
|
variable = variable.gsub(/\r?\n/, '\#') if variable.count("\n").positive?
|
|
104
|
+
|
|
101
105
|
return nil if variable.split('\#').all? { |line| line.strip.match?(/(^#? ?<.*>\.?$)|^$/) }
|
|
102
106
|
return nil if variable.match?(/^[+-]?[0-9]*$/) ||
|
|
103
107
|
variable.match?(/---/) ||
|
|
@@ -122,9 +126,7 @@ def self.read_map(maps_files_paths, output_path, logging, game_type, processing_
|
|
|
122
126
|
return
|
|
123
127
|
end
|
|
124
128
|
|
|
125
|
-
maps_object_map = Hash[maps_files_paths.map
|
|
126
|
-
[File.basename(filename), Marshal.load(File.binread(filename))]
|
|
127
|
-
end]
|
|
129
|
+
maps_object_map = Hash[maps_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
128
130
|
|
|
129
131
|
maps_lines = IndexSet.new
|
|
130
132
|
names_lines = IndexSet.new
|
|
@@ -266,9 +268,7 @@ end
|
|
|
266
268
|
# @param [String] game_type
|
|
267
269
|
# @param [String] processing_type
|
|
268
270
|
def self.read_other(other_files_paths, output_path, logging, game_type, processing_type)
|
|
269
|
-
other_object_array_map = Hash[other_files_paths.map
|
|
270
|
-
[File.basename(filename), Marshal.load(File.binread(filename))]
|
|
271
|
-
end]
|
|
271
|
+
other_object_array_map = Hash[other_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
272
272
|
|
|
273
273
|
inner_processing_type = processing_type
|
|
274
274
|
# 401 - dialogue lines
|
|
@@ -510,20 +510,18 @@ def self.read_system(system_file_path, ini_file_path, output_path, logging, proc
|
|
|
510
510
|
|
|
511
511
|
system_lines.add(value)
|
|
512
512
|
end
|
|
513
|
+
elsif value.is_a?(Array)
|
|
514
|
+
value.each do |string|
|
|
515
|
+
next unless string.is_a?(String)
|
|
513
516
|
|
|
514
|
-
|
|
515
|
-
|
|
517
|
+
string = string.strip
|
|
518
|
+
next if string.empty?
|
|
516
519
|
|
|
517
|
-
|
|
518
|
-
|
|
520
|
+
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
|
|
521
|
+
!system_translation_map.include?(string)
|
|
519
522
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
system_translation_map.insert_at_index(system_lines.length, string, '') if processing_type == :append &&
|
|
524
|
-
!system_translation_map.include?(string)
|
|
525
|
-
|
|
526
|
-
system_lines.add(string)
|
|
523
|
+
system_lines.add(string)
|
|
524
|
+
end
|
|
527
525
|
end
|
|
528
526
|
end
|
|
529
527
|
|
|
@@ -623,7 +621,7 @@ def self.read_scripts(scripts_file_path, output_path, logging, processing_type)
|
|
|
623
621
|
string.match?(/^(?=.*\d)[A-Za-z0-9\-]+$/) ||
|
|
624
622
|
string.match?(/^[a-z\-()\/ +'&]*$/) ||
|
|
625
623
|
string.match?(/^[A-Za-z]+[+-]$/) ||
|
|
626
|
-
string.match?(/^[.()+-:;\[\]^~%&!*\/→×??x%▼|]
|
|
624
|
+
string.match?(/^[.()+-:;\[\]^~%&!*\/→×??x%▼| ]+$/) ||
|
|
627
625
|
string.match?(/^Tile.*[A-Z]$/) ||
|
|
628
626
|
string.match?(/^[a-zA-Z][a-z]+([A-Z][a-z]*)+$/) ||
|
|
629
627
|
string.match?(/^Cancel Action$|^Invert$|^End$|^Individual$|^Missed File$|^Bitmap$|^Audio$/) ||
|
data/lib/write.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require 'zlib'
|
|
4
4
|
|
|
5
5
|
# @param [String] string A parsed scripts code string, containing raw Ruby code
|
|
6
|
-
# @return [
|
|
6
|
+
# @return [Array<Array<String, Integer>>] Hash of parsed from code strings and their start indices
|
|
7
7
|
def self.extract_quoted_strings(string)
|
|
8
8
|
strings_array = []
|
|
9
9
|
indices_array = []
|
|
@@ -129,9 +129,7 @@ end
|
|
|
129
129
|
# @param [Boolean] logging
|
|
130
130
|
# @param [String] game_type
|
|
131
131
|
def self.write_map(original_files_paths, maps_path, output_path, shuffle_level, logging, game_type)
|
|
132
|
-
maps_object_map = Hash[original_files_paths.map
|
|
133
|
-
[File.basename(filename), Marshal.load(File.binread(filename))]
|
|
134
|
-
end]
|
|
132
|
+
maps_object_map = Hash[original_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
135
133
|
|
|
136
134
|
maps_original_text = File.readlines(File.join(maps_path, 'maps.txt'), encoding: 'UTF-8', chomp: true).map do |line|
|
|
137
135
|
line.gsub('\#', "\n").strip
|
|
@@ -270,9 +268,7 @@ end
|
|
|
270
268
|
# @param [Boolean] logging
|
|
271
269
|
# @param [String] game_type
|
|
272
270
|
def self.write_other(original_files_paths, other_path, output_path, shuffle_level, logging, game_type)
|
|
273
|
-
other_object_array_map = Hash[original_files_paths.map
|
|
274
|
-
[File.basename(filename), Marshal.load(File.binread(filename))]
|
|
275
|
-
end]
|
|
271
|
+
other_object_array_map = Hash[original_files_paths.map { |f| [File.basename(f), Marshal.load(File.binread(f))] }]
|
|
276
272
|
|
|
277
273
|
# 401 - dialogue lines
|
|
278
274
|
# 405 - credits lines
|
|
@@ -424,9 +420,7 @@ end
|
|
|
424
420
|
# @param [String] translated
|
|
425
421
|
def self.write_ini_title(ini_file_path, translated)
|
|
426
422
|
file_lines = File.readlines(ini_file_path, chomp: true)
|
|
427
|
-
title_line_index = file_lines.each_with_index
|
|
428
|
-
break i if line.downcase.start_with?('title')
|
|
429
|
-
end
|
|
423
|
+
title_line_index = file_lines.each_with_index { |line, i| break i if line.downcase.start_with?('title') }
|
|
430
424
|
|
|
431
425
|
file_lines[title_line_index] = translated
|
|
432
426
|
File.binwrite(ini_file_path, file_lines.join("\n"))
|
|
@@ -522,9 +516,8 @@ def self.write_system(system_file_path, ini_file_path, other_path, output_path,
|
|
|
522
516
|
write_ini_title(ini_file_path, game_title_translated)
|
|
523
517
|
end
|
|
524
518
|
|
|
525
|
-
puts "Written #{system_basename}" if logging
|
|
526
|
-
|
|
527
519
|
File.binwrite(File.join(output_path, system_basename), Marshal.dump(system_object))
|
|
520
|
+
puts "Written #{system_basename}" if logging
|
|
528
521
|
end
|
|
529
522
|
|
|
530
523
|
# @param [String] scripts_file_path Path to Scripts.*data file
|
data/rvpacker-txt.gemspec
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = 'rvpacker-txt'
|
|
5
|
-
spec.version = '1.8.
|
|
5
|
+
spec.version = '1.8.5'
|
|
6
6
|
spec.authors = ['Howard Jeng', 'Andrew Kesterson', 'Solistra', 'Darkness9724', 'savannstm']
|
|
7
7
|
spec.email = ['savannstm@gmail.com']
|
|
8
|
-
spec.summary = 'Reads
|
|
8
|
+
spec.summary = 'Reads RPG Maker XP/VX/VXAce game text to .txt files and writes them to their initial form.'
|
|
9
9
|
spec.homepage = 'https://github.com/savannstm/rvpacker-txt'
|
|
10
10
|
spec.license = 'MIT'
|
|
11
11
|
spec.required_ruby_version = Gem::Requirement.new('>= 3.0.0')
|
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.8.
|
|
4
|
+
version: 1.8.5
|
|
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-23 00:00:00.000000000 Z
|
|
16
16
|
dependencies: []
|
|
17
17
|
description:
|
|
18
18
|
email:
|
|
@@ -53,5 +53,6 @@ requirements: []
|
|
|
53
53
|
rubygems_version: 3.5.14
|
|
54
54
|
signing_key:
|
|
55
55
|
specification_version: 4
|
|
56
|
-
summary: Reads
|
|
56
|
+
summary: Reads RPG Maker XP/VX/VXAce game text to .txt files and writes them to their
|
|
57
|
+
initial form.
|
|
57
58
|
test_files: []
|