Version 3.0.0 Added relative button

His Dad [12-10-14 - 08:54]
Version 3.0.0 Added relative button
Filename
AIResearchGrid.lua
changelog
diff --git a/AIResearchGrid.lua b/AIResearchGrid.lua
index 4dede08..0ab2067 100644
--- a/AIResearchGrid.lua
+++ b/AIResearchGrid.lua
@@ -10,8 +10,13 @@ AIRG.version = "3.0.0"
 AIRG.initialised = false
 AIRG.processing = false
 AIRG.all = " #ALL"  -- displayname for Virtual character
+AIRG.btnUpdateOtherText1 = "Set Relative to:"
+AIRG.btnUpdateOtherText2 = "Showing Relative to:"
+AIRG.ShowRelative = false  -- State of Button
+AIRG.relative= {}


+-- Added Update Other Button
 -- Set-up the defaults options for saved variables.
 AIRG.defaults = {
     data        = {},
@@ -19,114 +24,6 @@ AIRG.defaults = {
     showMotifs = true,
 }

-function AIRG.Initialise(eventCode, addOnName)
-	-- Only initialize our own addon
-	if (AIRG.name ~= addOnName) then return end
-
-    -- Language text
-    AIRG.InitialiseLanguage()
-
-    -- Load the saved variables
-    AIRG.vars = ZO_SavedVars:NewAccountWide("AIRG_SavedVariables", 2, nil, AIRG.defaults)
-
-    -- Register Keybinding
-    ZO_CreateStringId("SI_BINDING_NAME_TOGGLE_AIRG", "Toggle AI Research Grid")
-
-	-- Set-up some variables we'll want to refer to.
-    AIRG.craftNames = {}
-    AIRG.craftNames[CRAFTING_TYPE_BLACKSMITHING]    = "BLACKSMITHING"
-    AIRG.craftNames[CRAFTING_TYPE_CLOTHIER]         = "CLOTHING"
-    AIRG.craftNames[CRAFTING_TYPE_WOODWORKING]      = "WOODWORKING"
-    AIRG.playerName = GetUnitName("player")
-    AIRG.curCharacter = GetUnitName("player")       -- Default the display to the current character
-    AIRG.AssignGridTraits()
-    AIRG.AssignStyleLookups()
-    AIRG.vars.styles[AIRG.all] = {}           -- and our virtual character
-
-    -- 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.all] = {}    -- and our virtual character
-
-  -- Create Empty data for Virtual Char set to 0, (Not known)
-    local i, j
-
-    AIRG.vars.data[AIRG.all][CRAFTING_TYPE_BLACKSMITHING] = {}
-    -- Cycle through items for this profession
-    for i = 1, 7 do   -- Weapons
-        AIRG.vars.data[AIRG.all][CRAFTING_TYPE_BLACKSMITHING][i] = {}
-        -- Cycle through the traits for this item
-        for j = 1, 9 do
-                       AIRG.vars.data[AIRG.all][CRAFTING_TYPE_BLACKSMITHING][i][j] = 0   -- set to not known
-        end
-    end
-    for i = 8, 14 do  -- Armour
-        AIRG.vars.data[AIRG.all][CRAFTING_TYPE_BLACKSMITHING][i] = {}
-        -- Cycle through the traits for this item
-        for j = 10, 18 do
-                       AIRG.vars.data[AIRG.all][CRAFTING_TYPE_BLACKSMITHING][i][j] = 0   -- set to not known
-        end
-    end
-
-    AIRG.vars.data[AIRG.all][CRAFTING_TYPE_CLOTHIER] = {}
-    -- Cycle through items for this profession
-    for i = 1, 14 do
-        AIRG.vars.data[AIRG.all][CRAFTING_TYPE_CLOTHIER][i] = {}
-        -- Cycle through the traits for this item
-        for j = 10, 18  do
-                       AIRG.vars.data[AIRG.all][CRAFTING_TYPE_CLOTHIER][i][j] = 0   -- set to not known
-        end
-    end
-
-     AIRG.vars.data[AIRG.all][CRAFTING_TYPE_WOODWORKING] = {}
-    -- Cycle through items for this profession
-    for i = 1, 5 do
-        AIRG.vars.data[AIRG.all][CRAFTING_TYPE_WOODWORKING][i] = {}
-        -- Cycle through the traits for this item
-        for j = 1, 9 do
-                       AIRG.vars.data[AIRG.all][CRAFTING_TYPE_WOODWORKING][i][j] = 0   -- set to not known
-        end
-    end
-    for i = 6, 6 do  --Shields
-        AIRG.vars.data[AIRG.all][CRAFTING_TYPE_WOODWORKING][i] = {}
-        -- Cycle through the traits for this item
-        for j = 10, 18 do
-                       AIRG.vars.data[AIRG.all][CRAFTING_TYPE_WOODWORKING][i][j] = 0   -- set to not known
-        end
-    end
-
-    --Create Empty Style Table
-    for i = 1, 14 do
-        AIRG.vars.styles[AIRG.all][i] = false
-    end
-
- -- AIRG.CreateDataMatrix
-
-    -- Following replaced with PlayerActivate
-    -- Query data for THIS character and populate the data matrix with fresh data.
-    --AIRG.PopulateMatrix()
-
-    -- Query data for THIS character for STYLES
-    --AIRG.PopulateStyleData()
-
-    -- UI set-up. Create frames, position labels & buttons etc.
-    AIRG.initUI()
-
-
-    -- REGISTER for events that aren't initialise.
-    EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_SMITHING_TRAIT_RESEARCH_STARTED, AIRG.ResearchStarted)
-    EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_SMITHING_TRAIT_RESEARCH_COMPLETED, AIRG.ResearchCompleted)
-
-    EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_STYLE_LEARNED, AIRG.StyleLearned)
-
-    EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_PLAYER_ACTIVATED, AIRG.PlayerActivated)
-
-    -- Create the configuration/settings menu.
-    AIRG.CreateConfigMenu()
-
-    AIRG.initialised = true
-end -- AIRG.Initialise
-
-EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_ADD_ON_LOADED, AIRG.Initialise)



