New release

Leandro Silva [11-03-18 - 10:57]
New release
Filename
LeoAltholic.lua
LeoAltholic.txt
LeoAltholicInit.lua
ui/checklist.lua
ui/toolbar.lua
ui/writs.lua
diff --git a/LeoAltholic.lua b/LeoAltholic.lua
index 485a2f7..c0fad11 100644
--- a/LeoAltholic.lua
+++ b/LeoAltholic.lua
@@ -94,7 +94,8 @@ local function createQuestEntry(questId)
         location = locationInfo,
         repeatType = repeatType,
         isDaily = repeatType == QUEST_REPEAT_DAILY,
-        isCrafting = questType == QUEST_TYPE_CRAFTING
+        isCrafting = questType == QUEST_TYPE_CRAFTING,
+        questIndex = questId
     }
     if quest.isCrafting then
         quest.craft = LeoAltholic.GetCraftFromQuest(quest.name)
@@ -108,29 +109,27 @@ local function checkQuestForWrits(questName)
             LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastStarted = GetTimeStamp()
             LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastPreDeliver = nil
             LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastUpdated = nil
-            --LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastDone = nil
             LeoAltholicChecklistUI.startedWrit(trackedQuest.craft)

-            local numConditions = GetJournalQuestNumConditions(journalQuestIndex, QUEST_MAIN_STEP_INDEX)
+            local numConditions = GetJournalQuestNumConditions(trackedQuest.questIndex, QUEST_MAIN_STEP_INDEX)
             local hasUpdated = false
             for condition = 1, numConditions do
-                local current, max =  GetJournalQuestConditionValues(journalQuestIndex, QUEST_MAIN_STEP_INDEX, condition)
+                local current, max =  GetJournalQuestConditionValues(trackedQuest.questIndex, QUEST_MAIN_STEP_INDEX, condition)
                 if hasUpdated == false and current > 0 then
                     hasUpdated = true
                 end
-                local condText = GetJournalQuestConditionInfo(journalQuestIndex, QUEST_MAIN_STEP_INDEX, condition)
+                local condText = GetJournalQuestConditionInfo(trackedQuest.questIndex, QUEST_MAIN_STEP_INDEX, condition)
                 if string.find(condText, GetString(LEOALT_DELIVER)) then
                     LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastPreDeliver = GetTimeStamp()
                     LeoAltholicChecklistUI.preDeliverWrit(trackedQuest.craft)
-                    --LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastDone = nil
-                    return
+                    hasUpdated = false
                 end
             end
             if hasUpdated then
                 LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastUpdated = GetTimeStamp()
                 LeoAltholicChecklistUI.updateWrit(trackedQuest.craft)
-                --LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastDone = nil
             end
+            LeoAltholicUI.writsList:RefreshData()
             return
         end
     end
@@ -598,7 +597,7 @@ local function copy(obj, seen)
 end

 function LeoAltholic.GetCharacters(forceUpdate)
-    if #LeoAltholic.charList == 0 or (forceUpdate == true and GetTimeStamp() - LeoAltholic.lastUpdatedCharList > 10) then
+    if #LeoAltholic.charList == 0 or forceUpdate == true or GetTimeStamp() - LeoAltholic.lastUpdatedCharList > 10 then

         LeoAltholic.charList =  {}
         local i = 1
@@ -789,10 +788,17 @@ local function onMailRedable()
 end
 ]]

+local function updateMyself()
+    LeoAltholic.globalData.CharList[LeoAltholic.CharName].inventory.size = GetBagSize(BAG_BACKPACK)
+    LeoAltholic.globalData.CharList[LeoAltholic.CharName].inventory.used = GetNumBagUsedSlots(BAG_BACKPACK)
+    LeoAltholic.globalData.CharList[LeoAltholic.CharName].inventory.free = GetNumBagFreeSlots(BAG_BACKPACK)
+end
+
 local function onUpdate()

     processQueue()

+    updateMyself()
     LeoAltholicChecklistUI.checkReset()
     LeoAltholicToolbarUI:update()

