initial commit

This commit is contained in:
Gitea
2020-11-13 14:27:50 -05:00
commit e2015fd9bb
581 changed files with 101308 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local oUF = E.oUF
local function Update(self)
local element = self.ClassificationIndicator
if element.PreUpdate then
element:PreUpdate()
end
local classification = self.classification
if classification == 'elite' or classification == 'worldboss' then
element:SetAtlas('nameplates-icon-elite-gold')
element:Show()
elseif classification == 'rareelite' or classification == 'rare' then
element:SetAtlas('nameplates-icon-elite-silver')
element:Show()
else
element:Hide()
end
if element.PostUpdate then
return element:PostUpdate(classification)
end
end
local function Path(self, ...)
return (self.ClassificationIndicator.Override or Update) (self, ...)
end
local function ForceUpdate(element)
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function Enable(self)
local element = self.ClassificationIndicator
if element then
element.__owner = self
element.ForceUpdate = ForceUpdate
if element:IsObjectType('Texture') and not element:GetTexture() then
element:SetTexture([[Interface\TARGETINGFRAME\Nameplates]])
end
self:RegisterEvent('UNIT_CLASSIFICATION_CHANGED', Path)
return true
end
end
local function Disable(self)
local element = self.ClassificationIndicator
if element then
element:Hide()
self:UnregisterEvent('UNIT_CLASSIFICATION_CHANGED', Path)
end
end
oUF:AddElement('ClassificationIndicator', Path, Enable, Disable)

View File

@@ -0,0 +1,77 @@
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local oUF = E.oUF
local UnitExists = UnitExists
local UnitIsUnit = UnitIsUnit
local function MouseOnUnit(frame)
if frame and frame:IsVisible() and UnitExists('mouseover') then
return frame.unit and UnitIsUnit('mouseover', frame.unit)
end
return false
end
local function OnUpdate(self, elapsed)
if self.elapsed and self.elapsed > 0.1 then
if not MouseOnUnit(self) then
self:Hide()
self:ForceUpdate()
end
self.elapsed = 0
else
self.elapsed = (self.elapsed or 0) + elapsed
end
end
local function Update(self)
local element = self.Highlight
if element.PreUpdate then
element:PreUpdate()
end
if MouseOnUnit(self) then
element:Show()
else
element:Hide()
end
if element.PostUpdate then
return element:PostUpdate(element:IsShown())
end
end
local function Path(self, ...)
return (self.Highlight.Override or Update)(self, ...)
end
local function ForceUpdate(element)
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function Enable(self)
local element = self.Highlight
if element then
element.__owner = self
element.ForceUpdate = ForceUpdate
element:SetScript('OnUpdate', OnUpdate)
self:RegisterEvent('UPDATE_MOUSEOVER_UNIT', Path, true)
return true
end
end
local function Disable(self)
local element = self.Highlight
if element then
element:Hide()
element:SetScript('OnUpdate', nil)
self:UnregisterEvent('UPDATE_MOUSEOVER_UNIT', Path)
end
end
oUF:AddElement('Highlight', Path, Enable, Disable)

View File

