Back to Home

ESO Lua File v101032

ingame/guild/gamepad/guildselector_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
ZO_GuildSelector_Gamepad = ZO_ComboBox_Gamepad:Subclass()
function ZO_GuildSelector_Gamepad:New(...)
    return ZO_ComboBox_Gamepad.New(self, ...)
end
function ZO_GuildSelector_Gamepad:Initialize(...)
    ZO_ComboBox_Gamepad.Initialize(self, ...)
    self.entries = {}
    self:SetSortsItems(false)
    self.OnGuildChanged = function (_, entryText, entry)
        self:SelectGuild(entry)
    end
    self.filterFunction = function(guildId)
        return DoesPlayerHaveGuildPermission(guildId, GUILD_PERMISSION_GUILD_KIOSK_BID)
    end
    local function RefreshGuildList()
        self:RefreshGuildList()
    end
    self.m_container:SetHandler("OnEffectivelyShown", function()
        EVENT_MANAGER:RegisterForEvent("GuildSelectorGamepad", EVENT_GUILD_DATA_LOADED, RefreshGuildList)
    end)
    self.m_container:SetHandler("OnEffectivelyHidden", function()
        EVENT_MANAGER:UnregisterForEvent("GuildSelectorGamepad", EVENT_GUILD_DATA_LOADED)
    end)
end
function ZO_GuildSelector_Gamepad:SetGuildFilter(filterFunction)
end
function ZO_GuildSelector_Gamepad:SelectGuild(selectedEntry)
    if selectedEntry then
        self.guildId = selectedEntry.guildId
        self.control:SetSelectedItemText(selectedEntry.selectedText)
        if self.OnSelectionChanged then
            self.OnSelectionChanged(selectedEntry)
        end
    end
end
function ZO_GuildSelector_Gamepad:RefreshGuildList()
    ZO_ClearTable(self.entries)
    self:ClearItems()
    for i = 1, GetNumGuilds() do
        local guildId = GetGuildId(i)
        if not self.filterFunction or self.filterFunction(guildId) then
            local guildName = GetGuildName(guildId)
            local guildAlliance = GetGuildAlliance(guildId)
            local guildText = zo_iconTextFormat(GetLargeAllianceSymbolIcon(guildAlliance), 32, 32, guildName)
            local entry = self:CreateItemEntry(guildText, self.OnGuildSelected)
            entry.guildId = guildId
            entry.guildText = guildText
            if self.OnGuildsRefreshed then
                self.OnGuildsRefreshed(entry)
            end
            self.entries[guildId] = entry
            self:AddItem(entry)
        end
    end
    if next(self.entries) == nil then
        return false
    end
    self.highlightedIndex = 1
    return true
end
function ZO_GuildSelector_Gamepad:SetOnGuildsRefreshed(OnGuildsRefreshed)
end
function ZO_GuildSelector_Gamepad:OnGuildSelected(itemName, item)
    if self.OnGuildSelectedCallback then
        self.OnGuildSelectedCallback(item)
    end
end
function ZO_GuildSelector_Gamepad:SetOnGuildSelectedCallback(OnGuildSelectedCallback)
end