@@ -901,9 +907,10 @@ local function onQuestCounterChanged(eventCode, journalQuestIndex, questName, co
                 if string.find(condText, GetString(LEOALT_DELIVER)) then
                     LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastPreDeliver = GetTimeStamp()
                     LeoAltholicChecklistUI.preDeliverWrit(trackedQuest.craft)
-                    return
+                    break
                 end
             end
+            LeoAltholicUI.writsList:RefreshData()

             return
         end
@@ -918,6 +925,7 @@ local function onQuestRemoved(eventCode, isCompleted, journalQuestIndex, questNa
                 LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastPreDeliver = nil
                 LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastUpdated = nil
                 LeoAltholicChecklistUI.stoppedWrit(trackedQuest.craft)
+                LeoAltholicUI.writsList:RefreshData()
                 return
             end
         end
diff --git a/LeoAltholic.txt b/LeoAltholic.txt
index 4fd4f4b..f7946b9 100644
--- a/LeoAltholic.txt
+++ b/LeoAltholic.txt
@@ -1,6 +1,6 @@
 ## Title: Leo's Altholic
 ## APIVersion: 100024 100025
-## Version: 1.6.1
+## Version: 1.6.2
 ## Author: |c39B027@LeandroSilva|r
 ## SavedVariables: LeoAltholicSavedVariables LeoAltholicCharVariables
 ## OptionalDependsOn: LibStub LibFeedback LibAddonMenu-2.0
diff --git a/LeoAltholicInit.lua b/LeoAltholicInit.lua
index d535708..cb6630b 100644
--- a/LeoAltholicInit.lua
+++ b/LeoAltholicInit.lua
@@ -6,7 +6,7 @@ LeoAltholicToolbarUI = LeoAltholicToolbarUI or {}

 LeoAltholic.name = "LeoAltholic"
 LeoAltholic.displayName = "Leo's Altholic"
-LeoAltholic.version = "1.6.1"
+LeoAltholic.version = "1.6.2"
 LeoAltholic.chatPrefix = "|c39B027" .. LeoAltholic.name .. "|r: "

 LeoAltholic.TAB_BIO = "Bio"
diff --git a/ui/checklist.lua b/ui/checklist.lua
index 9fc9b47..cd6ea0f 100644
--- a/ui/checklist.lua
+++ b/ui/checklist.lua
@@ -304,11 +304,12 @@ function LeoAltholicChecklistUI.initializeQuests()
         for questIndex = 1, MAX_JOURNAL_QUESTS do
             if IsValidQuestIndex(questIndex) and GetJournalQuestName(questIndex) == trackedQuest.name then

-                LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].questIndex = questIndex
+                if LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].questIndex == nil then
+                    LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].questIndex = questIndex
+                end
                 LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastStarted = GetTimeStamp()
                 LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastPreDeliver = nil
                 LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastUpdated = nil
-                --LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastDone = nil
                 LeoAltholicChecklistUI.startedWrit(trackedQuest.craft)

                 local hasUpdated = false
@@ -322,14 +323,12 @@ function LeoAltholicChecklistUI.initializeQuests()
                     if string.find(condText, GetString(LEOALT_DELIVER)) then
                         LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastPreDeliver = GetTimeStamp()
                         LeoAltholicChecklistUI.preDeliverWrit(trackedQuest.craft)
-                        --LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastDone = nil
-                        return
+                        break
                     end
                 end
                 if hasUpdated then
                     LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastUpdated = GetTimeStamp()
                     LeoAltholicChecklistUI.updateWrit(trackedQuest.craft)
-                    --LeoAltholic.globalData.CharList[LeoAltholic.CharName].quests.writs[i].lastDone = nil
                 end
                 break
             end
diff --git a/ui/toolbar.lua b/ui/toolbar.lua
index a701a89..ad00ecb 100644
--- a/ui/toolbar.lua
+++ b/ui/toolbar.lua
@@ -170,14 +170,14 @@ function LeoAltholicToolbarUI.update()
     label:SetHidden(true)
     texture:SetHidden(true)
     if LeoAltholicToolbarUI.GetItem(LeoAltholicToolbarUI.items.INVENTORY) then
-        local color = '|c11EE11'
-        if char.inventory.free <= 25 then color = '|c596cfd' end
-        if char.inventory.free <= 10 then color = '|cCB110E' end
+        local color = '|c' .. LeoAltholic.color.hex.green
+        if char.inventory.free <= 25 then color = '|c'..LeoAltholic.color.hex.yellow end
+        if char.inventory.free <= 10 then color = '|c'..LeoAltholic.color.hex.red end
         label:SetText(color .. char.inventory.used .. "|r / " .. char.inventory.size)
         label:SetHidden(false)
         texture:SetHidden(false)
         texture:SetAnchor(TOPLEFT, toolbar, TOPLEFT, offsetX, 0)
