1#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd)]
5pub enum WmoVersion {
6 Classic,
8
9 Tbc,
11
12 Wotlk,
14
15 Cataclysm,
17
18 Mop,
20
21 Wod,
23
24 Legion,
26
27 Bfa,
29
30 Shadowlands,
32
33 Dragonflight,
35
36 WarWithin,
38}
39
40impl WmoVersion {
41 pub fn from_raw(raw: u32) -> Option<Self> {
45 match raw {
46 17 => Some(Self::Classic), 18 => Some(Self::Wod),
48 19 => Some(Self::Legion),
49 20 => Some(Self::Bfa),
50 21 => Some(Self::Shadowlands),
51 22 => Some(Self::Dragonflight),
52 23 => Some(Self::WarWithin),
53 _ => None,
54 }
55 }
56
57 pub fn from_raw_with_expansion(raw: u32, expansion: &str) -> Option<Self> {
60 match (raw, expansion.to_lowercase().as_str()) {
61 (17, exp) if exp.contains("vanilla") || exp.contains("classic") => Some(Self::Classic),
62 (17, exp) if exp.contains("tbc") || exp.contains("burning") => Some(Self::Tbc),
63 (17, exp) if exp.contains("wotlk") || exp.contains("wrath") => Some(Self::Wotlk),
64 (17, exp) if exp.contains("cata") || exp.contains("cataclysm") => Some(Self::Cataclysm),
65 (17, exp) if exp.contains("mop") || exp.contains("pandaria") => Some(Self::Mop),
66 (17, _) => Some(Self::Classic), _ => Self::from_raw(raw), }
69 }
70
71 pub fn to_raw(self) -> u32 {
74 match self {
75 Self::Classic | Self::Tbc | Self::Wotlk | Self::Cataclysm | Self::Mop => 17,
77 Self::Wod => 18,
79 Self::Legion => 19,
80 Self::Bfa => 20,
81 Self::Shadowlands => 21,
82 Self::Dragonflight => 22,
83 Self::WarWithin => 23,
84 }
85 }
86
87 pub fn expansion_name(self) -> &'static str {
89 match self {
90 Self::Classic => "Classic/Vanilla",
91 Self::Tbc => "The Burning Crusade",
92 Self::Wotlk => "Wrath of the Lich King",
93 Self::Cataclysm => "Cataclysm",
94 Self::Mop => "Mists of Pandaria",
95 Self::Wod => "Warlords of Draenor",
96 Self::Legion => "Legion",
97 Self::Bfa => "Battle for Azeroth",
98 Self::Shadowlands => "Shadowlands",
99 Self::Dragonflight => "Dragonflight",
100 Self::WarWithin => "The War Within",
101 }
102 }
103
104 pub fn min_supported() -> Self {
106 Self::Classic
107 }
108
109 pub fn max_supported() -> Self {
111 Self::WarWithin
112 }
113
114 pub fn supports_feature(self, feature: WmoFeature) -> bool {
116 self >= feature.min_version()
117 }
118
119 pub fn from_expansion_name(s: &str) -> Option<Self> {
122 match s.to_lowercase().as_str() {
123 "vanilla" | "classic" => Some(Self::Classic),
124 "tbc" | "bc" | "burningcrusade" | "burning_crusade" => Some(Self::Tbc),
125 "wotlk" | "wrath" | "lichking" | "lich_king" | "wlk" => Some(Self::Wotlk),
126 "cata" | "cataclysm" => Some(Self::Cataclysm),
127 "mop" | "pandaria" | "mists" | "mists_of_pandaria" => Some(Self::Mop),
128 "wod" | "draenor" | "warlords" | "warlords_of_draenor" => Some(Self::Wod),
129 "legion" => Some(Self::Legion),
130 "bfa" | "bfazeroth" | "battle_for_azeroth" | "battleforazeroth" => Some(Self::Bfa),
131 "sl" | "shadowlands" => Some(Self::Shadowlands),
132 "df" | "dragonflight" => Some(Self::Dragonflight),
133 "tww" | "warwithin" | "the_war_within" | "thewarwithin" => Some(Self::WarWithin),
134 _ => None,
135 }
136 }
137}
138
139#[derive(Debug, Clone, Copy, PartialEq, Eq)]
141pub enum WmoFeature {
142 Base,
144
145 ImprovedLighting,
147
148 SkyboxReferences,
150
151 DestructibleObjects,
153
154 ConvexVolumePlanes,
156
157 ExtendedMaterials,
159
160 LiquidV2,
162
163 GlobalAmbientColor,
165
166 ParticleSystems,
168
169 ShadowBatches,
171
172 RayTracedShadows,
174
175 EnhancedMaterials,
177}
178
179impl WmoFeature {
180 pub fn min_version(self) -> WmoVersion {
182 match self {
183 Self::Base => WmoVersion::Classic,
184 Self::ImprovedLighting => WmoVersion::Tbc,
185 Self::SkyboxReferences => WmoVersion::Wotlk,
186 Self::DestructibleObjects => WmoVersion::Cataclysm,
187 Self::ConvexVolumePlanes => WmoVersion::Cataclysm,
188 Self::ExtendedMaterials => WmoVersion::Mop,
189 Self::LiquidV2 => WmoVersion::Wod,
190 Self::GlobalAmbientColor => WmoVersion::Legion,
191 Self::ParticleSystems => WmoVersion::Bfa,
192 Self::ShadowBatches => WmoVersion::Shadowlands,
193 Self::RayTracedShadows => WmoVersion::Dragonflight,
194 Self::EnhancedMaterials => WmoVersion::WarWithin,
195 }
196 }
197}