Commit d75cd509 authored by Azilroka's avatar Azilroka

Merge branch 'development'

parents 34d3fa04 b0dd0f45
......@@ -7,7 +7,7 @@ local _G = _G
local wipe, date = wipe, date
local format, select, type, ipairs, pairs = format, select, type, ipairs, pairs
local strmatch, strfind, tonumber, tostring = strmatch, strfind, tonumber, tostring
local CreateFrame = CreateFrame
local strlen, CreateFrame = strlen, CreateFrame
local GetAddOnEnableState = GetAddOnEnableState
local GetBattlefieldArenaFaction = GetBattlefieldArenaFaction
local GetCVar, SetCVar = GetCVar, SetCVar
......@@ -34,6 +34,25 @@ local C_UIWidgetManager_GetStatusBarWidgetVisualizationInfo = C_UIWidgetManager.
local FACTION_HORDE = FACTION_HORDE
local FACTION_ALLIANCE = FACTION_ALLIANCE
function E:ClassColor(class, usePriestColor)
if not class then return end
local color = (_G.CUSTOM_CLASS_COLORS and _G.CUSTOM_CLASS_COLORS[class]) or _G.RAID_CLASS_COLORS[class]
if type(color) ~= 'table' then return end
if not color.colorStr then
color.colorStr = E:RGBToHex(color.r, color.g, color.b, 'ff')
elseif strlen(color.colorStr) == 6 then
color.colorStr = 'ff'..color.colorStr
end
if (usePriestColor and class == 'PRIEST') and tonumber(color.colorStr, 16) > tonumber(E.PriestColors.colorStr, 16) then
return E.PriestColors
else
return color
end
end
do -- other non-english locales require this
E.UnlocalizedClasses = {}
for k,v in pairs(_G.LOCALIZED_CLASS_NAMES_MALE) do E.UnlocalizedClasses[v] = k end
......@@ -48,34 +67,52 @@ function E:IsFoolsDay()
return strfind(date(), '04/01/') and not E.global.aprilFools
end
function E:ScanTooltipTextures(clean, grabTextures)
local essenceTextureID, textures, essences = 2975691
for i = 1, 10 do
local tex = _G['ElvUI_ScanTooltipTexture'..i]
local texture = tex and tex:GetTexture()
if texture then
if grabTextures then
if not textures then textures = {} end
do
local essenceTextureID = 2975691
function E:ScanTooltipTextures()
local tt = E.ScanTooltip
if not tt.gems then
tt.gems = {}
else
wipe(tt.gems)
end
if not tt.essences then
tt.essences = {}
else
for _, essences in pairs(tt.essences) do
wipe(essences)
end
end
local step = 1
for i = 1, 10 do
local tex = _G['ElvUI_ScanTooltipTexture'..i]
local texture = tex and tex:IsShown() and tex:GetTexture()
if texture then
if texture == essenceTextureID then
if not essences then essences = {} end
local selected = (tt.gems[i-1] ~= essenceTextureID and tt.gems[i-1]) or nil
if not tt.essences[step] then tt.essences[step] = {} end
tt.essences[step][1] = selected --essence texture if selected or nil
tt.essences[step][2] = tex:GetAtlas() --atlas place 'tooltip-heartofazerothessence-major' or 'tooltip-heartofazerothessence-minor'
tt.essences[step][3] = texture --border texture placed by the atlas
--`CollectEssenceInfo` will add 4 (hex quality color) and 5 (essence name)
local selected = (textures[i-1] ~= essenceTextureID and textures[i-1]) or nil
essences[i] = {selected, tex:GetAtlas(), texture}
step = step + 1
if selected then
textures[i-1] = nil
tt.gems[i-1] = nil
end
else
textures[i] = texture
tt.gems[i] = texture
end
end
if clean then
tex:SetTexture()
end
end
end
return textures, essences
return tt.gems, tt.essences
end
end
function E:GetPlayerRole()
......
......@@ -29,15 +29,23 @@ function E:Cooldown_OnUpdate(elapsed)
self.text:SetText('')
self.nextUpdate = 500
else
local timeColors, timeThreshold = (self.timerOptions and self.timerOptions.timeColors) or E.TimeColors, (self.timerOptions and self.timerOptions.timeThreshold) or E.db.cooldown.threshold
local timeColors, indicatorColors, timeThreshold = (self.timerOptions and self.timerOptions.timeColors) or E.TimeColors, (self.timerOptions and self.timerOptions.indicatorColors) or E.TimeIndicatorColors, (self.timerOptions and self.timerOptions.timeThreshold) or E.db.cooldown.threshold
if not timeThreshold then timeThreshold = E.TimeThreshold end
local hhmmThreshold = (self.timerOptions and self.timerOptions.hhmmThreshold) or (E.db.cooldown.checkSeconds and E.db.cooldown.hhmmThreshold)
local mmssThreshold = (self.timerOptions and self.timerOptions.mmssThreshold) or (E.db.cooldown.checkSeconds and E.db.cooldown.mmssThreshold)
local useIndicatorColor = (self.timerOptions and self.timerOptions.useIndicatorColor) or E.db.cooldown.useIndicatorColor
local value1, formatid, nextUpdate, value2 = E:GetTimeInfo(remain, timeThreshold, hhmmThreshold, mmssThreshold)
local value1, formatID, nextUpdate, value2 = E:GetTimeInfo(remain, timeThreshold, hhmmThreshold, mmssThreshold) --?? Simpy
self.nextUpdate = nextUpdate
self.text:SetFormattedText(('%s%s|r'):format(timeColors[formatid], E.TimeFormats[formatid][2]), value1, value2)
if useIndicatorColor then
self.text:SetFormattedText(E.TimeFormats[formatID][3], value1, indicatorColors[formatID], value2)
else
self.text:SetFormattedText(E.TimeFormats[formatID][2], value1, value2)
end
self.text:SetTextColor(timeColors[formatID].r, timeColors[formatID].g, timeColors[formatID].b)
end
else
E:Cooldown_StopTimer(self)
......@@ -122,9 +130,10 @@ function E:CreateCooldownTimer(parent)
timer.timerOptions.reverseToggle = db.cooldown.reverse
timer.timerOptions.hideBlizzard = db.cooldown.hideBlizzard
timer.timerOptions.useIndicatorColor = db.cooldown.useIndicatorColor
if db.cooldown.override and E.TimeColors[parent.CooldownOverride] then
timer.timerOptions.timeColors, timer.timerOptions.timeThreshold = E.TimeColors[parent.CooldownOverride], db.cooldown.threshold
if db.cooldown.override and E.TimeColors[parent.CooldownOverride] and E.TimeIndicatorColors[parent.CooldownOverride] then
timer.timerOptions.timeColors, timer.timerOptions.indicatorColors, timer.timerOptions.timeThreshold = E.TimeColors[parent.CooldownOverride], E.TimeIndicatorColors[parent.CooldownOverride], db.cooldown.threshold
else
timer.timerOptions.timeColors, timer.timerOptions.timeThreshold = nil, nil
end
......@@ -211,14 +220,21 @@ end
function E:GetCooldownColors(db)
if not db then db = self.db.cooldown end -- just incase someone calls this without a first arg use the global
local c6 = E:RGBToHex(db.hhmmColor.r, db.hhmmColor.g, db.hhmmColor.b) -- HH:MM color
local c5 = E:RGBToHex(db.mmssColor.r, db.mmssColor.g, db.mmssColor.b) -- MM:SS color
local c4 = E:RGBToHex(db.expiringColor.r, db.expiringColor.g, db.expiringColor.b) -- color for timers that are soon to expire
local c3 = E:RGBToHex(db.secondsColor.r, db.secondsColor.g, db.secondsColor.b) -- color for timers that have seconds remaining
local c2 = E:RGBToHex(db.minutesColor.r, db.minutesColor.g, db.minutesColor.b) -- color for timers that have minutes remaining
local c1 = E:RGBToHex(db.hoursColor.r, db.hoursColor.g, db.hoursColor.b) -- color for timers that have hours remaining
local c0 = E:RGBToHex(db.daysColor.r, db.daysColor.g, db.daysColor.b) -- color for timers that have days remaining
return c0, c1, c2, c3, c4, c5, c6
local c13 = E:RGBToHex(db.hhmmColorIndicator.r, db.hhmmColorIndicator.g, db.hhmmColorIndicator.b) -- color for timers that are soon to expire
local c12 = E:RGBToHex(db.mmssColorIndicator.r, db.mmssColorIndicator.g, db.mmssColorIndicator.b) -- color for timers that are soon to expire
local c11 = E:RGBToHex(db.expireIndicator.r, db.expireIndicator.g, db.expireIndicator.b) -- color for timers that are soon to expire
local c10 = E:RGBToHex(db.secondsIndicator.r, db.secondsIndicator.g, db.secondsIndicator.b) -- color for timers that have seconds remaining
local c9 = E:RGBToHex(db.minutesIndicator.r, db.minutesIndicator.g, db.minutesIndicator.b) -- color for timers that have minutes remaining
local c8 = E:RGBToHex(db.hoursIndicator.r, db.hoursIndicator.g, db.hoursIndicator.b) -- color for timers that have hours remaining
local c7 = E:RGBToHex(db.daysIndicator.r, db.daysIndicator.g, db.daysIndicator.b) -- color for timers that have days remaining
local c6 = db.hhmmColor -- HH:MM color
local c5 = db.mmssColor -- MM:SS color
local c4 = db.expiringColor -- color for timers that are soon to expire
local c3 = db.secondsColor -- color for timers that have seconds remaining
local c2 = db.minutesColor -- color for timers that have minutes remaining
local c1 = db.hoursColor -- color for timers that have hours remaining
local c0 = db.daysColor -- color for timers that have days remaining
return c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13
end
function E:UpdateCooldownOverride(module)
......@@ -242,8 +258,8 @@ function E:UpdateCooldownOverride(module)
CD.timerOptions.reverseToggle = db.reverse
CD.timerOptions.hideBlizzard = db.hideBlizzard
if cd.CooldownOverride and db.override and E.TimeColors[cd.CooldownOverride] then
CD.timerOptions.timeColors, CD.timerOptions.timeThreshold = E.TimeColors[cd.CooldownOverride], db.threshold
if cd.CooldownOverride and db.override and E.TimeColors[cd.CooldownOverride] and E.TimeIndicatorColors[cd.CooldownOverride] then
CD.timerOptions.timeColors, CD.timerOptions.indicatorColors, CD.timerOptions.timeThreshold = E.TimeColors[cd.CooldownOverride], E.TimeIndicatorColors[cd.CooldownOverride], db.threshold
else
CD.timerOptions.timeColors, CD.timerOptions.timeThreshold = nil, nil
end
......@@ -315,17 +331,18 @@ function E:UpdateCooldownOverride(module)
end
function E:UpdateCooldownSettings(module)
local cooldownDB, timeColors = self.db.cooldown, E.TimeColors
local cooldownDB, timeColors, indicatorColors = self.db.cooldown, E.TimeColors, E.TimeIndicatorColors
-- update the module timecolors if the config called it but ignore 'global' and 'all':
-- global is the main call from config, all is the core file calls
local isModule = module and (module ~= 'global' and module ~= 'all') and self.db[module] and self.db[module].cooldown
if isModule then
if not E.TimeColors[module] then E.TimeColors[module] = {} end
cooldownDB, timeColors = self.db[module].cooldown, E.TimeColors[module]
if not E.TimeIndicatorColors[module] then E.TimeIndicatorColors[module] = {} end
cooldownDB, timeColors, indicatorColors = self.db[module].cooldown, E.TimeColors[module], E.TimeIndicatorColors[module]
end
timeColors[0], timeColors[1], timeColors[2], timeColors[3], timeColors[4], timeColors[5], timeColors[6] = E:GetCooldownColors(cooldownDB)
timeColors[0], timeColors[1], timeColors[2], timeColors[3], timeColors[4], timeColors[5], timeColors[6], indicatorColors[0], indicatorColors[1], indicatorColors[2], indicatorColors[3], indicatorColors[4], indicatorColors[5], indicatorColors[6] = E:GetCooldownColors(cooldownDB)
if isModule then
E:UpdateCooldownOverride(module)
......
......@@ -16,7 +16,7 @@ local GetNumGroupMembers = GetNumGroupMembers
local GetSpecialization = GetSpecialization
local hooksecurefunc = hooksecurefunc
local InCombatLockdown = InCombatLockdown
local IsAddOnLoaded = IsAddOnLoaded
local GetAddOnEnableState = GetAddOnEnableState
local IsInGroup = IsInGroup
local IsInGuild = IsInGuild
local IsInRaid = IsInRaid
......@@ -61,6 +61,7 @@ E.myspec = GetSpecialization()
E.version = GetAddOnMetadata('ElvUI', 'Version')
E.wowpatch, E.wowbuild = GetBuildInfo()
E.wowbuild = tonumber(E.wowbuild)
E.IsRetail = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
E.resolution = ({GetScreenResolutions()})[GetCurrentResolution()] or GetCVar('gxWindowedResolution') --only used for now in our install.lua line 779
E.screenwidth, E.screenheight = GetPhysicalScreenSize()
E.isMacClient = IsMacClient()
......@@ -157,7 +158,7 @@ E.BadDispels = {
}
--Workaround for people wanting to use white and it reverting to their class color.
E.PriestColors = { r = 0.99, g = 0.99, b = 0.99, colorStr = 'fcfcfc' }
E.PriestColors = { r = 0.99, g = 0.99, b = 0.99, colorStr = 'fffcfcfc' }
-- Socket Type info from 8.2
E.GemTypeInfo = {
......@@ -222,7 +223,7 @@ function E:CheckClassColor(r, g, b)
local matchFound = false
for class in pairs(_G.RAID_CLASS_COLORS) do
if class ~= E.myclass then
local colorTable = class == 'PRIEST' and E.PriestColors or (_G.CUSTOM_CLASS_COLORS and _G.CUSTOM_CLASS_COLORS[class] or _G.RAID_CLASS_COLORS[class])
local colorTable = E:ClassColor(class, true)
local red, green, blue = E:GrabColorPickerValues(colorTable.r, colorTable.g, colorTable.b)
if red == r and green == g and blue == b then
matchFound = true
......@@ -296,7 +297,7 @@ function E:UpdateMedia()
--Border Color
local border = E.db.general.bordercolor
if self:CheckClassColor(border.r, border.g, border.b) then
local classColor = E.myclass == 'PRIEST' and E.PriestColors or (_G.CUSTOM_CLASS_COLORS and _G.CUSTOM_CLASS_COLORS[E.myclass] or _G.RAID_CLASS_COLORS[E.myclass])
local classColor = E:ClassColor(E.myclass, true)
E.db.general.bordercolor.r = classColor.r
E.db.general.bordercolor.g = classColor.g
E.db.general.bordercolor.b = classColor.b
......@@ -307,7 +308,7 @@ function E:UpdateMedia()
--UnitFrame Border Color
border = E.db.unitframe.colors.borderColor
if self:CheckClassColor(border.r, border.g, border.b) then
local classColor = E.myclass == 'PRIEST' and E.PriestColors or (_G.CUSTOM_CLASS_COLORS and _G.CUSTOM_CLASS_COLORS[E.myclass] or _G.RAID_CLASS_COLORS[E.myclass])
local classColor = E:ClassColor(E.myclass, true)
E.db.unitframe.colors.borderColor.r = classColor.r
E.db.unitframe.colors.borderColor.g = classColor.g
E.db.unitframe.colors.borderColor.b = classColor.b
......@@ -324,7 +325,7 @@ function E:UpdateMedia()
local value = self.db.general.valuecolor
if self:CheckClassColor(value.r, value.g, value.b) then
value = E.myclass == 'PRIEST' and E.PriestColors or (_G.CUSTOM_CLASS_COLORS and _G.CUSTOM_CLASS_COLORS[E.myclass] or _G.RAID_CLASS_COLORS[E.myclass])
value = E:ClassColor(E.myclass, true)
self.db.general.valuecolor.r = value.r
self.db.general.valuecolor.g = value.g
self.db.general.valuecolor.b = value.b
......@@ -498,13 +499,18 @@ function E:IncompatibleAddOn(addon, module)
E:StaticPopup_Show('INCOMPATIBLE_ADDON', addon, module)
end
function E:IsAddOnEnabled(addon)
return GetAddOnEnableState(E.myname, addon) == 2
end
function E:CheckIncompatible()
if E.global.ignoreIncompatible then return end
if IsAddOnLoaded('Prat-3.0') and E.private.chat.enable then E:IncompatibleAddOn('Prat-3.0', 'Chat') end
if IsAddOnLoaded('Chatter') and E.private.chat.enable then E:IncompatibleAddOn('Chatter', 'Chat') end
if IsAddOnLoaded('TidyPlates') and E.private.nameplates.enable then E:IncompatibleAddOn('TidyPlates', 'NamePlates') end
if IsAddOnLoaded('Aloft') and E.private.nameplates.enable then E:IncompatibleAddOn('Aloft', 'NamePlates') end
if IsAddOnLoaded('Healers-Have-To-Die') and E.private.nameplates.enable then E:IncompatibleAddOn('Healers-Have-To-Die', 'NamePlates') end
if E:IsAddOnEnabled('Prat-3.0') and E.private.chat.enable then E:IncompatibleAddOn('Prat-3.0', 'Chat') end
if E:IsAddOnEnabled('Chatter') and E.private.chat.enable then E:IncompatibleAddOn('Chatter', 'Chat') end
if E:IsAddOnEnabled('TidyPlates') and E.private.nameplates.enable then E:IncompatibleAddOn('TidyPlates', 'NamePlates') end
if E:IsAddOnEnabled('Aloft') and E.private.nameplates.enable then E:IncompatibleAddOn('Aloft', 'NamePlates') end
if E:IsAddOnEnabled('Healers-Have-To-Die') and E.private.nameplates.enable then E:IncompatibleAddOn('Healers-Have-To-Die', 'NamePlates') end
if E:IsAddOnEnabled('Bartender4') and E.private.actionbar.enable then E:IncompatibleAddOn('Bartender4', 'ActionBar') end
end
function E:CopyTable(currentTable, defaultTable)
......
......@@ -530,7 +530,7 @@ E.PopupDialogs.DISTRIBUTOR_REQUEST_DENIED = {
}
E.PopupDialogs.DISTRIBUTOR_FAILED = {
text = L["Lord! It\'s a miracle! The download up and vanished like a fart in the wind! Try Again!"],
text = L["Lord! It's a miracle! The download up and vanished like a fart in the wind! Try Again!"],
whileDead = 1,
hideOnEscape = 1,
button1 = _G.OKAY,
......
......@@ -54,7 +54,7 @@ function E:UpdateBlizzardFonts()
SetFont(_G.ChatBubbleFont, BUBBLE, self.private.general.chatBubbleFontSize, self.private.general.chatBubbleFontOutline)
SetFont(_G.CombatTextFont, COMBAT, 200, 'OUTLINE') -- number here just increase the font quality.
SetFont(_G.CoreAbilityFont, NORMAL, 26) -- Core abilities(title)
SetFont(_G.DestinyFontHuge, NORMAL, 20, nil, SHADOWCOLOR, BIGOFFSET) -- Garrison Mission Report
SetFont(_G.DestinyFontHuge, NORMAL, 32, nil, SHADOWCOLOR, BIGOFFSET) -- Garrison Mission Report
SetFont(_G.DestinyFontMed, NORMAL, 14) -- Added in 7.3.5 used for ?
SetFont(_G.Fancy12Font, NORMAL, 12) -- Added in 7.3.5 used for ?
SetFont(_G.Fancy14Font, NORMAL, 14) -- Added in 7.3.5 used for ?
......
......@@ -180,7 +180,7 @@ function E:SetupTheme(theme, noDisplayMsg)
E.db.unitframe.colors.castColor = E:GetColor(.31, .31, .31)
E.db.unitframe.colors.castClassColor = false
elseif theme == 'class' then
classColor = E.myclass == 'PRIEST' and E.PriestColors or (_G.CUSTOM_CLASS_COLORS and _G.CUSTOM_CLASS_COLORS[E.myclass] or _G.RAID_CLASS_COLORS[E.myclass])
classColor = E:ClassColor(E.myclass, true)
E.db.general.bordercolor = (E.PixelMode and E:GetColor(0, 0, 0) or E:GetColor(.31, .31, .31))
E.db.general.backdropcolor = E:GetColor(.1, .1, .1)
......@@ -419,7 +419,6 @@ function E:SetupLayout(layout, noDataReset, noDisplayMsg)
E.db.unitframe.units.party.width = 231
--Raid
E.db.unitframe.units.raid.growthDirection = 'RIGHT_UP'
E.db.unitframe.units.raid.health.frequentUpdates = true
E.db.unitframe.units.raid.infoPanel.enable = true
E.db.unitframe.units.raid.name.attachTextTo = 'InfoPanel'
E.db.unitframe.units.raid.name.position = 'BOTTOMLEFT'
......@@ -456,9 +455,7 @@ function E:SetupLayout(layout, noDataReset, noDisplayMsg)
E.db.movers.ShiftAB = 'TOPLEFT,ElvUIParent,BOTTOMLEFT,4,273'
E.db.movers.VOICECHAT = 'TOPLEFT,ElvUIParent,TOPLEFT,250,-82'
E.db.unitframe.units.party.enable = false
E.db.unitframe.units.party.health.frequentUpdates = true
E.db.unitframe.units.raid.visibility = '[nogroup] hide;show'
E.db.unitframe.units.raid40.health.frequentUpdates = true
end
end
......@@ -589,7 +586,7 @@ local function SetPage(PageNum)
if PageNum == 1 then
f.SubTitle:SetFormattedText(L["Welcome to ElvUI version %s!"], E.version)
f.Desc1:SetText(L["This install process will help you learn some of the features in ElvUI has to offer and also prepare your user interface for usage."])
f.Desc2:SetText(L["The in-game configuration menu can be accessed by typing the /ec command or by clicking the \'C\' button on the minimap. Press the button below if you wish to skip the installation process."])
f.Desc2:SetText(L["The in-game configuration menu can be accessed by typing the /ec command or by clicking the 'C' button on the minimap. Press the button below if you wish to skip the installation process."])
f.Desc3:SetText(L["Please press the continue button to go onto the next step."])
InstallOption1Button:Show()
InstallOption1Button:SetScript('OnClick', InstallComplete)
......@@ -678,8 +675,8 @@ local function SetPage(PageNum)
InstallOption3Button:SetText(L["Caster DPS"])
elseif PageNum == 7 then
f.SubTitle:SetText(L["Auras"])
f.Desc1:SetText(L["Select the type of aura system you want to use with ElvUI\'s unitframes. Set to Aura Bar & Icons to use both aura bars and icons, set to icons only to only see icons."])
f.Desc2:SetText(L["If you have an icon or aurabar that you don\'t want to display simply hold down shift and right click the icon for it to disapear."])
f.Desc1:SetText(L["Select the type of aura system you want to use with ElvUI's unitframes. Set to Aura Bar & Icons to use both aura bars and icons, set to icons only to only see icons."])
f.Desc2:SetText(L["If you have an icon or aurabar that you don't want to display simply hold down shift and right click the icon for it to disapear."])
f.Desc3:SetText(L["Importance: |cffD3CF00Medium|r"])
InstallOption1Button:Show()
InstallOption1Button:SetScript('OnClick', function() SetupAuras(true) end)
......
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
--Lua functions
local _G = _G
local format = format
local tinsert, strmatch = tinsert, strmatch
local select, tonumber = select, tonumber
local tinsert, strfind, strmatch = tinsert, strfind, strmatch
local select, tonumber, format = select, tonumber, format
local next, max, wipe = next, max, wipe
local utf8sub = string.utf8sub
--WoW API / Variables
local UnitIsUnit = UnitIsUnit
local GetCVarBool = GetCVarBool
local GetItemInfo = GetItemInfo
......@@ -16,7 +14,9 @@ local GetInventoryItemLink = GetInventoryItemLink
local GetInventoryItemTexture = GetInventoryItemTexture
local GetInspectSpecialization = GetInspectSpecialization
local RETRIEVING_ITEM_INFO = RETRIEVING_ITEM_INFO
-- GLOBALS: ElvUI_ScanTooltipTextLeft1
local ITEM_SPELL_TRIGGER_ONEQUIP = ITEM_SPELL_TRIGGER_ONEQUIP
local ESSENCE_DESCRIPTION = GetSpellDescription(277253)
local MATCH_ITEM_LEVEL = ITEM_LEVEL:gsub('%%d', '(%%d+)')
local MATCH_ITEM_LEVEL_ALT = ITEM_LEVEL_ALT:gsub('%%d(%s?)%(%%d%)', '%%d+%1%%((%%d+)%%)')
......@@ -29,41 +29,76 @@ local X2_INVTYPES, X2_EXCEPTIONS, ARMOR_SLOTS = {
[2] = 19, -- wands, use INVTYPE_RANGEDRIGHT, but are 1H
}, {1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
function E:InspectGearSlot(line, lineText, enchantText, enchantColors, iLvl, itemLevelColors, fullEnchantText)
local lr, lg, lb = line:GetTextColor()
local tr, tg, tb = ElvUI_ScanTooltipTextLeft1:GetTextColor()
local itemLevel = lineText and (strmatch(lineText, MATCH_ITEM_LEVEL_ALT) or strmatch(lineText, MATCH_ITEM_LEVEL))
function E:InspectGearSlot(line, lineText, slotInfo)
local enchant = strmatch(lineText, MATCH_ENCHANT)
if enchant then
fullEnchantText = fullEnchantText or enchant
enchantText = utf8sub(enchant, 1, 18)
enchantColors = {lr, lg, lb}
slotInfo.enchantText = enchant
slotInfo.enchantTextShort = utf8sub(enchant, 1, 18)
local lr, lg, lb = line:GetTextColor()
slotInfo.enchantColors[1] = lr
slotInfo.enchantColors[2] = lg
slotInfo.enchantColors[3] = lb
end
local itemLevel = lineText and (strmatch(lineText, MATCH_ITEM_LEVEL_ALT) or strmatch(lineText, MATCH_ITEM_LEVEL))
if itemLevel then
iLvl = tonumber(itemLevel)
itemLevelColors = {tr, tg, tb}
slotInfo.iLvl = tonumber(itemLevel)
local tr, tg, tb = _G.ElvUI_ScanTooltipTextLeft1:GetTextColor()
slotInfo.itemLevelColors[1] = tr
slotInfo.itemLevelColors[2] = tg
slotInfo.itemLevelColors[3] = tb
end
end
function E:CollectEssenceInfo(index, lineText, slotInfo)
local step = 1
local essence = slotInfo.essences[step]
if essence and next(essence) and (strfind(lineText, ITEM_SPELL_TRIGGER_ONEQUIP, nil, true) and strfind(lineText, ESSENCE_DESCRIPTION, nil, true)) then
for i = 4, 2, -1 do
local line = _G['ElvUI_ScanTooltipTextLeft'..index - i]
local text = line and line:GetText()
if text and (not strmatch(text, '^[ +]')) and essence and next(essence) then
local r, g, b = line:GetTextColor()
essence[4] = E:RGBToHex(r, g, b, '')
essence[5] = text
return iLvl, itemLevelColors, enchantText, enchantColors, fullEnchantText
step = step + 1
essence = slotInfo.essences[step]
end
end
end
end
function E:GetGearSlotInfo(unit, slot, deepScan)
E:ScanTooltipTextures(true)
E.ScanTooltip:SetOwner(_G.UIParent, 'ANCHOR_NONE')
E.ScanTooltip:SetInventoryItem(unit, slot)
E.ScanTooltip:Show()
local tt = E.ScanTooltip
tt:SetOwner(_G.UIParent, 'ANCHOR_NONE')
tt:SetInventoryItem(unit, slot)
tt:Show()
if not tt.slotInfo then tt.slotInfo = {} else wipe(tt.slotInfo) end
local slotInfo = tt.slotInfo
local iLvl, enchantText, enchantColors, itemLevelColors, gems, essences, fullEnchantText
if deepScan then
gems, essences = E:ScanTooltipTextures(nil, true)
for x = 1, E.ScanTooltip:NumLines() do
slotInfo.gems, slotInfo.essences = E:ScanTooltipTextures()
if not tt.enchantColors then tt.enchantColors = {} else wipe(tt.enchantColors) end
if not tt.itemLevelColors then tt.itemLevelColors = {} else wipe(tt.itemLevelColors) end
slotInfo.enchantColors = tt.enchantColors
slotInfo.itemLevelColors = tt.itemLevelColors
for x = 1, tt:NumLines() do
local line = _G['ElvUI_ScanTooltipTextLeft'..x]
if line then
local lineText = line:GetText()
if x == 1 and lineText == RETRIEVING_ITEM_INFO then
return 'tooSoon'
else
iLvl, itemLevelColors, enchantText, enchantColors, fullEnchantText = E:InspectGearSlot(line, lineText, enchantText, enchantColors, iLvl, itemLevelColors, fullEnchantText)
E:InspectGearSlot(line, lineText, slotInfo)
E:CollectEssenceInfo(x, lineText, slotInfo)
end
end
end
......@@ -80,14 +115,15 @@ function E:GetGearSlotInfo(unit, slot, deepScan)
local lineText = line:GetText()
local itemLevel = lineText and (strmatch(lineText, MATCH_ITEM_LEVEL_ALT) or strmatch(lineText, MATCH_ITEM_LEVEL))
if itemLevel then
iLvl = tonumber(itemLevel)
slotInfo.iLvl = tonumber(itemLevel)
end
end
end
end
E.ScanTooltip:Hide()
return iLvl, enchantText, deepScan and gems, deepScan and essences, enchantColors, itemLevelColors, fullEnchantText
tt:Hide()
return slotInfo
end
--Credit ls & Acidweb
......@@ -154,29 +190,31 @@ function E:GetPlayerItemLevel()
return format('%0.2f', E:Round((select(2, GetAverageItemLevel())), 2))
end
local iLevelDB = {}
function E:GetUnitItemLevel(unit)
if UnitIsUnit('player', unit) then
return E:GetPlayerItemLevel()
end
do
local iLevelDB, tryAgain = {}, {}
function E:GetUnitItemLevel(unit)
if UnitIsUnit('player', unit) then
return E:GetPlayerItemLevel()
end
if next(iLevelDB) then wipe(iLevelDB) end
if next(tryAgain) then wipe(tryAgain) end
wipe(iLevelDB)
local tryAgain
for i = 1, 17 do
if i ~= 4 then
local iLvl = E:GetGearSlotInfo(unit, i)
if iLvl == 'tooSoon' then
if not tryAgain then tryAgain = {} end
tinsert(tryAgain, i)
else
iLevelDB[i] = iLvl
for i = 1, 17 do
if i ~= 4 then
local slotInfo = E:GetGearSlotInfo(unit, i)
if slotInfo == 'tooSoon' then
tinsert(tryAgain, i)
else
iLevelDB[i] = slotInfo.iLvl
end
end
end
end
if tryAgain then
return 'tooSoon', unit, tryAgain, iLevelDB
end
if next(tryAgain) then
return 'tooSoon', unit, tryAgain, iLevelDB
end
return E:CalculateAverageItemLevel(iLevelDB, unit)
return E:CalculateAverageItemLevel(iLevelDB, unit)
end
end
......@@ -100,16 +100,17 @@ function E:Truncate(v, decimals)
end
--RGB to Hex
function E:RGBToHex(r, g, b)
function E:RGBToHex(r, g, b, header)
r = r <= 1 and r >= 0 and r or 1
g = g <= 1 and g >= 0 and g or 1
b = b <= 1 and b >= 0 and b or 1
return format('|cff%02x%02x%02x', r*255, g*255, b*255)
return format('%s%02x%02x%02x', header or '|cff', r*255, g*255, b*255)
end
--Hex to RGB
function E:HexToRGB(hex)
local rhex, ghex, bhex = strsub(hex, 1, 2), strsub(hex, 3, 4), strsub(hex, 5, 6)
hex = gsub(hex, '^|c[fF][fF]', '')
local rhex, ghex, bhex = string.sub(hex, 1, 2), string.sub(hex, 3, 4), string.sub(hex, 5, 6)
return tonumber(rhex, 16), tonumber(ghex, 16), tonumber(bhex, 16)
end
......@@ -302,6 +303,7 @@ function E:StringTitle(str)
end
E.TimeThreshold = 3
E.TimeColors = { -- aura time colors for days, hours, minutes, seconds, fadetimer
[0] = '|cffeeeeee',
[1] = '|cffeeeeee',
......@@ -311,14 +313,25 @@ E.TimeColors = { -- aura time colors for days, hours, minutes, seconds, fadetime
[5] = '|cff909090', --mmss
[6] = '|cff707070', --hhmm
}
E.TimeFormats = { -- short and long aura time formats
[0] = {'%dd', '%dd'},
[1] = {'%dh', '%dh'},
[2] = {'%dm', '%dm'},
[3] = {'%ds', '%d'},
[4] = {'%.1fs', '%.1f'},
[5] = {'%d:%02d', '%d:%02d'}, --mmss
[6] = {'%d:%02d', '%d:%02d'}, --hhmm
E.TimeFormats = { -- short/long/indicator color
[0] = {'%dd', '%dd', '%d%sd|r'},
[1] = {'%dh', '%dh', '%d%sh|r'},
[2] = {'%dm', '%dm', '%d%sm|r'},
[3] = {'%ds', '%d', '%d%ss|r'},
[4] = {'%.1fs', '%.1f', '%.1f%ss|r'},
[5] = {'%d:%02d', '%d:%02d', '%d%s:|r%02d'}, --mmss
[6] = {'%d:%02d', '%d:%02d', '%d%s:|r%02d'}, --hhmm
}
E.TimeIndicatorColors = {
[0] = '|cff00b3ff',
[1] = '|cff00b3ff',
[2] = '|cff00b3ff',
[3] = '|cff00b3ff',
[4] = '|cff00b3ff',
[5] = '|cff00b3ff',
[6] = '|cff00b3ff',
}
local DAY, HOUR, MINUTE = 86400, 3600, 60 --used for calculating aura time text
......
......@@ -2,7 +2,6 @@ local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, Private
--Lua functions
local min, max, abs, floor = min, max, abs, floor
local format, tonumber = format, tonumber
--WoW API / Variables
local UIParent = UIParent
......
......@@ -3,7 +3,6 @@ local Skins = E:GetModule('Skins')
--WoW API / Variables
local CreateFrame = CreateFrame
local GetAddOnEnableState = GetAddOnEnableState
local GetAddOnInfo = GetAddOnInfo
local GetCurrentResolution = GetCurrentResolution
local GetCVar = GetCVar
......@@ -14,15 +13,11 @@ local GetScreenResolutions = GetScreenResolutions
local GetSpecialization = GetSpecialization
local GetSpecializationInfo = GetSpecializationInfo
local function IsAddOnEnabled(addon)
return GetAddOnEnableState(E.myname, addon) == 2
end