forked from ArtOfShred/LuiExtended
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctions.lua
264 lines (239 loc) · 9.27 KB
/
Functions.lua
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
--[[
LuiExtended
License: The MIT License (MIT)
--]]
-- Called from the menu and on initialization to update timestamp color when changed.
LUIE.TimeStampColorize = nil
function LUIE.UpdateTimeStampColor()
LUIE.TimeStampColorize = ZO_ColorDef:New(unpack(LUIE.ChatAnnouncements.SV.TimeStampColor)):ToHex()
end
-- Toggle the display of the Alert Frame
function LUIE.SetupAlertFrameVisibility()
ZO_AlertTextNotification:SetHidden(LUIE.SV.HideAlertFrame)
end
-- Return a formatted time
-- Stolen from pChat, thanks @Ayantir
function LUIE.CreateTimestamp(timeStr, formatStr)
local formatStr = formatStr or LUIE.ChatAnnouncements.SV.TimeStampFormat
-- Split up default timestamp
local hours, minutes, seconds = timeStr:match("([^%:]+):([^%:]+):([^%:]+)")
local hoursNoLead = tonumber(hours) -- Hours without leading zero
local hours12NoLead = (hoursNoLead - 1)%12 + 1
local hours12
if (hours12NoLead < 10) then
hours12 = "0" .. hours12NoLead
else
hours12 = hours12NoLead
end
local pUp = "AM"
local pLow = "am"
if (hoursNoLead >= 12) then
pUp = "PM"
pLow = "pm"
end
-- Create new one
local timestamp = formatStr
timestamp = timestamp:gsub("HH", hours)
timestamp = timestamp:gsub("H", hoursNoLead)
timestamp = timestamp:gsub("hh", hours12)
timestamp = timestamp:gsub("h", hours12NoLead)
timestamp = timestamp:gsub("m", minutes)
timestamp = timestamp:gsub("s", seconds)
timestamp = timestamp:gsub("A", pUp)
timestamp = timestamp:gsub("a", pLow)
return timestamp
end
-- FormatMessage helper function
local function FormatMessage(msg, doTimestamp)
local msg = msg or ""
if doTimestamp then
local timestring = GetTimeString()
-- Color Code to match pChat default
msg = string.format("|c%s[%s]|r %s", LUIE.TimeStampColorize, LUIE.CreateTimestamp(timestring), msg)
end
return msg
end
-- Hide all controls if needed
function LUIE.ToggleVisibility(hidden)
for _, control in pairs( LUIE.Components ) do
control:SetHidden( hidden )
end
end
-- Easy Print to Chat
function LUIE.PrintToChat(msg, isSystem)
if CHAT_SYSTEM.primaryContainer then
if LUIE.ChatAnnouncements.SV.ChatMethod == "Print to All Tabs" then
if not LUIE.ChatAnnouncements.SV.ChatBypassFormat and CHAT_SYSTEM.primaryContainer then
-- Add timestamps if bypass is not enabled
local msg = FormatMessage(msg or "no message", LUIE.ChatAnnouncements.SV.TimeStamp)
CHAT_ROUTER:AddSystemMessage(msg)
else
CHAT_ROUTER:AddSystemMessage(msg)
end
else
-- If we have system messages sent to display in all windows then just print to all windows at once, otherwise send messages to individual tabs.
if isSystem and LUIE.ChatAnnouncements.SV.ChatSystemAll then
if not LUIE.ChatAnnouncements.SV.ChatBypassFormat then
-- Add timestamps if bypass is not enabled
local msg = FormatMessage(msg or "no message", LUIE.ChatAnnouncements.SV.TimeStamp)
CHAT_ROUTER:AddSystemMessage(msg)
else
CHAT_ROUTER:AddSystemMessage(msg)
end
else
for k, cc in ipairs(CHAT_SYSTEM.containers) do
for i = 1, #cc.windows do
if LUIE.ChatAnnouncements.SV.ChatTab[i] == true then
local chatContainer = cc
if chatContainer then
local chatWindow = cc.windows[i]
local msg = FormatMessage(msg or "no message", LUIE.ChatAnnouncements.SV.TimeStamp)
-- Don't print into the Combat Metrics Log window if CMX is enabled.
local flagHide = false
if CMX and CMX.db and CMX.db.chatLog then
if chatContainer:GetTabName(i) == CMX.db.chatLog.name then
flagHide = true
end
end
if not flagHide then
chatContainer:AddEventMessageToWindow(chatWindow, msg, CHAT_CATEGORY_SYSTEM)
end
end
end
end
end
end
end
end
end
-- Returns a formatted number with commas
-- Function no comma to be added in a later date.
function LUIE.AbbreviateNumber(number, shorten, comma)
if number > 0 and shorten then
local value
local suffix
if number >= 1000000000 then
value = number / 1000000000
suffix = "G"
elseif number >= 1000000 then
value = number / 1000000
suffix = "M"
elseif number >= 1000 then
value = number / 1000
suffix = "k"
else
value = number
end
-- If we could not conver even to "G", return full number
if value >= 1000 then
if comma then
value = ZO_LocalizeDecimalNumber(number)
return value
else
return number
end
elseif value >= 100 or suffix == nil then
value = string.format("%d", value)
else
value = string.format("%.1f", value)
end
if suffix ~= nil then
value = value .. suffix
end
return value
end
-- Add commas if needed
if comma then
local value = ZO_LocalizeDecimalNumber(number)
return value
end
return number
end
-- Takes an input with a name identifier, title, text, and callback function to create a dialogue button
function LUIE.RegisterDialogueButton(identifier, title, text, callback)
ESO_Dialogs[identifier] =
{
gamepadInfo =
{
dialogType = GAMEPAD_DIALOGS.BASIC,
},
canQueue = true,
title =
{
text = title
},
mainText =
{
text = text
},
buttons =
{
{
text = SI_DIALOG_CONFIRM,
callback = callback
},
{
text = SI_DIALOG_CANCEL,
},
},
}
return ESO_Dialogs[identifier]
end
function LUIE.UpdateGuildData()
local GuildsIndex = GetNumGuilds()
LUIE.GuildIndexData = {}
for i = 1,GuildsIndex do
local id = GetGuildId(i)
local name = GetGuildName(id)
local guildAlliance = GetGuildAlliance(id)
LUIE.GuildIndexData[i] = {id=id, name=name, guildAlliance=guildAlliance}
end
end
-- Simple function to check veteran difficult (VMA isn't considered being in a Veteran Dungeon so we have to do some filtering)
function LUIE.ResolveVeteranDifficulty()
if GetGroupSize() <= 1 and IsUnitUsingVeteranDifficulty('player') then
return true
elseif GetCurrentZoneDungeonDifficulty() == 2 or IsGroupUsingVeteranDifficulty() == true then
return true
else
return false
end
end
-- Simple function that checks if player is in a PVP zone.
function LUIE.ResolvePVPZone()
if IsUnitPvPFlagged('player') then
return true
else
return false
end
end
-- Pull the name for the current morph of a skill
function LUIE.GetSkillMorphName(abilityId)
local skillType, skillIndex, abilityIndex, morphChoice, rankIndex = GetSpecificSkillAbilityKeysByAbilityId(abilityId)
local abilityName = GetSkillAbilityInfo(skillType, skillIndex, abilityIndex)
return abilityName
end
-- Pull the icon for the current morph of a skill
function LUIE.GetSkillMorphIcon(abilityId)
local skillType, skillIndex, abilityIndex, morphChoice, rankIndex = GetSpecificSkillAbilityKeysByAbilityId(abilityId)
local abilityIcon = select(2, GetSkillAbilityInfo(skillType, skillIndex, abilityIndex))
return abilityIcon
end
-- Pull the AbilityId for the current morph of a skill
function LUIE.GetSkillMorphAbilityId(abilityId)
local skillType, skillIndex, abilityIndex, morphChoice, rankIndex = GetSpecificSkillAbilityKeysByAbilityId(abilityId)
local abilityId = GetSkillAbilityId(skillType, skillIndex, abilityIndex, false)
return abilityId
end
-- Function to update the syntax for default Mundus Stone tooltips we pull (in order to retain scaling)
function LUIE.UpdateMundusTooltipSyntax(abilityId, tooltipText)
-- Update syntax for The Lady, The Lover, and the Thief Mundus stones since they aren't consistent with other buffs.
if abilityId == 13976 or abilityId == 13981 then -- The Lady / The Lover
tooltipText = string.gsub(tooltipText, GetString(SI_LUIE_SKILL_MUNDUS_SUB_RES_PEN), GetString(SI_LUIE_SKILL_MUNDUS_SUB_RES_PEN_REPLACE))
elseif abilityId == 13975 then -- The Thief
tooltipText = string.gsub(tooltipText, GetString(SI_LUIE_SKILL_MUNDUS_SUB_THIEF), GetString(SI_LUIE_SKILL_MUNDUS_SUB_THIEF_REPLACE))
end
-- Replace "Increases your" with "Increase"
tooltipText = string.gsub(tooltipText, GetString(SI_LUIE_SKILL_MUNDUS_STRING), GetString(SI_LUIE_SKILL_DRINK_INCREASE))
return tooltipText
end