DayZ 1.24
Loading...
Searching...
No Matches
LayoutHolder.c
Go to the documentation of this file.
2{
5 protected Widget m_ParentWidget;
7 protected string m_LayoutName;
8
9 protected bool m_IsActive;
10 protected bool m_ImmedUpdate;
11 protected bool m_TooltipOwner;
12
13 protected EntityAI m_am_entity1, m_am_entity2;
14
17
18 // Override this and set m_ImmedUpdate to true if you need the widget to update on construction
19 // Had to be done this way since adding it to the constructor parameters would break mods..
21 {
22 m_ImmedUpdate = false;
23 }
24
26 {
27#ifdef DIAG_DEVELOPER
29 m_player.GetActionManager().OnInstantAction(ActionDebug, new Param2<ItemBase, int>(item, actionId));
30#endif
31 }
32
34 {
35#ifdef DIAG_DEVELOPER
37 m_player.GetActionManager().OnInstantAction(ActionDebug, new Param2<EntityAI, int>(item, actionId));
38#endif
39 }
40
42 {
44 HideOwnedTooltip();
45 m_am_entity1 = item;
46 m_am_entity2 = null;
47 ContextMenu cmenu = ContextMenu.Cast(GetGame().GetUIManager().GetMenu().GetContextMenu());
48
49 cmenu.Hide();
50 cmenu.Clear();
51
52 if (m_am_entity1 == null)
53 return;
54
57 itemBase.GetDebugActions(customActions);
58
59 if (ItemBase.GetDebugActionsMask() & DebugActionType.PLAYER_AGENTS)
60 m_player.GetDebugActions(customActions);
61
62 int actionsCount = customActions.Count();
63 for (int i = 0; i < customActions.Count(); i++)
64 {
66 if (actionInfo)
67 {
68 int actionId = actionInfo.param2;
69 int textColor = actionInfo.param4;
70 string actionText = actionInfo.param3;
71
72 if (actionId == EActions.SEPARATOR)
73 cmenu.AddEx(actionText, textColor, this, "", null);
74 else
75 cmenu.AddEx(actionText, textColor, this, "OnSelectActionEx", new Param3<EntityAI, int, int>(itemBase, actionId, textColor));
76 }
77 }
78
81 actionMenuPosX -= 5;
82 actionMenuPosY -= 5;
84 }
85
86
88 {
89 m_Parent = parent;
90
92 SetParentWidget();
93 SetImmedUpdate();
94
95 m_TooltipOwner = false;
96
97 if (m_LayoutName != "")
98 {
99 m_MainWidget = GetGame().GetWorkspace().CreateWidgets(m_LayoutName, null, false);
100 m_MainWidget.Show(true, false);
101 }
102
103 m_RootWidget = m_MainWidget;
104
105 if (m_ParentWidget)
106 {
107 m_ParentWidget.Show(true, false);
108 if (m_MainWidget)
109 m_ParentWidget.AddChild(m_MainWidget, false);
110 }
111
112 if (m_ImmedUpdate)
113 {
114 if (m_MainWidget)
115 m_MainWidget.Update();
116 }
117 }
118
120 {
121 HideOwnedTooltip();
122 delete m_RootWidget;
123 }
124
126 {
127 if (m_Parent)
128 {
130 return container;
131 }
132 else
133 return this;
134 }
135
137 {
138 if (m_Parent)
139 m_ParentWidget = m_Parent.GetMainWidget();
140 }
141
143 {
144 return m_Parent;
145 }
146
147 void SetActive(bool active)
148 {
150 }
151
154
155 bool IsActive()
156 {
157 return m_IsActive;
158 }
159
161 {
162 return m_MainWidget;
163 }
164
166 {
167 return m_RootWidget;
168 }
169
171 {
172 return true;
173 }
174
176 {
177 if (m_RootWidget)
178 return m_RootWidget.IsVisible();
179 return false;
180 }
181
182 void OnShow()
183 {
184 m_RootWidget.Show(true);
185 if (m_ParentWidget)
186 m_ParentWidget.Show(true);
187 }
188
189 void OnHide()
190 {
191 m_RootWidget.Show(false);
192 }
193
194 void Refresh()
195 {
196 m_RootWidget.Update();
197 }
198
200 {
201 InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
202 InspectMenuNew inspect_menu = InspectMenuNew.Cast(menu.EnterScriptedMenu(MENU_INSPECT));
203 if (inspect_menu)
204 {
205 GetGame().GetMission().GetHud().ShowHudUI(false);
206 GetGame().GetMission().GetHud().ShowQuickbarUI(false);
207 inspect_menu.SetItem(item);
208 }
209 }
210
212 {}
213
214 void PrepareOwnedTooltip(EntityAI item/*, Widget w*/, int x = 0, int y = 0)
215 {
216 ItemManager.GetInstance().PrepareTooltip(item, x, y);
217 m_TooltipOwner = true;
218 }
219
220 void PrepareOwnedSlotsTooltip(Widget w, string name, string desc, int x = 0, int y = 0)
221 {
222 ItemManager.GetInstance().SetTooltipWidget(w);
223 ItemManager.GetInstance().PrepareSlotsTooltip(name, desc, x, y);
224 m_TooltipOwner = true;
225 }
226
228 {
229 if (m_TooltipOwner)
230 {
231 ItemManager.GetInstance().HideTooltip();
232 m_TooltipOwner = false;
233 }
234 }
235
237 {
238 if (m_TooltipOwner)
239 {
240 ItemManager.GetInstance().HideTooltipSlot();
241 m_TooltipOwner = false;
242 }
243 }
244}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
EActions
Definition EActions.c:2
Icon x
Icon y
override ContextMenu GetContextMenu()
void InventoryMenu()
bool m_IsActive
PlayerBase GetPlayer()
DebugActionType
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
DayZPlayer m_player
Widget m_Parent
Definition SizeToChild.c:86
Widget m_ParentWidget
static ItemManager GetInstance()
override void SetLayoutName()
Definition Container.c:968
map: item x vector(index, width, height)
Definition EnWidgets.c:651
void ShowActionMenu(InventoryItem item)
void PrepareOwnedSlotsTooltip(Widget w, string name, string desc, int x=0, int y=0)
void PrepareOwnedTooltip(EntityAI item, int x=0, int y=0)
void OnSelectAction(ItemBase item, int actionId)
void LayoutHolder(LayoutHolder parent)
void InspectItem(EntityAI item)
void OnSelectActionEx(EntityAI item, int actionId)
void SetActive(bool active)
proto native CGame GetGame()
const int MENU_INSPECT
Definition constants.c:169
const int MENU_INVENTORY
Definition constants.c:170
proto void GetMousePos(out int x, out int y)