v3.1.4 Sent to Stormknight and CDG, published on esoui

His Dad [12-10-14 - 09:03]
v3.1.4 Sent to Stormknight and CDG, published on esoui
Localization files now used for relative button, but translations not provided
Filename
AIResearchGrid.lua
AIResearchGrid.txt
Language/en.lua
changelog
diff --git a/AIResearchGrid.lua b/AIResearchGrid.lua
index 8369036..d94ddcf 100644
--- a/AIResearchGrid.lua
+++ b/AIResearchGrid.lua
@@ -1,22 +1,19 @@
 -- AI Research Grid Addon for Elder Scrolls Online
 -- Author: Stormknight/LCAmethyst
--- "All"  functionality by His Dad
+-- "All" and "Relative"  functionality by His Dad

 local _
 AIRG = {}

 AIRG.name = "AIResearchGrid"
-AIRG.version = "3.1.0"
+AIRG.version = "3.1.4"
 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= {}
+AIRG.L = {}   -- declare language strings

-
--- Added Update Other Button
 -- Set-up the defaults options for saved variables.
 AIRG.defaults = {
     data        = {},
@@ -25,8 +22,6 @@ AIRG.defaults = {
 }


-
-
 function AIRG.PlayerActivated()
         -- somehow somewhere it sometimes happens that the data is not correct completely for whatever reason
         -- so we force a reload of the current character data when we are actually loaded into the world.
@@ -120,6 +115,7 @@ function AIRG.initUI()
     -- CREATE the DROPDOWN BOX for CHARACTER SELECT
     -- Uses code based on example from Seerah
     AIRG.UI.charDropdown = WINDOW_MANAGER:CreateControlFromVirtual("AIResearchGridDropdownCharacter", AIResearchGrid, "ZO_StatsDropdownRow")
+    AIRG.UI.charDropdown:SetWidth(205) -- Defaults to 607!!!
     AIRG.UI.charDropdown:SetAnchor(TOPRIGHT, AIResearchGrid, TOPRIGHT, -32, 0)
     AIRG.UI.charDropdown:GetNamedChild("Dropdown"):SetWidth(200)
     AIRG.UI.charDropdown.dropdown:SetSelectedItem(AIRG.curCharacter)  -- Set the current character as selected
@@ -134,13 +130,13 @@ function AIRG.initUI()
     --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)
+    if string.len(AIRG.L["btnRelativeOn"]) > string.len(AIRG.L["btnRelativeOff"])
+    then textlen = string.len(AIRG.L["btnRelativeOn"])
+    else textlen = string.len(AIRG.L["btnRelativeOff"])
     end

-    AIRG.UI.btnUpdateOther:SetDimensions(150+textlen, 30)
-    AIRG.UI.btnUpdateOther:SetAnchor(TOPRIGHT, AIResearchGrid, TOPRIGHT, -240, 0)
+    AIRG.UI.btnUpdateOther:SetDimensions(140+textlen, 30)
+    AIRG.UI.btnUpdateOther:SetAnchor(RIGHT, AIRG.UI.charDropdown, LEFT, 0, 0)
     AIRG.UI.btnUpdateOther:SetState(BSTATE_NORMAL)
     AIRG.UI.btnUpdateOther:SetMouseOverBlendMode(0)
 --    AIRG.UI.btnUpdateOther:SetNormalTexture("/esoui/art/icons/ability_tradecraft_008.dds")
@@ -148,10 +144,7 @@ function AIRG.initUI()
     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:SetText(AIRG.L["btnRelativeOff"])
     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
@@ -159,9 +152,9 @@ function AIRG.initUI()
       function(self)
                        AIRG.ShowRelative = not AIRG.ShowRelative
                        if AIRG.ShowRelative
-                       then  self:SetText(AIRG.btnUpdateOtherText2)
-
-                       else  self:SetText(AIRG.btnUpdateOtherText1)
+                       then  self:SetText(AIRG.L["btnRelativeOn"]) -- Lime green
+  --                     else  self:SetText(AIRG.btnUpdateOtherText1 )
+                        else  self:SetText(AIRG.L["btnRelativeOff"])
                      end
                      AIRG.OnCraftSelected() --redisplay
          end)
@@ -387,6 +380,14 @@ function AIRG.OnCraftSelected(_,thisCraft)
             AIRG.UI.columnButtons[i].text = name

             traitCount = 0
+            --Check for research expiry
+            for rowNum,tKnown in pairs(AIRG.vars.data[AIRG.curCharacter][thisCraft][i]) do
+              if (tKnown > 0 and tKnown < GetTimeStamp()) then
+                AIRG.vars.data[AIRG.curCharacter][thisCraft][i][rowNum] = -1  -- Change to known
+              end
+            end
+
+
             if  AIRG.ShowRelative
             then
               -- Great! relative mode! we need to address a matter of practical usage.
@@ -398,7 +399,7 @@ function AIRG.OnCraftSelected(_,thisCraft)
                   end
               end

-                for rowNum,tKnown in pairs(AIRG.relative[AIRG.curCharacter][thisCraft][i]) do
+              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
                     if (busy) then
