rmxp_extractor 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +35 -0
- data/lib/rmxp_extractor.rb +11 -1
- data/lib/rmxp_extractor/data_export.rb +1 -1
- data/lib/rmxp_extractor/data_import.rb +1 -1
- data/lib/rmxp_extractor/script_handler.rb +72 -70
- data/lib/rmxp_extractor/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a06d39585029a2d60d37b6dc116eafeec877f999ec43719026f576251f434be
|
4
|
+
data.tar.gz: f169f1439ac9ce51dd91ca35bce4d50411ba75376ade0572d2a7e94b8271e3f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95ef3b0cc78c766b2189b8e9dc1da54c979df5a1283eda3c86b9ec9401516c830a7f9fbf98a99215ea104e1bcad82b4dd7580b623f6dca2e0608fcf8f4b400f1
|
7
|
+
data.tar.gz: acb5e24a72277e1ec82b98de2f05b98a9f4a12721a3244982e4c769e7d1a1482b9341a1ed9cbdc68b31fe025b4c951be0f546118e30c60a3da61b1d504b0fb83
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rmxp_extractor (1.2.2)
|
5
|
+
fileutils
|
6
|
+
json
|
7
|
+
oj
|
8
|
+
pathname
|
9
|
+
ruby-progressbar
|
10
|
+
zlib
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
fileutils (1.5.0)
|
16
|
+
json (2.5.1)
|
17
|
+
oj (3.11.5)
|
18
|
+
pathname (0.1.0)
|
19
|
+
ruby-progressbar (1.11.0)
|
20
|
+
zlib (1.1.0)
|
21
|
+
|
22
|
+
PLATFORMS
|
23
|
+
x64-mingw32
|
24
|
+
|
25
|
+
DEPENDENCIES
|
26
|
+
fileutils
|
27
|
+
json
|
28
|
+
oj
|
29
|
+
pathname
|
30
|
+
rmxp_extractor!
|
31
|
+
ruby-progressbar
|
32
|
+
zlib
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
2.1.4
|
data/lib/rmxp_extractor.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module RMXPExtractor
|
2
2
|
require "rmxp_extractor/data_export"
|
3
3
|
require "rmxp_extractor/data_import"
|
4
|
+
require "rmxp_extractor/script_handler"
|
4
5
|
require "rmxp_extractor/version"
|
5
6
|
|
6
7
|
def self.usage
|
7
|
-
STDERR.puts "usage:
|
8
|
+
STDERR.puts "usage: rmxp_extractor import|export|scripts"
|
8
9
|
exit 1
|
9
10
|
end
|
10
11
|
|
@@ -15,6 +16,15 @@ module RMXPExtractor
|
|
15
16
|
RMXPExtractor.import
|
16
17
|
elsif type[0] == "export"
|
17
18
|
RMXPExtractor.export
|
19
|
+
elsif type[0] == "scripts"
|
20
|
+
if type[3] == "x"
|
21
|
+
RMXPExtractor.rpgscript(type[2], type[1], true)
|
22
|
+
elsif type.length < 3 || type.length > 4
|
23
|
+
STDERR.puts "usage: rmxp_extractor scripts scripts_dir game_dir [x]"
|
24
|
+
exit 1
|
25
|
+
elsif type[3] == nil
|
26
|
+
RMXPExtractor.rpgscript(type[2], type[1], false)
|
27
|
+
end
|
18
28
|
else
|
19
29
|
RMXPExtractor.usage
|
20
30
|
end
|
@@ -1,95 +1,97 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
require "zlib"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
module RMXPExtractor
|
5
|
+
def self.rpgscript(game_dir, scripts_dir, extract = false)
|
6
|
+
# Determine version of game engine
|
7
|
+
game_data_dir = File.join(game_dir, "Data")
|
8
|
+
unless Dir.exist? game_data_dir
|
9
|
+
STDERR.puts "error: #{game_dir} does not have a Data subdirectory"
|
10
|
+
exit 1
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
target_path = nil
|
14
|
+
Dir.entries(game_data_dir).each do |e|
|
15
|
+
ext = File.extname(e)
|
16
|
+
if ext =~ /\.r[xv]data2?/
|
17
|
+
target_path = File.join(game_data_dir, "xScripts" + ext)
|
18
|
+
break
|
19
|
+
end
|
18
20
|
end
|
19
|
-
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
unless target_path
|
23
|
+
STDERR.puts "warning: could not determine game engine version, assuming XP"
|
24
|
+
target_path = File.join(game_data_dir, "xScripts.rxdata")
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
# Generate path of script list
|
28
|
+
list_path = File.join(scripts_dir, "_scripts.txt")
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
if extract
|
31
|
+
# Make sure the script directory exists
|
32
|
+
Dir.mkdir(scripts_dir) unless Dir.exists? scripts_dir
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
# Keep track of names of scripts extracted so we can warn about duplicates
|
35
|
+
names = Hash.new(0)
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
# Read scripts
|
38
|
+
File.open(target_path, "rb") do |fin|
|
39
|
+
File.open(list_path, "w") do |flist|
|
40
|
+
Marshal.load(fin).each_with_index do |script, index|
|
41
|
+
name = script[1].strip
|
42
|
+
data = Zlib::Inflate.inflate(script[2]).rstrip
|
43
|
+
.gsub(/[ \t]*(?:$|\r\n?)/, "\n")
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
# Make sure this file doesn't already exist
|
46
|
+
if name.empty?
|
47
|
+
if data.empty? || data == "\n"
|
48
|
+
flist.puts
|
49
|
+
next
|
50
|
+
else
|
51
|
+
name = "UNTITLED"
|
52
|
+
end
|
51
53
|
end
|
52
|
-
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
names[name] += 1
|
56
|
+
if names[name] > 1
|
57
|
+
name << " (#{names[name]})"
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
if data.empty? || data == "\n"
|
61
|
+
# Treat this like a comment
|
62
|
+
flist.puts("# " + name)
|
63
|
+
else
|
64
|
+
# Write to file order list
|
65
|
+
flist.puts(name)
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
# Write script file
|
68
|
+
File.open(File.join(scripts_dir, name + ".rb"), "wb") do |fout|
|
69
|
+
fout.write(data)
|
70
|
+
end
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
72
74
|
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
scripts = []
|
75
|
+
#puts "#{target_path} extracted."
|
76
|
+
else
|
77
|
+
# Write scripts
|
78
|
+
scripts = []
|
78
79
|
|
79
|
-
|
80
|
-
|
81
|
-
|
80
|
+
IO.foreach(list_path) do |name|
|
81
|
+
name.strip!
|
82
|
+
next if name.empty? || name.start_with?("#")
|
82
83
|
|
83
|
-
|
84
|
+
data = File.read(File.join(scripts_dir, name + ".rb")).rstrip.gsub("\n", "\r\n")
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
86
|
+
script = Array.new(3)
|
87
|
+
script[0] = 0
|
88
|
+
script[1] = name
|
89
|
+
script[2] = Zlib.deflate(data)
|
90
|
+
scripts << script
|
91
|
+
end
|
91
92
|
|
92
|
-
|
93
|
-
|
93
|
+
File.open(target_path, "wb") { |f| f.write(Marshal.dump(scripts)) }
|
94
|
+
#puts "#{target_path} written."
|
95
|
+
end
|
94
96
|
end
|
95
97
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmxp_extractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Speak2Erase
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -104,6 +104,7 @@ extra_rdoc_files: []
|
|
104
104
|
files:
|
105
105
|
- CODE_OF_CONDUCT.md
|
106
106
|
- Gemfile
|
107
|
+
- Gemfile.lock
|
107
108
|
- LICENSE.txt
|
108
109
|
- README.md
|
109
110
|
- Rakefile
|