Back to Home

ESO Lua File v100031

internalingame/market/gamepad/marketclasses_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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
ZO_GAMEPAD_MARKET_INDIVIDUAL_PRODUCT_WIDTH = 407
ZO_GAMEPAD_MARKET_INDIVIDUAL_PRODUCT_HEIGHT = 270
ZO_GAMEPAD_MARKET_PRODUCT_TEMPLATE = "ZO_Gamepad_MarketProductTemplate"
ZO_GAMEPAD_MARKET_PRODUCT_BUNDLE_ATTACHMENT_TEMPLATE = "ZO_Gamepad_MarketProductBundleAttachmentTemplate"
ZO_GAMEPAD_MARKET_BLANK_TILE_TEMPLATE = "ZO_Gamepad_MarketBlankTileTemplate"
-- single tiles are 512 x 512
ZO_GAMEPAD_MARKET_INDIVIDUAL_TEXTURE_WIDTH_COORD = ZO_GAMEPAD_MARKET_INDIVIDUAL_PRODUCT_WIDTH / 512
ZO_GAMEPAD_MARKET_INDIVIDUAL_TEXTURE_HEIGHT_COORD = ZO_GAMEPAD_MARKET_INDIVIDUAL_PRODUCT_HEIGHT / 512
ZO_GAMEPAD_MARKET_ENTRY_MARKET_PRODUCT = "marketProduct"
ZO_GAMEPAD_MARKET_ENTRY_BLANK_TILE = "blankTile"
ZO_GAMEPAD_MARKET_ENTRY_FREE_TRIAL_TILE = "freeTrialTile"
ZO_GAMEPAD_MARKET_ENTRY_MEMBERSHIP_INFO_TILE = "membershipInfoTile"
--
--[[ Gamepad Market Product ]]--
--
ZO_GamepadMarketProduct = ZO_LargeSingleMarketProduct_Base:Subclass()
function ZO_GamepadMarketProduct:New(...)
    return ZO_LargeSingleMarketProduct_Base.New(self, ...)
end
function ZO_GamepadMarketProduct:Initialize(controlId, parent, controlName)
    local controlTemplate = self:GetTemplate()
    local control = CreateControlFromVirtual(controlName or controlTemplate, parent, controlTemplate, controlId)
    ZO_LargeSingleMarketProduct_Base.Initialize(self, control)
    self.focusData =
    {
        control = self.control,
        highlight = self.control.highlight,
        object = self,
    }
end
-- override of ZO_MarketProductBase:GetEsoPlusIcon()
function ZO_GamepadMarketProduct:GetEsoPlusIcon()
    return zo_iconFormatInheritColor("EsoUI/Art/Market/Gamepad/gp_ESOPlus_Chalice_WHITE_64.dds", "100%", "100%")
end
function ZO_GamepadMarketProduct:GetTemplate()
    return ZO_GAMEPAD_MARKET_PRODUCT_TEMPLATE
end
function ZO_GamepadMarketProduct:UpdateProductStyle()
    ZO_LargeSingleMarketProduct_Base.UpdateProductStyle(self)
     if self:IsPurchaseLocked() then
        self.control.highlightNormal:SetEdgeColor(ZO_MARKET_PRODUCT_PURCHASED_COLOR:UnpackRGB())
    else
        self.control.highlightNormal:SetEdgeColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGB())
    end
end
function ZO_GamepadMarketProduct:GetFocusData()
    return self.focusData
end
function ZO_GamepadMarketProduct:SetListIndex(listIndex)
    self.listIndex = listIndex
end
function ZO_GamepadMarketProduct:GetListIndex()
    return self.listIndex
end
-- Used for cycling through preview items in the preview screen
function ZO_GamepadMarketProduct:SetPreviewIndex(previewIndex)
    self.previewIndex = previewIndex
end
function ZO_GamepadMarketProduct:GetPreviewIndex()
    return self.previewIndex
end
function ZO_GamepadMarketProduct:GetEntryType()
    return ZO_GAMEPAD_MARKET_ENTRY_MARKET_PRODUCT
