Skip to content

Commit

Permalink
Tag system revamp
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviana committed Apr 5, 2016
1 parent 008619a commit 4389435
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion LunaUnitFrames.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ LunaUF = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceConsole-2.0", "AceDB
LunaUF:RegisterDB("LunaDB")

-- Assets ----------------------------------------------------------------------------------
LunaUF.Version = 2005
LunaUF.Version = 2006
LunaUF.BS = AceLibrary("Babble-Spell-2.2")
LunaUF.Banzai = AceLibrary("Banzai-1.0")
LunaUF.HealComm = AceLibrary("HealComm-1.0")
Expand Down
31 changes: 12 additions & 19 deletions modules/Tags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -596,31 +596,24 @@ local defaultTags = {
}

function GetTagText(text,unit)
if not text or text == "" then return "" end
local maxTags = 20
local numfound = 1
if not text or text == "" then return text or "" end
local tag, tagtext
local result = text
while numfound and numfound > 0 and maxTags > 0 do
_,numfound,tagtext = string.find(result,"%[(color:[A-Fa-f0-9]+)%]")
if not tagtext then
_,numfound,tagtext = string.find(result,"%[([%s%a:]+)%]")
end
_,_,tag = string.find(result,"%[(.+)%]")
while tag do
_,_,tagtext = string.find(tag,"color:(%x%x%x%x%x%x)")
if tagtext then
_,_,tag = string.find(tagtext,"([%a:]+)")
if defaultTags[tag] then
if tag == "color" then
local colorcode
_,_,colorcode = string.find(tagtext,"%a+:([A-Fa-f0-9]+)")
result = string.gsub(result, "%["..tagtext.."%]", defaultTags[tag](colorcode))
else
result = string.gsub(result, "%["..tagtext.."%]", string.gsub(tagtext,tag,defaultTags[tag](unit)))
end
tagtext = defaultTags["color"](tagtext)
else
_,_,tagtext = string.find(tag,"([%a:]+)")
if tagtext and defaultTags[tagtext] then
tagtext = defaultTags[tagtext](unit)
else
result = string.gsub(result, "%["..tagtext.."%]", "#invalidTag#")
tagtext = "#invalidTag#"
end
end
maxTags = maxTags - 1
result = string.gsub(result, "(%[[%w:]+%])", tagtext, 1)
_,_,tag = string.find(result,"%[(.+)%]")
end
return result
end
Expand Down

0 comments on commit 4389435

Please sign in to comment.