Class: Bayonetta::CLPFile
- Inherits:
-
LibBin::Structure
- Object
- LibBin::Structure
- Bayonetta::CLPFile
show all
- Defined in:
- lib/bayonetta/clp.rb
Defined Under Namespace
Classes: Cloth, FVector, Header
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.convert(input_name, output_name, output_big = false) ⇒ Object
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
# File 'lib/bayonetta/clp.rb', line 155
def self.convert(input_name, output_name, output_big = false)
if input_name.respond_to?(:read) && input_name.respond_to?(:seek)
input = input_name
else
input = File.open(input_name, "rb")
end
input_big = is_big?(input)
if output_name.respond_to?(:write) && output_name.respond_to?(:seek)
output = output_name
else
output = File.open(output_name, "wb")
end
output.rewind
clp = self::new
clp.instance_variable_set(:@__was_big, input_big)
clp.__convert(input, output, input_big, output_big)
input.close unless input_name.respond_to?(:read) && input_name.respond_to?(:seek)
output.close unless output_name.respond_to?(:write) && output_name.respond_to?(:seek)
clp
end
|
.is_big?(f) ⇒ Boolean
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/bayonetta/clp.rb', line 140
def self.is_big?(f)
f.rewind
f.size
block = lambda { |int|
num = f.read(4).unpack(int).first
( num >= 0 ) && ( num < 256 )
}
big = block.call("l>")
f.rewind
small = block.call("l<")
f.rewind
raise "Invalid data!" unless big ^ small
return big
end
|
.load(input_name) ⇒ Object
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
# File 'lib/bayonetta/clp.rb', line 179
def self.load(input_name)
if input_name.respond_to?(:read) && input_name.respond_to?(:seek)
input = input_name
else
input = File.open(input_name, "rb")
end
input_big = is_big?(input)
clp = self::new
clp.instance_variable_set(:@__was_big, input_big)
clp.__load(input, input_big)
input.close unless input_name.respond_to?(:read) && input_name.respond_to?(:seek)
clp
end
|
.load_bxm(input_name) ⇒ Object
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/bayonetta/clp.rb', line 126
def self.load_bxm(input_name)
bxm = BXMFile::load(input_name)
clp = self::new
doc = bxm.to_xml
h = doc.at_css("//CLOTH//CLOTH_HEADER")
clp. = Header.(h)
clp.cloth = doc.css("//CLOTH//CLOTH_WK").collect { |c|
Cloth.from_bxm_cloth(c)
}
clp
end
|
Instance Method Details
#dump(output_name, output_big = false) ⇒ Object
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# File 'lib/bayonetta/clp.rb', line 194
def dump(output_name, output_big = false)
if output_name.respond_to?(:write) && output_name.respond_to?(:seek)
output = output_name
else
output = File.open(output_name, "wb")
end
output.rewind
__set_dump_state(output, output_big, nil, nil)
__dump_fields
__unset_dump_state
output.close unless output_name.respond_to?(:write) && output_name.respond_to?(:seek)
self
end
|
#remap(map, poly = true, fix = true) ⇒ Object
120
121
122
123
124
|
# File 'lib/bayonetta/clp.rb', line 120
def remap(map, poly = true, fix = true)
@cloth.each { |c|
c.remap(map, poly, fix)
}
end
|
#was_big? ⇒ Boolean
116
117
118
|
# File 'lib/bayonetta/clp.rb', line 116
def was_big?
@__was_big
end
|