3 protected static int m_NormalWidth;
4 protected static int m_NormalHeight;
6 protected bool m_IsWeapon =
false;
7 protected bool m_IsMagazine =
false;
8 protected bool m_HasTemperature =
false;
9 protected bool m_HasQuantity =
false;
10 protected bool m_HasItemSize =
false;
11 protected float m_CurrQuantity = -1;
17 protected int m_SlotID;
18 protected bool m_IsDragged =
false;
20 protected Widget m_PanelWidget;
22 protected Widget m_CursorWidget;
23 protected Widget m_ColWidget;
24 protected Widget m_MountedWidget;
25 protected Widget m_OutOfReachWidget;
26 protected Widget m_ReservedWidget;
29 protected ImageWidget m_GhostSlot;
31 protected Widget m_ColorWidget;
32 protected Widget m_SelectedPanel;
33 protected Widget m_EmptySelectedPanel;
34 protected Widget m_MicromanagedPanel;
36 protected Widget m_QuantityPanel;
38 protected ProgressBarWidget m_QuantityProgress;
39 protected Widget m_QuantityStack;
41 protected string m_SlotDisplayName;
42 protected string m_SlotDesc;
44 protected Widget m_ItemSizePanel;
47 protected Widget m_AmmoIcon;
49 protected Widget m_RadialIconPanel;
50 protected Widget m_RadialIconClosed;
51 protected Widget m_RadialIcon;
53 protected bool m_Reserved;
59 m_PanelWidget = m_MainWidget.FindAnyWidget(
"PanelWidget" + index );
61 m_CursorWidget = m_MainWidget.FindAnyWidget(
"Cursor" + index );
62 m_ColWidget = m_MainWidget.FindAnyWidget(
"Col" + index );
63 m_MountedWidget = m_MainWidget.FindAnyWidget(
"Mounted" + index );
64 m_OutOfReachWidget = m_MainWidget.FindAnyWidget(
"OutOfReach" + index );
66 m_ItemPreview =
ItemPreviewWidget.Cast( m_MainWidget.FindAnyWidget(
"Render" + index ) );
67 m_ItemPreview.SetForceFlipEnable(
true);
68 m_ItemPreview.SetForceFlip(
false);
70 m_GhostSlot = ImageWidget.Cast( m_MainWidget.FindAnyWidget(
"GhostSlot" + index ) );
72 m_ColorWidget = m_MainWidget.FindAnyWidget(
"Color" + index );
74 m_EmptySelectedPanel = m_MainWidget.FindAnyWidget(
"EmptySelected" + index );
75 m_MicromanagedPanel = m_MainWidget.FindAnyWidget(
"Micromanaged" + index );
77 m_QuantityPanel = m_MainWidget.FindAnyWidget(
"QuantityPanel" + index );
78 m_QuantityItem =
TextWidget.Cast( m_MainWidget.FindAnyWidget(
"Quantity" + index ) );
79 m_QuantityProgress = ProgressBarWidget.Cast( m_MainWidget.FindAnyWidget(
"QuantityBar" + index ) );
80 m_QuantityStack = m_MainWidget.FindAnyWidget(
"QuantityStackPanel" + index );
82 m_ItemSizePanel = m_MainWidget.FindAnyWidget(
"ItemSizePanel" + index );
83 m_ItemSizeWidget =
TextWidget.Cast( m_MainWidget.FindAnyWidget(
"ItemSize" + index ) );
85 m_AmmoIcon = m_MainWidget.FindAnyWidget(
"AmmoIcon" + index );
87 m_RadialIconPanel = m_MainWidget.FindAnyWidget(
"RadialIconPanel" + index );
88 m_RadialIconClosed = m_MainWidget.FindAnyWidget(
"RadialIconClosed" + index );
89 m_RadialIcon = m_MainWidget.FindAnyWidget(
"RadialIcon" + index );
91 m_ReservedWidget =
Widget.Cast(
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/inventory_new/reserved_icon.layout", m_MainWidget ) );
92 m_ReservedWidget.Show(
false);
94 WidgetEventHandler.GetInstance().RegisterOnMouseEnter( m_PanelWidget,
this,
"MouseEnter" );
95 WidgetEventHandler.GetInstance().RegisterOnMouseLeave( m_PanelWidget,
this,
"MouseLeave" );
97 WidgetEventHandler.GetInstance().RegisterOnMouseEnter( m_GhostSlot,
this,
"MouseEnterGhostSlot" );
98 WidgetEventHandler.GetInstance().RegisterOnMouseLeave( m_GhostSlot,
this,
"MouseLeaveGhostSlot" );
100 WidgetEventHandler.GetInstance().RegisterOnMouseEnter( m_RadialIconPanel,
this,
"MouseEnterCategory" );
101 WidgetEventHandler.GetInstance().RegisterOnMouseLeave( m_RadialIconPanel,
this,
"MouseLeaveCategory" );
115 m_SlotParent = slot_parent;
117 m_PanelWidget.SetUserData(
this);
118 m_ItemPreview.SetUserData(
this);
119 m_GhostSlot.SetUserData(
this);
120 m_MainWidget.SetUserData(
this);
131 override bool IsVisible()
133 return m_MainWidget.IsVisible();
136 void SetSlotParent(
EntityAI parent)
138 m_SlotParent = parent;
143 m_Container = container;
146 void SetSlotDisplayName(
string text )
148 m_SlotDisplayName = text;
156 string GetSlotDisplayName( )
158 return m_SlotDisplayName;
161 void SetSlotDesc(
string text )
182 m_Obj.GetOnItemFlipped().Remove( UpdateFlip );
183 m_Obj.GetOnViewIndexChanged().Remove( SetItemPreview );
197 void SetSlotID(
int slot_ID)
209 return m_PanelWidget;
214 return m_CursorWidget;
222 Widget GetReservedWidget()
224 return m_ReservedWidget;
229 return m_MountedWidget;
234 return m_ItemPreview;
237 ImageWidget GetGhostSlot()
244 return m_ColorWidget;
252 Widget GetEmptySelectedPanel()
254 return m_EmptySelectedPanel;
257 Widget GetMicromanagedPanel()
259 return m_MicromanagedPanel;
264 return m_QuantityPanel;
267 Widget GetOutOfReachWidget()
269 return m_OutOfReachWidget;
274 return m_QuantityItem;
277 ProgressBarWidget GetQuantityProgress()
279 return m_QuantityProgress;
284 return m_QuantityStack;
289 return m_ItemSizePanel;
294 return m_ItemSizeWidget;
302 Widget GetRadialIconPanel()
304 return m_RadialIconPanel;
307 Widget GetRadialIconClosed()
309 return m_RadialIconClosed;
319 return GetCursorWidget().IsVisible();
322 override void SetActive(
bool active )
324 #ifdef PLATFORM_CONSOLE
325 super.SetActive( active );
327 if( active && GetObject() )
329 GetMainWidget().GetScreenPos(
x,
y );
330 PrepareOwnedTooltip(
EntityAI.Cast( GetObject() ),
x,
y );
334 GetMainWidget().GetScreenPos(
x,
y );
335 PrepareOwnedSlotsTooltip( GetMainWidget(), m_SlotDisplayName, m_SlotDesc,
x,
y );
342 override void SetLayoutName()
347 override void Refresh()
349 if( m_HasTemperature )
357 void SetTemperature()
377 void RefreshMuzzleIcon()
382 if( wpn.IsShowingChamberedBullet() )
384 int mi = wpn.GetCurrentMuzzle();
385 m_AmmoIcon.Show( wpn.IsChamberFull( mi ) );
390 m_AmmoIcon.Show(
false );
410 m_QuantityStack.Show(
false);
414 m_QuantityItem.SetText(q_text);
415 m_QuantityStack.Show(
true);
418 m_QuantityProgress.Show(
false);
422 float progress_max = m_QuantityProgress.GetMax();
423 int max =
m_Item.GetQuantityMax();
424 int count =
m_Item.ConfigGetInt(
"count");
425 float quantity = m_CurrQuantity;
434 float value =
Math.Round((quantity / max) * 100);
435 m_QuantityProgress.SetCurrent(value);
437 m_QuantityStack.Show(
false);
438 m_QuantityProgress.Show(
true);
444 void SetItemPreview()
446 m_ItemPreview.Show(
true );
447 m_ItemPreview.SetItem(
EntityAI.Cast( m_Obj ) );
448 m_ItemPreview.SetModelOrientation(
"0 0 0" );
449 m_ItemPreview.SetView( m_Obj.GetViewIndex() );
459 m_ItemSizePanel.Show(
true );
460 m_ItemSizeWidget.SetText( ( size_x * size_y ).
ToString() );
464 void UpdateFlip(
bool flipped )
468 float x_content, y_content;
469 GetPanelWidget().GetScreenSize( x_content, y_content );
470 GetPanelWidget().SetSize( y_content, x_content );
474 void Init(
EntityAI obj,
bool reservation =
false )
478 ClearRemainSelected();
481 m_Obj.GetOnItemFlipped().Insert( UpdateFlip );
482 m_Obj.GetOnViewIndexChanged().Insert( SetItemPreview );
483 m_Reserved = reservation;
488 ItemManager.GetInstance().SetWidgetDraggable( m_PanelWidget,
false );
491 m_IsMagazine =
false;
492 m_HasTemperature =
false;
493 m_HasQuantity =
false;
494 m_HasItemSize =
false;
500 CheckHasTemperature();
505 m_ReservedWidget.Show(reservation);
509 m_GhostSlot.Show(
false );
510 m_PanelWidget.Show(
true );
513 #ifdef PLATFORM_CONSOLE
516 Inventory.GetInstance().UpdateConsoleToolbar();
522 void ClearRemainSelected()
526 OnIconDrop(m_PanelWidget);
528 ItemManager.GetInstance().SetWidgetDraggable( a,
false );
532 m_Obj.GetOnItemFlipped().Remove( UpdateFlip );
533 m_Obj.GetOnViewIndexChanged().Remove( SetItemPreview );
541 m_ItemPreview.Show(
false );
542 m_ItemPreview.SetItem(
null );
546 m_IsMagazine =
false;
547 m_HasTemperature =
false;
548 m_HasQuantity =
false;
549 m_HasItemSize =
false;
551 m_GhostSlot.Show(
true );
552 m_AmmoIcon.Show(
false );
553 m_PanelWidget.Show(
false );
554 m_RadialIconPanel.Show(
false );
556 m_QuantityPanel.Show(
false );
557 if(GetSlotID() != -1)
559 int stack_max =
InventorySlots.GetStackMaxForSlotId( GetSlotID() );
562 m_QuantityPanel.Show(
true );
563 m_QuantityItem.SetText(
string.Format(
"0/%1", stack_max.ToString()) );
564 m_QuantityStack.Show(
true );
565 m_QuantityProgress.Show(
false );
566 m_PanelWidget.Show(
true );
567 m_ItemPreview.Show(
true );
571 m_ColWidget.Show(
false );
572 m_MountedWidget.Show(
false );
573 m_OutOfReachWidget.Show(
false );
574 m_ReservedWidget.Show(
false );
576 if( m_ItemSizePanel )
577 m_ItemSizePanel.Show(
false );
580 m_ColorWidget.Show(
false );
587 #ifdef PLATFORM_CONSOLE
590 m_CursorWidget.Show(
false);
591 m_EmptySelectedPanel.Show(
false);
593 ClearRemainSelected();
598 m_IsWeapon = (
Weapon_Base.Cast( m_Obj ) != null );
601 void CheckIsMagazine()
603 m_IsMagazine = ( Magazine.Cast( m_Obj ) != null );
606 void CheckHasTemperature()
610 m_HasTemperature = (
m_Item.GetTemperatureMax() != 0 &&
m_Item.GetTemperatureMin() != 0 );
614 void CheckHasQuantity()
621 m_QuantityPanel.Show(
true );
626 void CheckHasItemSize()
628 #ifdef PLATFORM_CONSOLE
629 string config =
"CfgVehicles " + m_Obj.GetType() +
" GUIInventoryAttachmentsProps";
632 m_HasItemSize =
false;
638 bool oot = ( m_OutOfReachWidget.IsVisible() || m_MountedWidget.IsVisible() );
642 bool MouseEnter(
Widget w,
int x,
int y)
645 return MouseEnterGhostSlot(w,
x,
y);
647 PrepareOwnedTooltip(
m_Item,
x,
y );
650 m_CursorWidget.Show(
true );
655 bool MouseEnterGhostSlot(
Widget w,
int x,
int y)
658 m_MainWidget.GetScreenPos(pos_x, pos_y);
663 PrepareOwnedSlotsTooltip( m_MainWidget, m_SlotDisplayName, m_SlotDesc,
x,
y );
666 m_EmptySelectedPanel.Show(
true );
676 return MouseLeaveGhostSlot(w, s,
x,
y);
681 m_CursorWidget.Show(
false );
688 HideOwnedSlotsTooltip();
692 m_EmptySelectedPanel.Show(
false );
698 override void UpdateInterval()
702 if( m_HasTemperature )
713 void OnIconDrag(
Widget w )
722 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
726 ItemManager.GetInstance().GetLeftDropzone().SetAlpha( 1 );
732 int m_sizeX, m_sizeY;
738 CargoContainer c_parent = CargoContainer.Cast(
m_Parent );
741 if( GetRoot().m_MainWidget.FindAnyWidget(
"HandsPanel" ) )
743 GetRoot().m_MainWidget.FindAnyWidget(
"HandsPanel" ).GetScreenSize( icon_size,
y );
746 icon_size = icon_size / 10;
749 m_ItemPreview.SetForceFlipEnable(
false);
751 if( !
m_Item.GetInventory().GetFlipCargo() )
753 w.SetSize( icon_x * icon_size , icon_y * icon_size );
757 w.SetSize( icon_y * icon_size , icon_x * icon_size );
760 m_ColWidget.Show(
true );
761 m_CursorWidget.Show(
true );
768 void OnIconDrop(
Widget w )
775 m_ColWidget.Show(
false );
776 m_CursorWidget.Show(
false );
777 m_EmptySelectedPanel.Show(
false );
778 m_CursorWidget.SetColor(
ARGBF( 1, 1, 1, 1 ) );
779 m_ItemPreview.SetForceFlipEnable(
true);
782 static int GetNormalWidth()
784 return m_NormalWidth;
787 static int GetNormalHeight()
789 return m_NormalHeight;