@@ -196,6 +93,7 @@ function AIRG.initUI()
     AIRG.UI.WindowSubTitle:SetColor(0, 1, 0, 1);    -- green
     AIRG.UI.WindowSubTitle:SetText("")
     -- Nice little line under the main title
+    -- ## Check is htis showing right?
     AIRG.UI.TopDivider = WINDOW_MANAGER:CreateControl("AIResearchGridTopDivider", AIResearchGrid, CT_TEXTURE)
     AIRG.UI.TopDivider:SetDimensions(760, 5)
     AIRG.UI.TopDivider:SetAnchor(TOPLEFT, AIResearchGrid, TOPLEFT, 0, 32)
@@ -209,7 +107,7 @@ function AIRG.initUI()
     -- CREATE BUTTON FOR CLOSE ADDON AT TOP_RIGHT
     AIRG.UI.btnCloseAddonFrame = WINDOW_MANAGER:CreateControl("AIResearchGridButtonCloseAddon", AIResearchGrid, CT_BUTTON)
     AIRG.UI.btnCloseAddonFrame:SetDimensions(28, 28)
-    AIRG.UI.btnCloseAddonFrame:SetAnchor(TOPRIGHT, AIResearchGrid, TOPRIGHT, 0 , 0)
+    AIRG.UI.btnCloseAddonFrame:SetAnchor(TOPRIGHT, AIResearchGrid, TOPRIGHT, 5 , 0)
     AIRG.UI.btnCloseAddonFrame:SetState(BSTATE_NORMAL)
     AIRG.UI.btnCloseAddonFrame:SetMouseOverBlendMode(0)
 --    AIRG.UI.btnCloseAddonFrame:SetHidden(false)
