Mercurial > LightClone
annotate LightClone/Source/GuiElement.cpp @ 18:33cb6979ac51
More work on GUI system
author | koryspansel |
---|---|
date | Wed, 14 Sep 2011 17:24:49 -0700 |
parents | 4951acfe92fc |
children | 51718795f019 |
rev | line source |
---|---|
10
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
1 /* |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
2 * GuiElement |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
3 */ |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
4 |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
5 #include "GuiElement.h" |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
6 |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
7 /* |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
8 * GuiElement |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
9 */ |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
10 GuiElement::GuiElement() |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
11 { |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
12 } |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
13 |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
14 /* |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
15 * ~GuiElement |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
16 */ |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
17 GuiElement::~GuiElement() |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
18 { |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
19 } |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
20 |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
21 /* |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
22 * Attach |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
23 */ |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
24 void GuiElement::Attach(GuiElement* pInstance) |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
25 { |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
26 pContainer = pInstance; |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
27 } |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
28 |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
29 /* |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
30 * Detach |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
31 */ |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
32 GuiElement* GuiElement::Detach() |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
33 { |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
34 GuiElement* pInstance = pContainer; |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
35 pContainer = NULL; |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
36 return pInstance; |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
37 } |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
38 |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
39 /* |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
40 * GetContainer |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
41 */ |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
42 GuiElement* GuiElement::GetContainer() |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
43 { |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
44 return pContainer; |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
45 } |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
46 |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
47 /* |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
48 * SetPosition |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
49 */ |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
50 void GuiElement::SetPosition(float fX, float fY) |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
51 { |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
52 kPosition.x = fX; |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
53 kPosition.y = fY; |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
54 } |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
55 |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
56 /* |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
57 * SetPosition |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
58 */ |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
59 void GuiElement::SetPosition(const D3DXVECTOR2& kValue) |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
60 { |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
61 kPosition = kValue; |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
62 } |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
63 |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
64 /* |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
65 * GetPosition |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
66 */ |
18 | 67 const D3DXVECTOR2 GuiElement::GetPosition() const |
10
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
68 { |
18 | 69 return pContainer ? pContainer->GetPosition() + kPosition : kPosition; |
10
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
70 } |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
71 |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
72 /* |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
73 * SetDimensions |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
74 */ |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
75 void GuiElement::SetDimensions(float fWidth, float fHeight) |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
76 { |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
77 kDimensions.x = fWidth; |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
78 kDimensions.y = fHeight; |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
79 } |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
80 |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
81 /* |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
82 * SetDimensions |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
83 */ |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
84 void GuiElement::SetDimensions(const D3DXVECTOR2& kValue) |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
85 { |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
86 kDimensions = kValue; |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
87 } |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
88 |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
89 /* |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
90 * GetDimensions |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
91 */ |
18 | 92 const D3DXVECTOR2 GuiElement::GetDimensions() const |
10
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
93 { |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
94 return kDimensions; |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
95 } |
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
96 |
11
d80d06d5ff53
Begin working on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
10
diff
changeset
|
97 /* |
d80d06d5ff53
Begin working on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
10
diff
changeset
|
98 * Pick |
d80d06d5ff53
Begin working on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
10
diff
changeset
|
99 */ |
d80d06d5ff53
Begin working on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
10
diff
changeset
|
100 GuiElement* GuiElement::Pick(float fX, float fY) |
d80d06d5ff53
Begin working on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
10
diff
changeset
|
101 { |
18 | 102 const D3DXVECTOR2& kLocation = GetPosition(); |
11
d80d06d5ff53
Begin working on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
10
diff
changeset
|
103 |
18 | 104 return Rectangle2(kLocation.y, kLocation.y, kDimensions.x, kDimensions.y).Contains(fX, fY) ? this : NULL; |
10
292e534f00c2
Moved rendering into Bot/Environment; Started work on Gui system
koryspansel <koryspansel@bendbroadband.com>
parents:
diff
changeset
|
105 } |