Class: Bayonetta::CLWFile
- Inherits:
-
LibBin::Structure
- Object
- LibBin::Structure
- Bayonetta::CLWFile
show all
- Defined in:
- lib/bayonetta/clw.rb
Defined Under Namespace
Classes: ClothWind, FVector
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.convert(input_name, output_name, output_big = false) ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/bayonetta/clw.rb', line 109
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/bayonetta/clw.rb', line 94
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/bayonetta/clw.rb', line 133
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
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/bayonetta/clw.rb', line 81
def self.load_bxm(input_name)
bxm = BXMFile::load(input_name)
clw = self::new
doc = bxm.to_xml
clw.cloth_wind_num = doc.at_css("//CLOTH_WIND//CLOTH_WIND_NUM").content.to_i
clw.cloth_wind = doc.css("//CLOTH_WIND//CLOTH_WIND_WK").collect { |c|
ClothWind.from_bxm_cloth_wind(c)
}
clw
end
|
Instance Method Details
#dump(output_name, output_big = false) ⇒ Object
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/bayonetta/clw.rb', line 148
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) ⇒ Object
75
76
77
78
79
|
# File 'lib/bayonetta/clw.rb', line 75
def remap(map)
@cloth_wind.each { |c|
c.remap(map)
}
end
|
#was_big? ⇒ Boolean
71
72
73
|
# File 'lib/bayonetta/clw.rb', line 71
def was_big?
@__was_big
end
|