-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFrame.cs
81 lines (61 loc) · 2.08 KB
/
Frame.cs
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
using System.Runtime.InteropServices;
using System;
using System.Text;
namespace mumblelib
{
using wchar = UInt16;
class Text
{
public static Encoding Encoding = Encoding.Unicode;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public unsafe struct Frame
{
public uint uiVersion;
public uint uiTick;
public fixed float fAvatarPosition[3];
public fixed float fAvatarFront[3];
public fixed float fAvatarTop[3];
public fixed wchar name[256];
public fixed float fCameraPosition[3];
public fixed float fCameraFront[3];
public fixed float fCameraTop[3];
public fixed wchar id[256];
public uint context_len;
public fixed byte context[256];
public fixed wchar description[2048];
public void SetName(string name)
{
fixed (Frame* ptr = &this)
{
byte[] bytes = Text.Encoding.GetBytes(name + "\u0000");
Marshal.Copy(bytes, 0, new IntPtr(ptr->name), bytes.Length);
}
}
public void SetDescription(string desc)
{
fixed (Frame* ptr = &this)
{
byte[] bytes = Text.Encoding.GetBytes(desc + "\u0000");
Marshal.Copy(bytes, 0, new IntPtr(ptr->description), bytes.Length);
}
}
public void SetID(string id)
{
fixed (Frame* ptr = &this)
{
byte[] bytes = Text.Encoding.GetBytes(id + "\u0000");
Marshal.Copy(bytes, 0, new IntPtr(ptr->id), bytes.Length);
}
}
public void SetContext(string context)
{
fixed (Frame* ptr = &this)
{
byte[] bytes = Encoding.UTF8.GetBytes(context);
this.context_len = (uint)Math.Min(256, bytes.Length);
Marshal.Copy(bytes, 0, new IntPtr(ptr->context), (int)this.context_len);
}
}
}
}