DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
AttachmentCategoriesContainer.c
См. документацию.
2{
4 protected int m_SlotsCount;
6
7 void AttachmentCategoriesContainer( LayoutHolder parent, int sort = -1 )
8 {
10 }
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 m_CollapsibleHeader.SetName( m_Entity.GetDisplayName() );
47 }
48
49 override bool IsDisplayable()
50 {
51 return !IsEmpty() || CanDisplayAnyCategory();
52 }
53
54 override void UpdateInterval()
55 {
56 if( m_Entity )
57 {
58 if( m_Entity.GetInventory().IsInventoryLockedForLockType( HIDE_INV_FROM_SCRIPT ) || m_Hidden )
59 {
60 if( m_Body.Count() > 0 && !m_Hidden )
61 m_CollapsibleHeader.OnHide();
62 HideContent();
63 GetMainWidget().Show( false );
64 }
65 else
66 {
67 if( m_Body.Count() > 0 && !m_Hidden )
68 {
69 if( m_Body.Count() > 0 && !m_Hidden )
70 m_CollapsibleHeader.OnShow();
71 int i;
72 for (i = m_SlotsCount; i < m_Body.Count(); i++)
73 {
75 if (row)
76 {
77 if (m_Entity.CanDisplayAttachmentCategory( row.GetCategoryIdentifier() ))
78 {
79 if ( row.IsDisplayable() )
80 {
82 if (!row.IsVisible())
83 {
84 row.OnShow();
85 }
86 }
87 else
88 {
89 ShowInSlots( row.GetCategoryIdentifier(), false );
90 if (row.IsVisible())
91 {
92 row.OnHide();
93 }
94 }
95 }
96 else
97 {
98 ShowInSlots( row.GetCategoryIdentifier(), false );
99 if (row.IsVisible())
100 {
101 row.OnHide();
102 }
103 }
104 row.UpdateInterval();
105 }
106 else
107 {
108 ContainerWithCargo cargo = ContainerWithCargo.Cast(m_Body[i]);
109 if (cargo)
110 {
111 if (m_Entity.CanDisplayCargo())
112 {
113 m_CargoSlotsIcon.m_MainWidget.Show(true);
114 if (!cargo.IsVisible())
115 {
116 cargo.OnShow();
117 }
118 }
119 else
120 {
121 m_CargoSlotsIcon.m_MainWidget.Show(false);
122 if (cargo.IsVisible())
123 {
124 cargo.OnHide();
125 }
126 }
127 cargo.UpdateInterval();
128 }
129 RecomputeOpenedContainers();
130
131 }
132
133 }
134 for ( i = 0; i < m_SlotsCount; i++)
135 {
137 {
138 if (slots.IsDisplayable())
139 {
140 slots.OnShow();
141 }
142 else
143 {
144 slots.OnHide();
145 }
146 }
147 }
148 }
149 GetMainWidget().Show( true );
150 }
151 }
152 }
153
154 void LoadAttachmentCategoriesIcon( SlotsContainer items_cont, string icon_name, int slot_number )
155 {
156 SlotsIcon icon = items_cont.GetSlotIcon( slot_number );
157 ImageWidget image_widget = icon.GetGhostSlot();
158 image_widget.Show( true );
159 image_widget.LoadImageFile( 0, StaticGUIUtils.VerifyIconImageString(StaticGUIUtils.IMAGESETGROUP_INVENTORY,icon_name) ); //icon_name must be in format "set:<setname> image:<imagename>"
160 }
161
162 int GetAttachmentCategoriesCount( string config_path )
163 {
164 return GetGame().ConfigGetChildrenCount( config_path );
165 }
166
168 {
169 AttachmentCategoriesSlotsContainer items_cont = AttachmentCategoriesSlotsContainer.Cast(m_Body.Get(icons_row));
170 return items_cont.GetSlotsContainer();
171 }
172
177
178 void ShowInSlots( string category, bool show )
179 {
180 int index = m_CategorySlotIndex.Get( category );
181 int slot_number = index % ITEMS_IN_ROW;
182
183 SlotsContainer items_cont = GetSlotsContainer( index / ITEMS_IN_ROW );
184 if( items_cont )
185 {
186 Widget icon_widget = items_cont.GetSlotIcon( slot_number ).GetMainWidget();
187 if( icon_widget )
188 icon_widget.Show( show );
189 icon_widget.GetParent().Update();
190 icon_widget.GetParent().GetParent().Update();
191 icon_widget.GetParent().GetParent().GetParent().Update();
192 }
193 }
194
195 //oof
196 override bool CanDisplayAnyCategory()
197 {
198 int count = m_Body.Count();
200 for (int i = m_SlotsCount; i < count; i++)
201 {
202 if (Class.CastTo(row,m_Body[i]) && m_Entity.CanDisplayAttachmentCategory( row.GetCategoryIdentifier() ))
203 {
204 return true;
205 }
206 }
207 return super.CanDisplayAnyCategory();
208 }
209
210 override void UpdateRadialIcon()
211 {
212 if ( m_SlotIcon )
213 {
214 if (m_Entity.CanDisplayCargo() || CanDisplayAnyCategory())
215 {
216 m_SlotIcon.GetRadialIconPanel().Show( true );
217 SetOpenForSlotIcon(!m_Hidden);
218 }
219 else
220 {
221 m_SlotIcon.GetRadialIconPanel().Show( false );
222 }
223 }
224 }
225
226 string GetAttachmentCategory( string config_path_attachment_categories, int i )
227 {
228 string attachment_category;
229 GetGame().ConfigGetChildName(config_path_attachment_categories, i, attachment_category);
230 return attachment_category;
231 }
232
233 string GetIconName( string config_path_attachment_categories, string attachment_category )
234 {
235 string icon_path = config_path_attachment_categories+ " " + attachment_category + " icon";
236 string icon_name;
237 GetGame().ConfigGetText(icon_path, icon_name);
238 return icon_name;
239 }
240
241 int GetViewIndex( string config_path_attachment_categories, string attachment_category )
242 {
243 string preview_path = config_path_attachment_categories+ " " + attachment_category + " view_index";
244 return GetGame().ConfigGetInt( preview_path );;
245 }
246
248 {
249 SlotsIcon icon;
250 w.GetUserData(icon);
251
253 if (c)
254 c.Toggle();
255 }
256
258 {
259 if (m_OpenedContainers.Count() > m_ActiveIndex)
260 {
261 //c - container where selected icon is part of
262 Container c = Container.Cast(m_OpenedContainers.Get( m_ActiveIndex ));
263 //cc - container connected to selected icon (this container will be close/open)
265 //icon - selected icon
266 SlotsIcon icon = c.GetFocusedSlotsIcon();
267
268 if (icon)
269 {
270 cc = ClosableContainer.Cast(icon.GetContainer());
271 }
272
273 if (cc)
274 {
275
276 cc.Toggle();
277 RecomputeOpenedContainers();
278 }
279 }
280 }
281
283 {
284 return m_CollapsibleHeader.IsActive();
285 }
286
288 {
289 m_SlotsCount = 0;
290
291 string type = m_Entity.GetType();
292 string config_path_attachment_categories = "CfgVehicles " + type + " GUIInventoryAttachmentsProps";
293 int attachments_categories_count = GetAttachmentCategoriesCount( config_path_attachment_categories );
294 int categories_count = attachments_categories_count;
295 if (m_Entity.GetInventory().GetCargo())
296 {
297 categories_count++;
298 }
299 int row_count = categories_count / ITEMS_IN_ROW;
300 if (categories_count % ITEMS_IN_ROW != 0)
301 {
302 row_count++;
303 }
304 for ( int i = 0; i < row_count; i++ )
305 {
307 m_Body.Insert( items_cont );
308 m_OpenedContainers.Insert( items_cont );
309
310 //TODO MW find better way
311 if (i == ( row_count - 1 ) && categories_count % ITEMS_IN_ROW != 0)
312 items_cont.GetSlotsContainer().SetColumnCount( categories_count % ITEMS_IN_ROW );
313 else
314 items_cont.GetSlotsContainer().SetColumnCount( ITEMS_IN_ROW );
315 }
316 m_SlotsCount = row_count;
317 }
318
320 {
321 string type = m_Entity.GetType();
322 string config_path_attachment_categories = "CfgVehicles " + type + " GUIInventoryAttachmentsProps";
323
324 int attachments_categories_count = GetAttachmentCategoriesCount( config_path_attachment_categories );
325
326 SlotsContainer items_cont;
327 SlotsIcon icon;
328 string attachment_category;
329 string icon_name;
330
331 for (int i = 0; i < attachments_categories_count; i++)
332 {
333 items_cont = GetSlotsContainer( i / ITEMS_IN_ROW );
334 attachment_category = GetAttachmentCategory( config_path_attachment_categories, i );
335 icon_name = GetIconName( config_path_attachment_categories, attachment_category );
336
337 if ( items_cont )
338 {
339 int slot_number = i % ITEMS_IN_ROW;
340 m_CategorySlotIndex.Insert( attachment_category, i );
341 icon = items_cont.GetSlotIcon( slot_number );
342 icon.GetGhostSlot().SetFlags( WidgetFlags.IGNOREPOINTER );
343
344 LoadAttachmentCategoriesIcon( items_cont, icon_name, slot_number );
345
346 string config = config_path_attachment_categories + " " + attachment_category + " name";
347 string name;
348
349 GetGame().ConfigGetText(config,name);
351
353
354 ar = new AttachmentCategoriesRow( this, -1 );
355 ar.Init(attachments_categories_count, i, attachment_category, config_path_attachment_categories, m_Entity, m_Body.Count() );
356
357 //Insert(ar);
358 ar.SetSlotIcon(icon);
359 //icon.SetContainer(ar);
360
361 icon.GetRadialIconPanel().Show( true );
362 ar.Open();
363 icon.SetContainer(ar);
364 Insert(ar);
365 }
366 }
367
368 if ( m_Entity.GetInventory().GetCargo() )
369 {
370 items_cont = GetSlotsContainer( m_SlotsCount - 1 );
371 if ( items_cont )
372 {
373 icon = items_cont.GetSlotIcon( attachments_categories_count );
374 icon.GetGhostSlot().Show( true );
375 icon.GetGhostSlot().LoadImageFile( 0, StaticGUIUtils.VerifyIconImageString(StaticGUIUtils.IMAGESETGROUP_INVENTORY,m_Entity.ConfigGetString("GUIInventoryCargoIcon")) );
376 icon.SetSlotDisplayName(m_Entity.ConfigGetString("GUIInventoryCargoName"));
377 icon.GetGhostSlot().SetFlags( WidgetFlags.IGNOREPOINTER );
378
379 icon.GetRadialIconPanel().Show( true );
380 icon.GetMainWidget().Show( true );
381
382 ContainerWithCargo iwc = new ContainerWithCargo( this, -1 );
383 iwc.Get( 0 ).GetRootWidget().ClearFlags( WidgetFlags.DRAGGABLE );
384 iwc.SetEntity( m_Entity, 0, false );
385 iwc.SetSlotIcon( icon );
386 iwc.Open();
387
388 icon.SetContainer(iwc);
389 m_CargoSlotsIcon = icon;
390 }
391 }
392
393 RecomputeOpenedContainers();
394 }
395
396
397 override void OnDropReceivedFromHeader( Widget w, int x, int y, Widget receiver )
398 {
399 ItemPreviewWidget iw = ItemPreviewWidget.Cast( w.FindAnyWidget("Render") );
400 if(!iw)
401 {
402 string name = w.GetName();
403 name.Replace("PanelWidget", "Render");
404 iw = ItemPreviewWidget.Cast( w.FindAnyWidget(name) );
405 }
406 if(!iw)
407 {
408 iw = ItemPreviewWidget.Cast( w );
409 }
410 if( !iw.GetItem() )
411 return;
412 if( m_Entity.GetInventory().CanAddAttachment( iw.GetItem() ) && iw.GetItem().GetInventory().CanRemoveEntity() )
413 {
414 GetGame().GetPlayer().PredictiveTakeEntityToTargetAttachment( m_Entity, iw.GetItem() );
415 }
416 else if( m_Entity.GetInventory().CanAddEntityToInventory( iw.GetItem() ) && iw.GetItem().GetInventory().CanRemoveEntity() )
417 {
418 GetGame().GetPlayer().PredictiveTakeEntityToTargetInventory( m_Entity, FindInventoryLocationType.ANY, iw.GetItem() );
419 }
420 }
421
422 override void DraggingOverHeader( Widget w, int x, int y, Widget receiver )
423 {
424 if( w == null )
425 {
426 return;
427 }
428 ItemPreviewWidget iw = ItemPreviewWidget.Cast( w.FindAnyWidget("Render") );
429 if(!iw)
430 {
431 string name = w.GetName();
432 name.Replace("PanelWidget", "Render");
433 iw = ItemPreviewWidget.Cast( w.FindAnyWidget(name) );
434 }
435 if(!iw)
436 {
437 iw = ItemPreviewWidget.Cast( w );
438 }
439 if( !iw || !iw.GetItem() )
440 {
441 return;
442 }
443
446 }
447
448 /*override void CollapseButtonOnMouseButtonDown(Widget w)
449 {
450 super.CollapseButtonOnMouseButtonDown(w);
451 RecomputeOpenedContainers();
452 }*/
454 {
455 if( !m_Hidden )
456 {
457 for (int i = 1; i < m_Body.Count(); i++)
458 {
459 m_Body.Get( i ).OnHide();
460 Container c = Container.Cast(m_Body.Get(i));
461 if (c)
462 {
463 c.Close();
464 }
465 }
466
467 //m_Hidden = true;
468 OnHide();
469 }
470 else
471 {
472 //m_Hidden = false;
473 OnShow();
474 }
475 m_Closed = m_Hidden;
476
479 {
480 m_CollapsibleHeader.SetHeaderVisible(true);
481 }
482
484 RecomputeOpenedContainers();
485 }
486
487 override void Open()
488 {
489 if( IsDisplayable() )
490 {
491 super.Open();
492 //ItemManager.GetInstance().SetDefaultOpenState( m_Entity.GetType(), true );
493 SetOpenForSlotIcon(true);
494 OnShow();
495 //m_Parent.m_Parent.Refresh();
496 }
497 }
498
499 override void Close()
500 {
501 //ItemManager.GetInstance().SetDefaultOpenState( m_Entity.GetType(), false );
502 super.Close();
503
504 SlotsIcon icon = null;
505 if (m_CargoSlotsIcon && m_CargoSlotsIcon.GetObject())
506 {
507 icon = m_CargoSlotsIcon;
508 }
509 else if (m_SlotIcon && m_SlotIcon.GetObject())
510 {
511 icon = m_SlotIcon;
512 }
513
514 SetOpenForSlotIcon(false,icon);
515 OnHide();
516 }
517
518 override void OnHide()
519 {
521 {
522 bool b1 = !m_SlotIcon && !m_CargoSlotsIcon;
523 bool b2 = (!m_SlotIcon || !m_SlotIcon.IsVisible()) && m_CargoSlotsIcon && m_CargoSlotsIcon.IsVisible();
524 m_CollapsibleHeader.SetHeaderVisible(b1 || b2);
525 }
526 super.OnHide();
527 }
528
529 override bool CanOpenCloseContainerEx(EntityAI focusedEntity)
530 {
531 if (m_OpenedContainers.Count() > m_ActiveIndex)
532 {
534 SlotsIcon icon = GetFocusedSlotsIcon();
535
536 if (icon)
537 {
538 c = ClosableContainer.Cast(icon.GetContainer());
539 }
540
541 if (c && c.IsDisplayable())
542 {
543 return true;
544 }
545 }
546
547 return false;
548 }
549}
const int ITEMS_IN_ROW
Определения Attachments.c:1
EntityAI m_Entity
Определения ActionDebug.c:11
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
map
Определения ControlsXboxNew.c:4
Icon x
Icon y
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
bool IsActive()
Определения ModifierBase.c:130
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
Определения PluginRemotePlayerDebugClient.c:14
Widget m_Parent
Определения SizeToChild.c:92
override bool CanDisplayAnyCategory()
override void UpdateInterval()
Определения AttachmentCategoriesContainer.c:54
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:49
string GetIconName(string config_path_attachment_categories, string attachment_category)
SlotsContainer GetSlotsContainer(int icons_row)
override void UpdateInterval()
Определения AttachmentCategoriesRow.c:962
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:889
string GetCategoryIdentifier()
Определения AttachmentCategoriesRow.c:23
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native DayZPlayer GetPlayer()
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
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
Определения Building.c:6
void ShowSourceDropzone(EntityAI item)
Определения ItemManager.c:302
static ItemManager GetInstance()
Определения ItemManager.c:282
Определения ItemManager.c:2
proto native EntityAI GetItem()
Определения gameplay.c:277
Определения Container.c:2
Определения LeftArea.c:2
SlotsIcon GetSlotIcon(int index)
Определения SlotsContainer.c:207
Определения SlotsContainer.c:2
Container GetContainer()
Определения SlotsIcon.c:149
void SetSlotDisplayName(string text)
Определения SlotsIcon.c:144
void SetContainer(Container container)
Определения SlotsIcon.c:139
Widget GetRadialIconPanel()
Определения SlotsIcon.c:300
ImageWidget GetGhostSlot()
Определения SlotsIcon.c:235
Определения 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
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
proto native CGame GetGame()
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:407
WidgetFlags
Определения EnWidgets.c:58