load ChatBubbles

This commit is contained in:
Crum
2017-12-21 00:31:07 -06:00
parent cc6080a4dc
commit fad73b0b79
4 changed files with 418 additions and 0 deletions
@@ -0,0 +1,203 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local M = E:GetModule("Misc");
-- local CH = E:GetModule("Chat");
-- local CC = E:GetModule("ClassCache");
--Cache global variables
--Lua functions
local select, unpack, type = select, unpack, type
local format, gsub = string.format, string.gsub
local strlower = strlower
--WoW API / Variables
local CreateFrame = CreateFrame
function M:UpdateBubbleBorder()
if not this.text then return end
if E.private.general.chatBubbles == "backdrop" then
if E.PixelMode then
this:SetBackdropBorderColor(this.text:GetTextColor())
else
local r, g, b = this.text:GetTextColor()
this.bordertop:SetTexture(r, g, b)
this.borderbottom:SetTexture(r, g, b)
this.borderleft:SetTexture(r, g, b)
this.borderright:SetTexture(r, g, b)
end
end
if E.private.chat.enable and E.private.general.classCache and E.private.general.classColorMentionsSpeech then
local classColorTable, isFirstWord, rebuiltString, lowerCaseWord, tempWord, wordMatch, classMatch
local text = this.text:GetText()
if text and text:match("%s-[^%s]+%s*") then
for word in text:gmatch("%s-[^%s]+%s*") do
tempWord = word:gsub("^[%s%p]-([^%s%p]+)([%-]?[^%s%p]-)[%s%p]*$","%1%2")
lowerCaseWord = tempWord:lower()
classMatch = CC:GetCacheTable()[E.myrealm][tempWord]
wordMatch = classMatch and lowerCaseWord
if wordMatch and not E.global.chat.classColorMentionExcludedNames[wordMatch] then
classColorTable = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[classMatch] or RAID_CLASS_COLORS[classMatch]
word = word:gsub(tempWord:gsub("%-","%%-"), format("\124cff%.2x%.2x%.2x%s\124r", classColorTable.r*255, classColorTable.g*255, classColorTable.b*255, tempWord))
end
if not isFirstWord then
rebuiltString = word
isFirstWord = true
else
rebuiltString = format("%s%s", rebuiltString, word)
end
end
if rebuiltString ~= nil then
this.text:SetText(rebuiltString)
end
end
end
end
function M:SkinBubble(frame)
local mult = E.mult * UIParent:GetScale()
for i = 1, frame:GetNumRegions() do
local region = select(i, frame:GetRegions())
if region:GetObjectType() == "Texture" then
region:SetTexture(nil)
elseif region:GetObjectType() == "FontString" then
frame.text = region
end
end
if frame.text then
if E.private.general.chatBubbles == "backdrop" then
if E.PixelMode then
E:SetTemplate(frame, "Transparent", true)
frame:SetBackdropColor(unpack(E.media.backdropfadecolor))
frame:SetBackdropBorderColor(0, 0, 0)
else
frame:SetBackdrop(nil)
end
local r, g, b = frame.text:GetTextColor()
if not E.PixelMode then
if not frame.backdrop then
frame.backdrop = frame:CreateTexture(nil, "BACKGROUND")
frame.backdrop:SetAllPoints(frame)
frame.backdrop:SetTexture(unpack(E.media.backdropfadecolor))
frame.bordertop = frame:CreateTexture(nil, "OVERLAY")
frame.bordertop:SetPoint("TOPLEFT", frame, "TOPLEFT", -mult*2, mult*2)
frame.bordertop:SetPoint("TOPRIGHT", frame, "TOPRIGHT", mult*2, mult*2)
frame.bordertop:SetHeight(mult)
frame.bordertop:SetTexture(r, g, b)
frame.bordertop.backdrop = frame:CreateTexture(nil, "BORDER")
frame.bordertop.backdrop:SetPoint("TOPLEFT", frame.bordertop, "TOPLEFT", -mult, mult)
frame.bordertop.backdrop:SetPoint("TOPRIGHT", frame.bordertop, "TOPRIGHT", mult, mult)
frame.bordertop.backdrop:SetHeight(mult * 3)
frame.bordertop.backdrop:SetTexture(0, 0, 0)
frame.borderbottom = frame:CreateTexture(nil, "OVERLAY")
frame.borderbottom:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", -mult*2, -mult*2)
frame.borderbottom:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", mult*2, -mult*2)
frame.borderbottom:SetHeight(mult)
frame.borderbottom:SetTexture(r, g, b)
frame.borderbottom.backdrop = frame:CreateTexture(nil, "BORDER")
frame.borderbottom.backdrop:SetPoint("BOTTOMLEFT", frame.borderbottom, "BOTTOMLEFT", -mult, -mult)
frame.borderbottom.backdrop:SetPoint("BOTTOMRIGHT", frame.borderbottom, "BOTTOMRIGHT", mult, -mult)
frame.borderbottom.backdrop:SetHeight(mult * 3)
frame.borderbottom.backdrop:SetTexture(0, 0, 0)
frame.borderleft = frame:CreateTexture(nil, "OVERLAY")
frame.borderleft:SetPoint("TOPLEFT", frame, "TOPLEFT", -mult*2, mult*2)
frame.borderleft:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", mult*2, -mult*2)
frame.borderleft:SetWidth(mult)
frame.borderleft:SetTexture(r, g, b)
frame.borderleft.backdrop = frame:CreateTexture(nil, "BORDER")
frame.borderleft.backdrop:SetPoint("TOPLEFT", frame.borderleft, "TOPLEFT", -mult, mult)
frame.borderleft.backdrop:SetPoint("BOTTOMLEFT", frame.borderleft, "BOTTOMLEFT", -mult, -mult)
frame.borderleft.backdrop:SetWidth(mult * 3)
frame.borderleft.backdrop:SetTexture(0, 0, 0)
frame.borderright = frame:CreateTexture(nil, "OVERLAY")
frame.borderright:SetPoint("TOPRIGHT", frame, "TOPRIGHT", mult*2, mult*2)
frame.borderright:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -mult*2, -mult*2)
frame.borderright:SetWidth(mult)
frame.borderright:SetTexture(r, g, b)
frame.borderright.backdrop = frame:CreateTexture(nil, "BORDER")
frame.borderright.backdrop:SetPoint("TOPRIGHT", frame.borderright, "TOPRIGHT", mult, mult)
frame.borderright.backdrop:SetPoint("BOTTOMRIGHT", frame.borderright, "BOTTOMRIGHT", mult, -mult)
frame.borderright.backdrop:SetWidth(mult * 3)
frame.borderright.backdrop:SetTexture(0, 0, 0)
end
else
frame:SetBackdropColor(unpack(E.media.backdropfadecolor))
frame:SetBackdropBorderColor(r, g, b)
end
E:FontTemplate(frame.text, E.LSM:Fetch("font", E.private.general.chatBubbleFont), E.private.general.chatBubbleFontSize, E.private.general.chatBubbleFontOutline)
elseif E.private.general.chatBubbles == "backdrop_noborder" then
frame:SetBackdrop(nil)
if not frame.backdrop then
frame.backdrop = frame:CreateTexture(nil, "ARTWORK")
E:SetInside(frame.backdrop, frame, 4, 4)
frame.backdrop:SetTexture(unpack(E.media.backdropfadecolor))
end
E:FontTemplate(frame.text, E.LSM:Fetch("font", E.private.general.chatBubbleFont), E.private.general.chatBubbleFontSize, E.private.general.chatBubbleFontOutline)
frame:SetClampedToScreen(false)
elseif E.private.general.chatBubbles == "nobackdrop" then
frame:SetBackdrop(nil)
E:FontTemplate(frame.text, E.LSM:Fetch("font", E.private.general.chatBubbleFont), E.private.general.chatBubbleFontSize, E.private.general.chatBubbleFontOutline)
frame:SetClampedToScreen(false)
end
end
HookScript(frame, "OnShow", M.UpdateBubbleBorder)
frame:SetFrameStrata("DIALOG")
M.UpdateBubbleBorder(frame)
frame.isBubblePowered = true
end
function M:IsChatBubble(frame)
for i = 1, frame:GetNumRegions() do
local region = select(i, frame:GetRegions())
if region.GetTexture and region:GetTexture() and type(region:GetTexture() == "string" and strlower(region:GetTexture()) == [[interface\tooltips\chatbubble-background]]) then return true end
end
return false
end
local numChildren = 0
function M:LoadChatBubbles()
if E.private.general.bubbles == false then
E.private.general.chatBubbles = "disabled"
E.private.general.bubbles = nil
end
if E.private.general.chatBubbles == "disabled" then return end
local frame = CreateFrame("Frame")
frame.lastupdate = -2
frame:SetScript("OnUpdate", function()
this.lastupdate = this.lastupdate + arg1
if this.lastupdate < .1 then return end
this.lastupdate = 0
local count = WorldFrame:GetNumChildren()
if count ~= numChildren then
for i = numChildren + 1, count do
local frame = select(i, WorldFrame:GetChildren())
if M:IsChatBubble(frame) then
M:SkinBubble(frame)
end
end
numChildren = count
end
end)
end
@@ -1,3 +1,5 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/"> <Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="Misc.lua"/>
<Script file="AFK.lua"/> <Script file="AFK.lua"/>
<Script file="ChatBubbles.lua"/>
</Ui> </Ui>
+209
View File
@@ -0,0 +1,209 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local M = E:NewModule("Misc", "AceEvent-3.0", "AceTimer-3.0");
E.Misc = M
--Cache global variables
--Lua functions
local format, gsub = string.format, string.gsub
--WoW API / Variables
local CanGuildBankRepair = CanGuildBankRepair
local CanMerchantRepair = CanMerchantRepair
local GetFriendInfo = GetFriendInfo
local GetGuildBankWithdrawMoney = GetGuildBankWithdrawMoney
local GetGuildRosterInfo = GetGuildRosterInfo
local GetNumFriends = GetNumFriends
local GetNumGuildMembers = GetNumGuildMembers
local GetNumPartyMembers = GetNumPartyMembers
local GetNumRaidMembers = GetNumRaidMembers
local GetPartyMember = GetPartyMember
local GetRepairAllCost = GetRepairAllCost
local GuildRoster = GuildRoster
local InCombatLockdown = InCombatLockdown
local IsInGuild = IsInGuild
local IsInInstance = IsInInstance
local IsShiftKeyDown = IsShiftKeyDown
local RepairAllItems = RepairAllItems
local UninviteUnit = UninviteUnit
local UnitInRaid = UnitInRaid
local UnitName = UnitName
local UIErrorsFrame = UIErrorsFrame
local MAX_PARTY_MEMBERS = MAX_PARTY_MEMBERS
local interruptMsg = INTERRUPTED.." %s's \124cff71d5ff\124Hspell:%d\124h[%s]\124h\124r!"
function M:ErrorFrameToggle(event)
if not E.db.general.hideErrorFrame then return end
if event == "PLAYER_REGEN_DISABLED" then
UIErrorsFrame:UnregisterEvent("UI_ERROR_MESSAGE")
else
UIErrorsFrame:RegisterEvent("UI_ERROR_MESSAGE")
end
end
function M:COMBAT_LOG_EVENT_UNFILTERED(_, _, event, _, sourceName, _, _, destName, _, _, _, _, spellID, spellName)
if E.db.general.interruptAnnounce == "NONE" then return end
if not (event == "SPELL_INTERRUPT" and sourceName == UnitName("player")) then return end
local party = GetNumPartyMembers()
if E.db.general.interruptAnnounce == "SAY" then
if party > 0 then
SendChatMessage(format(interruptMsg, destName, spellID, spellName), "SAY")
end
elseif E.db.general.interruptAnnounce == "EMOTE" then
if party > 0 then
SendChatMessage(format(interruptMsg, destName, spellID, spellName), "EMOTE")
end
else
local raid = GetNumRaidMembers()
local _, instanceType = IsInInstance()
local battleground = instanceType == "pvp"
if E.db.general.interruptAnnounce == "PARTY" then
if party > 0 then
SendChatMessage(format(interruptMsg, destName, spellID, spellName), battleground and "BATTLEGROUND" or "PARTY")
end
elseif E.db.general.interruptAnnounce == "RAID" then
if raid > 0 then
SendChatMessage(format(interruptMsg, destName, spellID, spellName), battleground and "BATTLEGROUND" or "RAID")
elseif party > 0 then
SendChatMessage(format(interruptMsg, destName, spellID, spellName), battleground and "BATTLEGROUND" or "PARTY")
end
elseif E.db.general.interruptAnnounce == "RAID_ONLY" then
if raid > 0 then
SendChatMessage(format(interruptMsg, destName, spellID, spellName), battleground and "BATTLEGROUND" or "RAID")
end
end
end
end
function M:MERCHANT_SHOW()
if E.db.general.vendorGrays then
E:GetModule("Bags"):VendorGrays(nil, true)
end
local autoRepair = E.db.general.autoRepair
if IsShiftKeyDown() or autoRepair == "NONE" or not CanMerchantRepair() then return end
local cost, possible = GetRepairAllCost()
local withdrawLimit = GetGuildBankWithdrawMoney()
if autoRepair == "GUILD" and (not CanGuildBankRepair() or cost > withdrawLimit) then
autoRepair = "PLAYER"
end
if cost > 0 then
if possible then
RepairAllItems(autoRepair == "GUILD")
if autoRepair == "GUILD" then
E:Print(L["Your items have been repaired using guild bank funds for: "]..E:FormatMoney(cost, "BLIZZARD", true))
else
E:Print(L["Your items have been repaired for: "]..E:FormatMoney(cost, "BLIZZARD", true))
end
else
E:Print(L["You don't have enough money to repair."])
end
end
end
function M:DisbandRaidGroup()
if InCombatLockdown() then return end -- Prevent user error in combat
if UnitInRaid("player") then
for i = 1, GetNumRaidMembers() do
local name, _, _, _, _, _, _, online = GetRaidRosterInfo(i)
if online and name ~= E.myname then
UninviteUnit(name)
end
end
else
for i = MAX_PARTY_MEMBERS, 1, -1 do
if GetPartyMember(i) then
UninviteUnit(UnitName("party"..i))
end
end
end
LeaveParty()
end
function M:PVPMessageEnhancement(_, msg)
if not E.db.general.enhancedPvpMessages then return end
local _, instanceType = IsInInstance()
if instanceType == "pvp" or instanceType == "arena" then
RaidNotice_AddMessage(RaidBossEmoteFrame, msg, ChatTypeInfo["RAID_BOSS_EMOTE"])
end
end
local hideStatic = false
function M:AutoInvite(event, leaderName)
if not E.db.general.autoAcceptInvite then return end
if event == "PARTY_INVITE_REQUEST" then
if GetNumPartyMembers() > 0 or GetNumRaidMembers() > 0 then return end
hideStatic = true
-- Update Guild and Friendlist
local numFriends = GetNumFriends()
if numFriends > 0 then ShowFriends() end
if IsInGuild() then GuildRoster() end
local inGroup = false
for friendIndex = 1, numFriends do
local friendName = gsub(GetFriendInfo(friendIndex), "-.*", "")
if friendName == leaderName then
AcceptGroup()
inGroup = true
break
end
end
if not inGroup then
for guildIndex = 1, GetNumGuildMembers(true) do
local guildMemberName = gsub(GetGuildRosterInfo(guildIndex), "-.*", "")
if guildMemberName == leaderName then
AcceptGroup()
inGroup = true
break
end
end
end
elseif event == "PARTY_MEMBERS_CHANGED" and hideStatic == true then
StaticPopup_Hide("PARTY_INVITE")
hideStatic = false
end
end
function M:ForceCVars()
if E.private.general.loot then
if GetCVar("lootUnderMouse") == "1" then
E:DisableMover("LootFrameMover")
else
E:EnableMover("LootFrameMover")
end
end
end
function M:Initialize()
-- self:LoadRaidMarker()
-- self:LoadLoot()
-- self:LoadLootRoll()
self:LoadChatBubbles()
self:RegisterEvent("MERCHANT_SHOW")
self:RegisterEvent("PLAYER_REGEN_DISABLED", "ErrorFrameToggle")
self:RegisterEvent("PLAYER_REGEN_ENABLED", "ErrorFrameToggle")
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:RegisterEvent("CHAT_MSG_BG_SYSTEM_HORDE", "PVPMessageEnhancement")
self:RegisterEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE", "PVPMessageEnhancement")
self:RegisterEvent("CHAT_MSG_BG_SYSTEM_NEUTRAL", "PVPMessageEnhancement")
self:RegisterEvent("PARTY_INVITE_REQUEST", "AutoInvite")
self:RegisterEvent("PARTY_MEMBERS_CHANGED", "AutoInvite")
self:RegisterEvent("CVAR_UPDATE", "ForceCVars")
self:RegisterEvent("PLAYER_ENTERING_WORLD", "ForceCVars")
end
local function InitializeCallback()
M:Initialize()
end
E:RegisterModule(M:GetName(), InitializeCallback)
+4
View File
@@ -7,6 +7,10 @@ V["general"] = {
["glossTex"] = "ElvUI Norm", ["glossTex"] = "ElvUI Norm",
["dmgfont"] = "PT Sans Narrow", ["dmgfont"] = "PT Sans Narrow",
["namefont"] = "PT Sans Narrow", ["namefont"] = "PT Sans Narrow",
["chatBubbles"] = "backdrop",
["chatBubbleFont"] = "PT Sans Narrow",
["chatBubbleFontSize"] = 14,
["chatBubbleFontOutline"] = "NONE",
["pixelPerfect"] = true, ["pixelPerfect"] = true,
["replaceBlizzFonts"] = true, ["replaceBlizzFonts"] = true,
["minimap"] = { ["minimap"] = {