rvpacker-txt 1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 23d385ac1a1e31fb6b845b028746ca52e58c882aed04ffd23721dfe513934451
4
+ data.tar.gz: 138b367cdd190e4edfbc8f1449b7b5129f03d2d614e8f17f7dbb9599c7c3aeb9
5
+ SHA512:
6
+ metadata.gz: c1273a05232251e539300f9c5cef0c1b082c041e5ecd3e7f4284f933ea5df29641808395d08e344dcd825f8cca727701e3f8e61fb9280016e47d60eecc8f2dfb
7
+ data.tar.gz: bd29920e41d1fd3871879d4a541863b078329f57338adfcc12fe08aeee6970b4e36b568747a06d0105388ae280482365039c98f8ee6bdf43e05550359fda0d17
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rvpacker-txt.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ Copyright (c) 2013 Howard Jeng
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
+ software and associated documentation files (the "Software"), to deal in the Software
5
+ without restriction, including without limitation the rights to use, copy, modify, merge,
6
+ publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7
+ to whom the Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or
10
+ substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15
+ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17
+ DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # rvpacker-txt
2
+
3
+ A tool to read RPG Maker data files to .txt files and write them back to the initial form. It's a port of Darkness9724's
4
+ port of Ruby 1.9.x's rvpacker to Ruby 3.x to use .txt files instead of YAML, and overall improve the code quality.
5
+
6
+ rvpacker consists of 3 parts:
7
+
8
+ * RPG library (stub classes for serialization of RPGMaker game data)
9
+ * RGSS library (some more classes for RPGMaker serialization)
10
+ * rvpacker-txt (the script you call on the frontend)
11
+
12
+ # Installation
13
+
14
+ ```
15
+ $ gem install rvpacker-txt
16
+ ```
17
+
18
+ Usage
19
+ =====
20
+
21
+ ```
22
+ $ rvpacker-txt -h
23
+ Usage: rvpacker-txt COMMAND [options]
24
+
25
+ COMMANDS:
26
+ read - Parses RPG Maker game files to .txt
27
+ write - Writes parsed files back to their initial form
28
+ OPTIONS:
29
+ -d, --input-dir DIRECTORY Input directory of RPG Maker project.
30
+ Must contain "Data" or "original" folder to read,
31
+ and additionally "translation" with "maps" and "other" subdirectories to write.
32
+ -l, --log Log information while processing.
33
+ -s, --shuffle NUMBER At value 1: Shuffles all lines in strings, at value 2: shuffles all lines and words in strings.
34
+ -h, --help Show help message.
35
+ ```
36
+
37
+ For example, to read a RPG Maker VX Ace project in E:/Documents/RPGMakerGame to .txt files:
38
+
39
+ ```
40
+ $ rvpacker read --input-dir E:/Documents/RPGMakerGame
41
+ ```
42
+
43
+ Program determines game engine automatically.
44
+
45
+ This will parse all text from Data/* files into translation/maps and translation/other directories as files without
46
+ _trans postfix that contain original text and files with _trans postfix that contain empty lines for translation.
47
+ Lines from Scripts file will be parsed into translation/other/scripts.txt file as plain text.
48
+
49
+ To write previously parsed project back to its initial form:
50
+
51
+ ```
52
+ $ rvpacker write --input-dir E:/Documents/RPGMakerGame
53
+ ```
54
+
55
+ This will take all of translation lines from _trans files from the translation subdirectories and repack all of them
56
+ to their initial form in output directory.
57
+
58
+ ## General
59
+
60
+ This is great for collaborating on translations and have clean version control.
61
+ You can easily push .txt files and easily merge them.
62
+
63
+ Now your translation can be forked/merged in an extremely easy way.
64
+
65
+ ## Credit to previous authors
66
+
67
+ The RPG and RGSS libraries were originally taken from SiCrane's YAML importer/exporter on the gamedev forums.
68
+
69
+ http://www.gamedev.net/topic/646333-rpg-maker-vx-ace-data-conversion-utility/
70
+
71
+ akesterson, ymaxkrapzv and BigBlueHat created an original rvpacker repository with the initial frontend for SiCrane's
72
+ YAML importer/exporter.
73
+
74
+ https://github.com/ymaxkrapzv/rvpacker
75
+
76
+ Darkness9724 forked rvpacker to rvpacker-ng, ported it to Ruby 3.x and updated dependencies.
77
+
78
+ https://gitlab.com/Darkness9724/rvpacker-ng
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/rvpacker-txt ADDED
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env ruby
2
+ require('RGSS')
3
+ require('optparse')
4
+
5
+ opts = {}
6
+ OptionParser.new do |options|
7
+ options.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"
8
+
9
+ options.on('-d', '--input-dir DIRECTORY', 'Input directory of RPG Maker project.',
10
+ 'Must contain "Data" or "original" folder to read,',
11
+ 'and additionally "translation" with "maps" and "other" subdirectories to write.') do |dir|
12
+ opts[:input_dir] = dir
13
+ end
14
+
15
+ options.on('-l', '--log', 'Log information while processing.') do
16
+ opts[:log] = true
17
+ end
18
+
19
+ options.on('-s', '--shuffle NUMBER', 'At value 1: Shuffles all lines in strings, at value 2: shuffles all lines and words in strings.') do |number|
20
+ opts[:shuffle] = number
21
+ end
22
+
23
+ options.on_tail('-h', '--help', 'Show help message.') do
24
+ puts options
25
+ exit
26
+ end
27
+ end.parse!(ARGV)
28
+
29
+ if ARGV.empty?
30
+ puts 'COMMAND argument is required.'
31
+ exit
32
+ end
33
+
34
+ opts[:action] = ARGV.shift
35
+
36
+ unless %w[read write].include?(opts[:action])
37
+ puts 'Invalid command. Allowed commands are: read, write.'
38
+ exit
39
+ end
40
+
41
+ project_types = { 'vx' => :vx, 'ace' => :ace, 'xp' => :xp }
42
+ $logging = opts[:log]
43
+
44
+ directory = opts[:input_dir]
45
+ raise "#{directory} not found" unless File.exist?(directory)
46
+
47
+ data_folder = Dir.foreach(directory).find { |filename| filename.downcase == 'original' }
48
+ data_folder = Dir.foreach(directory).find { |filename| filename.downcase == 'data' } if data_folder.nil?
49
+ raise '"Data" directory not found within input directory.' if data_folder.nil?
50
+
51
+ types = %i[vx ace xp]
52
+
53
+ type = types.find do |_type|
54
+ case _type
55
+ when 'vx'
56
+ break project_types[_type] if File.exist?(File.join(directory, data_folder, 'System.rxdata'))
57
+ when 'xp'
58
+ break project_types[_type] if File.exist?(File.join(directory, data_folder, 'System.rvdata'))
59
+ when 'ace'
60
+ break project_types[_type] if File.exist?(File.join(directory, data_folder, 'System.rvdata2'))
61
+ else
62
+ break nil
63
+ end
64
+ end
65
+
66
+ raise 'Couldn\'t determine project engine.' if type.nil?
67
+
68
+ RGSS.serialize(
69
+ type,
70
+ opts[:action],
71
+ directory,
72
+ {
73
+ line_width: -1,
74
+ table_width: -1,
75
+ }
76
+ )
@@ -0,0 +1,54 @@
1
+ module RGSS
2
+ module BasicCoder
3
+ def encode_with(coder)
4
+ ivars.each do |var|
5
+ name = var.to_s.sub(/^@/, '')
6
+ value = instance_variable_get(var)
7
+ coder[name] = encode(name, value)
8
+ end
9
+ end
10
+
11
+ def encode(name, value)
12
+ return value
13
+ end
14
+
15
+ def init_with(coder)
16
+ coder.map.each do |key, value|
17
+ sym = "@#{key}".to_sym
18
+ instance_variable_set(sym, decode(key, value))
19
+ end
20
+ end
21
+
22
+ def decode(name, value)
23
+ return value
24
+ end
25
+
26
+ def ivars
27
+ return instance_variables
28
+ end
29
+
30
+ INCLUDED_CLASSES = []
31
+
32
+ def self.included(mod)
33
+ INCLUDED_CLASSES.push(mod)
34
+ end
35
+
36
+ def self.set_ivars_methods(version)
37
+ INCLUDED_CLASSES.each do |c|
38
+ if version == :ace
39
+ RGSS.reset_method(
40
+ c,
41
+ :ivars,
42
+ -> { return instance_variables }
43
+ )
44
+ else
45
+ RGSS.reset_method(
46
+ c,
47
+ :ivars,
48
+ -> { return instance_variables.sort }
49
+ )
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end