Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_InventorySlotQuickSlotUI.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
5 {
6  ResourceName m_sPrimarySecondaryWeapon = "{F565C4A388964DBE}UI/Textures/InventoryIcons/InventorySlot_gadget.edds"; //TODO: icon for weapon
7 
8  protected ImageWidget m_wGamepadHintSmall;
9  protected ImageWidget m_wGamepadHintLarge;
10  protected RichTextWidget m_wKeybindText;
11 
12  //------------------------------------------------------------------------ USER METHODS ----------------------------------------------------------------------
13 
14  //------------------------------------------------------------------------------------------------
15  override void Init()
16  {
17  super.Init();
18  GetGame().OnInputDeviceIsGamepadInvoker().Insert(UpdateHints);
19  }
20 
21  //------------------------------------------------------------------------------------------------
23  override void SetSlotVisible( bool bVisible )
24  {
25  super.SetSlotVisible( bVisible );
26 
27  m_wKeybindText = RichTextWidget.Cast(m_widget.FindAnyWidget("KeybindRichText"));
28  if (m_wKeybindText && !GetStorageUI().GetInventoryMenuHandler())
29  {
30  EInputDeviceType currentDevice = GetGame().GetInputManager().GetLastUsedInputDevice();
31  InputBinding binding = GetGame().GetInputManager().CreateUserBinding();
32 
33  string deviceString = "keyboard";
34  if (currentDevice == EInputDeviceType.GAMEPAD)
35  deviceString = "gamepad";
36 
37  string name = string.Format("%1%2", "SwitchWeaponCategory", (m_iQuickSlotIndex + 1));
38 
39  array<string> bindings = {};
40  if (deviceString == "gamepad" &&
41  !binding.GetBindings(name, bindings, currentDevice))
42  return;
43 
44  if (name == "SwitchWeaponCategory10")
45  name = "SwitchWeaponCategory0";
46 
47  m_wKeybindText.SetText(string.Format("<action name='%1' preset='%2' device='" + deviceString + "' scale='1.25'/>", name, ""));
48  }
49 
50  if( bVisible )
51  {
52  m_wSelectedEffect = m_widget.FindAnyWidget("SelectedFrame");
53 
54  if ( !m_pItem ) //if item is not available, it's the empty slot, show the large number
55  {
56  m_wTextQuickSlotLarge = TextWidget.Cast( m_widget.FindAnyWidget( "TextQuickSlotLarge" ) );
57  SetQuickSlotIndexVisible( m_wTextQuickSlotLarge, true );
58  SetQuickSlotHintVisible(m_wKeybindText);
59  }
60  else
61  {
62  SetQuickSlotIndexVisible( m_wTextQuickSlot, m_pStorageUI.GetInventoryMenuHandler() != null );
63  SetQuickSlotHintVisible(m_wKeybindText);
64  }
65  }
66  else
67  {
68  m_wSelectedEffect = null;
69  m_wTextQuickSlotLarge = null;
70  }
71  }
72 
73  //------------------------------------------------------------------------------------------------
74  override string SetSlotSize()
75  {
76  ESlotSize slotSize;
77  string slotLayout = SLOT_LAYOUT_1x1;
78 
79  if ( m_iQuickSlotIndex < 2 )
80  slotSize = ESlotSize.SLOT_2x1;
81  else
82  slotSize = m_Attributes.GetQuickSlotItemSize();
83  switch ( slotSize )
84  {
85  case ESlotSize.SLOT_1x1: { slotLayout = SLOT_LAYOUT_1x1; m_iSizeX = 1; m_iSizeY = 1; } break;
86  case ESlotSize.SLOT_2x1: { slotLayout = SLOT_LAYOUT_2x1; m_iSizeX = 2; m_iSizeY = 1; } break;
87  case ESlotSize.SLOT_2x2: { slotLayout = SLOT_LAYOUT_2x2; m_iSizeX = 2; m_iSizeY = 2; } break;
88  case ESlotSize.SLOT_3x3: { slotLayout = SLOT_LAYOUT_3x3; m_iSizeX = 3; m_iSizeY = 3; } break;
89  }
90  return slotLayout;
91  }
92 
93  void UpdateHints()
94  {
95  // SetQuickSlotHintVisible(m_wKeybindText);
96  m_wKeybindText.SetVisible(!GetGame().GetInputManager().IsUsingMouseAndKeyboard());
97  }
98 
99  //------------------------------------------------------------------------------------------------
100  void SetQuickSlotHintVisible(RichTextWidget hintWidget)
101  {
102  if (!GetGame().GetInputManager().IsUsingMouseAndKeyboard() && hintWidget.IsEnabled())
103  hintWidget.SetVisible(true);
104  }
105 
106  //------------------------------------------------------------------------ COMMON METHODS ----------------------------------------------------------------------
107 
108  //------------------------------------------------------------------------------------------------
109  void SCR_InventorySlotQuickSlotUI( InventoryItemComponent pComponent = null, SCR_InventoryStorageBaseUI pStorageUI = null, bool bVisible = true, int iSlotIndex = -1, SCR_ItemAttributeCollection pAttributes = null )
110  {
111  m_iQuickSlotIndex = iSlotIndex;
112  m_Attributes = pAttributes;
113  }
114 
115  //------------------------------------------------------------------------------------------------
117  {
118  }
119 };
m_Attributes
private SCR_ItemAttributeCollection m_Attributes
Definition: SCR_UniversalInventoryStorageComponent.c:23
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SLOT_LAYOUT_2x2
const string SLOT_LAYOUT_2x2
Definition: SCR_InventorySlotUI.c:3
SLOT_LAYOUT_3x3
const string SLOT_LAYOUT_3x3
Definition: SCR_InventorySlotUI.c:4
SCR_InventoryStorageBaseUI
Definition: SCR_InventoryStorageBaseUI.c:6
m_iSizeY
int m_iSizeY
Definition: SCR_MapRTWBaseUI.c:6
ESlotSize
ESlotSize
Definition: InventoryConstants.c:1
SCR_InventorySlotQuickSlotUI
Definition: SCR_InventorySlotQuickSlotUI.c:4
InventoryItemComponent
Definition: InventoryItemComponent.c:12
SCR_ItemAttributeCollection
Definition: SCR_ItemAttributeCollection.c:2
m_iSizeX
int m_iSizeX
Definition: SCR_MapRTWBaseUI.c:3
GetInputManager
protected InputManager GetInputManager()
Definition: SCR_BaseManualCameraComponent.c:65
SLOT_LAYOUT_1x1
const string SLOT_LAYOUT_1x1
Definition: SCR_InventorySlotUI.c:1
SCR_InventorySlotUI
Definition: SCR_InventorySlotUI.c:27
SLOT_LAYOUT_2x1
const string SLOT_LAYOUT_2x1
Definition: SCR_InventorySlotUI.c:2