Advertisement
Guest User

inventorymenu.ws

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