DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
AttachmentCategoriesContainer.c
См. документацию.
2{
4 protected int m_SlotsCount;
6
11
13 {
14 #ifdef PLATFORM_CONSOLE
15 if (IsActive() && GetParent())
16 {
17 LeftArea leftArea = LeftArea.Cast(GetParent());
18 if (leftArea)
19 {
20 leftArea.SetFirstActive();
21 leftArea.ScrollToActiveContainer();
22 }
23 }
24 #endif
25 }
26
27 void SetEntity(EntityAI entity)
28 {
29 m_Entity = entity;
31
32 m_MainWidget = m_RootWidget.FindAnyWidget("body");
33 WidgetEventHandler.GetInstance().RegisterOnChildAdd(m_MainWidget, this, "OnChildAdd");
34 WidgetEventHandler.GetInstance().RegisterOnChildRemove(m_MainWidget, this, "OnChildRemove");
35
37
38 (Container.Cast(m_Parent)).m_Body.Insert(this);
39 m_Parent.Refresh();
41 RecomputeOpenedContainers();
42 }
43
45 {
46 TypeAttachmentGroupsDataHolder holder = m_Entity.GetTypeAttachmentGroupInfoHolder();
47 string text = "";
48 if (holder)
49 text = holder.GetHeaderDisplayName();
50
51 if (text == "")
52 text = m_Entity.GetDisplayName();
53
54 m_CollapsibleHeader.SetName(text);
55 }
56
57 override bool IsDisplayable()
58 {
59 return !IsEmpty() || CanDisplayAnyCategory();
60 }
61
62 override void UpdateInterval()
63 {
64 if (m_Entity)
65 {
66 int childrenCount = m_Body.Count();
67 int displayableChildrenCount = 0;
68
69 if (childrenCount > 0)
70 {
71 int i;
72 for (i = m_SlotsCount; i < childrenCount; ++i)
73 {
75 if (row)
76 {
77 if (m_Entity.CanDisplayAttachmentCategory(row.GetCategoryIdentifier()))
78 {
79 if (row.IsDisplayable())
80 {
82 if (!row.IsVisible())
83 row.OnShow();
84 }
85 else
86 {
88 if (row.IsVisible())
89 row.OnHide();
90 }
91 }
92 else
93 {
95 if (row.IsVisible())
96 row.OnHide();
97 }
98 row.UpdateInterval();
99 }
100 else
101 {
102 ContainerWithCargo cargo = ContainerWithCargo.Cast(m_Body[i]);
103 if (cargo)
104 {
105 if (m_Entity.CanDisplayCargo())
106 {
107 m_CargoSlotsIcon.m_MainWidget.Show(true);
108 if (!cargo.IsVisible())
109 cargo.OnShow();
110 }
111 else
112 {
113 m_CargoSlotsIcon.m_MainWidget.Show(false);
114 if (cargo.IsVisible())
115 cargo.OnHide();
116 }
117 cargo.UpdateInterval();
118 }
119 RecomputeOpenedContainers();
120 }
121
122 }
123
124 //finally update slot category icons
125 for (i = 0; i < m_SlotsCount; ++i)
126 {
128 if (slotsContainer.IsDisplayable())
129 {
130 if (!m_Hidden)
131 slotsContainer.OnShow();
132 else
133 slotsContainer.OnHide();
134
135 displayableChildrenCount++; //slot category icons should always count as 'there', regardless of visibility due to closed state of the parent container
136 }
137 else
138 {
139 slotsContainer.OnHide();
140 }
141 }
142 }
143
144 bool show = displayableChildrenCount > 0 && !m_Entity.GetInventory().IsInventoryLockedForLockType(HIDE_INV_FROM_SCRIPT);
145 if (!m_CollapsibleHeader.IsVisible() && show)
146 {
147 m_CollapsibleHeader.OnShow();
148 }
149 else if (m_CollapsibleHeader.IsVisible() && !show)
150 {
151 m_CollapsibleHeader.OnHide();
152 HideContent();
153 }
154
155 GetMainWidget().Show(show);
156 }
157 }
158
159 void LoadAttachmentCategoriesIcon(SlotsContainer items_cont, string icon_name, int slot_number)
160 {
161 SlotsIcon icon = items_cont.GetSlotIcon(slot_number);
162 ImageWidget image_widget = icon.GetGhostSlot();
163 image_widget.Show(true);
164 image_widget.LoadImageFile(0, StaticGUIUtils.VerifyIconImageString(StaticGUIUtils.IMAGESETGROUP_INVENTORY,icon_name)); //icon_name must be in format "set:<setname> image:<imagename>"
165 }
166
167 int GetAttachmentCategoriesCount(string config_path)
168 {
169 return g_Game.ConfigGetChildrenCount( config_path );
170 }
171
173 {
174 AttachmentCategoriesSlotsContainer items_cont = AttachmentCategoriesSlotsContainer.Cast(m_Body.Get(icons_row));
175 return items_cont.GetSlotsContainer();
176 }
177
182
183 void ShowInSlots(string category, bool show)
184 {
185 int index = m_CategorySlotIndex.Get(category);
186 int slot_number = index % ITEMS_IN_ROW;
187
188 SlotsContainer items_cont = GetSlotsContainer(index / ITEMS_IN_ROW);
189 if (items_cont)
190 {
191 Widget icon_widget = items_cont.GetSlotIcon(slot_number).GetMainWidget();
192 if (icon_widget)
193 icon_widget.Show(show);
194 icon_widget.GetParent().Update();
195 icon_widget.GetParent().GetParent().Update();
196 icon_widget.GetParent().GetParent().GetParent().Update();
197 }
198 }
199
200 //oof
201 override bool CanDisplayAnyCategory()
202 {
204 foreach (LayoutHolder holder : m_Body)
205 {
206 if (Class.CastTo(row, holder) && m_Entity.CanDisplayAttachmentCategory(row.GetCategoryIdentifier()))
207 return true;
208 }
209 return super.CanDisplayAnyCategory();
210 }
211
212 override void UpdateRadialIcon()
213 {
214 if (m_SlotIcon)
215 {
216 if (m_Entity.CanDisplayCargo() || CanDisplayAnyCategory())
217 {
218 m_SlotIcon.GetRadialIconPanel().Show(true);
219 SetOpenForSlotIcon(!m_Hidden);
220 }
221 else
222 {
223 m_SlotIcon.GetRadialIconPanel().Show(false);
224 }
225 }
226 }
227
228 string GetAttachmentCategory(string config_path_attachment_categories, int i)
229 {
230 string attachment_category;
231 g_Game.ConfigGetChildName(config_path_attachment_categories, i, attachment_category);
232 return attachment_category;
233 }
234
235 string GetIconName(string config_path_attachment_categories, string attachment_category)
236 {
237 string icon_path = config_path_attachment_categories+ " " + attachment_category + " icon";
238 string icon_name;
239 g_Game.ConfigGetText(icon_path, icon_name);
240 return icon_name;
241 }
242
243 int GetViewIndex(string config_path_attachment_categories, string attachment_category)
244 {
245 string preview_path = config_path_attachment_categories+ " " + attachment_category + " view_index";
246 return g_Game.ConfigGetInt( preview_path );
247 }
248
250 {
251 SlotsIcon icon;
252 w.GetUserData(icon);
253
255 if (c)
256 c.Toggle();
257 }
258
260 {
261 if (m_OpenedContainers.Count() > m_ActiveIndex)
262 {
263 //c - container where selected icon is part of
264 Container c = Container.Cast(m_OpenedContainers.Get(m_ActiveIndex));
265 //cc - container connected to selected icon (this container will be close/open)
267 //icon - selected icon
268 SlotsIcon icon = c.GetFocusedSlotsIcon();
269
270 if (icon)
271 {
272 cc = ClosableContainer.Cast(icon.GetContainer());
273 }
274
275 if (cc)
276 {
277
278 cc.Toggle();
279 RecomputeOpenedContainers();
280 }
281 }
282 }
283
285 {
286 return m_CollapsibleHeader.IsActive();
287 }
288
290 {
291 m_SlotsCount = 0;
292 TypeAttachmentGroupsDataHolder holder = m_Entity.GetTypeAttachmentGroupInfoHolder();
293 int categoriesCount = 0;
294 if (holder)
295 categoriesCount = holder.GetValidAttachmnetGroupCount();
296
297 if (m_Entity.GetInventory().GetCargo())
298 {
299 categoriesCount++;
300 }
301 int rowCount = categoriesCount / ITEMS_IN_ROW;
302 if (categoriesCount % ITEMS_IN_ROW != 0)
303 {
304 rowCount++;
305 }
306 for (int i = 0; i < rowCount; ++i)
307 {
309 m_Body.Insert(itemsCont);
310 m_OpenedContainers.Insert(itemsCont);
311
312 //TODO MW find better way
313 if (i == (rowCount - 1) && categoriesCount % ITEMS_IN_ROW != 0)
314 itemsCont.GetSlotsContainer().SetColumnCount(categoriesCount % ITEMS_IN_ROW);
315 else
316 itemsCont.GetSlotsContainer().SetColumnCount(ITEMS_IN_ROW);
317 }
318 m_SlotsCount = rowCount;
319 }
320
322 {
323 TypeAttachmentGroupsDataHolder holder = m_Entity.GetTypeAttachmentGroupInfoHolder();
324 TAttachmentGroupMap groupMap = holder.GetAttachmentGroupMap();
325 int categoriesCount = holder.GetValidAttachmnetGroupCount();
326 int childrenCount = m_Body.Count();
327
328 SlotsContainer items_cont;
329 SlotsIcon icon;
330 string attCategoryClass;
331 string icon_name2;
332 TypeAttachmentGroupData groupData;
333
334 for (int i = 0; i < categoriesCount; ++i)
335 {
336 items_cont = GetSlotsContainer(i / ITEMS_IN_ROW);
337 attCategoryClass = groupMap.GetKey(i);
338 groupData = groupMap.Get(attCategoryClass);
339
340 if (items_cont)
341 {
342 int slot_number = i % ITEMS_IN_ROW;
343 m_CategorySlotIndex.Insert(attCategoryClass, i);
344 icon = items_cont.GetSlotIcon(slot_number);
345 icon.GetGhostSlot().SetFlags(WidgetFlags.IGNOREPOINTER);
346 LoadAttachmentCategoriesIcon(items_cont, groupData.m_IconPath, slot_number);
347 icon.SetSlotDisplayName(groupData.m_Name);
348
350 ar = new AttachmentCategoriesRow(this, -1);
351 ar.Init(categoriesCount, i, attCategoryClass, holder.GetPropsCfgPath(), m_Entity, childrenCount);
352
353 ar.SetSlotIcon(icon);
354
355 icon.GetRadialIconPanel().Show(true);
356 ar.Open();
357 icon.SetContainer(ar);
358 Insert(ar);
359 }
360 }
361
362 if (m_Entity.GetInventory().GetCargo())
363 {
364 items_cont = GetSlotsContainer(m_SlotsCount - 1);
365 if (items_cont)
366 {
367 icon = items_cont.GetSlotIcon(categoriesCount);
368 icon.GetGhostSlot().Show(true);
369 icon.GetGhostSlot().LoadImageFile(0, StaticGUIUtils.VerifyIconImageString(StaticGUIUtils.IMAGESETGROUP_INVENTORY,m_Entity.ConfigGetString("GUIInventoryCargoIcon")));
370 icon.SetSlotDisplayName(m_Entity.ConfigGetString("GUIInventoryCargoName"));
371 icon.GetGhostSlot().SetFlags(WidgetFlags.IGNOREPOINTER);
372
373 icon.GetRadialIconPanel().Show(true);
374 icon.GetMainWidget().Show(true);
375
376 ContainerWithCargo iwc = new ContainerWithCargo(this, -1);
377 iwc.Get(0).GetRootWidget().ClearFlags(WidgetFlags.DRAGGABLE);
378 iwc.SetEntity(m_Entity, 0, false);
379 iwc.SetSlotIcon(icon);
380 iwc.Open();
381
382 icon.SetContainer(iwc);
383 m_CargoSlotsIcon = icon;
384 }
385 }
386
387 RecomputeOpenedContainers();
388 }
389
390
391 override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
392 {
393 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
394 if (!iw)
395 {
396 string name = w.GetName();
397 name.Replace("PanelWidget", "Render");
398 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
399 }
400 if (!iw)
401 {
402 iw = ItemPreviewWidget.Cast(w);
403 }
404 if (!iw.GetItem())
405 return;
406 if (m_Entity.GetInventory().CanAddAttachment(iw.GetItem()) && iw.GetItem().GetInventory().CanRemoveEntity())
407 {
408 g_Game.GetPlayer().PredictiveTakeEntityToTargetAttachment( m_Entity, iw.GetItem() );
409 }
410 else if (m_Entity.GetInventory().CanAddEntityToInventory(iw.GetItem()) && iw.GetItem().GetInventory().CanRemoveEntity())
411 {
412 g_Game.GetPlayer().PredictiveTakeEntityToTargetInventory( m_Entity, FindInventoryLocationType.ANY, iw.GetItem() );
413 }
414 }
415
416 override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
417 {
418 if (w == null)
419 {
420 return;
421 }
422 ItemPreviewWidget iw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
423 if (!iw)
424 {
425 string name = w.GetName();
426 name.Replace("PanelWidget", "Render");
427 iw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
428 }
429 if (!iw)
430 {
431 iw = ItemPreviewWidget.Cast(w);
432 }
433 if (!iw || !iw.GetItem())
434 {
435 return;
436 }
437
440 }
441
443 {
444 if (!m_Hidden)
445 {
446 int childrenCount = m_Body.Count();
447 for (int i = 1; i < childrenCount; ++i)
448 {
449 m_Body.Get(i).OnHide();
450 Container c = Container.Cast(m_Body.Get(i));
451 if (c)
452 {
453 c.Close();
454 }
455 }
456
457 OnHide();
458 }
459 else
460 {
461 OnShow();
462 }
463 m_Closed = m_Hidden;
464
467 {
468 m_CollapsibleHeader.SetHeaderVisible(true);
469 }
470
472 RecomputeOpenedContainers();
473 }
474
475 override void Open()
476 {
477 if (IsDisplayable())
478 {
479 super.Open();
480 //ItemManager.GetInstance().SetDefaultOpenState(m_Entity.GetType(), true);
481 SetOpenForSlotIcon(true);
482 OnShow();
483 //m_Parent.m_Parent.Refresh();
484 }
485 }
486
487 override void Close()
488 {
489 //ItemManager.GetInstance().SetDefaultOpenState(m_Entity.GetType(), false);
490 super.Close();
491
492 SlotsIcon icon = null;
493 if (m_CargoSlotsIcon && m_CargoSlotsIcon.GetObject())
494 {
495 icon = m_CargoSlotsIcon;
496 }
497 else if (m_SlotIcon && m_SlotIcon.GetObject())
498 {
499 icon = m_SlotIcon;
500 }
501
502 SetOpenForSlotIcon(false,icon);
503 OnHide();
504 }
505
506 override void OnHide()
507 {
509 {
510 bool b1 = !m_SlotIcon && !m_CargoSlotsIcon;
511 bool b2 = (!m_SlotIcon || !m_SlotIcon.IsVisible()) && m_CargoSlotsIcon && m_CargoSlotsIcon.IsVisible();
512 m_CollapsibleHeader.SetHeaderVisible(b1 || b2);
513 }
514 super.OnHide();
515 }
516
517 override bool CanOpenCloseContainerEx(EntityAI focusedEntity)
518 {
519 if (m_OpenedContainers.Count() > m_ActiveIndex)
520 {
522 SlotsIcon icon = GetFocusedSlotsIcon();
523
524 if (icon)
525 {
526 c = ClosableContainer.Cast(icon.GetContainer());
527 }
528
529 if (c && c.IsDisplayable())
530 {
531 return true;
532 }
533 }
534
535 return false;
536 }
537
539 {
540 TypeAttachmentGroupsDataHolder holder = m_Entity.GetTypeAttachmentGroupInfoHolder();
541 if (holder)
542 holder.RefreshLocalizedTexts();
543
545
546 if (holder)
547 {
548 TAttachmentGroupMap groupMap = holder.GetAttachmentGroupMap();
549 foreach (string attCategoryClass, int slotIndex : m_CategorySlotIndex)
550 {
551 TypeAttachmentGroupData groupData = groupMap.Get(attCategoryClass);
552 SlotsContainer items_cont = GetSlotsContainer(slotIndex / ITEMS_IN_ROW);
553 if (items_cont && groupData)
554 {
555 SlotsIcon icon = items_cont.GetSlotIcon(slotIndex % ITEMS_IN_ROW);
556 if (icon)
557 icon.SetSlotDisplayName(groupData.m_Name);
558 }
559 }
560 }
561 }
562}
const int ITEMS_IN_ROW
bool IsActive()
Определения BunkerBroadcastComponent.c:255
Entity m_Entity
Определения CachedEquipmentStorageBase.c:16
Entity m_Parent
Определения CachedEquipmentStorageBase.c:17
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Определения DayZGame.c:4074
Icon x
Icon y
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
Определения PluginRemotePlayerDebugClient.c:14
map< string, ref TypeAttachmentGroupData > TAttachmentGroupMap
Определения TypeAttachmentGroupDataHolders.c:1
override bool CanDisplayAnyCategory()
override void UpdateInterval()
Определения AttachmentCategoriesContainer.c:62
int GetViewIndex(string config_path_attachment_categories, string attachment_category)
override void DraggingOverHeader(Widget w, int x, int y, Widget receiver)
override void CollapseButtonOnMouseButtonDown(Widget w)
ref map< string, int > m_CategorySlotIndex
Определения AttachmentCategoriesContainer.c:3
void ShowInSlots(string category, bool show)
override void UpdateRadialIcon()
override bool CanOpenCloseContainerEx(EntityAI focusedEntity)
void AttachmentCategoriesContainer(LayoutHolder parent, int sort=-1)
Определения AttachmentCategoriesContainer.c:7
void SetEntity(EntityAI entity)
Определения AttachmentCategoriesContainer.c:27
override void ExpandCollapseContainer()
override void OnDropReceivedFromHeader(Widget w, int x, int y, Widget receiver)
void LoadAttachmentCategoriesIcon(SlotsContainer items_cont, string icon_name, int slot_number)
string GetAttachmentCategory(string config_path_attachment_categories, int i)
int GetAttachmentCategoriesCount(string config_path)
override bool IsDisplayable()
Определения AttachmentCategoriesContainer.c:57
string GetIconName(string config_path_attachment_categories, string attachment_category)
SlotsContainer GetSlotsContainer(int icons_row)
override void UpdateInterval()
Определения AttachmentCategoriesRow.c:987
void Init(int attachments_categories_count, int i, string attachment_category, string config_path_attachment_categories, EntityAI entity, int parent_m_Body_count)
Определения AttachmentCategoriesRow.c:914
string GetCategoryIdentifier()
Определения AttachmentCategoriesRow.c:23
Super root of all classes in Enforce script.
Определения EnScript.c:11
override void Open()
Определения ContainerWithCargo.c:68
override bool IsDisplayable()
Определения ContainerWithCargo.c:19
bool m_Hidden
Определения CollapsibleContainer.c:4
void CollapsibleContainer(LayoutHolder parent, int sort=-1)
Определения CollapsibleContainer.c:6
ref CollapsibleHeader m_CollapsibleHeader
Определения CollapsibleContainer.c:3
void SetCollapsibleHeaderArrowState(bool open)
Определения CollapsibleContainer.c:186
override void OnShow()
Определения CollapsibleContainer.c:36
override void Insert(LayoutHolder container, int pos=-1, bool immedUpdate=true)
Определения CollapsibleContainer.c:66
void UpdateCollapseButtons()
Определения CollapsibleContainer.c:91
void SetColor(Widget w, int color)
Определения ColorManager.c:32
static int RED_COLOR
Определения ColorManager.c:16
static ColorManager GetInstance()
Определения ColorManager.c:27
Определения ColorManager.c:2
override void Close()
Определения ClosableContainer.c:79
override void OnShow()
Определения ClosableContainer.c:93
override bool IsEmpty()
Определения CargoContainer.c:795
void ClosableContainer(LayoutHolder parent, int sort=-1)
Определения ClosableContainer.c:6
Определения CargoContainer.c:3
void ShowSourceDropzone(EntityAI item)
Определения ItemManager.c:302
static ItemManager GetInstance()
Определения ItemManager.c:282
Определения ItemManager.c:2
proto native EntityAI GetItem()
Определения gameplay.c:287
Определения Container.c:2
Определения LeftArea.c:2
SlotsIcon GetSlotIcon(int index)
Определения SlotsContainer.c:207
Определения SlotsContainer.c:2
void SetContainer(Container container)
Определения SlotsIconBase.c:109
Container GetContainer()
Определения SlotsIconBase.c:119
Widget GetRadialIconPanel()
Определения SlotsIconBase.c:270
ImageWidget GetGhostSlot()
Определения SlotsIconBase.c:205
void SetSlotDisplayName(string text)
Определения SlotsIconBase.c:114
Определения SlotsIcon.c:2
static const int IMAGESETGROUP_INVENTORY
Определения StaticGUIUtils.c:3
static string VerifyIconImageString(int imageset_group=IMAGESETGROUP_INVENTORY, string icon_name="")
Checks for improperly formated, legacy image names and corrects them to default format.
Определения StaticGUIUtils.c:7
Определения StaticGUIUtils.c:2
string m_IconPath
Displayable, unlocalized name.
Определения TypeAttachmentGroupData.c:11
Data for one attachment group.
Определения TypeAttachmentGroupData.c:4
TAttachmentGroupMap GetAttachmentGroupMap()
void RefreshLocalizedTexts()
Re-reads localized header/name strings without rebuilding slot config data.
Data holder for attachment group classes.
Определения TypeAttachmentGroupDataHolders.c:5
void RegisterOnChildRemove(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:167
static WidgetEventHandler GetInstance()
Определения WidgetEventHandler.c:22
void RegisterOnChildAdd(Widget w, Managed eventHandler, string functionName)
Определения WidgetEventHandler.c:160
Определения EnWidgets.c:190
Определения Transport.c:70
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto native Widget GetParent()
Get parent of the Effect.
Определения Effect.c:422
WidgetFlags
Определения EnWidgets.c:58