DayZ
1.24
Loading...
Searching...
No Matches
ActionMenu.c
Go to the documentation of this file.
1
class
ActionMenu
2
{
3
private
const
float
FADE_IN_TIME
= 0.3;
4
private
const
float
FADE_OUT_TIME
= 0.3;
5
private
const
float
HIDE_MENU_TIME
= 5;
6
7
private
ref
WidgetFadeTimer
m_FadeTimer
;
8
private
ref
array<TextWidget>
m_actionItems
;
9
private
TextWidget
m_defaultActionWidget
;
10
private
Widget
m_actionsPanelWidget
;
11
private
ref
Timer
m_hide_timer
;
12
13
private
bool
m_visible
;
14
15
void
ActionMenu
()
16
{
17
m_actionItems
=
new
array<TextWidget>
;
18
m_FadeTimer
=
new
WidgetFadeTimer;
19
m_hide_timer
=
new
Timer
(
CALL_CATEGORY_GUI
);
20
m_visible
=
false
;
21
}
22
23
void
Init
(
Widget
actions_panel_widget
,
TextWidget
default_action_widget
)
24
{
25
m_defaultActionWidget
=
default_action_widget
;
26
m_actionsPanelWidget
=
actions_panel_widget
;
27
m_actionItems
.Clear();
28
int
i
= 0;
29
TextWidget
w
=
TextWidget
.Cast(
m_actionsPanelWidget
.FindAnyWidget(
"ActionListItem"
+
i
.ToString()));
30
31
while
(
w
)
32
{
33
m_actionItems
.Insert(
w
);
34
w
.Show(
false
);
35
i
++;
36
w
=
TextWidget
.Cast(
m_actionsPanelWidget
.FindAnyWidget(
"ActionListItem"
+
i
.ToString()));
37
}
38
39
m_defaultActionWidget
.Show(
false
);
40
m_actionsPanelWidget
.Show(
true
);
41
m_actionsPanelWidget
.SetAlpha(0);
42
}
43
44
void
UpdateWidgets
()
45
{
46
#ifdef DIAG_DEVELOPER
47
// tmp
48
bool
newATSelection
=
DiagMenu
.
GetBool
(
DiagMenuIDs
.MISC_ACTION_TARGETS_NEW,
true
);
49
50
// read the action manager
51
PlayerBase
player
=
PlayerBase
.Cast(
GetGame
().
GetPlayer
());
52
TSelectableActionInfoArray
actions
=
player
.GetActionManager().GetSelectableActions();
53
int
selectedActionIndex
=
player
.GetActionManager().GetSelectedActionIndex();
54
55
// clear state
56
m_defaultActionWidget
.Show(
false
);
57
if
(
actions
.Count() <= 1)
58
m_FadeTimer
.FadeOut(
m_actionsPanelWidget
,
FADE_OUT_TIME
,
true
);
59
else
60
m_FadeTimer
.FadeIn(
m_actionsPanelWidget
,
FADE_IN_TIME
,
true
);
61
62
// update state
63
for
(
int
i
= 0;
i
<
m_actionItems
.Count();
i
++)
64
{
65
TextWidget
w
=
m_actionItems
.Get(
i
);
66
67
if
(
i
<
actions
.Count())
68
{
69
TSelectableActionInfo
actionInfo
=
actions
.Get(
i
);
70
w
.SetText(
actionInfo
.param3);
71
72
if
(
i
==
selectedActionIndex
)
73
{
74
w
.SetColor(0xFFFFEC44);
75
76
m_defaultActionWidget
.SetText(
actionInfo
.param3);
77
if
(!
newATSelection
)
78
m_defaultActionWidget
.Show(
true
);
79
}
80
else
81
w
.SetColor(0xFFFFFFFF);
82
83
w
.Show(
true
);
84
}
85
else
86
w
.Show(
false
);
87
}
88
89
float
sx
;
90
float
sy
;
91
m_actionsPanelWidget
.GetSize(
sx
,
sy
);
92
m_actionsPanelWidget
.SetSize(
sx
, 8 + (
actions
.Count() * 32));
93
#endif
94
}
95
96
void
NextAction
()
97
{
98
PlayerBase
player
=
PlayerBase
.Cast(
GetGame
().
GetPlayer
());
99
player
.GetActionManager().SelectNextAction();
100
101
UpdateWidgets
();
102
103
m_hide_timer
.Run(
HIDE_MENU_TIME
,
this
,
"HideWithFadeout"
);
104
}
105
106
void
PrevAction
()
107
{
108
PlayerBase
player
=
PlayerBase
.Cast(
GetGame
().
GetPlayer
());
109
player
.GetActionManager().SelectPrevAction();
110
111
UpdateWidgets
();
112
113
m_hide_timer
.Run(
HIDE_MENU_TIME
,
this
,
"HideWithFadeout"
);
114
}
115
116
void
NextActionCategory
()
117
{
118
PlayerBase
player
=
PlayerBase
.Cast(
GetGame
().
GetPlayer
());
119
player
.GetActionManager().SelectNextActionCategory();
120
121
UpdateWidgets
();
122
123
m_hide_timer
.Run(
HIDE_MENU_TIME
,
this
,
"HideWithFadeout"
);
124
}
125
126
void
PrevActionCategory
()
127
{
128
PlayerBase
player
=
PlayerBase
.Cast(
GetGame
().
GetPlayer
());
129
player
.GetActionManager().SelectPrevActionCategory();
130
131
UpdateWidgets
();
132
133
m_hide_timer
.Run(
HIDE_MENU_TIME
,
this
,
"HideWithFadeout"
);
134
}
135
136
void
Show
()
137
{
138
if
(
m_visible
)
139
return
;
140
141
m_visible
=
true
;
142
m_hide_timer
.Run(
HIDE_MENU_TIME
,
this
,
"HideWithFadeout"
);
143
}
144
145
void
Refresh
()
146
{
147
if
(!
m_visible
)
148
Show
();
149
150
PlayerBase
player
=
PlayerBase
.Cast(
GetGame
().
GetPlayer
());
151
if
(
player
.GetActionManager().IsSelectableActionsChanged())
152
UpdateWidgets
();
153
}
154
155
void
Hide
()
156
{
157
if
(!
m_visible
)
158
return
;
159
160
m_visible
=
false
;
161
m_hide_timer
.Stop();
162
m_FadeTimer
.Stop();
163
//m_defaultActionWidget.Show(false);
164
m_actionsPanelWidget
.Show(
false
);
165
}
166
167
void
HideWithFadeout
()
168
{
169
//m_defaultActionWidget.Show(false);
170
if
(
m_actionsPanelWidget
.IsVisible())
171
m_FadeTimer
.FadeOut(
m_actionsPanelWidget
,
FADE_OUT_TIME
,
true
);
172
}
173
}
DiagMenuIDs
DiagMenuIDs
Definition
EDiagMenuIDs.c:2
GetPlayer
PlayerBase GetPlayer()
Definition
ModifierBase.c:47
ActionMenu
Definition
ActionMenu.c:2
ActionMenu::PrevAction
void PrevAction()
Definition
ActionMenu.c:106
ActionMenu::Refresh
void Refresh()
Definition
ActionMenu.c:145
ActionMenu::m_hide_timer
ref Timer m_hide_timer
Definition
ActionMenu.c:11
ActionMenu::HIDE_MENU_TIME
const float HIDE_MENU_TIME
Definition
ActionMenu.c:5
ActionMenu::NextActionCategory
void NextActionCategory()
Definition
ActionMenu.c:116
ActionMenu::FADE_OUT_TIME
const float FADE_OUT_TIME
Definition
ActionMenu.c:4
ActionMenu::Init
void Init(Widget actions_panel_widget, TextWidget default_action_widget)
Definition
ActionMenu.c:23
ActionMenu::ActionMenu
void ActionMenu()
Definition
ActionMenu.c:15
ActionMenu::HideWithFadeout
void HideWithFadeout()
Definition
ActionMenu.c:167
ActionMenu::m_actionItems
ref array< TextWidget > m_actionItems
Definition
ActionMenu.c:8
ActionMenu::UpdateWidgets
void UpdateWidgets()
Definition
ActionMenu.c:44
ActionMenu::m_visible
bool m_visible
Definition
ActionMenu.c:13
ActionMenu::NextAction
void NextAction()
Definition
ActionMenu.c:96
ActionMenu::m_FadeTimer
ref WidgetFadeTimer m_FadeTimer
Definition
ActionMenu.c:7
ActionMenu::PrevActionCategory
void PrevActionCategory()
Definition
ActionMenu.c:126
ActionMenu::Show
void Show()
Definition
ActionMenu.c:136
ActionMenu::FADE_IN_TIME
const float FADE_IN_TIME
Definition
ActionMenu.c:3
ActionMenu::m_actionsPanelWidget
Widget m_actionsPanelWidget
Definition
ActionMenu.c:10
ActionMenu::Hide
void Hide()
Definition
ActionMenu.c:155
ActionMenu::m_defaultActionWidget
TextWidget m_defaultActionWidget
Definition
ActionMenu.c:9
DiagMenu
Definition
EnDebug.c:233
Param3
Definition
EntityAI.c:95
PlayerBase
Definition
PlayerBaseClient.c:2
TextWidget
Definition
EnWidgets.c:220
Timer
Definition
DayZPlayerImplement.c:61
Widget
Definition
EnWidgets.c:190
GetGame
proto native CGame GetGame()
DiagMenu::GetBool
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
CALL_CATEGORY_GUI
const int CALL_CATEGORY_GUI
Definition
tools.c:9
scripts
5_Mission
GUI
ActionMenu.c
Generated by
1.10.0