@@ -218,6 +116,7 @@ function AIRG.initUI()
     AIRG.UI.btnCloseAddonFrame:SetNormalTexture("/esoui/art/buttons/clearslot_down.dds")
     AIRG.UI.btnCloseAddonFrame:SetMouseOverTexture("/esoui/art/buttons/clearslot_up.dds")
     AIRG.UI.btnCloseAddonFrame:SetHandler("OnClicked", function(self) AIRG.ToggleMainWindow() end)
+
     -- CREATE the DROPDOWN BOX for CHARACTER SELECT
     -- Uses code based on example from Seerah
     AIRG.UI.charDropdown = WINDOW_MANAGER:CreateControlFromVirtual("AIResearchGridDropdownCharacter", AIResearchGrid, "ZO_StatsDropdownRow")
@@ -231,8 +130,46 @@ function AIRG.initUI()
         local entry = AIRG.UI.charDropdown.dropdown:CreateItemEntry(charName, OnItemSelect)
         AIRG.UI.charDropdown.dropdown:AddItem(entry)
     end
-
-    -- PEOPLE ICON NEXT TO THE DROPDOWN BOX
+    -- CREATE BUTTON FOR "Update Other" AT TOP_RIGHT
+    --AIRG.UI.btnUpdateOther = WINDOW_MANAGER:CreateControl("AIResearchGridButtonUpdateOther", AIResearchGrid, CT_BUTTON)
+    AIRG.UI.btnUpdateOther = WINDOW_MANAGER:CreateControlFromVirtual("AIResearchGridButtonUpdateOther", AIResearchGrid, "ZO_DefaultButton")
+    local textlen = 0
+    if string.len(AIRG.btnUpdateOtherText1) > string.len(AIRG.btnUpdateOtherText2)
+    then textlen = string.len(AIRG.btnUpdateOtherText1)
+    else textlen = string.len(AIRG.btnUpdateOtherText2)
+    end
+
+    AIRG.UI.btnUpdateOther:SetDimensions(150+textlen, 30)
+    AIRG.UI.btnUpdateOther:SetAnchor(TOPRIGHT, AIResearchGrid, TOPRIGHT, -240, 0)
+    AIRG.UI.btnUpdateOther:SetState(BSTATE_NORMAL)
+    AIRG.UI.btnUpdateOther:SetMouseOverBlendMode(0)
+--    AIRG.UI.btnUpdateOther:SetNormalTexture("/esoui/art/icons/ability_tradecraft_008.dds")
+    AIRG.UI.btnUpdateOther:SetMouseOverTexture("ESOUI/art/buttons/generic_highlight.dds")
+    AIRG.UI.btnUpdateOther:SetClickSound("Click")
+    AIRG.UI.btnUpdateOther:SetDisabledFontColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA())
+    AIRG.UI.btnUpdateOther:SetFont("ZoFontGame")
+    AIRG.UI.btnUpdateOther:SetText(AIRG.btnUpdateOtherText1)
+    AIRG.UI.btnUpdateOther:SetPressedFontColor(0.2, 1, 0.2, 1) -- green
+    AIRG.UI.btnUpdateOther:SetPressedOffset(2,2)
+
+    AIRG.UI.btnUpdateOther:SetEnabled(false)  -- starts pointing to current character, which can't use this
+    AIRG.UI.btnUpdateOther:SetHidden(false)
+-- enabled at end of function
+    AIRG.UI.btnUpdateOther:SetHandler("OnClicked",
+      function(self)
+                       AIRG.ShowRelative = not AIRG.ShowRelative
+                       if AIRG.ShowRelative
+                       then  self:SetText(AIRG.btnUpdateOtherText2)
+
+                       else  self:SetText(AIRG.btnUpdateOtherText1)
+                     end
+                     AIRG.OnCraftSelected() --redisplay
+         end)
+    AIRG.UI.btnUpdateOther:SetHandler("OnMouseEnter", ZO_Options_OnMouseEnter)
+    AIRG.UI.btnUpdateOther:SetHandler("OnMouseExit", ZO_Options_OnMouseExit)
+    AIRG.UI.btnUpdateOther:SetMouseEnabled(true)
+  --
+    -- PEOPLE ICON NEXT TO THE DROPDOWN BOX.
 --    AIRG.UI.PeopleIcon = WINDOW_MANAGER:CreateControl("AIResearchGridPeopleIcon", AIResearchGrid, CT_TEXTURE)
 --    AIRG.UI.PeopleIcon:SetDimensions(40, 32)
 --    AIRG.UI.PeopleIcon:SetAnchor(TOPRIGHT, AIRG.UI.charDropdown, TOPLEFT, 0, 0)
