Advertisement
Enzo_YinYang

Untitled

Sep 12th, 2021
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 124.69 KB | None | 0 0
  1. /***********************************************************************/
  2. /** © 2015 CD PROJEKT S.A. All rights reserved.
  3. /** THE WITCHER® is a trademark of CD PROJEKT S. A.
  4. /** The Witcher game is based on the prose of Andrzej Sapkowski.
  5. /***********************************************************************/
  6. enum EInventoryMenuState
  7. {
  8. IMS_Player,
  9. IMS_Shop,
  10. IMS_Container,
  11. IMS_HorseInventory,
  12. IMS_Stash
  13. }
  14.  
  15. // ---=== modE3 ===---
  16. enum InventoryMenuTabIndexes
  17. {
  18. InventoryMenuTab_Weapons = 0,
  19. InventoryMenuTab_Potions = 2,
  20. InventoryMenuTab_Default = 5,
  21. InventoryMenuTab_QuestItems = 4,
  22. InventoryMenuTab_Ingredients = 3,
  23. InventoryMenuTab_Books = 1
  24. };
  25. // ---=== modE3 ===---
  26. enum InventoryMenuStashTabIndexes
  27. {
  28. StashMenuTab_Weapons = 0,
  29. StashMenuTab_Default = 1
  30. };
  31.  
  32.  
  33. struct SentStatsData
  34. {
  35. var statName : name;
  36. var statValue : string;
  37. }
  38.  
  39. statemachine class CR4InventoryMenu extends CR4MenuBase
  40. {
  41. private var _playerInv : W3GuiPlayerInventoryComponent;
  42. private var _paperdollInv : W3GuiPaperdollInventoryComponent;
  43. private var _containerInv : W3GuiContainerInventoryComponent;
  44. private var _shopInv : W3GuiShopInventoryComponent;
  45. private var _horseInv : W3GuiContainerInventoryComponent;
  46. private var _horsePaperdollInv : W3GuiHorseInventoryComponent;
  47.  
  48. private var _currentInv : W3GuiBaseInventoryComponent;
  49. private var _currentMouseInv : W3GuiBaseInventoryComponent;
  50.  
  51. private var _quantityPopupData : QuantityPopupData;
  52. private var _statsContext : W3PlayerStatsContext;
  53. private var _paperdollContext : W3InventoryPaperdollContext;
  54. private var _invContext : W3InventoryGridContext;
  55. private var _externGridContext : W3ExternalGridContext;
  56. private var _bookPopupData : BookPopupFeedback;
  57. private var _paintingPopupData : PaintingPopup;
  58. private var _charStatsPopupData : CharacterStatsPopupData;
  59. private var _itemInfoPopupData : ItemInfoPopupData;
  60. private var _destroyConfPopData : W3DestroyItemConfPopup;
  61.  
  62. private var drawHorse : bool;
  63.  
  64. private var m_player : CEntity;
  65.  
  66. protected var _inv : CInventoryComponent;
  67. protected var _container : W3Container;
  68. protected var _shopNpc : CNewNPC;
  69. protected var _tooltipDataProvider : W3TooltipComponent;
  70. protected var currentlySelectedTab : int;
  71.  
  72. protected var _defaultInventoryState:EInventoryMenuState;
  73. protected var _currentState : EInventoryMenuState;
  74. private var optionsItemActions : array<EInventoryActionType>;
  75. private var _sentStats : array<SentStatsData>;
  76.  
  77. private var _currentQuickSlot : EEquipmentSlots;
  78. default _currentQuickSlot = EES_InvalidSlot;
  79.  
  80. private var _currentEqippedQuickSlot : EEquipmentSlots;
  81.  
  82. private var MAX_ITEM_NR : int;
  83. default MAX_ITEM_NR = 64;
  84. private var currentItemsNr : int;
  85. default currentItemsNr = 0;
  86.  
  87. private var m_menuInited : bool;
  88. private var m_isPadConnected : bool;
  89. private var m_isUsingPad : bool;
  90. private var m_hidePaperdoll : bool;
  91. private var m_tagsFilter : array<name>;
  92. private var m_ignoreSaveData : bool;
  93.  
  94. private var m_selectionModeActive : bool; default m_selectionModeActive = false;
  95. private var m_selectionModeItem : SItemUniqueId;
  96.  
  97. private var m_dyePreviewMode : bool;
  98. private var m_dyePreviewSlots : array<SItemUniqueId>;
  99. private var m_previewItems : array<SItemUniqueId>;
  100. private var m_previewSlots : array<bool>;
  101.  
  102. private var m_lastSelectedModuleID : int;
  103. private var m_lastSelectedModuleBindingName : string;
  104.  
  105. private var m_bookPopupItem : SItemUniqueId;
  106. var currentSelectedItem : SItemUniqueId;
  107.  
  108.  
  109. private var m_fxPaperdollRemoveItem : CScriptedFlashFunction;
  110. private var m_fxInventoryRemoveItem : CScriptedFlashFunction;
  111. private var m_fxInventoryUpdateFilter : CScriptedFlashFunction;
  112. private var m_fxForceSelectItem : CScriptedFlashFunction;
  113. private var m_fxForceSelectPaperdollSlot : CScriptedFlashFunction;
  114. private var m_fxSetFilteringMode : CScriptedFlashFunction;
  115. private var m_fxRemoveContainerItem : CScriptedFlashFunction;
  116. private var m_fxHideSelectionMode : CScriptedFlashFunction;
  117. private var m_fxSetInventoryMode : CScriptedFlashFunction;
  118. private var m_fxSetNewFlagsForTabs : CScriptedFlashFunction;
  119. private var m_fxSetSortingMode : CScriptedFlashFunction;
  120. private var m_fxSetVitality : CScriptedFlashFunction;
  121. private var m_fxSetToxicity : CScriptedFlashFunction;
  122. private var m_fxSetPreviewMode : CScriptedFlashFunction;
  123. private var m_fxSetDefaultTab : CScriptedFlashFunction;
  124.  
  125. // ---=== modE3 ===---
  126. private var tf_TabText : CScriptedFlashTextField;
  127. private var tf_StashText : CScriptedFlashTextField;
  128. // ---=== modE3 ===---
  129.  
  130. event OnConfigUI()
  131. {
  132. var l_flashPaperdoll : CScriptedFlashSprite;
  133. var l_flashInventory : CScriptedFlashSprite;
  134. var l_flashObject : CScriptedFlashObject;
  135. var l_flashArray : CScriptedFlashArray;
  136. var l_obj : IScriptable;
  137. var l_containerNpc : CNewNPC;
  138. var l_horse : CActor;
  139. var l_initData : W3InventoryInitData;
  140. var l_craftIngredientsList : array<name>;
  141.  
  142. var merchantComponent : W3MerchantComponent;
  143. var pinTypeName : name;
  144. var defaultTab : int;
  145. var hasNewItems : array<bool>;
  146.  
  147.  
  148. m_initialSelectionsToIgnore = 2;
  149. drawHorse = false;
  150. m_menuInited = false;
  151.  
  152. super.OnConfigUI();
  153.  
  154. l_obj = GetMenuInitData();
  155. _container = (W3Container)l_obj;
  156. l_containerNpc = (CNewNPC)l_obj;
  157.  
  158. l_initData = (W3InventoryInitData) l_obj;
  159. if (l_initData)
  160. {
  161. _container = (W3Container)l_initData.containerNPC;
  162. if (!_container)
  163. {
  164. l_containerNpc = (CNewNPC)l_initData.containerNPC;
  165. }
  166. m_tagsFilter = l_initData.filterTagsList;
  167. m_ignoreSaveData = true;
  168. }
  169. if (l_containerNpc)
  170. {
  171. if (l_containerNpc.HasTag('Merchant'))
  172. {
  173. m_initialSelectionsToIgnore = 3;
  174. _shopNpc = l_containerNpc;
  175. m_ignoreSaveData = true;
  176. }
  177. }
  178.  
  179. m_flashModule = GetMenuFlash();
  180. m_fxSetSortingMode = m_flashModule.GetMemberFlashFunction("setSortingMode");
  181. m_fxSetFilteringMode = m_flashModule.GetMemberFlashFunction( "setFilteringMode" );
  182. m_fxPaperdollRemoveItem = m_flashModule.GetMemberFlashFunction( "paperdollRemoveItem" );
  183. m_fxInventoryRemoveItem = m_flashModule.GetMemberFlashFunction( "inventoryRemoveItem" );
  184. m_fxInventoryUpdateFilter = m_flashModule.GetMemberFlashFunction( "forceSelectTab" );
  185. m_fxForceSelectItem = m_flashModule.GetMemberFlashFunction( "forceSelectItem" );
  186. m_fxForceSelectPaperdollSlot = m_flashModule.GetMemberFlashFunction( "forceSelectPaperdollSlot" );
  187. m_fxRemoveContainerItem = m_flashModule.GetMemberFlashFunction( "shopRemoveItem" );
  188. m_fxSetInventoryMode = m_flashModule.GetMemberFlashFunction( "setInventoryMode" );
  189. m_fxHideSelectionMode = m_flashModule.GetMemberFlashFunction( "hideSelectionMode" );
  190. m_fxSetNewFlagsForTabs = m_flashModule.GetMemberFlashFunction( "setNewFlagsForTabs" );
  191. m_fxSetVitality = m_flashModule.GetMemberFlashFunction( "setVitality" );
  192. m_fxSetToxicity = m_flashModule.GetMemberFlashFunction( "setToxicity" );
  193. m_fxSetPreviewMode = m_flashModule.GetMemberFlashFunction( "setPreviewMode" );
  194. m_fxSetDefaultTab = m_flashModule.GetMemberFlashFunction( "setDefaultTab" );
  195. m_fxSetPaperdollPreviewIcon = m_flashModule.GetMemberFlashFunction( "setPaperdollPreviewIcon" );
  196.  
  197. m_fxSetSortingMode.InvokeSelfSixArgs(FlashArgInt(theGame.GetGuiManager().GetInventorySortingMode()),
  198. FlashArgString(GetLocStringByKeyExt("gui_panel_filter_item_type")),
  199. FlashArgString(GetLocStringByKeyExt("attribute_name_price")),
  200. FlashArgString(GetLocStringByKeyExt("attribute_name_weight")),
  201. FlashArgString(GetLocStringByKeyExt("attribute_name_durability")),
  202. FlashArgString(GetLocStringByKeyExt("gui_panel_filter_item_rarity")));
  203.  
  204. _inv = thePlayer.GetInventory();
  205. _playerInv = new W3GuiPlayerInventoryComponent in this;
  206. _playerInv.Initialize( _inv );
  207. _playerInv.filterTagList = m_tagsFilter;
  208. _playerInv.autoCleanNewMark = true;
  209.  
  210. if (m_tagsFilter.Size() > 0)
  211. {
  212. _playerInv.SetFilterType(IFT_None);
  213. }
  214.  
  215. _currentInv = _playerInv;
  216.  
  217. _paperdollInv = new W3GuiPaperdollInventoryComponent in this;
  218. _paperdollInv.Initialize( _inv );
  219.  
  220. _horseInv = new W3GuiContainerInventoryComponent in this;
  221. _horseInv.Initialize(GetWitcherPlayer().GetHorseManager().GetInventoryComponent());
  222. _horsePaperdollInv = new W3GuiHorseInventoryComponent in this;
  223. _horsePaperdollInv.Initialize(GetWitcherPlayer().GetHorseManager().GetInventoryComponent());
  224.  
  225. _tooltipDataProvider = new W3TooltipComponent in this;
  226. _tooltipDataProvider.initialize(_inv, m_flashValueStorage);
  227.  
  228. theGame.GetGuiManager().SetBackgroundTexture( LoadResource( "inventory_background" ) );
  229.  
  230. m_flashValueStorage.SetFlashString("inventory.grid.paperdoll.pockets",GetLocStringByKeyExt("panel_inventory_paperdoll_slotname_quickitems"));
  231. m_flashValueStorage.SetFlashString("inventory.grid.paperdoll.potions",GetLocStringByKeyExt("panel_inventory_paperdoll_slotname_potions"));
  232. m_flashValueStorage.SetFlashString("inventory.grid.paperdoll.petards",GetLocStringByKeyExt("panel_inventory_paperdoll_slotname_petards"));
  233. m_flashValueStorage.SetFlashString("playerstats.stats.name", GetLocStringByKeyExt("panel_common_statistics_name") );
  234.  
  235. if( _container )
  236. {
  237. _containerInv = new W3GuiContainerInventoryComponent in this;
  238. _containerInv.Initialize( _container.GetInventory() );
  239. if( m_tagsFilter.Size() > 0 )
  240. {
  241. if( m_tagsFilter.FindFirst('HideOwnerInventory') != -1 )
  242. {
  243. _containerInv.HideAllItems();
  244. }
  245. }
  246.  
  247. _playerInv.currentDefaultItemAction = IAT_Transfer;
  248. _paperdollInv.currentDefaultItemAction = IAT_Transfer;
  249. m_flashValueStorage.SetFlashString("inventory.grid.container.name",_container.GetDisplayName(false));
  250. _defaultInventoryState = IMS_Container;
  251. }
  252. else if( _shopNpc )
  253. {
  254. _shopInv = new W3GuiShopInventoryComponent in this;
  255. _shopNpc.GetInventory().UpdateLoot();
  256. _shopNpc.GetInventory().ClearGwintCards();
  257. _shopNpc.GetInventory().ClearTHmaps();
  258. _shopNpc.GetInventory().ClearKnownRecipes();
  259. _shopInv.Initialize( _shopNpc.GetInventory() );
  260.  
  261. merchantComponent = (W3MerchantComponent)_shopNpc.GetComponentByClassName( 'W3MerchantComponent' );
  262. if( merchantComponent )
  263. {
  264. pinTypeName = merchantComponent.GetMapPinType();
  265.  
  266. switch( pinTypeName )
  267. {
  268. case 'Alchemic':
  269. case 'Herbalist':
  270. defaultTab = 0;
  271. break;
  272. case 'Innkeeper':
  273. defaultTab = 2;
  274. break;
  275. default:
  276. defaultTab = -1;
  277. }
  278.  
  279. m_fxSetDefaultTab.InvokeSelfOneArg( FlashArgInt( defaultTab ) );
  280. }
  281.  
  282.  
  283.  
  284. _tooltipDataProvider.setShopInventory(_shopNpc.GetInventory());
  285.  
  286. _playerInv.SetShopInvCmp( _shopInv );
  287. _playerInv.currentDefaultItemAction = IAT_Sell;
  288. m_flashValueStorage.SetFlashString("inventory.grid.container.name",_shopNpc.GetDisplayName(false));
  289. _defaultInventoryState = IMS_Shop;
  290. UpdateMerchantData();
  291.  
  292. if(theGame.GetTutorialSystem() && theGame.GetTutorialSystem().IsRunning())
  293. {
  294. theGame.GetTutorialSystem().uiHandler.OnOpeningMenu('ShopMenu');
  295. }
  296.  
  297. l_craftIngredientsList = UpdatePinnedCraftingItemInfo();
  298. _shopInv.highlightItems(l_craftIngredientsList);
  299. }
  300. else if( l_containerNpc )
  301. {
  302. _containerInv = new W3GuiContainerInventoryComponent in this;
  303. _containerInv.Initialize( l_containerNpc.GetInventory() );
  304.  
  305. _playerInv.currentDefaultItemAction = IAT_Transfer;
  306. _paperdollInv.currentDefaultItemAction = IAT_Transfer;
  307.  
  308. m_flashValueStorage.SetFlashString("inventory.grid.container.name",l_containerNpc.GetDisplayName(false));
  309. _defaultInventoryState = IMS_Container;
  310. }
  311. else if ( theGame.GameplayFactsQuerySum("stashMode") == 1 )
  312. {
  313. _defaultInventoryState = IMS_Stash;
  314. }
  315. else
  316. {
  317. _defaultInventoryState = IMS_Player;
  318. }
  319.  
  320. defaultTab = SetInitialTabNewFlags( hasNewItems );
  321. if( _defaultInventoryState == IMS_Container )
  322. {
  323.  
  324. m_fxSetDefaultTab.InvokeSelfOneArg( FlashArgInt( defaultTab ) );
  325. }
  326.  
  327. PaperdollUpdateAll();
  328. UpdatePlayerStatisticsData();
  329.  
  330. m_menuInited = true;
  331. if (m_menuState == '') m_menuState = 'CharacterInventory';
  332. ApplyMenuState(m_menuState);
  333.  
  334. _currentEqippedQuickSlot = GetCurrentEquippedQuickSlot();
  335. SelectCurrentModule();
  336.  
  337. m_fxSetNewFlagsForTabs.InvokeSelfSixArgs( FlashArgBool(hasNewItems[0]), FlashArgBool(hasNewItems[1]), FlashArgBool(hasNewItems[2]), FlashArgBool(hasNewItems[3]), FlashArgBool(hasNewItems[4]), FlashArgBool(hasNewItems[5] ) );
  338. m_fxSetTooltipState.InvokeSelfTwoArgs( FlashArgBool( thePlayer.upscaledTooltipState ), FlashArgBool( true ) );
  339.  
  340. m_dyePreviewSlots.Resize( EnumGetMax( 'EEquipmentSlots' ) + 1 );
  341. m_previewSlots.Resize( EnumGetMax( 'EEquipmentSlots' ) + 1 );
  342.  
  343. // ---=== modE3 ===---
  344. tf_TabText = m_flashModule.GetChildFlashSprite("mcPlayerInventory").GetChildFlashTextField("tfTabText");
  345. tf_StashText = m_flashModule.GetChildFlashSprite("mcStashBackground").GetChildFlashTextField("tfStashText");
  346. tf_TabText.SetTextHtml("<font color='#ffae967d' size='23.5'>" + StrUpper(GetLocStringById(1078785)) + "</font>");
  347. tf_StashText.SetTextHtml("<font color='#ffae967d' size='23.5'>" + StrUpper(GetLocStringByKeyExt("panel_title_stash")) + "</font>");
  348.  
  349. if( _defaultInventoryState == IMS_Player )
  350. {
  351. OnRequestStatsData();
  352. }
  353. // ---=== modE3 ===---
  354. }
  355.  
  356. event OnSortingIndexChoosingStart()
  357. {
  358. var commonMenu : CR4CommonMenu;
  359.  
  360. commonMenu = (CR4CommonMenu)m_parentMenu;
  361.  
  362. if (commonMenu)
  363. {
  364. commonMenu.m_contextInputBlocked = true;
  365. }
  366. }
  367.  
  368. event OnSortingIndexChosen( sortIndex : int )
  369. {
  370. var commonMenu : CR4CommonMenu;
  371.  
  372. commonMenu = (CR4CommonMenu)m_parentMenu;
  373.  
  374. if (commonMenu)
  375. {
  376. commonMenu.m_contextInputBlocked = false;
  377. }
  378. theGame.GetGuiManager().SetInventorySortingMode(sortIndex);
  379.  
  380.  
  381. }
  382.  
  383. event OnGuiSceneEntitySpawned(entity : CEntity)
  384. {
  385. var arr : array< name >;
  386.  
  387. Event_OnGuiSceneEntitySpawned();
  388. m_player = entity;
  389. arr.PushBack( 'Inventory' );
  390. m_player.ActivateBehaviorsSync( arr );
  391.  
  392. ((CActor)m_player).SetBehaviorMimicVariable( 'gameplayMimicsMode', (float)(int)PGMM_Inventory );
  393. }
  394.  
  395. timer function GuiSceneEntityUpdate(dt : float, id : int)
  396. {
  397.  
  398.  
  399. }
  400.  
  401.  
  402.  
  403.  
  404.  
  405. event OnScaleCharRenderer(delta:float, isPad:bool)
  406. {
  407. var guiSceneController : CR4GuiSceneController;
  408.  
  409. guiSceneController = theGame.GetGuiManager().GetSceneController();
  410.  
  411. if ( !guiSceneController )
  412. {
  413. return 0;
  414. }
  415.  
  416. guiSceneController.ZoomEntity(delta, isPad);
  417. }
  418.  
  419. event OnPlayAnimation(animationId:int)
  420. {
  421. var itemOnSlot : SItemUniqueId;
  422.  
  423. switch (animationId)
  424. {
  425. case 0:
  426. GetWitcherPlayer().GetItemEquippedOnSlot( EES_SteelSword, itemOnSlot );
  427. if( _inv.IsIdValid( itemOnSlot ) )
  428. {
  429. PlayPaperdollAnimation( 'steelsword' );
  430. }
  431. break;
  432.  
  433. case 1:
  434. GetWitcherPlayer().GetItemEquippedOnSlot( EES_SilverSword, itemOnSlot );
  435. if( _inv.IsIdValid( itemOnSlot ) )
  436. {
  437. PlayPaperdollAnimation( 'silversword' );
  438. }
  439. break;
  440.  
  441. case 2:
  442. ((CActor)m_player).SetBehaviorMimicVariable( 'gameplayMimicsMode', (float)(int)PGMM_Combat );
  443. m_player.RaiseEvent('CombatActionFriendlyEnd');
  444. break;
  445.  
  446. default:
  447. break;
  448. }
  449. }
  450.  
  451. event OnFlashTick()
  452. {
  453. var guiSceneController : CR4GuiSceneController;
  454. var curRotation : EulerAngles;
  455.  
  456. guiSceneController = theGame.GetGuiManager().GetSceneController();
  457.  
  458. if ( guiSceneController )
  459. {
  460.  
  461. }
  462. }
  463.  
  464. event OnChangeCharRenderFocus(next:bool)
  465. {
  466. theGame.GetGuiManager().GetSceneController().OnChangeCharRenderFocus( next );
  467. }
  468.  
  469. event OnMoveCharRenderer(delta:float)
  470. {
  471. var guiSceneController : CR4GuiSceneController;
  472.  
  473. guiSceneController = theGame.GetGuiManager().GetSceneController();
  474.  
  475. if ( !guiSceneController )
  476. {
  477. return 0;
  478. }
  479.  
  480. guiSceneController.MoveEntity(-delta);
  481. }
  482.  
  483. event OnRotateCharRenderer(delta:float)
  484. {
  485. var guiSceneController : CR4GuiSceneController;
  486.  
  487. guiSceneController = theGame.GetGuiManager().GetSceneController();
  488.  
  489. if ( !guiSceneController )
  490. {
  491. return 0;
  492. }
  493.  
  494. guiSceneController.RotateEntity(-delta);
  495. }
  496.  
  497. event OnPlayerStatsShown()
  498. {
  499. if (m_currentContext)
  500. {
  501. m_currentContext.Deactivate();
  502. }
  503. }
  504.  
  505. event OnPlayerStatsHidden()
  506. {
  507. var tutorialStateNewGeekpage : W3TutorialManagerUIHandlerStateNewGeekpage;
  508.  
  509. if (m_currentContext)
  510. {
  511. ActivateContext(m_currentContext);
  512. m_currentContext.UpdateContext();
  513. }
  514.  
  515. if( theGame.GetTutorialSystem().uiHandler && theGame.GetTutorialSystem().uiHandler.GetCurrentStateName() == 'NewGeekpage' )
  516. {
  517. tutorialStateNewGeekpage = ( W3TutorialManagerUIHandlerStateNewGeekpage )theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  518. tutorialStateNewGeekpage.OnGeekpageClosed();
  519. }
  520. }
  521.  
  522. event OnResetPlayerPosition()
  523. {
  524. var guiSceneController : CR4GuiSceneController;
  525.  
  526. guiSceneController = theGame.GetGuiManager().GetSceneController();
  527.  
  528. if ( !guiSceneController )
  529. {
  530. return 0;
  531. }
  532.  
  533. guiSceneController.ResetEntityPosition();
  534. }
  535.  
  536.  
  537. event OnRequestStatsData()
  538. {
  539. var gfxData : CScriptedFlashObject;
  540. var tutorialStateNewGeekpage : W3TutorialManagerUIHandlerStateNewGeekpage;
  541.  
  542. gfxData = GetPlayerStatsGFxDataModded(m_flashValueStorage);
  543.  
  544.  
  545. m_flashValueStorage.SetFlashObject("inventory.player.stats", gfxData);
  546.  
  547.  
  548. if( ShouldProcessTutorial( 'TutorialGeekpageStats' ) && theGame.GetTutorialSystem().uiHandler && theGame.GetTutorialSystem().uiHandler.GetCurrentStateName() == 'NewGeekpage' )
  549. {
  550. tutorialStateNewGeekpage = ( W3TutorialManagerUIHandlerStateNewGeekpage )theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  551. tutorialStateNewGeekpage.OnGeekpageOpened();
  552. }
  553. }
  554.  
  555. event OnTickEvent( delta : int )
  556. {
  557.  
  558. }
  559.  
  560.  
  561.  
  562.  
  563. event OnGuiSceneEntityDestroyed()
  564. {
  565. Event_OnGuiSceneEntityDestroyed();
  566. }
  567.  
  568. private function RestoreSaved() : void
  569. {
  570. var UIData : SInventoryItemUIData;
  571.  
  572.  
  573. }
  574.  
  575. event OnSortingRequested()
  576. {
  577. _playerInv.CleanupItemsGridPosition();
  578. updateCurrentTab();
  579.  
  580. SetTabNewFlags();
  581. }
  582.  
  583. event OnTabDataRequested(tabIndex : int, isHorse:bool)
  584. {
  585. PopulateTabData(tabIndex);
  586. }
  587.  
  588. event OnTabChanged(tabIndex:int)
  589. {
  590. var tutStatePot : W3TutorialManagerUIHandlerStatePotions;
  591. var tutStateOil : W3TutorialManagerUIHandlerStateOils;
  592. var tutStateBooks : W3TutorialManagerUIHandlerStateBooks;
  593. var tutStateArmorUpgrades : W3TutorialManagerUIHandlerStateArmorUpgrades;
  594. var tutStateFood : W3TutorialManagerUIHandlerStateFood;
  595. var tutStateSecondPotionEquip : W3TutorialManagerUIHandlerStateSecondPotionEquip;
  596. var tutStateRecipeReading : W3TutorialManagerUIHandlerStateRecipeReading;
  597.  
  598. // ---=== modE3 ===---
  599. var text : string;
  600.  
  601. switch(tabIndex)
  602. {
  603. case 0:
  604. text = GetLocStringByKeyExt("panel_inventory_tab_weapons");
  605. break;
  606. case 1:
  607. text = GetLocStringById(1054366);
  608. break;
  609. case 2:
  610. text = GetLocStringByKeyExt("panel_alchemy_tab_potions");
  611. break;
  612. case 3:
  613. text = GetLocStringById(1076686);
  614. break;
  615. case 4:
  616. text = GetLocStringById(1078785);
  617. break;
  618. case 5:
  619. text = GetLocStringById(1084734);
  620. break;
  621. }
  622. text = "<font color='#ffae967d' size='23.5'>" + StrUpper(text) + "</font>";
  623. tf_TabText.SetTextHtml(text);
  624. // ---=== modE3 ===---
  625.  
  626.  
  627. currentlySelectedTab = tabIndex;
  628.  
  629. if(tabIndex == InventoryMenuTab_Potions && ShouldProcessTutorial('TutorialPotionCanEquip2'))
  630. {
  631. tutStatePot = (W3TutorialManagerUIHandlerStatePotions)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  632. if(tutStatePot)
  633. {
  634. tutStatePot.OnPotionTabSelected();
  635. }
  636. }
  637. if(tabIndex == InventoryMenuTab_Default && ShouldProcessTutorial('TutorialFoodSelectTab'))
  638. {
  639. tutStateFood = (W3TutorialManagerUIHandlerStateFood)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  640. if(tutStateFood)
  641. {
  642. tutStateFood.OnPotionTabSelected();
  643. }
  644. }
  645. if(tabIndex == InventoryMenuTab_Potions && ShouldProcessTutorial('TutorialOilCanEquip2'))
  646. {
  647. tutStateOil = (W3TutorialManagerUIHandlerStateOils)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  648. if(tutStateOil)
  649. {
  650. tutStateOil.OnOilTabSelected();
  651. }
  652. }
  653. if(ShouldProcessTutorial('TutorialBooksSelectTab'))
  654. {
  655. tutStateBooks = (W3TutorialManagerUIHandlerStateBooks)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  656. if(tutStateBooks)
  657. {
  658. tutStateBooks.OnSelectedTab(tabIndex == InventoryMenuTab_Books);
  659. }
  660. else
  661. {
  662. tutStateRecipeReading = (W3TutorialManagerUIHandlerStateRecipeReading)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  663. if(tutStateRecipeReading)
  664. {
  665. tutStateRecipeReading.OnSelectedTab(tabIndex == InventoryMenuTab_Books);
  666. }
  667. }
  668. }
  669. if(tabIndex == InventoryMenuTab_Weapons && ShouldProcessTutorial('TutorialArmorSocketsSelectTab'))
  670. {
  671. tutStateArmorUpgrades = (W3TutorialManagerUIHandlerStateArmorUpgrades)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  672. if(tutStateArmorUpgrades)
  673. {
  674. tutStateArmorUpgrades.OnTabSelected();
  675. }
  676. }
  677. if(tabIndex == InventoryMenuTab_Potions && ShouldProcessTutorial('TutorialPotionCanEquip1'))
  678. {
  679. tutStateSecondPotionEquip = (W3TutorialManagerUIHandlerStateSecondPotionEquip)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  680. if(tutStateSecondPotionEquip)
  681. {
  682. tutStateSecondPotionEquip.OnPotionTabSelected();
  683. }
  684. }
  685. }
  686.  
  687. public function updateCurrentTab():void
  688. {
  689. if (currentlySelectedTab != -1)
  690. {
  691. PopulateTabData(currentlySelectedTab);
  692. }
  693. }
  694.  
  695. public function PopulateTabData(tabIndex:int) : void
  696. {
  697. var l_flashObject : CScriptedFlashObject;
  698. var l_flashArray : CScriptedFlashArray;
  699.  
  700. l_flashObject = m_flashValueStorage.CreateTempFlashObject();
  701. l_flashArray = m_flashValueStorage.CreateTempFlashArray();
  702.  
  703.  
  704. switch (tabIndex)
  705. {
  706. case InventoryMenuTab_Weapons:
  707. _playerInv.SetFilterType( IFT_Weapons );
  708. _playerInv.GetInventoryFlashArray(l_flashArray, l_flashObject);
  709. break;
  710. case InventoryMenuTab_Potions:
  711. _playerInv.SetFilterType( IFT_AlchemyItems );
  712. _playerInv.GetInventoryFlashArray(l_flashArray, l_flashObject);
  713. break;
  714. case InventoryMenuTab_Ingredients:
  715. _playerInv.SetFilterType( IFT_Ingredients );
  716. _playerInv.GetInventoryFlashArray(l_flashArray, l_flashObject);
  717. break;
  718. case InventoryMenuTab_QuestItems:
  719. _playerInv.SetFilterType( IFT_QuestItems );
  720. _playerInv.GetInventoryFlashArray(l_flashArray, l_flashObject);
  721. break;
  722. case InventoryMenuTab_Default:
  723. _playerInv.SetFilterType( IFT_Default );
  724. _playerInv.GetInventoryFlashArray(l_flashArray, l_flashObject);
  725. break;
  726. case InventoryMenuTab_Books:
  727. _playerInv.SetFilterType( IFT_Books );
  728. _playerInv.GetInventoryFlashArray(l_flashArray, l_flashObject);
  729. break;
  730. }
  731.  
  732.  
  733.  
  734.  
  735. PopulateDataForTab(tabIndex, l_flashArray);
  736. }
  737.  
  738. private function PopulateDataForTab(tabIndex:int, entriesArray:CScriptedFlashArray):void
  739. {
  740. var l_flashObject : CScriptedFlashObject;
  741.  
  742. l_flashObject = m_flashValueStorage.CreateTempFlashObject();
  743. l_flashObject.SetMemberFlashInt("tabIndex", tabIndex);
  744. l_flashObject.SetMemberFlashArray("tabData", entriesArray);
  745.  
  746. if( entriesArray.GetLength() > 0 )
  747. {
  748. m_fxShowSecondaryModulesSFF.InvokeSelfOneArg(FlashArgBool(true));
  749. }
  750. else
  751. {
  752. m_fxShowSecondaryModulesSFF.InvokeSelfOneArg(FlashArgBool(false));
  753. }
  754.  
  755. m_flashValueStorage.SetFlashObject( "player.inventory.menu.tabs.data" + tabIndex, l_flashObject );
  756. }
  757.  
  758. public function SetInitialTabNewFlags( out hasNewItems : array< bool > ):int
  759. {
  760. var notEmptyTabIdx : int = -1;
  761. var hasItems : bool;
  762. var currentFilter : EInventoryFilterType;
  763.  
  764. currentFilter = _playerInv.GetFilterType();
  765.  
  766. _playerInv.SetFilterType( IFT_Ingredients );
  767. hasNewItems.PushBack( _playerInv.HasNewFlagOnItem( hasItems ) );
  768. if (hasItems) notEmptyTabIdx = 0;
  769.  
  770. _playerInv.SetFilterType( IFT_QuestItems );
  771. hasNewItems.PushBack( _playerInv.HasNewFlagOnItem( hasItems ) );
  772. if (hasItems) notEmptyTabIdx = 1;
  773.  
  774. _playerInv.SetFilterType( IFT_Default );
  775. hasNewItems.PushBack( _playerInv.HasNewFlagOnItem( hasItems ) );
  776. if (hasItems) notEmptyTabIdx = 2;
  777.  
  778. _playerInv.SetFilterType( IFT_AlchemyItems );
  779. hasNewItems.PushBack( _playerInv.HasNewFlagOnItem( hasItems ) );
  780. if (hasItems) notEmptyTabIdx = 3;
  781.  
  782. _playerInv.SetFilterType( IFT_Weapons );
  783. hasNewItems.PushBack( _playerInv.HasNewFlagOnItem( hasItems ) );
  784. if (hasItems) notEmptyTabIdx = 4;
  785.  
  786. _playerInv.SetFilterType( currentFilter );
  787. return notEmptyTabIdx;
  788. }
  789.  
  790. public function SetTabNewFlags():void
  791. {
  792. var hasNewItems : array< bool >;
  793. var filtersToCheck : array <EInventoryFilterType>;
  794.  
  795. filtersToCheck.PushBack( IFT_Ingredients );
  796. filtersToCheck.PushBack( IFT_QuestItems );
  797. filtersToCheck.PushBack( IFT_Default );
  798. filtersToCheck.PushBack( IFT_AlchemyItems );
  799. filtersToCheck.PushBack( IFT_Weapons );
  800.  
  801. hasNewItems = _playerInv.GetNewFlagForTabs( filtersToCheck );
  802.  
  803. m_fxSetNewFlagsForTabs.InvokeSelfSixArgs(FlashArgBool(hasNewItems[IFT_Ingredients]), FlashArgBool(hasNewItems[IFT_QuestItems]), FlashArgBool(hasNewItems[IFT_Default]), FlashArgBool(hasNewItems[IFT_AlchemyItems]), FlashArgBool(hasNewItems[IFT_Weapons]), FlashArgBool(hasNewItems[5]));
  804. }
  805.  
  806. public function getTabFromItem(item:SItemUniqueId):int
  807. {
  808. var inventoryFilterType:EInventoryFilterType;
  809.  
  810. inventoryFilterType = _playerInv.GetFilterTypeByItem(item);
  811.  
  812. return getTabFromFilter(inventoryFilterType);
  813. }
  814.  
  815. public function getTabFromFilter(inventoryFilterType:EInventoryFilterType):int
  816. {
  817.  
  818. switch (inventoryFilterType)
  819. {
  820. case IFT_Weapons:
  821. return InventoryMenuTab_Weapons;
  822. case IFT_AlchemyItems:
  823. return InventoryMenuTab_Potions;
  824. case IFT_Ingredients:
  825. return InventoryMenuTab_Ingredients;
  826. case IFT_QuestItems:
  827. return InventoryMenuTab_QuestItems;
  828. case IFT_Default:
  829. return InventoryMenuTab_Default;
  830. case IFT_Books:
  831. return InventoryMenuTab_Books;
  832. }
  833.  
  834.  
  835. return InventoryMenuTab_Default;
  836. }
  837.  
  838. public function UpdateEncumbranceInfo() : void
  839. {
  840. var encumbrance : int;
  841. var encumbranceMax : int;
  842. var hasHorseUpgrade : bool;
  843.  
  844. encumbrance = (int)GetWitcherPlayer().GetEncumbrance();
  845. encumbranceMax = (int)GetWitcherPlayer().GetMaxRunEncumbrance(hasHorseUpgrade);
  846.  
  847.  
  848.  
  849.  
  850. UpdateItemsCounter();
  851. }
  852.  
  853. public function GetCurrentInventoryState():EInventoryMenuState
  854. {
  855. return _currentState;
  856. }
  857.  
  858. private function SetInventoryState(targetMode : int) : void
  859. {
  860. drawHorse = false;
  861. _currentState = targetMode;
  862. m_fxSetInventoryMode.InvokeSelfOneArg(FlashArgInt(_currentState));
  863. switch (targetMode)
  864. {
  865. case IMS_Player:
  866. m_fxSetFilteringMode.InvokeSelfOneArg(FlashArgBool(false));
  867. UpdateEntityTemplate();
  868. break;
  869. case IMS_Shop:
  870. UpdateShop();
  871. m_fxSetFilteringMode.InvokeSelfOneArg(FlashArgBool(false));
  872. break;
  873. case IMS_Container:
  874. UpdateContainer();
  875. m_fxSetFilteringMode.InvokeSelfOneArg(FlashArgBool(m_tagsFilter.Size() > 0));
  876. break;
  877. case IMS_HorseInventory:
  878. drawHorse = true;
  879. UpdateHorseInventory();
  880. UpdateHorsePaperdoll();
  881. m_fxSetFilteringMode.InvokeSelfOneArg(FlashArgBool(false));
  882. break;
  883. case IMS_Stash:
  884. _playerInv.stashMode = true;
  885. _horseInv.dontShowEquipped = true;
  886. UpdateHorseInventory();
  887. break;
  888. default:
  889. break;
  890. }
  891. }
  892.  
  893. private function UpdateEntityTemplate() : void
  894. {
  895. var templateFilename : string;
  896. var appearance : name;
  897. var environmentFilename : string;
  898. var environmentSunRotation : EulerAngles;
  899. var cameraLookAt : Vector;
  900. var cameraRotation : EulerAngles;
  901. var cameraDistance : float;
  902. var updateItems : bool;
  903. var fov : float;
  904.  
  905. var guiSceneController : CR4GuiSceneController;
  906.  
  907. guiSceneController = theGame.GetGuiManager().GetSceneController();
  908. if ( !guiSceneController )
  909. {
  910.  
  911. return;
  912. }
  913.  
  914. if ( drawHorse )
  915. {
  916. templateFilename = "HorseForUI";
  917. appearance = '';
  918. environmentSunRotation.Yaw = 250;
  919. environmentSunRotation.Pitch = 10;
  920. cameraLookAt.Z = 1;
  921. cameraRotation.Yaw = 88.6;
  922. cameraRotation.Pitch = 355;
  923. cameraDistance = 3.17;
  924. fov = 35.0f;
  925. updateItems = true;
  926. }
  927. else
  928. {
  929.  
  930.  
  931. templateFilename = "GeraltForUI";
  932. appearance = '';
  933. environmentSunRotation.Yaw = 180; // 0 not sure these envSun vars even do anything...
  934. environmentSunRotation.Pitch = 0; // 0
  935. cameraLookAt.Z = -0.92; // 0.92
  936. cameraRotation.Yaw = 220; // 190.71
  937. cameraRotation.Pitch = -10; // 5
  938. cameraDistance = 3.2; // 3.2
  939. fov = 35.0f; // 35.0f
  940. updateItems = true;
  941. }
  942.  
  943.  
  944. guiSceneController.SetEntityTemplate( templateFilename );
  945. guiSceneController.SetCamera( cameraLookAt, cameraRotation, cameraDistance, fov );
  946. guiSceneController.SetEnvironmentAndSunRotation( "DefaultEnvironmentForUI", environmentSunRotation );
  947.  
  948. // ---=== modE3 ===--- // Position (x,y,z) // Rotation(pitch,yaw,roll) // Scale (each direction should be the same)
  949. guiSceneController.SetEntityTransform(Vector(0,0,-1.8), EulerAngles(0,60,0) , Vector(0.9,0.9,0.9));
  950. // ---=== modE3 ===---
  951.  
  952. guiSceneController.SetEntityAppearance( appearance );
  953. guiSceneController.SetEntityItems( updateItems );
  954. }
  955.  
  956. public function SetMenuState(newState : name) : void
  957. {
  958. super.SetMenuState(newState);
  959. if (m_menuInited)
  960. {
  961. ApplyMenuState(newState);
  962. }
  963. }
  964.  
  965. protected function ApplyMenuState(newState : name) : void
  966. {
  967. //LogChannel('INVENTORY', "SetMenuState: " + newState);
  968.  
  969. switch (newState)
  970. {
  971. case 'CharacterInventory':
  972. SetInventoryState(_defaultInventoryState);
  973. break;
  974. case 'HorseInventory':
  975. SetInventoryState(IMS_HorseInventory);
  976. break;
  977. }
  978. }
  979.  
  980. function UpdateData()
  981. {
  982. updateCurrentTab();
  983. PaperdollUpdateAll();
  984. UpdateItemsCounter();
  985. UpdatePlayerStatisticsData();
  986. }
  987.  
  988. function InventoryUpdateItem( item : SItemUniqueId )
  989. {
  990. var tempFlashObject : CScriptedFlashObject;
  991. var itemDataObject : CScriptedFlashObject;
  992.  
  993. if (!_inv.ItemHasTag(item, 'NoShow'))
  994. {
  995. tempFlashObject = m_flashValueStorage.CreateTempFlashObject();
  996. itemDataObject = tempFlashObject.CreateFlashObject("red.game.witcher3.menus.common.ItemDataStub");
  997. _playerInv.SetInventoryFlashObjectForItem(item, itemDataObject);
  998. itemDataObject.SetMemberFlashInt("tabIndex", getTabFromFilter(_playerInv.GetFilterTypeByItem(item)));
  999. m_flashValueStorage.SetFlashObject( "inventory.grid.player.itemUpdate", itemDataObject );
  1000. }
  1001. }
  1002.  
  1003. function ShopUpdateItem( item : SItemUniqueId )
  1004. {
  1005. var tempFlashObject : CScriptedFlashObject;
  1006. var itemDataObject : CScriptedFlashObject;
  1007.  
  1008. tempFlashObject = m_flashValueStorage.CreateTempFlashObject();
  1009. itemDataObject = tempFlashObject.CreateFlashObject("red.game.witcher3.menus.common.ItemDataStub");
  1010. _shopInv.SetInventoryFlashObjectForItem(item, itemDataObject);
  1011. itemDataObject.SetMemberFlashInt("tabIndex", GetTabIndexForSlot(getTabFromFilter(_shopInv.GetInventoryComponent().GetFilterTypeByItem(item))));
  1012. m_flashValueStorage.SetFlashObject( "inventory.grid.container.itemUpdate", itemDataObject );
  1013. }
  1014.  
  1015. function InventoryUpdateItems( itemsList : array<SItemUniqueId> )
  1016. {
  1017. var i : int;
  1018. var tempFlashObject : CScriptedFlashObject;
  1019. var itemDataObject : CScriptedFlashObject;
  1020. var itemsDataList : CScriptedFlashArray;
  1021.  
  1022. itemsDataList = m_flashValueStorage.CreateTempFlashArray();
  1023. tempFlashObject = m_flashValueStorage.CreateTempFlashObject();
  1024. for ( i = 0; i < itemsList.Size(); i += 1 )
  1025. {
  1026. itemDataObject = tempFlashObject.CreateFlashObject("red.game.witcher3.menus.common.ItemDataStub");
  1027. _playerInv.SetInventoryFlashObjectForItem(itemsList[i], itemDataObject);
  1028. itemDataObject.SetMemberFlashInt("tabIndex", getTabFromFilter(_playerInv.GetFilterTypeByItem(itemsList[i])));
  1029. itemsDataList.PushBackFlashObject(itemDataObject);
  1030. }
  1031. m_flashValueStorage.SetFlashArray( "inventory.grid.player.itemsUpdate", itemsDataList );
  1032. }
  1033.  
  1034. function InventoryRemoveItem( item : SItemUniqueId, optional keepSelectionIdx : bool )
  1035. {
  1036. m_fxInventoryRemoveItem.InvokeSelfTwoArgs( FlashArgUInt(ItemToFlashUInt(item)), FlashArgBool(keepSelectionIdx) );
  1037.  
  1038. }
  1039.  
  1040. function ShopRemoveItem( item : SItemUniqueId )
  1041. {
  1042. m_fxRemoveContainerItem.InvokeSelfOneArg( FlashArgUInt( ItemToFlashUInt(item) ));
  1043. }
  1044.  
  1045. function PaperdollRemoveItem( item : SItemUniqueId )
  1046. {
  1047. m_fxPaperdollRemoveItem.InvokeSelfOneArg( FlashArgUInt( ItemToFlashUInt(item) ));
  1048. }
  1049.  
  1050. private function AddEquippedPotionsToList(out itemsList : array < SItemUniqueId > ) : void
  1051. {
  1052. var itemOnSlot : SItemUniqueId;
  1053.  
  1054. GetWitcherPlayer().GetItemEquippedOnSlot(EES_Potion1, itemOnSlot);
  1055. if ( _inv.IsIdValid(itemOnSlot) )
  1056. {
  1057. itemsList.PushBack(itemOnSlot);
  1058. }
  1059. GetWitcherPlayer().GetItemEquippedOnSlot(EES_Potion2,itemOnSlot);
  1060. if ( _inv.IsIdValid(itemOnSlot) )
  1061. {
  1062. itemsList.PushBack(itemOnSlot);
  1063. }
  1064. GetWitcherPlayer().GetItemEquippedOnSlot(EES_Potion3,itemOnSlot);
  1065. if ( _inv.IsIdValid(itemOnSlot) )
  1066. {
  1067. itemsList.PushBack(itemOnSlot);
  1068. }
  1069. GetWitcherPlayer().GetItemEquippedOnSlot(EES_Potion4,itemOnSlot);
  1070. if ( _inv.IsIdValid(itemOnSlot) )
  1071. {
  1072. itemsList.PushBack(itemOnSlot);
  1073. }
  1074. }
  1075.  
  1076. function PaperdollUpdateItemsList( itemsList : array<SItemUniqueId> )
  1077. {
  1078. var i : int;
  1079. var tempFlashObject : CScriptedFlashObject;
  1080. var itemDataObject : CScriptedFlashObject;
  1081. var itemsDataList : CScriptedFlashArray;
  1082.  
  1083. itemsDataList = m_flashValueStorage.CreateTempFlashArray();
  1084. tempFlashObject = m_flashValueStorage.CreateTempFlashObject();
  1085. for ( i = 0; i < itemsList.Size(); i += 1 )
  1086. {
  1087. itemDataObject = tempFlashObject.CreateFlashObject("red.game.witcher3.menus.common.ItemDataStub");
  1088. _paperdollInv.SetInventoryFlashObjectForItem(itemsList[i], itemDataObject);
  1089. itemsDataList.PushBackFlashObject(itemDataObject);
  1090. }
  1091. m_flashValueStorage.SetFlashArray( "inventory.grid.paperdoll.items.update", itemsDataList );
  1092. }
  1093.  
  1094. function PaperdollUpdateItem( item : SItemUniqueId )
  1095. {
  1096. var tempFlashObject : CScriptedFlashObject;
  1097. var itemDataObject : CScriptedFlashObject;
  1098.  
  1099. tempFlashObject = m_flashValueStorage.CreateTempFlashObject();
  1100. itemDataObject = tempFlashObject.CreateFlashObject("red.game.witcher3.menus.common.ItemDataStub");
  1101. _paperdollInv.SetInventoryFlashObjectForItem(item, itemDataObject);
  1102. m_flashValueStorage.SetFlashObject( "inventory.grid.paperdoll.item.update", itemDataObject );
  1103. }
  1104.  
  1105. function PaperdollUpdateHorseItem( item : SItemUniqueId )
  1106. {
  1107. var tempFlashObject : CScriptedFlashObject;
  1108. var itemDataObject : CScriptedFlashObject;
  1109.  
  1110. tempFlashObject = m_flashValueStorage.CreateTempFlashObject();
  1111. itemDataObject = tempFlashObject.CreateFlashObject("red.game.witcher3.menus.common.ItemDataStub");
  1112. _horsePaperdollInv.SetInventoryFlashObjectForItem(item, itemDataObject);
  1113. m_flashValueStorage.SetFlashObject( "inventory.grid.paperdoll.item.update", itemDataObject );
  1114. }
  1115.  
  1116. function UpdateItemData( item : SItemUniqueId )
  1117. {
  1118. var l_flashObject : CScriptedFlashObject;
  1119.  
  1120. l_flashObject = m_flashValueStorage.CreateTempFlashObject();
  1121. _playerInv.SetInventoryFlashObjectForItem(item,l_flashObject);
  1122. m_flashValueStorage.SetFlashObject( "inventory.grid.player.item", l_flashObject );
  1123. }
  1124.  
  1125. function PaperdollUpdateAll()
  1126. {
  1127. UpdateItemsList("inventory.grid.paperdoll", _paperdollInv, _horsePaperdollInv);
  1128. }
  1129.  
  1130. function UpdateHorsePaperdoll()
  1131. {
  1132. UpdateItemsList("inventory.grid.paperdoll.horse", _horsePaperdollInv);
  1133. }
  1134.  
  1135. function UpdateHorseInventory()
  1136. {
  1137. UpdateItemsList("inventory.grid.container", _horseInv);
  1138. }
  1139.  
  1140. function UpdateContainer()
  1141. {
  1142. UpdateItemsList("inventory.grid.container", _containerInv);
  1143. }
  1144.  
  1145. function UpdateShop()
  1146. {
  1147. UpdateItemsList("inventory.grid.container", _shopInv);
  1148. }
  1149.  
  1150. private function UpdateItemsList( flashBinding:string, targetInventory : W3GuiBaseInventoryComponent, optional secondaryInventory : W3GuiBaseInventoryComponent ):void
  1151. {
  1152. var l_flashObject : CScriptedFlashObject;
  1153. var l_flashArray : CScriptedFlashArray;
  1154.  
  1155. l_flashArray = m_flashValueStorage.CreateTempFlashArray();
  1156. l_flashObject = m_flashValueStorage.CreateTempFlashObject();
  1157.  
  1158. if (targetInventory)
  1159. {
  1160. targetInventory.GetInventoryFlashArray(l_flashArray, l_flashObject);
  1161. }
  1162.  
  1163. if (secondaryInventory)
  1164. {
  1165. secondaryInventory.GetInventoryFlashArray(l_flashArray, l_flashObject);
  1166. }
  1167.  
  1168.  
  1169.  
  1170. m_flashValueStorage.SetFlashArray( flashBinding, l_flashArray );
  1171.  
  1172. }
  1173.  
  1174. private function UpdateItemsCounter()
  1175. {
  1176. var itemsNr : int;
  1177. var commonMenu : CR4CommonMenu;
  1178.  
  1179. commonMenu = (CR4CommonMenu)m_parentMenu;
  1180.  
  1181. if( commonMenu )
  1182. {
  1183. itemsNr = commonMenu.UpdateItemsCounter();
  1184. }
  1185.  
  1186. if( itemsNr >= MAX_ITEM_NR && currentItemsNr != itemsNr )
  1187. {
  1188. currentItemsNr = itemsNr;
  1189.  
  1190. }
  1191. }
  1192.  
  1193.  
  1194.  
  1195. event OnGetItemData(item : SItemUniqueId, compareItemType : int)
  1196. {
  1197. ShowItemTooltip(item, compareItemType);
  1198. }
  1199.  
  1200. event OnGetItemDataForMouse(item : SItemUniqueId, compareItemType : int)
  1201. {
  1202. ShowItemMouseTooltip(item, compareItemType);
  1203. }
  1204.  
  1205. event OnShowStatTooltip(statName : name)
  1206. {
  1207. ShowStatTooltip(statName);
  1208. }
  1209.  
  1210. event OnGetEmptyPaperdollTooltip(equipID:int, isLocked:bool)
  1211. {
  1212. ShowEmptySlotTooltip(equipID);
  1213. }
  1214.  
  1215.  
  1216. public function ShowStatTooltip(statName : name)
  1217. {
  1218. var resultData : CScriptedFlashObject;
  1219. var statsList : CScriptedFlashArray;
  1220.  
  1221. resultData = m_flashValueStorage.CreateTempFlashObject();
  1222. statsList = m_flashValueStorage.CreateTempFlashArray();
  1223. switch (statName)
  1224. {
  1225. case 'vitality':
  1226. GetHealthTooltipData(statsList);
  1227. break;
  1228. case 'toxicity':
  1229. GetToxicityTooltipData(statsList);
  1230. break;
  1231. case 'stamina':
  1232. GetStaminaTooltipData(statsList);
  1233. break;
  1234. case 'focus':
  1235. GetAdrenalineTooltipData(statsList);
  1236. break;
  1237. case 'stat_offense':
  1238. GetOffenseTooltipData(statsList);
  1239. break;
  1240. case 'stat_defense':
  1241. GetDefenseTooltipData(statsList);
  1242. break;
  1243. case 'stat_signs':
  1244. GetSignsTooltipData(statsList);
  1245. break;
  1246. }
  1247. resultData.SetMemberFlashString("title", GetLocStringByKeyExt(statName));
  1248. resultData.SetMemberFlashString("description", GetLocStringByKeyExt(statName+"_desc"));
  1249. resultData.SetMemberFlashArray("statsList", statsList);
  1250.  
  1251. m_flashValueStorage.SetFlashObject("statistic.tooltip.data", resultData);
  1252. }
  1253.  
  1254. var hackHideStatTooltip:bool;
  1255. public function HideStatTooltip()
  1256. {
  1257. m_flashValueStorage.SetFlashBool("statistic.tooltip.hide", hackHideStatTooltip);
  1258. hackHideStatTooltip = !hackHideStatTooltip;
  1259. }
  1260.  
  1261. public function GetItemExpTooltipData(item : SItemUniqueId) : CScriptedFlashObject
  1262. {
  1263. _tooltipDataProvider.setCurrentInventory(GetCurrentInventory(item));
  1264. return _tooltipDataProvider.GetExItemData(item, _currentInv == _shopInv);
  1265. }
  1266.  
  1267. public function ShowEmptySlotTooltip(slotId : int):void
  1268. {
  1269. var tooltipData : CScriptedFlashObject;
  1270. _tooltipDataProvider.setCurrentInventory(GetCurrentInventory(GetInvalidUniqueId()));
  1271. tooltipData = _tooltipDataProvider.GetEmptySlotData(slotId);
  1272. m_flashValueStorage.SetFlashObject("context.tooltip.data", tooltipData);
  1273. //theGame.GetGuiManager().ShowNotification( "ShowEmptySlotTooltip" );
  1274. }
  1275.  
  1276. event OnClearSlotNewFlag(item : SItemUniqueId)
  1277. {
  1278. var curInventory : CInventoryComponent;
  1279. var uiData : SInventoryItemUIData;
  1280.  
  1281. curInventory = GetCurrentInventory(item);
  1282.  
  1283. if ( curInventory.IsIdValid( m_bookPopupItem ) && m_bookPopupItem == item )
  1284. {
  1285.  
  1286. m_bookPopupItem = GetInvalidUniqueId();
  1287. return false;
  1288. }
  1289.  
  1290.  
  1291. if (curInventory.IsIdValid(item))
  1292. {
  1293. uiData = curInventory.GetInventoryItemUIData( item );
  1294. uiData.isNew = false;
  1295. curInventory.SetInventoryItemUIData( item, uiData );
  1296. }
  1297. }
  1298.  
  1299. public function ShowItemTooltip(item : SItemUniqueId, compareItemType : int) : void
  1300. {
  1301. var tooltipData : CScriptedFlashObject;
  1302. // ---=== modE3 ===--- Lim3zer0
  1303. //ShowItemTooltipIcon(item,GetCurrentInventory(item),187,824);
  1304. // ---=== modE3 ===---
  1305. _tooltipDataProvider.setCurrentInventory(GetCurrentInventory(item));
  1306. tooltipData = _tooltipDataProvider.GetTooltipData(item, _currentInv == _shopInv, true);
  1307. m_flashValueStorage.SetFlashObject("context.tooltip.data", tooltipData);
  1308. }
  1309.  
  1310. public function ShowItemMouseTooltip(item : SItemUniqueId, compareItemType : int) : void
  1311. {
  1312. var tooltipData : CScriptedFlashObject;
  1313. // ---=== modE3 ===--- Lim3zer0
  1314. //ShowItemTooltipIcon(item,GetInventoryComponent(_currentMouseInv),187,824);
  1315. // ---=== modE3 ===---
  1316. _tooltipDataProvider.setCurrentInventory(GetInventoryComponent(_currentMouseInv));
  1317. tooltipData = _tooltipDataProvider.GetTooltipData(item, _currentMouseInv == _shopInv, true);
  1318. m_flashValueStorage.SetFlashObject("context.tooltip.data", tooltipData);
  1319. }
  1320.  
  1321. var hackHideItemTooltip:bool;
  1322. public function HideItemTooltip()
  1323. {
  1324. m_flashValueStorage.SetFlashBool("context.tooltip.hide", hackHideItemTooltip);
  1325. hackHideItemTooltip = !hackHideItemTooltip;
  1326. }
  1327.  
  1328. public function GetCurrentInventoryComponent():W3GuiBaseInventoryComponent
  1329. {
  1330. return _currentInv;
  1331. }
  1332.  
  1333. public function GetCurrentInventory(optional item : SItemUniqueId):CInventoryComponent
  1334. {
  1335. return GetInventoryComponent(_currentInv);
  1336. }
  1337.  
  1338. public function GetInventoryComponent(_targetInv : W3GuiBaseInventoryComponent):CInventoryComponent
  1339. {
  1340. if( _targetInv == _shopInv )
  1341. {
  1342. return _shopNpc.GetInventory();
  1343. }
  1344. else if( _targetInv == _containerInv)
  1345. {
  1346. return _container.GetInventory();
  1347. }
  1348. else if (_targetInv == _horsePaperdollInv)
  1349. {
  1350. return _horsePaperdollInv.GetInventoryComponent();
  1351. }
  1352. else if (_targetInv == _horseInv)
  1353. {
  1354. return _horseInv.GetInventoryComponent();
  1355. }
  1356. else
  1357. {
  1358. return _inv;
  1359. }
  1360. }
  1361.  
  1362. public function getShopInventory():CInventoryComponent
  1363. {
  1364. if (_shopNpc)
  1365. {
  1366. return _shopNpc.GetInventory();
  1367. }
  1368. return NULL;
  1369. }
  1370.  
  1371. function GetFilterType( item : SItemUniqueId ) : EInventoryFilterType
  1372. {
  1373. return _paperdollInv.GetFilterTypeByItem( item );
  1374. }
  1375.  
  1376. function GetItemDefaultActionName( item : SItemUniqueId ) : string
  1377. {
  1378. var itemAction : EInventoryActionType;
  1379. itemAction = GetItemDefaultAction(item);
  1380.  
  1381. return GetItemActionFriendlyName(itemAction,GetWitcherPlayer().IsItemEquipped(item));
  1382. }
  1383.  
  1384. function GetItemDefaultAction( item : SItemUniqueId ) : EInventoryActionType
  1385. {
  1386. var itemAction : EInventoryActionType;
  1387. itemAction = _playerInv.GetItemActionType( item, true );
  1388. return itemAction;
  1389. }
  1390.  
  1391.  
  1392.  
  1393. private function GetHealthTooltipData(out GFxData: CScriptedFlashArray):void
  1394. {
  1395. var maxHealth:float;
  1396. var curHealth:float;
  1397. var inCombatRegen:float;
  1398. var outOfCombatRegen:float;
  1399. var inCombatRegenStr : string;
  1400. var outOfCombatRegenStr : string;
  1401.  
  1402. maxHealth = thePlayer.GetStatMax(BCS_Vitality);
  1403. curHealth = thePlayer.GetStatPercents(BCS_Vitality);
  1404. inCombatRegen = CalculateAttributeValue(thePlayer.GetAttributeValue('vitalityCombatRegen'));
  1405. outOfCombatRegen = CalculateAttributeValue(thePlayer.GetAttributeValue('vitalityRegen'));
  1406. inCombatRegenStr = NoTrailZeros( RoundTo( inCombatRegen, 1 ) );
  1407. outOfCombatRegenStr = NoTrailZeros( RoundTo( outOfCombatRegen, 1 ) );
  1408. PushStatItem(GFxData, "panel_common_statistics_tooltip_current_health", (string)RoundMath(maxHealth * curHealth));
  1409. PushStatItem(GFxData, "panel_common_statistics_tooltip_maximum_health", (string)RoundMath(maxHealth));
  1410. PushStatItem(GFxData, "panel_common_statistics_tooltip_incombat_regen", inCombatRegenStr );
  1411. PushStatItem(GFxData, "panel_common_statistics_tooltip_outofcombat_regen", outOfCombatRegenStr );
  1412. }
  1413.  
  1414. private function GetToxicityTooltipData(out GFxData: CScriptedFlashArray):void
  1415. {
  1416. var maxToxicity:float;
  1417. var curToxicity:float;
  1418. var lockedToxicity:float;
  1419. var toxicityThreshold:float;
  1420.  
  1421. maxToxicity = thePlayer.GetStatMax(BCS_Toxicity);
  1422. curToxicity = thePlayer.GetStat(BCS_Toxicity, true);
  1423. lockedToxicity = thePlayer.GetStat(BCS_Toxicity) - curToxicity;
  1424. toxicityThreshold = GetWitcherPlayer().GetToxicityDamageThreshold();
  1425.  
  1426. PushStatItem(GFxData, "panel_common_statistics_tooltip_current_toxicity", (string)RoundMath(curToxicity));
  1427. PushStatItem(GFxData, "panel_common_statistics_tooltip_current_maximum", (string)RoundMath(maxToxicity));
  1428.  
  1429. PushStatItem(GFxData, "panel_common_statistics_tooltip_locked", (string)RoundMath(lockedToxicity));
  1430. PushStatItem(GFxData, "panel_common_statistics_tooltip_threshold", (string)RoundMath(toxicityThreshold));
  1431. PushStatItem(GFxData, "panel_common_statistics_tooltip_degeneration", (string)RoundMath(0));
  1432. }
  1433.  
  1434. private function GetStaminaTooltipData(out GFxData: CScriptedFlashArray):void
  1435. {
  1436. var maxStamina:float;
  1437. var regenStamia:float;
  1438. var value : SAbilityAttributeValue;
  1439.  
  1440. value = thePlayer.GetAttributeValue('staminaRegen');
  1441. regenStamia = value.valueMultiplicative / 0.34;
  1442. maxStamina = thePlayer.GetStatMax(BCS_Stamina);
  1443. PushStatItem(GFxData, "panel_common_statistics_tooltip_maximum_stamina ", (string)RoundMath(maxStamina));
  1444. PushStatItem(GFxData, "panel_common_statistics_tooltip_regeneration_rate", (string)NoTrailZeros( RoundTo(regenStamia, 2) ) );
  1445.  
  1446. }
  1447.  
  1448. private function GetAdrenalineTooltipData(out GFxData: CScriptedFlashArray):void
  1449. {
  1450. var maxAdrenaline:float;
  1451. var curAdrenaline:float;
  1452.  
  1453. maxAdrenaline = thePlayer.GetStatMax(BCS_Focus);
  1454. curAdrenaline = thePlayer.GetStat(BCS_Focus);
  1455. PushStatItem(GFxData, "panel_common_statistics_tooltip_adrenaline_current", (string)FloorF(curAdrenaline));
  1456. PushStatItem(GFxData, "panel_common_statistics_tooltip_adrenaline_max", (string)RoundMath(maxAdrenaline));
  1457.  
  1458. }
  1459.  
  1460. private function GetOffenseTooltipData(out GFxData: CScriptedFlashArray):void
  1461. {
  1462. var curStats:SPlayerOffenseStats;
  1463. curStats = GetWitcherPlayer().GetOffenseStatsList();
  1464.  
  1465. PushStatItem(GFxData, "panel_common_statistics_tooltip_steel_fast_dps", StatToStr(curStats.steelFastDPS));
  1466. PushStatItem(GFxData, "panel_common_statistics_tooltip_steel_fast_crit_chance", StatToStr(curStats.steelFastCritChance) + "%");
  1467. PushStatItem(GFxData, "panel_common_statistics_tooltip_steel_fast_crit_dmg", StatToStr(curStats.steelFastCritDmg) + "%");
  1468.  
  1469. PushStatItem(GFxData, "panel_common_statistics_tooltip_steel_strong_dps", StatToStr(curStats.steelStrongDPS));
  1470. PushStatItem(GFxData, "panel_common_statistics_tooltip_steel_strong_crit_chance", StatToStr(curStats.steelStrongCritChance) + "%");
  1471. PushStatItem(GFxData, "panel_common_statistics_tooltip_steel_strong_crit_dmg", StatToStr(curStats.steelStrongCritDmg) + "%");
  1472.  
  1473. PushStatItem(GFxData, "panel_common_statistics_tooltip_silver_fast_dps", StatToStr(curStats.silverFastDPS));
  1474. PushStatItem(GFxData, "panel_common_statistics_tooltip_silver_fast_crit_chance", StatToStr(curStats.silverFastCritChance) + "%");
  1475. PushStatItem(GFxData, "panel_common_statistics_tooltip_silver_fast_crit_dmg", StatToStr(curStats.silverFastCritDmg) + "%");
  1476.  
  1477. PushStatItem(GFxData, "panel_common_statistics_tooltip_silver_strong_dps", StatToStr(curStats.silverStrongDPS));
  1478. PushStatItem(GFxData, "panel_common_statistics_tooltip_silver_strong_crit_chance", StatToStr(curStats.silverStrongCritChance) + "%");
  1479. PushStatItem(GFxData, "panel_common_statistics_tooltip_silver_strong_crit_dmg", StatToStr(curStats.silverStrongCritDmg) + "%");
  1480.  
  1481. PushStatItem(GFxData, "panel_common_statistics_tooltip_crossbow_dps", StatToStr(curStats.crossbowCritChance) + "%");
  1482. PushStatItem(GFxData, "panel_common_statistics_tooltip_crossbow_crit_chance", StatToStr(curStats.crossbowSteelDmg));
  1483. }
  1484.  
  1485. private function GetDefenseTooltipData(out GFxData: CScriptedFlashArray):void
  1486. {
  1487. PushStatItem(GFxData, "panel_common_statistics_tooltip_armor", "");
  1488. PushStatItem(GFxData, "slashing_resistance", GetStatValue('slashing_resistance_perc') + "%");
  1489. PushStatItem(GFxData, "piercing_resistance", GetStatValue('piercing_resistance_perc') + "%");
  1490. PushStatItem(GFxData, "bludgeoning_resistance", GetStatValue('bludgeoning_resistance_perc') + "%");
  1491. PushStatItem(GFxData, "rending_resistance", GetStatValue('rending_resistance_perc') + "%");
  1492. PushStatItem(GFxData, "elemental_resistance", GetStatValue('elemental_resistance_perc') + "%");
  1493. PushStatItem(GFxData, "poison_resistance", GetStatValue('poison_resistance_perc') + "%");
  1494. PushStatItem(GFxData, "fire_resistance", GetStatValue('fire_resistance_perc') + "%");
  1495. PushStatItem(GFxData, "bleeding_resistance", GetStatValue('bleeding_resistance_perc') + "%");
  1496. PushStatItem(GFxData, "knockdown_resistance", GetStatValue('knockdown_resistance_perc') + "%");
  1497. }
  1498.  
  1499. private function GetSignsTooltipData(out GFxData: CScriptedFlashArray):void
  1500. {
  1501. var sp : SAbilityAttributeValue;
  1502. var witcher : W3PlayerWitcher;
  1503.  
  1504. witcher = GetWitcherPlayer();
  1505.  
  1506. sp = witcher.GetTotalSignSpellPower(S_Magic_1);
  1507. PushStatItem(GFxData, 'aard_intensity', (string)RoundMath(sp.valueMultiplicative*100) + "%");
  1508.  
  1509. sp = witcher.GetTotalSignSpellPower(S_Magic_2);
  1510. PushStatItem(GFxData, 'igni_intensity', (string)RoundMath(sp.valueMultiplicative*100) + "%");
  1511.  
  1512. sp = witcher.GetTotalSignSpellPower(S_Magic_3);
  1513. PushStatItem(GFxData, 'yrden_intensity', (string)RoundMath(sp.valueMultiplicative*100) + "%");
  1514.  
  1515. sp = witcher.GetTotalSignSpellPower(S_Magic_4);
  1516. PushStatItem(GFxData, 'quen_intensity', (string)RoundMath(sp.valueMultiplicative*100) + "%");
  1517.  
  1518. sp = witcher.GetTotalSignSpellPower(S_Magic_5);
  1519. PushStatItem(GFxData, 'axii_intensity', (string)RoundMath(sp.valueMultiplicative*100) + "%");
  1520. }
  1521.  
  1522. private function PushStatItem(out statsList: CScriptedFlashArray, label:string, value:string):void
  1523. {
  1524. var statItemData : CScriptedFlashObject;
  1525. statItemData = m_flashValueStorage.CreateTempFlashObject();
  1526. statItemData.SetMemberFlashString("name", GetLocStringByKeyExt(label));
  1527. statItemData.SetMemberFlashString("value", value);
  1528. statsList.PushBackFlashObject(statItemData);
  1529. }
  1530.  
  1531. private function StatToStr(value:float):string
  1532. {
  1533. return (string)NoTrailZeros(RoundTo(value, 1));
  1534. }
  1535.  
  1536. public function UpdatePlayerStatisticsData()
  1537. {
  1538. UpdateVitality();
  1539. UpdateToxicity();
  1540. }
  1541.  
  1542. private function updateSentStatValue(statName:name, statValue:string):void
  1543. {
  1544. var sentStat : SentStatsData;
  1545. var i : int;
  1546.  
  1547. for (i = 0; i < _sentStats.Size(); i += 1)
  1548. {
  1549. if (_sentStats[i].statName == statName)
  1550. {
  1551. _sentStats[i].statValue = statValue;
  1552. return;
  1553. }
  1554. }
  1555.  
  1556. sentStat.statName = statName;
  1557. sentStat.statValue = statValue;
  1558. _sentStats.PushBack(sentStat);
  1559. }
  1560.  
  1561. private function getLastSentStatValue(statName:name) : string
  1562. {
  1563. var i : int;
  1564.  
  1565. for (i = 0; i < _sentStats.Size(); i += 1)
  1566. {
  1567. if (_sentStats[i].statName == statName)
  1568. {
  1569. return _sentStats[i].statValue;
  1570. }
  1571. }
  1572.  
  1573. return "";
  1574. }
  1575.  
  1576. private function GetSignStat(targetSkill:ESkill):string
  1577. {
  1578. var powerStatValue : SAbilityAttributeValue;
  1579. var damageTypeName : name;
  1580. var points : float;
  1581.  
  1582. GetWitcherPlayer().GetSignStats(targetSkill, damageTypeName, points, powerStatValue);
  1583. return NoTrailZeros(RoundMath(powerStatValue.valueMultiplicative * 100)) + " %";
  1584. }
  1585.  
  1586. function GetCurrentEquippedQuickSlot() : EEquipmentSlots
  1587. {
  1588. var currentSelectedQuickItem : SItemUniqueId;
  1589. var itemOnSlot : SItemUniqueId;
  1590. var i : int;
  1591. var slot : EEquipmentSlots;
  1592. slot = EES_InvalidSlot;
  1593.  
  1594. currentSelectedQuickItem = GetWitcherPlayer().GetSelectedItemId();
  1595. for( i = EES_Quickslot1; i < EES_Quickslot2 + 1; i += 1 )
  1596. {
  1597. if(GetWitcherPlayer().GetItemEquippedOnSlot(i,itemOnSlot))
  1598. {
  1599. if( currentSelectedQuickItem == itemOnSlot )
  1600. {
  1601. return i;
  1602. }
  1603. }
  1604. }
  1605. return EES_InvalidSlot;
  1606. }
  1607.  
  1608. event OnTick( timeDelta : float )
  1609. {
  1610. //LogChannel('INVTICK'," timeDelta "+timeDelta);
  1611. }
  1612.  
  1613. event OnGlobalUpdate()
  1614. {
  1615. UpdateData();
  1616. }
  1617.  
  1618. event OnSetInventoryGridFilter( item : SItemUniqueId )
  1619. {
  1620. var filterType : EInventoryFilterType;
  1621. filterType = _playerInv.GetFilterTypeByItem(item);
  1622. _playerInv.SetFilterType( filterType );
  1623. m_fxInventoryUpdateFilter.InvokeSelfOneArg( FlashArgUInt( getTabFromFilter(filterType) ));
  1624. }
  1625.  
  1626. event OnSaveItemGridPosition( item : SItemUniqueId, gridPos : int )
  1627. {
  1628. SetGridPosition(item, gridPos);
  1629. }
  1630.  
  1631. private function SetGridPosition( item : SItemUniqueId, gridPos : int ) : void
  1632. {
  1633. var UIData : SInventoryItemUIData;
  1634. UIData = _inv.GetInventoryItemUIData( item );
  1635. UIData.gridPosition = gridPos;
  1636. _inv.SetInventoryItemUIData( item , UIData );
  1637. }
  1638. private function GetGridPosition( item : SItemUniqueId ) : int
  1639. {
  1640. var UIData : SInventoryItemUIData;
  1641. UIData = _inv.GetInventoryItemUIData( item );
  1642. return UIData.gridPosition;
  1643. }
  1644.  
  1645. event OnTooltipLoaded()
  1646. {
  1647.  
  1648. }
  1649.  
  1650. event OnHighlightPaperDollSlot( slotType : int )
  1651. {
  1652. m_flashValueStorage.SetFlashInt("inventory.grid.paperdoll.highlight",slotType);
  1653. }
  1654.  
  1655. event OnClosingMenu()
  1656. {
  1657. OnRemoveCurrentTooltip(false); // ---=== modE3 ===---
  1658.  
  1659. SaveStateData();
  1660. super.OnClosingMenu();
  1661. theGame.GetGuiManager().SetLastOpenedCommonMenuName( GetMenuName() );
  1662.  
  1663. thePlayer.ForceSoundAppearanceUpdate();
  1664.  
  1665. if(theGame.GetTutorialSystem() && theGame.GetTutorialSystem().IsRunning())
  1666. {
  1667. theGame.GetTutorialSystem().uiHandler.OnClosingMenu('ShopMenu');
  1668. }
  1669. theGame.GetGuiManager().SendCustomUIEvent( 'ClosingShopMenu' );
  1670.  
  1671. if (_playerInv)
  1672. {
  1673. delete _playerInv;
  1674. }
  1675.  
  1676. if (_paperdollInv)
  1677. {
  1678. delete _paperdollInv;
  1679. }
  1680.  
  1681. if (_horseInv)
  1682. {
  1683. delete _horseInv;
  1684. }
  1685.  
  1686. if (_horsePaperdollInv)
  1687. {
  1688. delete _horsePaperdollInv;
  1689. }
  1690.  
  1691. if (_tooltipDataProvider)
  1692. {
  1693. delete _tooltipDataProvider;
  1694. }
  1695.  
  1696. if (_containerInv)
  1697. {
  1698. delete _containerInv;
  1699. }
  1700.  
  1701. if (_shopInv)
  1702. {
  1703. delete _shopInv;
  1704. }
  1705.  
  1706. if (_quantityPopupData)
  1707. {
  1708. delete _quantityPopupData;
  1709. }
  1710.  
  1711. if (_statsContext)
  1712. {
  1713. delete _statsContext;
  1714. }
  1715.  
  1716. if (_paperdollContext)
  1717. {
  1718. delete _paperdollContext;
  1719. }
  1720.  
  1721. if (_invContext)
  1722. {
  1723. delete _invContext;
  1724. }
  1725.  
  1726. if (_externGridContext)
  1727. {
  1728. delete _externGridContext;
  1729. }
  1730.  
  1731. if (_bookPopupData)
  1732. {
  1733. delete _bookPopupData;
  1734. }
  1735.  
  1736. if (_charStatsPopupData)
  1737. {
  1738. _charStatsPopupData.ClosePopupOverlay();
  1739. delete _charStatsPopupData;
  1740. }
  1741.  
  1742. if (_itemInfoPopupData)
  1743. {
  1744. delete _itemInfoPopupData;
  1745. }
  1746.  
  1747. if (_destroyConfPopData)
  1748. {
  1749. delete _destroyConfPopData;
  1750. }
  1751.  
  1752. if (_paintingPopupData)
  1753. {
  1754. delete _paintingPopupData;
  1755. }
  1756.  
  1757. theGame.GetGuiManager().RequestClearScene();
  1758. }
  1759.  
  1760. event OnCloseMenu()
  1761. {
  1762. CloseMenu();
  1763.  
  1764. if( m_parentMenu )
  1765. {
  1766. m_parentMenu.ChildRequestCloseMenu();
  1767. }
  1768.  
  1769. if( _currentEqippedQuickSlot != EES_InvalidSlot )
  1770. {
  1771. GetWitcherPlayer().ClearSelectedItemId();
  1772. GetWitcherPlayer().SelectQuickslotItem(_currentEqippedQuickSlot);
  1773. }
  1774.  
  1775. if( _container )
  1776. {
  1777. _container.OnContainerClosed();
  1778. }
  1779. }
  1780.  
  1781.  
  1782. event OnSetActiveItem()
  1783. {
  1784.  
  1785. //LogChannel('ITEMDRAG'," OnSetActiveItem ");
  1786.  
  1787. }
  1788.  
  1789. event OnSwapItems( playerItem : SItemUniqueId, paperdollItem : SItemUniqueId, paperdollSlot : int )
  1790. {
  1791. OnEquipItem(playerItem, paperdollSlot, 1);
  1792. }
  1793.  
  1794. event OnUseDye( item : SItemUniqueId, optional isPreview : bool )
  1795. {
  1796. var targetList : array<int>;
  1797. var itemOnSlot : SItemUniqueId;
  1798. var wplayer : W3PlayerWitcher;
  1799.  
  1800. wplayer = GetWitcherPlayer();
  1801.  
  1802. m_dyePreviewMode = true;
  1803.  
  1804. if( wplayer.GetItemEquippedOnSlot( EES_Armor, itemOnSlot ) && _inv.CanItemBeColored( itemOnSlot ) )
  1805. {
  1806. targetList.PushBack( EES_Armor );
  1807. }
  1808.  
  1809. if( wplayer.GetItemEquippedOnSlot( EES_Gloves, itemOnSlot ) && _inv.CanItemBeColored( itemOnSlot ) )
  1810. {
  1811. targetList.PushBack( EES_Gloves );
  1812. }
  1813.  
  1814. if( wplayer.GetItemEquippedOnSlot( EES_Pants, itemOnSlot ) && _inv.CanItemBeColored( itemOnSlot ) )
  1815. {
  1816. targetList.PushBack( EES_Pants );
  1817. }
  1818.  
  1819. if( wplayer.GetItemEquippedOnSlot( EES_Boots, itemOnSlot ) && _inv.CanItemBeColored( itemOnSlot ) )
  1820. {
  1821. targetList.PushBack( EES_Boots );
  1822. }
  1823.  
  1824. if( targetList.Size() > 0 )
  1825. {
  1826. ShowSelectionMode( item, targetList );
  1827. }
  1828. else
  1829. {
  1830. showNotification( GetLocStringByKeyExt( "inventory_cant_apply_dye" ) );
  1831. OnPlaySoundEvent( "gui_global_denied" );
  1832. }
  1833. }
  1834.  
  1835. event OnPutInSocket( item : SItemUniqueId )
  1836. {
  1837. var targetList : array<int>;
  1838. var itemOnSlot : SItemUniqueId;
  1839. var uiStateRunes : W3TutorialManagerUIHandlerStateRunes;
  1840. var uiStateArmorUpgrades : W3TutorialManagerUIHandlerStateArmorUpgrades;
  1841.  
  1842. if (thePlayer.IsInCombat())
  1843. {
  1844. showNotification(GetLocStringByKeyExt("menu_cannot_perform_action_combat"));
  1845. OnPlaySoundEvent("gui_global_denied");
  1846. }
  1847. else
  1848. {
  1849. if(ShouldProcessTutorial('TutorialRunesSelectSword') && thePlayer.inv.ItemHasTag(item, 'WeaponUpgrade'))
  1850. {
  1851. uiStateRunes = (W3TutorialManagerUIHandlerStateRunes)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  1852. if(uiStateRunes)
  1853. {
  1854. uiStateRunes.OnSelectingSword();
  1855. }
  1856. }
  1857. else if(ShouldProcessTutorial('TutorialArmorSocketsSelectTab') && thePlayer.inv.ItemHasTag(item, 'ArmorUpgrade'))
  1858. {
  1859. uiStateArmorUpgrades = (W3TutorialManagerUIHandlerStateArmorUpgrades)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  1860. if(uiStateArmorUpgrades)
  1861. {
  1862. uiStateArmorUpgrades.OnSelectingArmor();
  1863. }
  1864. }
  1865.  
  1866. if (GetWitcherPlayer().GetItemEquippedOnSlot(EES_SilverSword, itemOnSlot) && _playerInv.CanBeUpgradedBy(itemOnSlot, item))
  1867. {
  1868. targetList.PushBack(EES_SilverSword);
  1869. }
  1870.  
  1871. if (GetWitcherPlayer().GetItemEquippedOnSlot(EES_SteelSword, itemOnSlot) && _playerInv.CanBeUpgradedBy(itemOnSlot, item))
  1872. {
  1873. targetList.PushBack(EES_SteelSword);
  1874. }
  1875.  
  1876. if (GetWitcherPlayer().GetItemEquippedOnSlot(EES_Armor, itemOnSlot) && _playerInv.CanBeUpgradedBy(itemOnSlot, item))
  1877. {
  1878. targetList.PushBack(EES_Armor);
  1879. }
  1880.  
  1881. if (GetWitcherPlayer().GetItemEquippedOnSlot(EES_Boots, itemOnSlot) && _playerInv.CanBeUpgradedBy(itemOnSlot, item))
  1882. {
  1883. targetList.PushBack(EES_Boots);
  1884. }
  1885.  
  1886. if (GetWitcherPlayer().GetItemEquippedOnSlot(EES_Pants, itemOnSlot) && _playerInv.CanBeUpgradedBy(itemOnSlot, item))
  1887. {
  1888. targetList.PushBack(EES_Pants);
  1889. }
  1890.  
  1891. if (GetWitcherPlayer().GetItemEquippedOnSlot(EES_Gloves, itemOnSlot) && _playerInv.CanBeUpgradedBy(itemOnSlot, item))
  1892. {
  1893. targetList.PushBack(EES_Gloves);
  1894. }
  1895.  
  1896. if (GetWitcherPlayer().GetItemEquippedOnSlot(EES_RangedWeapon, itemOnSlot) && _playerInv.CanBeUpgradedBy(itemOnSlot, item))
  1897. {
  1898. targetList.PushBack(EES_RangedWeapon);
  1899. }
  1900.  
  1901.  
  1902. if (targetList.Size() > 0)
  1903. {
  1904. ShowSelectionMode(item, targetList);
  1905. }
  1906. else
  1907. {
  1908. showNotification(GetLocStringByKeyExt("panel_inventory_notification_no_upgradable_items"));
  1909. OnPlaySoundEvent("gui_global_denied");
  1910. }
  1911.  
  1912.  
  1913. }
  1914. }
  1915.  
  1916. public function ShowApplyOilMode( item : SItemUniqueId )
  1917. {
  1918. var targetList : array<int>;
  1919. var itemOnSlot : SItemUniqueId;
  1920.  
  1921.  
  1922.  
  1923. if (_inv.ItemHasTag(item, 'SteelOil') && GetWitcherPlayer().GetItemEquippedOnSlot(EES_SteelSword, itemOnSlot) && thePlayer.inv.IsItemSteelSwordUsableByPlayer(itemOnSlot))
  1924. {
  1925. targetList.PushBack(EES_SteelSword);
  1926. }
  1927.  
  1928. if (_inv.ItemHasTag(item, 'SilverOil') && GetWitcherPlayer().GetItemEquippedOnSlot(EES_SilverSword, itemOnSlot) && thePlayer.inv.IsItemSilverSwordUsableByPlayer(itemOnSlot))
  1929. {
  1930. targetList.PushBack(EES_SilverSword);
  1931. }
  1932.  
  1933. if (targetList.Size() > 0)
  1934. {
  1935. ShowSelectionMode(item, targetList);
  1936. }
  1937. else
  1938. {
  1939.  
  1940.  
  1941. }
  1942. }
  1943.  
  1944. event OnRepairItem( item : SItemUniqueId )
  1945. {
  1946. var targetList : array<int>;
  1947. var itemOnSlot : SItemUniqueId;
  1948.  
  1949.  
  1950.  
  1951. if (_inv.ItemHasTag(item, 'WeaponReapairKit') )
  1952. {
  1953. if ( GetWitcherPlayer().GetItemEquippedOnSlot(EES_SteelSword, itemOnSlot) )
  1954. {
  1955. if ( GetWitcherPlayer().IsItemRepairAble ( itemOnSlot ) )
  1956. {
  1957. targetList.PushBack(EES_SteelSword);
  1958. }
  1959. }
  1960. if ( GetWitcherPlayer().GetItemEquippedOnSlot(EES_SilverSword, itemOnSlot) )
  1961. {
  1962. if ( GetWitcherPlayer().IsItemRepairAble ( itemOnSlot ) )
  1963. {
  1964. targetList.PushBack(EES_SilverSword);
  1965. }
  1966. }
  1967. }
  1968.  
  1969. if (_inv.ItemHasTag(item, 'ArmorReapairKit') )
  1970. {
  1971. if ( GetWitcherPlayer().GetItemEquippedOnSlot(EES_Armor, itemOnSlot) )
  1972. {
  1973. if ( GetWitcherPlayer().IsItemRepairAble ( itemOnSlot ) )
  1974. {
  1975. targetList.PushBack(EES_Armor);
  1976. }
  1977. }
  1978. if ( GetWitcherPlayer().GetItemEquippedOnSlot(EES_Boots, itemOnSlot) )
  1979. {
  1980. if ( GetWitcherPlayer().IsItemRepairAble ( itemOnSlot ) )
  1981. {
  1982. targetList.PushBack(EES_Boots);
  1983. }
  1984. }
  1985. if ( GetWitcherPlayer().GetItemEquippedOnSlot(EES_Pants, itemOnSlot) )
  1986. {
  1987. if ( GetWitcherPlayer().IsItemRepairAble ( itemOnSlot ) )
  1988. {
  1989. targetList.PushBack(EES_Pants);
  1990. }
  1991. }
  1992. if ( GetWitcherPlayer().GetItemEquippedOnSlot(EES_Gloves, itemOnSlot) )
  1993. {
  1994. if ( GetWitcherPlayer().IsItemRepairAble ( itemOnSlot ) )
  1995. {
  1996. targetList.PushBack(EES_Gloves);
  1997. }
  1998. }
  1999. }
  2000.  
  2001. if (targetList.Size() > 0)
  2002. {
  2003. ShowSelectionMode(item, targetList);
  2004. }
  2005. else
  2006. {
  2007.  
  2008. showNotification(GetLocStringByKeyExt("panel_inventory_nothing_to_repair"));
  2009. OnPlaySoundEvent("gui_global_denied");
  2010. }
  2011. }
  2012.  
  2013. public function TryEquipToPockets(item : SItemUniqueId, slot : int ) : bool
  2014. {
  2015. var targetList : array<int>;
  2016.  
  2017. if( slot == EES_Quickslot1 || slot == EES_Quickslot2 )
  2018. {
  2019. targetList.PushBack(EES_Quickslot1);
  2020. targetList.PushBack(EES_Quickslot2);
  2021. }
  2022. else if( slot == EES_Petard1 || slot == EES_Petard2 )
  2023. {
  2024. targetList.PushBack(EES_Petard1);
  2025. targetList.PushBack(EES_Petard2);
  2026. }
  2027. else if( IsSlotPotionSlot(slot) )
  2028. {
  2029. targetList.PushBack(EES_Potion1);
  2030. targetList.PushBack(EES_Potion2);
  2031. targetList.PushBack(EES_Potion3);
  2032. targetList.PushBack(EES_Potion4);
  2033. }
  2034.  
  2035. if (targetList.Size() > 0)
  2036. {
  2037. if (theInput.LastUsedPCInput())
  2038. {
  2039. EquipToFirstEmptySocket (item, targetList);
  2040. }
  2041. else
  2042. {
  2043. ShowSelectionMode(item, targetList);
  2044. }
  2045. return true;
  2046. }
  2047.  
  2048. return false;
  2049. }
  2050.  
  2051. private function EquipToFirstEmptySocket(itemId : SItemUniqueId, targetSlotList : array< int >):void
  2052. {
  2053. var i, len : int;
  2054. var currentSlot : int;
  2055. var equippedItem : SItemUniqueId;
  2056.  
  2057. len = targetSlotList.Size();
  2058. if (len > 0)
  2059. {
  2060. for (i = 0; i < len; i += 1)
  2061. {
  2062. currentSlot = targetSlotList[i];
  2063. GetWitcherPlayer().GetItemEquippedOnSlot(currentSlot, equippedItem);
  2064. if (!_inv.IsIdValid(equippedItem))
  2065. {
  2066. OnEquipItem(itemId, currentSlot, 1);
  2067. return;
  2068. }
  2069. }
  2070.  
  2071.  
  2072. OnEquipItem(itemId, targetSlotList[len - 1], 1);
  2073. }
  2074. }
  2075.  
  2076. event OnDropOnPaperdoll(item : SItemUniqueId, slot : int, quantity : int)
  2077. {
  2078. OnEquipItem(item, slot, quantity);
  2079. }
  2080.  
  2081. event OnApplyOil(item : SItemUniqueId, slot : int)
  2082. {
  2083. ApplyOil(item, slot);
  2084. }
  2085.  
  2086. event OnApplyUpgrade(item : SItemUniqueId, slot : int)
  2087. {
  2088. ApplyUpgrade(item, slot);
  2089. }
  2090.  
  2091. event OnApplyRepairKit(item : SItemUniqueId, slot : int)
  2092. {
  2093. ApplyRepairKit(item, slot);
  2094. }
  2095.  
  2096. event OnApplyDye( item : SItemUniqueId, slot : int )
  2097. {
  2098. ApplyDye( item, slot );
  2099. }
  2100.  
  2101. event OnEquipItem( item : SItemUniqueId, slot : int, quantity : int )
  2102. {
  2103. var paperdollItemsToUpdate : array< SItemUniqueId >;
  2104. var gridItemsToUpdate : array< SItemUniqueId >;
  2105. var itemAlreadyEuipped : bool;
  2106. var keepSelection : bool;
  2107.  
  2108. var OnSlot : bool;
  2109. var itemOnSlot : SItemUniqueId;
  2110. var boltsItem : SItemUniqueId;
  2111. var hItem : SItemUniqueId;
  2112. var uiData : SInventoryItemUIData;
  2113. var abls : array< name >;
  2114. var i : int;
  2115. var filterType : EInventoryFilterType;
  2116.  
  2117. OnSlot = false;
  2118. itemAlreadyEuipped = false;
  2119.  
  2120. if( _currentInv == _containerInv )
  2121. {
  2122. if( _shopNpc )
  2123. {
  2124. BuyItem(item, quantity);
  2125. UpdateShop();
  2126. UpdatePlayerStatisticsData();
  2127. }
  2128. else
  2129. {
  2130. TakeItem(item, quantity);
  2131. UpdateContainer();
  2132. UpdatePlayerStatisticsData();
  2133. }
  2134. }
  2135. else
  2136. {
  2137. if( _shopNpc )
  2138. {
  2139. SellItem(item,quantity);
  2140. UpdateShop();
  2141. UpdatePlayerStatisticsData();
  2142. }
  2143. else if( _containerInv )
  2144. {
  2145. GiveItem(item, quantity);
  2146. UpdateContainer();
  2147. UpdatePlayerStatisticsData();
  2148. }
  2149. else
  2150. {
  2151. if ( !thePlayer.HasRequiredLevelToEquipItem(item) )
  2152. {
  2153. showNotification(GetLocStringByKeyExt("panel_inventory_cannot_equip_low_level"));
  2154. OnPlaySoundEvent("gui_global_denied");
  2155. return false;
  2156. }
  2157.  
  2158. //LogChannel('INVENTORY'," item; slot "+slot );
  2159.  
  2160. GetWitcherPlayer().GetItemEquippedOnSlot( slot, itemOnSlot );
  2161. if ( IsItemInPreview( item ) )
  2162. {
  2163. m_fxSetPaperdollPreviewIcon.InvokeSelfTwoArgs( FlashArgInt( slot ), FlashArgBool( false ) );
  2164. }
  2165. ResetDisplayPreviewCache( item, slot, gridItemsToUpdate );
  2166.  
  2167. if( slot == EES_Bolt )
  2168. {
  2169. if (!GetWitcherPlayer().IsAnyItemEquippedOnSlot(EES_RangedWeapon))
  2170. {
  2171. showNotification(GetLocStringByKeyExt("panel_inventory_cannot_equip_bolts"));
  2172. OnPlaySoundEvent("gui_global_denied");
  2173. return false;
  2174. }
  2175. else if (_inv.ItemHasTag(itemOnSlot,theGame.params.TAG_INFINITE_AMMO))
  2176. {
  2177.  
  2178. if(_inv.GetItemName(itemOnSlot) == 'Harpoon Bolt')
  2179. {
  2180. showNotification(GetLocStringByKeyExt("menu_cannot_perform_action_now"));
  2181. OnPlaySoundEvent("gui_global_denied");
  2182. return false;
  2183. }
  2184.  
  2185. OnSlot = true;
  2186. }
  2187. }
  2188.  
  2189. if ( slot == EES_HorseBlinders || slot == EES_HorseSaddle || slot == EES_HorseBag || slot == EES_HorseTrophy )
  2190. {
  2191. if (!GetWitcherPlayer().GetHorseManager())
  2192. {
  2193. return true;
  2194. }
  2195.  
  2196.  
  2197.  
  2198.  
  2199. hItem = GetWitcherPlayer().GetHorseManager().MoveItemToHorse(item, 1);
  2200. itemOnSlot = GetWitcherPlayer().GetHorseManager().EquipItem(hItem);
  2201.  
  2202. if (_inv.IsIdValid(itemOnSlot))
  2203. {
  2204. InventoryRemoveItem(item, true);
  2205. InventoryUpdateItem(itemOnSlot);
  2206.  
  2207. itemAlreadyEuipped = true;
  2208. }
  2209. else
  2210. {
  2211. InventoryRemoveItem(item, false);
  2212. }
  2213.  
  2214.  
  2215.  
  2216.  
  2217. PaperdollUpdateHorseItem(hItem);
  2218.  
  2219. UpdateEncumbranceInfo();
  2220.  
  2221. PlayItemEquipSound( _horsePaperdollInv.GetInventoryComponent().GetItemCategory(item) );
  2222.  
  2223. return true;
  2224. }
  2225. else
  2226. {
  2227. PlayItemEquipSound( _inv.GetItemCategory(item) );
  2228.  
  2229. itemAlreadyEuipped = GetWitcherPlayer().IsItemEquipped(item);
  2230. _playerInv.EquipItem( item, slot );
  2231. }
  2232.  
  2233. UpdatePlayerStatisticsData();
  2234.  
  2235. PlayPaperdollAnimation(_inv.GetItemCategory( item ));
  2236.  
  2237. }
  2238. }
  2239.  
  2240. if (!OnSlot && _inv.IsIdValid(itemOnSlot) && !_inv.ItemHasTag(itemOnSlot, 'NoShow'))
  2241. {
  2242. SetGridPosition(itemOnSlot, GetGridPosition(item));
  2243.  
  2244. keepSelection = !_inv.ItemHasTag(itemOnSlot, 'NoShow');
  2245. InventoryRemoveItem(item, keepSelection );
  2246.  
  2247. if (!itemAlreadyEuipped)
  2248. {
  2249. gridItemsToUpdate.PushBack(itemOnSlot);
  2250.  
  2251. filterType = _playerInv.GetFilterTypeByItem(itemOnSlot);
  2252. _playerInv.SetFilterType( filterType );
  2253. UpdateInventoryFilter( filterType );
  2254. }
  2255. else
  2256. {
  2257. paperdollItemsToUpdate.PushBack(itemOnSlot);
  2258. }
  2259.  
  2260.  
  2261.  
  2262. }
  2263. else
  2264. {
  2265. InventoryRemoveItem(item);
  2266. }
  2267.  
  2268.  
  2269. UpdateEncumbranceInfo();
  2270. if (slot == EES_RangedWeapon)
  2271. {
  2272. PaperdollUpdateAll();
  2273. }
  2274. else
  2275. {
  2276. paperdollItemsToUpdate.PushBack(item);
  2277.  
  2278. if (_inv.GetEnchantment(item) == 'Runeword 6')
  2279. {
  2280. AddEquippedPotionsToList(paperdollItemsToUpdate);
  2281. }
  2282.  
  2283. if (_inv.IsItemSetItem(item))
  2284. {
  2285. PushIfItemEquipped(paperdollItemsToUpdate, EES_Petard1);
  2286. PushIfItemEquipped(paperdollItemsToUpdate, EES_Petard2);
  2287. PushIfItemEquipped(paperdollItemsToUpdate, EES_Quickslot1);
  2288. PushIfItemEquipped(paperdollItemsToUpdate, EES_Quickslot2);
  2289. PushIfItemEquipped(paperdollItemsToUpdate, EES_Potion1);
  2290. PushIfItemEquipped(paperdollItemsToUpdate, EES_Potion2);
  2291. PushIfItemEquipped(paperdollItemsToUpdate, EES_Potion3);
  2292. PushIfItemEquipped(paperdollItemsToUpdate, EES_Potion4);
  2293.  
  2294. PopulateTabData(InventoryMenuTab_Potions);
  2295. }
  2296.  
  2297. PaperdollUpdateItemsList(paperdollItemsToUpdate);
  2298. }
  2299.  
  2300. if( gridItemsToUpdate.Size() > 0 )
  2301. {
  2302. InventoryUpdateItems( gridItemsToUpdate );
  2303. }
  2304.  
  2305. OnSaveItemGridPosition(item, -1);
  2306. UpdateGuiSceneEntityItems();
  2307.  
  2308. OnRequestStatsData();// ---=== modE3 ===---
  2309. }
  2310.  
  2311. private function PlayPaperdollAnimation( category : name ):void
  2312. {
  2313. if (m_player)
  2314. {
  2315. ((CActor)m_player).SetBehaviorMimicVariable( 'gameplayMimicsMode', (float)(int)PGMM_Inventory );
  2316.  
  2317. switch (category)
  2318. {
  2319. case 'armor':
  2320. m_player.RaiseEvent('ShowArmor_Inv');
  2321. break;
  2322. case 'gloves':
  2323. m_player.RaiseEvent('ShowGlove_Inv');
  2324. break;
  2325. case 'pants':
  2326. m_player.RaiseEvent('ShowPants_Inv');
  2327. break;
  2328. case 'boots':
  2329. m_player.RaiseEvent('ShowBoots_Inv');
  2330. break;
  2331. case 'steelsword':
  2332. m_player.RaiseEvent('DrawSteelSword_Inv');
  2333. break;
  2334. case 'silversword':
  2335. m_player.RaiseEvent('DrawSilverSword_Inv');
  2336. break;
  2337. case 'crossbow':
  2338. m_player.RaiseEvent('DrawCrossbow_Inv');
  2339. break;
  2340. default:
  2341. break;
  2342. }
  2343. }
  2344. }
  2345.  
  2346. function FindEmptySlot( first : EEquipmentSlots, last : EEquipmentSlots, out outSlot : int ) : bool
  2347. {
  2348. var i : int;
  2349. var itemOnSlot : SItemUniqueId;
  2350.  
  2351. for(i = first; i < last + 1; i += 1 )
  2352. {
  2353. GetWitcherPlayer().GetItemEquippedOnSlot(i, itemOnSlot);
  2354.  
  2355. if( !_inv.IsIdValid(itemOnSlot) )
  2356. {
  2357. outSlot = i;
  2358. return true;
  2359. }
  2360. }
  2361. return false;
  2362. }
  2363.  
  2364. function FindMaskSlot( first : EEquipmentSlots, last : EEquipmentSlots, out outSlot : int ) : bool
  2365. {
  2366. var i : int;
  2367. var itemOnSlot : SItemUniqueId;
  2368.  
  2369. for(i = first; i < last + 1; i += 1 )
  2370. {
  2371. GetWitcherPlayer().GetItemEquippedOnSlot(i, itemOnSlot);
  2372.  
  2373. if ( _inv.IsItemMask( itemOnSlot ) )
  2374. {
  2375. outSlot = i;
  2376. return true;
  2377. }
  2378. }
  2379. return false;
  2380. }
  2381.  
  2382. event OnUnequipItem( item : SItemUniqueId, moveToIndex : int )
  2383. {
  2384. if (thePlayer.IsInCombat())
  2385. {
  2386. showNotification(GetLocStringByKeyExt("menu_cannot_perform_action_combat"));
  2387. OnPlaySoundEvent("gui_global_denied");
  2388. return false;
  2389. }
  2390.  
  2391. return UnequipItem(item, moveToIndex);
  2392. }
  2393.  
  2394. public function UnequipItem( item : SItemUniqueId, moveToIndex : int ) : bool
  2395. {
  2396. var forceInvAllUpdate : bool;
  2397. var isSetBonusActive : bool;
  2398.  
  2399. var filterType : EInventoryFilterType;
  2400. var itemOnSlot : SItemUniqueId;
  2401. var crossbowOnSlot : SItemUniqueId;
  2402. var horseItem : SItemUniqueId;
  2403. var slot : EEquipmentSlots;
  2404. var itemsList : array<SItemUniqueId>;
  2405. var gridUpdateList : array<SItemUniqueId>;
  2406. var abls : array<name>;
  2407. var i, targetSlot : int;
  2408.  
  2409. forceInvAllUpdate = false;
  2410.  
  2411. if (thePlayer.IsInCombat())
  2412. {
  2413. showNotification(GetLocStringByKeyExt("menu_cannot_perform_action_combat"));
  2414. OnPlaySoundEvent("gui_global_denied");
  2415. return false;
  2416. }
  2417.  
  2418. if ( _horsePaperdollInv.GetInventoryComponent().IsIdValid(item) && _horsePaperdollInv.isHorseItem(item))
  2419. {
  2420. slot = _horsePaperdollInv.GetInventoryComponent().GetSlotForItemId(item);
  2421. horseItem = GetWitcherPlayer().GetHorseManager().UnequipItem(slot);
  2422.  
  2423. PlayItemUnequipSound( _inv.GetItemCategory(horseItem) );
  2424.  
  2425. m_fxInventoryUpdateFilter.InvokeSelfOneArg( FlashArgUInt( GetTabIndexForSlot(slot) ));
  2426.  
  2427. InventoryUpdateItem(horseItem);
  2428.  
  2429. PaperdollUpdateAll();
  2430.  
  2431. UpdateEncumbranceInfo();
  2432.  
  2433.  
  2434.  
  2435.  
  2436. PlayItemUnequipSound( _horsePaperdollInv.GetInventoryComponent().GetItemCategory(item) );
  2437.  
  2438. return true;
  2439. }
  2440.  
  2441. if( _containerInv )
  2442. {
  2443. GiveItem(item, 1);
  2444. UpdateContainer();
  2445.  
  2446. InventoryUpdateItem(item);
  2447. PaperdollRemoveItem(item);
  2448. UpdatePlayerStatisticsData();
  2449. }
  2450. else if (_inv.IsIdValid(item))
  2451. {
  2452. if (_inv.IsItemBolt(item) && _inv.ItemHasTag(item,theGame.params.TAG_INFINITE_AMMO))
  2453. {
  2454. return false;
  2455. }
  2456.  
  2457. //LogChannel('ITEMDRAG'," OnUnequipItem "+_playerInv.GetItemName(item)+" moveToIndex "+moveToIndex);
  2458. if( moveToIndex > -1 )
  2459. {
  2460. _playerInv.MoveItem( item , moveToIndex );
  2461. }
  2462.  
  2463. PlayItemUnequipSound( _inv.GetItemCategory(item) );
  2464.  
  2465. if (_inv.IsItemCrossbow(item) && GetWitcherPlayer().GetItemEquippedOnSlot(EES_Bolt,itemOnSlot))
  2466. {
  2467. _playerInv.UnequipItem( itemOnSlot );
  2468. PaperdollRemoveItem(itemOnSlot);
  2469.  
  2470. if (!_inv.ItemHasTag(itemOnSlot,theGame.params.TAG_INFINITE_AMMO))
  2471. {
  2472. forceInvAllUpdate = true;
  2473. }
  2474. }
  2475.  
  2476. isSetBonusActive = GetWitcherPlayer().IsSetBonusActive( EISB_RedWolf_2 );
  2477.  
  2478. targetSlot = _inv.GetSlotForItemId( item );
  2479. ResetDisplayPreviewCache( item, slot, gridUpdateList );
  2480.  
  2481. _playerInv.UnequipItem( item );
  2482. filterType = _playerInv.GetFilterTypeByItem(item);
  2483. _playerInv.SetFilterType( filterType );
  2484. UpdateInventoryFilter(filterType);
  2485.  
  2486. if (_inv.IsItemSetItem(item) && isSetBonusActive)
  2487. {
  2488. PushIfItemEquipped(itemsList, EES_Petard1);
  2489. PushIfItemEquipped(itemsList, EES_Petard2);
  2490. PushIfItemEquipped(itemsList, EES_Quickslot1);
  2491. PushIfItemEquipped(itemsList, EES_Quickslot2);
  2492. PushIfItemEquipped(itemsList, EES_Potion1);
  2493. PushIfItemEquipped(itemsList, EES_Potion2);
  2494. PushIfItemEquipped(itemsList, EES_Potion3);
  2495. PushIfItemEquipped(itemsList, EES_Potion4);
  2496.  
  2497. PopulateTabData(InventoryMenuTab_Potions);
  2498. }
  2499.  
  2500. if (forceInvAllUpdate)
  2501. {
  2502. PopulateTabData(getTabFromItem(item));
  2503. }
  2504. else
  2505. {
  2506. gridUpdateList.PushBack( item );
  2507. }
  2508.  
  2509. if (_inv.GetEnchantment(item) == 'Runeword 6')
  2510. {
  2511. AddEquippedPotionsToList(itemsList);
  2512. }
  2513.  
  2514. PaperdollRemoveItem(item);
  2515.  
  2516. if(_inv.IsItemBolt(item) && GetWitcherPlayer().GetItemEquippedOnSlot(EES_Bolt, itemOnSlot))
  2517. {
  2518. itemsList.PushBack(itemOnSlot);
  2519. }
  2520.  
  2521. PaperdollUpdateItemsList(itemsList);
  2522.  
  2523. UpdatePlayerStatisticsData();
  2524. }
  2525.  
  2526. if( gridUpdateList.Size() > 0 )
  2527. {
  2528. InventoryUpdateItems( gridUpdateList );
  2529. }
  2530.  
  2531. UpdateEncumbranceInfo();
  2532. UpdateGuiSceneEntityItems();
  2533.  
  2534.  
  2535. switch (_inv.GetItemCategory( item ))
  2536. {
  2537. case 'steelsword':
  2538. m_player.RaiseEvent('RemoveSteelSword_Inv');
  2539. break;
  2540. case 'silversword':
  2541. m_player.RaiseEvent('RemoveSilverSword_Inv');
  2542. break;
  2543. case 'crossbow':
  2544. m_player.RaiseEvent('RemoveCrossbow_Inv');
  2545. break;
  2546. default:
  2547. break;
  2548. }
  2549.  
  2550. OnRequestStatsData();// ---=== modE3 ===---
  2551.  
  2552. return true;
  2553. }
  2554.  
  2555. private function PushIfItemEquipped(out itemsList : array<SItemUniqueId>, slotId:EEquipmentSlots):void
  2556. {
  2557. var itemOnSlot : SItemUniqueId;
  2558.  
  2559. if(GetWitcherPlayer().GetItemEquippedOnSlot(slotId, itemOnSlot) && _inv.IsIdValid(itemOnSlot))
  2560. {
  2561. itemsList.PushBack(itemOnSlot);
  2562. }
  2563. }
  2564.  
  2565. public function UpdateInventoryFilter( filterType : EInventoryFilterType ):void
  2566. {
  2567. m_fxInventoryUpdateFilter.InvokeSelfOneArg( FlashArgUInt( getTabFromFilter(filterType) ));
  2568. }
  2569.  
  2570. event OnDragItemStarted( itemId : SItemUniqueId )
  2571. {
  2572. var filterType : EInventoryFilterType;
  2573. var slot : EEquipmentSlots;
  2574.  
  2575. if ( _horsePaperdollInv.GetInventoryComponent().IsIdValid(itemId) && _horsePaperdollInv.isHorseItem(itemId))
  2576. {
  2577. slot = _horsePaperdollInv.GetInventoryComponent().GetSlotForItemId(itemId);
  2578. m_fxInventoryUpdateFilter.InvokeSelfOneArg( FlashArgUInt( GetTabIndexForSlot(slot) ));
  2579. }
  2580. else
  2581. {
  2582. filterType = _playerInv.GetFilterTypeByItem(itemId);
  2583. UpdateInventoryFilter(filterType);
  2584. }
  2585. }
  2586.  
  2587. event OnEmptySlotActivate( equipID : int )
  2588. {
  2589. var targetTabIndex : InventoryMenuTabIndexes;
  2590.  
  2591. targetTabIndex = GetTabIndexForSlot(equipID);
  2592.  
  2593. m_flashValueStorage.SetFlashInt("OnTabSelectRequested", -1);
  2594. m_flashValueStorage.SetFlashInt("OnTabSelectRequested", targetTabIndex);
  2595. }
  2596.  
  2597. protected function GetTabIndexForSlot(equipID : int) : int
  2598. {
  2599. switch (equipID)
  2600. {
  2601. // ---=== modE3 ===---
  2602. case EES_SilverSword:
  2603. case EES_SteelSword:
  2604. case EES_RangedWeapon:
  2605. case EES_Bolt:
  2606. default:
  2607. return InventoryMenuTab_Weapons;
  2608. // ---=== modE3 ===---
  2609. case EES_Petard1:
  2610. case EES_Petard2:
  2611. return InventoryMenuTab_Potions;
  2612. case EES_Quickslot1:
  2613. case EES_Quickslot2:
  2614. if (_currentState == IMS_Stash)
  2615. {
  2616. return StashMenuTab_Default;
  2617. }
  2618. else
  2619. {
  2620. return InventoryMenuTab_Default;
  2621. }
  2622. case EES_Potion1:
  2623. case EES_Potion2:
  2624. case EES_Potion3:
  2625. case EES_Potion4:
  2626. return InventoryMenuTab_Potions;
  2627.  
  2628. // ---=== modE3 ===---
  2629. case EES_HorseTrophy:
  2630. case EES_HorseBlinders:
  2631. case EES_HorseSaddle:
  2632. case EES_HorseBag:
  2633. case EES_Armor:
  2634. case EES_Boots:
  2635. case EES_Pants:
  2636. case EES_Gloves:
  2637. return InventoryMenuTab_Books;
  2638. // ---=== modE3 ===---
  2639. }
  2640.  
  2641. return InventoryMenuTab_Weapons;
  2642. }
  2643.  
  2644. event OnDropItem( item : SItemUniqueId, quantity : int )
  2645. {
  2646. if (( _inv.ItemHasTag(item, 'SilverOil') || _inv.ItemHasTag(item, 'SteelOil') || _inv.ItemHasTag(item, 'Petard') || ( _inv.ItemHasTag(item, 'Potion') && _inv.GetItemCategory(item)!='edibles' ) ) && _playerInv.CanDrop(item))
  2647. {
  2648. if (_destroyConfPopData)
  2649. {
  2650. delete _destroyConfPopData;
  2651. }
  2652.  
  2653. _destroyConfPopData = new W3DestroyItemConfPopup in this;
  2654. _destroyConfPopData.SetMessageTitle(GetLocStringByKeyExt("panel_button_common_drop"));
  2655. _destroyConfPopData.SetMessageText(GetLocStringByKeyExt("panel_inventory_message_destroy_item"));
  2656. _destroyConfPopData.menuRef = this;
  2657. _destroyConfPopData.item = item;
  2658. _destroyConfPopData.quantity = quantity;
  2659. _destroyConfPopData.BlurBackground = true;
  2660.  
  2661. RequestSubMenu('PopupMenu', _destroyConfPopData);
  2662. }
  2663. else
  2664. {
  2665. DropItem(item, quantity);
  2666. }
  2667. }
  2668.  
  2669. event OnReadBook( item : SItemUniqueId )
  2670. {
  2671. var itemCategory : name;
  2672. var tutStateBooks : W3TutorialManagerUIHandlerStateBooks;
  2673. var tutStateRecipeReading : W3TutorialManagerUIHandlerStateRecipeReading;
  2674. var isSthLearned : bool;
  2675. var updateBook : bool;
  2676.  
  2677. updateBook = !thePlayer.inv.IsBookRead(item);
  2678.  
  2679.  
  2680. ReadBook(item);
  2681.  
  2682. itemCategory = thePlayer.inv.GetItemCategory( item );
  2683. isSthLearned = false;
  2684. if ( itemCategory == 'alchemy_recipe' || itemCategory == 'crafting_schematic' )
  2685. {
  2686. if ( !thePlayer.inv.ItemHasTag( item, 'BookReaded') )
  2687. {
  2688. thePlayer.inv.AddItemTag(item,'BookReaded');
  2689.  
  2690. isSthLearned = true;
  2691.  
  2692. UpdateData();
  2693. updateCurrentTab();
  2694. }
  2695. }
  2696. else if (updateBook)
  2697. {
  2698. InventoryUpdateItem(item);
  2699. }
  2700.  
  2701.  
  2702. if(ShouldProcessTutorial('TutorialBooksSelectTab'))
  2703. {
  2704. tutStateBooks = (W3TutorialManagerUIHandlerStateBooks)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  2705. if(tutStateBooks)
  2706. {
  2707. tutStateBooks.OnBookRead();
  2708. }
  2709. else if(isSthLearned)
  2710. {
  2711. tutStateRecipeReading = (W3TutorialManagerUIHandlerStateRecipeReading)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  2712. if(tutStateRecipeReading)
  2713. {
  2714. tutStateRecipeReading.OnBookRead();
  2715. }
  2716. }
  2717. }
  2718. }
  2719.  
  2720. event OnUpgradeItem( item : SItemUniqueId, slot : int, quantity : int )
  2721. {
  2722. var swordItem : SItemUniqueId;
  2723. if (thePlayer.IsInCombat())
  2724. {
  2725. showNotification(GetLocStringByKeyExt("menu_cannot_perform_action_combat"));
  2726. OnPlaySoundEvent("gui_global_denied");
  2727. } else
  2728. {
  2729. if(_inv.ItemHasTag(item,'SilverOil'))
  2730. {
  2731. GetWitcherPlayer().GetItemEquippedOnSlot(EES_SilverSword, swordItem);
  2732. }
  2733. else if(_inv.ItemHasTag(item,'SteelOil'))
  2734. {
  2735. GetWitcherPlayer().GetItemEquippedOnSlot(EES_SteelSword, swordItem);
  2736. }
  2737.  
  2738. if( _inv.IsIdValid(swordItem) )
  2739. {
  2740. _playerInv.UpgradeItem( swordItem, item );
  2741. UpdateData();
  2742. }
  2743. }
  2744. }
  2745.  
  2746. event OnTransferItem( item : SItemUniqueId, quantity : int, moveToIdx : int )
  2747. {
  2748. var filterType : EInventoryFilterType;
  2749. var newItemID : SItemUniqueId;
  2750.  
  2751. if( _currentInv == _containerInv )
  2752. {
  2753. _containerInv.GiveItem( item, _playerInv, quantity, newItemID );
  2754.  
  2755. UpdateContainer();
  2756.  
  2757. filterType = _playerInv.GetFilterTypeByItem( newItemID );
  2758. _playerInv.SetFilterType( filterType );
  2759. m_fxInventoryUpdateFilter.InvokeSelfOneArg( FlashArgUInt( getTabFromFilter( filterType ) ));
  2760. InventoryUpdateItem( newItemID );
  2761. }
  2762. else
  2763. {
  2764. InventoryRemoveItem(item, false);
  2765.  
  2766. _playerInv.GiveItem( item, _containerInv, quantity, newItemID );
  2767. _playerInv.clearGridPosition(item);
  2768.  
  2769. UpdateContainer();
  2770. }
  2771.  
  2772. UpdateEncumbranceInfo();
  2773. }
  2774.  
  2775. event OnSellItem( itemId : SItemUniqueId, quantity : int )
  2776. {
  2777. var invItem : SInventoryItem;
  2778. var itemPrice : int;
  2779. var newShopItem : SItemUniqueId;
  2780.  
  2781. if (!_playerInv.GetInventoryComponent().IsIdValid(itemId))
  2782. {
  2783. return false;
  2784. }
  2785.  
  2786. invItem = _playerInv.GetInventoryComponent().GetItem( itemId );
  2787. itemPrice = _shopInv.GetInventoryComponent().GetInventoryItemPriceModified( invItem, true );
  2788.  
  2789. if ( itemPrice <= 0 || !_playerInv.CanDrop( itemId ))
  2790. {
  2791. showNotification(GetLocStringByKeyExt("panel_shop_not_for_sale"));
  2792. OnPlaySoundEvent("gui_global_denied");
  2793. return false;
  2794. }
  2795.  
  2796. //LogChannel('QP', "OnSellItem, quantity: " + quantity);
  2797. if ( quantity <= 1 )
  2798. {
  2799.  
  2800. newShopItem = SellItem( itemId, quantity );
  2801. if ( GetInvalidUniqueId() != newShopItem )
  2802. {
  2803. InventoryRemoveItem(itemId);
  2804. UpdateItemsCounter();
  2805. UpdatePlayerStatisticsData();
  2806. ShopUpdateItem(newShopItem);
  2807. UpdateEncumbranceInfo();
  2808. }
  2809. }
  2810. else
  2811. {
  2812.  
  2813. if(_shopInv.GetInventoryComponent().GetMoney() < itemPrice)
  2814. {
  2815. this.showNotification(GetLocStringByKeyExt("panel_shop_notification_shopkeeper_not_enough_money"));
  2816. OnPlaySoundEvent("gui_global_denied");
  2817. }
  2818. else
  2819. {
  2820. OpenQuantityPopup( itemId, QTF_Sell, quantity );
  2821. }
  2822. }
  2823. }
  2824.  
  2825. event OnBuyItem( item : SItemUniqueId, quantity : int, moveToIdx : int )
  2826. {
  2827. var itemName : name;
  2828. var tutorialState : W3TutorialManagerUIHandlerStateShop;
  2829. var result : bool;
  2830.  
  2831.  
  2832. //LogChannel('QP', "OnBuyItem, quantity: " + quantity);
  2833. itemName = _shopInv.GetItemName(item);
  2834. if (quantity <= 1)
  2835. {
  2836. result = BuyItem(item , quantity );
  2837.  
  2838.  
  2839. if(result && ShouldProcessTutorial('TutorialShopBuy') && theGame.GetTutorialSystem().uiHandler && theGame.GetTutorialSystem().uiHandler.GetCurrentStateName() == 'Shop' && itemName == 'Local pepper vodka')
  2840. {
  2841. tutorialState = (W3TutorialManagerUIHandlerStateShop)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  2842. tutorialState.OnBoughtItem();
  2843. }
  2844. }
  2845. else
  2846. {
  2847.  
  2848. if(_shopInv.GetInventoryComponent().GetInventoryItemPriceModified( _shopInv.GetInventoryComponent().GetItem(item), false ) > thePlayer.GetMoney())
  2849. {
  2850. showNotification( GetLocStringByKeyExt("panel_shop_notification_not_enough_money") );
  2851. OnPlaySoundEvent("gui_global_denied");
  2852. }
  2853. else
  2854. {
  2855. OpenQuantityPopup(item, QTF_Buy, quantity);
  2856. }
  2857. }
  2858. }
  2859.  
  2860. private function OpenQuantityPopup( itemId : SItemUniqueId, action : EQuantityTransferFunction, maxValue : int )
  2861. {
  2862. var invItem : SInventoryItem;
  2863. var maxAffordable, money : int;
  2864.  
  2865. if ( _quantityPopupData )
  2866. {
  2867. delete _quantityPopupData;
  2868. }
  2869.  
  2870. _quantityPopupData = new QuantityPopupData in this;
  2871.  
  2872. switch( action )
  2873. {
  2874. case QTF_Sell:
  2875. invItem = _playerInv.GetInventoryComponent().GetItem( itemId );
  2876. _quantityPopupData.itemCost = _shopInv.GetInventoryComponent().GetInventoryItemPriceModified( invItem, true );
  2877. _quantityPopupData.showPrice = true;
  2878. money = _shopInv.GetInventoryComponent().GetMoney();
  2879. maxAffordable = FloorF(money / _quantityPopupData.itemCost);
  2880. maxAffordable = Min(maxAffordable, maxValue);
  2881. _quantityPopupData.minValue = Min(1, maxAffordable);
  2882. break;
  2883. case QTF_Buy:
  2884. _quantityPopupData.itemCost = _shopInv.GetInventoryComponent().GetItemPriceModified( itemId, false );
  2885. _quantityPopupData.showPrice = true;
  2886. money = thePlayer.GetMoney();
  2887. maxAffordable = FloorF(money / _quantityPopupData.itemCost);
  2888. maxAffordable = Min(maxAffordable, maxValue);
  2889. _quantityPopupData.minValue = Min(1, maxAffordable);
  2890. break;
  2891. case QTF_Give:
  2892. case QTF_Take:
  2893. case QTF_Drop:
  2894. case QTF_MoveToStash:
  2895. _quantityPopupData.showPrice = false;
  2896. maxAffordable = maxValue;
  2897. _quantityPopupData.minValue = 1;
  2898. break;
  2899. }
  2900.  
  2901. _quantityPopupData.itemId = itemId;
  2902. _quantityPopupData.currentValue = maxAffordable;
  2903. _quantityPopupData.maxValue = maxValue;
  2904. _quantityPopupData.actionType = action;
  2905. _quantityPopupData.inventoryRef = this;
  2906. RequestSubMenu( 'PopupMenu', _quantityPopupData );
  2907. }
  2908.  
  2909. function TakeItem( item : SItemUniqueId, quantity : int )
  2910. {
  2911. _containerInv.GiveItem( item, _playerInv, quantity );
  2912. }
  2913.  
  2914. function GiveItem( item : SItemUniqueId, quantity : int )
  2915. {
  2916. if( _container && _container.OnTryToGiveItem( item ) )
  2917. {
  2918. _playerInv.GiveItem( item, _containerInv, quantity );
  2919. }
  2920. else if( _containerInv )
  2921. {
  2922. _playerInv.GiveItem( item, _containerInv, quantity );
  2923. }
  2924. }
  2925.  
  2926.  
  2927. function BuyItem( item : SItemUniqueId, quantity : int ) : bool
  2928. {
  2929. var m_defMgr : CDefinitionsManagerAccessor;
  2930. var filterType : EInventoryFilterType;
  2931. var newItemID : SItemUniqueId;
  2932. var schematic : SCraftingSchematic;
  2933. var resultValue : bool;
  2934. var isSchematic : bool;
  2935. var startingQuantity : int;
  2936. var itemCategory : name;
  2937. var schematicName : name;
  2938. var notifyString : string;
  2939.  
  2940. theTelemetry.LogWithLabelAndValue(TE_INV_ITEM_BOUGHT, _shopInv.GetItemName(item), quantity);
  2941. filterType = _shopInv.GetFilterTypeByItem(item);
  2942. resultValue = _shopInv.GiveItem( item, _playerInv, quantity, newItemID);
  2943.  
  2944. if (resultValue)
  2945. {
  2946. itemCategory = thePlayer.GetInventory().GetItemCategory( newItemID );
  2947. isSchematic = itemCategory == 'alchemy_recipe' || itemCategory == 'crafting_schematic';
  2948.  
  2949.  
  2950. if (itemCategory != 'gwint' && !isSchematic )
  2951. {
  2952. _playerInv.SetFilterType( filterType );
  2953. UpdateInventoryFilter(filterType);
  2954. _playerInv.clearGridPosition(newItemID);
  2955. InventoryUpdateItem(newItemID);
  2956. }
  2957.  
  2958. theSound.SoundEvent( 'gui_inventory_buy' );
  2959.  
  2960. UpdateEncumbranceInfo();
  2961. UpdatePlayerMoney();
  2962. UpdatePlayerStatisticsData();
  2963. UpdateItemsCounter();
  2964. UpdateMerchantData();
  2965.  
  2966. if( isSchematic )
  2967. {
  2968. m_defMgr = theGame.GetDefinitionsManager();
  2969. thePlayer.inv.ReadSchematicsAndRecipes( newItemID );
  2970.  
  2971. schematicName = thePlayer.inv.GetItemName( newItemID );
  2972. schematic = getCraftingSchematicFromName( schematicName );
  2973.  
  2974. notifyString = GetLocStringByKeyExt( "panel_hud_craftingschematic_update_new_entry" ) + "<br>";
  2975. notifyString += GetLocStringByKeyExt( m_defMgr.GetItemLocalisationKeyName( schematic.craftedItemName ) );
  2976. showNotification( notifyString );
  2977. }
  2978.  
  2979. if (_shopInv.GetItemQuantity(item) == 0)
  2980. {
  2981. ShopRemoveItem(item);
  2982. }
  2983. else
  2984. {
  2985. ShopUpdateItem(item);
  2986. }
  2987.  
  2988. UpdatePinnedCraftingItemInfo();
  2989. }
  2990. else
  2991. {
  2992. showNotification( GetLocStringByKeyExt("panel_shop_notification_not_enough_money") );
  2993. OnPlaySoundEvent("gui_global_denied");
  2994. }
  2995.  
  2996. return resultValue;
  2997. }
  2998.  
  2999. function SellItem( item : SItemUniqueId, quantity : int ) : SItemUniqueId
  3000. {
  3001. var shopInvComponent : CInventoryComponent;
  3002. var newItemID : SItemUniqueId;
  3003. var itemCost : int;
  3004. var shopMoney : int;
  3005. var invItem : SInventoryItem;
  3006. var preSellQty : int;
  3007. var uiDataGrid : SInventoryItemUIData;
  3008.  
  3009. newItemID = GetInvalidUniqueId();
  3010.  
  3011. if( _shopNpc )
  3012. {
  3013. theTelemetry.LogWithLabelAndValue(TE_INV_ITEM_SOLD, _playerInv.GetItemName(item), quantity);
  3014.  
  3015. invItem = _playerInv.GetInventoryComponent().GetItem( item );
  3016. shopInvComponent = _shopInv.GetInventoryComponent();
  3017. itemCost = shopInvComponent.GetInventoryItemPriceModified( invItem, true ) * quantity;
  3018. shopMoney = shopInvComponent.GetMoney();
  3019.  
  3020. preSellQty = _playerInv.GetInventoryComponent().GetItemQuantity( item );
  3021.  
  3022. if ( shopMoney < itemCost )
  3023. {
  3024. this.showNotification(GetLocStringByKeyExt("panel_shop_notification_shopkeeper_not_enough_money"));
  3025. OnPlaySoundEvent("gui_global_denied");
  3026. }
  3027. else if ( _shopInv.ReceiveItem( item, _playerInv, quantity, newItemID) )
  3028. {
  3029. theSound.SoundEvent( 'gui_inventory_sell' );
  3030.  
  3031. UpdatePlayerMoney();
  3032. UpdateMerchantData();
  3033. UpdateItemsCounter();
  3034.  
  3035. UpdatePinnedCraftingItemInfo();
  3036.  
  3037. if (preSellQty == 1 || preSellQty == quantity)
  3038. {
  3039.  
  3040. uiDataGrid = _playerInv.GetInventoryComponent().GetInventoryItemUIData( item );
  3041. uiDataGrid.gridPosition = -1;
  3042. _playerInv.GetInventoryComponent().SetInventoryItemUIData( item, uiDataGrid );
  3043. }
  3044. }
  3045. else
  3046. {
  3047. this.showNotification(GetLocStringByKeyExt("panel_shop_not_for_sale"));
  3048. OnPlaySoundEvent("gui_global_denied");
  3049. }
  3050.  
  3051. }
  3052. return newItemID;
  3053. }
  3054.  
  3055. function DropItem( item : SItemUniqueId, quantity : int ) : bool
  3056. {
  3057. var itemOnSlot :SItemUniqueId;
  3058. var boltSlot : SItemUniqueId;
  3059. var updateBoltsInInv : bool;
  3060.  
  3061. updateBoltsInInv = false;
  3062.  
  3063. if ( thePlayer.IsInCombat() && ( _inv.IsItemMounted( item ) || _inv.IsItemHeld( item ) ) )
  3064. {
  3065. showNotification(GetLocStringByKeyExt("menu_cannot_perform_action_combat"));
  3066. OnPlaySoundEvent("gui_global_denied");
  3067. return false;
  3068. }
  3069.  
  3070. if (_playerInv.CanDrop(item))
  3071. {
  3072. if (quantity <= 1)
  3073. {
  3074. if ( _inv.ItemHasTag(item, 'Potion') && _inv.GetItemCategory(item) != 'edibles' )
  3075. {
  3076. OnPlaySoundEvent( "gui_inv_potion" );
  3077. }
  3078. else
  3079. {
  3080. OnPlaySoundEvent( "gui_inventory_drop" );
  3081. }
  3082.  
  3083. if (_inv.IsItemCrossbow(item) && GetWitcherPlayer().GetItemEquippedOnSlot(EES_RangedWeapon,itemOnSlot))
  3084. {
  3085.  
  3086.  
  3087. if (itemOnSlot == item && GetWitcherPlayer().GetItemEquippedOnSlot(EES_Bolt,itemOnSlot))
  3088. {
  3089. updateBoltsInInv = !_inv.ItemHasTag(itemOnSlot,theGame.params.TAG_INFINITE_AMMO);
  3090.  
  3091. PaperdollRemoveItem(itemOnSlot);
  3092. _playerInv.UnequipItem( itemOnSlot );
  3093.  
  3094. if (updateBoltsInInv)
  3095. {
  3096. InventoryUpdateItem(itemOnSlot);
  3097. }
  3098. }
  3099. }
  3100.  
  3101. FinalDropItem(item, quantity);
  3102.  
  3103. PaperdollRemoveItem(item);
  3104. InventoryRemoveItem(item);
  3105. UpdateItemsCounter();
  3106. UpdatePlayerStatisticsData();
  3107. UpdateGuiSceneEntityItems();
  3108. }
  3109. else
  3110. {
  3111. OpenQuantityPopup(item, QTF_Drop, quantity);
  3112. }
  3113. }
  3114. else
  3115. {
  3116. OnPlaySoundEvent( "gui_global_denied" );
  3117. }
  3118.  
  3119. return true;
  3120. }
  3121.  
  3122. public function FinalDropItem(item : SItemUniqueId, quantity : int)
  3123. {
  3124. var uiDataGrid : SInventoryItemUIData;
  3125.  
  3126.  
  3127. uiDataGrid = _inv.GetInventoryItemUIData( item );
  3128. uiDataGrid.gridPosition = -1;
  3129. _inv.SetInventoryItemUIData( item, uiDataGrid );
  3130.  
  3131. if ( _inv.ItemHasTag(item, 'SilverOil') || _inv.ItemHasTag(item, 'SteelOil') || _inv.ItemHasTag(item, 'Petard') || ( _inv.ItemHasTag(item, 'Potion') && _inv.GetItemCategory(item) != 'edibles' ))
  3132. {
  3133. _inv.RemoveItem( item );
  3134. _inv.DespawnItem( item );
  3135. }
  3136. else
  3137. {
  3138. _playerInv.DropItem( item, quantity );
  3139. }
  3140.  
  3141. OnSaveItemGridPosition(item, -1);
  3142. }
  3143.  
  3144. public function UpdatePlayerMoney()
  3145. {
  3146. var commonMenu : CR4CommonMenu;
  3147. commonMenu = (CR4CommonMenu)m_parentMenu;
  3148.  
  3149. if( commonMenu )
  3150. {
  3151. commonMenu.UpdatePlayerOrens();
  3152. }
  3153. }
  3154.  
  3155. public function UpdateMerchantData() : void
  3156. {
  3157. var l_merchantData : CScriptedFlashObject;
  3158.  
  3159. if (_shopNpc)
  3160. {
  3161. l_merchantData = m_flashValueStorage.CreateTempFlashObject();
  3162. GetNpcInfo((CGameplayEntity)_shopNpc, l_merchantData);
  3163. m_flashValueStorage.SetFlashObject("inventory.merchant.info", l_merchantData);
  3164. }
  3165. }
  3166.  
  3167. public function IsItemInPreview( itemId : SItemUniqueId ) : bool
  3168. {
  3169. return m_previewItems.Contains( itemId );
  3170. }
  3171.  
  3172. public function IsSlotInPreview( targetSlot : int ) : bool
  3173. {
  3174. return m_previewSlots[targetSlot] || _inv.IsIdValid( m_dyePreviewSlots[targetSlot] );
  3175. }
  3176.  
  3177. public function RemovePreviewFromSlot( targetSlot : int ) : void
  3178. {
  3179. var i, itemsCount : int;
  3180. var curItemId : SItemUniqueId;
  3181. var itemsToUpdate : array< SItemUniqueId >;
  3182. var itemOnSlot : SItemUniqueId;
  3183.  
  3184. if( !m_previewSlots[ targetSlot ] )
  3185. {
  3186. return;
  3187. }
  3188.  
  3189. itemsCount = m_previewItems.Size();
  3190. for(i = 0; i < itemsCount; i += 1)
  3191. {
  3192. curItemId = m_previewItems[i];
  3193.  
  3194. if( targetSlot == _inv.GetSlotForItemId( curItemId ) && m_previewItems.Contains( curItemId ) )
  3195. {
  3196. m_previewItems.Remove( curItemId );
  3197. itemsToUpdate.PushBack( curItemId );
  3198. continue;
  3199. }
  3200. }
  3201.  
  3202. m_previewSlots[ targetSlot ] = false;
  3203.  
  3204. _playerInv.previewItems = m_previewItems;
  3205. _paperdollInv.previewSlots = m_previewSlots;
  3206.  
  3207. GetWitcherPlayer().GetItemEquippedOnSlot( targetSlot, itemOnSlot );
  3208. if( _inv.IsIdValid( itemOnSlot ) )
  3209. {
  3210. PaperdollUpdateItem( itemOnSlot );
  3211. }
  3212.  
  3213. InventoryUpdateItems( itemsToUpdate );
  3214. UpdateGuiSceneEntityItems();
  3215.  
  3216. m_fxSetPaperdollPreviewIcon.InvokeSelfTwoArgs( FlashArgInt( targetSlot ), FlashArgBool( false ) );
  3217.  
  3218. if (m_currentContext)
  3219. {
  3220. m_currentContext.UpdateContext();
  3221. }
  3222. }
  3223.  
  3224. public function UnPreviewItem( itemId : SItemUniqueId ) : void
  3225. {
  3226. var idx : int;
  3227. var targetSlot : int;
  3228. var itemOnSlot : SItemUniqueId;
  3229.  
  3230. if( !_inv.IsIdValid( itemId ) || !m_previewItems.Contains( itemId ) )
  3231. {
  3232. return;
  3233. }
  3234.  
  3235. targetSlot = _inv.GetSlotForItemId( itemId );
  3236.  
  3237. m_previewItems.Remove( itemId );
  3238. m_previewSlots[ targetSlot ] = false;
  3239.  
  3240. _playerInv.previewItems = m_previewItems;
  3241. _paperdollInv.previewItems = m_previewItems;
  3242. _paperdollInv.previewSlots = m_previewSlots;
  3243.  
  3244. GetWitcherPlayer().GetItemEquippedOnSlot( targetSlot, itemOnSlot );
  3245. if( _inv.IsIdValid( itemOnSlot ) )
  3246. {
  3247. PaperdollUpdateItem( itemOnSlot );
  3248. }
  3249.  
  3250. InventoryUpdateItem( itemId );
  3251. UpdateGuiSceneEntityItems();
  3252.  
  3253. m_fxSetPaperdollPreviewIcon.InvokeSelfTwoArgs( FlashArgInt( targetSlot ), FlashArgBool( false ) );
  3254.  
  3255. if (m_currentContext)
  3256. {
  3257. m_currentContext.UpdateContext();
  3258. }
  3259. }
  3260.  
  3261. public function PreviewItem( itemId : SItemUniqueId ):void
  3262. {
  3263. var i, itemsCount : int;
  3264. var curItemId : SItemUniqueId;
  3265. var previewSlot : EEquipmentSlots;
  3266. var itemsToUpdate : array< SItemUniqueId >;
  3267. var itemOnSlot : SItemUniqueId;
  3268.  
  3269. previewSlot = _inv.GetSlotForItemId( itemId );
  3270. m_previewSlots[ previewSlot ] = true;
  3271. itemsCount = m_previewItems.Size();
  3272.  
  3273. for(i = 0; i < itemsCount; i += 1)
  3274. {
  3275. curItemId = m_previewItems[i];
  3276.  
  3277. if( previewSlot == _inv.GetSlotForItemId( curItemId ) )
  3278. {
  3279. m_previewItems.Remove( curItemId );
  3280. itemsToUpdate.PushBack( curItemId );
  3281. continue;
  3282. }
  3283. }
  3284.  
  3285. m_previewItems.PushBack( itemId );
  3286. GetWitcherPlayer().GetItemEquippedOnSlot( previewSlot, itemOnSlot );
  3287. m_previewSlots[ previewSlot ] = true;
  3288.  
  3289. _playerInv.previewItems = m_previewItems;
  3290. _paperdollInv.previewSlots = m_previewSlots;
  3291. itemsToUpdate.PushBack( itemId );
  3292.  
  3293. if( _inv.IsIdValid( itemOnSlot ) )
  3294. {
  3295. PaperdollUpdateItem( itemOnSlot );
  3296. }
  3297.  
  3298. InventoryUpdateItems( itemsToUpdate );
  3299. UpdateGuiSceneEntityItems();
  3300. PlayPaperdollAnimation( _inv.GetItemCategory( itemId ) );
  3301.  
  3302. m_fxSetPaperdollPreviewIcon.InvokeSelfTwoArgs( FlashArgInt( previewSlot ), FlashArgBool( true ) );
  3303. }
  3304.  
  3305. public function PreviewDye( itemId : SItemUniqueId, targetSlot : int ) : void
  3306. {
  3307. m_dyePreviewSlots.Clear();
  3308. m_dyePreviewSlots.Resize( EnumGetMax( 'EEquipmentSlots' ) + 1 );
  3309. m_dyePreviewSlots[ targetSlot ] = itemId;
  3310.  
  3311. UpdateGuiSceneEntityItems();
  3312. }
  3313.  
  3314. public function UnpreviewDye() : void
  3315. {
  3316. m_dyePreviewSlots.Clear();
  3317. m_dyePreviewSlots.Resize( EnumGetMax( 'EEquipmentSlots' ) + 1 );
  3318.  
  3319. UpdateGuiSceneEntityItems();
  3320. }
  3321.  
  3322. private function ResetDisplayPreviewCache( itemId : SItemUniqueId, slot : EEquipmentSlots, optional out itemsToUpdate : array < SItemUniqueId > ) : void
  3323. {
  3324. var curItemId : SItemUniqueId;
  3325. var i, len : int;
  3326.  
  3327. m_dyePreviewSlots[ slot ] = GetInvalidUniqueId();
  3328. m_previewItems.Remove( itemId );
  3329. m_previewSlots[ slot ] = false;
  3330.  
  3331. _playerInv.previewItems = m_previewItems;
  3332. _paperdollInv.previewItems = m_previewItems;
  3333. _paperdollInv.previewSlots = m_previewSlots;
  3334.  
  3335. len = m_previewItems.Size();
  3336.  
  3337. if( slot != EES_InvalidSlot )
  3338. {
  3339. for( i = 0; i < len; i = i + 1)
  3340. {
  3341. curItemId = m_previewItems[ i ];
  3342.  
  3343. if( _inv.GetSlotForItemId( curItemId ) == slot )
  3344. {
  3345. itemsToUpdate.PushBack( curItemId );
  3346. }
  3347. }
  3348. }
  3349. }
  3350.  
  3351. event OnSetCurrentPlayerGrid( value : string )
  3352. {
  3353. if( value == "inventory.grid.container" )
  3354. {
  3355. if( _shopInv )
  3356. {
  3357. _currentInv = _shopInv;
  3358. }
  3359. else if (_currentState == IMS_Stash)
  3360. {
  3361. _currentInv = _horseInv;
  3362. }
  3363. else
  3364. {
  3365. _currentInv = _containerInv;
  3366. }
  3367. }
  3368. else
  3369. if( value == "inventory.paperdoll.horse" )
  3370. {
  3371. _currentInv = _horsePaperdollInv;
  3372. }
  3373. else
  3374. {
  3375. _currentInv = _playerInv;
  3376. }
  3377. }
  3378.  
  3379. event OnConsumeItem( item : SItemUniqueId )
  3380. {
  3381. if (thePlayer.IsInCombat())
  3382. {
  3383. showNotification(GetLocStringByKeyExt("menu_cannot_perform_action_combat"));
  3384. OnPlaySoundEvent("gui_global_denied");
  3385. }
  3386. else
  3387. {
  3388. _playerInv.ConsumeItem( item );
  3389. FactsAdd("item_use_" + _playerInv.GetItemName(item), 1, 3);
  3390.  
  3391. if (_currentInv.GetItemQuantity( item ) > 0)
  3392. {
  3393. InventoryUpdateItem(item);
  3394. }
  3395. else
  3396. {
  3397. InventoryRemoveItem(item);
  3398. }
  3399. UpdateItemsCounter();
  3400. UpdatePlayerStatisticsData();
  3401. }
  3402. }
  3403.  
  3404. event OnMoveItem( item : SItemUniqueId, moveToIndex : int )
  3405. {
  3406.  
  3407. _playerInv.MoveItem( item , moveToIndex );
  3408.  
  3409.  
  3410.  
  3411. InventoryUpdateItem(item);
  3412. m_flashValueStorage.SetFlashInt("inventory.grid.player.offset",0);
  3413. }
  3414.  
  3415. event OnMoveItems( item : SItemUniqueId, moveToIndex : int, itemSecond : SItemUniqueId, moveToSecondIndex : int )
  3416. {
  3417. var itemsList : array<SItemUniqueId>;
  3418.  
  3419. _playerInv.MoveItems( item, moveToIndex, itemSecond, moveToSecondIndex);
  3420.  
  3421. itemsList.PushBack(item);
  3422. itemsList.PushBack(itemSecond);
  3423. InventoryUpdateItems(itemsList);
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429. }
  3430.  
  3431.  
  3432.  
  3433. event OnContainerFilterSelected( filterType : EInventoryFilterType )
  3434. {
  3435.  
  3436.  
  3437. UpdateContainer();
  3438. }
  3439.  
  3440. function SaveStateData()
  3441. {
  3442. UISavedData.openedCategories.Clear();
  3443. UISavedData.openedCategories.PushBack(GetFilterTypeName(_playerInv.GetFilterType()));
  3444. m_guiManager.UpdateUISavedData( GetMenuName(), UISavedData.openedCategories, '',UISavedData.selectedModule , UISavedData.gridItem, UISavedData.slotID );
  3445. }
  3446.  
  3447.  
  3448.  
  3449. event OnModuleSelected( moduleID : int, moduleBindingName : string )
  3450. {
  3451. //LogChannel('CONTEXT'," OnModuleSelected " + moduleBindingName);
  3452. super.OnModuleSelected( moduleID, moduleBindingName );
  3453.  
  3454. m_lastSelectedModuleID = moduleID;
  3455. m_lastSelectedModuleBindingName = moduleBindingName;
  3456.  
  3457. if (m_selectionModeActive)
  3458. {
  3459. return false;
  3460. }
  3461.  
  3462. switch (moduleBindingName)
  3463. {
  3464. case "inventory.grid.player" :
  3465. ResetContext();
  3466. createInventoryContext();
  3467. break;
  3468. case "inventory.grid.paperdoll.horse":
  3469. case "inventory.paperdoll" :
  3470. ResetContext();
  3471. createPaperdollContext();
  3472. break;
  3473. case "inventory.stats" :
  3474. ResetContext();
  3475. createStatContext();
  3476. break;
  3477. case "inventory.grid.container" :
  3478. ResetContext();
  3479. createExternalContext();
  3480. break;
  3481. default:
  3482. break;
  3483. }
  3484. }
  3485.  
  3486. protected function createStatContext():void
  3487. {
  3488. if (_statsContext)
  3489. {
  3490. delete _statsContext;
  3491. }
  3492.  
  3493. _statsContext = new W3PlayerStatsContext in this;
  3494. _statsContext.SetInventoryRef(this);
  3495. m_currentContext = _statsContext;
  3496. ActivateContext(m_currentContext);
  3497. }
  3498.  
  3499. protected function createPaperdollContext():void
  3500. {
  3501. if (_paperdollContext)
  3502. {
  3503. delete _paperdollContext;
  3504. }
  3505.  
  3506. _paperdollContext = new W3InventoryPaperdollContext in this;
  3507. _paperdollContext.SetInventoryRef(this);
  3508. _paperdollContext.SetSecondInventoryComponentRef(GetWitcherPlayer().GetHorseManager().GetInventoryComponent());
  3509. m_currentContext = _paperdollContext;
  3510. ActivateContext(m_currentContext);
  3511. }
  3512.  
  3513. protected function createInventoryContext():void
  3514. {
  3515. if (_invContext)
  3516. {
  3517. delete _invContext;
  3518. }
  3519.  
  3520. _invContext = new W3InventoryGridContext in this;
  3521. _invContext.SetInventoryRef(this);
  3522. m_currentContext = _invContext;
  3523. ActivateContext(m_currentContext);
  3524. }
  3525.  
  3526. protected function createExternalContext():void
  3527. {
  3528. if (_externGridContext)
  3529. {
  3530. delete _externGridContext;
  3531. }
  3532.  
  3533. _externGridContext = new W3ExternalGridContext in this;
  3534. _externGridContext.SetInventoryRef(this);
  3535. m_currentContext = _externGridContext;
  3536. ActivateContext(m_currentContext);
  3537. }
  3538.  
  3539.  
  3540. event OnSelectInventoryItem(itemId:SItemUniqueId, slot:int, positionX:float, positionY:float)
  3541. {
  3542. var inventoryGridContext : W3InventoryItemContext;
  3543. var tutorialState : W3TutorialManagerUIHandlerStateRunes;
  3544. var tutorialStateBooks : W3TutorialManagerUIHandlerStateBooks;
  3545. var tutorialStateFood : W3TutorialManagerUIHandlerStateFood;
  3546. var tutorialStateRecipeReading : W3TutorialManagerUIHandlerStateRecipeReading;
  3547. var tutorialStateDye : W3TutorialManagerUIHandlerStateDye;
  3548. var tutorialStateSets : W3TutorialManagerUIHandlerStateSetItemsInfo;
  3549.  
  3550. inventoryGridContext = (W3InventoryItemContext) m_currentContext;
  3551. SaveSelectedItem(itemId);
  3552. if (inventoryGridContext)
  3553. {
  3554. inventoryGridContext.SetContextMenuData(positionX, positionY);
  3555. inventoryGridContext.SetCurrentSlot(slot);
  3556. inventoryGridContext.SetCurrentItem(itemId);
  3557. }
  3558.  
  3559.  
  3560. if(ShouldProcessTutorial('TutorialRunesSelectRune') && theGame.GetTutorialSystem().uiHandler && theGame.GetTutorialSystem().uiHandler.GetCurrentStateName() == 'Runes')
  3561. {
  3562. tutorialState = (W3TutorialManagerUIHandlerStateRunes)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  3563. tutorialState.OnSelectedItem(itemId);
  3564. }
  3565.  
  3566. if(ShouldProcessTutorial('TutorialBooksSelectTab') && theGame.GetTutorialSystem().uiHandler && theGame.GetTutorialSystem().uiHandler.GetCurrentStateName() == 'Books')
  3567. {
  3568. tutorialStateBooks = (W3TutorialManagerUIHandlerStateBooks)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  3569. tutorialStateBooks.OnSelectedItem(itemId);
  3570. }
  3571.  
  3572. if(ShouldProcessTutorial('TutorialFoodSelectTab') && theGame.GetTutorialSystem().uiHandler && theGame.GetTutorialSystem().uiHandler.GetCurrentStateName() == 'Food')
  3573. {
  3574. tutorialStateFood = (W3TutorialManagerUIHandlerStateFood)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  3575. tutorialStateFood.OnSelectedItem(itemId);
  3576. }
  3577.  
  3578. if(ShouldProcessTutorial('TutorialBooksSelectTab') && theGame.GetTutorialSystem().uiHandler && theGame.GetTutorialSystem().uiHandler.GetCurrentStateName() == 'RecipeReading')
  3579. {
  3580. tutorialStateRecipeReading = (W3TutorialManagerUIHandlerStateRecipeReading)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  3581. tutorialStateRecipeReading.OnSelectedItem(itemId);
  3582. }
  3583.  
  3584. if( ShouldProcessTutorial( 'TutorialDye' ) && theGame.GetTutorialSystem().uiHandler && theGame.GetTutorialSystem().uiHandler.GetCurrentStateName() == 'Dye' && thePlayer.inv.IsItemDye( itemId ) )
  3585. {
  3586. tutorialStateDye = ( W3TutorialManagerUIHandlerStateDye )theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  3587. tutorialStateDye.OnDyeSelected();
  3588. }
  3589.  
  3590. if( ShouldProcessTutorial( 'TutorialSetBonusesInfo' ) && theGame.GetTutorialSystem().uiHandler && theGame.GetTutorialSystem().uiHandler.GetCurrentStateName() == 'SetItemsInfo' && thePlayer.inv.ItemHasTag(itemId, theGame.params.ITEM_SET_TAG_BONUS ) )
  3591. {
  3592. tutorialStateSets = ( W3TutorialManagerUIHandlerStateSetItemsInfo )theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  3593. tutorialStateSets.OnSetItemSelected();
  3594. }
  3595. }
  3596.  
  3597. event OnSelectPaperdollItem(itemId:SItemUniqueId, slot:int, positionX:float, positionY:float)
  3598. {
  3599. var paperdollContext : W3InventoryPaperdollContext;
  3600.  
  3601.  
  3602. if ( slot == EES_HorseBlinders || slot == EES_HorseSaddle || slot == EES_HorseBag || slot == EES_HorseTrophy )
  3603. {
  3604. OnSetCurrentPlayerGrid("inventory.paperdoll.horse");
  3605. }
  3606. else
  3607. {
  3608. OnSetCurrentPlayerGrid("inventory.paperdoll");
  3609. }
  3610.  
  3611. paperdollContext = (W3InventoryPaperdollContext) m_currentContext;
  3612. UISavedData.slotID = slot;
  3613.  
  3614. if (paperdollContext)
  3615. {
  3616. paperdollContext.SetContextMenuData(positionX, positionY);
  3617. paperdollContext.SetCurrentSlot(slot);
  3618. paperdollContext.SetCurrentItem(itemId);
  3619. }
  3620.  
  3621. if (m_dyePreviewMode)
  3622. {
  3623. PreviewDye(m_selectionModeItem, slot);
  3624. }
  3625. }
  3626.  
  3627. event OnSelectPlayerStat(statId : name)
  3628. {
  3629. var statContext : W3PlayerStatsContext;
  3630. statContext = (W3PlayerStatsContext) m_currentContext;
  3631. if (statContext)
  3632. {
  3633. statContext.SetStatName(statId);
  3634. }
  3635. }
  3636.  
  3637. function SaveSelectedItem( itemId : SItemUniqueId )
  3638. {
  3639. UISavedData.gridItem = itemId;
  3640. }
  3641.  
  3642. function ReadBook( item : SItemUniqueId )
  3643. {
  3644. theSound.SoundEvent( 'gui_inventory_read' );
  3645.  
  3646. ShowBookPopup( GetLocStringByKeyExt( _inv.GetItemLocalizedNameByUniqueID( item ) ), _playerInv.GetBookText( item ), item);
  3647. }
  3648.  
  3649. function ShowBookPopup(BookTitle:string, BookText:string, item : SItemUniqueId, optional singleBookMode : bool )
  3650. {
  3651. if (_bookPopupData)
  3652. {
  3653. delete _bookPopupData;
  3654. }
  3655.  
  3656. m_bookPopupItem = item;
  3657.  
  3658. _bookPopupData = new BookPopupFeedback in this;
  3659. _bookPopupData.SetMessageTitle( BookTitle );
  3660. _bookPopupData.SetMessageText( BookText );
  3661. _bookPopupData.bookItemId = item;
  3662. _bookPopupData.singleBookMode = singleBookMode;
  3663. _bookPopupData.inventoryRef = this;
  3664. _bookPopupData.curInventory = GetCurrentInventory();
  3665.  
  3666. RequestSubMenu('PopupMenu', _bookPopupData);
  3667. }
  3668.  
  3669. function ShowPainting(item : SItemUniqueId)
  3670. {
  3671. var itemName:name;
  3672.  
  3673. if (_paintingPopupData)
  3674. {
  3675. delete _paintingPopupData;
  3676. }
  3677.  
  3678. itemName = _inv.GetItemName(item);
  3679.  
  3680. if( !_inv.IsBookRead( item ) )
  3681. {
  3682. _inv.ReadBook( item );
  3683. }
  3684.  
  3685. _paintingPopupData = new PaintingPopup in this;
  3686. _paintingPopupData.SetMessageTitle( GetLocStringByKeyExt(_inv.GetItemLocalizedNameByUniqueID(item)) );
  3687. _paintingPopupData.SetImagePath("img://icons/inventory/paintings/" + itemName + ".png");
  3688.  
  3689. RequestSubMenu('PopupMenu', _paintingPopupData);
  3690. }
  3691.  
  3692. event OnShowFullStats()
  3693. {
  3694. if (_charStatsPopupData)
  3695. {
  3696. delete _charStatsPopupData;
  3697. }
  3698.  
  3699. _charStatsPopupData = new CharacterStatsPopupData in this;
  3700. _charStatsPopupData.HideTutorial = true;
  3701.  
  3702. RequestSubMenu('PopupMenu', _charStatsPopupData);
  3703. }
  3704.  
  3705. event OnPlaySound( soundKey : string )
  3706. {
  3707. theSound.SoundEvent( soundKey );
  3708. }
  3709.  
  3710.  
  3711. event OnInputHandled(NavCode:string, KeyCode:int, ActionId:int)
  3712. {
  3713. //LogChannel('GFX', "OnInputHandled, NavCode: "+NavCode+"; actionId: "+ActionId);
  3714. if (m_currentContext)
  3715. {
  3716. m_currentContext.HandleUserFeedback(NavCode);
  3717. }
  3718. }
  3719.  
  3720. event OnMouseInputHandled(NavCodeAnalog : string, itemId : SItemUniqueId, slotId:int, moduleBinding : string)
  3721. {
  3722. var curInvContext : W3InventoryItemContext;
  3723.  
  3724.  
  3725. OnModuleSelected(0, moduleBinding);
  3726.  
  3727. curInvContext = (W3InventoryItemContext) m_currentContext;
  3728. if (curInvContext)
  3729. {
  3730. curInvContext.SetCurrentItem(itemId);
  3731. curInvContext.SetCurrentSlot(slotId);
  3732. curInvContext.HandleUserFeedback(NavCodeAnalog);
  3733. }
  3734. }
  3735.  
  3736. event OnSetMouseInventoryComponent(moduleBinding : string, slotId:int)
  3737. {
  3738. if( moduleBinding == "inventory.grid.container" )
  3739. {
  3740. if (_currentState == IMS_Stash)
  3741. {
  3742. _currentMouseInv = _horseInv;
  3743. }
  3744. else if( _shopInv )
  3745. {
  3746. _currentMouseInv = _shopInv;
  3747. }
  3748. else
  3749. {
  3750. _currentMouseInv = _containerInv;
  3751. }
  3752. }
  3753. else
  3754. if( moduleBinding == "inventory.paperdoll" )
  3755. {
  3756. if ( slotId == EES_HorseBlinders || slotId == EES_HorseSaddle || slotId == EES_HorseBag || slotId == EES_HorseTrophy )
  3757. {
  3758. _currentMouseInv = _horsePaperdollInv;
  3759. }
  3760. else
  3761. {
  3762. _currentMouseInv = _playerInv;
  3763. }
  3764. }
  3765. else
  3766. {
  3767. _currentMouseInv = _playerInv;
  3768. }
  3769. }
  3770.  
  3771. event OnShowItemPopup( item : SItemUniqueId )
  3772. {
  3773.  
  3774. }
  3775.  
  3776. public function ShowItemInfoPopup( item : SItemUniqueId ) : void
  3777. {
  3778. if (_itemInfoPopupData)
  3779. {
  3780. delete _itemInfoPopupData;
  3781. }
  3782.  
  3783. _itemInfoPopupData= new ItemInfoPopupData in this;
  3784. _itemInfoPopupData.inventoryRef = this;
  3785. _itemInfoPopupData.invRef = GetCurrentInventory(item);
  3786. _itemInfoPopupData.itemId = item;
  3787. RequestSubMenu('PopupMenu', _itemInfoPopupData);
  3788. }
  3789.  
  3790. public function OnItemPopupClosed():void
  3791. {
  3792.  
  3793. m_flashValueStorage.SetFlashBool( "render.to.texture.texture.visible", true);
  3794. }
  3795.  
  3796. private function UpdateGuiSceneEntityItems()
  3797. {
  3798. var guiSceneController : CR4GuiSceneController;
  3799.  
  3800. if (_currentState != IMS_Player)
  3801. {
  3802. return;
  3803. }
  3804.  
  3805. guiSceneController = theGame.GetGuiManager().GetSceneController();
  3806. if ( !guiSceneController )
  3807. {
  3808. return;
  3809. }
  3810. guiSceneController.SetEntityItems( true, m_previewItems, m_dyePreviewSlots );
  3811. }
  3812.  
  3813. event OnInventoryItemSelected(itemId:SItemUniqueId) : void
  3814. {
  3815.  
  3816. }
  3817.  
  3818. public function ShowSelectionMode( sourceItem : SItemUniqueId, targetSlotList : array< int > )
  3819. {
  3820. var l_flashArray : CScriptedFlashArray;
  3821. var l_flashObject : CScriptedFlashObject;
  3822. var i : int;
  3823.  
  3824. if (m_selectionModeActive)
  3825. {
  3826. return;
  3827. }
  3828.  
  3829. if (targetSlotList.Size() == 0)
  3830. {
  3831.  
  3832. return;
  3833. }
  3834.  
  3835. if (!_inv.IsIdValid(sourceItem))
  3836. {
  3837.  
  3838. return;
  3839. }
  3840.  
  3841. l_flashObject = m_flashValueStorage.CreateTempFlashObject();
  3842. l_flashArray = m_flashValueStorage.CreateTempFlashArray();
  3843.  
  3844. l_flashObject.SetMemberFlashInt("sourceItem", ItemToFlashUInt(sourceItem));
  3845. l_flashObject.SetMemberFlashBool("isDyeApplyingMode", _inv.IsItemDye( sourceItem ) );
  3846.  
  3847. for (i = 0; i < targetSlotList.Size(); i += 1)
  3848. {
  3849. l_flashArray.PushBackFlashInt(targetSlotList[i]);
  3850. }
  3851.  
  3852. OnPlaySoundEvent("gui_global_panel_open");
  3853.  
  3854. l_flashObject.SetMemberFlashArray("validSlots", l_flashArray);
  3855.  
  3856. m_selectionModeItem = sourceItem;
  3857. ResetContext();
  3858.  
  3859. m_flashValueStorage.SetFlashObject("inventory.selection.mode.show", l_flashObject);
  3860. m_selectionModeActive = true;
  3861. }
  3862.  
  3863. public function HideSelectionMode()
  3864. {
  3865. if (!m_selectionModeActive)
  3866. {
  3867. return;
  3868. }
  3869.  
  3870. m_fxHideSelectionMode.InvokeSelf();
  3871. m_selectionModeActive = false;
  3872.  
  3873. OnModuleSelected(m_lastSelectedModuleID, m_lastSelectedModuleBindingName);
  3874. m_dyePreviewMode = false;
  3875. UnpreviewDye();
  3876. }
  3877.  
  3878. event OnSelectionModeCancelRequested()
  3879. {
  3880. var uiStateRunes : W3TutorialManagerUIHandlerStateRunes;
  3881. var uiStateArmorUpgrades : W3TutorialManagerUIHandlerStateArmorUpgrades;
  3882.  
  3883. if(ShouldProcessTutorial('TutorialRunesSelectSword'))
  3884. {
  3885. uiStateRunes = (W3TutorialManagerUIHandlerStateRunes)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  3886. if(uiStateRunes)
  3887. {
  3888. uiStateRunes.OnSelectingSwordAborted();
  3889. }
  3890. }
  3891. else if(ShouldProcessTutorial('TutorialArmorSocketsSelectTab'))
  3892. {
  3893. uiStateArmorUpgrades = (W3TutorialManagerUIHandlerStateArmorUpgrades)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  3894. if(uiStateArmorUpgrades)
  3895. {
  3896. uiStateArmorUpgrades.OnSelectingArmorAborted();
  3897. }
  3898. }
  3899.  
  3900. OnPlaySoundEvent("gui_global_panel_close");
  3901.  
  3902. HideSelectionMode();
  3903. m_dyePreviewMode = false;
  3904. }
  3905.  
  3906. event OnSelectionModeTargetChosen( targetSlot : int )
  3907. {
  3908. var alreadyEquippedItem : bool;
  3909. var isEquippedItemValid : bool;
  3910. var curItemInSlot, otherMask : SItemUniqueId;
  3911. var filterType : EInventoryFilterType;
  3912.  
  3913. alreadyEquippedItem = false;
  3914.  
  3915. if( _inv.ItemHasTag( m_selectionModeItem, 'mod_dye' ) )
  3916. {
  3917. ApplyDye( m_selectionModeItem, targetSlot );
  3918. m_dyePreviewMode = false;
  3919. }
  3920.  
  3921.  
  3922. else
  3923. if (_playerInv.isPotionItem(m_selectionModeItem) || _playerInv.isPetardItem(m_selectionModeItem) || _playerInv.isQuickslotItem(m_selectionModeItem) || _playerInv.isFoodItem(m_selectionModeItem) )
  3924. {
  3925.  
  3926. if(_inv.IsItemMask(m_selectionModeItem))
  3927. {
  3928. if(targetSlot == EES_Quickslot1)
  3929. GetWitcherPlayer().GetItemEquippedOnSlot(EES_Quickslot2, otherMask);
  3930. else if(targetSlot == EES_Quickslot2)
  3931. GetWitcherPlayer().GetItemEquippedOnSlot(EES_Quickslot1, otherMask);
  3932. }
  3933.  
  3934. alreadyEquippedItem = GetWitcherPlayer().GetItemEquippedOnSlot(targetSlot, curItemInSlot);
  3935.  
  3936. PlayItemEquipSound( _inv.GetItemCategory(m_selectionModeItem) );
  3937. _playerInv.EquipItem( m_selectionModeItem, targetSlot );
  3938. UpdatePlayerStatisticsData();
  3939.  
  3940. if (alreadyEquippedItem && _inv.IsIdValid(curItemInSlot))
  3941. {
  3942. InventoryRemoveItem(m_selectionModeItem, true);
  3943. InventoryUpdateItem(curItemInSlot);
  3944.  
  3945. filterType = _playerInv.GetFilterTypeByItem(curItemInSlot);
  3946. _playerInv.SetFilterType( filterType );
  3947. UpdateInventoryFilter(filterType);
  3948. }
  3949. else
  3950. {
  3951. InventoryRemoveItem(m_selectionModeItem);
  3952. }
  3953.  
  3954.  
  3955. if(_inv.IsItemMask(m_selectionModeItem) && _inv.IsItemMask(otherMask))
  3956. {
  3957. PaperdollRemoveItem(otherMask);
  3958. InventoryUpdateItem(otherMask);
  3959. }
  3960.  
  3961. PaperdollUpdateItem(m_selectionModeItem);
  3962. }
  3963. else if (_inv.ItemHasTag(m_selectionModeItem, 'Upgrade'))
  3964. {
  3965. ApplyUpgrade(m_selectionModeItem, targetSlot);
  3966. }
  3967. else if (_inv.ItemHasTag(m_selectionModeItem, 'SteelOil') || _inv.ItemHasTag(m_selectionModeItem, 'SilverOil'))
  3968. {
  3969. ApplyOil(m_selectionModeItem, targetSlot);
  3970. }
  3971. else if (_inv.ItemHasTag(m_selectionModeItem, 'WeaponReapairKit') || _inv.ItemHasTag(m_selectionModeItem, 'ArmorReapairKit'))
  3972. {
  3973. ApplyRepairKit(m_selectionModeItem, targetSlot);
  3974. }
  3975.  
  3976. HideSelectionMode();
  3977. UpdateGuiSceneEntityItems();
  3978. }
  3979.  
  3980. private function ApplyDye( itemId : SItemUniqueId, targetSlot : int ) : void
  3981. {
  3982. var curItemInSlot : SItemUniqueId;
  3983. var isEquippedItemValid : bool;
  3984.  
  3985. isEquippedItemValid = GetWitcherPlayer().GetItemEquippedOnSlot( targetSlot, curItemInSlot );
  3986.  
  3987. if ( isEquippedItemValid && _inv.IsIdValid( curItemInSlot ) )
  3988. {
  3989. _inv.ColorItem( curItemInSlot, itemId );
  3990. _inv.RemoveItem ( itemId, 1 );
  3991.  
  3992. if ( _inv.GetItemQuantity( itemId ) > 0 )
  3993. {
  3994. InventoryUpdateItem( itemId );
  3995. }
  3996. else
  3997. {
  3998. InventoryRemoveItem( itemId );
  3999. }
  4000.  
  4001. PaperdollUpdateItem( curItemInSlot );
  4002. UpdateGuiSceneEntityItems();
  4003.  
  4004. theSound.SoundEvent("gui_ep2_apply_dye");
  4005. }
  4006. }
  4007.  
  4008. private function ApplyUpgrade(itemId : SItemUniqueId, targetSlot : int) : void
  4009. {
  4010. var curItemInSlot : SItemUniqueId;
  4011. var uiStateRunes : W3TutorialManagerUIHandlerStateRunes;
  4012. var uiStateArmorUpgrades : W3TutorialManagerUIHandlerStateArmorUpgrades;
  4013.  
  4014. if (GetWitcherPlayer().GetItemEquippedOnSlot(targetSlot, curItemInSlot))
  4015. {
  4016. if (targetSlot == EES_SilverSword || targetSlot == EES_SteelSword)
  4017. {
  4018. OnPlaySoundEvent("gui_inventory_rune_attach");
  4019. }
  4020. else
  4021. {
  4022. OnPlaySoundEvent("gui_inventory_armorupgrade_attach");
  4023. }
  4024.  
  4025. if (_inv.EnhanceItemScript(curItemInSlot, itemId))
  4026. {
  4027. if (_inv.IsIdValid(itemId) && _inv.GetItemQuantity( itemId ) > 0)
  4028. {
  4029. InventoryUpdateItem(itemId);
  4030. }
  4031. else
  4032. {
  4033. InventoryRemoveItem(itemId);
  4034. }
  4035. PaperdollUpdateItem(curItemInSlot);
  4036.  
  4037. if(ShouldProcessTutorial('TutorialRunesSelectSword'))
  4038. {
  4039. uiStateRunes = (W3TutorialManagerUIHandlerStateRunes)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  4040. if(uiStateRunes)
  4041. {
  4042. uiStateRunes.OnUpgradedItem();
  4043. }
  4044. }
  4045. if(ShouldProcessTutorial('TutorialArmorSocketsSelectTab'))
  4046. {
  4047. uiStateArmorUpgrades = (W3TutorialManagerUIHandlerStateArmorUpgrades)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  4048. if(uiStateArmorUpgrades)
  4049. {
  4050. uiStateArmorUpgrades.OnUpgradedItem();
  4051. }
  4052. }
  4053. }
  4054. }
  4055. }
  4056.  
  4057. private function ApplyOil(itemId : SItemUniqueId, targetSlot : int) : void
  4058. {
  4059. var curItemInSlot : SItemUniqueId;
  4060.  
  4061. OnPlaySoundEvent("gui_preparation_potion");
  4062.  
  4063. if (_inv.GetItemEquippedOnSlot(targetSlot, curItemInSlot))
  4064. {
  4065. GetWitcherPlayer().ApplyOil(itemId, curItemInSlot);
  4066. InventoryUpdateItem(m_selectionModeItem);
  4067. PaperdollUpdateItem(curItemInSlot);
  4068. }
  4069. else
  4070. {
  4071. return;
  4072. }
  4073. }
  4074.  
  4075. private function ApplyRepairKit(itemId : SItemUniqueId, targetSlot : int) : void
  4076. {
  4077. var curItemInSlot : SItemUniqueId;
  4078.  
  4079. OnPlaySoundEvent("gui_inventory_repair");
  4080.  
  4081. if (_inv.GetItemEquippedOnSlot(targetSlot, curItemInSlot))
  4082. {
  4083. GetWitcherPlayer().RepairItem (itemId, curItemInSlot);
  4084. if (_inv.IsIdValid(itemId) && _inv.GetItemQuantity( itemId ) > 0)
  4085. {
  4086. InventoryUpdateItem(itemId);
  4087. }
  4088. else
  4089. {
  4090. InventoryRemoveItem(itemId);
  4091. }
  4092. PaperdollUpdateItem(curItemInSlot);
  4093. }
  4094. else
  4095. {
  4096. return;
  4097. }
  4098. }
  4099.  
  4100. public function UpdateAllItemData() : void
  4101. {
  4102. UpdateItemsCounter();
  4103. UpdatePlayerStatisticsData();
  4104. UpdateGuiSceneEntityItems();
  4105. UpdateEncumbranceInfo();
  4106. }
  4107.  
  4108. public final function GetCurrentlySelectedTab() : int
  4109. {
  4110. return currentlySelectedTab;
  4111. }
  4112.  
  4113. event OnMoveToStash( item : SItemUniqueId )
  4114. {
  4115. MoveToStash( item );
  4116. }
  4117.  
  4118. public function MoveToStash(item : SItemUniqueId) : void
  4119. {
  4120. var itemQuant:int;
  4121.  
  4122. if( _inv.IsItemQuest( item ) || _inv.IsItemAlchemyItem( item ) )
  4123. {
  4124. showNotification( GetLocStringByKeyExt( "inventory_cant_transfer_item" ) );
  4125. OnPlaySoundEvent( "gui_global_denied" );
  4126. return;
  4127. }
  4128.  
  4129. itemQuant = _inv.GetItemQuantity( item );
  4130.  
  4131. if (itemQuant > 1)
  4132. {
  4133. OpenQuantityPopup( item, QTF_MoveToStash, _inv.GetItemQuantity( item ) );
  4134. }
  4135. else
  4136. {
  4137. InventoryRemoveItem(item, false);
  4138. _playerInv.clearGridPosition(item);
  4139. GetWitcherPlayer().GetHorseManager().MoveItemToHorse(item, 1);
  4140. UpdateHorseInventory();
  4141. UpdateEncumbranceInfo();
  4142. }
  4143. }
  4144.  
  4145. public function handleMoveToStashQuantity(item : SItemUniqueId, quantity : int) : void
  4146. {
  4147. var itemQuant:int;
  4148.  
  4149. itemQuant = _inv.GetItemQuantity( item );
  4150.  
  4151. GetWitcherPlayer().GetHorseManager().MoveItemToHorse(item, quantity);
  4152.  
  4153. if (quantity >= itemQuant)
  4154. {
  4155. InventoryRemoveItem(item, false);
  4156. _playerInv.clearGridPosition(item);
  4157. }
  4158. else
  4159. {
  4160. InventoryUpdateItem(item);
  4161. }
  4162.  
  4163. UpdateHorseInventory();
  4164. UpdateEncumbranceInfo();
  4165. }
  4166.  
  4167. event OnTakeFromStash(item : SItemUniqueId)
  4168. {
  4169. TakeItemFromStash(item);
  4170. }
  4171.  
  4172. public function TakeItemFromStash(item : SItemUniqueId) : void
  4173. {
  4174. var newItemId : SItemUniqueId;
  4175. var filterType : EInventoryFilterType;
  4176.  
  4177. if (GetWitcherPlayer().GetHorseManager().GetInventoryComponent().IsIdValid(item))
  4178. {
  4179. newItemId = GetWitcherPlayer().GetHorseManager().MoveItemFromHorse(item, GetWitcherPlayer().GetHorseManager().GetInventoryComponent().GetItemQuantity(item));
  4180. UpdateHorseInventory();
  4181.  
  4182. filterType = _playerInv.GetFilterTypeByItem(newItemId);
  4183. _playerInv.SetFilterType( filterType );
  4184. m_fxInventoryUpdateFilter.InvokeSelfOneArg( FlashArgUInt( getTabFromFilter(filterType) ));
  4185. InventoryUpdateItem( newItemId );
  4186. UpdateEncumbranceInfo();
  4187. }
  4188. }
  4189.  
  4190. public function UpdatePinnedCraftingItemInfo() : array<name>
  4191. {
  4192. var craftedItemArray : CScriptedFlashArray;
  4193. var schematic : SCraftingSchematic;
  4194. var recipe : SAlchemyRecipe;
  4195. var enchantment : SEnchantmentSchematic;
  4196. var enchantmentIcon : string;
  4197. var enchantmentData : CScriptedFlashObject;
  4198. var ingredientsList : array<name>;
  4199. var i : int;
  4200. var pinnedRecipe : name;
  4201.  
  4202. pinnedRecipe = theGame.GetGuiManager().PinnedCraftingRecipe;
  4203. craftedItemArray = m_flashValueStorage.CreateTempFlashArray();
  4204.  
  4205. if (pinnedRecipe != '')
  4206. {
  4207. if (StrStartsWith(NameToString(pinnedRecipe), "Runeword") || StrStartsWith(NameToString(pinnedRecipe), "Glyphword"))
  4208. {
  4209. enchantment = getEnchantmentSchematicFromName(pinnedRecipe);
  4210. enchantmentData = m_flashValueStorage.CreateTempFlashObject();
  4211.  
  4212. enchantmentData.SetMemberFlashString("txtName", GetLocStringByKeyExt(enchantment.localizedName) );
  4213.  
  4214. switch (enchantment.level)
  4215. {
  4216. case 3:
  4217. enchantmentIcon = "icons/inventory/enchantments/enchantment_level3.png";
  4218. break;
  4219. case 2:
  4220. enchantmentIcon = "icons/inventory/enchantments/enchantment_level2.png";
  4221. break;
  4222. case 1:
  4223. default:
  4224. enchantmentIcon = "icons/inventory/enchantments/enchantment_level1.png";
  4225. break;
  4226. }
  4227. enchantmentData.SetMemberFlashInt("gridSize", 1);
  4228. enchantmentData.SetMemberFlashInt("quantity", -1);
  4229. enchantmentData.SetMemberFlashString("imgLoc", enchantmentIcon);
  4230. craftedItemArray.PushBackFlashObject(enchantmentData);
  4231.  
  4232. for( i = 0; i < enchantment.ingredients.Size(); i += 1 )
  4233. {
  4234. ingredientsList.PushBack(enchantment.ingredients[i].itemName);
  4235. craftedItemArray.PushBackFlashObject(CreateRecipeFlashItem(enchantment.ingredients[i].itemName, enchantment.ingredients[i].quantity));
  4236. }
  4237. }
  4238. else
  4239. {
  4240. schematic = getCraftingSchematicFromName(pinnedRecipe);
  4241.  
  4242. if (schematic.schemName != '')
  4243. {
  4244. craftedItemArray.PushBackFlashObject(CreateRecipeFlashItem(schematic.craftedItemName, -1));
  4245.  
  4246. for( i = 0; i < schematic.ingredients.Size(); i += 1 )
  4247. {
  4248. ingredientsList.PushBack(schematic.ingredients[i].itemName);
  4249. craftedItemArray.PushBackFlashObject(CreateRecipeFlashItem(schematic.ingredients[i].itemName, schematic.ingredients[i].quantity));
  4250. }
  4251. }
  4252. else
  4253. {
  4254. recipe = getAlchemyRecipeFromName(pinnedRecipe);
  4255.  
  4256. if (recipe.recipeName != '')
  4257. {
  4258. craftedItemArray.PushBackFlashObject(CreateRecipeFlashItem(recipe.cookedItemName, -1));
  4259.  
  4260. for( i = 0; i < recipe.requiredIngredients.Size(); i += 1 )
  4261. {
  4262. ingredientsList.PushBack(recipe.requiredIngredients[i].itemName);
  4263. craftedItemArray.PushBackFlashObject(CreateRecipeFlashItem(recipe.requiredIngredients[i].itemName, recipe.requiredIngredients[i].quantity));
  4264. }
  4265. }
  4266. }
  4267. }
  4268. }
  4269.  
  4270. if (craftedItemArray.GetLength() > 0)
  4271. {
  4272. m_flashValueStorage.SetFlashArray( "inventory.pinned.crafting.info", craftedItemArray );
  4273. }
  4274.  
  4275. return ingredientsList;
  4276. }
  4277.  
  4278. public function CreateRecipeFlashItem(item : name, reqQuantity : int) : CScriptedFlashObject
  4279. {
  4280. var returnObject : CScriptedFlashObject;
  4281. var dm : CDefinitionsManagerAccessor = theGame.GetDefinitionsManager();
  4282. var itemType : EInventoryFilterType;
  4283. var minQuality : int;
  4284. var maxQuality : int;
  4285. var itemInShop : bool;
  4286.  
  4287. returnObject = m_flashValueStorage.CreateTempFlashObject();
  4288.  
  4289. itemType = dm.GetFilterTypeByItem(item);
  4290.  
  4291.  
  4292. itemInShop = false;
  4293. if (_shopNpc)
  4294. {
  4295. if ( _shopNpc.GetInventory().HasItem(item) )
  4296. {
  4297. itemInShop = true;
  4298. }
  4299. }
  4300.  
  4301. returnObject.SetMemberFlashBool("highlight", itemInShop);
  4302.  
  4303. if (reqQuantity == -1)
  4304. {
  4305. returnObject.SetMemberFlashInt("quantity", -1);
  4306. }
  4307. else
  4308. {
  4309. returnObject.SetMemberFlashInt("quantity", _inv.GetItemQuantityByName(item));
  4310. }
  4311.  
  4312. returnObject.SetMemberFlashInt("reqQuantity", reqQuantity);
  4313.  
  4314. returnObject.SetMemberFlashString("imgLoc", dm.GetItemIconPath(item));
  4315.  
  4316. if (itemType == IFT_Weapons || itemType == IFT_Armors)
  4317. {
  4318. returnObject.SetMemberFlashInt("gridSize", 2);
  4319. }
  4320. else
  4321. {
  4322. returnObject.SetMemberFlashInt("gridSize", 1);
  4323. }
  4324. returnObject.SetMemberFlashString("txtName", GetLocStringByKeyExt(dm.GetItemLocalisationKeyName(item)));
  4325.  
  4326. _inv.GetItemQualityFromName(item, minQuality, maxQuality);
  4327.  
  4328. returnObject.SetMemberFlashInt("quality", minQuality);
  4329.  
  4330. return returnObject;
  4331. }
  4332.  
  4333. function PlayOpenSoundEvent()
  4334. {
  4335.  
  4336.  
  4337. }
  4338.  
  4339. //mod__hoods++ eNoodles
  4340. function HoodsAnim()
  4341. //TKMC++ eNoodles
  4342. function TKMCAnim()
  4343.  
  4344. {
  4345. PlayPaperdollAnimation('armor');
  4346. }
  4347. //--mod_hoods
  4348. //--TKMC
  4349.  
  4350. private function UpdateVitality():void
  4351. {
  4352. var value:int = RoundMath(thePlayer.GetStat(BCS_Vitality, true));
  4353. var valueMax:int = RoundMath(thePlayer.GetStatMax(BCS_Vitality));
  4354.  
  4355. m_fxSetVitality.InvokeSelfThreeArgs( FlashArgNumber(value), FlashArgNumber(0), FlashArgNumber(valueMax));
  4356. }
  4357.  
  4358. private function UpdateToxicity():void
  4359. {
  4360. var value:int = RoundMath(thePlayer.GetStat(BCS_Toxicity, false));
  4361. var valueMax:int = RoundMath(thePlayer.GetStatMax(BCS_Toxicity));
  4362.  
  4363. m_fxSetToxicity.InvokeSelfThreeArgs( FlashArgNumber(value), FlashArgNumber(0), FlashArgNumber(valueMax));
  4364. }
  4365.  
  4366.  
  4367.  
  4368.  
  4369. }
  4370.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement