Skip to main content

glacier_texture/
lib.rs

1use std::str::FromStr;
2
3pub mod texture_map;
4
5pub mod atlas;
6pub mod box_reflection;
7pub mod convert;
8pub mod enums;
9#[cfg(feature = "image")]
10pub mod image;
11pub mod mipblock;
12pub mod pack;
13#[cfg(feature = "rpkg")]
14pub mod rpkg;
15
16#[non_exhaustive]
17#[derive(Debug, PartialEq, Clone, Copy)]
18pub enum GlacierGame {
19    HM2016,
20    HM2,
21    HM3,
22    KNT,
23}
24
25impl GlacierGame{
26    pub(crate) fn supports_lz4_compression(&self) -> bool{
27        match self{
28            GlacierGame::HM2016 | GlacierGame::HM2 => false,
29            GlacierGame::HM3 | GlacierGame::KNT => true
30        }
31    }
32}
33
34impl FromStr for GlacierGame {
35    type Err = String;
36    fn from_str(s: &str) -> Result<Self, Self::Err> {
37        match s.to_lowercase().as_str() {
38            "1" | "H1" | "HM1" | "HM2016" | "H2016" => Ok(GlacierGame::HM2016),
39            "2" | "H2" | "HM2" | "HM2018" | "H2018" => Ok(GlacierGame::HM2),
40            "3" | "H3" | "HM3" | "HM2020" | "H2020" => Ok(GlacierGame::HM3),
41            "007" | "KNT" | "BOND" | "FIRSTLIGHT" | "B2026" => Ok(GlacierGame::KNT),
42            _ => Err(format!("Invalid value for GlacierGame: {s}")),
43        }
44    }
45}
46
47pub trait Version {
48    fn get_version() -> GlacierGame;
49}