forked from derandark/DungeonViewerAC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HUDControls.cpp
120 lines (87 loc) · 1.98 KB
/
HUDControls.cpp
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
#include "StdAfx.h"
#include "Render.h"
#include "HUDControls.h"
Region::Region(const RECT& Rect)
{
m_Rect = Rect;
}
Region::~Region()
{
}
BOOL Region::PointInRegion(long x, long y)
{
if (x >= m_Rect.left &&
x <= m_Rect.right &&
y >= m_Rect.top &&
y <= m_Rect.bottom)
return TRUE;
return FALSE;
}
HUDControl::HUDControl(const RECT& Rect) : Region(Rect)
{
m_Visible = TRUE;
}
HUDControl::~HUDControl()
{
}
BOOL HUDControl::GetVisible()
{
return m_Visible;
}
void HUDControl::SetVisible(BOOL Visible)
{
m_Visible = Visible;
}
void HUDControl::Draw()
{
if (!GetVisible())
return;
DrawInternal();
}
void HUDControl::DrawBox(long x, long y, long cx, long cy, COLORREF Color, float Width, BOOL Antialias)
{
LPD3DXLINE lpLineDrawer = Render::GetLineDrawer();
if (!lpLineDrawer)
return;
// Transform local coordinates to device coordinates..
D3DXVECTOR2 Box[5];
Box[0] = Box[1] = Box[2] = Box[3] = Box[4] =
D3DXVECTOR2(m_Rect.left + x, m_Rect.top + y);
Box[1].x += cx;
Box[2].x += cx;
Box[2].y += cy;
Box[3].y += cy;
lpLineDrawer->SetWidth(Width);
lpLineDrawer->SetAntialias(Antialias);
lpLineDrawer->Begin();
lpLineDrawer->Draw(Box, 5, Color);
lpLineDrawer->End();
}
void HUDControl::DrawRegionBox()
{
LPD3DXLINE lpLineDrawer = Render::GetLineDrawer();
if (!lpLineDrawer)
return;
D3DXVECTOR2 Box[5];
Box[0].x = Box[4].x = m_Rect.left;
Box[0].y = Box[4].y = m_Rect.top;
Box[1].x = m_Rect.right;
Box[1].y = m_Rect.top;
Box[2].x = m_Rect.right;
Box[2].y = m_Rect.bottom;
Box[3].x = m_Rect.left;
Box[3].y = m_Rect.bottom;
lpLineDrawer->SetWidth(3);
lpLineDrawer->Begin();
lpLineDrawer->Draw(Box, 5, 0xFFFF0000);
lpLineDrawer->End();
}
ButtonControl::ButtonControl(const RECT& Rect) : HUDControl(Rect)
{
}
ButtonControl::~ButtonControl()
{
}
void ButtonControl::DrawInternal()
{
}