V3.2.1 Garkin's Fixed Dwemer Styles

His Dad [01-08-15 - 02:18]
V3.2.1  Garkin's Fixed Dwemer Styles
Filename
AIResearchGrid.lua
AIResearchGrid.txt
doc/changelog.txt
doc/description.txt
diff --git a/AIResearchGrid.lua b/AIResearchGrid.lua
index c7f27db..fa7be1b 100644
--- a/AIResearchGrid.lua
+++ b/AIResearchGrid.lua
@@ -2,12 +2,13 @@
 -- Author: Stormknight/LCAmethyst
 -- "All" and "Relative"  functionality by His Dad
 -- Dwemer Motif by rkuhnjr
+-- Dwemer Motif By garkin

 local _
 AIRG = {}

 AIRG.name = "AIResearchGrid"
-AIRG.version = "3.1.11"
+AIRG.version = "3.2.1"
 AIRG.initialised = false
 AIRG.processing = false
 AIRG.all = " #ALL"  -- Default displayname for Virtual character, overrwritten by Localised version
@@ -522,6 +523,14 @@ function AIRG.PopulateStyleData()
         known = IsSmithingStyleKnown(j, 1) --patternIndex set to 1, temporary workaround for changes introduced in Update 4
         AIRG.vars.styles[AIRG.playerName][i] = known
     end
+	--Dwemer style chapters
+    AIRG.vars.styles[AIRG.playerName][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.playerName][15][AIRG.styleChaptersLookup[i]] = numCompleted == 1
+    end
 end -- AIRG.PopulateStyleData

 -- When any character data changes we have to go through and create our virtual "All" from the beginning.
@@ -569,6 +578,39 @@ function AIRG.DisplayStyles()
             end
         end
     end
+	--Dwemer Motif, special case
+	--update old saved variables, if exists
+	AIRG.vars.styles[AIRG.curCharacter][15] = AIRG.vars.styles[AIRG.curCharacter][15] or {}
+	if (AIRG.vars.styles[AIRG.curCharacter][15] == true) then AIRG.vars.styles[AIRG.curCharacter][15] = { [1] = true } end
+	--making styleIndex as variable, so it will be easier to make a loop if there will be any new styles
+	local styleIndex = 15
+	--for styleIndex = 15, maxStyleIndex do  --start of the future loop
+	local tooltipText = ""
+	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|c808080", 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.7, 1, 0.7, 1)  -- Green
+		else
+			AIRG.UI.motifButtons[styleIndex]:SetColor(1, 1, 0.7, 1)    -- yellow
+		end
+	end
+	local itemStyle = AIRG.styleLookupValue[styleIndex]
+	local 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)
+	--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.
@@ -710,6 +752,23 @@ function AIRG.AssignStyleLookups()
     AIRG.styleLookupItem[13] = 21   -- Daedric      = Daedra Heart
     AIRG.styleLookupItem[14] = 20   -- Primal       = Argentum
     AIRG.styleLookupItem[15] = 15   -- Dwemer       = Dwemer Frame
+
+	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


diff --git a/AIResearchGrid.txt b/AIResearchGrid.txt
index dd377c2..4c14abf 100644
--- a/AIResearchGrid.txt
+++ b/AIResearchGrid.txt
@@ -1,6 +1,6 @@
-## Title: |cFFFFB0Research Grid|r v3.1.11
+## Title: |cFFFFB0Research Grid|r v3.2.1
 ## APIVersion: 100010
-## Version: 3.1.11
+## Version: 3.2.1
 ## Author: Stormknight and Team
 ## OptionalDependsOn: LibAddonMenu-2.0
 ## SavedVariables: AIRG_SavedVariables
diff --git a/doc/changelog.txt b/doc/changelog.txt
index 7684a54..f1d69c8 100644
--- a/doc/changelog.txt
+++ b/doc/changelog.txt
@@ -1,3 +1,11 @@
+2015-01-08  V3.2.1
+	New Feature
+	The Style Motif for Dwemer now shows something useful. Thankyou Garkin.
+	The #All functionality for this hasn't been updated though.
+	Updated Version String.
+	Bug Fixed
+	None
+
 2015-01-05  V3.1.11
     New Feature
 	None
diff --git a/doc/description.txt b/doc/description.txt
index a4e3a26..e322b6f 100644
--- a/doc/description.txt
+++ b/doc/description.txt
@@ -66,7 +66,7 @@ So, several hours later, this addon was born --StormKnight

 [SIZE="4"][COLOR="Lime"]Known Bugs[/COLOR][/SIZE]
 [LIST]
-[*]If you use the addon menu to delete a characters' data, follow with a /reloadui
+[*] #All does not show Dwemer Styles
 [/LIST]

 All rights reserved - Stormknight.
@@ -76,3 +76,4 @@ A big thank you to all those who have contributed with ideas and feedback.
 Special mention goes to the following:
 Krysstof - ideas for the code used to implement timers.
 rkuhnjr -- for the Dwemer motif patch.
+garkin for the improved Dwemer motif patch