@@ -26,17 +26,19 @@ private final func Init() -> Void {
2626
2727@wrapMethod(FullscreenVendorGameController)
2828protected cb func OnInventoryItemHoverOver(evt: ref<ItemDisplayHoverOverEvent > ) -> Bool {
29- let targetItem: InventoryItemData = evt.itemData;
3029 let wrapped: Bool = wrappedMethod(evt);
31- let sellStackLocalizedText: String ;
30+ let controller = inkWidgetRef.GetController(this.m_sortingDropdown) as DropdownListController ;
3231
33- if !IsDefined(this.m_storageUserData) && IsDefined(this.m_vendorUserData) {
34- if InventoryItemData.IsVendorItem(targetItem) {
35- this.m_buttonHintsController.AddButtonHint(this.fFastButton, this.fFastBuyText);
36- }
37- else {
38- if this.m_VendorDataManager.CanPlayerSellItem(InventoryItemData.GetID(targetItem)) {
39- this.m_buttonHintsController.AddButtonHint(this.fFastButton, this.fFastSellText);
32+ // Bugfix by CDPR: Ignore hover over event when the sorting dropdown is open
33+ if !controller.IsOpened() {
34+ if !IsDefined(this.m_storageUserData) && IsDefined(this.m_vendorUserData) {
35+ if Equals(evt.displayContextData.GetDisplayContext(), ItemDisplayContext.Vendor) {
36+ this.m_buttonHintsController.AddButtonHint(this.fFastButton, this.fFastBuyText);
37+ }
38+ else {
39+ if this.m_VendorDataManager.CanPlayerSellItem(evt.uiInventoryItem.GetID()) && !evt.uiInventoryItem.IsIconic() {
40+ this.m_buttonHintsController.AddButtonHint(this.fFastButton, this.fFastSellText);
41+ }
4042 }
4143 }
4244 }
@@ -51,23 +53,68 @@ protected cb func OnInventoryItemHoverOut(evt: ref<ItemDisplayHoverOutEvent>) ->
5153}
5254
5355@wrapMethod(FullscreenVendorGameController)
54- private final func HandleVendorSlotInput(evt: ref<ItemDisplayClickEvent > , itemData: InventoryItemData) -> Void {
55- wrappedMethod(evt, itemData);
56+ private final func HandleVendorSlotInput(evt: ref<ItemDisplayClickEvent > ) -> Void {
57+ let targetItem: wref<UIInventoryItem> = evt.uiInventoryItem;
58+ let vendorNotification: ref<UIMenuNotificationEvent>;
5659
57- if evt.actionName.IsAction(this.fFastButton) {
58- let maxQty: Int32;
60+ wrappedMethod(evt);
5961
60- if (InventoryItemData.IsVendorItem(itemData)) {
61- maxQty = this.flibGetMaxQuantity(itemData, QuantityPickerActionType.Buy);
62- this.BuyItem(InventoryItemData.GetGameItemData(itemData), maxQty);
63- this.PlaySound(n"Item", n"OnBuy");
64- }
65- else {
66- maxQty = this.flibGetMaxQuantity(itemData, QuantityPickerActionType.Sell);
67- this.SellItem(InventoryItemData.GetGameItemData(itemData), maxQty);
68- this.PlaySound(n"Item", n"OnSell");
62+ if evt.actionName.IsAction(this.fFastButton) && IsDefined(targetItem) {
63+ let maxQty: Int32 = 0;
64+
65+ switch evt.displayContextData.GetDisplayContext() {
66+ case ItemDisplayContext.Vendor:
67+ maxQty = this.flibGetMaxPurchasable(targetItem, QuantityPickerActionType.Buy);
68+ // CDPR new logic for ammo limits
69+ if (maxQty == 0) {
70+ vendorNotification = new UIMenuNotificationEvent();
71+ vendorNotification.m_notificationType = UIMenuNotificationType.CraftingAmmoCap;
72+ GameInstance.GetUISystem(this.m_player.GetGame()).QueueEvent(vendorNotification);
73+ this.PlaySound(n"MapPin", n"OnDelete");
74+ }
75+ else {
76+ this.BuyItem(targetItem.GetItemData(), maxQty, evt.isBuybackStack);
77+ this.PlaySound(n"Item", n"OnBuy");
78+ this.m_TooltipsManager.HideTooltips();
79+ }
80+ break;
81+ case ItemDisplayContext.VendorPlayer:
82+ // Don't fast sell iconics
83+ if targetItem.IsIconic() {
84+ this.OpenConfirmationPopup(targetItem, targetItem.GetQuantity(), QuantityPickerActionType.Sell);
85+ }
86+ else {
87+ maxQty = this.flibGetMaxPurchasable(targetItem, QuantityPickerActionType.Sell);
88+ this.SellItem(targetItem.GetItemData(), maxQty);
89+ this.PlaySound(n"Item", n"OnSell");
90+ }
91+ break;
92+ default:
93+ break;
6994 }
95+ }
96+ }
97+
98+ @addMethod(FullscreenVendorGameController)
99+ private func flibGetMaxPurchasable(item: wref<UIInventoryItem > , actionType: QuantityPickerActionType) -> Int32 {
100+ let price: Int32 = this.GetPrice(item.GetItemData(), actionType, 1);
101+ let maxQty: Int32 = this.GetMaxQuantity(item, Equals(actionType, QuantityPickerActionType.Sell));
102+ let money: Int32 = 0;
70103
71- this.m_TooltipsManager.HideTooltips();
104+ if (price <= 0) {
105+ return maxQty;
72106 }
107+
108+ switch (actionType) {
109+ case QuantityPickerActionType.Sell:
110+ money = MarketSystem.GetVendorMoney(this.m_VendorDataManager.GetVendorInstance());
111+ break;
112+ case QuantityPickerActionType.Buy:
113+ money = this.m_VendorDataManager.GetLocalPlayerCurrencyAmount();
114+ break;
115+ default:
116+ return maxQty;
117+ }
118+
119+ return Min(maxQty, money / price);
73120}
0 commit comments