@@ -0,0 +1,176 @@
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local oUF = E.oUF
local wipe = wipe
local format = format
local GetArenaOpponentSpec = GetArenaOpponentSpec
local GetBattlefieldScore = GetBattlefieldScore
local GetInstanceInfo = GetInstanceInfo
local GetNumArenaOpponentSpecs = GetNumArenaOpponentSpecs
local GetNumBattlefieldScores = GetNumBattlefieldScores
local GetSpecializationInfoByID = GetSpecializationInfoByID
local UnitName = UnitName
local UNKNOWN = UNKNOWN
local healerSpecIDs = {
65, --Paladin Holy
105, --Druid Restoration
256, --Priest Discipline
257, --Priest Holy
264, --Shaman Restoration
270, --Monk Mistweaver
}
local tankSpecIDs = {
66, --Paladin Protection
581, --Demon Hunter Vengeance
104, --Druid Guardian
268, --Monk Brewmaster
73, --Warrior Protection
250, --Death Knight Blood
}
local Healers, HealerSpecs = {}, {}
local Tanks, TankSpecs = {}, {}
for _, specID in pairs(healerSpecIDs) do
local _, name = GetSpecializationInfoByID(specID)
if name and not HealerSpecs[name] then
HealerSpecs[name] = true
end
end
for _, specID in pairs(tankSpecIDs) do
local _, name = GetSpecializationInfoByID(specID)
if name and not TankSpecs[name] then
TankSpecs[name] = true
end
end
local function WipeTable()
wipe(Healers)
wipe(Tanks)
end
local function Event()
local _, instanceType = GetInstanceInfo()
if instanceType == 'pvp' or instanceType == 'arena' then
local numOpps = GetNumArenaOpponentSpecs()
if numOpps == 0 then
for i = 1, GetNumBattlefieldScores() do
local name, _, _, _, _, _, _, _, _, _, _, _, _, _, _, talentSpec = GetBattlefieldScore(i)
name = name and name ~= UNKNOWN and E:StripMyRealm(name)
if name then
if HealerSpecs[talentSpec] then
Healers[name] = talentSpec
elseif Healers[name] then
Healers[name] = nil;
end
if TankSpecs[talentSpec] then
Tanks[name] = talentSpec
elseif Tanks[name] then
Tanks[name] = nil;
end
end
end
elseif numOpps >= 1 then
for i = 1, numOpps do
local name, realm = UnitName(format('arena%d', i))
if name and name ~= UNKNOWN then
realm = (realm and realm ~= '') and E:ShortenRealm(realm)
if realm then name = name..'-'..realm end
local s = GetArenaOpponentSpec(i)
local _, talentSpec = nil, UNKNOWN
if s and s > 0 then
_, talentSpec = GetSpecializationInfoByID(s)
end
if talentSpec and talentSpec ~= UNKNOWN then
if HealerSpecs[talentSpec] then
Healers[name] = talentSpec
end
if TankSpecs[talentSpec] then
Tanks[name] = talentSpec
end
end
end
end
end
end
end
local function Update(self)
local element, isShown = self.PVPRole
if element.PreUpdate then
element:PreUpdate()
end
local _, instanceType = GetInstanceInfo()
if instanceType == 'pvp' or instanceType == 'arena' then
local name, realm = UnitName(self.unit)
realm = (realm and realm ~= '') and E:ShortenRealm(realm)
if realm then name = name..'-'..realm end
if Healers[name] and element.ShowHealers then
element:SetTexture(element.HealerTexture)
isShown = true
elseif Tanks[name] and element.ShowTanks then
element:SetTexture(element.TankTexture)
isShown = true
end
end
element:SetShown(isShown)
if element.PostUpdate then
return element:PostUpdate(instanceType)
end
end
local function Path(self, ...)
return (self.PVPRole.Override or Update) (self, ...)
end
local function ForceUpdate(element)
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function Enable(self)
local element = self.PVPRole
if element then
element.__owner = self
element.ForceUpdate = ForceUpdate
if not element.HealerTexture then element.HealerTexture = E.Media.Textures.Healer end
if not element.TankTexture then element.TankTexture = E.Media.Textures.Tank end
self:RegisterEvent('UNIT_TARGET', Path)
self:RegisterEvent('PLAYER_TARGET_CHANGED', Path, true)
self:RegisterEvent('UNIT_NAME_UPDATE', Path)
self:RegisterEvent('ARENA_OPPONENT_UPDATE', Event, true)
self:RegisterEvent('UPDATE_BATTLEFIELD_SCORE', Event, true)
self:RegisterEvent('PLAYER_ENTERING_WORLD', WipeTable, true)
return true
end
end
local function Disable(self)
local element = self.PVPRole
if element then
element:Hide()
self:UnregisterEvent('UNIT_NAME_UPDATE', Path)
self:UnregisterEvent('ARENA_OPPONENT_UPDATE', Event)
self:UnregisterEvent('UPDATE_BATTLEFIELD_SCORE', Event)
self:UnregisterEvent('UNIT_TARGET', Path)
self:UnregisterEvent('PLAYER_TARGET_CHANGED', Path)
self:UnregisterEvent('PLAYER_ENTERING_WORLD', WipeTable)
end
end
oUF:AddElement('PVPRole', Path, Enable, Disable)