@@ -333,7 +270,7 @@ function AIRG.initUI()
             AIRG.UI.gridButtons[i][j] = WINDOW_MANAGER:CreateControl("AIResearchGridGridButton" .. tostring(i) .. "x" .. tostring(j), AIResearchGrid, CT_TEXTURE)
             AIRG.UI.gridButtons[i][j]:SetDimensions(24, 24)
             AIRG.UI.gridButtons[i][j]:SetAnchor(TOP, AIRG.UI.columnButtons[i], BOTTOM, 0, 28*j -20)
-            AIRG.UI.gridButtons[i][j]:SetTexture("/esoui/art/buttons/swatchframe_down.dds")
+            AIRG.UI.gridButtons[i][j]:SetTexture("/esoui/art/buttons/swatchframe_down.dds")  -- little square box
             AIRG.UI.gridButtons[i][j]:SetColor(1, 1, 1, 0.4)
             AIRG.UI.gridButtons[i][j]:SetHidden(false)
             AIRG.UI.gridButtons[i][j]:SetMouseEnabled(false)
@@ -410,6 +347,7 @@ function AIRG.initUI()
     AIRG.UI.StyleLabel:SetDimensions(150, 24)
     AIRG.UI.StyleLabel:SetFont("ZoFontGame")
     AIRG.UI.StyleLabel:SetHorizontalAlignment(TEXT_ALIGN_RIGHT)
+
 end -- AIRG.initUI

 -- User has clicked on one of the profession buttons
@@ -422,8 +360,17 @@ function AIRG.OnCraftSelected(_,thisCraft)
             thisCraft = AIRG.curCraft
         end
     end
+
+    -- the below doesnt seem to work right for some reason..
+    if AIRG.ShowRelative  -- point to table set we are using.
+      then local DispData = AIRG.vars.data
+    else local DispData = AIRG.relative
+  end
+
+
     AIRG.UI.WindowSubTitle:SetText(AIRG.craftNames[thisCraft])
     local i,j
+
     local tType,tDesc,tKnown,tRemain,rowNum,traitCount
     local maxLines = GetNumSmithingResearchLines(thisCraft) -- the number of columns for this profession
     AIRG.curCraft = thisCraft
@@ -444,7 +391,20 @@ function AIRG.OnCraftSelected(_,thisCraft)
             AIRG.UI.columnButtons[i].text = name

             traitCount = 0
-            for rowNum,tKnown in pairs(AIRG.vars.data[AIRG.curCharacter][thisCraft][i]) do
+            if  AIRG.ShowRelative
+            then
+                for rowNum,tKnown in pairs(AIRG.relative[AIRG.curCharacter][thisCraft][i]) do
+                  AIRG.UI.gridButtons[i][rowNum].tooltipText = tKnown
+                  if (tKnown == -1) then       -- Trait is known
+                    AIRG.UI.gridButtons[i][rowNum]:SetColor(0.2, 1, 0.2, 1)   -- Green
+                    AIRG.UI.gridButtons[i][rowNum]:SetTexture("/esoui/art/loot/loot_finesseitem.dds")
+                    traitCount = traitCount + 1
+                  end
+                end
+
+
+            else
+              for rowNum,tKnown in pairs(AIRG.vars.data[AIRG.curCharacter][thisCraft][i]) do
                 AIRG.UI.gridButtons[i][rowNum].tooltipText = tKnown
                 if (tKnown == -1) then       -- Trait is known
                     AIRG.UI.gridButtons[i][rowNum]:SetColor(0.2, 1, 0.2, 1)   -- Green
