Back to Home

ESO Lua File v101042

publicallingames/marketcurrency/marketcurrency_shared.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
ZO_MarketCurrency_Shared = ZO_InitializingObject:Subclass()
function ZO_MarketCurrency_Shared:Initialize(control)
    self.control = control
    local IS_PLURAL = false
    local IS_UPPER = false
    -- List order determines display order. Note: All currency types default to visible.
    self.marketCurrencyTypes =
    {
        {
            marketCurrencyType = MKCT_CROWNS,
            tooltip = zo_strformat(SI_MARKET_CURRENCY_TOOLTIP, GetCurrencyName(CURT_CROWNS, IS_PLURAL, IS_UPPER)),
        },
        {
            marketCurrencyType = MKCT_CROWN_GEMS,
            tooltip = zo_strformat(SI_MARKET_CURRENCY_TOOLTIP, GetCurrencyName(CURT_CROWN_GEMS, IS_PLURAL, IS_UPPER)),
        },
        {
            marketCurrencyType = MKCT_ENDEAVOR_SEALS,
            tooltip = zo_strformat(SI_MARKET_CURRENCY_TOOLTIP, GetCurrencyName(CURT_ENDEAVOR_SEALS, IS_PLURAL, IS_UPPER)),
        },
    }
    internalassert(MKCT_MAX_VALUE == MKCT_ENDEAVOR_SEALS, "New market currency types must be configured.")
    self.marketCurrencyTypeMap = {}
    for _, data in ipairs(self.marketCurrencyTypes) do
        data.currencyType = GetCurrencyTypeFromMarketCurrencyType(data.marketCurrencyType)
        self.marketCurrencyTypeMap[data.marketCurrencyType] = data
    end
    -- Order matters
    -- Currency layout initialization
end
function ZO_MarketCurrency_Shared:InitializeControls()
    -- To be overridden
end
function ZO_MarketCurrency_Shared:InitializeEventHandlers()
    local function OnCurrencyUpdate(_, currencyType)
        local marketCurrencyType = GetMarketCurrencyTypeFromCurrencyType(currencyType)
        if self.marketCurrencyTypeMap[marketCurrencyType] then
            self:OnMarketCurrencyUpdated(marketCurrencyType)
        end
    end
    self.control:RegisterForEvent(EVENT_CURRENCY_UPDATE, OnCurrencyUpdate)
end
function ZO_MarketCurrency_Shared:SetVisibleMarketCurrencyTypes(marketCurrencyTypes)
    local visibleMarketCurrencyTypes = {}
    if marketCurrencyTypes then
        for _, marketCurrencyType in ipairs(marketCurrencyTypes) do
            visibleMarketCurrencyTypes[marketCurrencyType] = true
        end
    end
    for marketCurrencyType, data in pairs(self.marketCurrencyTypeMap) do
        data.visible = visibleMarketCurrencyTypes[marketCurrencyType] == true
    end
end
function ZO_MarketCurrency_Shared:IsMarketCurrencyTypeVisible(marketCurrencyType)
    -- The default is true, so nil is interpreted as true
    return self.marketCurrencyTypeMap[marketCurrencyType].visible ~= false
end
function ZO_MarketCurrency_Shared:OnMarketCurrencyTypeVisibilityUpdated()
    -- To be overriden
end
function ZO_MarketCurrency_Shared:OnMarketCurrencyUpdated(currencyType)
    -- To be overridden
end