Back to Home

ESO Lua File v100034

ingame/guild/guildhistory_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
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
GUILD_HISTORY_CATEGORIES =
{
    [GUILD_HISTORY_GENERAL] =
    {
        up = "EsoUI/Art/Guild/guildHistory_indexIcon_guild_up.dds",
        down = "EsoUI/Art/Guild/guildHistory_indexIcon_guild_down.dds",
        over = "EsoUI/Art/Guild/guildHistory_indexIcon_guild_over.dds",
        subcategoryEnumName = "SI_GUILDHISTORYGENERALSUBCATEGORIES",
        subcategories = 
        {
            [GUILD_HISTORY_GENERAL_ROSTER] =
            {
                gamepadIcon = "EsoUI/Art/Guild/gamepad/gp_guild_menuIcon_roster.dds",
                events = {
                    [GUILD_EVENT_GUILD_CREATE] = true,
                    [GUILD_EVENT_GUILD_INVITE] = true,
                    [GUILD_EVENT_GUILD_JOIN] = true,
                    [GUILD_EVENT_GUILD_PROMOTE] = true,
                    [GUILD_EVENT_GUILD_DEMOTE] = true,
                    [GUILD_EVENT_GUILD_KICKED] = true,
                    [GUILD_EVENT_GUILD_LEAVE] = true,
                    [GUILD_EVENT_GUILD_APPLICATION_DECLINED] = true,
                    [GUILD_EVENT_GUILD_APPLICATION_ACCEPTED] = true,
                    [GUILD_EVENT_REMOVED_FROM_BLACKLIST] = true,
                    [GUILD_EVENT_ADDED_TO_BLACKLIST] = true,
                }
            },
            [GUILD_HISTORY_GENERAL_CUSTOMIZATION] =
            {
                gamepadIcon = "EsoUI/Art/Guild/gamepad/gp_guild_menuIcon_customization.dds",
                events = {
                    [GUILD_EVENT_BANKGOLD_PURCHASE_HERALDRY] = true,
                    [GUILD_EVENT_HERALDRY_EDITED] = true,
                    [GUILD_EVENT_MOTD_EDITED] = true,
                    [GUILD_EVENT_ABOUT_US_EDITED] = true,
                    [GUILD_EVENT_GUILD_RECRUITMENT_GUILD_LISTED] = true,
                    [GUILD_EVENT_GUILD_RECRUITMENT_GUILD_UNLISTED] = true,
                }
            },
            [GUILD_HISTORY_GENERAL_UNLOCKS] =
            {
                gamepadIcon = "EsoUI/Art/Guild/gamepad/gp_guild_menuIcon_unlocks.dds",
                events = {
                    [GUILD_EVENT_GUILD_BANK_LOCKED] = true,
                    [GUILD_EVENT_GUILD_BANK_UNLOCKED] = true,
                    [GUILD_EVENT_GUILD_KIOSK_LOCKED] = true,
                    [GUILD_EVENT_GUILD_KIOSK_UNLOCKED] = true,
                    [GUILD_EVENT_GUILD_STANDARD_LOCKED] = true,
                    [GUILD_EVENT_GUILD_STANDARD_UNLOCKED] = true,
                    [GUILD_EVENT_GUILD_STORE_LOCKED] = true,
                    [GUILD_EVENT_GUILD_STORE_UNLOCKED] = true,
                    [GUILD_EVENT_GUILD_TABARD_LOCKED] = true,
                    [GUILD_EVENT_GUILD_TABARD_UNLOCKED] = true,
                }
            },
        },
    },
    [GUILD_HISTORY_BANK] =
    {
        up = "EsoUI/Art/Guild/guildHistory_indexIcon_guildBank_up.dds",
        down = "EsoUI/Art/Guild/guildHistory_indexIcon_guildBank_down.dds",
        over = "EsoUI/Art/Guild/guildHistory_indexIcon_guildBank_over.dds",
        
        subcategoryEnumName = "SI_GUILDHISTORYBANKSUBCATEGORIES",
        subcategories = 
        {
            [GUILD_HISTORY_BANK_DEPOSITS] =
            {
                gamepadIcon = "EsoUI/Art/Guild/gamepad/gp_guild_menuIcon_deposits.dds",
                events = {
                    [GUILD_EVENT_BANKITEM_ADDED] = true,
                    [GUILD_EVENT_BANKGOLD_ADDED] = true,
                    [GUILD_EVENT_BANKGOLD_KIOSK_BID_REFUND] = true,
                },
                gatingPermission = GUILD_PERMISSION_BANK_VIEW_DEPOSIT_HISTORY,
            },
            [GUILD_HISTORY_BANK_WITHDRAWALS] =
            {
                gamepadIcon = "EsoUI/Art/Guild/gamepad/gp_guild_menuIcon_withdrawals.dds",
                events = {
                    [GUILD_EVENT_BANKITEM_REMOVED] = true,
                    [GUILD_EVENT_BANKGOLD_REMOVED] = true,
                    [GUILD_EVENT_BANKGOLD_KIOSK_BID] = true,
                    [GUILD_EVENT_BANKGOLD_PURCHASE_HERALDRY] = true,
                    [GUILD_EVENT_GUILD_KIOSK_PURCHASED] = true,
                    [GUILD_EVENT_HERALDRY_EDITED] = true,
                },
                gatingPermission = GUILD_PERMISSION_BANK_VIEW_WITHDRAW_HISTORY,
            },
        },
    },
    [GUILD_HISTORY_STORE] =
    {
        up = "EsoUI/Art/Guild/guildHistory_indexIcon_guildStore_up.dds",
        down = "EsoUI/Art/Guild/guildHistory_indexIcon_guildStore_down.dds",
        over = "EsoUI/Art/Guild/guildHistory_indexIcon_guildStore_over.dds",
        subcategoryEnumName = "SI_GUILDHISTORYSTORESUBCATEGORIES",
        subcategories = 
        {
            [GUILD_HISTORY_STORE_PURCHASES] =
            {
                gamepadIcon = "EsoUI/Art/Guild/gamepad/gp_guild_menuIcon_purchases.dds",
                events = {
                    [GUILD_EVENT_ITEM_SOLD] = true,
                }
            },
            [GUILD_HISTORY_STORE_HIRED_TRADER] =
            {
                gamepadIcon = "EsoUI/Art/Guild/gamepad/gp_guild_menuIcon_trader.dds",
                events = {
                    [GUILD_EVENT_BANKGOLD_KIOSK_BID] = true,
                    [GUILD_EVENT_BANKGOLD_KIOSK_BID_REFUND] = true,
                    [GUILD_EVENT_GUILD_KIOSK_PURCHASED] = true,
                },
                gatingPermission = GUILD_PERMISSION_BANK_VIEW_GOLD,
            },
        },
    },
    [GUILD_HISTORY_ALLIANCE_WAR] =
    {
        up = "EsoUI/Art/Guild/guildHistory_indexIcon_campaigns_up.dds",
        down = "EsoUI/Art/Guild/guildHistory_indexIcon_campaigns_down.dds",
        over = "EsoUI/Art/Guild/guildHistory_indexIcon_campaigns_over.dds",
        subcategoryEnumName = "SI_GUILDHISTORYALLIANCEWARSUBCATEGORIES",
        subcategories = 
        {
            [GUILD_HISTORY_ALLIANCE_WAR_OWNERSHIP] =
            {
                gamepadIcon = "EsoUI/Art/Guild/gamepad/gp_guild_menuIcon_ownership.dds",
                events = {
                    [GUILD_EVENT_KEEP_CLAIMED] = true,
                    [GUILD_EVENT_KEEP_LOST] = true,
                    [GUILD_EVENT_KEEP_RELEASED] = true,
                }
            },
        },
    },
}
local function GetContrastTextColor()
    if IsInGamepadPreferredMode() then
        return ZO_SELECTED_TEXT
    end
    return ZO_SECOND_CONTRAST_TEXT
