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/lib/R3EXS/rvdata2_json.rb
CHANGED
|
@@ -2,95 +2,91 @@
|
|
|
2
2
|
|
|
3
3
|
require 'zlib'
|
|
4
4
|
require_relative 'utils'
|
|
5
|
+
require_relative 'logger'
|
|
5
6
|
|
|
6
7
|
module R3EXS
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
script_info_file_path = full_dir.join('Scripts_info.json')
|
|
30
|
-
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Serializing to #{Utils::RESET_COLOR}#{script_info_file_path}\r" if $global_options[:verbose]
|
|
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]
|
|
8
|
+
# 将 CommonEvents 对象数组序列化为分开的 JSON 文件
|
|
9
|
+
#
|
|
10
|
+
# @param commonevents [Array<RPG::CommonEvent>] CommonEvents 对象数组
|
|
11
|
+
# @param output_dir [Pathname] 输出目录
|
|
12
|
+
# @param complete [Boolean] 是否序列化所有内容
|
|
13
|
+
#
|
|
14
|
+
# @return [void]
|
|
15
|
+
def self.commonevents_json(commonevents, output_dir, complete)
|
|
16
|
+
if complete
|
|
17
|
+
commonevents.each_with_index do |commonevent, index|
|
|
18
|
+
file_path = output_dir.join("#{format('CommonEvent_%05d', index)}.json")
|
|
19
|
+
Utils.object_json(commonevent, file_path)
|
|
20
|
+
Logger.debug("Serialize #{file_path}")
|
|
21
|
+
end
|
|
22
|
+
else
|
|
23
|
+
commonevents = Utils.rpg_r3exs(commonevents, R3EXS::CommonEvent)
|
|
24
|
+
commonevents.each do |commonevent|
|
|
25
|
+
file_path = output_dir.join("#{format('CommonEvent_%05d', commonevent.index)}.json")
|
|
26
|
+
Utils.object_json(commonevent, file_path)
|
|
27
|
+
Logger.debug("Serialize #{file_path}")
|
|
28
|
+
end
|
|
33
29
|
end
|
|
30
|
+
end
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
# 将 Script 对象数组序列化为分开的 Ruby 源码
|
|
33
|
+
#
|
|
34
|
+
# @param scripts [Array<Object>] Script 对象数组
|
|
35
|
+
# @param output_dir [Pathname] 输出目录
|
|
36
|
+
#
|
|
37
|
+
# @return [void]
|
|
38
|
+
def self.scripts_rb(scripts, output_dir)
|
|
39
|
+
scripts_info = []
|
|
40
|
+
script_info_file_path = output_dir.join('Scripts_info.json')
|
|
41
|
+
scripts.each_with_index do |script, index|
|
|
42
|
+
next if script.nil?
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
44
|
+
scripts_info << { index: index, name: script[1] }
|
|
45
|
+
file_path = output_dir.join("#{format('Script_%03d', index)}.rb")
|
|
46
|
+
Utils.script_rb_compressing(script[2], file_path)
|
|
47
|
+
Logger.debug("Serialize #{file_path}")
|
|
63
48
|
end
|
|
49
|
+
Utils.object_json(scripts_info, script_info_file_path)
|
|
50
|
+
Logger.debug("Serialize #{script_info_file_path}")
|
|
51
|
+
end
|
|
64
52
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Utils.all_rvdata2_files(target_dir) do |object, file_basename, parent_relative_dir|
|
|
79
|
-
if file_basename == 'Scripts'
|
|
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)
|
|
83
|
-
else
|
|
84
|
-
file_path = output_dir.join(parent_relative_dir, "#{file_basename}.json")
|
|
85
|
-
print "#{Utils::ESCAPE}#{Utils::MAGENTA_COLOR}Serializing to #{Utils::RESET_COLOR}#{file_path}...\r" if $global_options[:verbose]
|
|
86
|
-
if complete
|
|
87
|
-
Utils.object_json(object, file_path)
|
|
88
|
-
else
|
|
89
|
-
Utils.object_json(Utils.rpg_r3exs(object, file_basename, with_notes), file_path)
|
|
90
|
-
end
|
|
91
|
-
print "#{Utils::ESCAPE}#{Utils::GREEN_COLOR}Serialized #{Utils::RESET_COLOR}#{file_path}\n" if $global_options[:verbose]
|
|
92
|
-
end
|
|
93
|
-
end
|
|
53
|
+
# 将常规对象数组序列化为 JSON 文件
|
|
54
|
+
#
|
|
55
|
+
# @param obj [Array<Object>] 常规对象数组
|
|
56
|
+
# @param klass [::Class] 对应 R3EXS 模块的类
|
|
57
|
+
# @param file_path [Pathname] 输出文件路径
|
|
58
|
+
# @param complete [Boolean] 是否序列化所有内容
|
|
59
|
+
#
|
|
60
|
+
# @return [void]
|
|
61
|
+
def self.regular_json(obj, klass, file_path, complete)
|
|
62
|
+
if complete
|
|
63
|
+
Utils.object_json(obj, file_path)
|
|
64
|
+
else
|
|
65
|
+
Utils.object_json(Utils.rpg_r3exs(obj, klass), file_path)
|
|
94
66
|
end
|
|
67
|
+
Logger.debug("Serialize #{file_path}")
|
|
68
|
+
end
|
|
95
69
|
|
|
96
|
-
|
|
70
|
+
# 将指定目录下的所有 rvdata2 文件序列化为 JSON 格式
|
|
71
|
+
#
|
|
72
|
+
# @param target_dir [Pathname] 目标目录
|
|
73
|
+
# @param output_dir [Pathname] 输出目录
|
|
74
|
+
# @param complete [Boolean] 是否序列化所有内容
|
|
75
|
+
# @param with_scripts [Boolean] 是否包含脚本
|
|
76
|
+
#
|
|
77
|
+
# @raise [Rvdata2DirError] target_dir 不存在
|
|
78
|
+
#
|
|
79
|
+
# @return [void]
|
|
80
|
+
def self.rvdata2_json(target_dir, output_dir, complete, with_scripts)
|
|
81
|
+
Utils.all_rvdata2_files(target_dir) do |obj, klass, file_basename, rvdata2_path|
|
|
82
|
+
file_path = output_dir.join(rvdata2_path.relative_path_from(target_dir)).sub_ext('.json')
|
|
83
|
+
if file_basename.to_s == 'CommonEvents'
|
|
84
|
+
commonevents_json(obj, file_path.sub_ext(''), complete)
|
|
85
|
+
elsif file_basename.to_s == 'Scripts'
|
|
86
|
+
scripts_rb(obj, file_path.sub_ext('')) if with_scripts
|
|
87
|
+
else
|
|
88
|
+
regular_json(obj, klass, file_path, complete)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|