Styles fix

His Dad [10-13-15 - 08:12]
Styles fix
Filename
AIResearchGrid.lua
AIResearchGrid.txt
doc/changelog.txt
diff --git a/AIResearchGrid.lua b/AIResearchGrid.lua
index dbc7cad..7e4a035 100644
--- a/AIResearchGrid.lua
+++ b/AIResearchGrid.lua
@@ -12,7 +12,7 @@ local _
 AIRG = {}

 AIRG.name = "AIResearchGrid"
-AIRG.version = "3.3.4"
+AIRG.version = "3.3.5"
 AIRG.initialised = false
 AIRG.processing = false
 AIRG.all = " #ALL"  -- Default displayname for Virtual character, overrwritten by Localised version
@@ -527,54 +527,52 @@ end -- AIRG.PopulateMatrix

 -- Lookup the style data for the current character and send it to saved vars.
 function AIRG.PopulateStyleData()
-  for thisname, _ in pairs(AIRG.vars.data) do   --iterate over all characters
-    if thisname ~= AIRG.all then                --skip our virtual
-
-      AIRG.vars.styles[thisname] = {}    -- create a table for this character's matrix
-      local i, j, known
+      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[thisname][i] = known
+        AIRG.vars.styles[AIRG.curCharacter][i] = known
       end

       --Dwemer style chapters
-      AIRG.vars.styles[thisname][15] = {}
+      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[thisname][15][AIRG.styleChaptersLookup[i]] = numCompleted == 1
+        AIRG.vars.styles[AIRG.curCharacter][15][AIRG.styleChaptersLookup[i]] = numCompleted == 1
       end

       --Glass style chapters
-      AIRG.vars.styles[thisname][16] = {}
+      AIRG.vars.styles[AIRG.curCharacter][16] = {}
       local itemStyle = AIRG.styleLookupItem[16]
       for i = 1, 14 do
         --local known = IsSmithingStyleKnown(itemStyle, i)
         local _, numCompleted = GetAchievementCriterion(1319, i)
-        AIRG.vars.styles[thisname][16][AIRG.styleChaptersLookup[i]] = numCompleted == 1
+        AIRG.vars.styles[AIRG.curCharacter][16][AIRG.styleChaptersLookup[i]] = numCompleted == 1
       end
+
       --Xiv Style chapters
-      AIRG.vars.styles[thisname][17] = {}
+      AIRG.vars.styles[AIRG.curCharacter][17] = {}
       local itemStyle = AIRG.styleLookupItem[17]
       for i = 1, 14 do
         local _, numCompleted = GetAchievementCriterion(1181, i)
-        AIRG.vars.styles[thisname][17][AIRG.styleChaptersLookup[i]] = numCompleted == 1
+        AIRG.vars.styles[tAIRG.curCharacter][17][AIRG.styleChaptersLookup[i]] = numCompleted == 1
       end
+
       --Ancient Orc Style chapters
-      AIRG.vars.styles[thisname][18] = {}
+      AIRG.vars.styles[AIRG.curCharacter][18] = {}
       local itemStyle = AIRG.styleLookupItem[18]
       for i = 1, 14 do
         local _, numCompleted = GetAchievementCriterion(1341, i)
-        AIRG.vars.styles[thisname][18][AIRG.styleChaptersLookup[i]] = numCompleted == 1
+        AIRG.vars.styles[AIRG.curCharacter][18][AIRG.styleChaptersLookup[i]] = numCompleted == 1
       end
-    end
-  end
 end -- AIRG.PopulateStyleData

 -- When any character data changes we have to go through and create our virtual "All" from the beginning.
 -- its simplified by not having to reset to unknown as traits can't be forgotton.
+-- The ALL char data was erased at startup
 function AIRG.PopulateAll()
     local craft, item, trait, thisname, style, known
     for thisname, _ in pairs(AIRG.vars.data) do   --iterate over all characters
@@ -631,7 +629,6 @@ end  -- AIRG.PopulateAll

 -- Set the icon highlights for the currently selected character
 function AIRG.DisplayStyles()
-    local i
     if (AIRG.vars.styles[AIRG.curCharacter] == nil) then
         for i = 1, 18 do
             AIRG.UI.motifButtons[i]:SetTexture(AIRG.styleLookupIcons[i] .. "up.dds")
@@ -650,7 +647,6 @@ function AIRG.DisplayStyles()
     end
 	--Dwemer Motif, special case
 	--update old saved variables, if exists
-	--AIRG.vars.styles[AIRG.curCharacter][15] = AIRG.vars.styles[AIRG.curCharacter][15] or {}

 	--making styleIndex as variable, so it will be easier to make a loop if there will be any new styles
 	local styleIndex = 15
diff --git a/AIResearchGrid.txt b/AIResearchGrid.txt
index 1cbcada..1ce02f5 100644
--- a/AIResearchGrid.txt
+++ b/AIResearchGrid.txt
@@ -1,6 +1,6 @@
-## Title: |cFFFFB0Research Grid|r v3.3.4
+## Title: |cFFFFB0Research Grid|r v3.3.5
 ## APIVersion: 100012
-## Version: 3.3.4
+## Version: 3.3.5
 ## Author: Stormknight and Team
 ## OptionalDependsOn: LibAddonMenu-2.0
 ## SavedVariables: AIRG_SavedVariables
diff --git a/doc/changelog.txt b/doc/changelog.txt
index 97b5041..92e3b62 100644
--- a/doc/changelog.txt
+++ b/doc/changelog.txt
@@ -1,3 +1,10 @@
+2015-10-10  v3.3.5
+	New Feature
+	None
+	Bug Fix
+	Styles not displaying correctly. Log in to all chars to load correct data.
+
+
 2015-10-10  v3.3.4
 	New Feature
 	None