DayZ 1.24
Loading...
Searching...
No Matches
ActionMenu.c
Go to the documentation of this file.
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;
12
13 private bool m_visible;
14
16 {
18 m_FadeTimer = new WidgetFadeTimer;
20 m_visible = false;
21 }
22
24 {
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
45 {
46#ifdef DIAG_DEVELOPER
47 // tmp
48 bool newATSelection = DiagMenu.GetBool(DiagMenuIDs.MISC_ACTION_TARGETS_NEW, true);
49
50 // read the action manager
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)
59 else
61
62 // update state
63 for (int i = 0; i < m_actionItems.Count(); i++)
64 {
66
67 if (i < actions.Count())
68 {
70 w.SetText(actionInfo.param3);
71
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
97 {
99 player.GetActionManager().SelectNextAction();
100
102
103 m_hide_timer.Run(HIDE_MENU_TIME, this, "HideWithFadeout");
104 }
105
107 {
109 player.GetActionManager().SelectPrevAction();
110
112
113 m_hide_timer.Run(HIDE_MENU_TIME, this, "HideWithFadeout");
114 }
115
117 {
119 player.GetActionManager().SelectNextActionCategory();
120
122
123 m_hide_timer.Run(HIDE_MENU_TIME, this, "HideWithFadeout");
124 }
125
127 {
129 player.GetActionManager().SelectPrevActionCategory();
130
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
151 if (player.GetActionManager().IsSelectableActionsChanged())
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
168 {
169 //m_defaultActionWidget.Show(false);
170 if (m_actionsPanelWidget.IsVisible())
172 }
173}
DiagMenuIDs
Definition EDiagMenuIDs.c:2
PlayerBase GetPlayer()
void PrevAction()
Definition ActionMenu.c:106
void Refresh()
Definition ActionMenu.c:145
ref Timer m_hide_timer
Definition ActionMenu.c:11
const float HIDE_MENU_TIME
Definition ActionMenu.c:5
void NextActionCategory()
Definition ActionMenu.c:116
const float FADE_OUT_TIME
Definition ActionMenu.c:4
void Init(Widget actions_panel_widget, TextWidget default_action_widget)
Definition ActionMenu.c:23
void ActionMenu()
Definition ActionMenu.c:15
void HideWithFadeout()
Definition ActionMenu.c:167
ref array< TextWidget > m_actionItems
Definition ActionMenu.c:8
void UpdateWidgets()
Definition ActionMenu.c:44
bool m_visible
Definition ActionMenu.c:13
void NextAction()
Definition ActionMenu.c:96
ref WidgetFadeTimer m_FadeTimer
Definition ActionMenu.c:7
void PrevActionCategory()
Definition ActionMenu.c:126
void Show()
Definition ActionMenu.c:136
const float FADE_IN_TIME
Definition ActionMenu.c:3
Widget m_actionsPanelWidget
Definition ActionMenu.c:10
void Hide()
Definition ActionMenu.c:155
TextWidget m_defaultActionWidget
Definition ActionMenu.c:9
proto native CGame GetGame()
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
const int CALL_CATEGORY_GUI
Definition tools.c:9