@@ -409,10 +410,10 @@ function AIRG.OnCraftSelected(_,thisCraft)
                     AIRG.UI.gridButtons[i][rowNum]:SetTexture("/esoui/art/loot/loot_finesseitem.dds")
                     traitCount = traitCount + 1
                   end
-                end
+              end


-            else
+            else -- not relative
               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
@@ -420,30 +421,17 @@ function AIRG.OnCraftSelected(_,thisCraft)
                     AIRG.UI.gridButtons[i][rowNum]:SetTexture("/esoui/art/loot/loot_finesseitem.dds")
                     traitCount = traitCount + 1
                 elseif (tKnown > 0) then   -- Trait is being researched
-                    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]:SetTexture("ESOUI/art/mounts/timer_icon.dds")
                         AIRG.UI.gridButtons[i][rowNum]:SetColor(0.5, 0.5, 1, 1)   -- Blue
                         AIRG.UI.gridButtons[i][rowNum]:SetMouseEnabled(true)
-                    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")  --  an   "X".
                 end
-              end
-
-            end
+              end
+            end  --Relative

-
-      --      if (traitCount > 0) then
-               AIRG.UI.columnFooters[i]:SetText(traitCount)
-      --      else
-      --          AIRG.UI.columnFooters[i]:SetText("")
-      --      end
+            AIRG.UI.columnFooters[i]:SetText(traitCount)
         end
     end
 end -- AIRG:OnCraftSelected
@@ -456,7 +444,7 @@ function AIRG.OnCharacterSelect(charName)
     end
     AIRG.curCharacter = charName

-      -- The Update Other Button doesn't make sense if selecting these
+      -- The Relative 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
@@ -466,14 +454,13 @@ function AIRG.OnCharacterSelect(charName)

     AIRG.DisplayStyles()
     AIRG.OnCraftSelected()
-

 end -- AIRG.OnCharacterSelect

 -- Deletes data for the named character from the saved data and removes them from the dropdown box.
 function AIRG.DeleteCharacter(charName)
     -- Can't delete the current character
-    if (charName == AIRG.playerName or charName == AIRG.all) then
+    if (charName == AIRG.playerName or charName == AIRG.all or charName == AIRG.curCharacter) then
         d(AIRG.L["DeleteFalse"])
     else
         if (AIRG.vars.data[charName] ~= nil) then
@@ -483,6 +470,7 @@ function AIRG.DeleteCharacter(charName)
         if (AIRG.vars.styles[charName] ~= nil) then
             AIRG.vars.styles[charName] = nil
         end
+        AIRG.PopulateAll()
     end
 end -- AIRG.DeleteCharacter

@@ -572,7 +560,6 @@ function AIRG.DisplayStyles()
 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)  -- for current  player, not the selected
   local i, j
     local tType, tKnown, tRemain, rowNum, tTargetStamp
@@ -713,10 +700,9 @@ 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)

diff --git a/AIResearchGrid.txt b/AIResearchGrid.txt
index 5a43369..ef4cede 100644
--- a/AIResearchGrid.txt
+++ b/AIResearchGrid.txt
@@ -1,4 +1,4 @@
-## Title: |cFFFFB0Research Grid|r v3.0 by |c00C000CrazyDutchGuy|r and His Dad
+## Title: |cFFFFB0Research Grid|r v3.1 by |c00C000CrazyDutchGuy|r and His Dad
 ## APIVersion: 100010
 ## Version: 3.1
 ## Author: Stormknight, CrazyDutchGuy &  His Dad
@@ -20,4 +20,5 @@ AIResearchGridConfig.lua
 AIResearchGrid.xml
 Bindings.xml

-Language/$(language).lua
\ No newline at end of file
+Language/en.lua
+Language/$(language).lua
diff --git a/Language/en.lua b/Language/en.lua
index fcf2616..045bec5 100644
--- a/Language/en.lua
+++ b/Language/en.lua
@@ -17,5 +17,9 @@ function AIRG.InitialiseLanguage()
     AIRG.L["DeleteDesc"]                            = "Click this button to delete data for the selected character."

     AIRG.L["DeleteFalse"]                           = "|c8080ffAI Research Grid|r: Can't delete data for the current character."
+
+
     AIRG.L["DeleteTrue"]                            = "|c8080ffAI Research Grid|r: Deleted character data for "
+    AIRG.L["btnRelativeOff"]                        = "Set Relative to:"
+    AIRG.L["btnRelativeOn"]                         = "|c4AFF6ERelative to:|r"
 end
\ No newline at end of file
diff --git a/changelog b/changelog
index 5d4b789..4ab970b 100644
--- a/changelog
+++ b/changelog
@@ -14,3 +14,17 @@
 	New features
 	If using the relative mode but the destination character is already researching that item, the icon will be a dull red tick.
 	Characters can only research 1 trait in a item at at time, no matter how many research slots might be available.
+
+2014-12-05 V3.1.2
+	New Feature
+	None
+	Bugs Fixed
+	Deleting charater data for selected char caused crash
+	In relative mode, scrolling through chars would not update for completed research.
+
+2014-12-05 V3.1.4
+	New Feature
+	Localization files now used for relative button, but translations not provided
+	Bugs Fixed
+	None
+	Note: this file does not have a txt extension, for good reason!