Refactoring of Styles. Still buggy

His Dad [02-17-16 - 05:16]
Refactoring of Styles. Still buggy
Filename
AIResearchGrid.lua
AIResearchGrid.txt
doc/changelog.txt
diff --git a/AIResearchGrid.lua b/AIResearchGrid.lua
index fab5dcc..32932cc 100644
--- a/AIResearchGrid.lua
+++ b/AIResearchGrid.lua
@@ -9,10 +9,13 @@
 -- Glass, Xivkyn, Ancient Orc, and Mercenary Akaviri added in by Scinutz

 local _
+local COLOR_ORANGE = ZO_ColorDef:New(220/255, 129/255, 34/255)
+local COLOR_RED = ZO_ColorDef:New(255/255, 25/255, 25/255)
+local COLOR_MOTIF_KNOWN = ZO_ColorDef:New(0.2, 1, 0.2, 1)   -- Green
 AIRG = {}

 AIRG.name = "AIResearchGrid"
-AIRG.version = "3.3.10"
+AIRG.version = "3.4.0"
 AIRG.initialised = false
 AIRG.processing = false
 AIRG.all = " #ALL"  -- Default displayname for Virtual character, overrwritten by Localised version
@@ -62,7 +65,7 @@ function AIRG.ResearchCompleted()
     AIRG.OnCraftSelected()              -- Redisplay data for the current profession
 end -- AIRG.ResearchEnded

-function AIRG.StyleLearned(eventCode, styleIndex)
+function AIRG.StyleLearned(eventCode, StyleIndex)
     AIRG.PopulateStyleData()
     AIRG.DisplayStyles()
     AIRG.PopulateAll()
@@ -308,40 +311,46 @@ function AIRG.initUI()
 --    AIRG.UI.columnFooterTitle:SetText(GetString(SI_SMITHING_RESEARCH_LINE_HEADER))
     AIRG.UI.columnFooterTitle:SetText(GetString(SI_CRAFTING_COMPONENT_TOOLTIP_TRAITS))   -- "Traits"

-  AIResearchGrid:SetHeight(AIRG.vars.showMotifs and 756 or 636)
+	AIResearchGrid:SetHeight(AIRG.vars.showMotifs and 756 or 636)

     -- BUILD THE MOTIF ICONS ACROSS THE BOTTOM
-    -- Note that for now, we're just setting up 15 icons and stuff is configured manually
-    -- but we can fix it later. It's not like it's going to have an overhead on processing. :)
     -- It's set-up inside a container frame to make hiding or showing the whole lot simpler.
     AIRG.UI.motifSection = WINDOW_MANAGER:CreateControl("AIResearchMotifSection", AIResearchGrid, CT_CONTROL)
     AIRG.UI.motifSection:SetDimensions(750, 100)
     AIRG.UI.motifSection:SetAnchor(BOTTOMLEFT, AIResearchGrid, BOTTOMLEFT, 0, 0)
     AIRG.UI.motifSection:SetHidden(not AIRG.vars.showMotifs)

-    AIRG.UI.motifButtons = {}
-	local yoffset = 0
-	local xoffset,j
-    for i = 1, 20 do
+    AIRG.UI.StyleSingleButtons = {}
+    for StyleIndex, Style in ipairs(AIRG.StyleSingleDat) do
+        AIRG.UI.StyleSingleButtons[StyleIndex] = WINDOW_MANAGER:CreateControl("AIRGStyleSingleButton" .. tostring(StyleIndex), AIRG.UI.motifSection, CT_TEXTURE)
+        AIRG.UI.StyleSingleButtons[StyleIndex]:SetDimensions(40, 40)
+        AIRG.UI.StyleSingleButtons[StyleIndex]:SetAnchor(TOPLEFT, AIRG.UI.motifSection, TOPLEFT, 40*StyleIndex , 0)
+        AIRG.UI.StyleSingleButtons[StyleIndex]:SetTexture(Style[3] .. "up.dds")
+        AIRG.UI.StyleSingleButtons[StyleIndex]:SetMouseEnabled(true)
+        tDesc ,_,_,_,_ = GetSmithingStyleItemInfo( Style[2] )			--Mat name
+        AIRG.UI.StyleSingleButtons[StyleIndex].tooltipText = zo_strformat("<<t:1>>\n<<t:2>>", GetString("SI_ITEMSTYLE",Style[1]), tDesc)
+        AIRG.UI.StyleSingleButtons[StyleIndex]:SetHandler("OnMouseEnter", function (self)
+                                                ZO_Tooltips_ShowTextTooltip(self, TOP, self.tooltipText)
+                                            end)
+        AIRG.UI.StyleSingleButtons[StyleIndex]:SetHandler("OnMouseExit", function (self)
+                                                ZO_Tooltips_HideTextTooltip()
+                                            end)
+    end

