rvpacker-txt 1.5.2 → 1.7.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/README.md +5 -4
- data/bin/rvpacker-txt +37 -33
- data/lib/classes.rb +63 -1
- data/lib/read.rb +312 -229
- data/lib/write.rb +347 -279
- data/rvpacker-txt.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b723edca892d423ad6b4dcd7800a904244fddfa8e7a68bfc823db6be676c0c82
|
|
4
|
+
data.tar.gz: 2acde66ea3d5f6643ed0e5a81ab12f66ec066952f8bc797d13337d0499db764d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7ba34d8ca913bc93073b322cf3c19d2492438e57cac203161df3c9332176f7b4078e8f229607986a109f4baa3d72470c6491b87825e6f0baf86d927bd3fc4209
|
|
7
|
+
data.tar.gz: 3e3f67a08e881777ea7057d7545253262746d9875f3bef1c2bd7ac21db52f4b7862881223405ca304dc794b369402f4726747a73bd984e2b11c3ac535733ca28
|
data/README.md
CHANGED
|
@@ -31,13 +31,14 @@ COMMANDS:
|
|
|
31
31
|
OPTIONS:
|
|
32
32
|
-i, --input-dir DIR Input directory of RPG Maker project
|
|
33
33
|
-o, --output-dir DIR Output directory of parsed/written files
|
|
34
|
-
--disable-processing FILES Don't process specified files (maps, other, system,
|
|
34
|
+
--disable-processing FILES Don't process specified files (maps, other, system, scripts)
|
|
35
35
|
-s, --shuffle NUM Shuffle level (1: lines, 2: lines and words)
|
|
36
|
-
--
|
|
36
|
+
--disable-custom-processing Disables built-in custom parsing/writing for some games
|
|
37
37
|
-l, --log Log information while processing
|
|
38
|
-
-f, --force Force rewrite all files. Cannot be used with --append
|
|
38
|
+
-f, --force Force rewrite all files. Cannot be used with --append
|
|
39
39
|
USE WITH CAUTION!
|
|
40
|
-
-a, --append When you update the rvpacker-txt, you probably should re-read
|
|
40
|
+
-a, --append When you update the rvpacker-txt, you probably should re-read
|
|
41
|
+
your files with append, as some new text might be added to parser
|
|
41
42
|
Cannot be used with --force
|
|
42
43
|
-h, --help Show help message
|
|
43
44
|
```
|
data/bin/rvpacker-txt
CHANGED
|
@@ -5,11 +5,9 @@ require 'optparse'
|
|
|
5
5
|
require 'fileutils'
|
|
6
6
|
|
|
7
7
|
require 'classes'
|
|
8
|
-
require 'read'
|
|
9
|
-
require 'write'
|
|
10
8
|
|
|
11
9
|
def self.parse_options
|
|
12
|
-
options = { disable_processing:
|
|
10
|
+
options = { disable_processing: {}, input_dir: './', output_dir: './', shuffle_level: 0 }
|
|
13
11
|
|
|
14
12
|
OptionParser.new do |cmd|
|
|
15
13
|
cmd.banner = "This tool allows to parse RPG Maker project to .txt files and back.\n\nUsage: rvpacker-txt COMMAND [options]\n\nCOMMANDS:\n read - Parses RPG Maker game files to .txt\n write - Writes parsed files back to their initial form\nOPTIONS:\n"
|
|
@@ -23,10 +21,11 @@ def self.parse_options
|
|
|
23
21
|
options[:output_dir] = File.exist?(dir) ? File.realpath(dir) : (raise "#{dir} not found")
|
|
24
22
|
end
|
|
25
23
|
|
|
26
|
-
cmd.on('--disable-processing FILES', Array, "Don't process specified files (maps, other, system,
|
|
24
|
+
cmd.on('--disable-processing FILES', Array, "Don't process specified files (maps, other, system, scripts)") do |files|
|
|
27
25
|
files.each do |file|
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
files = %w[maps other system scripts]
|
|
27
|
+
index = files.index(file)
|
|
28
|
+
options[:disable_processing][files[index]] = true if index
|
|
30
29
|
end
|
|
31
30
|
end
|
|
32
31
|
|
|
@@ -46,7 +45,8 @@ def self.parse_options
|
|
|
46
45
|
options[:force] = true
|
|
47
46
|
end
|
|
48
47
|
|
|
49
|
-
cmd.on('-a', '--append', 'When you update the rvpacker-txt, you probably should re-read',
|
|
48
|
+
cmd.on('-a', '--append', 'When you update the rvpacker-txt, you probably should re-read',
|
|
49
|
+
'your files with append, as some new text might be added to parser', 'Cannot be used with --force') do
|
|
50
50
|
raise '--append cannot be used beside --force.' if options[:force]
|
|
51
51
|
options[:append] = true
|
|
52
52
|
end
|
|
@@ -64,6 +64,8 @@ def self.parse_options
|
|
|
64
64
|
options
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
+
# @param [String] system_file_path
|
|
68
|
+
# @return [String, nil]
|
|
67
69
|
def self.get_game_type(system_file_path)
|
|
68
70
|
object = Marshal.load(File.binread(system_file_path))
|
|
69
71
|
game_title = object.instance_variable_get(:@game_title).to_s.downcase
|
|
@@ -82,26 +84,22 @@ disable_processing = options[:disable_processing]
|
|
|
82
84
|
force = options[:force]
|
|
83
85
|
append = options[:append]
|
|
84
86
|
|
|
85
|
-
extensions = { xp: '
|
|
87
|
+
extensions = { xp: 'rxdata', vx: 'rvdata', ace: 'rvdata2' }
|
|
86
88
|
|
|
87
89
|
original_directory = Dir.glob(File.join(input_dir, '{data,original}'), File::FNM_CASEFOLD).first
|
|
88
90
|
raise '"Data" or "original" directory not found within input directory.' unless original_directory
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
translation_path: File.join(input_dir, 'translation'),
|
|
93
|
-
maps_path: File.join(input_dir, 'translation', 'maps'),
|
|
94
|
-
other_path: File.join(input_dir, 'translation', 'other'),
|
|
95
|
-
output_path: File.join(output_dir, 'output')
|
|
96
|
-
}
|
|
92
|
+
maps_path = File.join(input_dir, 'translation', 'maps')
|
|
93
|
+
other_path = File.join(input_dir, 'translation', 'other')
|
|
97
94
|
|
|
98
|
-
|
|
95
|
+
FileUtils.mkdir_p(maps_path)
|
|
96
|
+
FileUtils.mkdir_p(other_path)
|
|
99
97
|
|
|
100
|
-
engine = extensions.
|
|
101
|
-
symbol if File.exist?(File.join(
|
|
98
|
+
engine = extensions.each do |symbol, extension|
|
|
99
|
+
break symbol if File.exist?(File.join(original_directory, "System.#{extension}"))
|
|
102
100
|
end || (raise "Couldn't determine project engine.")
|
|
103
101
|
|
|
104
|
-
files = Dir.glob("#{
|
|
102
|
+
files = Dir.glob("#{original_directory}/*#{extensions[engine]}")
|
|
105
103
|
|
|
106
104
|
maps_files_paths = []
|
|
107
105
|
other_files_paths = []
|
|
@@ -110,6 +108,7 @@ scripts_file_path = nil
|
|
|
110
108
|
|
|
111
109
|
files.each do |file|
|
|
112
110
|
basename = File.basename(file)
|
|
111
|
+
next unless basename.end_with?(extensions[engine])
|
|
113
112
|
|
|
114
113
|
if basename.start_with?(/Map[0-9]/)
|
|
115
114
|
maps_files_paths.push(file)
|
|
@@ -122,7 +121,7 @@ files.each do |file|
|
|
|
122
121
|
end
|
|
123
122
|
end
|
|
124
123
|
|
|
125
|
-
ini_file_path = File.join(input_dir,
|
|
124
|
+
ini_file_path = File.join(input_dir, 'Game.ini')
|
|
126
125
|
|
|
127
126
|
game_type = disable_custom_processing ? nil : get_game_type(system_file_path)
|
|
128
127
|
|
|
@@ -130,30 +129,35 @@ wait_time = 0
|
|
|
130
129
|
processing_type = if force
|
|
131
130
|
wait_time_start = Time.now
|
|
132
131
|
|
|
133
|
-
puts "WARNING! You
|
|
132
|
+
puts "WARNING! You're about to forcefully rewrite all your translation files, including _trans files.\nIf you really want to do it, make sure you've made a backup of your _trans files, if you made some changes in them already.\nInput 'Y' to continue."
|
|
134
133
|
exit unless gets.chomp == 'Y'
|
|
135
134
|
|
|
136
135
|
wait_time = Time.now - wait_time_start
|
|
137
|
-
|
|
136
|
+
:force
|
|
138
137
|
else
|
|
139
|
-
append ?
|
|
138
|
+
append ? :append : :default
|
|
140
139
|
end
|
|
141
140
|
|
|
142
141
|
puts 'Custom processing for this game is enabled. Use --disable-custom-processing to disable it.' unless game_type.nil?
|
|
143
142
|
|
|
144
143
|
if options[:action] == 'read'
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
require 'read'
|
|
145
|
+
read_map(maps_files_paths, maps_path, logging, game_type, processing_type) unless disable_processing[:maps]
|
|
146
|
+
read_other(other_files_paths, other_path, logging, game_type, processing_type) unless disable_processing[:other]
|
|
147
|
+
read_system(system_file_path, ini_file_path, other_path, logging, processing_type) unless disable_processing[:system]
|
|
148
|
+
read_scripts(scripts_file_path, other_path, logging, processing_type) unless disable_processing[:scripts]
|
|
149
149
|
else
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
150
|
+
require 'write'
|
|
151
|
+
output_path = File.join(output_dir, 'output')
|
|
152
|
+
FileUtils.mkdir_p(output_path)
|
|
153
|
+
|
|
154
|
+
write_map(maps_files_paths, maps_path, output_path, shuffle_level, logging, game_type) unless disable_processing[:maps]
|
|
155
|
+
write_other(other_files_paths, other_path, output_path, shuffle_level, logging, game_type) unless disable_processing[:other]
|
|
156
|
+
write_system(system_file_path, ini_file_path, other_path, output_path, shuffle_level, logging) unless disable_processing[:system]
|
|
157
|
+
write_scripts(scripts_file_path, other_path, output_path, logging) unless disable_processing[:scripts]
|
|
154
158
|
end
|
|
155
159
|
|
|
156
160
|
$wait_time = 0 if $wait_time.nil?
|
|
157
|
-
|
|
161
|
+
elapsed_time = Time.now - start_time - wait_time - $wait_time
|
|
158
162
|
|
|
159
|
-
puts "Done in #{
|
|
163
|
+
puts "Done in #{elapsed_time}"
|
data/lib/classes.rb
CHANGED
|
@@ -21,7 +21,6 @@ DEALINGS IN THE SOFTWARE.
|
|
|
21
21
|
class Table
|
|
22
22
|
def initialize(bytes)
|
|
23
23
|
@dim, @x, @y, @z, items, *@data = bytes.unpack('L5 S*')
|
|
24
|
-
|
|
25
24
|
raise 'Size mismatch loading Table from data' unless items == @data.length && @x * @y * @z == items
|
|
26
25
|
end
|
|
27
26
|
|
|
@@ -114,6 +113,69 @@ class IndexSet
|
|
|
114
113
|
end
|
|
115
114
|
|
|
116
115
|
module RPG
|
|
116
|
+
class Map
|
|
117
|
+
attr_accessor :display_name, :events
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
class Event
|
|
121
|
+
attr_accessor :pages
|
|
122
|
+
|
|
123
|
+
class Page
|
|
124
|
+
attr_accessor :list
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
class EventCommand
|
|
129
|
+
attr_accessor :code, :parameters
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
class Actor
|
|
133
|
+
attr_accessor :name, :nickname, :description, :note
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
class Armor
|
|
137
|
+
attr_accessor :name, :nickname, :description, :note
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
class Class
|
|
141
|
+
attr_accessor :name, :nickname, :description, :note
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
class Enemy
|
|
145
|
+
attr_accessor :name, :nickname, :description, :note
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
class Item
|
|
149
|
+
attr_accessor :name, :nickname, :description, :note
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
class Skill
|
|
153
|
+
attr_accessor :name, :nickname, :description, :note
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
class State
|
|
157
|
+
attr_accessor :name, :nickname, :description, :note
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
class Weapon
|
|
161
|
+
attr_accessor :name, :nickname, :description, :note
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
class CommonEvent
|
|
165
|
+
attr_accessor :pages, :list
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
class Troop
|
|
169
|
+
attr_accessor :pages
|
|
170
|
+
|
|
171
|
+
class Page
|
|
172
|
+
attr_accessor :list
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
class System
|
|
177
|
+
attr_accessor :elements, :skill_types, :weapon_types, :armor_types, :currency_unit, :terms, :words, :game_title
|
|
178
|
+
end
|
|
117
179
|
end
|
|
118
180
|
|
|
119
181
|
module RGSS
|