end
local function GetGoldString(amount)
    local color = GetContrastTextColor()
    local formattedGoldIcon = ZO_Currency_GetPlatformFormattedCurrencyIcon(CURT_MONEY)
    return zo_strformat(SI_GUILD_EVENT_GOLD_FORMAT, color:Colorize(ZO_CurrencyControl_FormatCurrency(amount)), formattedGoldIcon)
end
local function IsInvalidParam(param)
    return not param or param == "" or param == GetString(SI_GUILD_HISTORY_DEFAULT_PARSED_TEXT)
end
local function DefaultEventFormat(eventType, ...)
    local contrastColor = GetContrastTextColor()
    local formatString = GetString("SI_GUILDEVENTTYPE", eventType)
    local colorizedParams = {}
    for i = 1, select('#', ...) do
        local param = select(i, ...)
        colorizedParams[i] = contrastColor:Colorize(param)
    end
    return zo_strformat(formatString, unpack(colorizedParams))
end
local function DefaultEventFormatWithDisplayName(eventType, displayName, ...)
    return DefaultEventFormat(eventType, ZO_FormatUserFacingDisplayName(displayName), ...)
end
local function DefaultEventFormatWithTwoDisplayNames(eventType, displayName1, displayName2, ...)
    return DefaultEventFormat(eventType, ZO_FormatUserFacingDisplayName(displayName1), ZO_FormatUserFacingDisplayName(displayName2), ...)