View File

@@ -0,0 +1,313 @@
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local NP = E:GetModule('NamePlates')
local oUF = E.oUF
local _G = _G
local pairs, ipairs, ceil, floor, tonumber = pairs, ipairs, ceil, floor, tonumber
local wipe, strmatch, strlower, strfind = wipe, strmatch, strlower, strfind
local GetLocale = GetLocale
local IsInInstance = IsInInstance
local UnitIsPlayer = UnitIsPlayer
local GetQuestLogSpecialItemInfo = GetQuestLogSpecialItemInfo
local C_QuestLog_GetTitleForLogIndex = C_QuestLog.GetTitleForLogIndex
local C_QuestLog_GetNumQuestLogEntries = C_QuestLog.GetNumQuestLogEntries
local C_QuestLog_GetQuestIDForLogIndex = C_QuestLog.GetQuestIDForLogIndex
local ThreatTooltip = THREAT_TOOLTIP:gsub('%%d', '%%d-')
local questIcons = {
iconTypes = { 'Default', 'Item', 'Skull', 'Chat' },
indexByID = {}, --[questID] = questIndex
activeQuests = {} --[questTitle] = questID
}
NP.QuestIcons = questIcons
local typesLocalized = {
enUS = {
--- short matching applies here so,
-- kill: killed, destory: destoryed, etc ...
KILL = {'slain', 'destroy', 'eliminate', 'repel', 'kill', 'defeat'},
CHAT = {'speak', 'talk'}
},
deDE = {
KILL = {'besiegen', 'besiegt', 'getötet', 'töten', 'tötet', 'vernichtet', 'zerstört', 'genährt'},
CHAT = {'befragt', 'sprecht'}
},
ruRU = {
KILL = {'убит', 'уничтож', 'разбомблен', 'разбит', 'сразит'},
CHAT = {'поговорит', 'спрашивать'}
},
esMX = {
-- asesinad: asesinado, asesinados, asesinada, asesinadas
-- derrota: derrotar, derrotado, derrotados, derrotada, derrotadas
-- destrui: destruir, destruido, destruidos, destruida, destruidas
-- elimin: eliminar, elimine, eliminadas, eliminada, eliminados, eliminado
-- repel: repele, repelido, repelidos, repelida, repelidas
KILL = {'asesinad', 'destrui', 'elimin', 'repel', 'derrota'},
CHAT = {'habla', 'pídele'}
},
ptBR = {
-- destrui: above but also destruição
-- repel: repelir, repelido, repelidos, repelida, repelidas
KILL = {'morto', 'morta', 'matar', 'destrui', 'elimin', 'repel', 'derrota'},
CHAT = {'falar', 'pedir'}
},
frFR = {
-- tué: tués, tuée, tuées
-- abattu: abattus, abattue
-- détrui: détruite, détruire, détruit, détruits, détruites
-- repouss: repousser, repoussés, repoussée, repoussées
-- élimin: éliminer, éliminé, éliminés, éliminée, éliminées
KILL = {'tué', 'tuer', 'attaqué', 'attaque', 'abattre', 'abattu', 'détrui', 'élimin', 'repouss', 'vaincu', 'vaincre'},
-- demande: demander, demandez
-- parle: parler, parlez
CHAT = {'parle', 'demande'}
},
koKR = {
KILL = {'쓰러뜨리기', '물리치기', '공격', '파괴'},
CHAT = {'대화'}
},
zhCN = {
KILL = {'消灭', '摧毁', '击败', '毁灭', '击退'},
CHAT = {'交谈', '谈一谈'}
},
zhTW = {
KILL = {'毀滅', '擊退', '殺死'},
CHAT = {'交談', '說話'}
},
}
local questTypes = typesLocalized[GetLocale()] or typesLocalized.enUS
local function CheckTextForQuest(text)
local x, y = strmatch(text, '(%d+)/(%d+)')
if x and y then
return floor(y - x)
elseif not strmatch(text, ThreatTooltip) then
local progress = tonumber(strmatch(text, '([%d%.]+)%%'))
if progress and progress <= 100 then
return ceil(100 - progress), true
end
end
end
NP.QuestIcons.CheckTextForQuest = CheckTextForQuest
local function GetQuests(unitID)
if IsInInstance() then return end
E.ScanTooltip:SetOwner(_G.UIParent, 'ANCHOR_NONE')
E.ScanTooltip:SetUnit(unitID)
E.ScanTooltip:Show()
local QuestList, notMyQuest, activeID
for i = 3, E.ScanTooltip:NumLines() do
local str = _G['ElvUI_ScanTooltipTextLeft' .. i]
local text = str and str:GetText()
if not text or text == '' then return end
if UnitIsPlayer(text) then
notMyQuest = text ~= E.myname
elseif text and not notMyQuest then
local count, percent = CheckTextForQuest(text)
-- this line comes from one line up in the tooltip
local activeQuest = questIcons.activeQuests[text]
if activeQuest then activeID = activeQuest end
if count then
local type, index, texture, _
if activeID then
index = questIcons.indexByID[activeID]
_, texture = GetQuestLogSpecialItemInfo(index)
end
if texture then
type = 'QUEST_ITEM'
else
local lowerText = strlower(text)
-- check kill type first
for _, listText in ipairs(questTypes.KILL) do
if strfind(lowerText, listText, nil, true) then
type = 'KILL'
break
end
end
-- check chat type if kill type doesn't exist
if not type then
for _, listText in ipairs(questTypes.CHAT) do
if strfind(lowerText, listText, nil, true) then
type = 'CHAT'
break
end
end
end
end
if not QuestList then QuestList = {} end
QuestList[#QuestList + 1] = {
isPercent = percent,
itemTexture = texture,
objectiveCount = count,
questType = type or 'DEFAULT',
-- below keys are currently unused
questLogIndex = index,
questID = activeID
}
end
end
end
E.ScanTooltip:Hide()
return QuestList
end
local function hideIcons(element)
for _, object in pairs(questIcons.iconTypes) do
local icon = element[object]
icon:Hide()
if icon.Text then
icon.Text:SetText('')
end
end
end
local function Update(self, event, arg1)
local element = self.QuestIcons
if not element then return end
local unit = (event == 'UNIT_NAME_UPDATE' and arg1) or self.unit
if unit ~= self.unit then return end
if element.PreUpdate then
element:PreUpdate()
end
hideIcons(element)
local QuestList = GetQuests(unit)
if QuestList then
element:Show()
else
element:Hide()
return
end
local shownCount
for i = 1, #QuestList do
local quest = QuestList[i]
local objectiveCount = quest.objectiveCount
local questType = quest.questType
local isPercent = quest.isPercent
if isPercent or objectiveCount > 0 then
local icon
if questType == 'DEFAULT' then
icon = element.Default
elseif questType == 'KILL' then
icon = element.Skull
elseif questType == 'CHAT' then
icon = element.Chat
elseif questType == 'QUEST_ITEM' then
icon = element.Item
end
if icon and not icon:IsShown() then
shownCount = (shownCount and shownCount + 1) or 0
local size = icon.size or 25
local setPosition = icon.position or 'TOPLEFT'
local newPosition = E.InversePoints[setPosition]
local offset = shownCount * (5 + size)
icon:Show()
icon:ClearAllPoints()
icon:Point(newPosition, element, newPosition, (strmatch(setPosition, 'LEFT') and -offset) or offset, 0)
if questType ~= 'CHAT' and icon.Text and (isPercent or objectiveCount > 1) then
icon.Text:SetText((isPercent and objectiveCount..'%') or objectiveCount)
end
if questType == 'QUEST_ITEM' then
element.Item:SetTexture(quest.itemTexture)
end
end
end
end
if element.PostUpdate then
return element:PostUpdate()
end
end
local function Path(self, ...)
return (self.QuestIcons.Override or Update) (self, ...)
end
local function ForceUpdate(element)
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function Enable(self)
local element = self.QuestIcons
if element then
element.__owner = self
element.ForceUpdate = ForceUpdate
if element.Default:IsObjectType('Texture') and not element.Default:GetAtlas() then
element.Default:SetAtlas('SmallQuestBang')
end
if element.Skull:IsObjectType('Texture') and not element.Skull:GetTexture() then
element.Skull:SetTexture(E.Media.Textures.SkullIcon)
end
if element.Chat:IsObjectType('StatusBar') and not element.Chat:GetTexture() then
element.Chat:SetTexture([[Interface\WorldMap\ChatBubble_64.PNG]])
end
self:RegisterEvent('QUEST_LOG_UPDATE', Path, true)
self:RegisterEvent('UNIT_NAME_UPDATE', Path, true)
self:RegisterEvent('PLAYER_ENTERING_WORLD', Path, true)
return true
end
end
local function Disable(self)
local element = self.QuestIcons
if element then
element:Hide()
hideIcons(element)
self:UnregisterEvent('QUEST_LOG_UPDATE', Path)
self:UnregisterEvent('UNIT_NAME_UPDATE', Path)
self:UnregisterEvent('PLAYER_ENTERING_WORLD', Path)
end
end
local frame = CreateFrame('Frame')
frame:RegisterEvent('QUEST_ACCEPTED')
frame:RegisterEvent('QUEST_REMOVED')
frame:RegisterEvent('PLAYER_ENTERING_WORLD')
frame:SetScript('OnEvent', function(self, event)
wipe(questIcons.indexByID)
wipe(questIcons.activeQuests)
for i = 1, C_QuestLog_GetNumQuestLogEntries() do
local id = C_QuestLog_GetQuestIDForLogIndex(i)
if id and id > 0 then
questIcons.indexByID[id] = i
local title = C_QuestLog_GetTitleForLogIndex(i)
if title then questIcons.activeQuests[title] = id end
end
end
if event == 'PLAYER_ENTERING_WORLD' then
self:UnregisterEvent(event)
end
end)
oUF:AddElement('QuestIcons', Path, Enable, Disable)