end
-- override of ZO_MarketProductBase:AnchorBundledProductsLabel()
function ZO_GamepadMarketProduct:AnchorBundledProductsLabel()
    local control = self.control
    local numBundledProductsLabel = control.numBundledProductsLabel
    numBundledProductsLabel:ClearAnchors()
    local canBePurchased = self:CanBePurchased()
    if canBePurchased then
        if self:HasEsoPlusCost() then
            numBundledProductsLabel:SetAnchor(BOTTOMRIGHT, control.esoPlusDealLabelControl, TOPRIGHT, 0, 5)
        else
            numBundledProductsLabel:SetAnchor(BOTTOMRIGHT, control, BOTTOMRIGHT, -20, -10)
        end
    else
        numBundledProductsLabel:SetAnchor(BOTTOMRIGHT, control.purchaseLabelControl, TOPRIGHT, 0, 5)
    end
end
-- override of ZO_MarketProductBase:AnchorLabelBetweenBundleIndicatorAndCost(label)
function ZO_GamepadMarketProduct:AnchorLabelBetweenBundleIndicatorAndCost(label)
    label:ClearAnchors()
    local control = self.control
    label:SetAnchor(BOTTOMRIGHT, control, BOTTOMRIGHT, -20, -10)
    -- anchor the left side to the right-most cost label
    if self:HasEsoPlusCost() then
        label:SetAnchor(BOTTOMLEFT, control.esoPlusCost, BOTTOMRIGHT, 10, 0, ANCHOR_CONSTRAINS_X)
    elseif self:HasCost() then
        label:SetAnchor(BOTTOMLEFT, control.cost, BOTTOMRIGHT, 10, 0, ANCHOR_CONSTRAINS_X)
    else
        -- we shouldn't hit this case
        label:SetAnchor(BOTTOMLEFT, control, BOTTOMLEFT, 10, 0, ANCHOR_CONSTRAINS_X)
    end
end
--
--[[ Gamepad Market Product Bundle Attachment ]]--
--
ZO_GamepadMarketProductBundleAttachment = ZO_GamepadMarketProduct:Subclass()
function ZO_GamepadMarketProductBundleAttachment:New(...)
    return ZO_GamepadMarketProduct.New(self, ...)
end
function ZO_GamepadMarketProductBundleAttachment:GetTemplate()
    return ZO_GAMEPAD_MARKET_PRODUCT_BUNDLE_ATTACHMENT_TEMPLATE
end
function ZO_GamepadMarketProductBundleAttachment:GetMarketProductDisplayState()
    local parentDisplayState = ZO_GetMarketProductDisplayState(self.bundleMarketProductId)
    if parentDisplayState == MARKET_PRODUCT_DISPLAY_STATE_PURCHASED then
        return parentDisplayState
    end
    return ZO_GamepadMarketProduct.GetMarketProductDisplayState(self)
end
function ZO_GamepadMarketProductBundleAttachment:Show(...)
    ZO_GamepadMarketProduct.Show(self, ...)
    local allCollectiblesOwned = self:AreAllCollectiblesUnlocked()
    local control = self.control
    control.purchaseLabelControl:SetHidden(not allCollectiblesOwned)
    if allCollectiblesOwned then
        control.purchaseLabelControl:SetText(GetString("SI_COLLECTIBLEUNLOCKSTATE", COLLECTIBLE_UNLOCK_STATE_UNLOCKED_OWNED))
    end
    -- hide all the price info
    control.cost:SetHidden(true)
    control.previousCost:SetHidden(true)
    control.textCallout:SetHidden(true)
end
-- override of ZO_LargeSingleMarketProduct_Base:LayoutTooltip(tooltip)
function ZO_GamepadMarketProductBundleAttachment:LayoutTooltip(tooltip)
    GAMEPAD_TOOLTIPS:LayoutMarketProduct(tooltip, self:GetId())
end
function ZO_GamepadMarketProductBundleAttachment:SetBundleMarketProductId(bundleMarketProductId)
    self.bundleMarketProductId = bundleMarketProductId
end
function ZO_GamepadMarketProductBundleAttachment:IsPurchaseLocked()
     return ZO_GetMarketProductDisplayState(self.bundleMarketProductId) ~= MARKET_PRODUCT_DISPLAY_STATE_NOT_PURCHASED or ZO_GamepadMarketProduct.IsPurchaseLocked(self)
end
function ZO_GamepadMarketProductBundleAttachment:Reset()
    ZO_GamepadMarketProduct.Reset(self)
    self.bundleMarketProductId = nil
