Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
layoutholder.c
Go to the documentation of this file.
1class LayoutHolder extends ScriptedWidgetEventHandler
2{
3 protected Widget m_MainWidget;
4 protected Widget m_RootWidget;
5 protected Widget m_ParentWidget;
6 protected LayoutHolder m_Parent;
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
15 void UpdateInterval();
16 void SetLayoutName();
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..
20 void SetImmedUpdate()
21 {
22 m_ImmedUpdate = false;
23 }
24
25 void OnSelectAction(ItemBase item, int actionId)
26 {
27 #ifdef DIAG_DEVELOPER
28 PlayerBase m_player = PlayerBase.Cast( g_Game.GetPlayer() );
29 m_player.GetActionManager().OnInstantAction(ActionDebug,new Param2<ItemBase,int>(item,actionId));
30 #endif
31 }
32
33 void OnSelectActionEx(EntityAI item, int actionId)
34 {
35 #ifdef DIAG_DEVELOPER
36 PlayerBase m_player = PlayerBase.Cast( g_Game.GetPlayer() );
37 m_player.GetActionManager().OnInstantAction(ActionDebug,new Param2<EntityAI,int>(item,actionId));
38 #endif
39 }
40
41 void ShowActionMenu(InventoryItem item)
42 {
43 PlayerBase m_player = PlayerBase.Cast( g_Game.GetPlayer() );
44 HideOwnedTooltip();
45 m_am_entity1 = item;
46 m_am_entity2 = null;
47 ContextMenu cmenu = ContextMenu.Cast(g_Game.GetUIManager().GetMenu().GetContextMenu());
48
49 cmenu.Hide();
50 cmenu.Clear();
51
52 if (m_am_entity1 == null)
53 return;
54
55 TSelectableActionInfoArrayEx customActions = new TSelectableActionInfoArrayEx();
56 ItemBase itemBase = ItemBase.Cast(item);
57 itemBase.GetDebugActions(customActions);
58
59 if (ItemBase.GetDebugActionsMask() & DebugActionType.PLAYER_AGENTS)
60 {
61 m_player.GetDebugActions(customActions);
62 }
63
64 int actionsCount = customActions.Count();
65 for (int i = 0; i < customActions.Count(); i++)
66 {
67 TSelectableActionInfoWithColor actionInfo = TSelectableActionInfoWithColor.Cast(customActions.Get(i));
68 if (actionInfo)
69 {
70 int actionId = actionInfo.param2;
71 int textColor = actionInfo.param4;
72 string actionText = actionInfo.param3;
73
74 if (actionId == EActions.SEPARATOR)
75 cmenu.AddEx(actionText, textColor, this, "", null);
76 else
77 cmenu.AddEx(actionText, textColor, this, "OnSelectActionEx", new Param3<EntityAI, int, int>(itemBase, actionId, textColor));
78 }
79 }
80
81 int actionMenuPosX, actionMenuPosY;
82 GetMousePos(actionMenuPosX, actionMenuPosY);
83 actionMenuPosX -= 5;
84 actionMenuPosY -= 5;
85 cmenu.Show(actionMenuPosX, actionMenuPosY);
86 }
87
88
89 void LayoutHolder( LayoutHolder parent )
90 {
91 m_Parent = parent;
92
94 SetParentWidget();
95 SetImmedUpdate();
96
97 m_TooltipOwner = false;
98
99 if ( m_LayoutName != "" )
100 {
101 m_MainWidget = g_Game.GetWorkspace().CreateWidgets( m_LayoutName, null, false );
102 m_MainWidget.Show( true, false );
103 }
104
105 m_RootWidget = m_MainWidget;
106
107 if ( m_ParentWidget )
108 {
109 m_ParentWidget.Show( true, false );
110 if ( m_MainWidget )
111 {
112 m_ParentWidget.AddChild( m_MainWidget, false );
113 }
114 }
115
116 if ( m_ImmedUpdate )
117 {
118 if ( m_MainWidget )
119 m_MainWidget.Update();
120 }
121 }
122
123 void ~LayoutHolder()
124 {
125 HideOwnedTooltip();
126 delete m_RootWidget;
127 }
128
129 LayoutHolder GetRoot()
130 {
131 if ( m_Parent )
132 {
133 ref LayoutHolder container = m_Parent.GetRoot();
134 return container;
135 }
136 else
137 {
138 return this;
139 }
140 }
141
142 void SetParentWidget()
143 {
144 if ( m_Parent )
145 m_ParentWidget = m_Parent.GetMainWidget();
146 }
147
148 LayoutHolder GetParent()
149 {
150 return m_Parent;
151 }
152
153 void SetActive(bool active)
154 {
155 m_IsActive = active;
156 }
157
158 void SetLastActive();
159 void SetFirstActive();
160
161 bool IsActive()
162 {
163 return m_IsActive;
164 }
165
166 Widget GetMainWidget()
167 {
168 return m_MainWidget;
169 }
170
171 Widget GetRootWidget()
172 {
173 return m_RootWidget;
174 }
175
176 bool IsDisplayable()
177 {
178 return true;
179 }
180
181 bool IsVisible()
182 {
183 if (m_RootWidget)
184 {
185 return m_RootWidget.IsVisible();
186 }
187 return false;
188 }
189
190 void OnShow()
191 {
192 m_RootWidget.Show( true );
193 if ( m_ParentWidget )
194 m_ParentWidget.Show( true );
195 }
196
197 void OnHide()
198 {
199 m_RootWidget.Show( false );
200 }
201
202 void Refresh()
203 {
204 m_RootWidget.Update();
205 }
206
207 void InspectItem( EntityAI item )
208 {
209 InventoryMenu menu = InventoryMenu.Cast( g_Game.GetUIManager().FindMenu(MENU_INVENTORY) );
210 InspectMenuNew inspect_menu = InspectMenuNew.Cast( menu.EnterScriptedMenu(MENU_INSPECT) );
211 if ( inspect_menu )
212 {
213 Hud hud = g_Game.GetMission().GetHud();
214 hud.ShowHudUI( false );
215 hud.ShowQuickbarUI( false );
216 inspect_menu.SetItem( item );
217 }
218 }
219
221 {}
222
223 void PrepareOwnedTooltip(EntityAI item/*, Widget w*/, int x = 0, int y = 0)
224 {
225 ItemManager.GetInstance().PrepareTooltip(item,x,y);
226 m_TooltipOwner = true;
227 }
228
229 void PrepareOwnedSlotsTooltip(Widget w, string name, string desc, int x = 0, int y = 0)
230 {
231 ItemManager.GetInstance().SetTooltipWidget(w);
232 ItemManager.GetInstance().PrepareSlotsTooltip(name,desc,x,y);
233 m_TooltipOwner = true;
234 }
235
236 void HideOwnedTooltip()
237 {
238 if (m_TooltipOwner)
239 {
240 ItemManager.GetInstance().HideTooltip();
241 m_TooltipOwner = false;
242 }
243 }
244
245 void HideOwnedSlotsTooltip()
246 {
247 if (m_TooltipOwner)
248 {
249 ItemManager.GetInstance().HideTooltipSlot();
250 m_TooltipOwner = false;
251 }
252 }
253}
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition entityai.c:104
class LogManager EntityAI
Entity m_Parent
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
override void UpdateInterval()
Definition container.c:768
override void SetFirstActive()
Definition container.c:823
override void Refresh()
Definition container.c:1251
bool InspectItem()
Definition container.c:387
override void SetLayoutName()
Definition container.c:1196
override void SetLastActive()
Definition container.c:779
override void UpdateSelectionIcons()
Definition container.c:1307
override void OnShow()
DayZGame g_Game
Definition dayzgame.c:3942
EActions
Definition eactions.c:2
class GP5GasMask extends MaskBase ItemBase
const int MENU_INSPECT
Definition constants.c:179
const int MENU_INVENTORY
Definition constants.c:180
proto void GetMousePos(out int x, out int y)
Object GetParent()
Get parent of the Effect.
Definition effect.c:422
Icon x
Icon y
override void OnHide()
void InventoryMenu()
bool m_IsActive
bool IsActive()
DebugActionType
void OnSelectAction(EntityAI ent, int actionId)
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
DayZPlayer m_player
void SetActive()
Definition trapbase.c:404
Widget m_ParentWidget