end
local function DefaultEventFormatNoParams(eventType)
    return zo_strformat(GetString(SI_GUILD_EVENT_NO_PARAM_FORMAT), GetString("SI_GUILDEVENTTYPE", eventType))
end
local function BankItemEventFormat(eventType, displayName, quantity, itemLink)
    local contrastColor = GetContrastTextColor()
    local formatString = GetString("SI_GUILDEVENTTYPE", eventType)
    return zo_strformat(formatString,   contrastColor:Colorize(ZO_FormatUserFacingDisplayName(displayName)),
                                        ZO_SELECTED_TEXT:Colorize(quantity),
                                        itemLink)
end
local function BankGoldEventFormat(eventType, displayName, gold)
    local contrastColor = GetContrastTextColor()
    local formatString = GetString("SI_GUILDEVENTTYPE", eventType)
    return zo_strformat(formatString,   contrastColor:Colorize(ZO_FormatUserFacingDisplayName(displayName)),
                                        GetGoldString(gold))
end
local function KioskBuyOrBidEventFormat(eventType, displayName, gold, kioskName)
    local contrastColor = GetContrastTextColor()
    local formatString = GetString("SI_GUILDEVENTTYPE", eventType)
    return zo_strformat(formatString,   contrastColor:Colorize(ZO_FormatUserFacingDisplayName(displayName)),
                                        GetGoldString(gold),
                                        contrastColor:Colorize(kioskName))
end
local function KioskRefundEventFormat(eventType, kiosk, gold)
    local contrastColor = GetContrastTextColor()
    local formatString = GetString("SI_GUILDEVENTTYPE", eventType)
    return zo_strformat(formatString,   contrastColor:Colorize(kiosk),
                                        GetGoldString(gold))
end
local function GuildJoinedEventFormat(eventType, joinerDisplayName, optionalInviterDisplayName)
    if IsInvalidParam(optionalInviterDisplayName) then
        local contrastColor = GetContrastTextColor()
        local userFacingJoinerDisplayName = ZO_FormatUserFacingDisplayName(joinerDisplayName)
        return zo_strformat(SI_GUILDEVENTTYPEDEPRECATED7, contrastColor:Colorize(userFacingJoinerDisplayName))
    else
        return DefaultEventFormatWithTwoDisplayNames(eventType, joinerDisplayName, optionalInviterDisplayName)
    end
