maraiah: add functions to EntryData for gathering info
parent
54ab1f9153
commit
8f1b043b93
|
@ -76,6 +76,88 @@ pub fn read_all(head: &head::Header,
|
|||
Ok(data_map)
|
||||
}
|
||||
|
||||
impl EntryData
|
||||
{
|
||||
pub fn get_type(&self) -> EntryType
|
||||
{
|
||||
if self.has_minf() {
|
||||
EntryType::Map
|
||||
} else if self.has_fxpx() ||
|
||||
self.has_mnpx() ||
|
||||
self.has_prpx() ||
|
||||
self.has_pxpx() ||
|
||||
self.has_wppx() {
|
||||
EntryType::Physics
|
||||
} else if self.has_pict() {
|
||||
EntryType::Image
|
||||
} else {
|
||||
EntryType::Other
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_epnt(&self) -> bool {self.epnt.is_some()}
|
||||
pub fn has_fxpx(&self) -> bool {self.fxpx.is_some()}
|
||||
pub fn has_lins(&self) -> bool {self.lins.is_some()}
|
||||
pub fn has_lite(&self) -> bool {self.lite.is_some()}
|
||||
pub fn has_mnpx(&self) -> bool {self.mnpx.is_some()}
|
||||
pub fn has_minf(&self) -> bool {self.minf.is_some()}
|
||||
pub fn has_name(&self) -> bool {self.name.is_some()}
|
||||
pub fn has_note(&self) -> bool {self.note.is_some()}
|
||||
pub fn has_objs(&self) -> bool {self.objs.is_some()}
|
||||
pub fn has_pict(&self) -> bool {self.pict.is_some()}
|
||||
pub fn has_pnts(&self) -> bool {self.pnts.is_some()}
|
||||
pub fn has_poly(&self) -> bool {self.poly.is_some()}
|
||||
pub fn has_prpx(&self) -> bool {self.prpx.is_some()}
|
||||
pub fn has_pxpx(&self) -> bool {self.pxpx.is_some()}
|
||||
pub fn has_sids(&self) -> bool {self.sids.is_some()}
|
||||
pub fn has_wppx(&self) -> bool {self.wppx.is_some()}
|
||||
pub fn has_ambi(&self) -> bool {self.ambi.is_some()}
|
||||
pub fn has_bonk(&self) -> bool {self.bonk.is_some()}
|
||||
pub fn has_iidx(&self) -> bool {self.iidx.is_some()}
|
||||
pub fn has_medi(&self) -> bool {self.medi.is_some()}
|
||||
pub fn has_plac(&self) -> bool {self.plac.is_some()}
|
||||
pub fn has_plat(&self) -> bool {self.plat.is_some()}
|
||||
pub fn has_term(&self) -> bool {self.term.is_some()}
|
||||
|
||||
pub fn num_unknown(&self) -> usize {self.unkn.len()}
|
||||
|
||||
pub fn len(&self) -> usize
|
||||
{
|
||||
let ret = if self.has_epnt() {1} else {0} +
|
||||
if self.has_fxpx() {1} else {0} +
|
||||
if self.has_lins() {1} else {0} +
|
||||
if self.has_lite() {1} else {0} +
|
||||
if self.has_mnpx() {1} else {0} +
|
||||
if self.has_minf() {1} else {0} +
|
||||
if self.has_name() {1} else {0} +
|
||||
if self.has_note() {1} else {0} +
|
||||
if self.has_objs() {1} else {0} +
|
||||
if self.has_pict() {1} else {0} +
|
||||
if self.has_pnts() {1} else {0} +
|
||||
if self.has_poly() {1} else {0} +
|
||||
if self.has_prpx() {1} else {0} +
|
||||
if self.has_pxpx() {1} else {0} +
|
||||
if self.has_sids() {1} else {0} +
|
||||
if self.has_wppx() {1} else {0} +
|
||||
if self.has_ambi() {1} else {0} +
|
||||
if self.has_bonk() {1} else {0} +
|
||||
if self.has_iidx() {1} else {0} +
|
||||
if self.has_medi() {1} else {0} +
|
||||
if self.has_plac() {1} else {0} +
|
||||
if self.has_plat() {1} else {0} +
|
||||
self.num_unknown();
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
/// The abstract type of an entry.
|
||||
pub enum EntryType {
|
||||
Other,
|
||||
Map,
|
||||
Image,
|
||||
Physics,
|
||||
}
|
||||
|
||||
/// The loaded data of a Map file entry.
|
||||
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
||||
#[derive(Debug, Default, Eq, PartialEq)]
|
||||
|
|
Loading…
Reference in New Issue