summaryrefslogtreecommitdiff
path: root/src/to_clt/hud.rs
blob: c7a206ad0c423b50a8df1bd836353e3207567b7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
use super::*;

#[mt_derive(to = "clt", repr = "u32", enumset)]
pub enum HudStyleFlag {
    Bold,
    Italic,
    Mono,
}

#[mt_derive(to = "clt", repr = "u8", tag = "attribute", content = "value")]
pub enum HudChange {
    Pos([f32; 2]) = 0,
    Name(String),
    Scale([f32; 2]),
    Text(String),
    Number(u32),
    Item(u32),
    Dir(u32),
    Align([f32; 2]),
    Offset([f32; 2]),
    WorldPos([f32; 3]),
    ZIndex(i32),
    Text2(String),
    Style(EnumSet<HudStyleFlag>),
}

#[mt_derive(to = "clt", repr = "u8")]
pub enum HudType {
    Image = 0,
    Text,
    Statbar,
    Inv,
    Waypoint,
    ImageWaypoint,
}

#[mt_derive(to = "clt")]
pub struct HudElement {
    pub hud_type: HudType,
    pub pos: [f32; 2],
    pub name: String,
    pub scale: [f32; 2],
    pub text: String,
    pub number: u32,
    pub item: u32,
    pub dir: u32,
    pub align: [f32; 2],
    pub offset: [f32; 2],
    pub world_pos: [f32; 3],
    pub z_index: i32,
    pub text_2: String,
    pub style: EnumSet<HudStyleFlag>,
}

impl HudElement {
    pub fn apply_change(&mut self, change: HudChange) {
        use HudChange::*;

        match change {
            Pos(v) => self.pos = v,
            Name(v) => self.name = v,
            Scale(v) => self.scale = v,
            Text(v) => self.text = v,
            Number(v) => self.number = v,
            Item(v) => self.item = v,
            Dir(v) => self.dir = v,
            Align(v) => self.align = v,
            Offset(v) => self.offset = v,
            WorldPos(v) => self.world_pos = v,
            ZIndex(v) => self.z_index = v,
            Text2(v) => self.text_2 = v,
            Style(v) => self.style = v,
        }
    }
}

#[mt_derive(to = "clt", repr = "u32", enumset)]
pub enum HudFlag {
    Hotbar,
    HealthBar,
    Crosshair,
    WieldedItem,
    BreathBar,
    Minimap,
    RadarMinimap,
}

#[mt_derive(to = "clt", repr = "u16", tag = "attribute", content = "value")]
pub enum HotbarParam {
    Size(#[mt(const16 = 4)] u32) = 0,
    Image(String),
    SelectionImage(String),
}

#[mt_derive(to = "clt", repr = "u16")]
pub enum MinimapType {
    None = 0,
    Surface,
    Radar,
    Texture,
}

#[mt_derive(to = "clt")]
pub struct MinimapMode {
    pub minimap_type: MinimapType,
    pub label: String,
    pub size: u16,
    pub texture: String,
    pub scale: u16,
}

/*
TODO: rustify

var DefaultMinimap = []MinimapMode{
    {Type: NoMinimap},
    {Type: SurfaceMinimap, Size: 256},
    {Type: SurfaceMinimap, Size: 128},
    {Type: SurfaceMinimap, Size: 64},
    {Type: RadarMinimap, Size: 512},
    {Type: RadarMinimap, Size: 256},
    {Type: RadarMinimap, Size: 128},
}
*/