@@ -454,6 +414,8 @@ function AIRG.OnCraftSelected(_,thisCraft)
                     AIRG.UI.gridButtons[i][rowNum]:SetTexture("ESOUI/art/mounts/timer_icon.dds")
                     if (tKnown < GetTimeStamp()) then   -- This is on another character and the timer has completed.
                         AIRG.UI.gridButtons[i][rowNum]:SetColor(0.2, 1, 0.2, 1)   -- Green
+                        AIRG.UI.gridButtons[i][rowNum]:SetTexture("/esoui/art/loot/loot_finesseitem.dds")  -- nice gold tick
+                        AIRG.vars.data[AIRG.curCharacter][thisCraft][i][rowNum] = -1 -- Reset trait to known
                         traitCount = traitCount + 1
                     else
                         AIRG.UI.gridButtons[i][rowNum]:SetColor(0.5, 0.5, 1, 1)   -- Blue
@@ -461,9 +423,13 @@ function AIRG.OnCraftSelected(_,thisCraft)
                     end
                 else                        -- Trait is NOT known
                     AIRG.UI.gridButtons[i][rowNum]:SetColor(1, 0.2, 0.2, 1)   -- Red
-                    AIRG.UI.gridButtons[i][rowNum]:SetTexture("ESOUI/art/buttons/decline_up.dds")
+                    AIRG.UI.gridButtons[i][rowNum]:SetTexture("ESOUI/art/buttons/decline_up.dds")  --  an   "X".
                 end
-            end
+              end
+
+            end
+
+
       --      if (traitCount > 0) then
                AIRG.UI.columnFooters[i]:SetText(traitCount)
       --      else
@@ -476,11 +442,23 @@ end -- AIRG:OnCraftSelected
 -- Invoked when the user selected a character from the dropdown box
 function AIRG.OnCharacterSelect(charName)

-    if (charName == nil) then else
-        AIRG.curCharacter = charName
+    if (charName == nil) then
+        return
+    end
+    AIRG.curCharacter = charName
+
+      -- The Update Other Button doesn't make sense if selecting these
+    if charName == AIRG.all or charName == AIRG.playerName then
+      AIRG.UI.btnUpdateOther:SetEnabled(false)
+      AIRG.ShowRelative = false
+    else
+      AIRG.UI.btnUpdateOther:SetEnabled(true)
     end
+
     AIRG.DisplayStyles()
     AIRG.OnCraftSelected()
+
+
 end -- AIRG.OnCharacterSelect

 -- Deletes data for the named character from the saved data and removes them from the dropdown box.
@@ -521,7 +499,9 @@ function AIRG.PopulateMatrix()
           AIRG.curCraft = CRAFTING_TYPE_WOODWORKING
           curCount = thisCount
         end
-
+      AIRG.CreateDataMatrixRelative(CRAFTING_TYPE_BLACKSMITHING)
+      AIRG.CreateDataMatrixRelative(CRAFTING_TYPE_WOODWORKING)
+     AIRG.CreateDataMatrixRelative(CRAFTING_TYPE_CLOTHIER)
 end -- AIRG.PopulateMatrix

 -- Lookup the style data for the current character and send it to saved vars.
@@ -560,6 +540,7 @@ function AIRG.PopulateAll()
     end
  end  -- AIRG.PopulateAll

+
 -- Set the icon highlights for the currently selected character
 function AIRG.DisplayStyles()
     local i
@@ -583,12 +564,14 @@ end -- AIRG.DisplayStyles()

 -- Look up all the data on this profession and commit to saved variables for this character.
 -- TO DO: At some point, get clever with storing the timestamp for when research will be complete
-function AIRG.CreateDataMatrix(thisCraft)
+function AIRG.CreateDataMatrix(thisCraft)  -- for current  player, not the selected
   local i, j
     local tType, tKnown, tRemain, rowNum, tTargetStamp
     local rCount = 0
     local maxLines = GetNumSmithingResearchLines(thisCraft)     -- the number of columns for this profession