View File

@@ -0,0 +1,167 @@
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local NP = E:GetModule('NamePlates')
local UnitHealth = UnitHealth
local UnitIsUnit = UnitIsUnit
local UnitHealthMax = UnitHealthMax
--[[ Target Glow Style Option Variables
style1:'Border',
style2:'Background',
style3:'Top Arrow Only',
style4:'Side Arrows Only',
style5:'Border + Top Arrow',
style6:'Background + Top Arrow',
style7:'Border + Side Arrows',
style8:'Background + Side Arrows'
]]
local _, ns = ...
local oUF = ns.oUF
local function Update(self)
local element = self.TargetIndicator
if element.PreUpdate then
element:PreUpdate()
end
if element.TopIndicator then element.TopIndicator:Hide() end
if element.LeftIndicator then element.LeftIndicator:Hide() end
if element.RightIndicator then element.RightIndicator:Hide() end
if element.Shadow then element.Shadow:Hide() end
if element.Spark then element.Spark:Hide() end
if UnitIsUnit(self.unit, 'target') and (element.style ~= 'none') then
if element.TopIndicator and (element.style == 'style3' or element.style == 'style5' or element.style == 'style6') then
element.TopIndicator:Show()
end
if element.LeftIndicator and element.RightIndicator and (element.style == 'style4' or element.style == 'style7' or element.style == 'style8') then
element.RightIndicator:Show()
element.LeftIndicator:Show()
end
if element.Shadow and (element.style == 'style1' or element.style == 'style5' or element.style == 'style7') then
element.Shadow:Show()
end
if element.Spark and (element.style == 'style2' or element.style == 'style6' or element.style == 'style8') then
element.Spark:Show()
end
end
local r, g, b
local showIndicator
if UnitIsUnit(self.unit, 'target') then
showIndicator = true
r, g, b = NP.db.colors.glowColor.r, NP.db.colors.glowColor.g, NP.db.colors.glowColor.b
elseif not UnitIsUnit(self.unit, 'target') and element.lowHealthThreshold > 0 then
local health, maxHealth = UnitHealth(self.unit), UnitHealthMax(self.unit)
local perc = (maxHealth > 0 and health/maxHealth) or 0
if perc <= element.lowHealthThreshold then
showIndicator = true
if perc <= element.lowHealthThreshold / 2 then
r, g, b = 1, 0, 0
else
r, g, b = 1, 1, 0
end
end
end
if showIndicator then
if element.TopIndicator and (element.style == 'style3' or element.style == 'style5' or element.style == 'style6') then
element.TopIndicator:SetVertexColor(r, g, b)
element.TopIndicator:SetTexture(element.arrow)
end
if element.LeftIndicator and element.RightIndicator and (element.style == 'style4' or element.style == 'style7' or element.style == 'style8') then
element.LeftIndicator:SetVertexColor(r, g, b)
element.RightIndicator:SetVertexColor(r, g, b)
element.LeftIndicator:SetTexture(element.arrow)
element.RightIndicator:SetTexture(element.arrow)
end
if element.Shadow and (element.style == 'style1' or element.style == 'style5' or element.style == 'style7') then
element.Shadow:Show()
element.Shadow:SetBackdropBorderColor(r, g, b)
end
if element.Spark and (element.style == 'style2' or element.style == 'style6' or element.style == 'style8') then
element.Spark:Show()
element.Spark:SetVertexColor(r, g, b)
end
end
if element.PostUpdate then
return element:PostUpdate(self.unit)
end
end
local function Path(self, ...)
return (self.TargetIndicator.Override or Update) (self, ...)
end
local function ForceUpdate(element)
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function Enable(self)
local element = self.TargetIndicator
if element then
element.__owner = self
element.ForceUpdate = ForceUpdate
if not element.style then
element.style = 'style1'
end
if not element.lowHealthThreshold then
element.lowHealthThreshold = .4
end
if element.Shadow and element.Shadow:IsObjectType('Frame') and not element.Shadow:GetBackdrop() then
element.Shadow:SetBackdrop({edgeFile = E.Media.Textures.GlowTex, edgeSize = E:Scale(5)})
end
if element.Spark and element.Spark:IsObjectType('Texture') and not element.Spark:GetTexture() then
element.Spark:SetTexture(E.Media.Textures.Spark)
end
if element.TopIndicator and element.TopIndicator:IsObjectType('Texture') and not element.TopIndicator:GetTexture() then
element.TopIndicator:SetTexture(E.Media.Textures.ArrowUp)
element.TopIndicator:SetRotation(3.14)
end
if element.LeftIndicator and element.LeftIndicator:IsObjectType('Texture') and not element.LeftIndicator:GetTexture() then
element.LeftIndicator:SetTexture(E.Media.Textures.ArrowUp)
element.LeftIndicator:SetRotation(1.57)
end
if element.RightIndicator and element.RightIndicator:IsObjectType('Texture') and not element.RightIndicator:GetTexture() then
element.RightIndicator:SetTexture(E.Media.Textures.ArrowUp)
element.RightIndicator:SetRotation(-1.57)
end
self:RegisterEvent('PLAYER_TARGET_CHANGED', Path, true)
return true
end
end
local function Disable(self)
local element = self.TargetIndicator
if element then
if element.TopIndicator then element.TopIndicator:Hide() end
if element.LeftIndicator then element.LeftIndicator:Hide() end
if element.RightIndicator then element.RightIndicator:Hide() end
if element.Shadow then element.Shadow:Hide() end
if element.Spark then element.Spark:Hide() end
self:UnregisterEvent('PLAYER_TARGET_CHANGED', Path)
end
end
oUF:AddElement('TargetIndicator', Path, Enable, Disable)