-        offsetX = offsetX + 95
+        offsetX = offsetX + 100
         numSections = numSections + 1
         totalWidth = totalWidth + 105
     end
@@ -222,9 +222,9 @@ function LeoAltholicToolbarUI.update()
                     firstTexture = texture
                 end
                 local researching, total, lowest = LeoAltholic.GetResearchCounters(craft)
-                local color = '|c21A121'
+                local color = '|c'..LeoAltholic.color.hex.green
                 if researching < total then
-                    color = '|cCB110E'
+                    color = '|c'..LeoAltholic.color.hex.red
                 end
                 label:SetText(color .. researching .. '/' .. total .. '|r ' .. LeoAltholic.FormatTime(lowest - GetTimeStamp(), true, true))
                 label:SetHidden(false)
diff --git a/ui/writs.lua b/ui/writs.lua
index 2e82856..256cac1 100644
--- a/ui/writs.lua
+++ b/ui/writs.lua
@@ -34,16 +34,29 @@ function LeoAltholicWritsList:SetupEntry(control, data)
         child = GetControl(control, "Craft"..craft.."Status")
         texture = GetControl(control, "Craft"..craft.."Icon")
         local icon = "esoui/art/tutorial/menubar_help_up.dds"
-        local color = {1,1,1,1}
+        local color = LeoAltholic.color.rgba.white
         local ago = ""
+        local tooltip = ""
         for _, writ in pairs(data.writs) do
             if craft == writ.craft then
+                local inProgress = true
                 if writ.lastDone ~= nil and LeoAltholic.IsAfterReset(writ.lastDone) then
-                    color = {0,1,0,1}
+                    color = LeoAltholic.color.rgba.green
+                    icon = "esoui/art/buttons/accept_up.dds"
+                elseif writ.lastPreDeliver ~= nil and LeoAltholic.IsAfterReset(writ.lastPreDeliver) then
+                    color = LeoAltholic.color.rgba.yellow
+                    icon = "esoui/art/loot/loot_finesseItem.dds"
+                elseif writ.lastUpdated ~= nil and LeoAltholic.IsAfterReset(writ.lastUpdated) then
+                    color = LeoAltholic.color.rgba.orange
+                    icon = "esoui/art/buttons/pointsplus_up.dds"
+                elseif writ.lastStarted ~= nil and LeoAltholic.IsAfterReset(writ.lastStarted) then
+                    color = LeoAltholic.color.rgba.white
+                    icon = "esoui/art/buttons/pointsminus_up.dds"
                 else
-                    color = {1,0,0,1}
+                    inProgress = false
+                    color = LeoAltholic.color.rgba.red
+                    icon = "esoui/art/buttons/decline_up.dds"
                 end
-                icon = "esoui/art/buttons/accept_up.dds"
                 if writ.lastDone ~= nil then
                     local diff = GetTimeStamp() - writ.lastDone
                     if diff < 3600 then
@@ -53,8 +66,12 @@ function LeoAltholicWritsList:SetupEntry(control, data)
                     else
                         ago = ZO_CachedStrFormat(GetString(SI_TIME_FORMAT_DAYS), math.floor(diff / 86400))
                     end
+                    tooltip = ZO_CachedStrFormat(GetString(SI_TIME_DURATION_AGO), ago)
+                    tooltip = ZO_CachedStrFormat(GetString(SI_TRACKED_QUEST_STEP_DONE), tooltip)
+                elseif inProgress then
+                    ago = ""
                 else
-                    ago  = "|cCB110E -- |r"
+                    ago  = "--"
                 end
                 break
             end
@@ -65,6 +82,16 @@ function LeoAltholicWritsList:SetupEntry(control, data)

         child:SetText(ago)
         child:SetColor(unpack(color))
+        if tooltip ~= "" then
+            child:SetHandler("OnMouseEnter", function(control)
+                InitializeTooltip(InformationTooltip, control, TOPLEFT, 50, 0, TOPLEFT)
+                SetTooltipText(InformationTooltip, tooltip)
+            end)
+            child:SetHandler("OnMouseExit", function(self) ClearTooltip(InformationTooltip) end)
+            child:SetMouseEnabled(true)
+        else
+            child:SetMouseEnabled(true)
+        end
     end

     ZO_SortFilterList.SetupRow(self, control, data)