Back to Home

ESO Lua File v101042

ingame/fence/gamepad/fencewindowsell_gamepad.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
ZO_GamepadFenceSell = ZO_GamepadFenceComponent:Subclass()
function ZO_GamepadFenceSell:Initialize()
    ZO_GamepadFenceComponent.Initialize(self, ZO_MODE_STORE_SELL_STOLEN, GetString(SI_STORE_MODE_SELL))
    self:InitializeKeybindStrip(GetString(SI_ITEM_ACTION_SELL))
    self:CreateModeData(SI_STORE_MODE_SELL, self.mode, "EsoUI/Art/Vendor/vendor_tabIcon_sell_up.dds", self.fragment, self.keybindStripDescriptor)
    self.list:SetNoItemText(GetString(SI_GAMEPAD_NO_STOLEN_ITEMS_SELL))
end
function ZO_GamepadFenceSell:GetRemainingSells()
    local totalSells, sellsUsed = GetFenceSellTransactionInfo()
    return zo_max(totalSells - sellsUsed, 0)
end
do
    local IGNORE_INVALID_COST = true
    function ZO_GamepadFenceSell:Confirm()
        local remainingSells = self:GetRemainingSells()
        if remainingSells == 0 then
            ZO_Alert(UI_ALERT_CATEGORY_ALERT, SOUNDS.NEGATIVE_CLICK, GetString("SI_STOREFAILURE", STORE_FAILURE_AT_FENCE_LIMIT))
            return
        end
        local targetData = self.list:GetTargetData()
        local itemData = {}
        itemData.bag, itemData.slot = ZO_Inventory_GetBagAndIndex(targetData)
        itemData.itemName = targetData.text
        itemData.functionalQuality = GetItemFunctionalQuality(itemData.bag, itemData.slot)
        itemData.displayQuality = GetItemDisplayQuality(itemData.bag, itemData.slot)
        -- itemData.quality is deprecated, included here for addon backwards compatibility
        itemData.quality = itemData.functionalQuality
        itemData.stackCount = targetData.stackCount
        if self.confirmationMode then
            itemData.stackCount = STORE_WINDOW_GAMEPAD:GetSpinnerValue()
            if itemData.stackCount > 0 then
                if itemData.functionalQuality >= ITEM_FUNCTIONAL_QUALITY_ARTIFACT then
                    ZO_Dialogs_ShowGamepadDialog("CANT_BUYBACK_FROM_FENCE", itemData)
                else
                    SellInventoryItem(itemData.bag, itemData.slot, itemData.stackCount)
                end
                self:UnselectItem()
            end
        else
            if itemData.stackCount > 1 then
                self:SelectItem(IGNORE_INVALID_COST)
                local spinnerMax = zo_min(itemData.stackCount, remainingSells)
                local calcSellPrice = GetItemSellValueWithBonuses(itemData.bag, itemData.slot)
                STORE_WINDOW_GAMEPAD:SetupSpinner(spinnerMax, spinnerMax, calcSellPrice, targetData.currencyType1)
            else
                if itemData.functionalQuality >= ITEM_FUNCTIONAL_QUALITY_ARTIFACT then
                    ZO_Dialogs_ShowGamepadDialog("CANT_BUYBACK_FROM_FENCE", itemData)
                else
                    SellInventoryItem(itemData.bag, itemData.slot, 1)
                end
            end
        end
    end
end
function ZO_GamepadFenceSell:RefreshFooter()
    self:ClearFooter()
    local data = {}
    local hagglingSkillLevel = FENCE_MANAGER:GetHagglingBonus()
    if hagglingSkillLevel > 0 then
        data.data1HeaderText = GetString(SI_GAMEPAD_FENCE_HAGGLING_SKILL_NAME)
        data.data1Text = zo_strformat(SI_GAMEPAD_FENCE_HAGGLING_BONUS, hagglingSkillLevel)
        data.data1Color = ZO_CURRENCY_HIGHLIGHT_TEXT
    end
    if self:GetRemainingSells() == 0 then
        local footerLabel = GetString(SI_FENCE_SELL_LIMIT_RESET)
        local resetTimeSeconds = select(3, GetFenceSellTransactionInfo())
        local footerValue = ZO_FormatTimeMilliseconds(resetTimeSeconds * 1000, TIME_FORMAT_STYLE_COLONS, TIME_FORMAT_PRECISION_TWELVE_HOUR)
        if hagglingSkillLevel > 0 then
            data.data2HeaderText = footerLabel
            data.data2Text = footerValue
        else
            data.data1HeaderText = footerLabel
            data.data1Text = footerValue
        end
    end
    
    GAMEPAD_GENERIC_FOOTER:Refresh(data)
end
function ZO_GamepadFenceSell:SetupEntry(control, data, selected, selectedDuringRebuild, enabled, activated)
    local calcSellPrice = GetItemSellValueWithBonuses(data.bagId, data.slotIndex)
    if self.confirmationMode and selected then
        calcSellPrice = calcSellPrice * STORE_WINDOW_GAMEPAD:GetSpinnerValue()
    end
    self:SetupStoreItem(control, data, selected, selectedDuringRebuild, enabled, activated, calcSellPrice, ZO_STORE_FORCE_VALID_PRICE, self.mode)
end
    FENCE_SELL_GAMEPAD = ZO_GamepadFenceSell:New()
    STORE_WINDOW_GAMEPAD:AddComponent(FENCE_SELL_GAMEPAD)
end
function ZO_GamepadFenceSell:GetCurrencyOptions()
    return ZO_GAMEPAD_FENCE_CURRENCY_OPTIONS
end