Guest User

Untitled

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