R3EXS 1.0.5 → 1.1.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.
- checksums.yaml +4 -4
- data/.yardopts +2 -2
- data/CHANGELOG.md +12 -0
- data/README.md +260 -260
- data/README_EN.md +260 -260
- data/bin/R3EXS +9 -19
- data/ext/R3EXS/R3EXS.c +601 -0
- data/ext/R3EXS/extconf.rb +3 -0
- data/lib/R3EXS/RGSS3.rb +1478 -1456
- data/lib/R3EXS/RGSS3_R3EXS.rb +504 -281
- data/lib/R3EXS/ast.rb +45 -41
- data/lib/R3EXS/error.rb +94 -75
- data/lib/R3EXS/extract_strings.rb +75 -79
- data/lib/R3EXS/inject_strings.rb +36 -44
- data/lib/R3EXS/json_rvdata2.rb +114 -104
- data/lib/R3EXS/rvdata2_json.rb +49 -18
- data/lib/R3EXS/utils.rb +1083 -970
- data/lib/R3EXS/version.rb +1 -1
- data/lib/R3EXS.rb +2 -1
- metadata +13 -14
- data/ext/rgss3a_rvdata2/extconf.rb +0 -3
- data/ext/rgss3a_rvdata2/rgss3a_rvdata2.c +0 -616
data/lib/R3EXS/inject_strings.rb
CHANGED
@@ -3,64 +3,30 @@
|
|
3
3
|
require 'zlib'
|
4
4
|
require_relative 'ast'
|
5
5
|
require_relative 'utils'
|
6
|
-
require_relative 'RGSS3_R3EXS'
|
7
6
|
|
8
7
|
module R3EXS
|
9
8
|
|
10
|
-
# 将 Ruby 源码中的字符串和符号替换为指定的字符串
|
11
|
-
#
|
12
|
-
# @param target_dir [String] 目标目录
|
13
|
-
# @param output_dir [String] 输出目录
|
14
|
-
# @param hash [Hash]
|
15
|
-
#
|
16
|
-
# @raise [ScriptsDirError] Scripts 目录不存在
|
17
|
-
# @raise [ScriptsInfoPathError] Scripts_info.json 文件不存在
|
18
|
-
#
|
19
|
-
# @return [void]
|
20
|
-
def R3EXS.rb_in_strings(target_dir, output_dir, hash)
|
21
|
-
target_full_dir = File.join(target_dir, 'Scripts')
|
22
|
-
output_full_dir = File.join(output_dir, 'Scripts')
|
23
|
-
script_info_file_path = File.join(target_full_dir, 'Scripts_info.json')
|
24
|
-
|
25
|
-
FileUtils.mkdir(output_full_dir) unless Dir.exist?(output_full_dir)
|
26
|
-
Dir.exist?(target_full_dir) or raise ScriptsDirError.new(target_full_dir), "Scripts directory not found: #{target_full_dir}"
|
27
|
-
File.exist?(script_info_file_path) or raise ScriptsInfoPathError.new(script_info_file_path), "Scripts_info.json not found: #{script_info_file_path}"
|
28
|
-
|
29
|
-
print "#{Utils::ESCAPE}#{Utils::YELLOW_COLOR}Copying #{Utils::RESET_COLOR}Scripts_info.json to #{output_full_dir}...\r" if $global_options[:verbose]
|
30
|
-
FileUtils.cp(script_info_file_path, output_full_dir)
|
31
|
-
|
32
|
-
Dir.glob(File.join(target_full_dir, "*.rb")).each do |script_file_path|
|
33
|
-
output_script_file_dir = File.join(output_full_dir, File.basename(script_file_path))
|
34
|
-
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Injecting to #{Utils::RESET_COLOR}#{output_script_file_dir}...\r" if $global_options[:verbose]
|
35
|
-
|
36
|
-
File.write(output_script_file_dir, StringsInjector.new(hash).rewrite(script_file_path, Prism.parse_file(script_file_path).value), mode: 'w')
|
37
|
-
|
38
|
-
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Injected #{Utils::RESET_COLOR}#{output_script_file_dir}\n" if $global_options[:verbose]
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
9
|
# 将指定目录下的所有已经序列化为 R3EXS 后的 JOSN 文件按照 ManualTransFile.json 翻译注入
|
43
10
|
#
|
44
|
-
# @param target_dir [
|
45
|
-
# @param output_dir [
|
46
|
-
# @param manualtransfile_path [
|
11
|
+
# @param target_dir [Pathname] 目标目录
|
12
|
+
# @param output_dir [Pathname] 输出目录
|
13
|
+
# @param manualtransfile_path [Pathname] ManualTransFile.json 文件路径
|
47
14
|
# @param with_scripts [Boolean] 是否包含脚本
|
48
15
|
#
|
49
16
|
# @raise [R3EXSJsonFileError] json 文件不是 R3EXS 模块中的对象
|
50
17
|
# @raise [JsonDirError] target_dir 不存在
|
51
|
-
# @raise [ScriptsDirError] Scripts 目录不存在
|
52
18
|
# @raise [ScriptsInfoPathError] Scripts_info.json 文件不存在
|
53
19
|
# @raise [ManualTransFilePath] ManualTransFile.json 不存在
|
54
20
|
#
|
55
21
|
# @return [void]
|
56
22
|
def R3EXS.in_strings(target_dir, output_dir, manualtransfile_path, with_scripts)
|
57
|
-
|
58
|
-
File.exist?(manualtransfile_path) or raise ManualTransFilePathError.new(manualtransfile_path), "ManualTransFile.json not found: #{manualtransfile_path}"
|
23
|
+
manualtransfile_path.exist? or raise ManualTransFilePathError.new(manualtransfile_path.to_s), "ManualTransFile.json not found: #{manualtransfile_path}"
|
59
24
|
|
60
|
-
manual_trans_hash = Oj.load_file(manualtransfile_path)
|
25
|
+
manual_trans_hash = Oj.load_file(manualtransfile_path.to_s)
|
61
26
|
|
62
|
-
|
63
|
-
|
27
|
+
# 处理常规的 JSON 文件
|
28
|
+
Utils.all_json_files(target_dir, :R3EXS) do |object, file_basename, parent_relative_dir|
|
29
|
+
file_path = output_dir.join(parent_relative_dir, "#{file_basename}.json")
|
64
30
|
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Injecting to #{Utils::RESET_COLOR}#{file_path}...\r" if $global_options[:verbose]
|
65
31
|
if object.is_a?(Array)
|
66
32
|
object.each do |obj|
|
@@ -70,11 +36,37 @@ module R3EXS
|
|
70
36
|
object.in_strings(manual_trans_hash)
|
71
37
|
end
|
72
38
|
Utils.object_json(object, file_path)
|
73
|
-
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Injected #{Utils::RESET_COLOR}#{
|
39
|
+
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Injected #{Utils::RESET_COLOR}#{file_path}\n" if $global_options[:verbose]
|
40
|
+
end
|
41
|
+
|
42
|
+
# 处理 CommonEvent_\d{5}.json 文件
|
43
|
+
Utils.all_commonevent_json_files(target_dir, :R3EXS) do |commonevents, commonevents_basenames, parent_relative_dir|
|
44
|
+
commonevents.zip(commonevents_basenames).each do |commonevent, commonevent_basename|
|
45
|
+
file_path = output_dir.join(parent_relative_dir, "#{commonevent_basename}.json")
|
46
|
+
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Injecting to #{Utils::RESET_COLOR}#{file_path}...\r" if $global_options[:verbose]
|
47
|
+
commonevent.in_strings(manual_trans_hash)
|
48
|
+
Utils.object_json(commonevent, file_path)
|
49
|
+
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Injected #{Utils::RESET_COLOR}#{file_path}\n" if $global_options[:verbose]
|
50
|
+
end
|
74
51
|
end
|
75
52
|
|
53
|
+
# 处理 \d{5}.rb 文件
|
76
54
|
if with_scripts
|
77
|
-
|
55
|
+
Utils.all_rb_files(target_dir) do |scripts, scripts_basenames, parent_relative_dir|
|
56
|
+
full_output_dir = output_dir.join(parent_relative_dir)
|
57
|
+
full_output_dir.mkdir unless full_output_dir.exist?
|
58
|
+
|
59
|
+
script_info_file_path = target_dir.join(parent_relative_dir, 'Scripts_info.json')
|
60
|
+
script_info_file_path.exist? or raise ScriptsInfoPathError.new(script_info_file_path.to_s), "Scripts_info.json not found: #{script_info_file_path}"
|
61
|
+
# 记得把 Scripts_info.json 也复制过去
|
62
|
+
FileUtils.cp(script_info_file_path, full_output_dir)
|
63
|
+
|
64
|
+
scripts.zip(scripts_basenames).each do |script, script_basename|
|
65
|
+
output_file_path = full_output_dir.join("#{script_basename}.rb")
|
66
|
+
output_file_path.binwrite(StringsInjector.new(manual_trans_hash).rewrite(script, Prism.parse(script).value))
|
67
|
+
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Injected #{Utils::RESET_COLOR}#{output_file_path}\n" if $global_options[:verbose]
|
68
|
+
end
|
69
|
+
end
|
78
70
|
end
|
79
71
|
end
|
80
72
|
|
data/lib/R3EXS/json_rvdata2.rb
CHANGED
@@ -1,105 +1,115 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'zlib'
|
4
|
-
require_relative 'utils'
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# @param
|
12
|
-
# @param
|
13
|
-
#
|
14
|
-
# @
|
15
|
-
#
|
16
|
-
#
|
17
|
-
# @
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
print "#{Utils::ESCAPE}#{Utils::
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'zlib'
|
4
|
+
require_relative 'utils'
|
5
|
+
|
6
|
+
module R3EXS
|
7
|
+
|
8
|
+
# 将指定目录下的所有JSON文件转换为 rvdata2 文件
|
9
|
+
#
|
10
|
+
# @param [Pathname] target_dir 目标目录
|
11
|
+
# @param [Pathname] output_dir 输出目录
|
12
|
+
# @param [Pathname] original_dir 原始 rvdata2 文件目录
|
13
|
+
# @param [Boolean] complete 是否完全转换
|
14
|
+
# @param [Boolean] with_scripts 是否转换Scripts
|
15
|
+
#
|
16
|
+
# @raise [RPGJsonFileError] json 文件不是 RPG 模块中的对象
|
17
|
+
# @raise [R3EXSJsonFileError] json 文件不是 R3EXS 模块中的对象
|
18
|
+
# @raise [Rvdata2FileError] 原始 rvdata2 文件可能损坏
|
19
|
+
# @raise [JsonDirError] target_dir 不存在
|
20
|
+
# @raise [Rvdata2DirError] original_dir 不存在
|
21
|
+
# @raise [ScriptsInfoPathError] Scripts_info.json 文件不存在
|
22
|
+
#
|
23
|
+
# @return [void]
|
24
|
+
def R3EXS.json_rvdata2(target_dir, output_dir, original_dir, complete, with_scripts)
|
25
|
+
# 处理常规的 JSON 文件
|
26
|
+
Utils.all_json_files(target_dir, (complete) ? :RPG : :R3EXS) do |object, file_basename, parent_relative_dir|
|
27
|
+
output_file_path = output_dir.join(parent_relative_dir, "#{file_basename}.rvdata2")
|
28
|
+
if complete
|
29
|
+
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Serializing to #{Utils::RESET_COLOR}#{output_file_path}...\r" if $global_options[:verbose]
|
30
|
+
Utils.object_rvdata2(object, output_file_path)
|
31
|
+
else
|
32
|
+
# 检查 original_dir 是否存在
|
33
|
+
original_dir.exist? or raise Rvdata2DirError.new(original_dir.to_s), "Original rvdata2 directory not found: #{original_dir}"
|
34
|
+
original_file_path = original_dir.join(parent_relative_dir, "#{file_basename}.rvdata2")
|
35
|
+
print "#{Utils::ESCAPE}#{Utils::BLUE_COLOR}Reading and Deserializing #{Utils::RESET_COLOR}#{original_file_path}...\r" if $global_options[:verbose]
|
36
|
+
original_object = Marshal.load(original_file_path.binread)
|
37
|
+
|
38
|
+
# 这里的类型检查要用紧凑模式,因为 rvdata2 文件中可能存在 nil 元素,必须忽略
|
39
|
+
begin
|
40
|
+
Utils.check_type(original_object, file_basename, true, :RPG)
|
41
|
+
rescue RPGTypeError
|
42
|
+
raise Rvdata2FileError.new(original_file_path.to_s), "Invalid rvdata2 file: #{original_file_path}"
|
43
|
+
end
|
44
|
+
|
45
|
+
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Serializing to #{Utils::RESET_COLOR}#{output_file_path}...\r" if $global_options[:verbose]
|
46
|
+
|
47
|
+
# 根据是否为数组进行不同的处理
|
48
|
+
if object.is_a?(Array)
|
49
|
+
object.each do |obj|
|
50
|
+
obj.inject_to(original_object[obj.index])
|
51
|
+
end
|
52
|
+
else
|
53
|
+
object.inject_to(original_object)
|
54
|
+
end
|
55
|
+
Utils.object_rvdata2(original_object, output_file_path)
|
56
|
+
end
|
57
|
+
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Serialized #{Utils::RESET_COLOR}#{output_file_path}\n" if $global_options[:verbose]
|
58
|
+
end
|
59
|
+
|
60
|
+
# 处理 CommonEvent_\d{5}.json 文件
|
61
|
+
Utils.all_commonevent_json_files(target_dir, (complete) ? :RPG : :R3EXS) do |commonevents, _, parent_relative_dir|
|
62
|
+
output_file_path = output_dir.join(parent_relative_dir.parent, 'CommonEvents.rvdata2')
|
63
|
+
if complete
|
64
|
+
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Serializing to #{Utils::RESET_COLOR}#{output_file_path}...\r" if $global_options[:verbose]
|
65
|
+
Utils.object_rvdata2(commonevents, output_file_path)
|
66
|
+
else
|
67
|
+
# 检查 original_dir 是否存在
|
68
|
+
original_dir.exist? or raise Rvdata2DirError.new(original_dir.to_s), "Original rvdata2 directory not found: #{original_dir}"
|
69
|
+
original_file_path = original_dir.join(parent_relative_dir.parent, 'CommonEvents.rvdata2')
|
70
|
+
print "#{Utils::ESCAPE}#{Utils::BLUE_COLOR}Reading and Deserializing #{Utils::RESET_COLOR}#{original_file_path}...\r" if $global_options[:verbose]
|
71
|
+
original_object = Marshal.load(original_file_path.binread)
|
72
|
+
|
73
|
+
# 这里的类型检查要用紧凑模式,因为 rvdata2 文件中可能存在 nil 元素,必须忽略
|
74
|
+
begin
|
75
|
+
Utils.check_type(original_object, 'CommonEvents', true, :RPG)
|
76
|
+
rescue RPGTypeError
|
77
|
+
raise Rvdata2FileError.new(original_file_path.to_s), "Invalid rvdata2 file: #{original_file_path}"
|
78
|
+
end
|
79
|
+
|
80
|
+
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Serializing to #{Utils::RESET_COLOR}#{output_file_path}...\r" if $global_options[:verbose]
|
81
|
+
|
82
|
+
commonevents.each do |commonevent|
|
83
|
+
commonevent.inject_to(original_object[commonevent.index])
|
84
|
+
end
|
85
|
+
|
86
|
+
Utils.object_rvdata2(original_object, output_file_path)
|
87
|
+
end
|
88
|
+
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Serialized #{Utils::RESET_COLOR}#{output_file_path}\n" if $global_options[:verbose]
|
89
|
+
end
|
90
|
+
|
91
|
+
# 处理 \d{5}.rb 文件
|
92
|
+
if with_scripts
|
93
|
+
Utils.all_rb_files(target_dir) do |scripts, _, parent_relative_dir|
|
94
|
+
output_file_path = output_dir.join(parent_relative_dir.parent, 'Scripts.rvdata2')
|
95
|
+
script_info_file_path = target_dir.join(parent_relative_dir, 'Scripts_info.json')
|
96
|
+
script_info_file_path.exist? or raise ScriptsInfoPathError.new(script_info_file_path.to_s), "Scripts_info.json not found: #{script_info_file_path}"
|
97
|
+
|
98
|
+
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Serializing to #{Utils::RESET_COLOR}#{output_file_path}...\r" if $global_options[:verbose]
|
99
|
+
|
100
|
+
print "#{Utils::ESCAPE}#{Utils::YELLOW_COLOR}Reading from #{Utils::RESET_COLOR}#{script_info_file_path}...\r" if $global_options[:verbose]
|
101
|
+
scripts_info_array = Oj.load_file(script_info_file_path.to_s)
|
102
|
+
|
103
|
+
output_scripts_array = []
|
104
|
+
scripts_info_array.each do |script_info|
|
105
|
+
index = script_info[:index]
|
106
|
+
script = scripts[index]
|
107
|
+
output_scripts_array << [114514, script_info[:name], Zlib::Deflate.deflate(script)]
|
108
|
+
end
|
109
|
+
Utils.object_rvdata2(output_scripts_array, output_file_path)
|
110
|
+
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Serialized #{Utils::RESET_COLOR}#{output_file_path}\n" if $global_options[:verbose]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
105
115
|
end
|
data/lib/R3EXS/rvdata2_json.rb
CHANGED
@@ -2,38 +2,70 @@
|
|
2
2
|
|
3
3
|
require 'zlib'
|
4
4
|
require_relative 'utils'
|
5
|
-
require_relative 'RGSS3_R3EXS'
|
6
5
|
|
7
6
|
module R3EXS
|
8
7
|
|
9
8
|
# 将 Script 对象数组序列化为 Ruby 源码
|
10
9
|
#
|
11
|
-
# @param scripts [Array<
|
12
|
-
# @param output_dir [
|
10
|
+
# @param scripts [Array<Object>] 待转换的 Script 对象数组
|
11
|
+
# @param output_dir [Pathname] 输出目录
|
12
|
+
#
|
13
13
|
# @return [void]
|
14
14
|
def R3EXS.scripts_rb(scripts, output_dir)
|
15
|
-
|
16
|
-
full_dir =
|
17
|
-
|
15
|
+
output_dir.mkpath unless output_dir.exist?
|
16
|
+
full_dir = output_dir.join('Scripts')
|
17
|
+
full_dir.mkdir unless full_dir.exist?
|
18
18
|
|
19
19
|
scripts_info_array = []
|
20
20
|
scripts.each_with_index do |script, index|
|
21
21
|
next if script.nil?
|
22
22
|
scripts_info_array << { index: index, name: script[1] }
|
23
|
-
script_file_path =
|
23
|
+
script_file_path = full_dir.join("#{format('%03d', index)}.rb")
|
24
24
|
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Serializing to #{Utils::RESET_COLOR}#{script_file_path}...\r" if $global_options[:verbose]
|
25
|
-
|
25
|
+
script_file_path.write(Zlib::Inflate.inflate(script[2]).encode(universal_newline: true))
|
26
|
+
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Serialized #{Utils::RESET_COLOR}#{script_file_path}\n" if $global_options[:verbose]
|
26
27
|
end
|
27
28
|
|
28
|
-
script_info_file_path =
|
29
|
+
script_info_file_path = full_dir.join('Scripts_info.json')
|
29
30
|
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Serializing to #{Utils::RESET_COLOR}#{script_info_file_path}\r" if $global_options[:verbose]
|
30
31
|
Utils.object_json(scripts_info_array, script_info_file_path)
|
32
|
+
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Serialized #{Utils::RESET_COLOR}#{script_info_file_path}\n" if $global_options[:verbose]
|
33
|
+
end
|
34
|
+
|
35
|
+
# 将 CommonEvents 对象数组序列化为分开的 JSON 文件
|
36
|
+
#
|
37
|
+
# @param commonevents [Array<Object>] 待转换的 CommonEvents 对象数组
|
38
|
+
# @param output_dir [Pathname] 输出目录
|
39
|
+
# @param complete [Boolean] 是否序列化所有内容
|
40
|
+
# @param with_notes [Boolean] 是否包含备注
|
41
|
+
#
|
42
|
+
# @return [void]
|
43
|
+
def R3EXS.commonevents_json(commonevents, output_dir, complete, with_notes)
|
44
|
+
full_dir = output_dir.join('CommonEvents')
|
45
|
+
|
46
|
+
if complete
|
47
|
+
commonevents.each_with_index do |commonevent, index|
|
48
|
+
commonevent_file_path = full_dir.join("#{format('CommonEvent_%05d', index)}.json")
|
49
|
+
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Serializing to #{Utils::RESET_COLOR}#{commonevent_file_path}...\r" if $global_options[:verbose]
|
50
|
+
Utils.object_json(commonevent, commonevent_file_path)
|
51
|
+
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Serialized #{Utils::RESET_COLOR}#{commonevent_file_path}\n" if $global_options[:verbose]
|
52
|
+
end
|
53
|
+
else
|
54
|
+
commonevents = Utils.rpg_r3exs(commonevents, 'CommonEvents', with_notes)
|
55
|
+
commonevents.each do |commonevent|
|
56
|
+
index = commonevent.index
|
57
|
+
commonevent_file_path = full_dir.join("#{format('CommonEvent_%05d', index)}.json")
|
58
|
+
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Serializing to #{Utils::RESET_COLOR}#{commonevent_file_path}...\r" if $global_options[:verbose]
|
59
|
+
Utils.object_json(commonevent, commonevent_file_path)
|
60
|
+
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Serialized #{Utils::RESET_COLOR}#{commonevent_file_path}\n" if $global_options[:verbose]
|
61
|
+
end
|
62
|
+
end
|
31
63
|
end
|
32
64
|
|
33
65
|
# 将指定目录下的所有 rvdata2 文件序列化为 JSON 格式
|
34
66
|
#
|
35
|
-
# @param target_dir [
|
36
|
-
# @param output_dir [
|
67
|
+
# @param target_dir [Pathname] 目标目录
|
68
|
+
# @param output_dir [Pathname] 输出目录
|
37
69
|
# @param complete [Boolean] 是否序列化所有内容
|
38
70
|
# @param with_scripts [Boolean] 是否包含脚本
|
39
71
|
# @param with_notes [Boolean] 是否包含备注
|
@@ -43,21 +75,20 @@ module R3EXS
|
|
43
75
|
#
|
44
76
|
# @return [void]
|
45
77
|
def R3EXS.rvdata2_json(target_dir, output_dir, complete, with_scripts, with_notes)
|
46
|
-
|
47
|
-
Utils.all_rvdata2_files(target_dir) do |object, file_basename|
|
78
|
+
Utils.all_rvdata2_files(target_dir) do |object, file_basename, parent_relative_dir|
|
48
79
|
if file_basename == 'Scripts'
|
49
|
-
|
50
|
-
|
51
|
-
|
80
|
+
scripts_rb(object, output_dir.join(parent_relative_dir)) if with_scripts
|
81
|
+
elsif file_basename == 'CommonEvents'
|
82
|
+
commonevents_json(object, output_dir.join(parent_relative_dir), complete, with_notes)
|
52
83
|
else
|
53
|
-
file_path =
|
84
|
+
file_path = output_dir.join(parent_relative_dir, "#{file_basename}.json")
|
54
85
|
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Serializing to #{Utils::RESET_COLOR}#{file_path}...\r" if $global_options[:verbose]
|
55
86
|
if complete
|
56
87
|
Utils.object_json(object, file_path)
|
57
88
|
else
|
58
89
|
Utils.object_json(Utils.rpg_r3exs(object, file_basename, with_notes), file_path)
|
59
90
|
end
|
60
|
-
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Serialized #{Utils::RESET_COLOR}#{
|
91
|
+
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Serialized #{Utils::RESET_COLOR}#{file_path}\n" if $global_options[:verbose]
|
61
92
|
end
|
62
93
|
end
|
63
94
|
end
|