DayZ
1.24
Loading...
Searching...
No Matches
ClosableHeader.c
Go to the documentation of this file.
1
class
ClosableHeader
:
Header
2
{
3
protected
float
m_SquareSize
;
4
protected
int
m_DefaultSort
;
5
6
protected
Widget
m_MovePanel
;
7
protected
Widget
m_PanelWidget
;
8
protected
Widget
m_DragRender
;
9
protected
ButtonWidget
m_MoveUp
;
10
protected
ButtonWidget
m_MoveDown
;
11
12
protected
bool
m_IsInLocalEquipment
;
13
14
void
ClosableHeader
(
LayoutHolder
parent,
string
function_name
)
15
{
16
m_MovePanel
= GetMainWidget().FindAnyWidget(
"MovePanel"
);
17
m_PanelWidget
= GetMainWidget().FindAnyWidget(
"PanelWidget"
);
18
m_DragRender
= GetMainWidget().FindAnyWidget(
"Drag_Render"
);
19
m_MoveUp
=
ButtonWidget
.Cast(GetMainWidget().
FindAnyWidget
(
"MoveUp"
));
20
m_MoveDown
=
ButtonWidget
.Cast(GetMainWidget().
FindAnyWidget
(
"MoveDown"
));
21
22
WidgetEventHandler
.
GetInstance
().RegisterOnClick(
m_MoveUp
,
m_Parent
,
"MoveContainerUp"
);
23
WidgetEventHandler
.
GetInstance
().RegisterOnClick(
m_MoveDown
,
m_Parent
,
"MoveContainerDown"
);
24
WidgetEventHandler
.
GetInstance
().RegisterOnMouseLeave(
m_MoveUp
,
this
,
"MouseLeave"
);
25
WidgetEventHandler
.
GetInstance
().RegisterOnMouseLeave(
m_MoveDown
,
this
,
"MouseLeave"
);
26
27
WidgetEventHandler
.
GetInstance
().RegisterOnDrag(GetMainWidget(),
this
,
"OnDragHeader"
);
28
WidgetEventHandler
.
GetInstance
().RegisterOnDrop(GetMainWidget(),
this
,
"OnDropHeader"
);
29
30
WidgetEventHandler
.
GetInstance
().RegisterOnMouseEnter(GetMainWidget(),
this
,
"MouseEnter"
);
31
WidgetEventHandler
.
GetInstance
().RegisterOnMouseLeave(GetMainWidget(),
this
,
"MouseLeave"
);
32
33
float
temp
;
34
GetMainWidget().GetScreenSize(
temp
,
m_SquareSize
);
35
36
m_DefaultColor
=
m_PanelWidget
.GetColor();
37
m_DefaultFontSize
= 20;
38
39
if
(
GetParent
() &&
GetParent
().
GetParent
() &&
GetParent
().
GetParent
().
GetParent
())
40
m_IsInLocalEquipment
=
GetParent
().GetParent().GetParent().IsInherited(
RightArea
);
41
}
42
43
void
~ClosableHeader
()
44
{
45
if
(
InventoryItem
.Cast(
m_Entity
))
46
InventoryItem
.Cast(
m_Entity
).GetOnItemFlipped().Remove(
UpdateFlip
);
47
}
48
49
override
void
SetLayoutName
()
50
{
51
m_LayoutName =
WidgetLayoutName
.
ClosableHeader
;
52
}
53
54
override
void
SetName
(
string
name
)
55
{
56
name
.ToUpper();
57
58
m_HeaderText
.SetText(
name
);
59
m_HeaderText
.Update();
60
61
float
x
,
y
;
62
m_HeaderText
.GetScreenSize(
x
,
y
);
63
m_PanelWidget
.SetSize(1,
y
+
InventoryMenu
.GetHeightMultiplied(10));
64
}
65
66
void
OnDragHeader
(
Widget
w
,
int
x
,
int
y
)
67
{
68
ClosableContainer
parent =
ClosableContainer
.Cast(
m_Parent
);
69
if
(parent && GetMainWidget() &&
m_Entity
)
70
{
71
ItemPreviewWidget
item_preview_drag
=
ItemPreviewWidget
.Cast(
m_DragRender
);
72
item_preview_drag
.SetFlags(
WidgetFlags
.EXACTPOS);
73
m_DefaultSort
= GetRootWidget().GetSort();
74
item_preview_drag
.GetParent().GetParent().GetParent().GetParent().GetParent().GetParent().GetParent().GetParent().AddChild(GetRootWidget());
75
if
(
item_preview_drag
&&
m_Entity
)
76
{
77
item_preview_drag
.SetItem(
m_Entity
);
78
item_preview_drag
.SetView(
m_Entity
.GetViewIndex());
79
}
80
81
ItemManager
.
GetInstance
().SetIsDragging(
true
);
82
83
parent.HideContent(
true
);
84
85
m_PanelWidget
.Show(
false
);
86
if
(
item_preview_drag
)
87
item_preview_drag
.Show(
true
);
88
89
int
ww
,
hh
;
90
GetGame
().GetInventoryItemSize(
InventoryItem
.Cast(
m_Entity
),
ww
,
hh
);
91
if
(
item_preview_drag
)
92
{
93
m_Entity
.GetOnItemFlipped().Insert(
UpdateFlip
);
94
if
(
m_Entity
.GetInventory().GetFlipCargo())
95
item_preview_drag
.SetSize(
hh
*
m_SquareSize
,
ww
*
m_SquareSize
);
96
else
97
item_preview_drag
.SetSize(
ww
*
m_SquareSize
,
hh
*
m_SquareSize
);
98
}
99
}
100
}
101
102
void
UpdateFlip
(
bool
flipped
)
103
{
104
ItemPreviewWidget
item_preview_drag
=
ItemPreviewWidget
.Cast(
m_DragRender
);
105
if
(
InventoryItem
.Cast(
m_Entity
) &&
item_preview_drag
)
106
{
107
int
ww
,
hh
;
108
GetGame
().GetInventoryItemSize(
InventoryItem
.Cast(
m_Entity
),
ww
,
hh
);
109
if
(
flipped
)
110
item_preview_drag
.SetSize(
hh
*
m_SquareSize
,
ww
*
m_SquareSize
);
111
else
112
item_preview_drag
.SetSize(
ww
*
m_SquareSize
,
hh
*
m_SquareSize
);
113
}
114
}
115
116
void
OnDropHeader
(
Widget
w
)
117
{
118
ClosableContainer
parent =
ClosableContainer
.Cast(
m_Parent
);
119
parent.GetMainWidget().AddChild(GetRootWidget());
120
GetRootWidget().SetSort(0);
121
if
(parent)
122
{
123
//
124
ItemPreviewWidget
item_preview_drag
=
ItemPreviewWidget
.Cast(
m_DragRender
);
125
if
(
item_preview_drag
)
126
{
127
item_preview_drag
.SetItem(
null
);
//TODO: is this safe?
128
}
129
//
130
131
m_PanelWidget
.Show(
true
);
132
m_DragRender
.Show(
false
);
133
134
parent.ShowContent(
true
);
135
136
ItemManager
.
GetInstance
().HideDropzones();
137
ItemManager
.
GetInstance
().SetIsDragging(
false
);
138
}
139
if
(
InventoryItem
.Cast(
m_Entity
))
140
InventoryItem
.Cast(
m_Entity
).GetOnItemFlipped().Remove(
UpdateFlip
);
141
}
142
143
bool
MouseEnter
(
Widget
w
,
int
x
,
int
y
)
144
{
145
if
(
m_IsInLocalEquipment
&& !
GetDragWidget
())
146
{
147
#ifdef PLATFORM_CONSOLE
148
m_MovePanel
.Show(
GetGame
().
GetInput
().IsEnabledMouseAndKeyboardEvenOnServer());
149
#else
150
m_MovePanel
.Show(
true
);
151
#endif
152
}
153
PrepareOwnedTooltip(
m_Entity
,
x
,
y
);
154
return
true
;
155
}
156
157
bool
MouseLeave
(
Widget
w
,
Widget
enter_w
,
int
x
,
int
y
)
158
{
159
if
(
enter_w
!=
m_MoveUp
&&
enter_w
!=
m_MoveDown
&&
enter_w
!=
m_CollapseButton
)
160
{
161
if
(
m_IsInLocalEquipment
)
162
m_MovePanel
.Show(
false
);
163
}
164
HideOwnedTooltip();
165
return
true
;
166
}
167
168
override
void
SetActive
(
bool
active
)
169
{
170
super
.SetActive(
active
);
171
if
(
active
)
172
m_PanelWidget
.SetColor(
ARGBF
(1, 1, 0, 0));
173
else
174
m_PanelWidget
.SetColor(
m_DefaultColor
);
175
}
176
}
GetInput
ActionInput GetInput()
Definition
ActionBase.c:989
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
x
Icon x
y
Icon y
InventoryMenu
void InventoryMenu()
Definition
InventoryMenu.c:20
m_Parent
Widget m_Parent
Definition
SizeToChild.c:86
ClosableContainer
Definition
ContainerWithCargo.c:2
ClosableHeader
Definition
ClosableHeader.c:2
ClosableHeader::m_SquareSize
float m_SquareSize
Definition
ClosableHeader.c:3
ClosableHeader::SetActive
override void SetActive(bool active)
Definition
ClosableHeader.c:168
ClosableHeader::m_DragRender
Widget m_DragRender
Definition
ClosableHeader.c:8
ClosableHeader::m_MovePanel
Widget m_MovePanel
Definition
ClosableHeader.c:6
ClosableHeader::m_MoveUp
ButtonWidget m_MoveUp
Definition
ClosableHeader.c:9
ClosableHeader::m_DefaultSort
int m_DefaultSort
Definition
ClosableHeader.c:4
ClosableHeader::OnDropHeader
void OnDropHeader(Widget w)
Definition
ClosableHeader.c:116
ClosableHeader::UpdateFlip
void UpdateFlip(bool flipped)
Definition
ClosableHeader.c:102
ClosableHeader::m_PanelWidget
Widget m_PanelWidget
Definition
ClosableHeader.c:7
ClosableHeader::MouseEnter
bool MouseEnter(Widget w, int x, int y)
Definition
ClosableHeader.c:143
ClosableHeader::m_IsInLocalEquipment
bool m_IsInLocalEquipment
Definition
ClosableHeader.c:12
ClosableHeader::OnDragHeader
void OnDragHeader(Widget w, int x, int y)
Definition
ClosableHeader.c:66
ClosableHeader::ClosableHeader
void ClosableHeader(LayoutHolder parent, string function_name)
Definition
ClosableHeader.c:14
ClosableHeader::m_MoveDown
ButtonWidget m_MoveDown
Definition
ClosableHeader.c:10
ClosableHeader::~ClosableHeader
void ~ClosableHeader()
Definition
ClosableHeader.c:43
ClosableHeader::SetLayoutName
override void SetLayoutName()
Definition
ClosableHeader.c:49
ClosableHeader::SetName
override void SetName(string name)
Definition
ClosableHeader.c:54
ClosableHeader::MouseLeave
bool MouseLeave(Widget w, Widget enter_w, int x, int y)
Definition
ClosableHeader.c:157
Header
Definition
Header.c:2
Header::m_Entity
EntityAI m_Entity
Definition
Header.c:6
Header::m_DefaultFontSize
int m_DefaultFontSize
Definition
Header.c:4
Header::m_DefaultColor
int m_DefaultColor
Definition
Header.c:3
Header::m_CollapseButton
Widget m_CollapseButton
Definition
Header.c:8
Header::m_HeaderText
TextWidget m_HeaderText
Definition
Header.c:11
InventoryItem
Definition
ItemBase.c:14
ItemManager
Definition
ItemManager.c:2
ItemManager::GetInstance
static ItemManager GetInstance()
Definition
ItemManager.c:265
ItemPreviewWidget
Definition
gameplay.c:274
LayoutHolder
Definition
Container.c:2
Param3
Definition
EntityAI.c:95
RightArea
Definition
RightArea.c:2
WidgetEventHandler
Definition
WidgetEventHandler.c:2
WidgetEventHandler::GetInstance
static WidgetEventHandler GetInstance()
Definition
WidgetEventHandler.c:22
Widget
Definition
EnWidgets.c:190
WidgetLayoutName
Definition
WidgetLayoutName.c:2
WidgetLayoutName::ClosableHeader
const string ClosableHeader
Definition
WidgetLayoutName.c:44
GetGame
proto native CGame GetGame()
GetParent
proto native Widget GetParent()
Get parent of the Effect.
Definition
Effect.c:389
WidgetFlags
WidgetFlags
Definition
EnWidgets.c:58
FindAnyWidget
proto native Widget FindAnyWidget(string pathname)
GetDragWidget
proto native Widget GetDragWidget()
ARGBF
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition
proto.c:332
scripts
5_Mission
GUI
InventoryNew
ContainedItems
Headers
ClosableHeader.c
Generated by
1.10.0