R3EXS 1.1.1 → 2.0.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/.yardopts +10 -12
- data/CHANGELOG.md +43 -23
- data/README.md +17 -38
- data/README_EN.md +21 -40
- data/bin/R3EXS +191 -217
- data/ext/R3EXS/R3EXS.cxx +334 -0
- data/ext/R3EXS/extconf.rb +9 -0
- data/lib/R3EXS/RGSS3.rb +553 -1459
- data/lib/R3EXS/RGSS3_R3EXS.rb +1939 -2027
- data/lib/R3EXS/ast.rb +209 -158
- data/lib/R3EXS/error.rb +39 -245
- data/lib/R3EXS/extract_strings.rb +86 -62
- data/lib/R3EXS/inject_strings.rb +83 -60
- data/lib/R3EXS/json_rvdata2.rb +122 -108
- data/lib/R3EXS/logger.rb +44 -0
- data/lib/R3EXS/rvdata2_json.rb +79 -83
- data/lib/R3EXS/utils.rb +403 -1057
- data/lib/R3EXS/version.rb +3 -4
- data/lib/R3EXS.rb +14 -13
- metadata +17 -30
- data/ext/R3EXS/R3EXS.c +0 -601
data/bin/R3EXS
CHANGED
|
@@ -1,217 +1,191 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require 'gli'
|
|
5
|
-
require 'R3EXS'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
desc '
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
desc '
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
desc '
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
rescue R3EXS::ManualTransFilePathError => e
|
|
193
|
-
$stderr.puts "#{R3EXS::Utils::RED_COLOR}#{e.message}#{R3EXS::Utils::RESET_COLOR}"
|
|
194
|
-
$stderr.puts "You are supposed to use #{R3EXS::Utils::GREEN_COLOR}ex_strings#{R3EXS::Utils::RESET_COLOR} subcommand to generate the ManualTransFile.json"
|
|
195
|
-
$stderr.puts "For more information, please enter '#{R3EXS::Utils::GREEN_COLOR}R3EXS help ex_strings#{R3EXS::Utils::RESET_COLOR}'"
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
pre do |global, command, options, args|
|
|
201
|
-
$global_options = global
|
|
202
|
-
true
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
post do |global, command, options, args|
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
on_error do |exception|
|
|
209
|
-
# Error logic here
|
|
210
|
-
# return false to skip default error handling
|
|
211
|
-
$stderr.puts "#{R3EXS::Utils::RED_COLOR}#{exception.message}#{R3EXS::Utils::RESET_COLOR}"
|
|
212
|
-
$stderr.puts exception.backtrace
|
|
213
|
-
false
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
exit App.run(ARGV)
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require 'gli'
|
|
5
|
+
require 'R3EXS'
|
|
6
|
+
|
|
7
|
+
class App
|
|
8
|
+
extend GLI::App
|
|
9
|
+
|
|
10
|
+
program_desc 'A tool for extracting and translating strings from the RGSS3 game engine'
|
|
11
|
+
|
|
12
|
+
version R3EXS::VERSION
|
|
13
|
+
|
|
14
|
+
subcommand_option_handling :normal
|
|
15
|
+
arguments :strict
|
|
16
|
+
|
|
17
|
+
desc 'Enable verbose mode'
|
|
18
|
+
switch %i[v verbose]
|
|
19
|
+
|
|
20
|
+
desc 'Decrypt the Game.rgss3a file'
|
|
21
|
+
arg_name '<Game.rgss3a file path>'
|
|
22
|
+
command :decrypt do |c|
|
|
23
|
+
c.desc 'The *.rvdata2 output dir'
|
|
24
|
+
c.default_value './'
|
|
25
|
+
c.arg_name 'DIRECTORY'
|
|
26
|
+
c.flag %i[o output_dir]
|
|
27
|
+
|
|
28
|
+
c.action do |global_options, options, args|
|
|
29
|
+
R3EXS.rgss3a_rvdata2(args[0], options[:output_dir], global_options[:verbose])
|
|
30
|
+
R3EXS::Logger.info("All rvdata2 files have been written to #{options[:output_dir]}")
|
|
31
|
+
rescue R3EXS::RGSS3AFileError => e
|
|
32
|
+
R3EXS::Logger.warn(e.message)
|
|
33
|
+
rescue SystemCallError => e
|
|
34
|
+
R3EXS::Logger.warn("#{e.class}: #{e.message}")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
desc 'Serialize rvdata2 files into JSON'
|
|
39
|
+
arg_name '<the *.rvdata2 dir>'
|
|
40
|
+
command :rvdata2_json do |c|
|
|
41
|
+
c.desc 'Enable complete serialization'
|
|
42
|
+
c.switch %i[c complete]
|
|
43
|
+
|
|
44
|
+
c.desc 'Enable Scripts.rvdata2 serialization'
|
|
45
|
+
c.switch %i[s with_scripts]
|
|
46
|
+
|
|
47
|
+
c.desc 'The *.json output dir'
|
|
48
|
+
c.default_value './JSON'
|
|
49
|
+
c.arg_name 'DIRECTORY'
|
|
50
|
+
c.flag %i[o output_dir]
|
|
51
|
+
|
|
52
|
+
c.action do |_global_options, options, args|
|
|
53
|
+
R3EXS.rvdata2_json(Pathname(args[0]), Pathname(options[:output_dir]), options[:complete], options[:with_scripts])
|
|
54
|
+
R3EXS::Logger.info("All JSON files have been written to #{options[:output_dir]}")
|
|
55
|
+
rescue R3EXS::Rvdata2DirError => e
|
|
56
|
+
R3EXS::Logger.warn(e.message)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
desc 'Deserialize JSON files back into rvdata2'
|
|
61
|
+
arg_name '<the *.json dir>'
|
|
62
|
+
command :json_rvdata2 do |c|
|
|
63
|
+
c.desc 'Enable complete deserialization'
|
|
64
|
+
c.switch %i[c complete]
|
|
65
|
+
|
|
66
|
+
c.desc 'Enable Scripts JSON deserialization'
|
|
67
|
+
c.switch %i[s with_scripts]
|
|
68
|
+
|
|
69
|
+
c.desc 'The NEW *.rvdata2 output dir'
|
|
70
|
+
c.default_value './Data_NEW'
|
|
71
|
+
c.arg_name 'DIRECTORY'
|
|
72
|
+
c.flag %i[o output_dir]
|
|
73
|
+
|
|
74
|
+
c.desc 'The ORIGINAL *.rvdata2 dir'
|
|
75
|
+
c.default_value './Data'
|
|
76
|
+
c.arg_name 'DIRECTORY'
|
|
77
|
+
c.flag %i[r original_dir]
|
|
78
|
+
|
|
79
|
+
c.action do |_global_options, options, args|
|
|
80
|
+
R3EXS.json_rvdata2(Pathname(args[0]), Pathname(options[:output_dir]), Pathname(options[:original_dir]), options[:complete], options[:with_scripts])
|
|
81
|
+
R3EXS::Logger.info("All new rvdata2 files have been written to #{options[:output_dir]}")
|
|
82
|
+
rescue R3EXS::JsonDirError => e
|
|
83
|
+
R3EXS::Logger.warn(e.message)
|
|
84
|
+
rescue R3EXS::RPGJsonFileError => e
|
|
85
|
+
R3EXS::Logger.warn(e.message)
|
|
86
|
+
R3EXS::Logger.warn('Your JSON files are not in RPG module')
|
|
87
|
+
R3EXS::Logger.warn("You are supposed to use '-c' or '--complete' to enable complete serialization in rvdata2_json subcommand")
|
|
88
|
+
R3EXS::Logger.warn("Or NOT use '-c' or '--complete' to enable complete deserialization in json_rvdata2 subcommand")
|
|
89
|
+
R3EXS::Logger.warn("For more information, please enter 'R3EXS help json_rvdata2'")
|
|
90
|
+
rescue R3EXS::R3EXSJsonFileError => e
|
|
91
|
+
R3EXS::Logger.warn(e.message)
|
|
92
|
+
R3EXS::Logger.warn('Your JSON files are not in R3EXS module')
|
|
93
|
+
R3EXS::Logger.warn("You are NOT supposed to use '-c' or '--complete' to enable complete serialization in rvdata2_json subcommand")
|
|
94
|
+
R3EXS::Logger.warn("Or use '-c' or '--complete' to enable complete deserialization in json_rvdata2 subcommand")
|
|
95
|
+
R3EXS::Logger.warn("For more information, please enter 'R3EXS help json_rvdata2'")
|
|
96
|
+
rescue R3EXS::Rvdata2PathError => e
|
|
97
|
+
R3EXS::Logger.warn(e.message)
|
|
98
|
+
rescue R3EXS::ScriptsInfoPathError => e
|
|
99
|
+
R3EXS::Logger.warn(e.message)
|
|
100
|
+
R3EXS::Logger.warn('Make sure the Scripts_info.json is in the Scripts directory')
|
|
101
|
+
R3EXS::Logger.warn("For more information, please enter 'R3EXS help rvdata2_json'")
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
desc 'Extract all strings'
|
|
106
|
+
arg_name '<the *.json dir>'
|
|
107
|
+
command :ex_strings do |c|
|
|
108
|
+
c.desc 'Enable Scripts extraction'
|
|
109
|
+
c.switch %i[s with_scripts]
|
|
110
|
+
|
|
111
|
+
c.desc 'Enable Symbol extraction in Scripts extraction'
|
|
112
|
+
c.switch %i[y with_symbol]
|
|
113
|
+
|
|
114
|
+
c.desc 'Enable Scripts extraction into a separate ManualTransFile_scripts.json'
|
|
115
|
+
c.switch %i[p with_scripts_separate]
|
|
116
|
+
|
|
117
|
+
c.desc 'The ManualTransFile.json or ManualTransFile_scripts.json output dir'
|
|
118
|
+
c.default_value './'
|
|
119
|
+
c.arg_name 'DIRECTORY'
|
|
120
|
+
c.flag %i[o output_dir]
|
|
121
|
+
|
|
122
|
+
c.action do |_global_options, options, args|
|
|
123
|
+
R3EXS.ex_strings(Pathname(args[0]), Pathname(options[:output_dir]), options[:with_scripts], options[:with_symbol], options[:with_scripts_separate])
|
|
124
|
+
if options[:with_scripts_separate]
|
|
125
|
+
R3EXS::Logger.info("All strings have been extracted to #{File.join(options[:output_dir], 'ManualTransFile.json')} and #{File.join(options[:output_dir], 'ManualTransFile_scripts.json')}")
|
|
126
|
+
else
|
|
127
|
+
R3EXS::Logger.info("All strings have been extracted to #{File.join(options[:output_dir], 'ManualTransFile.json')}")
|
|
128
|
+
end
|
|
129
|
+
rescue R3EXS::JsonDirError => e
|
|
130
|
+
R3EXS::Logger.warn(e.message)
|
|
131
|
+
rescue R3EXS::R3EXSJsonFileError => e
|
|
132
|
+
R3EXS::Logger.warn(e.message)
|
|
133
|
+
R3EXS::Logger.warn('Your JSON files are not in R3EXS module')
|
|
134
|
+
R3EXS::Logger.warn("You are NOT supposed to use '-c' or '--complete' to enable complete serialization in rvdata2_json subcommand")
|
|
135
|
+
R3EXS::Logger.warn("For more information, please enter 'R3EXS help json_rvdata2'")
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
desc 'Inject all strings'
|
|
140
|
+
arg_name '<the *.json dir>'
|
|
141
|
+
command :in_strings do |c|
|
|
142
|
+
c.desc 'Enable Scripts Injection'
|
|
143
|
+
c.switch %i[s with_scripts]
|
|
144
|
+
|
|
145
|
+
c.desc 'The ManualTransFile.json path'
|
|
146
|
+
c.default_value './ManualTransFile.json'
|
|
147
|
+
c.arg_name 'FILE'
|
|
148
|
+
c.flag %i[m manualtransfile_path]
|
|
149
|
+
|
|
150
|
+
c.desc 'The NEW *.json output dir'
|
|
151
|
+
c.default_value './JSON_NEW'
|
|
152
|
+
c.arg_name 'DIRECTORY'
|
|
153
|
+
c.flag %i[o output_dir]
|
|
154
|
+
|
|
155
|
+
c.action do |_global_options, options, args|
|
|
156
|
+
R3EXS.in_strings(Pathname(args[0]), Pathname(options[:output_dir]), Pathname(options[:manualtransfile_path]), options[:with_scripts])
|
|
157
|
+
R3EXS::Logger.info("All new JSON files have been written to #{options[:output_dir]}")
|
|
158
|
+
rescue R3EXS::ManualTransFilePathError => e
|
|
159
|
+
R3EXS::Logger.warn(e.message)
|
|
160
|
+
R3EXS::Logger.warn('You are supposed to use ex_strings subcommand to generate the ManualTransFile.json')
|
|
161
|
+
R3EXS::Logger.warn("For more information, please enter 'R3EXS help ex_strings'")
|
|
162
|
+
rescue R3EXS::JsonDirError => e
|
|
163
|
+
R3EXS::Logger.warn(e.message)
|
|
164
|
+
rescue R3EXS::R3EXSJsonFileError => e
|
|
165
|
+
R3EXS::Logger.warn(e.message)
|
|
166
|
+
R3EXS::Logger.warn('Your JSON files are not in R3EXS module')
|
|
167
|
+
R3EXS::Logger.warn("You are NOT supposed to use '-c' or '--complete' to enable complete serialization in rvdata2_json subcommand")
|
|
168
|
+
R3EXS::Logger.warn("For more information, please enter 'R3EXS help json_rvdata2'")
|
|
169
|
+
rescue R3EXS::ScriptsInfoPathError => e
|
|
170
|
+
R3EXS::Logger.warn(e.message)
|
|
171
|
+
R3EXS::Logger.warn('Make sure the Scripts_info.json is in the Scripts directory')
|
|
172
|
+
R3EXS::Logger.warn("For more information, please enter 'R3EXS help rvdata2_json'")
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
pre do |global, _command, _options, _args|
|
|
177
|
+
R3EXS::Logger.level = R3EXS::Logger::DEBUG if global[:verbose]
|
|
178
|
+
true
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
post do |_global, _command, _options, _args|
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
on_error do |exception|
|
|
185
|
+
R3EXS::Logger.warn(exception.message)
|
|
186
|
+
exception.backtrace.each { |line| R3EXS::Logger.warn(line) }
|
|
187
|
+
false
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
exit App.run(ARGV)
|