-    AIRG.vars.data[AIRG.playerName][thisCraft] = {}             -- create a table for this profession
+    AIRG.vars.data[AIRG.playerName][thisCraft] = {}             -- create a table for this profession for real traits
+
+    -- Not relative updates, show all for Current Character
     -- Cycle through items for this profession
     for i = 1, maxLines do
         AIRG.vars.data[AIRG.playerName][thisCraft][i] = {}      -- create a table for this item
@@ -611,10 +594,35 @@ function AIRG.CreateDataMatrix(thisCraft)
                 end
             end
         end
+
     end
     return rCount       -- the total number of traits already researched in this profession
 end -- AIRG.CreateDataMatrix

+function AIRG.CreateDataMatrixRelative(thisCraft)  -- for the current selected  player, relative to the real player
+    local craft, item, trait, thisname, style, known
+
+    for thisname, _ in pairs(AIRG.vars.data) do   --iterate over all characters
+      if thisname ~= AIRG.all then                --skip our virtual
+        AIRG.relative[thisname] = {}
+        for craft, _ in pairs(AIRG.vars.data[thisname]) do   --iterate over all crafts
+          AIRG.relative[thisname][craft] = {}
+          for item, _ in pairs(AIRG.vars.data[thisname][craft]) do   --iterate over all weapons/armour
+            AIRG.relative[thisname][craft][item] = {}
+            for trait, _ in pairs(AIRG.vars.data[thisname][craft][item]) do   --iterate over all traits
+              AIRG.relative[thisname][craft][item][trait] = {}
+              if AIRG.vars.data[thisname][craft][item][trait] ==  0 then -- thischar doesn't have traits
+                if AIRG.vars.data[AIRG.playerName][craft][item][trait] ==  -1  ---PLayer Does
+                then AIRG.relative[thisname][craft][item][trait] = -1
+                else AIRG.relative[thisname][craft][item][trait] = nil
+                end
+              end
+            end
+          end
+        end
+      end
+    end
+end -- AIRG.CreateDataMatrix



@@ -692,6 +700,116 @@ function AIRG.AssignStyleLookups()
     AIRG.styleLookupItem[14] = 20   -- Primal       = Argentum
 end -- AIRG.AssignStyleLookups

