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