-		if i > 14 then	--split normal from chapter
-			yoffset = 50
-			xoffset = i -14
-		else
-			xoffset = i
-		end
-        AIRG.UI.motifButtons[i] = WINDOW_MANAGER:CreateControl("AIResearchGridMotifButton" .. tostring(i), AIRG.UI.motifSection, CT_TEXTURE)
-        AIRG.UI.motifButtons[i]:SetDimensions(40, 40)
-        AIRG.UI.motifButtons[i]:SetAnchor(TOPLEFT, AIRG.UI.motifSection, TOPLEFT, 40*xoffset + 40, yoffset)
-        AIRG.UI.motifButtons[i]:SetTexture(AIRG.styleLookupIcons[i] .. "up.dds")
-        AIRG.UI.motifButtons[i]:SetMouseEnabled(true)
-         j = AIRG.styleLookupValue[i]
-        tDesc ,_,_,_,_ = GetSmithingStyleItemInfo( AIRG.styleLookupItem[i] )
-        AIRG.UI.motifButtons[i].tooltipText = zo_strformat("<<t:1>>\n<<t:2>>", GetString("SI_ITEMSTYLE",j), tDesc)
-        AIRG.UI.motifButtons[i]:SetHandler("OnMouseEnter", function (self)
+	AIRG.UI.StyleChapterButtons = {}
+    for StyleIndex, Style in ipairs(AIRG.StyleChapterDat) do
+        AIRG.UI.StyleChapterButtons[StyleIndex] = WINDOW_MANAGER:CreateControl("AIRGStyleChapterButton" .. tostring(StyleIndex), AIRG.UI.motifSection, CT_TEXTURE)
+        AIRG.UI.StyleChapterButtons[StyleIndex]:SetDimensions(40, 40)
+        AIRG.UI.StyleChapterButtons[StyleIndex]:SetAnchor(TOPLEFT, AIRG.UI.motifSection, TOPLEFT, 40*StyleIndex , 40)
+        AIRG.UI.StyleChapterButtons[StyleIndex]:SetTexture(Style[3] .. "up.dds")
+        AIRG.UI.StyleChapterButtons[StyleIndex]:SetMouseEnabled(true)
+    --    tDesc ,_,_,_,_ = GetSmithingStyleItemInfo( Style[2] )			--Mat name
+    --    AIRG.UI.StyleChapterButtons[StyleIndex].tooltipText = zo_strformat("<<t:1>>\n<<t:2>>", GetString("SI_ITEMSTYLE",Style[1]), tDesc)
+		AIRG.UI.StyleChapterButtons[StyleIndex].tooltipText = ""
+        AIRG.UI.StyleChapterButtons[StyleIndex]:SetHandler("OnMouseEnter", function (self)
                                                 ZO_Tooltips_ShowTextTooltip(self, TOP, self.tooltipText)
                                             end)
-        AIRG.UI.motifButtons[i]:SetHandler("OnMouseExit", function (self)
+        AIRG.UI.StyleChapterButtons[StyleIndex]:SetHandler("OnMouseExit", function (self)
                                                 ZO_Tooltips_HideTextTooltip()
                                             end)
     end
@@ -491,9 +500,15 @@ function AIRG.DeleteCharacter(charName)
             AIRG.vars.data[charName] = nil
             d(AIRG.L["DeleteTrue"] .. charName)
         end
-        if (AIRG.vars.styles[charName] ~= nil) then
-            AIRG.vars.styles[charName] = nil
+
+        if (AIRG.vars.StyleSingle[charName] ~= nil) then
+            AIRG.vars.StyleSingle[charName] = nil
         end
+
+        if (AIRG.vars.StyleChapter[charName] ~= nil) then
+            AIRG.vars.StyleChapter[charName] = nil
+        end
+
         AIRG.PopulateAll()
 		--this part is new, Thank you Garkin
         for i, item in ipairs(AIRG.UI.charDropdown.dropdown.m_sortedItems) do
@@ -535,63 +550,26 @@ end -- AIRG.PopulateMatrix

 -- Lookup the style data for the current character and send it to saved vars.
 function AIRG.PopulateStyleData()
-      AIRG.vars.styles[AIRG.curCharacter] = {}    -- create a table for this character's matrix
-      local j, known
-      for i = 1, 14 do
-        j = AIRG.styleLookupItem[i]
-        known = IsSmithingStyleKnown(j, 1) --patternIndex set to 1, temporary workaround for changes introduced in Update 4
-        AIRG.vars.styles[AIRG.curCharacter][i] = known
-      end

-      --Dwemer style chapters
-      AIRG.vars.styles[AIRG.curCharacter][15] = {}
-      local itemStyle = AIRG.styleLookupItem[15]
-      for i = 1, 14 do
-        --local known = IsSmithingStyleKnown(itemStyle, i)
-        local _, numCompleted = GetAchievementCriterion(1144, i)
-        AIRG.vars.styles[AIRG.curCharacter][15][AIRG.styleChaptersLookup[i]] = numCompleted == 1
+      for StyleIndex, Style in ipairs (AIRG.StyleSingleDat) do
+        AIRG.vars.StyleSingle[AIRG.curCharacter][StyleIndex] = IsSmithingStyleKnown(Style[2], 1) --patternIndex set to 1, temporary workaround for changes introduced in Update 4
       end

-      --Glass style chapters
-      AIRG.vars.styles[AIRG.curCharacter][16] = {}
-      itemStyle = AIRG.styleLookupItem[16]
-      for i = 1, 14 do
-        --local known = IsSmithingStyleKnown(itemStyle, i)
-        local _, numCompleted = GetAchievementCriterion(1319, i)
-        AIRG.vars.styles[AIRG.curCharacter][16][AIRG.styleChaptersLookup[i]] = numCompleted == 1
-      end
+      --Chapter Styles
+      AIRG.vars.StyleChapter[AIRG.curCharacter] = {}		-- Table for each style
+      for StyleIndex, Style in ipairs (AIRG.StyleChapterDat) do
+			AIRG.vars.StyleChapter[AIRG.curCharacter][StyleIndex] = {}	-- Table for each Chapter (weapon/clothing)

-      --Xiv Style chapters
-      AIRG.vars.styles[AIRG.curCharacter][17] = {}
-      itemStyle = AIRG.styleLookupItem[17]
-      for i = 1, 14 do
-        local _, numCompleted = GetAchievementCriterion(1181, i)
-        AIRG.vars.styles[AIRG.curCharacter][17][AIRG.styleChaptersLookup[i]] = numCompleted == 1
-      end

-      --Ancient Orc Style chapters
-      AIRG.vars.styles[AIRG.curCharacter][18] = {}
-      itemStyle = AIRG.styleLookupItem[18]
-      for i = 1, 14 do
-        local _, numCompleted = GetAchievementCriterion(1341, i)
-        AIRG.vars.styles[AIRG.curCharacter][18][AIRG.styleChaptersLookup[i]] = numCompleted == 1
-      end
+		for ChapterIndex, Chapter in ipairs(AIRG.styleChaptersLookup) do

-      --Akaviri Style chapters
-      AIRG.vars.styles[AIRG.curCharacter][19] = {}
-      itemStyle = AIRG.styleLookupItem[19]
-      for i = 1, 14 do
-        local _, numCompleted = GetAchievementCriterion(1318, i)
-        AIRG.vars.styles[AIRG.curCharacter][19][AIRG.styleChaptersLookup[i]] = numCompleted == 1
-      end
-
-      --Mercenary Akaviri Style chapters
-      AIRG.vars.styles[AIRG.curCharacter][20] = {}
-      itemStyle = AIRG.styleLookupItem[20]
-      for i = 1, 14 do
-        local _, numCompleted = GetAchievementCriterion(1348, i)
-        AIRG.vars.styles[AIRG.curCharacter][20][AIRG.styleChaptersLookup[i]] = numCompleted == 1
-      end
+				local desc, numCompleted = GetAchievementCriterion(Style[4], Chapter)
+						if numCompleted == 1 then
+							d(ChapterIndex .. " " .. Chapter .. ":  Completed: " .. desc)
+						end
+			AIRG.vars.StyleChapter[AIRG.curCharacter][StyleIndex][ChapterIndex]	= numCompleted == 1   -- Note we save the Chapter Index, so the table will be an array. (can use ipairs)
+	    end
+	  end


 end -- AIRG.PopulateStyleData
@@ -612,251 +590,101 @@ function AIRG.PopulateAll()
             end
           end
         end
-		-- Fix crash for empty data.
-		if AIRG.vars.styles[thisname] == nil then
-			AIRG.vars.styles[thisname] = {}
-		end
-
-		for i = 15 ,20  do	-- helps stop crashes when new styles are added
-			if type(AIRG.vars.styles[thisname][i]) ~= "table"  then
-				AIRG.vars.styles[thisname][i] = {}
-			end
-		end
+        -- Fix crash for empty data.

+        if type (AIRG.vars.StyleSingle[thisname])  ~= "table" then
+          AIRG.vars.StyleSingle[thisname] = {}
+        end

-        -- Update the Styles for this char.
-		for i = 1, 14 do	--iterate over all non-dwemer styles
-			if  AIRG.vars.styles[thisname][i] then
-				AIRG.vars.styles[AIRG.all][i] = true
-			end
-		end
-		--Update Dwemer styles
-		for i = 1, 14 do	--iterate over all dwemer items
-			if  AIRG.vars.styles[thisname][15][i] then
-				AIRG.vars.styles[AIRG.all][15][i] = true
-			end
-		end
-		--Update Glass styles
-		for i = 1, 14 do	--iterate over all Glass items
-			if  AIRG.vars.styles[thisname][16][i] then
-				AIRG.vars.styles[AIRG.all][16][i] = true
-			end
-		end
-		--Update Xivkyn styles
-		for i = 1, 14 do	--iterate over all Xiv items
-			if  AIRG.vars.styles[thisname][17][i] then
-				AIRG.vars.styles[AIRG.all][17][i] = true
-			end
-		end
-		--Update Ancient Orc styles
-		for i = 1, 14 do	--iterate over all Ancient Orc items
-			if  AIRG.vars.styles[thisname][18][i] then
-				AIRG.vars.styles[AIRG.all][18][i] = true
-			end
-		end
-
-		--Update Akaviri styles
-		for i = 1, 14 do	--iterate over all Mercenary Akaviri items
-			if  AIRG.vars.styles[thisname][19][i] then
-				AIRG.vars.styles[AIRG.all][19][i] = true
-			end
-		end
+        if type (AIRG.vars.StyleChapter[thisname])  ~= "table" then
+          AIRG.vars.StyleChapter[thisname] = {}	-- no contents, but ipairs doesnt mind- runs zero times
+        end

-		--Update Mercenary styles
-		for i = 1, 14 do	--iterate over all Mercenary Akaviri items
-			if  AIRG.vars.styles[thisname][20][i] then
-				AIRG.vars.styles[AIRG.all][20][i] = true
-			end
-		end
+        -- Loop through my Singles
+        for i, Known in ipairs(AIRG.vars.StyleSingle[thisname]) do
+          if  Known then
+            AIRG.vars.StyleSingle[AIRG.all][i] = true
+          end
+        end

+        -- Loop through my Chapters
+        for i, Style in ipairs(AIRG.vars.StyleChapter[thisname]) do
+          for j, Chapter in ipairs (Style) do

-      end
-    end
+            if  Known then
+              AIRG.vars.StyleChapter[AIRG.all][j] = true
+            end
+          end
+        end
+      end   -- thisname ~= AIRG.all
+		end   --for
 end  -- AIRG.PopulateAll


 -- Set the icon highlights for the currently selected character
 function AIRG.DisplayStyles()
-    if (AIRG.vars.styles[AIRG.curCharacter] == nil) then
-        for i = 1, 20 do
-            AIRG.UI.motifButtons[i]:SetTexture(AIRG.styleLookupIcons[i] .. "up.dds")
-            AIRG.UI.motifButtons[i]:SetColor(1, 1, 1, 0.7)   -- grey
-        end
-    else
-        for i = 1, 20 do
-            if (AIRG.vars.styles[AIRG.curCharacter][i]) then
-                AIRG.UI.motifButtons[i]:SetTexture(AIRG.styleLookupIcons[i] .. "down.dds")
-                AIRG.UI.motifButtons[i]:SetColor(0.2, 1, 0.2, 1)   -- Green
-            else
-                AIRG.UI.motifButtons[i]:SetTexture(AIRG.styleLookupIcons[i] .. "up.dds")
-                AIRG.UI.motifButtons[i]:SetColor(1, 1, 1, 0.7)   -- grey
-            end
-        end
-    end
-	--Dwemer Motif, special case
-	--update old saved variables, if exists
-
-	--making styleIndex as variable, so it will be easier to make a loop if there will be any new styles
-	local styleIndex = 15
-        -- start of loop if its ever written
-	local tooltipText = ""
-  local itemStyle,tDesc
-	local knownCount = 0
-	for i = 1, 14 do
-		--check how many chapters are known and build tooltip
-		if (AIRG.vars.styles[AIRG.curCharacter][styleIndex][i]) then
-		   tooltipText = zo_strjoin(nil, tooltipText, "\n|cFFFFFF", GetString("SI_ITEMSTYLECHAPTER", i), "|r")
-		   knownCount = knownCount + 1
-		else
-		   tooltipText = zo_strjoin(nil, tooltipText, "\n|c806060", GetString("SI_ITEMSTYLECHAPTER", i), "|r")
-		end
-	end
-	if knownCount == 0 then
-		AIRG.UI.motifButtons[styleIndex]:SetTexture(AIRG.styleLookupIcons[styleIndex] .. "up.dds")
-		AIRG.UI.motifButtons[styleIndex]:SetColor(1, 1, 1, 0.7)   -- grey
-	else
-		AIRG.UI.motifButtons[styleIndex]:SetTexture(AIRG.styleLookupIcons[styleIndex] .. "down.dds")
-		if knownCount == 14 then
-			AIRG.UI.motifButtons[styleIndex]:SetColor(0.2, 1, 0.2, 1)   -- Green
-		else
-			AIRG.UI.motifButtons[styleIndex]:SetColor(1, 1, 0.6, 1)    -- yellow
-		end
-	end
-	itemStyle = AIRG.styleLookupValue[styleIndex]
-	tDesc = GetSmithingStyleItemLink(AIRG.styleLookupItem[styleIndex])
-	AIRG.UI.motifButtons[styleIndex].tooltipText = zo_strjoin(nil, zo_strformat("<<t:1>> (<<2>>/14)\n<<t:3>>\n", GetString("SI_ITEMSTYLE", itemStyle), knownCount, tDesc), tooltipText)
-
-
-	--Glass Motif, special case
-
-	--making styleIndex as variable
-	styleIndex = 16
-	--
-	tooltipText = ""
-	knownCount = 0
-	for i = 1, 14 do
-		-- check how many chapters are known and build tooltip
-		if (AIRG.vars.styles[AIRG.curCharacter][styleIndex][i]) then
-		   tooltipText = zo_strjoin(nil, tooltipText, "\n|cFFFFFF", GetString("SI_ITEMSTYLECHAPTER", i), "|r")
-		   knownCount = knownCount + 1
-		else
-		   tooltipText = zo_strjoin(nil, tooltipText, "\n|c806060", GetString("SI_ITEMSTYLECHAPTER", i), "|r")
-		end
-	end
-	if knownCount == 0 then
-		AIRG.UI.motifButtons[styleIndex]:SetTexture(AIRG.styleLookupIcons[styleIndex] .. "up.dds")
-		AIRG.UI.motifButtons[styleIndex]:SetColor(1, 1, 1, 0.7)   -- grey
-	else
-		AIRG.UI.motifButtons[styleIndex]:SetTexture(AIRG.styleLookupIcons[styleIndex] .. "down.dds")
-		if knownCount == 14 then
-			AIRG.UI.motifButtons[styleIndex]:SetColor(0.2, 1, 0.2, 1)   -- Green
-		else
-			AIRG.UI.motifButtons[styleIndex]:SetColor(1, 1, 0.6, 1)    -- yellow
-		end
-	end
-	itemStyle = AIRG.styleLookupValue[styleIndex]
-	tDesc = GetSmithingStyleItemLink(AIRG.styleLookupItem[styleIndex])
-	AIRG.UI.motifButtons[styleIndex].tooltipText = zo_strjoin(nil, zo_strformat("<<t:1>> (<<2>>/14)\n<<t:3>>\n", GetString("SI_ITEMSTYLE", itemStyle), knownCount, tDesc), tooltipText)

-	--Xivkyn Motif, special case
+    -- Single Styles
+    for StyleIndex, known in ipairs(AIRG.vars.StyleSingle[AIRG.curCharacter]) do
+        if (known) then
+              AIRG.UI.StyleSingleButtons[StyleIndex]:SetTexture(AIRG.StyleSingleDat[StyleIndex][3] .. "down.dds")
+              AIRG.UI.StyleSingleButtons[StyleIndex]:SetColor(0.2, 1, 0.2, 1)   -- Green

-	styleIndex = 17
-	--
-	tooltipText = ""
-	knownCount = 0
-	for i = 1, 14 do
+        else
+              AIRG.UI.StyleSingleButtons[StyleIndex]:SetTexture(AIRG.StyleSingleDat[StyleIndex][3] .. "up.dds")
+              AIRG.UI.StyleSingleButtons[StyleIndex]:SetColor(1, 1, 1, 0.7)   -- grey
+        end
+    end
+	-- =================
+	-- Chapter Styles
+	for StyleIndex, Style in ipairs(AIRG.vars.StyleChapter[AIRG.curCharacter]) do
+		local tooltipText = ""
+		local itemStyle,tDesc
+		local KnownCount  = 0
+		local AllKnown = true
+
+		-- Run through the complete list in AIRG.styleChaptersLookup, and look up to see which we have.
 		-- check how many chapters are known and build tooltip
-		if (AIRG.vars.styles[AIRG.curCharacter][styleIndex][i]) then
-		   tooltipText = zo_strjoin(nil, tooltipText, "\n|cFFFFFF", GetString("SI_ITEMSTYLECHAPTER", i), "|r")
-		   knownCount = knownCount + 1
-		else
-		   tooltipText = zo_strjoin(nil, tooltipText, "\n|c806060", GetString("SI_ITEMSTYLECHAPTER", i), "|r")
-		end
-	end
-	if knownCount == 0 then
-		AIRG.UI.motifButtons[styleIndex]:SetTexture(AIRG.styleLookupIcons[styleIndex] .. "up.dds")
-		AIRG.UI.motifButtons[styleIndex]:SetColor(1, 1, 1, 0.7)   -- grey
-	else
-		AIRG.UI.motifButtons[styleIndex]:SetTexture(AIRG.styleLookupIcons[styleIndex] .. "down.dds")
-		if knownCount == 14 then
-			AIRG.UI.motifButtons[styleIndex]:SetColor(0.2, 1, 0.2, 1)   -- Green
-		else
-			AIRG.UI.motifButtons[styleIndex]:SetColor(1, 1, 0.6, 1)    -- yellow
+		for ChapterIndex, chapter in ipairs(AIRG.styleChaptersLookup) do
+			if (AIRG.vars.StyleChapter[AIRG.curCharacter][StyleIndex][ChapterIndex]) then
+				tooltipText = zo_strjoin(nil, tooltipText, "\n|cFFFFFF", GetString("SI_ITEMSTYLECHAPTER", chapter), "|r")
+				KnownCount = KnownCount +1
+			else
+				AllKnown = false
+				tooltipText = zo_strjoin(nil, tooltipText, "\n|c806060", GetString("SI_ITEMSTYLECHAPTER", chapter), "|r")
+			end
 		end
-	end
-	itemStyle = AIRG.styleLookupValue[styleIndex]
-	tDesc = GetSmithingStyleItemLink(AIRG.styleLookupItem[styleIndex])
-	AIRG.UI.motifButtons[styleIndex].tooltipText = zo_strjoin(nil, zo_strformat("<<t:1>> (<<2>>/14)\n<<t:3>>\n", GetString("SI_ITEMSTYLE", itemStyle), knownCount, tDesc), tooltipText)
-
-	--Ancient Orc Motif, special case

-	styleIndex = 18
-	--
-	tooltipText = ""
-	knownCount = 0
-	for i = 1, 14 do
-		-- check how many chapters are known and build tooltip
-		if (AIRG.vars.styles[AIRG.curCharacter][styleIndex][i]) then
-		   tooltipText = zo_strjoin(nil, tooltipText, "\n|cFFFFFF", GetString("SI_ITEMSTYLECHAPTER", i), "|r")
-		   knownCount = knownCount + 1
+		if KnownCount == 0 then
+			AIRG.UI.StyleChapterButtons[StyleIndex]:SetTexture(AIRG.StyleChapterDat[StyleIndex][3] .. "up.dds")
+			AIRG.UI.StyleChapterButtons[StyleIndex]:SetColor(1, 1, 1, 0.7)   -- grey
 		else
-		   tooltipText = zo_strjoin(nil, tooltipText, "\n|c806060", GetString("SI_ITEMSTYLECHAPTER", i), "|r")
-		end
-	end
-	if knownCount == 0 then
-		AIRG.UI.motifButtons[styleIndex]:SetTexture(AIRG.styleLookupIcons[styleIndex] .. "up.dds")
-		AIRG.UI.motifButtons[styleIndex]:SetColor(1, 1, 1, 0.7)   -- grey
-	else
-		AIRG.UI.motifButtons[styleIndex]:SetTexture(AIRG.styleLookupIcons[styleIndex] .. "down.dds")
-		if knownCount == 14 then
-			AIRG.UI.motifButtons[styleIndex]:SetColor(0.2, 1, 0.2, 1)   -- Green
-		else
-			AIRG.UI.motifButtons[styleIndex]:SetColor(1, 1, 0.6, 1)    -- yellow
+			AIRG.UI.StyleChapterButtons[StyleIndex]:SetTexture(AIRG.StyleChapterDat[StyleIndex][3] .. "down.dds")
+			if AllKnown then
+				AIRG.UI.StyleChapterButtons[StyleIndex]:SetColor(0.2, 1, 0.2, 1)   -- Green
+			else
+				AIRG.UI.StyleChapterButtons[StyleIndex]:SetColor(1, 1, 0.6, 1)    -- yellow
+			end
 		end
+		itemStyle = AIRG.StyleChapterDat[StyleIndex][1]
+		tDesc = GetSmithingStyleItemLink(AIRG.StyleChapterDat[StyleIndex][2])
+		AIRG.UI.StyleChapterButtons[StyleIndex].tooltipText = zo_strjoin(nil, zo_strformat("<<t:1>> (<<2>>/14)\n<<t:3>>\n", GetString("SI_ITEMSTYLE", itemStyle), KnownCount, tDesc), tooltipText)
 	end
-	itemStyle = AIRG.styleLookupValue[styleIndex]
-	tDesc = GetSmithingStyleItemLink(AIRG.styleLookupItem[styleIndex])
-	AIRG.UI.motifButtons[styleIndex].tooltipText = zo_strjoin(nil, zo_strformat("<<t:1>> (<<2>>/14)\n<<t:3>>\n", GetString("SI_ITEMSTYLE", itemStyle), knownCount, tDesc), tooltipText)
+  --[[

-	--  Akaviri Motif, special case

-	styleIndex = 19
-	--
-	tooltipText = ""
-	knownCount = 0
-	for i = 1, 14 do
-		-- check how many chapters are known and build tooltip
-		if (AIRG.vars.styles[AIRG.curCharacter][styleIndex][i]) then
-		   tooltipText = zo_strjoin(nil, tooltipText, "\n|cFFFFFF", GetString("SI_ITEMSTYLECHAPTER", i), "|r")
-		   knownCount = knownCount + 1
-		else
-		   tooltipText = zo_strjoin(nil, tooltipText, "\n|c806060", GetString("SI_ITEMSTYLECHAPTER", i), "|r")
-		end
-	end
-	if knownCount == 0 then
-		AIRG.UI.motifButtons[styleIndex]:SetTexture(AIRG.styleLookupIcons[styleIndex] .. "up.dds")
-		AIRG.UI.motifButtons[styleIndex]:SetColor(1, 1, 1, 0.7)   -- grey
-	else
-		AIRG.UI.motifButtons[styleIndex]:SetTexture(AIRG.styleLookupIcons[styleIndex] .. "down.dds")
-		if knownCount == 14 then
-			AIRG.UI.motifButtons[styleIndex]:SetColor(0.2, 1, 0.2, 1)   -- Green
-		else
-			AIRG.UI.motifButtons[styleIndex]:SetColor(1, 1, 0.6, 1)    -- yellow
-		end
-	end
-	itemStyle = AIRG.styleLookupValue[styleIndex]
-	tDesc = GetSmithingStyleItemLink(AIRG.styleLookupItem[styleIndex])
-	AIRG.UI.motifButtons[styleIndex].tooltipText = zo_strjoin(nil, zo_strformat("<<t:1>> (<<2>>/14)\n<<t:3>>\n", GetString("SI_ITEMSTYLE", itemStyle), knownCount, tDesc), tooltipText)
-
-	--  Mercenary Motif, special case
+	--Dwemer Motif, special case
+	--update old saved variables, if exists

-	styleIndex = 20
-	--
-	tooltipText = ""
-	knownCount = 0
+	--making StyleIndex as variable, so it will be easier to make a loop if there will be any new styles
+	local StyleIndex = 15
+        -- start of loop if its ever written
+	local tooltipText = ""
+  local itemStyle,tDesc
+	local knownCount = 0
 	for i = 1, 14 do
-		-- check how many chapters are known and build tooltip
-		if (AIRG.vars.styles[AIRG.curCharacter][styleIndex][i]) then
+		--check how many chapters are known and build tooltip
+		if (AIRG.vars.styles[AIRG.curCharacter][StyleIndex][i]) then
 		   tooltipText = zo_strjoin(nil, tooltipText, "\n|cFFFFFF", GetString("SI_ITEMSTYLECHAPTER", i), "|r")
 		   knownCount = knownCount + 1
 		else
@@ -864,25 +692,23 @@ function AIRG.DisplayStyles()
 		end
 	end
 	if knownCount == 0 then
-		AIRG.UI.motifButtons[styleIndex]:SetTexture(AIRG.styleLookupIcons[styleIndex] .. "up.dds")
-		AIRG.UI.motifButtons[styleIndex]:SetColor(1, 1, 1, 0.7)   -- grey
+		AIRG.UI.StyleSingleButtons[StyleIndex]:SetTexture(AIRG.styleLookupIcons[StyleIndex] .. "up.dds")
+		AIRG.UI.StyleSingleButtons[StyleIndex]:SetColor(1, 1, 1, 0.7)   -- grey
 	else
-		AIRG.UI.motifButtons[styleIndex]:SetTexture(AIRG.styleLookupIcons[styleIndex] .. "down.dds")
+		AIRG.UI.StyleSingleButtons[StyleIndex]:SetTexture(AIRG.styleLookupIcons[StyleIndex] .. "down.dds")
 		if knownCount == 14 then
-			AIRG.UI.motifButtons[styleIndex]:SetColor(0.2, 1, 0.2, 1)   -- Green
+			AIRG.UI.StyleSingleButtons[StyleIndex]:SetColor(0.2, 1, 0.2, 1)   -- Green
 		else
-			AIRG.UI.motifButtons[styleIndex]:SetColor(1, 1, 0.6, 1)    -- yellow
+			AIRG.UI.StyleSingleButtons[StyleIndex]:SetColor(1, 1, 0.6, 1)    -- yellow
 		end
 	end
-	itemStyle = AIRG.styleLookupValue[styleIndex]
-	tDesc = GetSmithingStyleItemLink(AIRG.styleLookupItem[styleIndex])
-	AIRG.UI.motifButtons[styleIndex].tooltipText = zo_strjoin(nil, zo_strformat("<<t:1>> (<<2>>/14)\n<<t:3>>\n", GetString("SI_ITEMSTYLE", itemStyle), knownCount, tDesc), tooltipText)
+	itemStyle = AIRG.styleLookupValue[StyleIndex]
+	tDesc = GetSmithingStyleItemLink(AIRG.styleLookupItem[StyleIndex])
+	AIRG.UI.StyleSingleButtons[StyleIndex].tooltipText = zo_strjoin(nil, zo_strformat("<<t:1>> (<<2>>/14)\n<<t:3>>\n", GetString("SI_ITEMSTYLE", itemStyle), knownCount, tDesc), tooltipText)
+ --]]



-
-
-	--end --end of the future loop
 end -- AIRG.DisplayStyles()

 -- Look up all the data on this profession and commit to saved variables for this character.
@@ -945,7 +771,7 @@ end -- AIRG.CreateDataMatrix



-function AIRG.AssignGridTraits()
+function AIRG.LoadStatic()
     -- Translates the traitType to the correct ROW of the grid
     AIRG.gridTraits = {}
     AIRG.gridTraits[ITEM_TRAIT_TYPE_WEAPON_POWERED] = 1
@@ -966,96 +792,67 @@ function AIRG.AssignGridTraits()
     AIRG.gridTraits[ITEM_TRAIT_TYPE_ARMOR_EXPLORATION] = 16
     AIRG.gridTraits[ITEM_TRAIT_TYPE_ARMOR_DIVINES] = 17
     AIRG.gridTraits[ITEM_TRAIT_TYPE_ARMOR_NIRNHONED] = 18
-end -- AIRG.AssignGridTraits
-
-function AIRG.AssignStyleLookups()
-    -- Lookup the correct icon for the style
-    AIRG.styleLookupIcons = {}
-    AIRG.styleLookupIcons[1] = "ESOUI/art/charactercreate/charactercreate_altmericon_"
-    AIRG.styleLookupIcons[2] = "ESOUI/art/charactercreate/charactercreate_dunmericon_"
-    AIRG.styleLookupIcons[3] = "ESOUI/art/charactercreate/charactercreate_bosmericon_"
-    AIRG.styleLookupIcons[4] = "ESOUI/art/charactercreate/charactercreate_nordicon_"
-    AIRG.styleLookupIcons[5] = "ESOUI/art/charactercreate/charactercreate_bretonicon_"
-    AIRG.styleLookupIcons[6] = "ESOUI/art/charactercreate/charactercreate_redguardicon_"
-    AIRG.styleLookupIcons[7] = "ESOUI/art/charactercreate/charactercreate_khajiiticon_"
-    AIRG.styleLookupIcons[8] = "ESOUI/art/charactercreate/charactercreate_orcicon_"
-    AIRG.styleLookupIcons[9] = "ESOUI/art/charactercreate/charactercreate_argonianicon_"
-    AIRG.styleLookupIcons[10] = "ESOUI/art/charactercreate/charactercreate_imperialicon_"
-    AIRG.styleLookupIcons[11] = "ESOUI/art/progression/progression_indexicon_weapons_"
-    AIRG.styleLookupIcons[12] = "ESOUI/art/progression/progression_indexicon_weapons_"
-    AIRG.styleLookupIcons[13] = "ESOUI/art/progression/progression_indexicon_weapons_"
-    AIRG.styleLookupIcons[14] = "ESOUI/art/progression/progression_indexicon_weapons_"
-    AIRG.styleLookupIcons[15] = "ESOUI/art/progression/progression_indexicon_weapons_"
-    AIRG.styleLookupIcons[16] = "ESOUI/art/progression/progression_indexicon_weapons_"
-    AIRG.styleLookupIcons[17] = "ESOUI/art/progression/progression_indexicon_weapons_"
-    AIRG.styleLookupIcons[18] = "ESOUI/art/progression/progression_indexicon_weapons_"
-    AIRG.styleLookupIcons[19] = "ESOUI/art/progression/progression_indexicon_weapons_"
-    AIRG.styleLookupIcons[20] = "ESOUI/art/progression/progression_indexicon_weapons_"
-
-
-    -- Translate the icon position to the in-game type. Used for text look-up
-    AIRG.styleLookupValue = {}
-    AIRG.styleLookupValue[1] = ITEMSTYLE_RACIAL_HIGH_ELF
-    AIRG.styleLookupValue[2] = ITEMSTYLE_RACIAL_DARK_ELF
-    AIRG.styleLookupValue[3] = ITEMSTYLE_RACIAL_WOOD_ELF
-    AIRG.styleLookupValue[4] = ITEMSTYLE_RACIAL_NORD
-    AIRG.styleLookupValue[5] = ITEMSTYLE_RACIAL_BRETON
-    AIRG.styleLookupValue[6] = ITEMSTYLE_RACIAL_REDGUARD
-    AIRG.styleLookupValue[7] = ITEMSTYLE_RACIAL_KHAJIIT
-    AIRG.styleLookupValue[8] = ITEMSTYLE_RACIAL_ORC
-    AIRG.styleLookupValue[9] = ITEMSTYLE_RACIAL_ARGONIAN
-    AIRG.styleLookupValue[10] = ITEMSTYLE_AREA_IMPERIAL
-    AIRG.styleLookupValue[11] = ITEMSTYLE_AREA_ANCIENT_ELF
-    AIRG.styleLookupValue[12] = ITEMSTYLE_AREA_REACH
-    AIRG.styleLookupValue[13] = ITEMSTYLE_ENEMY_DAEDRIC
-    AIRG.styleLookupValue[14] = ITEMSTYLE_ENEMY_PRIMITIVE
-    AIRG.styleLookupValue[15] = ITEMSTYLE_AREA_DWEMER
-    AIRG.styleLookupValue[16] = ITEMSTYLE_GLASS
-    AIRG.styleLookupValue[17] = ITEMSTYLE_AREA_XIVKYN
-    AIRG.styleLookupValue[18] = ITEMSTYLE_AREA_ANCIENT_ORC
-    AIRG.styleLookupValue[19] = ITEMSTYLE_AREA_AKAVIRI
-    AIRG.styleLookupValue[20] = ITEMSTYLE_UNDAUNTED
-
-    -- This is a bit of a hack, but only because of the way ESO uses Style Items with different index to styles.
-    AIRG.styleLookupItem = {}
-    AIRG.styleLookupItem[1] = 8     -- Altmer       = Adamantite
-    AIRG.styleLookupItem[2] = 5     -- Dunmer       = Obsidian
-    AIRG.styleLookupItem[3] = 9     -- Bosmer       = Bone
-    AIRG.styleLookupItem[4] = 6     -- Nord         = Corundum
-    AIRG.styleLookupItem[5] = 2     -- Breton       = Molybdenum
-    AIRG.styleLookupItem[6] = 3     -- Redguard     = Starmetal
-    AIRG.styleLookupItem[7] = 10    -- Khajit       = Moonstone
-    AIRG.styleLookupItem[8] = 4     -- Orc          = Manganese
-    AIRG.styleLookupItem[9] = 7     -- Argonian     = Flint
-    AIRG.styleLookupItem[10] = 35   -- Imperial     = Nickel
-    AIRG.styleLookupItem[11] = 16   -- Ancient Elf  = Palladium
-    AIRG.styleLookupItem[12] = 18   -- Barbarian    = Copper
-    AIRG.styleLookupItem[13] = 21   -- Daedric      = Daedra Heart
-    AIRG.styleLookupItem[14] = 20   -- Primal       = Argentum
-    AIRG.styleLookupItem[15] = 15   -- Dwemer       = Dwemer Frame
-    AIRG.styleLookupItem[16] = 29   -- Glass        = Malachite Shard
-    AIRG.styleLookupItem[17] = 30   -- Xivkyn       = ??
-    AIRG.styleLookupItem[18] = 23   -- Ancient Orc  = ??
-    AIRG.styleLookupItem[19] = 34   -- Akaviri    = ??
-    AIRG.styleLookupItem[20] = 27   -- Mercenary    = ??
-
-    AIRG.styleChaptersLookup = {}
-    AIRG.styleChaptersLookup[1] = 10   --Axe
-    AIRG.styleChaptersLookup[2] = 6    --Belt
-    AIRG.styleChaptersLookup[3] = 3    --Boots
-    AIRG.styleChaptersLookup[4] = 14   --Bows
-    AIRG.styleChaptersLookup[5] = 5    --Chests
-    AIRG.styleChaptersLookup[6] = 11   --Daggers
-    AIRG.styleChaptersLookup[7] = 2    --Gloves
-    AIRG.styleChaptersLookup[8] = 1    --Helmets
-    AIRG.styleChaptersLookup[9] = 4    --Legs
-    AIRG.styleChaptersLookup[10] = 9   --Maces
-    AIRG.styleChaptersLookup[11] = 13  --Shields
-    AIRG.styleChaptersLookup[12] = 7   --Shoulders
-    AIRG.styleChaptersLookup[13] = 12  --Staves
-    AIRG.styleChaptersLookup[14] = 8   --Swords
-
-end -- AIRG.AssignStyleLookups
+
+
+
+    AIRG.styleChaptersLookup = {}   -- Display Order
+    AIRG.styleChaptersLookup[1] = ITEM_STYLE_CHAPTER_AXES  	--10   --Axe
+    AIRG.styleChaptersLookup[2] = ITEM_STYLE_CHAPTER_BELTS	--6    --Belt
+    AIRG.styleChaptersLookup[3] = ITEM_STYLE_CHAPTER_BOOTS	    --Boots
+    AIRG.styleChaptersLookup[4] = ITEM_STYLE_CHAPTER_BOWS   --Bows
+    AIRG.styleChaptersLookup[5] = ITEM_STYLE_CHAPTER_CHESTS	--5    --Chests
+    AIRG.styleChaptersLookup[6] = ITEM_STYLE_CHAPTER_DAGGERS	-- 11   --Daggers
+    AIRG.styleChaptersLookup[7] = ITEM_STYLE_CHAPTER_GLOVES	-- 2    --Gloves
+    AIRG.styleChaptersLookup[8] = ITEM_STYLE_CHAPTER_HELMETS    --Helmets
+    AIRG.styleChaptersLookup[9] = ITEM_STYLE_CHAPTER_LEGS		-- 4    --Legs
+    AIRG.styleChaptersLookup[10] = ITEM_STYLE_CHAPTER_MACES   --Maces
+    AIRG.styleChaptersLookup[11] = ITEM_STYLE_CHAPTER_SHIELDS	-- 13  --Shields
+    AIRG.styleChaptersLookup[12] = ITEM_STYLE_CHAPTER_SHOULDERS   --Shoulders
+    AIRG.styleChaptersLookup[13] = ITEM_STYLE_CHAPTER_STAVES	-- 12  --Staves
+    AIRG.styleChaptersLookup[14] = ITEM_STYLE_CHAPTER_SWORDS   --Swords
+
+	--These tables contain records of Styles in Display Order
+	-- Style Number for name,Mat Number, Icon
+	-- NOTE for testing if known put the MATNUMBER NOT THE STYLE NUMBER into IsSmithingStyleKnown(<VAL>,1)
+	-- Determined by trying them all
+
+	AIRG.StyleSingleDat ={				-- Styles without Chapters.
+
+	{ITEMSTYLE_RACIAL_HIGH_ELF, 8, "ESOUI/art/charactercreate/charactercreate_altmericon_"},
+	{ITEMSTYLE_RACIAL_DARK_ELF, 5, "ESOUI/art/charactercreate/charactercreate_dunmericon_"},
+	{ITEMSTYLE_RACIAL_WOOD_ELF, 9, "ESOUI/art/charactercreate/charactercreate_bosmericon_"},
+	{ITEMSTYLE_RACIAL_NORD, 6, "ESOUI/art/charactercreate/charactercreate_nordicon_"},
+	{ITEMSTYLE_RACIAL_BRETON, 2, "ESOUI/art/charactercreate/charactercreate_bretonicon_"},
+	{ITEMSTYLE_RACIAL_REDGUARD, 3, "ESOUI/art/charactercreate/charactercreate_redguardicon_"},
+	{ITEMSTYLE_RACIAL_KHAJIIT, 10, "ESOUI/art/charactercreate/charactercreate_khajiiticon_"},
+	{ITEMSTYLE_RACIAL_ORC, 4, "ESOUI/art/charactercreate/charactercreate_orcicon_"},
+	{ITEMSTYLE_RACIAL_ARGONIAN, 7, "ESOUI/art/charactercreate/charactercreate_argonianicon_"},
+	{ITEMSTYLE_RACIAL_IMPERIAL, 35, "ESOUI/art/charactercreate/charactercreate_imperialicon_"},
+	{ITEMSTYLE_AREA_ANCIENT_ELF, 16, "ESOUI/art/progression/progression_indexicon_weapons_"},
+	{ITEMSTYLE_AREA_REACH, 18, "ESOUI/art/progression/progression_indexicon_weapons_"}, 		-- Barbaric
+	{ITEMSTYLE_ENEMY_DAEDRIC, 21, "ESOUI/art/progression/progression_indexicon_weapons_"},
+	{ITEMSTYLE_ENEMY_PRIMITIVE, 20, "ESOUI/art/progression/progression_indexicon_weapons_"},	-- Primal
+	{ITEMSTYLE_AREA_SOUL_SHRIVEN, 31, "ESOUI/art/progression/progression_indexicon_weapons_"}
+	}
+
+
+	-- Style Number,Mat Number, Icon, Achievment ID
+	AIRG.StyleChapterDat ={
+	{ITEMSTYLE_AREA_DWEMER, 15, "ESOUI/art/progression/progression_indexicon_weapons_", 1144},
+	{ITEMSTYLE_GLASS, 29, "ESOUI/art/progression/progression_indexicon_weapons_", 1319},
+	{ITEMSTYLE_AREA_XIVKYN, 30, "ESOUI/art/progression/progression_indexicon_weapons_", 1181},
+	{ITEMSTYLE_AREA_ANCIENT_ORC, 23, "ESOUI/art/progression/progression_indexicon_weapons_", 1341},
+	{ITEMSTYLE_AREA_AKAVIRI, 34, "ESOUI/art/progression/progression_indexicon_weapons_", 1318},
+	{ITEMSTYLE_UNDAUNTED, 27, "ESOUI/art/progression/progression_indexicon_weapons_",1348},			--Mercenary
+	{ITEMSTYLE_DEITY_MALACATH, 14, "ESOUI/art/progression/progression_indexicon_weapons_", 1412},
+	{ITEMSTYLE_DEITY_TRINIMAC, 21, "ESOUI/art/progression/progression_indexicon_weapons_", 1411},
+	{47, 48, "ESOUI/art/progression/progression_indexicon_weapons_", 1417},			-- Outlaw
+	{ITEMSTYLE_ALLIANCE_EBONHEART, 25, "ESOUI/art/progression/progression_indexicon_weapons_",1414},
+	{ITEMSTYLE_ALLIANCE_ALDMERI, 26, "ESOUI/art/progression/progression_indexicon_weapons_", 1415},
+	{ITEMSTYLE_ALLIANCE_DAGGERFALL, 24, "ESOUI/art/progression/progression_indexicon_weapons_", 1416}
+
+	}
+end -- AIRG.LoadStatic


 function AIRG.Initialise(eventCode, addOnName)
@@ -1080,24 +877,31 @@ function AIRG.Initialise(eventCode, addOnName)
     AIRG.curCraft= CRAFTING_TYPE_WOODWORKING
     AIRG.playerName = GetUnitName("player")
     AIRG.curCharacter = GetUnitName("player")       -- Default the display to the current character
-    AIRG.AssignGridTraits()
-    AIRG.AssignStyleLookups()
+    AIRG.LoadStatic()

-	--Remove possibly spurious character data
-	AIRG.vars.styles["#TOUS"] = nil
-	AIRG.vars.styles[" #ALLE"] = nil
-	AIRG.vars.styles[" #ALL"] = nil
+	-- tables for new Data on version 3.4.0
+	if type (AIRG.vars.StyleSingle) ~= "table" then
+		AIRG.vars.StyleSingle = {}
+	end
+
+	if type (AIRG.vars.StyleChapter) ~= "table" then
+		AIRG.vars.StyleChapter = {}
+	end
+
+  AIRG.vars.style = nil        -- erase old tables
+
+	-- Remove "ALL" data, we will recreate it.
+	AIRG.vars.StyleChapter[AIRG.all] = {}
+	AIRG.vars.StyleSingle[AIRG.all] = {}
+  AIRG.vars.data[AIRG.all] = {}

-	AIRG.vars.styles[AIRG.all] = {}
     -- Create these here so the UI dropdown will have them first time around.
-    AIRG.vars.data[AIRG.playerName] = {}    -- create a table for this character's matrix
+  AIRG.vars.data[AIRG.playerName] = {}    -- create a table for this character's matrix
+	AIRG.vars.StyleSingle[AIRG.playerName] = {}
+	AIRG.vars.StyleChapter[AIRG.playerName] = {}
+

-	--Remove possibly spurious character data
-	AIRG.vars.data["#TOUS"] = nil
-	AIRG.vars.data[" #ALLE"] = nil
-	AIRG.vars.data[" #ALL"] = nil
-    AIRG.vars.data[AIRG.all] = {}    -- and our virtual character
-  -- Create Empty data for Virtual Char set to 0, (Not known)
+  -- Create Empty data for "ALL" set to 0, (Not known)

     AIRG.vars.data[AIRG.all][CRAFTING_TYPE_BLACKSMITHING] = {}
     -- Cycle through items for this profession
@@ -1143,42 +947,19 @@ function AIRG.Initialise(eventCode, addOnName)
         end
     end

-    --Create Empty Style Table
-    for i = 1, 14 do
-        AIRG.vars.styles[AIRG.all][i] = false
-    end
-
-	AIRG.vars.styles[AIRG.all][15]= {}	--Dwemer
-    for i = 1, 14 do
-        AIRG.vars.styles[AIRG.all][15][i] = false
-    end
-	AIRG.vars.styles[AIRG.all][16]= {}	--Glass
-    for i = 1, 14 do
-        AIRG.vars.styles[AIRG.all][16][i] = false
-    end
-	AIRG.vars.styles[AIRG.all][17]= {}	--Xiv
-    for i = 1, 14 do
-        AIRG.vars.styles[AIRG.all][17][i] = false
-    end
-
-	AIRG.vars.styles[AIRG.all][18]= {}	--Ancient Orc
-    for i = 1, 14 do
-        AIRG.vars.styles[AIRG.all][18][i] = false
-    end
-
-	AIRG.vars.styles[AIRG.all][19]= {}	-- Akaviri
-    for i = 1, 14 do
-        AIRG.vars.styles[AIRG.all][19][i] = false
-    end
-
-	AIRG.vars.styles[AIRG.all][20]= {}	--Mercenary Akaviri
-    for i = 1, 14 do
-        AIRG.vars.styles[AIRG.all][20][i] = false
-    end

+	for i,_ in ipairs(AIRG.StyleSingleDat) do
+		AIRG.vars.StyleSingle[AIRG.all][i] = false
+	end

+	for i,_ in ipairs(AIRG.StyleChapterDat) do
+		AIRG.vars.StyleChapter[AIRG.all][i] =  {}
+		for j,_ in ipairs(AIRG.styleChaptersLookup) do
+			AIRG.vars.StyleChapter[AIRG.all][i][j] = false
+		end
+	end

- -- AIRG.CreateDataMatrix
+	 -- AIRG.CreateDataMatrix

     -- Following replaced with PlayerActivate
     -- Query data for THIS character and populate the data matrix with fresh data.
@@ -1208,5 +989,6 @@ function AIRGslash(extra)
 end -- AIRGslash

 SLASH_COMMANDS["/airg"] = AIRGslash
+SLASH_COMMANDS["/test"] = AIRG.DisplayStyles
 EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_ADD_ON_LOADED, AIRG.Initialise)
 -- EOF
diff --git a/AIResearchGrid.txt b/AIResearchGrid.txt
index e434722..98b1902 100644
--- a/AIResearchGrid.txt
+++ b/AIResearchGrid.txt
@@ -1,6 +1,6 @@
-## Title: |cFFFFB0Research Grid|r v3.3.10
-## APIVersion: 100013
-## Version: 3.3.10
+## Title: |cFFFFB0Research Grid|r v3.4.0
+## APIVersion: 100014
+## Version: 3.4.0
 ## Author: Stormknight and Team
 ## OptionalDependsOn: LibAddonMenu-2.0
 ## SavedVariables: AIRG_SavedVariables
diff --git a/doc/changelog.txt b/doc/changelog.txt
index 7af0d4d..4f9bf12 100644
--- a/doc/changelog.txt
+++ b/doc/changelog.txt
@@ -1,10 +1,16 @@
-2016-02-30
+2016-03-01  v3.4.0
+	New Feature
+	Thieves Guild DLC
+	Bug Fix
+	Internal Refactoring of Styles
+
+2016-02-30 3.3.10
 	New Feature
 	None
 	Bug Fix
 	Adjust Motif bar Colours
 	New Screenshots
-
+
 2015-11-08 3.3.9
 	New Feature
 	None