rmxp_extractor 1.2.1 → 1.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4e501c93220e4e3cb8f1ab35e0726259e1ebedb18cf17e1a7eea332f407e41f
4
- data.tar.gz: cf23a4a87ed6263ea249ffb16f8a220719190dbcd7fad0baad9a672bd384d9ed
3
+ metadata.gz: 5a06d39585029a2d60d37b6dc116eafeec877f999ec43719026f576251f434be
4
+ data.tar.gz: f169f1439ac9ce51dd91ca35bce4d50411ba75376ade0572d2a7e94b8271e3f2
5
5
  SHA512:
6
- metadata.gz: 42f8238ed15d307215c3e1e43625bae8a24df27d6ac0045981d36e72c313d75dd21414e7c3e22edf891947d3c088b7572d6f4f7e54fb41e90d6d717692b84edf
7
- data.tar.gz: 35882711f5159359d4999d3b5dcb40df122e67631d4d91a6f3afee4ecdb43d5019a0108a2e9b501a82bb3d6f01be8cb3f690391e2bc4f6014977034eae3d2882
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
@@ -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: data-extractor.rb import|export"
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
@@ -35,7 +35,7 @@ module RMXPExtractor
35
35
  #puts name.to_s
36
36
  case name.to_s
37
37
  when "xScripts"
38
- rpgscript("./", "./Scripts", true)
38
+ RMXPExtractor.rpgscript("./", "./Scripts", true)
39
39
  content[:version] = VERSION
40
40
  when "Scripts"
41
41
  content[:version] = VERSION
@@ -37,7 +37,7 @@ module RMXPExtractor
37
37
 
38
38
  case name.to_s
39
39
  when "xScripts"
40
- rpgscript("./", "./Scripts")
40
+ RMXPExtractor.rpgscript("./", "./Scripts")
41
41
  progress.increment
42
42
  return
43
43
  when "Scripts"
@@ -1,95 +1,97 @@
1
1
  #!/usr/bin/ruby
2
2
  require "zlib"
3
3
 
4
- def rpgscript(game_dir, scripts_dir, extract = false)
5
- # Determine version of game engine
6
- game_data_dir = File.join(game_dir, "Data")
7
- unless Dir.exist? game_data_dir
8
- STDERR.puts "error: #{game_dir} does not have a Data subdirectory"
9
- exit 1
10
- end
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
- target_path = nil
13
- Dir.entries(game_data_dir).each do |e|
14
- ext = File.extname(e)
15
- if ext =~ /\.r[xv]data2?/
16
- target_path = File.join(game_data_dir, "xScripts" + ext)
17
- break
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
- unless target_path
22
- STDERR.puts "warning: could not determine game engine version, assuming XP"
23
- target_path = File.join(game_data_dir, "xScripts.rxdata")
24
- end
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
- # Generate path of script list
27
- list_path = File.join(scripts_dir, "_scripts.txt")
27
+ # Generate path of script list
28
+ list_path = File.join(scripts_dir, "_scripts.txt")
28
29
 
29
- if extract
30
- # Make sure the script directory exists
31
- Dir.mkdir(scripts_dir) unless Dir.exists? scripts_dir
30
+ if extract
31
+ # Make sure the script directory exists
32
+ Dir.mkdir(scripts_dir) unless Dir.exists? scripts_dir
32
33
 
33
- # Keep track of names of scripts extracted so we can warn about duplicates
34
- names = Hash.new(0)
34
+ # Keep track of names of scripts extracted so we can warn about duplicates
35
+ names = Hash.new(0)
35
36
 
36
- # Read scripts
37
- File.open(target_path, "rb") do |fin|
38
- File.open(list_path, "w") do |flist|
39
- Marshal.load(fin).each_with_index do |script, index|
40
- name = script[1].strip
41
- data = Zlib::Inflate.inflate(script[2]).rstrip
42
- .gsub(/[ \t]*(?:$|\r\n?)/, "\n")
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
- # Make sure this file doesn't already exist
45
- if name.empty?
46
- if data.empty? || data == "\n"
47
- flist.puts
48
- next
49
- else
50
- name = "UNTITLED"
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
- names[name] += 1
55
- if names[name] > 1
56
- name << " (#{names[name]})"
57
- end
55
+ names[name] += 1
56
+ if names[name] > 1
57
+ name << " (#{names[name]})"
58
+ end
58
59
 
59
- if data.empty? || data == "\n"
60
- # Treat this like a comment
61
- flist.puts("# " + name)
62
- else
63
- # Write to file order list
64
- flist.puts(name)
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
- # Write script file
67
- File.open(File.join(scripts_dir, name + ".rb"), "wb") do |fout|
68
- fout.write(data)
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
- end
74
- #puts "#{target_path} extracted."
75
- else
76
- # Write scripts
77
- scripts = []
75
+ #puts "#{target_path} extracted."
76
+ else
77
+ # Write scripts
78
+ scripts = []
78
79
 
79
- IO.foreach(list_path) do |name|
80
- name.strip!
81
- next if name.empty? || name.start_with?("#")
80
+ IO.foreach(list_path) do |name|
81
+ name.strip!
82
+ next if name.empty? || name.start_with?("#")
82
83
 
83
- data = File.read(File.join(scripts_dir, name + ".rb")).rstrip.gsub("\n", "\r\n")
84
+ data = File.read(File.join(scripts_dir, name + ".rb")).rstrip.gsub("\n", "\r\n")
84
85
 
85
- script = Array.new(3)
86
- script[0] = 0
87
- script[1] = name
88
- script[2] = Zlib.deflate(data)
89
- scripts << script
90
- end
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
- File.open(target_path, "wb") { |f| f.write(Marshal.dump(scripts)) }
93
- #puts "#{target_path} written."
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
@@ -1,3 +1,3 @@
1
1
  module RMXPExtractor
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
  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.1
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-25 00:00:00.000000000 Z
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