rgss_db 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/COPYING.md +674 -0
- data/README.md +347 -0
- data/bin/rgss-db +4 -0
- data/bin/rgssdb +4 -0
- data/lib/rgss_db/app.rb +928 -0
- data/lib/rgss_db/controller/data_manager.rb +557 -0
- data/lib/rgss_db/model/data_file.rb +516 -0
- data/lib/rgss_db/model/data_file_factory.rb +94 -0
- data/lib/rgss_db/model/debug.rb +199 -0
- data/lib/rgss_db/model/errors.rb +17 -0
- data/lib/rgss_db/model/mixins/jsonable.rb +35 -0
- data/lib/rgss_db/model/mixins/jsonable_constructor.rb +40 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rgss/color.rb +72 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rgss/rect.rb +70 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rgss/table.rb +99 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb +72 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rgss.rb +11 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/actor.rb +44 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/animation.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/animation_frame.rb +20 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/animation_timing.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/area.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/armor.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/audio_file.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/base_item.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/bgm.rb +36 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/bgs.rb +36 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/class.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/class_learning.rb +20 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/common_event.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/enemy.rb +44 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/enemy_action.rb +29 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/enemy_drop_item.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/event.rb +36 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/event_command.rb +19 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/event_page.rb +32 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/event_page_condition.rb +34 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/event_page_graphic.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/item.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/map.rb +47 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/map_info.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/me.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/move_command.rb +18 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/move_route.rb +20 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/se.rb +21 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/skill.rb +22 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/state.rb +47 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/system.rb +43 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/system_terms.rb +53 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/system_test_battler.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/system_vehicle.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/troop.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/troop_member.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/troop_page.rb +21 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/troop_page_condition.rb +33 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/usable_item.rb +87 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/weapon.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg.rb +59 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rgss/color.rb +72 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rgss/rect.rb +70 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rgss/table.rb +99 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rgss/tone.rb +72 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rgss.rb +11 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/actor.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/animation.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/animation_frame.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/animation_timing.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/armor.rb +20 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/audio_file.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/base_item.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/base_item_feature.rb +29 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/bgm.rb +43 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/bgs.rb +43 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/class.rb +37 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/class_learning.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/common_event.rb +33 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/enemy.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/enemy_action.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/enemy_drop_item.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/equip_item.rb +19 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/event.rb +36 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/event_command.rb +19 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/event_page.rb +35 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/event_page_condition.rb +40 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/event_page_graphic.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/item.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/map.rb +58 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/map_encounter.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/map_info.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/me.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/move_command.rb +17 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/move_route.rb +19 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/se.rb +21 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/skill.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/state.rb +34 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/system.rb +62 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/system_terms.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/system_test_battler.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/system_vehicle.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/tileset.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/troop.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/troop_member.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/troop_page.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/troop_page_condition.rb +39 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item.rb +84 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb +56 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_effect.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/weapon.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg.rb +66 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rgss/color.rb +72 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rgss/rect.rb +70 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rgss/table.rb +99 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rgss/tone.rb +72 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rgss.rb +11 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/actor.rb +44 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/animation.rb +28 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/animation_frame.rb +20 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/animation_timing.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/armor.rb +37 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/audio_file.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/class.rb +28 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/class_learning.rb +20 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/common_event.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/enemy.rb +47 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/enemy_action.rb +28 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/event.rb +36 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/event_command.rb +19 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/event_page.rb +32 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/event_page_condition.rb +30 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/event_page_graphic.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/item.rb +48 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/map.rb +39 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/map_info.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/move_command.rb +18 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/move_route.rb +19 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/skill.rb +47 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/state.rb +51 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/system.rb +56 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/system_test_battler.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/system_words.rb +39 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/tileset.rb +39 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/troop.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/troop_member.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/troop_page.rb +21 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/troop_page_condition.rb +32 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/weapon.rb +38 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg.rb +52 -0
- data/lib/rgss_db/model/strings.rb +607 -0
- data/lib/rgss_db/model/utilities.rb +90 -0
- data/lib/rgss_db/version.rb +7 -0
- data/lib/rgss_db/view/app_cli.rb +449 -0
- data/lib/rgss_db.rb +41 -0
- data/sig/rgss_db.rbs +5221 -0
- metadata +496 -0
@@ -0,0 +1,199 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
module RgssDb
|
6
|
+
#
|
7
|
+
# Debug module
|
8
|
+
#
|
9
|
+
module Debug
|
10
|
+
# Debug log file name
|
11
|
+
# @return [String]
|
12
|
+
DEBUG_FILE_NAME = "rgss-db.log"
|
13
|
+
|
14
|
+
# Debug mode disabled
|
15
|
+
# @return [Integer]
|
16
|
+
DEBUG_MODE_DISABLE = 0
|
17
|
+
|
18
|
+
# Debug mode errors and below
|
19
|
+
# @return [Integer]
|
20
|
+
DEBUG_MODE_ERROR = 1
|
21
|
+
|
22
|
+
# Debug mode warnings and below
|
23
|
+
# @return [Integer]
|
24
|
+
DEBUG_MODE_WARNING = 2
|
25
|
+
|
26
|
+
# Debug mode info and below
|
27
|
+
# @return [Integer]
|
28
|
+
DEBUG_MODE_INFO = 3
|
29
|
+
|
30
|
+
# Debug absolute file path
|
31
|
+
# @return [String]
|
32
|
+
@debug_file_path = ""
|
33
|
+
|
34
|
+
# Debug mode
|
35
|
+
# @return [Integer]
|
36
|
+
@debug_mode = 0
|
37
|
+
|
38
|
+
# Debug extra information
|
39
|
+
# @return [String]
|
40
|
+
@debug_extra_info = ""
|
41
|
+
|
42
|
+
#
|
43
|
+
# Starts the debug module with the given information
|
44
|
+
#
|
45
|
+
# Optionally sets the debug mode
|
46
|
+
#
|
47
|
+
# @param debug_file_path [String] Path to the debug file
|
48
|
+
# @param debug_mode [Integer] Debug mode
|
49
|
+
#
|
50
|
+
def self.start(debug_file_path, debug_mode = nil)
|
51
|
+
@debug_file_path = File.join(debug_file_path, DEBUG_FILE_NAME)
|
52
|
+
@debug_mode = debug_mode unless debug_mode.nil?
|
53
|
+
|
54
|
+
# Creates the directory (recursively)
|
55
|
+
FileUtils.mkdir_p(debug_file_path)
|
56
|
+
|
57
|
+
# Overwrites file if it exists already
|
58
|
+
File.truncate(@debug_file_path, 0) if File.exist?(@debug_file_path)
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# Gets the debug mode
|
63
|
+
#
|
64
|
+
# @return [Integer]
|
65
|
+
#
|
66
|
+
def self.debug_mode
|
67
|
+
@debug_mode
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# Sets the debug mode
|
72
|
+
#
|
73
|
+
# Set to 0 to disable
|
74
|
+
#
|
75
|
+
# @param debug_mode [Integer] Debug mode
|
76
|
+
#
|
77
|
+
def self.update_debug_mode(debug_mode)
|
78
|
+
@debug_mode = debug_mode
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# Sets the debug extra information
|
83
|
+
#
|
84
|
+
# @param extra_info [Array<String>]
|
85
|
+
#
|
86
|
+
def self.update_extra_info(*extra_info)
|
87
|
+
@debug_extra_info = extra_info
|
88
|
+
end
|
89
|
+
|
90
|
+
#
|
91
|
+
# Writes the debug header to the log file
|
92
|
+
#
|
93
|
+
def self.write_debug_header
|
94
|
+
log("<--- debug module started --->")
|
95
|
+
log("debug mode: #{Debug.debug_mode}")
|
96
|
+
log("debug extra:")
|
97
|
+
@debug_extra_info.each { |str| log("\t- #{str}") }
|
98
|
+
log("<---------------------------->")
|
99
|
+
end
|
100
|
+
|
101
|
+
#
|
102
|
+
# Logs the string
|
103
|
+
#
|
104
|
+
# @param string [String]
|
105
|
+
#
|
106
|
+
def self.log(string)
|
107
|
+
File.write(@debug_file_path, "#{string}\n", mode: "a") unless disabled?
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
# Logs the string as information
|
112
|
+
#
|
113
|
+
# @param string [String]
|
114
|
+
#
|
115
|
+
def self.log_info(string)
|
116
|
+
log("info: #{string}") if info?
|
117
|
+
end
|
118
|
+
|
119
|
+
#
|
120
|
+
# Logs the string as an error
|
121
|
+
#
|
122
|
+
# @param string [String]
|
123
|
+
#
|
124
|
+
def self.log_error(string)
|
125
|
+
log("error: #{string}") if error?
|
126
|
+
end
|
127
|
+
|
128
|
+
#
|
129
|
+
# Logs the string as a warning
|
130
|
+
#
|
131
|
+
# @param string [String]
|
132
|
+
#
|
133
|
+
def self.log_warning(string)
|
134
|
+
log("warning: #{string}") if warning?
|
135
|
+
end
|
136
|
+
|
137
|
+
#
|
138
|
+
# Logs the given exception as an error
|
139
|
+
#
|
140
|
+
# Optionally logs the application options if given
|
141
|
+
#
|
142
|
+
# @param app_options [Hash]
|
143
|
+
#
|
144
|
+
# @param [StandardError] exception
|
145
|
+
#
|
146
|
+
def self.log_exception(exception, app_options = nil)
|
147
|
+
# Logs the exception
|
148
|
+
log_error("Application Exception:")
|
149
|
+
log_error("\t#{exception.message} (#{exception.class})")
|
150
|
+
exception.backtrace.each do |str|
|
151
|
+
log_error("\t\tfrom #{str}")
|
152
|
+
end
|
153
|
+
|
154
|
+
return unless app_options.is_a?(Hash)
|
155
|
+
|
156
|
+
# Logs the application options
|
157
|
+
log_error("Application options:")
|
158
|
+
app_options.each_pair do |opt_id, opt_value|
|
159
|
+
log_error("\t- #{opt_id} => #{opt_value}")
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
#
|
164
|
+
# Checks whether the debug module is disabled or not
|
165
|
+
#
|
166
|
+
# @return [Boolean]
|
167
|
+
#
|
168
|
+
def self.disabled?
|
169
|
+
@debug_mode == DEBUG_MODE_DISABLE
|
170
|
+
end
|
171
|
+
|
172
|
+
#
|
173
|
+
# Checks whether the debug mode is info or not
|
174
|
+
#
|
175
|
+
# @return [Boolean]
|
176
|
+
#
|
177
|
+
def self.info?
|
178
|
+
@debug_mode >= DEBUG_MODE_INFO
|
179
|
+
end
|
180
|
+
|
181
|
+
#
|
182
|
+
# Checks whether the debug mode is error or not
|
183
|
+
#
|
184
|
+
# @return [Boolean]
|
185
|
+
#
|
186
|
+
def self.error?
|
187
|
+
@debug_mode >= DEBUG_MODE_ERROR
|
188
|
+
end
|
189
|
+
|
190
|
+
#
|
191
|
+
# Checks whether the debug mode is warning or not
|
192
|
+
#
|
193
|
+
# @return [Boolean]
|
194
|
+
#
|
195
|
+
def self.warning?
|
196
|
+
@debug_mode >= DEBUG_MODE_WARNING
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RgssDb
|
4
|
+
#
|
5
|
+
# Base Error class
|
6
|
+
#
|
7
|
+
class Error < StandardError
|
8
|
+
#
|
9
|
+
# Creates a new error object
|
10
|
+
#
|
11
|
+
# @param message [String] Error message
|
12
|
+
#
|
13
|
+
def initialize(message)
|
14
|
+
super("[rgss-db] #{message}")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RgssDb
|
4
|
+
#
|
5
|
+
# Jsonable mixin
|
6
|
+
#
|
7
|
+
module Jsonable
|
8
|
+
#
|
9
|
+
# Returns this instance as a json-ready hash
|
10
|
+
#
|
11
|
+
# @return [Hash]
|
12
|
+
#
|
13
|
+
def as_json
|
14
|
+
hash = {}
|
15
|
+
hash.store(JSON.create_id, self.class.name)
|
16
|
+
instance_variables.each do |ivar|
|
17
|
+
ivar_id = ivar.to_s.delete("@")
|
18
|
+
ivar_value = instance_variable_get(ivar)
|
19
|
+
hash.store(ivar_id, ivar_value)
|
20
|
+
end
|
21
|
+
hash
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Converts this instance to a JSON string
|
26
|
+
#
|
27
|
+
# @param args [Array] Arguments
|
28
|
+
#
|
29
|
+
# @return [String]
|
30
|
+
#
|
31
|
+
def to_json(*args)
|
32
|
+
as_json.to_json(*args)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RgssDb
|
4
|
+
#
|
5
|
+
# Jsonable constructor module
|
6
|
+
#
|
7
|
+
module JsonableConstructor
|
8
|
+
#
|
9
|
+
# JSON constructor
|
10
|
+
#
|
11
|
+
# This constructor is used to create a default instance
|
12
|
+
#
|
13
|
+
# Note: Needs to be overriden in case class constructor needs arguments
|
14
|
+
#
|
15
|
+
# @param args [Array]
|
16
|
+
#
|
17
|
+
# @return Class instance
|
18
|
+
#
|
19
|
+
def json_new(*args)
|
20
|
+
new(*args)
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# JSON deserializer
|
25
|
+
#
|
26
|
+
# @param hash [Hash]
|
27
|
+
# @param args [Array]
|
28
|
+
#
|
29
|
+
# @return Class instance
|
30
|
+
#
|
31
|
+
def json_create(hash, *args)
|
32
|
+
instance = json_new(*args)
|
33
|
+
hash.each_pair do |key, value|
|
34
|
+
ivar = "@#{key}".to_sym
|
35
|
+
instance.instance_variable_set(ivar, value) if instance.instance_variables.include?(ivar)
|
36
|
+
end
|
37
|
+
instance
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# The RGBA color class.
|
5
|
+
#
|
6
|
+
# Each component is handled with a floating-point value (Float).
|
7
|
+
#
|
8
|
+
class Color
|
9
|
+
include RgssDb::Jsonable
|
10
|
+
extend RgssDb::JsonableConstructor
|
11
|
+
|
12
|
+
#
|
13
|
+
# Creates a Color object. If alpha is omitted, it is assumed to be 255.
|
14
|
+
#
|
15
|
+
# The default values when no arguments are specified are (0, 0, 0, 0).
|
16
|
+
#
|
17
|
+
# @param red [Integer]
|
18
|
+
# @param green [Integer]
|
19
|
+
# @param blue [Integer]
|
20
|
+
# @param alpha [Integer]
|
21
|
+
#
|
22
|
+
def initialize(red = 0, green = 0, blue = 0, alpha = 0)
|
23
|
+
@red = red
|
24
|
+
@green = green
|
25
|
+
@blue = blue
|
26
|
+
@alpha = [red, green, blue].sum.positive? && alpha.zero? ? 255 : alpha
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Dumps this instance into a binary string
|
31
|
+
#
|
32
|
+
# Note: needed for Marshal module support
|
33
|
+
#
|
34
|
+
# @return [String]
|
35
|
+
#
|
36
|
+
def _dump(*)
|
37
|
+
# double, double, double, double (double-precision)
|
38
|
+
[@red, @green, @blue, @alpha].pack("dddd")
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Creates a new instance using the given binary data
|
43
|
+
#
|
44
|
+
# Note: needed for Marshal module support
|
45
|
+
#
|
46
|
+
# @param serialized_string [String]
|
47
|
+
#
|
48
|
+
# @return [Color]
|
49
|
+
#
|
50
|
+
def self._load(serialized_string)
|
51
|
+
Color.new_serialized(serialized_string)
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Creates a new instance from a serialized string
|
56
|
+
#
|
57
|
+
# Note: needed for Marshal module support
|
58
|
+
#
|
59
|
+
# @param serialized_string [String]
|
60
|
+
#
|
61
|
+
# @return [Color]
|
62
|
+
#
|
63
|
+
def self.new_serialized(serialized_string)
|
64
|
+
# double, double, double, double (double-precision)
|
65
|
+
red, green, blue, alpha = serialized_string.unpack("dddd")
|
66
|
+
|
67
|
+
# Creates the instance
|
68
|
+
Color.new(red, green, blue, alpha)
|
69
|
+
end
|
70
|
+
|
71
|
+
attr_accessor :red, :green, :blue, :alpha
|
72
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# The rectangle class.
|
5
|
+
#
|
6
|
+
class Rect
|
7
|
+
include RgssDb::Jsonable
|
8
|
+
extend RgssDb::JsonableConstructor
|
9
|
+
|
10
|
+
#
|
11
|
+
# Creates a new Rect object.
|
12
|
+
#
|
13
|
+
# The default values when no arguments are specified are (0, 0, 0, 0).
|
14
|
+
#
|
15
|
+
# @param x [Integer]
|
16
|
+
# @param y [Integer]
|
17
|
+
# @param width [Integer]
|
18
|
+
# @param height [Integer]
|
19
|
+
#
|
20
|
+
def initialize(x = 0, y = 0, width = 0, height = 0)
|
21
|
+
@x = x
|
22
|
+
@y = y
|
23
|
+
@width = width
|
24
|
+
@height = height
|
25
|
+
end
|
26
|
+
|
27
|
+
#
|
28
|
+
# Dumps this instance into a binary string
|
29
|
+
#
|
30
|
+
# Note: needed for Marshal module support
|
31
|
+
#
|
32
|
+
# @return [String]
|
33
|
+
#
|
34
|
+
def _dump(*)
|
35
|
+
# int32_t, int32_t, int32_t, int32_t
|
36
|
+
[@x, @y, @width, @height].pack("llll")
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Creates a new instance using the given binary data
|
41
|
+
#
|
42
|
+
# Note: needed for Marshal module support
|
43
|
+
#
|
44
|
+
# @param serialized_string [String]
|
45
|
+
#
|
46
|
+
# @return [Rect]
|
47
|
+
#
|
48
|
+
def self._load(serialized_string)
|
49
|
+
Rect.new_serialized(serialized_string)
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Creates a new instance from a serialized string
|
54
|
+
#
|
55
|
+
# Note: needed for Marshal module support
|
56
|
+
#
|
57
|
+
# @param serialized_string [String]
|
58
|
+
#
|
59
|
+
# @return [Rect]
|
60
|
+
#
|
61
|
+
def self.new_serialized(serialized_string)
|
62
|
+
# int32_t, int32_t, int32_t, int32_t
|
63
|
+
x, y, width, height = serialized_string.unpack("llll")
|
64
|
+
|
65
|
+
# Creates the instance
|
66
|
+
Rect.new(x, y, width, height)
|
67
|
+
end
|
68
|
+
|
69
|
+
attr_accessor :x, :y, :width, :height
|
70
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# The multidimensional array class.
|
5
|
+
#
|
6
|
+
# Each element is an integer of 2 signed bytes ranging from -32,768 to 32,767.
|
7
|
+
#
|
8
|
+
class Table
|
9
|
+
include RgssDb::Jsonable
|
10
|
+
extend RgssDb::JsonableConstructor
|
11
|
+
|
12
|
+
#
|
13
|
+
# Creates a Table object.
|
14
|
+
#
|
15
|
+
# Specifies the size of each dimension in the multidimensional array. 1-, 2-, and 3-dimensional arrays are possible.
|
16
|
+
#
|
17
|
+
# Arrays with no parameters are also permitted.
|
18
|
+
#
|
19
|
+
# @param xsize [Integer]
|
20
|
+
# @param ysize [Integer]
|
21
|
+
# @param zsize [Integer]
|
22
|
+
#
|
23
|
+
def initialize(xsize, ysize = 0, zsize = 0)
|
24
|
+
# RMXP needs dimensions
|
25
|
+
@dim = 1
|
26
|
+
@dim = 2 if ysize.positive?
|
27
|
+
@dim = 3 if zsize.positive?
|
28
|
+
@x = xsize
|
29
|
+
@y = ysize
|
30
|
+
@z = zsize
|
31
|
+
@data = []
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Dumps this instance into a binary string
|
36
|
+
#
|
37
|
+
# Note: needed for Marshal module support
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
#
|
41
|
+
def _dump(*)
|
42
|
+
# int32_t, int32_t, int32_t, int32_t, int32_t, int16_t *
|
43
|
+
[@dim, @x, @y, @z, @x * @y * @z, *@data].pack("llllls*")
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# Creates a new instance using the given binary data
|
48
|
+
#
|
49
|
+
# Note: needed for Marshal module support
|
50
|
+
#
|
51
|
+
# @param serialized_string [String]
|
52
|
+
#
|
53
|
+
# @return [Table]
|
54
|
+
#
|
55
|
+
def self._load(serialized_string)
|
56
|
+
Table.new_serialized(serialized_string)
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Creates a new instance from a serialized string
|
61
|
+
#
|
62
|
+
# Note: needed for Marshal module support
|
63
|
+
#
|
64
|
+
# @param serialized_string [String]
|
65
|
+
#
|
66
|
+
# @return [Table]
|
67
|
+
#
|
68
|
+
def self.new_serialized(serialized_string)
|
69
|
+
# int32_t, int32_t, int32_t, int32_t, int32_t, int16_t *
|
70
|
+
dim, x, y, z, size, *data = serialized_string.unpack("llllls*")
|
71
|
+
|
72
|
+
# Checks if written size value matches the actual size of the table
|
73
|
+
raise "Table: bad file format (size mismatch)" unless size == (x * y * z)
|
74
|
+
# Double check no data was lost
|
75
|
+
raise "Table: bad file format (data length mismatch)" unless size == data.length
|
76
|
+
|
77
|
+
# Creates the instance
|
78
|
+
table = Table.new(0, 0, 0)
|
79
|
+
table.dim = dim
|
80
|
+
table.x = x
|
81
|
+
table.y = y
|
82
|
+
table.z = z
|
83
|
+
table.data = data
|
84
|
+
table
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# Returns a table instance for JSON deserialization
|
89
|
+
#
|
90
|
+
# @param args [Array]
|
91
|
+
#
|
92
|
+
# @return [Table]
|
93
|
+
#
|
94
|
+
def self.json_new(*args)
|
95
|
+
Table.new(0, 0, 0)
|
96
|
+
end
|
97
|
+
|
98
|
+
attr_accessor :dim, :x, :y, :z, :data
|
99
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# The color tone class.
|
5
|
+
#
|
6
|
+
# Each component is handled with a floating-point value (Float).
|
7
|
+
#
|
8
|
+
class Tone
|
9
|
+
include RgssDb::Jsonable
|
10
|
+
extend RgssDb::JsonableConstructor
|
11
|
+
|
12
|
+
#
|
13
|
+
# Creates a Tone object. If gray is omitted, it is assumed to be 0.
|
14
|
+
#
|
15
|
+
# The default values when no arguments are specified are (0, 0, 0, 0).
|
16
|
+
#
|
17
|
+
# @param red [Integer]
|
18
|
+
# @param green [Integer]
|
19
|
+
# @param blue [Integer]
|
20
|
+
# @param gray [Integer]
|
21
|
+
#
|
22
|
+
def initialize(red = 0, green = 0, blue = 0, gray = 0)
|
23
|
+
@red = red
|
24
|
+
@green = green
|
25
|
+
@blue = blue
|
26
|
+
@gray = gray
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Dumps this instance into a binary string
|
31
|
+
#
|
32
|
+
# Note: needed for Marshal module support
|
33
|
+
#
|
34
|
+
# @return [String]
|
35
|
+
#
|
36
|
+
def _dump(*)
|
37
|
+
# double, double, double, double (double-precision)
|
38
|
+
[@red, @green, @blue, @gray].pack("dddd")
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Creates a new instance using the given binary data
|
43
|
+
#
|
44
|
+
# Note: needed for Marshal module support
|
45
|
+
#
|
46
|
+
# @param serialized_string [String]
|
47
|
+
#
|
48
|
+
# @return [Tone]
|
49
|
+
#
|
50
|
+
def self._load(serialized_string)
|
51
|
+
Tone.new_serialized(serialized_string)
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Creates a new instance from a serialized string
|
56
|
+
#
|
57
|
+
# Note: needed for Marshal module support
|
58
|
+
#
|
59
|
+
# @param serialized_string [String]
|
60
|
+
#
|
61
|
+
# @return [Tone]
|
62
|
+
#
|
63
|
+
def self.new_serialized(serialized_string)
|
64
|
+
# double, double, double, double (double-precision)
|
65
|
+
red, green, blue, gray = serialized_string.unpack("dddd")
|
66
|
+
|
67
|
+
# Creates the instance
|
68
|
+
Tone.new(red, green, blue, gray)
|
69
|
+
end
|
70
|
+
|
71
|
+
attr_accessor :red, :green, :blue, :gray
|
72
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Application mixins
|
4
|
+
require_relative "../../mixins/jsonable"
|
5
|
+
require_relative "../../mixins/jsonable_constructor"
|
6
|
+
|
7
|
+
# RGSS Impl.
|
8
|
+
require_relative "./rgss/color"
|
9
|
+
require_relative "./rgss/rect"
|
10
|
+
require_relative "./rgss/table"
|
11
|
+
require_relative "./rgss/tone"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RPG
|
4
|
+
#
|
5
|
+
# Data class for actors.
|
6
|
+
#
|
7
|
+
class Actor
|
8
|
+
include RgssDb::Jsonable
|
9
|
+
extend RgssDb::JsonableConstructor
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@id = 0
|
13
|
+
@name = ""
|
14
|
+
@class_id = 1
|
15
|
+
@initial_level = 1
|
16
|
+
@exp_basis = 25
|
17
|
+
@exp_inflation = 35
|
18
|
+
@character_name = ""
|
19
|
+
@character_index = 0
|
20
|
+
@face_name = ""
|
21
|
+
@face_index = 0
|
22
|
+
@parameters = Table.new(6, 100)
|
23
|
+
@weapon_id = 0
|
24
|
+
@armor1_id = 0
|
25
|
+
@armor2_id = 0
|
26
|
+
@armor3_id = 0
|
27
|
+
@armor4_id = 0
|
28
|
+
@two_swords_style = false
|
29
|
+
@fix_equipment = false
|
30
|
+
@auto_battle = false
|
31
|
+
@super_guard = false
|
32
|
+
@pharmacology = false
|
33
|
+
@critical_bonus = false
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
@name.to_s
|
38
|
+
end
|
39
|
+
|
40
|
+
attr_accessor :id, :name, :class_id, :initial_level, :exp_basis, :exp_inflation, :character_name, :character_index,
|
41
|
+
:face_name, :face_index, :parameters, :weapon_id, :armor1_id, :armor2_id, :armor3_id, :armor4_id,
|
42
|
+
:two_swords_style, :fix_equipment, :auto_battle, :super_guard, :pharmacology, :critical_bonus
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RPG
|
4
|
+
#
|
5
|
+
# Data class for animation.
|
6
|
+
#
|
7
|
+
class Animation
|
8
|
+
include RgssDb::Jsonable
|
9
|
+
extend RgssDb::JsonableConstructor
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@id = 0
|
13
|
+
@name = ""
|
14
|
+
@animation1_name = ""
|
15
|
+
@animation1_hue = 0
|
16
|
+
@animation2_name = ""
|
17
|
+
@animation2_hue = 0
|
18
|
+
@position = 1
|
19
|
+
@frame_max = 1
|
20
|
+
@frames = [RPG::Animation::Frame.new]
|
21
|
+
@timings = []
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
@name.to_s
|
26
|
+
end
|
27
|
+
|
28
|
+
attr_accessor :id, :name, :animation1_name, :animation1_hue, :animation2_name, :animation2_hue, :position,
|
29
|
+
:frame_max, :frames, :timings
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RPG
|
4
|
+
class Animation
|
5
|
+
#
|
6
|
+
# Data class for animation frames.
|
7
|
+
#
|
8
|
+
class Frame
|
9
|
+
include RgssDb::Jsonable
|
10
|
+
extend RgssDb::JsonableConstructor
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@cell_max = 0
|
14
|
+
@cell_data = Table.new(0, 0)
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_accessor :cell_max, :cell_data
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|