6 protected static ResourceName m_ItemPreviewManagerPrefab =
"{9F18C476AB860F3B}Prefabs/World/Game/ItemPreviewManager.et";
7 protected static Widget s_wQuickSlotStorage;
10 static bool s_bOpened;
12 [
Attribute(
"{A1E61EF091EAC47C}UI/layouts/Menus/Inventory/InventoryQuickSlotsGrid.layout" )]
13 protected string m_sQuickSlotGridLayout;
19 static void RefreshQuickSlots(
int id = -1)
21 if (s_pQuickSlotStorage)
24 s_pQuickSlotStorage.RefreshQuickSlots();
26 s_pQuickSlotStorage.RefreshSlot(
id);
27 s_pQuickSlotStorage.HighlightLastSelectedSlot();
32 protected void Init( IEntity owner )
43 if (!world.GetItemPreviewManager())
45 Resource rsc = Resource.Load(m_ItemPreviewManagerPrefab);
47 GetGame().SpawnEntityPrefabLocal(rsc, world);
51 InputManager inputManager =
GetGame().GetInputManager();;
52 inputManager.AddActionListener(
"Inventory_WeaponSwitching", EActionTrigger.UP, QuickBarClosedOnly );
53 inputManager.AddActionListener(
"Inventory_WeaponSwitching", EActionTrigger.DOWN, Action_OpenQuickSelectionBar );
54 inputManager.AddActionListener(
"Inventory_WeaponSwitching", EActionTrigger.UP, Action_CloseQuickSelectionBar );
56 for (
int i = 0; i < 10; ++i)
58 inputManager.AddActionListener(
"SwitchWeaponCategory" + i.ToString(), EActionTrigger.DOWN, Action_OpenQuickSelectionBar);
59 inputManager.AddActionListener(
"SwitchWeaponCategory" + i.ToString(), EActionTrigger.UP, Action_CloseQuickSelectionBar);
64 protected void RemoveActionListeners()
66 InputManager inputManager =
GetGame().GetInputManager();
67 inputManager.RemoveActionListener(
"Inventory_WeaponSwitching", EActionTrigger.UP, QuickBarClosedOnly );
68 inputManager.RemoveActionListener(
"Inventory_WeaponSwitching", EActionTrigger.DOWN, Action_OpenQuickSelectionBar );
69 inputManager.RemoveActionListener(
"Inventory_WeaponSwitching", EActionTrigger.UP, Action_CloseQuickSelectionBar );
71 for (
int i = 0; i < 10; ++i)
73 inputManager.RemoveActionListener(
"SwitchWeaponCategory" + i.ToString(), EActionTrigger.DOWN, Action_OpenQuickSelectionBar);
74 inputManager.RemoveActionListener(
"SwitchWeaponCategory" + i.ToString(), EActionTrigger.UP, Action_CloseQuickSelectionBar);
79 void Action_OpenQuickSelectionBar()
84 ChimeraCharacter character = ChimeraCharacter.Cast(
SCR_PlayerController.GetLocalControlledEntity());
85 CharacterControllerComponent controller;
88 controller = character.GetCharacterController();
90 if (controller && controller.IsUnconscious())
93 GetGame().GetInputManager().AddActionListener(
"CharacterSwitchWeapon", EActionTrigger.VALUE, Action_SelectSlot );
95 GetGame().GetCallqueue().Remove( ShowQuickSlots );
98 if( s_wQuickSlotStorage )
101 s_wQuickSlotStorage.RemoveFromHierarchy();
103 Widget parent =
m_wRoot.FindAnyWidget(
"QuickSlots" );
104 s_wQuickSlotStorage =
GetGame().GetWorkspace().CreateWidgets( m_sQuickSlotGridLayout, parent );
105 if( !s_wQuickSlotStorage )
108 s_wQuickSlotStorage.AddHandler( s_pQuickSlotStorage );
109 s_pQuickSlotStorage.SetInitialQuickSlot();
110 s_pQuickSlotStorage.HighlightLastSelectedSlot();
113 BlurWidget wBlur = BlurWidget.Cast(
m_wRoot.FindAnyWidget(
"wBlur" ) );
115 wBlur.SetVisible(
true );
122 SCR_InventoryStorageManagerComponent inventory = SCR_InventoryStorageManagerComponent.Cast(controller.GetInventoryStorageManager());
124 inventory.m_OnQuickBarOpenInvoker.Invoke(
true);
128 void Action_CloseQuickSelectionBar()
130 GetGame().GetInputManager().RemoveActionListener(
"CharacterSwitchWeapon", EActionTrigger.VALUE, Action_SelectSlot );
134 BlurWidget wBlur = BlurWidget.Cast(
m_wRoot.FindAnyWidget(
"wBlur" ) );
136 wBlur.SetVisible(
false );
138 if ( s_pQuickSlotStorage && s_pQuickSlotStorage.UseItemInSlot() )
139 GetGame().GetCallqueue().CallLater( ShowQuickSlots, 2000,
false,
false,
UIConstants.FADE_RATE_DEFAULT,
true );
143 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(
SCR_PlayerController.GetLocalControlledEntity());
147 CharacterControllerComponent controller = character.GetCharacterController();
151 SCR_InventoryStorageManagerComponent inventory = SCR_InventoryStorageManagerComponent.Cast(controller.GetInventoryStorageManager());
153 inventory.m_OnQuickBarOpenInvoker.Invoke(
false);
158 protected void QuickBarClosedOnly()
160 if (s_pQuickSlotStorage)
161 s_pQuickSlotStorage.SetQuickBarClosed();
165 void Action_SelectSlot()
167 if (!s_bOpened || !s_pQuickSlotStorage)
172 InputManager inputManager =
GetGame().GetInputManager();
173 if (inputManager.GetActionTriggered(
"SwitchWeaponCategory1"))
175 else if (inputManager.GetActionTriggered(
"SwitchWeaponCategory2"))
177 else if (inputManager.GetActionTriggered(
"SwitchWeaponCategory3"))
179 else if (inputManager.GetActionTriggered(
"SwitchWeaponCategory4"))
181 else if (inputManager.GetActionTriggered(
"SwitchWeaponCategory5"))
183 else if (inputManager.GetActionTriggered(
"SwitchWeaponCategory6"))
185 else if (inputManager.GetActionTriggered(
"SwitchWeaponCategory7"))
187 else if (inputManager.GetActionTriggered(
"SwitchWeaponCategory8"))
189 else if (inputManager.GetActionTriggered(
"SwitchWeaponCategory9"))
191 else if (inputManager.GetActionTriggered(
"SwitchWeaponCategory0"))
194 if ( targetSlot == - 1 )
195 s_pQuickSlotStorage.SelectSlot( inputManager.GetActionValue(
"CharacterSwitchWeapon") );
197 s_pQuickSlotStorage.SelectSlot( targetSlot );
201 override void UpdateValues(IEntity owner,
float timeSlice)
206 GetGame().GetInputManager().ActivateContext(
"WeaponSelectionContext");
209 protected void ShowQuickSlots(
bool show,
float speed =
UIConstants.FADE_RATE_DEFAULT)
215 override event void OnStartDraw(IEntity owner)
217 super.OnStartDraw(owner);
223 override event void OnStopDraw(IEntity owner)
225 super.OnStopDraw(owner);
226 RemoveActionListeners();
227 s_pQuickSlotStorage =
null;
233 override void OnComplete()