DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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
25 void OnSelectAction(ItemBase item, int actionId)
26 {
28 m_player.GetActionManager().OnInstantAction(ActionDebug,new Param2<ItemBase,int>(item,actionId));
29 }
30
32 {
34 HideOwnedTooltip();
35 m_am_entity1 = item;
36 m_am_entity2 = null;
37 ContextMenu cmenu = ContextMenu.Cast(GetGame().GetUIManager().GetMenu().GetContextMenu());
38
39 cmenu.Hide();
40 cmenu.Clear();
41
42 if (m_am_entity1 == null)
43 return;
44
45 TSelectableActionInfoArrayEx customActions = new TSelectableActionInfoArrayEx();
46 ItemBase itemBase = ItemBase.Cast(item);
47 itemBase.GetDebugActions(customActions);
48
49 if (ItemBase.GetDebugActionsMask() & DebugActionType.PLAYER_AGENTS)
50 {
51 m_player.GetDebugActions(customActions);
52 }
53
54 int actionsCount = customActions.Count();
55 for (int i = 0; i < customActions.Count(); i++)
56 {
57 TSelectableActionInfoWithColor actionInfo = TSelectableActionInfoWithColor.Cast(customActions.Get(i));
58 if (actionInfo)
59 {
60 int actionId = actionInfo.param2;
61 int textColor = actionInfo.param4;
62 string actionText = actionInfo.param3;
63
64 if (actionId == EActions.SEPARATOR)
65 cmenu.AddEx(actionText, textColor, this, "", null);
66 else
67 cmenu.AddEx(actionText, textColor, this, "OnSelectAction", new Param3<ItemBase, int, int>(itemBase, actionId, textColor));
68 }
69 }
70
71 int actionMenuPosX, actionMenuPosY;
72 GetMousePos(actionMenuPosX, actionMenuPosY);
73 actionMenuPosX -= 5;
74 actionMenuPosY -= 5;
75 cmenu.Show(actionMenuPosX, actionMenuPosY);
76 }
77
78
80 {
81 m_Parent = parent;
82
84 SetParentWidget();
85 SetImmedUpdate();
86
87 m_TooltipOwner = false;
88
89 if ( m_LayoutName != "" )
90 {
91 m_MainWidget = GetGame().GetWorkspace().CreateWidgets( m_LayoutName, null, false );
92 m_MainWidget.Show( true, false );
93 }
94
95 m_RootWidget = m_MainWidget;
96
97 if ( m_ParentWidget )
98 {
99 m_ParentWidget.Show( true, false );
100 if ( m_MainWidget )
101 {
102 m_ParentWidget.AddChild( m_MainWidget, false );
103 }
104 }
105
106 if ( m_ImmedUpdate )
107 {
108 if ( m_MainWidget )
109 m_MainWidget.Update();
110 }
111 }
112
114 {
115 HideOwnedTooltip();
116 delete m_RootWidget;
117 }
118
120 {
121 if ( m_Parent )
122 {
123 ref LayoutHolder container = m_Parent.GetRoot();
124 return container;
125 }
126 else
127 {
128 return this;
129 }
130 }
131
133 {
134 if ( m_Parent )
135 m_ParentWidget = m_Parent.GetMainWidget();
136 }
137
139 {
140 return m_Parent;
141 }
142
143 void SetActive(bool active)
144 {
145 m_IsActive = active;
146 }
147
150
151 bool IsActive()
152 {
153 return m_IsActive;
154 }
155
157 {
158 return m_MainWidget;
159 }
160
162 {
163 return m_RootWidget;
164 }
165
167 {
168 return true;
169 }
170
172 {
173 if (m_RootWidget)
174 {
175 return m_RootWidget.IsVisible();
176 }
177 return false;
178 }
179
180 void OnShow()
181 {
182 m_RootWidget.Show( true );
183 if ( m_ParentWidget )
184 m_ParentWidget.Show( true );
185 }
186
187 void OnHide()
188 {
189 m_RootWidget.Show( false );
190 }
191
192 void Refresh()
193 {
194 m_RootWidget.Update();
195 }
196
198 {
199 InventoryMenu menu = InventoryMenu.Cast( GetGame().GetUIManager().FindMenu(MENU_INVENTORY) );
200 InspectMenuNew inspect_menu = InspectMenuNew.Cast( menu.EnterScriptedMenu(MENU_INSPECT) );
201 if ( inspect_menu )
202 {
203 GetGame().GetMission().GetHud().ShowHudUI( false );
205 inspect_menu.SetItem( item );
206 }
207 }
208
210 {}
211
212 void PrepareOwnedTooltip(EntityAI item/*, Widget w*/, int x = 0, int y = 0)
213 {
215 m_TooltipOwner = true;
216 }
217
218 void PrepareOwnedSlotsTooltip(Widget w, string name, string desc, int x = 0, int y = 0)
219 {
222 m_TooltipOwner = true;
223 }
224
226 {
227 if (m_TooltipOwner)
228 {
230 m_TooltipOwner = false;
231 }
232 }
233
235 {
236 if (m_TooltipOwner)
237 {
239 m_TooltipOwner = false;
240 }
241 }
242}
Param4< int, int, string, int > TSelectableActionInfoWithColor
EActions
Definition EActions.c:2
Icon x
Icon y
override ContextMenu GetContextMenu()
void InventoryMenu()
bool m_IsActive
PlayerBase GetPlayer()
string name
DebugActionType
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
DayZPlayer m_player
protected Widget m_Parent
Definition SizeToChild.c:92
protected Widget m_ParentWidget
proto native Mission GetMission()
proto native WorkspaceWidget GetWorkspace()
void ShowHudUI(bool show)
void ShowQuickbarUI(bool show)
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
void PrepareTooltip(EntityAI item, int x=0, int y=0)
void HideTooltipSlot()
void PrepareSlotsTooltip(string name, string desc, int x=0, int y=0)
position is currentlycalculated from the owning 'm_TooltipSourceWidget' directly
void HideTooltip()
void SetTooltipWidget(Widget w)
static ItemManager GetInstance()
override void SetLayoutName()
Definition Container.c:961
Hud GetHud()
Definition gameplay.c:697
map: item x vector(index, width, height)
Definition EnWidgets.c:538
protected bool m_IsActive
Definition LayoutHolder.c:9
protected string m_LayoutName
Definition LayoutHolder.c:7
protected Widget m_MainWidget
Definition LayoutHolder.c:3
void LayoutHolder(LayoutHolder parent)
void PrepareOwnedTooltip(EntityAI item, int x=0, int y=0)
void SetActive(bool active)
protected bool m_ImmedUpdate
protected LayoutHolder m_Parent
Definition LayoutHolder.c:6
void OnSelectAction(ItemBase item, int actionId)
protected EntityAI m_am_entity1
void InspectItem(EntityAI item)
void ShowActionMenu(InventoryItem item)
protected bool m_TooltipOwner
protected Widget m_RootWidget
Definition LayoutHolder.c:4
void PrepareOwnedSlotsTooltip(Widget w, string name, string desc, int x=0, int y=0)
proto native CGame GetGame()
const int MENU_INSPECT
Definition constants.c:157
const int MENU_INVENTORY
Definition constants.c:158
proto void GetMousePos(out int x, out int y)
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.