+
+function AIRG.Initialise(eventCode, addOnName)
+	-- Only initialize our own addon
+	if (AIRG.name ~= addOnName) then return end
+
+    -- Language text
+    AIRG.InitialiseLanguage()
+
+    -- Load the saved variables
+    AIRG.vars = ZO_SavedVars:NewAccountWide("AIRG_SavedVariables", 2, nil, AIRG.defaults)
+
+    -- Register Keybinding
+    ZO_CreateStringId("SI_BINDING_NAME_TOGGLE_AIRG", "Toggle AI Research Grid")
+
+	-- Set-up some variables we'll want to refer to.
+    AIRG.craftNames = {}
+    AIRG.relative = {}
+    AIRG.craftNames[CRAFTING_TYPE_BLACKSMITHING]    = "BLACKSMITHING"
+    AIRG.craftNames[CRAFTING_TYPE_CLOTHIER]         = "CLOTHING"
+    AIRG.craftNames[CRAFTING_TYPE_WOODWORKING]      = "WOODWORKING"
+    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.vars.styles[AIRG.all] = {}           -- and our virtual character
+
+    -- 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.all] = {}    -- and our virtual character
+
+  -- Create Empty data for Virtual Char set to 0, (Not known)
+    local i, j
+
+    AIRG.vars.data[AIRG.all][CRAFTING_TYPE_BLACKSMITHING] = {}
+    -- Cycle through items for this profession
+    for i = 1, 7 do   -- Weapons
+        AIRG.vars.data[AIRG.all][CRAFTING_TYPE_BLACKSMITHING][i] = {}
+        -- Cycle through the traits for this item
+        for j = 1, 9 do
+                       AIRG.vars.data[AIRG.all][CRAFTING_TYPE_BLACKSMITHING][i][j] = 0   -- set to not known
+        end
+    end
+    for i = 8, 14 do  -- Armour
+        AIRG.vars.data[AIRG.all][CRAFTING_TYPE_BLACKSMITHING][i] = {}
+        -- Cycle through the traits for this item
+        for j = 10, 18 do
+                       AIRG.vars.data[AIRG.all][CRAFTING_TYPE_BLACKSMITHING][i][j] = 0   -- set to not known
+        end
+    end
+
+    AIRG.vars.data[AIRG.all][CRAFTING_TYPE_CLOTHIER] = {}
+    -- Cycle through items for this profession
+    for i = 1, 14 do
+        AIRG.vars.data[AIRG.all][CRAFTING_TYPE_CLOTHIER][i] = {}
+        -- Cycle through the traits for this item
+        for j = 10, 18  do
+                       AIRG.vars.data[AIRG.all][CRAFTING_TYPE_CLOTHIER][i][j] = 0   -- set to not known
+        end
+    end
+
+     AIRG.vars.data[AIRG.all][CRAFTING_TYPE_WOODWORKING] = {}
+    -- Cycle through items for this profession
+    for i = 1, 5 do
+        AIRG.vars.data[AIRG.all][CRAFTING_TYPE_WOODWORKING][i] = {}
+        -- Cycle through the traits for this item
+        for j = 1, 9 do
+                       AIRG.vars.data[AIRG.all][CRAFTING_TYPE_WOODWORKING][i][j] = 0   -- set to not known
+        end
+    end
+    for i = 6, 6 do  --Shields
+        AIRG.vars.data[AIRG.all][CRAFTING_TYPE_WOODWORKING][i] = {}
+        -- Cycle through the traits for this item
+        for j = 10, 18 do
+                       AIRG.vars.data[AIRG.all][CRAFTING_TYPE_WOODWORKING][i][j] = 0   -- set to not known
+        end
+    end
+
+    --Create Empty Style Table
+    for i = 1, 14 do
+        AIRG.vars.styles[AIRG.all][i] = false
+    end
+
+ -- AIRG.CreateDataMatrix
+
+    -- Following replaced with PlayerActivate
+    -- Query data for THIS character and populate the data matrix with fresh data.
+    --AIRG.PopulateMatrix()
+
+    -- Query data for THIS character for STYLES
+    --AIRG.PopulateStyleData()
+
+    -- UI set-up. Create frames, position labels & buttons etc.
+    AIRG.initUI()
+
+    -- REGISTER for events that aren't initialise.
+    EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_SMITHING_TRAIT_RESEARCH_STARTED, AIRG.ResearchStarted)
+    EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_SMITHING_TRAIT_RESEARCH_COMPLETED, AIRG.ResearchCompleted)
+
+    EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_STYLE_LEARNED, AIRG.StyleLearned)
+
+    EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_PLAYER_ACTIVATED, AIRG.PlayerActivated)
+
+    -- Create the configuration/settings menu.
+    AIRG.CreateConfigMenu()
+
+    AIRG.initialised = true
+end -- AIRG.Initialise
+
+EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_ADD_ON_LOADED, AIRG.Initialise)
 -- SLASH COMMAND FUNCTIONALITY
 function AIRGslash(extra)
     AIRG.ToggleMainWindow()
diff --git a/changelog b/changelog
new file mode 100644
index 0000000..dd345a5
--- /dev/null
+++ b/changelog
@@ -0,0 +1,11 @@
+2014-12-01  V3.0.0  Sent to Stormknight and CDG
+	New Feature
+		Added #ALL
+
+2014-12-03  V3.0.0  Sent to Stormknight and CDG
+	Bugs Fixed
+	-- might not display correctly on a char with no traits learned
+	--if trait timer completes on another char, the trait goes green, but the icon remains the hourglass.
+	New Feature
+	Add a button to put it in relative mode.
+		Provided you have one other char in there (it is disabled for #all and the current player), it will show the traits that the current player can make (or will be able to make if still in research) that the selected char doesn't have. This is for when you are trying to consolidate traits on to your main crafting chars, to get that magical "8" traits known. If you are like me, you might get alts to learn traits because you don't have the bank space to hold the item..
\ No newline at end of file