From 4389435f3f101576a2e7fb394e6354c05dc236c1 Mon Sep 17 00:00:00 2001 From: Aviana Date: Tue, 5 Apr 2016 22:11:26 +0200 Subject: [PATCH] Tag system revamp --- LunaUnitFrames.lua | 2 +- modules/Tags.lua | 31 ++++++++++++------------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/LunaUnitFrames.lua b/LunaUnitFrames.lua index 1fc1d9e4..90bfd90c 100644 --- a/LunaUnitFrames.lua +++ b/LunaUnitFrames.lua @@ -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") diff --git a/modules/Tags.lua b/modules/Tags.lua index dc7f4a16..65774849 100644 --- a/modules/Tags.lua +++ b/modules/Tags.lua @@ -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