ESO Lua File v100011

ingame/playeremote/playeremote.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
local function AddEmote(emoteIndex, ...)
    for i = 1, select("#", ...) do
        local cmd = select(i, ...)
        if(SLASH_COMMANDS[cmd] == nil) then
              SLASH_COMMANDS[cmd] = function() PlayEmoteByIndex(emoteIndex) end
        end
    end
end
local function AddEmotes()
     local numEmotes = GetNumEmotes()
     for emoteIndex = 1, numEmotes, 1 do
        AddEmote(emoteIndex, zo_strsplit(" ", GetEmoteSlashNameByIndex(emoteIndex)))
     end
end
local function OnAddOnLoaded(event, name)
    if name == "ZO_Ingame" then
          AddEmotes()
        EVENT_MANAGER:UnregisterForEvent("PlayerEmote_OnAddOnLoaded", EVENT_ADD_ON_LOADED)
     end
end
     
EVENT_MANAGER:RegisterForEvent("PlayerEmote_OnAddOnLoaded", EVENT_ADD_ON_LOADED, OnAddOnLoaded)
local ZO_PlayerEmoteManager = ZO_Object:Subclass()
function ZO_PlayerEmoteManager:CompareEmotes(emoteA, emoteB)
    return self:GetEmoteItemInfo(emoteA).emoteName < self:GetEmoteItemInfo(emoteB).emoteName
end
local function CompareCategories(categoryA, categoryB)
    return categoryA < categoryB
end
-- This is a placeholder list to test functionality while the emote quickslots are setup
local SLOTTED_EMOTE_IDS = {
    35,
    158,
    -1,
    136,
    142,
    285,
    53,
    58,
}
function ZO_PlayerEmoteManager:InitializeSlottedEmotes()
    for i=1, #SLOTTED_EMOTE_IDS do
        self.slottedEmoteList[i] = SLOTTED_EMOTE_IDS[i]
    end
end
function ZO_PlayerEmoteManager:GetEmoteItemInfo(emoteId)
    return self.emoteList[emoteId]
end
function ZO_PlayerEmoteManager:InitializeEmoteList()
    self.emoteList = {}
    self.emoteCategories = {}
    self.emoteCategoryTypes = {}
    self.slottedEmoteList = {}
     for emoteIndex = 1, GetNumEmotes() do
        local emoteSlashName, emoteCategory, emoteId = GetEmoteInfo(emoteIndex)
        if emoteSlashName ~= "" then
            if not self.emoteCategories[emoteCategory] then
                self.emoteCategories[emoteCategory] = {}
                table.insert(self.emoteCategoryTypes, emoteCategory)
            end
            self.emoteList[emoteId] =   {
                                            emoteName = string.sub(emoteSlashName,2),
                                            emoteCategory = emoteCategory,
                                            emoteId = emoteId,
                                            emoteIndex = emoteIndex
                                        }
            table.insert(self.emoteCategories[emoteCategory], emoteId)
        end
     end
    for _, emoteList in pairs(self.emoteCategories) do
        table.sort(emoteList, function(emoteA, emoteB) return self:CompareEmotes(emoteA, emoteB) end)
    end
    table.sort(self.emoteCategoryTypes, CompareCategories)
end
local EMOTE_ICONS = {
    [EMOTE_CATEGORY_INVALID] =      {   inactiveIcon = "EsoUI/Art/Quickslots/quickslot_emptySlot.dds", 
                                        activeIcon = "EsoUI/Art/Quickslots/quickslot_emptySlot.dds"
                                    },
    [EMOTE_CATEGORY_COMMON] =       {   inactiveIcon = "EsoUI/Art/HUD/radialIcon_trade_disabled.dds", 
                                        activeIcon = "EsoUI/Art/HUD/radialIcon_trade_over.dds"
                                    },
    [EMOTE_CATEGORY_EMOTION] =      {   inactiveIcon = "EsoUI/Art/HUD/radialIcon_inviteGroup_disabled.dds", 
                                        activeIcon = "EsoUI/Art/HUD/radialIcon_inviteGroup_over.dds"
                                    },
    [EMOTE_CATEGORY_PERPETUAL] =    {   inactiveIcon = "EsoUI/Art/HUD/radialIcon_addFriend_disabled.dds", 
                                        activeIcon = "EsoUI/Art/HUD/radialIcon_addFriend_over.dds"
                                    },
}
function ZO_PlayerEmoteManager:GetEmoteListForType(emoteType)
    if not self.emoteCategories then
        self:InitializeEmoteList()
    end
    return self.emoteCategories[emoteType]
end
function ZO_PlayerEmoteManager:GetEmoteCategories()
    if not self.emoteCategoryTypes then
        self:InitializeEmoteList()
    end
    return self.emoteCategoryTypes
end
function ZO_PlayerEmoteManager:GetSlottedEmotes()
    if not self.slottedEmoteList then
        self:InitializeEmoteList()
    end
    return self.slottedEmoteList
end
function ZO_PlayerEmoteManager:GetEmoteIconForCategory(category)
    if EMOTE_ICONS[category] then
        return EMOTE_ICONS[category]
    end
    return EMOTE_ICONS[EMOTE_CATEGORY_INVALID]
end
-- Globals
-------------------------------------------------------------
PLAYER_EMOTE_MANAGER = ZO_PlayerEmoteManager:New()