end
--
--[[ Gamepad Market Blank Tile ]]--
--
ZO_GamepadMarketBlankTile = ZO_Object:Subclass()
function ZO_GamepadMarketBlankTile:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_GamepadMarketBlankTile:Initialize(control)
    self.control = control
    self.highlightControl = control:GetNamedChild("Highlight")
    self.focusData =
    {
        control = control,
        highlight = self.highlightControl,
        object = self,
    }
end
function ZO_GamepadMarketBlankTile:GetControl()
    return self.control
end
function ZO_GamepadMarketBlankTile:GetFocusData()
    return self.focusData
end
function ZO_GamepadMarketBlankTile:SetListIndex(listIndex)
    self.listIndex = listIndex
end
function ZO_GamepadMarketBlankTile:GetListIndex()
    return self.listIndex
end
function ZO_GamepadMarketBlankTile:SetIsFocused(isFocused)
    if self.isFocused ~= isFocused then
        self.isFocused = isFocused
    end
end
function ZO_GamepadMarketBlankTile:GetEntryType()
    return ZO_GAMEPAD_MARKET_ENTRY_BLANK_TILE
end
function ZO_GamepadMarketBlankTile:Show()
    self.control:SetHidden(false)
end
function ZO_GamepadMarketBlankTile:Refresh()
    -- nothing to refresh
end
function ZO_GamepadMarketBlankTile:Reset()
    self.control:SetHidden(true)
end
--
--[[ Gamepad Market Generic Tile ]]--
--
ZO_GamepadMarketGenericTile = ZO_Object:Subclass()
function ZO_GamepadMarketGenericTile:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_GamepadMarketGenericTile:Initialize(control)
    self.control = control
    self.focusData =
    {
        control = control,
        highlight = control.highlight,
        object = self,
    }
    self:Reset()
end
function ZO_GamepadMarketGenericTile:GetControl()
    return self.control
end
function ZO_GamepadMarketGenericTile:GetFocusData()
    return self.focusData
end
function ZO_GamepadMarketGenericTile:SetListIndex(listIndex)
    self.listIndex = listIndex
end
function ZO_GamepadMarketGenericTile:GetListIndex()
    return self.listIndex
end
function ZO_GamepadMarketGenericTile:SetIsFocused(isFocused)
    if self.isFocused ~= isFocused then
        self.isFocused = isFocused
        self:UpdateProductStyle()
    end
end
function ZO_GamepadMarketGenericTile:SetEntryType(entryType)
    self.entryType = entryType
end
function ZO_GamepadMarketGenericTile:GetEntryType()
    return self.entryType
end
function ZO_GamepadMarketGenericTile:SetBackground(backgroundTexture)
    self.control.backgroundTexture:SetTexture(backgroundTexture)
end
function ZO_GamepadMarketGenericTile:SetTitle(titleStringOrFunction)
end
function ZO_GamepadMarketGenericTile:GetTitle()
    if type(self.titleStringOrFunction) == "function" then
        return self.titleStringOrFunction()
    else
        return self.titleStringOrFunction
    end
end
function ZO_GamepadMarketGenericTile:SetTitleColors(selectedColor, unselectedColor)
    self.titleSelectedColor = selectedColor or self.titleSelectedColor
    self.titleUnselectedColor = unselectedColor or self.titleUnselectedColor
end
function ZO_GamepadMarketGenericTile:SetTitlePurchasedColors(selectedColor, unselectedColor)
    self.titlePurchasedSelectedColor = selectedColor or self.titlePurchasedSelectedColor
    self.titlePurchasedUnselectedColor = unselectedColor or self.titlePurchasedUnselectedColor
end
function ZO_GamepadMarketGenericTile:UpdateTitleLabel()
    local titleLabel = self.control.titleLabel
    if self:IsPurchased() then
        if self.isFocused then
            titleLabel:SetColor(self.titlePurchasedSelectedColor:UnpackRGB())
        else
            titleLabel:SetColor(self.titlePurchasedUnselectedColor:UnpackRGB())
        end
    else
        if self.isFocused then
            titleLabel:SetColor(self.titleSelectedColor:UnpackRGB())
        else
            titleLabel:SetColor(self.titleUnselectedColor:UnpackRGB())
        end
    end
    titleLabel:SetText(self:GetTitle())
