Advertisement
Nevermoon

Untitled

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