end
GUILD_EVENT_EVENT_FORMAT =
{                                                                           -- Event Values passed to function
    [GUILD_EVENT_GUILD_PROMOTE] = DefaultEventFormatWithTwoDisplayNames,    -- (eventType, displayName1, displayName2, rankName)
    [GUILD_EVENT_GUILD_DEMOTE] = DefaultEventFormatWithTwoDisplayNames,     -- (eventType, displayName1, displayName2, rankName)
    [GUILD_EVENT_GUILD_CREATE] = DefaultEventFormatWithDisplayName,         -- (eventType, displayName)
    [GUILD_EVENT_GUILD_INVITE] = DefaultEventFormatWithTwoDisplayNames,     -- (eventType, displayName1, displayName2)
    [GUILD_EVENT_GUILD_JOIN] = GuildJoinedEventFormat,                      -- (eventType, joinerDisplayName, optionalInviterDisplayName)
    [GUILD_EVENT_GUILD_LEAVE] = DefaultEventFormatWithDisplayName,          -- (eventType, displayName)
    [GUILD_EVENT_GUILD_KICKED] = DefaultEventFormatWithTwoDisplayNames,     -- (eventType, displayName1, displayName2)
    [GUILD_EVENT_BANKITEM_ADDED] = BankItemEventFormat,                     -- (eventType, displayName, itemQuantity, itemName)
    [GUILD_EVENT_BANKITEM_REMOVED] = BankItemEventFormat,                   -- (eventType, displayName, itemQuantity, itemName)
    [GUILD_EVENT_BANKGOLD_ADDED] = BankGoldEventFormat,                     -- (eventType, displayName, goldQuantity)
    [GUILD_EVENT_BANKGOLD_REMOVED] = BankGoldEventFormat,                   -- (eventType, displayName, goldQuantity)
    [GUILD_EVENT_BANKGOLD_KIOSK_BID_REFUND] = KioskRefundEventFormat,       -- (eventType, kioskName, goldQuantity)
    [GUILD_EVENT_BANKGOLD_KIOSK_BID] = KioskBuyOrBidEventFormat,            -- (eventType, displayName, goldQuantity, kioskName)
    [GUILD_EVENT_GUILD_KIOSK_PURCHASED] = KioskBuyOrBidEventFormat,         -- (eventType, displayName, goldQuantity, kioskName)
    [GUILD_EVENT_BANKGOLD_GUILD_STORE_TAX] = DefaultEventFormatNoParams,    -- (eventType)
    [GUILD_EVENT_MOTD_EDITED] = DefaultEventFormatWithDisplayName,          -- (eventType, displayName)
    [GUILD_EVENT_ABOUT_US_EDITED] = DefaultEventFormatWithDisplayName,      -- (eventType, displayName)
    [GUILD_EVENT_KEEP_CLAIMED] = DefaultEventFormatWithDisplayName,         -- (eventType, displayName, keepName, campaignName)
    [GUILD_EVENT_KEEP_RELEASED] = DefaultEventFormatWithDisplayName,        -- (eventType, displayName, keepName, campaignName)
    [GUILD_EVENT_KEEP_LOST] = DefaultEventFormat,                           -- (eventType, keepName, campaignName)
    [GUILD_EVENT_HERALDRY_EDITED] = BankGoldEventFormat,                    -- (eventType, displayName, goldCost)
    [GUILD_EVENT_GUILD_STORE_UNLOCKED] = DefaultEventFormatNoParams,        -- (eventType)
    [GUILD_EVENT_GUILD_STORE_LOCKED] = DefaultEventFormatNoParams,          -- (eventType)
    [GUILD_EVENT_GUILD_BANK_UNLOCKED] = DefaultEventFormatNoParams,         -- (eventType)
    [GUILD_EVENT_GUILD_BANK_LOCKED] = DefaultEventFormatNoParams,           -- (eventType)
    [GUILD_EVENT_GUILD_STANDARD_UNLOCKED] = DefaultEventFormatNoParams,     -- (eventType)
    [GUILD_EVENT_GUILD_STANDARD_LOCKED] = DefaultEventFormatNoParams,       -- (eventType)
    [GUILD_EVENT_GUILD_KIOSK_UNLOCKED] = DefaultEventFormatNoParams,        -- (eventType)
    [GUILD_EVENT_GUILD_KIOSK_LOCKED] = DefaultEventFormatNoParams,          -- (eventType)
    [GUILD_EVENT_GUILD_TABARD_UNLOCKED] = DefaultEventFormatNoParams,       -- (eventType)
    [GUILD_EVENT_GUILD_TABARD_LOCKED] = DefaultEventFormatNoParams,         -- (eventType)
    [GUILD_EVENT_GUILD_APPLICATION_DECLINED] = DefaultEventFormatWithTwoDisplayNames,     -- (eventType, displayName1, displayName2)
    [GUILD_EVENT_GUILD_APPLICATION_ACCEPTED] = DefaultEventFormatWithTwoDisplayNames,     -- (eventType, displayName1, displayName2)
    [GUILD_EVENT_REMOVED_FROM_BLACKLIST] = DefaultEventFormatWithTwoDisplayNames,     -- (eventType, displayName1, displayName2)
    [GUILD_EVENT_ADDED_TO_BLACKLIST] = DefaultEventFormatWithTwoDisplayNames,     -- (eventType, displayName1, displayName2)
    [GUILD_EVENT_GUILD_RECRUITMENT_GUILD_LISTED] = DefaultEventFormatWithDisplayName,          -- (eventType, displayName)
    [GUILD_EVENT_GUILD_RECRUITMENT_GUILD_UNLISTED] = DefaultEventFormatWithDisplayName,          -- (eventType, displayName)
    [GUILD_EVENT_ITEM_SOLD] = function(eventType, seller, buyer, quantity, itemLink, price, tax)
        local contrastColor = GetContrastTextColor()
        local formatString = GetString("SI_GUILDEVENTTYPE", eventType)
        return zo_strformat(formatString,   contrastColor:Colorize(ZO_FormatUserFacingDisplayName(seller)),
                                            contrastColor:Colorize(ZO_FormatUserFacingDisplayName(buyer)),
                                            ZO_SELECTED_TEXT:Colorize(quantity),
                                            itemLink,
                                            GetGoldString(price),
                                            GetGoldString(tax))
    end,
}
function ComputeGuildHistoryEventSubcategory(eventType, category)
    local categoryData = GUILD_HISTORY_CATEGORIES[category]
    local subcategoryData = categoryData.subcategories
    if(subcategoryData ~= nil) then
        for subcategoryId, data in pairs(subcategoryData) do
            if(data.events[eventType]) then
                return subcategoryId
            end
        end
    end
