Back to Home

ESO Lua File v101044

ingame/housingeditor/gamepad/housingfurnitureproducts_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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
ZO_HousingFurnitureProducts_Gamepad = ZO_HousingFurnitureList_Gamepad:Subclass()
function ZO_HousingFurnitureProducts_Gamepad:New(...)
    return ZO_HousingFurnitureList_Gamepad.New(self, ...)
end
function ZO_HousingFurnitureProducts_Gamepad:Initialize(owner)
    ZO_HousingFurnitureList_Gamepad.Initialize(self, owner)
    SHARED_FURNITURE:RegisterCallback("MarketProductsChanged", function(fromSearch)
        if fromSearch then
            self:ResetSavedPositions()
        end
    end)
end
function ZO_HousingFurnitureProducts_Gamepad:InitializeKeybindStripDescriptors()
    ZO_HousingFurnitureList_Gamepad.InitializeKeybindStripDescriptors(self)
    -- purchase
        {
            name = GetString(SI_HOUSING_FURNITURE_BROWSER_PURCHASE_KEYBIND),
            keybind = "UI_SHORTCUT_PRIMARY",
            callback = function()
                local targetData = self.furnitureList.list:GetTargetData()
                if targetData then
                    local furnitureObject = targetData.furnitureObject
                    local IS_PURCHASE = false
                    RequestPurchaseMarketProduct(furnitureObject.marketProductId, furnitureObject.presentationIndex, IS_PURCHASE)
                end
            end,
            enabled = function()
                local targetData = self.furnitureList.list:GetTargetData()
                if targetData == nil then
                    return false
                else
                    local furnitureObject = targetData.furnitureObject
                    if not furnitureObject:CanBePurchased() then
                        local expectedPurchaseResult = CouldPurchaseMarketProduct(furnitureObject.marketProductId, furnitureObject.presentationIndex)
                        return false, GetString("SI_MARKETPURCHASABLERESULT", expectedPurchaseResult)
                    end
                end
                return true
            end,
        }
    )
    -- placement preview
        {
            name = GetString(SI_HOUSING_EDITOR_PREVIEW_PLACEMENT),
            keybind = "UI_SHORTCUT_QUINARY",
            callback = function()
                local targetData = self.furnitureList.list:GetTargetData()
                if targetData then
                    local furnitureObject = targetData.furnitureObject
                    self:PreviewMarketProductPlacement(furnitureObject)
                end
            end,
            visible = function()
                local targetData = self.furnitureList.list:GetTargetData()
                if targetData then
                    local furnitureObject = targetData.furnitureObject
                    return furnitureObject:CanPreviewPlacement()
                end
                return false
            end,
        }
    )
    -- gift
        {
            name = GetString(SI_HOUSING_FURNITURE_BROWSER_GIFT_KEYBIND),
            keybind = "UI_SHORTCUT_RIGHT_STICK",
            visible =  function()
                            local targetData = self.furnitureList.list:GetTargetData()
                            if targetData then
                                local furnitureObject = targetData.furnitureObject
                                return IsMarketProductGiftable(furnitureObject.marketProductId, furnitureObject.presentationIndex)
                            end
                            return false
                        end,
            callback =  function()
                            local targetData = self.furnitureList.list:GetTargetData()
                            if targetData then
                                local furnitureObject = targetData.furnitureObject
                                local IS_GIFT = true
                                RequestPurchaseMarketProduct(furnitureObject.marketProductId, furnitureObject.presentationIndex, IS_GIFT)
                            end
                        end,
        }
    )
    local buyCrownsKeybind = MARKET_CURRENCY_GAMEPAD:GetBuyCrownsKeybind("UI_SHORTCUT_SECONDARY")
    self:AddFurnitureListKeybind(buyCrownsKeybind)
    table.insert(self.categoryKeybindStripDescriptor, buyCrownsKeybind)
end
function ZO_HousingFurnitureProducts_Gamepad:GetCategoryTreeDataRoot()
    return SHARED_FURNITURE:GetMarketProductCategoryTreeData()
end
function ZO_HousingFurnitureProducts_Gamepad:CompareFurnitureEntries(a, b)
    -- Primary order: New products before existing products.
    if a.isNew then
        if not b.isNew then
            return true
        end
    elseif b.isNew then
        return false
    end
    -- Secondary order: Product name in ascending alphabetical order.
    return ZO_HousingFurnitureList_Gamepad.CompareFurnitureEntries(self, a, b)
end
function ZO_HousingFurnitureProducts_Gamepad:OnFurnitureTargetChanged(list, targetData, oldTargetData)
    ZO_HousingFurnitureList_Gamepad.OnFurnitureTargetChanged(self, list, targetData, oldTargetData)
    ZO_HousingFurnitureBrowser_Base.PreviewFurniture(targetData.furnitureObject)
end
function ZO_HousingFurnitureProducts_Gamepad:GetNoItemText()
    if SHARED_FURNITURE:AreThereMarketProducts() then
        return GetString(SI_HOUSING_FURNITURE_NO_SEARCH_RESULTS)
    else
        return GetString(SI_HOUSING_FURNITURE_NO_MARKET_PRODUCTS)
    end
end
function ZO_HousingFurnitureProducts_Gamepad:OnShowing()
    ZO_HousingFurnitureList_Gamepad.OnShowing(self)
    UpdateMarketDisplayGroup(MARKET_DISPLAY_GROUP_HOUSE_EDITOR)
    MARKET_CURRENCY_GAMEPAD:SetVisibleMarketCurrencyTypes({MKCT_CROWNS, MKCT_CROWN_GEMS})
    MARKET_CURRENCY_GAMEPAD:Show()
end
function ZO_HousingFurnitureProducts_Gamepad:UpdateCurrentKeybinds()
    ZO_HousingFurnitureList_Gamepad.UpdateCurrentKeybinds(self)
    local currencyStyle = MARKET_CURRENCY_GAMEPAD:ModifyKeybindStripStyleForCurrency(KEYBIND_STRIP_GAMEPAD_STYLE)
    KEYBIND_STRIP:SetStyle(currencyStyle)
end
function ZO_HousingFurnitureProducts_Gamepad:OnHiding()
    ZO_HousingFurnitureList_Gamepad.OnHiding(self)
    MARKET_CURRENCY_GAMEPAD:Hide()
    KEYBIND_STRIP:SetStyle(KEYBIND_STRIP_GAMEPAD_STYLE)
end
function ZO_HousingFurnitureProducts_Gamepad:RequestPurchase(data, isGift)
    GAMEPAD_TOOLTIPS:ClearTooltip(GAMEPAD_RIGHT_TOOLTIP)
    RequestPurchaseMarketProduct(data.marketProductId, data.presentationIndex, isGift)
end