rvpacker-txt 1.3.0 → 1.3.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/bin/rvpacker-txt +6 -1
- data/lib/classes.rb +9 -8
- data/lib/serialize.rb +46 -29
- data/rvpacker-txt.gemspec +2 -2
- data/sig/global_variables.rbs +2 -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: be60b9ca7d30b5ba65f22b5c71b2051cddc357d0793e5040bddddb4b940f7aec
|
|
4
|
+
data.tar.gz: a62fc90e814c94a9eeb0d56299c6a9211311263589d6d55b0ef5367a74a281ae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 58e86a866916217af89835096794ecdcaef8803eadc695f24347790179e5e3fda42510d5ce968a904e6d86e84c88602cbbd7fdf7411d2294b253c2a4d225b63b
|
|
7
|
+
data.tar.gz: 4a6b9e66cc383defab76c9d6216afdfcc45f16de09530ebec498b2401faf4fac16dd3d1aa1843ecc6992585116f22f750f123a9df4d76dd1e1cacbede6ca2705
|
data/bin/rvpacker-txt
CHANGED
|
@@ -5,6 +5,7 @@ require 'optparse'
|
|
|
5
5
|
$logging = false
|
|
6
6
|
$shuffle = 0
|
|
7
7
|
$no = [false, false, false, false] # 0 is whether to NOT process maps, 1 is other, 2 is system, 3 is scripts
|
|
8
|
+
$disable_custom_parsing = false
|
|
8
9
|
|
|
9
10
|
options = {}
|
|
10
11
|
OptionParser.new do |command|
|
|
@@ -43,6 +44,9 @@ OptionParser.new do |command|
|
|
|
43
44
|
'--shuffle NUMBER',
|
|
44
45
|
'At value 1: Shuffles all lines in strings, at value 2: shuffles all lines and words in strings.') { |number| $shuffle = number }
|
|
45
46
|
|
|
47
|
+
command.on('--disable-custom-parsing',
|
|
48
|
+
'Disables built-in custom parsing for some games, which may improperly parse/write some games.')
|
|
49
|
+
|
|
46
50
|
command.on('-l',
|
|
47
51
|
'--log',
|
|
48
52
|
'Log information while processing.') { $logging = true }
|
|
@@ -53,7 +57,7 @@ OptionParser.new do |command|
|
|
|
53
57
|
end.parse!(ARGV)
|
|
54
58
|
|
|
55
59
|
if ARGV.empty?
|
|
56
|
-
puts 'COMMAND argument is required.'
|
|
60
|
+
puts 'COMMAND argument is required. Use rvpacker-txt -h for help.'
|
|
57
61
|
exit
|
|
58
62
|
end
|
|
59
63
|
|
|
@@ -66,6 +70,7 @@ end
|
|
|
66
70
|
|
|
67
71
|
directory = options[:input_dir]
|
|
68
72
|
raise "#{directory} not found" unless File.exist?(directory)
|
|
73
|
+
directory = File.realpath(directory)
|
|
69
74
|
|
|
70
75
|
original_directory = Dir.foreach(directory).find { |dirname| dirname.downcase == 'original' || dirname.downcase == 'data' }
|
|
71
76
|
raise '"Data" or "original" directory not found within input directory.' if original_directory.nil?
|
data/lib/classes.rb
CHANGED
|
@@ -84,17 +84,14 @@ end
|
|
|
84
84
|
module RGSS
|
|
85
85
|
# creates an empty class in a potentially nested scope
|
|
86
86
|
def self.process(root, name, *args)
|
|
87
|
-
if
|
|
88
|
-
|
|
87
|
+
if args.empty?
|
|
88
|
+
root.const_set(name, Class.new) unless root.const_defined?(name, false)
|
|
89
89
|
else
|
|
90
|
-
|
|
91
|
-
root.const_set(name, Class.new)
|
|
92
|
-
end
|
|
90
|
+
process(root.const_get(name), *args)
|
|
93
91
|
end
|
|
94
92
|
end
|
|
95
93
|
|
|
96
|
-
|
|
97
|
-
[
|
|
94
|
+
classes_nested_array = [
|
|
98
95
|
# RGSS data structures
|
|
99
96
|
%i[RPG Actor],
|
|
100
97
|
%i[RPG Animation],
|
|
@@ -143,7 +140,11 @@ module RGSS
|
|
|
143
140
|
%i[RPG UsableItem Damage],
|
|
144
141
|
%i[RPG UsableItem Effect],
|
|
145
142
|
%i[RPG Weapon]
|
|
146
|
-
].
|
|
143
|
+
].freeze
|
|
144
|
+
|
|
145
|
+
classes_nested_array.each do |symbol_array|
|
|
146
|
+
process(Object, *symbol_array)
|
|
147
|
+
end
|
|
147
148
|
end
|
|
148
149
|
|
|
149
150
|
require 'serialize'
|
data/lib/serialize.rb
CHANGED
|
@@ -18,41 +18,40 @@
|
|
|
18
18
|
|
|
19
19
|
require 'zlib'
|
|
20
20
|
|
|
21
|
+
# Fuck using an array with set, that's just straight dumb and not efficient
|
|
21
22
|
class IndexedSet
|
|
22
23
|
def initialize
|
|
23
|
-
@
|
|
24
|
-
@index = []
|
|
24
|
+
@hash = Hash.new
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def add(item)
|
|
28
|
-
return if @
|
|
29
|
-
|
|
30
|
-
@
|
|
31
|
-
@index << item
|
|
28
|
+
return if @hash.include?(item)
|
|
29
|
+
@hash[item] = hash.size
|
|
30
|
+
@hash
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
def include?(item)
|
|
35
|
-
@
|
|
34
|
+
@hash.include?(item)
|
|
36
35
|
end
|
|
37
36
|
|
|
38
37
|
def each(&block)
|
|
39
|
-
@
|
|
38
|
+
@hash.each_key(&block)
|
|
40
39
|
end
|
|
41
40
|
|
|
42
41
|
def to_a
|
|
43
|
-
@
|
|
42
|
+
@hash.dup
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
def join(delimiter = '')
|
|
47
|
-
@
|
|
46
|
+
@hash.keys.join(delimiter)
|
|
48
47
|
end
|
|
49
48
|
|
|
50
49
|
def length
|
|
51
|
-
@
|
|
50
|
+
@hash.size
|
|
52
51
|
end
|
|
53
52
|
|
|
54
53
|
def empty?
|
|
55
|
-
@
|
|
54
|
+
@hash.empty?
|
|
56
55
|
end
|
|
57
56
|
end
|
|
58
57
|
|
|
@@ -61,7 +60,7 @@ module RGSS
|
|
|
61
60
|
object = Marshal.load(File.read(system_file_path, mode: 'rb'))
|
|
62
61
|
game_title = object.instance_variable_get(:@game_title)
|
|
63
62
|
|
|
64
|
-
return nil if !game_title.is_a?(String) || game_title.empty?
|
|
63
|
+
return nil if $disable_custom_parsing || (!game_title.is_a?(String) || game_title.empty?)
|
|
65
64
|
|
|
66
65
|
game_title.downcase!
|
|
67
66
|
|
|
@@ -99,7 +98,7 @@ module RGSS
|
|
|
99
98
|
|
|
100
99
|
case $game_type
|
|
101
100
|
when 'lisa'
|
|
102
|
-
unless variable.split('\#').all? { |line| line.match?(/^<.*>\.?$/) || line.
|
|
101
|
+
unless variable.split('\#').all? { |line| line.match?(/^<.*>\.?$/) || line.empty? }
|
|
103
102
|
return nil
|
|
104
103
|
end
|
|
105
104
|
else
|
|
@@ -277,10 +276,10 @@ module RGSS
|
|
|
277
276
|
|
|
278
277
|
[elements, skill_types, weapon_types, armor_types].each do |array|
|
|
279
278
|
next if array.nil?
|
|
280
|
-
array.each { |string| lines.add(string)
|
|
279
|
+
array.each { |string| lines.add(string) if string.is_a?(String) && !string.empty? }
|
|
281
280
|
end
|
|
282
281
|
|
|
283
|
-
lines.add(currency_unit)
|
|
282
|
+
lines.add(currency_unit) if currency_unit.is_a?(String) && !currency_unit.empty?
|
|
284
283
|
|
|
285
284
|
terms.instance_variables.each do |variable|
|
|
286
285
|
value = terms.instance_variable_get(variable)
|
|
@@ -290,10 +289,10 @@ module RGSS
|
|
|
290
289
|
next
|
|
291
290
|
end
|
|
292
291
|
|
|
293
|
-
value.each { |string| lines.add(string)
|
|
292
|
+
value.each { |string| lines.add(string) if string.is_a?(String) && !string.empty? }
|
|
294
293
|
end
|
|
295
294
|
|
|
296
|
-
lines.add(game_title)
|
|
295
|
+
lines.add(game_title) if game_title.is_a?(String) && !game_title.empty?
|
|
297
296
|
|
|
298
297
|
puts "Parsed #{filename}" if $logging
|
|
299
298
|
|
|
@@ -306,10 +305,10 @@ module RGSS
|
|
|
306
305
|
array.map do |string|
|
|
307
306
|
re = /\S+/
|
|
308
307
|
words = string.scan(re)
|
|
309
|
-
words.shuffle
|
|
308
|
+
shuffled = words.shuffle
|
|
310
309
|
|
|
311
310
|
(0..(words.length)).each do |i|
|
|
312
|
-
string.sub!(
|
|
311
|
+
string.sub!(words[i], shuffled[i])
|
|
313
312
|
end
|
|
314
313
|
|
|
315
314
|
string
|
|
@@ -370,7 +369,7 @@ module RGSS
|
|
|
370
369
|
extract_quoted_strings(code).each do |string|
|
|
371
370
|
string.strip!
|
|
372
371
|
|
|
373
|
-
next if string.empty? || string.
|
|
372
|
+
next if string.empty? || string.gsub(' ', '').empty?
|
|
374
373
|
|
|
375
374
|
# Maybe this mess will remove something that mustn't be removed, but it needs to be tested
|
|
376
375
|
next if string.start_with?(/([#!?$@]|(\.\/)?(Graphics|Data|Audio|CG|Movies|Save)\/)/) ||
|
|
@@ -395,7 +394,25 @@ module RGSS
|
|
|
395
394
|
string.match?(/\+?=?=/) ||
|
|
396
395
|
string.match?(/[}{_<>]/) ||
|
|
397
396
|
string.match?(/r[vx]data/) ||
|
|
398
|
-
string.match?(/No such file or directory
|
|
397
|
+
string.match?(/No such file or directory/) ||
|
|
398
|
+
string.match?(/level \*\*/) ||
|
|
399
|
+
string.match?(/Courier New/) ||
|
|
400
|
+
string.match?(/Comic Sans/) ||
|
|
401
|
+
string.match?(/Lucida/) ||
|
|
402
|
+
string.match?(/Verdana/) ||
|
|
403
|
+
string.match?(/Tahoma/) ||
|
|
404
|
+
string.match?(/Arial/) ||
|
|
405
|
+
string.match?(/Player start location/) ||
|
|
406
|
+
string.match?(/Common event call has exceeded/) ||
|
|
407
|
+
string.match?(/se-/) ||
|
|
408
|
+
string.match?(/Start Pos/) ||
|
|
409
|
+
string.match?(/An error has occurred/) ||
|
|
410
|
+
string.match?(/Define it first/) ||
|
|
411
|
+
string.match?(/Process Skill/) ||
|
|
412
|
+
string.match?(/Wpn Only/) ||
|
|
413
|
+
string.match?(/Don't Wait/) ||
|
|
414
|
+
string.match?(/Clear image/) ||
|
|
415
|
+
string.match?(/Can Collapse/)
|
|
399
416
|
|
|
400
417
|
strings.add(string)
|
|
401
418
|
end
|
|
@@ -792,6 +809,8 @@ module RGSS
|
|
|
792
809
|
code = Zlib::Inflate.inflate(script[2]).force_encoding('UTF-8')
|
|
793
810
|
|
|
794
811
|
scripts_original_text.zip(scripts_translated_text).each do |original, translated|
|
|
812
|
+
# That may possibly break something, but until it does, who cares
|
|
813
|
+
# Honestly, it needs to be changed to find quoted strings like in `extract_quoted_strings` method
|
|
795
814
|
code.gsub!(original, translated) unless translated.nil?
|
|
796
815
|
end
|
|
797
816
|
|
|
@@ -804,14 +823,12 @@ module RGSS
|
|
|
804
823
|
def self.serialize(engine, action, directory, original_directory)
|
|
805
824
|
start_time = Time.now
|
|
806
825
|
|
|
807
|
-
absolute_path = File.realpath(directory).freeze
|
|
808
|
-
|
|
809
826
|
paths = {
|
|
810
|
-
original_path: File.join(
|
|
811
|
-
translation_path: File.join(
|
|
812
|
-
maps_path: File.join(
|
|
813
|
-
other_path: File.join(
|
|
814
|
-
output_path: File.join(
|
|
827
|
+
original_path: File.join(directory, original_directory),
|
|
828
|
+
translation_path: File.join(directory, 'translation'),
|
|
829
|
+
maps_path: File.join(directory, 'translation/maps'),
|
|
830
|
+
other_path: File.join(directory, 'translation/other'),
|
|
831
|
+
output_path: File.join(directory, 'output')
|
|
815
832
|
}
|
|
816
833
|
|
|
817
834
|
paths.each_value { |path| FileUtils.mkdir_p(path) }
|
data/rvpacker-txt.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |spec|
|
|
2
2
|
spec.name = 'rvpacker-txt'
|
|
3
|
-
spec.version = '1.3.
|
|
3
|
+
spec.version = '1.3.1'
|
|
4
4
|
spec.authors = ['Howard Jeng', 'Andrew Kesterson', 'Solistra', 'Darkness9724', 'savannstm']
|
|
5
5
|
spec.email = ['savannstm@gmail.com']
|
|
6
6
|
spec.summary = 'Reads or writes RPG Maker XP/VX/VXAce game text to .txt files'
|
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
|
11
11
|
spec.metadata = { 'homepage_uri' => 'https://github.com/savannstm/rvpacker-txt' }
|
|
12
12
|
|
|
13
13
|
spec.files = `git ls-files -z`.split("\x0")
|
|
14
|
-
spec.executables =
|
|
14
|
+
spec.executables = ['rvpacker-txt']
|
|
15
15
|
spec.require_paths = ['lib']
|
|
16
16
|
|
|
17
17
|
spec.add_development_dependency 'bundler', '~> 2.5'
|
data/sig/global_variables.rbs
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rvpacker-txt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Howard Jeng
|
|
@@ -12,7 +12,7 @@ authors:
|
|
|
12
12
|
autorequire:
|
|
13
13
|
bindir: bin
|
|
14
14
|
cert_chain: []
|
|
15
|
-
date: 2024-07-
|
|
15
|
+
date: 2024-07-07 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
18
|
name: bundler
|