forked from Phobos-developers/YRpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BasicStructures.h
101 lines (80 loc) · 1.7 KB
/
BasicStructures.h
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
#pragma once
struct Color16Struct;
//used for most colors
struct ColorStruct
{
ColorStruct() = default;
ColorStruct(BYTE const r, BYTE const g, BYTE const b)
: R(r), G(g), B(b)
{ }
inline explicit ColorStruct(Color16Struct const color);
bool operator == (ColorStruct const rhs) const {
return R == rhs.R && G == rhs.G && B == rhs.B;
}
bool operator != (ColorStruct const rhs) const {
return !(*this == rhs);
}
BYTE R, G, B;
};
struct BytePalette {
ColorStruct Entries[256];
ColorStruct& operator [](int const idx) {
return this->Entries[idx];
}
ColorStruct const& operator [](int const idx) const {
return this->Entries[idx];
}
};
//used for light colors
struct TintStruct
{
int Red, Green, Blue;
};
//16bit colors
#pragma pack(push, 1)
struct Color16Struct
{
Color16Struct() = default;
explicit Color16Struct(ColorStruct const color) :
R(static_cast<unsigned short>(color.R >> 3u)),
G(static_cast<unsigned short>(color.G >> 2u)),
B(static_cast<unsigned short>(color.B >> 3u))
{ }
bool operator == (Color16Struct const rhs) const {
return R == rhs.R && G == rhs.G && B == rhs.B;
}
bool operator != (Color16Struct const rhs) const {
return !(*this == rhs);
}
unsigned short R : 5;
unsigned short G : 6;
unsigned short B : 5;
};
#pragma pack(pop)
inline ColorStruct::ColorStruct(Color16Struct const color) :
R(static_cast<BYTE>(color.R << 3)),
G(static_cast<BYTE>(color.G << 2)),
B(static_cast<BYTE>(color.B << 3))
{ }
//Random number range
struct RandomStruct
{
int Min, Max;
};
//3D Matrix
struct Matrix3DStruct
{
float Data[12];
};
//obvious
struct RectangleStruct
{
int X, Y, Width, Height;
};
struct LTRBStruct
{
int Left;
int Top;
int Right;
int Bottom;
};