Class: Bayonetta::CLHFile
- Inherits:
-
LibBin::Structure
- Object
- LibBin::Structure
- Bayonetta::CLHFile
show all
- Defined in:
- lib/bayonetta/clh.rb
Defined Under Namespace
Classes: ClothAT, FVector
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.convert(input_name, output_name, output_big = false) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/bayonetta/clh.rb', line 102
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/bayonetta/clh.rb', line 87
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/bayonetta/clh.rb', line 126
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
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/bayonetta/clh.rb', line 74
def self.load_bxm(input_name)
bxm = BXMFile::load(input_name)
clat = self::new
doc = bxm.to_xml
clat.cloth_at_num = doc.at_css("//CLOTH_AT//CLOTH_AT_NUM").content.to_i
clat.cloth_at = doc.css("//CLOTH_AT//CLOTH_AT_WK").collect { |c|
ClothAT.from_bxm_cloth_at(c)
}
clat
end
|
Instance Method Details
#dump(output_name, output_big = false) ⇒ Object
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/bayonetta/clh.rb', line 141
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
68
69
70
71
72
|
# File 'lib/bayonetta/clh.rb', line 68
def remap(map)
@cloth_at.each { |c|
c.remap(map)
}
end
|
#was_big? ⇒ Boolean
64
65
66
|
# File 'lib/bayonetta/clh.rb', line 64
def was_big?
@__was_big
end
|