1#![expect(
2 clippy::cast_possible_truncation,
3 reason = "bindgen GuiPriority_* constants are small enums that fit in u8"
4)]
5
6use crate::bindings::{
7 GuiPriority_GUI_PRIORITY_CHAT, GuiPriority_GUI_PRIORITY_DISCONNECT,
8 GuiPriority_GUI_PRIORITY_HUD, GuiPriority_GUI_PRIORITY_INVENTORY,
9 GuiPriority_GUI_PRIORITY_LOADING, GuiPriority_GUI_PRIORITY_MENU,
10 GuiPriority_GUI_PRIORITY_OLDLOADING, GuiPriority_GUI_PRIORITY_TEXIDS,
11 GuiPriority_GUI_PRIORITY_TEXPACK, GuiPriority_GUI_PRIORITY_TOUCH,
12 GuiPriority_GUI_PRIORITY_TOUCHMORE, GuiPriority_GUI_PRIORITY_URLWARNING,
13};
14
15#[derive(Debug, Clone)]
16pub enum Priority {
17 UnderDisconnect,
18 Disconnect,
19 OverDisconnect,
20 UnderOldLoading,
21 OldLoading,
22 OverOldLoading,
23 UnderMenu,
24 Menu,
25 OverMenu,
26 UnderTouchMore,
27 TouchMore,
28 OverTouchMore,
29 UnderUrlWarning,
30 UrlWarning,
31 OverUrlWarning,
32 UnderTexPack,
33 TexPack,
34 OverTexPack,
35 UnderTexIds,
36 TexIds,
37 OverTexIds,
38 UnderTouch,
39 Touch,
40 OverTouch,
41 UnderInventory,
42 Inventory,
43 OverInventory,
44 UnderChat,
45 Chat,
46 OverChat,
47 UnderHud,
48 Hud,
49 OverHud,
50 UnderLoading,
51 Loading,
52 OverLoading,
53 UnderEverything,
54 OverEverything,
55 Custom(u8),
56}
57
58impl From<u8> for Priority {
59 fn from(n: u8) -> Self {
60 Self::Custom(n)
61 }
62}
63
64impl Priority {
65 #[must_use]
66 pub fn to_u8(&self) -> u8 {
67 match self {
68 Self::UnderDisconnect => GuiPriority_GUI_PRIORITY_DISCONNECT as u8 - 1,
69 Self::Disconnect => GuiPriority_GUI_PRIORITY_DISCONNECT as u8,
70 Self::OverDisconnect => GuiPriority_GUI_PRIORITY_DISCONNECT as u8 + 1,
71 Self::UnderOldLoading => GuiPriority_GUI_PRIORITY_OLDLOADING as u8 - 1,
72 Self::OldLoading => GuiPriority_GUI_PRIORITY_OLDLOADING as u8,
73 Self::OverOldLoading => GuiPriority_GUI_PRIORITY_OLDLOADING as u8 + 1,
74 Self::UnderMenu => GuiPriority_GUI_PRIORITY_MENU as u8 - 1,
75 Self::Menu => GuiPriority_GUI_PRIORITY_MENU as u8,
76 Self::OverMenu => GuiPriority_GUI_PRIORITY_MENU as u8 + 1,
77 Self::UnderTouchMore => GuiPriority_GUI_PRIORITY_TOUCHMORE as u8 - 1,
78 Self::TouchMore => GuiPriority_GUI_PRIORITY_TOUCHMORE as u8,
79 Self::OverTouchMore => GuiPriority_GUI_PRIORITY_TOUCHMORE as u8 + 1,
80 Self::UnderUrlWarning => GuiPriority_GUI_PRIORITY_URLWARNING as u8 - 1,
81 Self::UrlWarning => GuiPriority_GUI_PRIORITY_URLWARNING as u8,
82 Self::OverUrlWarning => GuiPriority_GUI_PRIORITY_URLWARNING as u8 + 1,
83 Self::UnderTexPack => GuiPriority_GUI_PRIORITY_TEXPACK as u8 - 1,
84 Self::TexPack => GuiPriority_GUI_PRIORITY_TEXPACK as u8,
85 Self::OverTexPack => GuiPriority_GUI_PRIORITY_TEXPACK as u8 + 1,
86 Self::UnderTexIds => GuiPriority_GUI_PRIORITY_TEXIDS as u8 - 1,
87 Self::TexIds => GuiPriority_GUI_PRIORITY_TEXIDS as u8,
88 Self::OverTexIds => GuiPriority_GUI_PRIORITY_TEXIDS as u8 + 1,
89 Self::UnderTouch => GuiPriority_GUI_PRIORITY_TOUCH as u8 - 1,
90 Self::Touch => GuiPriority_GUI_PRIORITY_TOUCH as u8,
91 Self::OverTouch => GuiPriority_GUI_PRIORITY_TOUCH as u8 + 1,
92 Self::UnderInventory => GuiPriority_GUI_PRIORITY_INVENTORY as u8 - 1,
93 Self::Inventory => GuiPriority_GUI_PRIORITY_INVENTORY as u8,
94 Self::OverInventory => GuiPriority_GUI_PRIORITY_INVENTORY as u8 + 1,
95 Self::UnderChat => GuiPriority_GUI_PRIORITY_CHAT as u8 - 1,
96 Self::Chat => GuiPriority_GUI_PRIORITY_CHAT as u8,
97 Self::OverChat => GuiPriority_GUI_PRIORITY_CHAT as u8 + 1,
98 Self::UnderHud => GuiPriority_GUI_PRIORITY_HUD as u8 - 1,
99 Self::Hud => GuiPriority_GUI_PRIORITY_HUD as u8,
100 Self::OverHud => GuiPriority_GUI_PRIORITY_HUD as u8 + 1,
101 Self::UnderLoading => GuiPriority_GUI_PRIORITY_LOADING as u8 - 1,
102 Self::Loading => GuiPriority_GUI_PRIORITY_LOADING as u8,
103 Self::OverLoading => GuiPriority_GUI_PRIORITY_LOADING as u8 + 1,
104 Self::UnderEverything => 0,
105 Self::OverEverything => 255,
106 Self::Custom(n) => *n,
107 }
108 }
109}