end
function ZO_GamepadMarketGenericTile:SetText(textStringOrFunction)
end
function ZO_GamepadMarketGenericTile:GetText()
    if type(self.textStringOrFunction) == "function" then
        return self.textStringOrFunction()
    else
        return self.textStringOrFunction
    end
end
function ZO_GamepadMarketGenericTile:SetTextColors(selectedColor, unselectedColor)
    self.textSelectedColor = selectedColor or self.textSelectedColor
    self.textUnselectedColor = unselectedColor or self.textUnselectedColor
end
function ZO_GamepadMarketGenericTile:SetTextPurchasedColors(selectedColor, unselectedColor)
    self.textPurchasedSelectedColor = selectedColor or self.textPurchasedSelectedColor
    self.textPurchasedUnselectedColor = unselectedColor or self.textPurchasedUnselectedColor
end
function ZO_GamepadMarketGenericTile:UpdateTextLabel()
    local textLabel = self.control.textLabel
    if self:IsPurchased() then
        if self.isFocused then
            textLabel:SetColor(self.textPurchasedSelectedColor:UnpackRGB())
        else
            textLabel:SetColor(self.textPurchasedUnselectedColor:UnpackRGB())
        end
    else
        if self.isFocused then
            textLabel:SetColor(self.textSelectedColor:UnpackRGB())
        else
            textLabel:SetColor(self.textUnselectedColor:UnpackRGB())
        end
    end
    textLabel:SetText(self:GetText())
end
function ZO_GamepadMarketGenericTile:SetPurchaseCheckFunction(purchaseCheckFunction)
end
function ZO_GamepadMarketGenericTile:IsPurchased()
    if self.purchaseCheckFunction then
        return self.purchaseCheckFunction()
    else
        return false
    end
end
function ZO_GamepadMarketGenericTile:Show()
    self.control:SetHidden(false)
end
function ZO_GamepadMarketGenericTile:UpdateProductStyle()
    local isPurchased = self:IsPurchased()
    if isPurchased then
        self.control.highlightNormal:SetEdgeColor(ZO_MARKET_PRODUCT_PURCHASED_COLOR:UnpackRGB())
    else
        self.control.highlightNormal:SetEdgeColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGB())
    end
    local backgroundColor = self.isFocused and ZO_MARKET_PRODUCT_BACKGROUND_BRIGHTNESS_COLOR or ZO_MARKET_DIMMED_COLOR
    self.control.backgroundTexture:SetColor(backgroundColor:UnpackRGB())
    local backgroundDesaturation = isPurchased and ZO_MARKET_PRODUCT_PURCHASED_DESATURATION or ZO_MARKET_PRODUCT_NOT_PURCHASED_DESATURATION
    self.control.backgroundTexture:SetDesaturation(backgroundDesaturation)
end
function ZO_GamepadMarketGenericTile:Refresh()
end
function ZO_GamepadMarketGenericTile:Reset()
    self.control:SetHidden(true)
    self.entryType = nil
    self.purchaseCheckFunction = nil
    self.titleStringOrFunction = ""
    self.titleSelectedColor = ZO_MARKET_SELECTED_COLOR
    self.titleUnselectedColor = ZO_MARKET_DIMMED_COLOR
    self.titlePurchasedSelectedColor = ZO_MARKET_PRODUCT_PURCHASED_COLOR
    self.titlePurchasedUnselectedColor = ZO_MARKET_PRODUCT_PURCHASED_DIMMED_COLOR
    self.textStringOrFunction = ""
    self.textSelectedColor = ZO_MARKET_SELECTED_COLOR
    self.textUnselectedColor = ZO_MARKET_DIMMED_COLOR
    self.textPurchasedSelectedColor = ZO_MARKET_PRODUCT_PURCHASED_COLOR
    self.textPurchasedUnselectedColor = ZO_MARKET_PRODUCT_PURCHASED_DIMMED_COLOR
end
--
--[[ XML Handlers ]]--
--
    control.highlight = control:GetNamedChild("Highlight")
    control.highlightNormal = control:GetNamedChild("HighlightNormal")
end
    control.backgroundTexture = control:GetNamedChild("Background")
    control.highlight = control:GetNamedChild("Highlight")
    control.highlightNormal = control:GetNamedChild("HighlightNormal")
    control.titleLabel = control:GetNamedChild("Title")
    control.textLabel = control:GetNamedChild("Text")
end