end
function ZO_GuildHistory_GetNoEntriesText(categoryId, subcategoryId, guildId)
    local categoryData = GUILD_HISTORY_CATEGORIES[categoryId]
    if not categoryData then
        return GetString(SI_GUILD_HISTORY_NO_ENTRIES)
    end
    if subcategoryId then
        local subcategoryData = categoryData.subcategories[subcategoryId]
        if subcategoryData.gatingPermission and not DoesPlayerHaveGuildPermission(guildId, subcategoryData.gatingPermission) then
            return GetString(SI_GUILD_CANT_VIEW_HISTORY)
        end
    else
        local numSubcategories = #categoryData.subcategories
        local numPermissionsFailed = 0
        for i, subcategoryData in ipairs(categoryData.subcategories) do
            if subcategoryData.gatingPermission and not DoesPlayerHaveGuildPermission(guildId, subcategoryData.gatingPermission) then
                numPermissionsFailed = numPermissionsFailed + 1
            else
                -- subcategory was not gated or permission was met, we can show the generic message
                break
            end
        end
        if numPermissionsFailed == numSubcategories then
            return GetString(SI_GUILD_CANT_VIEW_HISTORY)
        else
            return GetString(SI_GUILD_HISTORY_NO_ENTRIES)
        end
    end
    return GetString(SI_GUILD_HISTORY_NO_ENTRIES)
end