update for thieves guild

René Welbers [02-05-16 - 12:31]
update for thieves guild
Filename
Locales/de.lua
Locales/en.lua
RaidTimer.lua
RaidTimer.txt
diff --git a/Locales/de.lua b/Locales/de.lua
index 1592989..0d36f32 100644
--- a/Locales/de.lua
+++ b/Locales/de.lua
@@ -13,6 +13,8 @@ L.Total_Time_Color            = 'Timer Farbe'
 L.Total_Time_Color_Tooltip    = 'Ändert die Farbe des Timers.'
 L.Raid_Score_Color            = 'Punktzahl Farbe'
 L.Raid_Score_Color_Tooltip    = 'Ändert die Farbe der Punktzahl.'
+L.Vitality_Bonus_Color         = 'Vitalitätsbonus Farbe'
+L.Vitality_Bonus_Color_Tooltip = 'Ändert die Farbe des Vitalitätsbonus.'
 L.Fonts                       = 'Schriftart'
 L.Fonts_Tooltip               = 'Ändert die Schriftart des Timers.'
 L.Font_Size                   = 'Schriftgröße'
@@ -28,10 +30,12 @@ L.Aplly_Tooltip               = 'Speichert die Änderungen.'
 -- ---------------------------------------------------
 L.Total_Time_Template           = 'Zeit:'
 L.Raid_Score_Template           = 'Punkte: 0'
+L.Vitality_Bonus_Template       = 'Vitalitätsbonus Leben: 0 / 0'
 L.Total_Time                    = 'Zeit: <<1>>' -- <<1>> is the formatted time
 L.Raid_Score_Without_Estimation = 'Punkte: <<1>>' -- <<1>> ist the current score
 L.Raid_Score_With_Estimation    = 'Punkte: <<1>> (~<<2>>)' -- <<1>> ist the current score, <<2>> the estimated score
 L.Raid_Score_With_New_TopScore  = 'Punkte: <<1>> (~<<2>>)!!'  -- <<1>> ist the current score, <<2>> the estimated score
+L.Vitality_Bonus                = 'Vitalitätsbonus Leben: <<1>> / <<2>>'  -- <<1>> are the current lifes, <<2>> the max lifes
 L.Possible_New_TopScore_Debug   = 'Mögliche neue Bestpunktzahl! Vorherige Bestpunktzahl war <<1>> (<<2>>)'  -- <<1>> ist the previous score, <<2>> the previous time
 L.Debug_Message                 = 'Punkte: |cFFFFFF<<1>>|r, Total: |cFFFFFF<<2>>|r, Grund: |cFFFFFF<<3>>|r'  -- <<1>> ist the current points, <<2>> the total raidscore and <<3>> the reason for getting points
 L.Trial_Start_Message           = 'Prüfung gestartet, aktuelle Bestpunktzahl: |cFFFFFF<<1>>|r, Zeit: |cFFFFFF<<2>>|r' -- <<1>> is the previous topscore, <<2>> the previous top time
diff --git a/Locales/en.lua b/Locales/en.lua
index f122535..fb16335 100644
--- a/Locales/en.lua
+++ b/Locales/en.lua
@@ -13,6 +13,8 @@ L.Total_Time_Color            = 'Total Timer color'
 L.Total_Time_Color_Tooltip    = 'Change the color of Total Timer.'
 L.Raid_Score_Color            = 'Raid Score color'
 L.Raid_Score_Color_Tooltip    = 'Change the color of the Raid Score.'
+L.Vitality_Bonus_Color         = 'Vitality Bonus color'
+L.Vitality_Bonus_Color_Tooltip = 'Change the color of the Vitality Bonus.'
 L.Fonts                       = 'Fonts'
 L.Fonts_Tooltip               = 'Change the font of the timers.'
 L.Font_Size                   = 'Font Size'
@@ -28,10 +30,12 @@ L.Aplly_Tooltip               = 'Apply the changes.'
 -- ---------------------------------------------------
 L.Total_Time_Template           = 'Total Time:'
 L.Raid_Score_Template           = 'Raid Score: 0'
+L.Vitality_Bonus_Template       = 'Vitality Bonus Lifes: 0 / 0'
 L.Total_Time                    = 'Total Time: <<1>>' -- <<1>> is the formatted time
 L.Raid_Score_Without_Estimation = 'Raid Score: <<1>>' -- <<1>> ist the current score
 L.Raid_Score_With_Estimation    = 'Raid Score: <<1>> (~<<2>>)' -- <<1>> ist the current score, <<2>> the estimated score
 L.Raid_Score_With_New_TopScore  = 'Raid Score: <<1>> (~<<2>>)!!'  -- <<1>> ist the current score, <<2>> the estimated score
+L.Vitality_Bonus                = 'Vitality Bonus Lifes: <<1>> / <<2>>'  -- <<1>> are the current lifes, <<2>> the max lifes
 L.Possible_New_TopScore_Debug   = 'Possible new Topscore! Previuos Topscore was <<1>> (<<2>>)'  -- <<1>> ist the previous score, <<2>> the previous time
 L.Debug_Message                 = 'Raid Score: |cFFFFFF<<1>>|r, total: |cFFFFFF<<2>>|r, reason: |cFFFFFF<<3>>|r'  -- <<1>> ist the current points, <<2>> the total raidscore and <<3>> the reason for getting points
 L.Trial_Start_Message           = 'Raid Started, current TopScore: |cFFFFFF<<1>>|r, Time: |cFFFFFF<<2>>|r' -- <<1>> is the previous topscore, <<2>> the previous top time
diff --git a/RaidTimer.lua b/RaidTimer.lua
index 99f2fcf..5b6d8ab 100644
--- a/RaidTimer.lua
+++ b/RaidTimer.lua
@@ -5,7 +5,7 @@ RaidTimer = {}

 RaidTimer.name		= 'RaidTimer'
 RaidTimer.slash		= '/rt'
-RaidTimer.version	= '1.3.6'
+RaidTimer.version	= '1.4.0'
 RaidTimer.versionDB	= 1
 RaidTimer.loaded	= false
 RaidTimer.author    = 'Noshiz, Garkin & silentgecko'
@@ -22,13 +22,17 @@ RaidTimer.variables = {
     TotalOffsetY = 30,
     ScoreOffsetX = 45,
     ScoreOffsetY = 60,
+    VitalityOffsetX = 45,
+    VitalityOffsetY = 60,
     FontFace = "Univers 67",
     FontSize = 16,
     FontStyle = "soft-shadow-thin",
     TotalFonts = "ZoFontHeader",
     ScoreFonts = "ZoFontHeader",
+    VitalityFonts = "ZoFontHeader",
     TotalColor = { ZO_NORMAL_TEXT:UnpackRGBA() },
     ScoreColor = { ZO_NORMAL_TEXT:UnpackRGBA() },
+    VitalityColor = { ZO_NORMAL_TEXT:UnpackRGBA() },
     Movable = true,
     hardMode = false,
     hardModePoints = 40000,       -- Hardmode Bonus Points for AA, HR and SO
@@ -50,6 +54,10 @@ RaidTimer.variables = {
             time = 0,
             score = 0,
         },
+        [5] = {
+            time = 0,
+            score = 0,
+        },
         [6] = {
             time = 0,
             score = 0,
@@ -63,7 +71,7 @@ RaidTimer.timeLimits = {
     [2] = 720,  --Aetherian Archive (12 minutes)
     [3] = 1500, --Sanctum Ophidia (25 minutes)
     [4] = 3900, --Dragonstar Arena (Veteran) (65 minutes)
-    [5] = 0,    --none
+    [5] = 1500, --Maw of Lorkahj -- todo
     [6] = 5400, --Maelstrom Arena (Veteran) (4 hours 16 min 40 sek)
 }

@@ -73,7 +81,7 @@ RaidTimer.raidPoints = {
     [2] = 63000, --Aetherian Archive
     [3] = 100750,--Sanctum Ophidia (117.750 with troll archievement)
     [4] = 20000, --Dragonstar Arena (Veteran)
-    [5] = 0,     --none
+    [5] = 100000, --Maw of Lorkahj -- todo
     [6] = 396000, --Maelstrom Arena (Veteran)
 }

@@ -96,15 +104,6 @@ local function CreateSettingsMenu()
         },
         {
             type = "checkbox",
-            name = GetString(RAIDTIMER_HARDMODE),
-            tooltip = GetString(RAIDTIMER_HARDMODE_TOOLTIP),
-            getFunc = function() return RaidTimer.savedVariables.hardMode end,
-            setFunc = function(value)
-                RaidTimer.savedVariables.hardMode = value
-            end,
-        },
-        {
-            type = "checkbox",
             name = GetString(RAIDTIMER_SHOW_TIMERS_OUTSIDE),
             tooltip = GetString(RAIDTIMER_SHOW_TIMERS_OUTSIDE_TOOLTIP),
             getFunc = function() return RaidTimer.tempVars.showTimers end,
@@ -126,6 +125,15 @@ local function CreateSettingsMenu()
                 end,
         },
         {
+            type = "checkbox",
+            name = GetString(RAIDTIMER_HARDMODE),
+            tooltip = GetString(RAIDTIMER_HARDMODE_TOOLTIP),
+            getFunc = function() return RaidTimer.savedVariables.hardMode end,
+            setFunc = function(value)
+                RaidTimer.savedVariables.hardMode = value
+            end,
+        },
+        {
             type = "colorpicker",
             name = GetString(RAIDTIMER_TOTAL_TIME_COLOR),
             tooltip = GetString(RAIDTIMER_TOTAL_TIME_COLOR_TOOLTIP),
@@ -146,6 +154,16 @@ local function CreateSettingsMenu()
                 end,
         },
         {
+            type = "colorpicker",
+            name = GetString(RAIDTIMER_VITALITY_BONUS_COLOR),
+            tooltip = GetString(RAIDTIMER_VITALITY_BONUS_COLOR_TOOLTIP),
+            getFunc = function() return unpack(RaidTimer.savedVariables.VitalityColor) end,
+            setFunc = function(r,g,b,a)
+                RaidTimer.Vitality_Bonus:SetColor(r, g, b, a)
+                RaidTimer.savedVariables.VitalityColor = {r,g,b,a}
+            end,
+        },
+        {
             type = "dropdown",
             name = GetString(RAIDTIMER_FONTS),
             tooltip = GetString(RAIDTIMER_FONTS_TOOLTIP),
@@ -193,8 +211,12 @@ local function CreateSettingsMenu()
                     RaidTimer.finalFont = (formatstring):format(LMP:Fetch("font", RaidTimer.savedVariables.FontFace), RaidTimer.savedVariables.FontSize, RaidTimer.savedVariables.FontStyle)
                     RaidTimer.Total_Timer:SetFont(RaidTimer.finalFont)
                     RaidTimer.Raid_Score:SetFont(RaidTimer.finalFont)
+                    if (GetAPIVersion() == 100014) then
+                        RaidTimer.Vitality_Bonus:SetFont(RaidTimer.finalFont)
+                    end
                     RaidTimer.savedVariables.TotalFonts = RaidTimer.finalFont
                     RaidTimer.savedVariables.ScoreFonts = RaidTimer.finalFont
+                    RaidTimer.savedVariables.VitalityFonts = RaidTimer.finalFont
                 end,
         },
     }
@@ -261,6 +283,19 @@ function RaidTimer.Initialize(event, addonName)
     self.Raid_Score:SetColor(unpack(self.savedVariables.ScoreColor))
     self.Raid_Score:SetHandler("OnMoveStop", self.SaveLoc)

+    if GetAPIVersion() == 100014 then
+        self.Vitality_Bonus = WINDOW_MANAGER:CreateControl(nil, self.Root_Window, CT_LABEL)
+        self.Vitality_Bonus:SetText(GetString(RAIDTIMER_VITALITY_BONUS_TEMPLATE))
+        self.Vitality_Bonus:SetMouseEnabled(true)
+        self.Vitality_Bonus:SetHidden(true)
+        self.Vitality_Bonus:SetAnchor(TOPLEFT, self.Root_Window, TOPLEFT, self.savedVariables.VitalityOffsetX, self.savedVariables.VitalityOffsetY)
+        self.Vitality_Bonus:SetFont(self.savedVariables.VitalityFonts)
+        self.Vitality_Bonus:SetMovable(self.savedVariables.Movable)
+        self.Vitality_Bonus:SetClampedToScreen(true)
+        self.Vitality_Bonus:SetColor(unpack(self.savedVariables.VitalityColor))
+        self.Vitality_Bonus:SetHandler("OnMoveStop", self.SaveLoc)
+    end
+
     local RaidTimerSceneFragment = ZO_HUDFadeSceneFragment:New(self.Root_Window)
     HUD_SCENE:AddFragment(RaidTimerSceneFragment)
     HUD_UI_SCENE:AddFragment(RaidTimerSceneFragment)
@@ -286,6 +321,12 @@ function RaidTimer.TimerUpdate()

     local currentTime = GetTimeStamp()
     local raidDuration = GetDiffBetweenTimeStamps(currentTime, self.raidStart)
+
+    -- new on thieves guild
+    if (GetAPIVersion() == 100014) then
+        raidDuration = GetRaidDuration() / 1000 -- raidduration in MS
+    end
+
     local formatedTime = ZO_FormatTime(raidDuration, TIME_FORMAT_STYLE_COLONS, TIME_FORMAT_PRECISION_SECONDS)
     self.Total_Timer:SetText(zo_strformat(GetString(RAIDTIMER_TOTAL_TIME), formatedTime))

@@ -295,9 +336,9 @@ function RaidTimer.TimerUpdate()
         local maxPoints = self.raidPoints[self.raidId] or 0
         if timeLimit > 0 and maxPoints > 0 then

-            -- hardmode only on the first three raids
+            -- hardmode only on the raids
             local currentPoints = self.score
-            if self.raidId > 0 and self.raidId <= 3 and self.savedVariables.hardMode then
+            if ((self.raidId > 0 and self.raidId <= 3) or self.raidId == 5) and self.savedVariables.hardMode then
                 maxPoints = maxPoints + self.variables.hardModePoints
                 currentPoints = self.score + self.variables.hardModePoints
             end
@@ -336,12 +377,18 @@ function RaidTimer.ScoreUpdate(event, scoreType, scoreAmount, totalScore)
         self.raidId = self.raidId or GetCurrentParticipatingRaidId()
         local currentTime  = GetTimeStamp()
         local raidDuration = GetDiffBetweenTimeStamps(currentTime, self.raidStart)
+
+        -- new on thieves guild
+        if (GetAPIVersion() == 100014) then
+            raidDuration = GetRaidDuration() / 1000 -- raidduration in MS
+        end
+
         local timeLimit    = self.timeLimits[self.raidId] or 0
         local maxPoints    = self.raidPoints[self.raidId] or 0

-        -- hardmode only on the first three raids
+        -- hardmode only on the raids
         local currentPoints = totalScore
-        if self.raidId > 0 and self.raidId <= 3 and self.savedVariables.hardMode then
+        if ((self.raidId > 0 and self.raidId <= 3) or self.raidId == 5) and self.savedVariables.hardMode then
             maxPoints = maxPoints + self.variables.hardModePoints
             currentPoints = totalScore + self.variables.hardModePoints
         end
@@ -372,11 +419,24 @@ function RaidTimer.ScoreUpdate(event, scoreType, scoreAmount, totalScore)
         end
         self.score = totalScore
     end
-    if self.savedVariables.debug then
+    if self.savedVariables.debug and scoreType ~= nil and scoreAmount ~= nil then
         d(zo_strformat(GetString(RAIDTIMER_DEBUG_MESSAGE), scoreAmount, totalScore, self.pointReasons[scoreType]))
     end
 end

+function RaidTimer.ReviveUpdate(event, lifesRemaining)
+    local self = RaidTimer
+
+    if GetAPIVersion() == 100014 then
+        local currentVitality = GetRaidReviveCountersRemaining()
+        local maxVitality = GetCurrentRaidStartingReviveCounters()
+        self.Vitality_Bonus:SetText(zo_strformat(GetString(RAIDTIMER_VITALITY_BONUS), currentVitality, maxVitality))
+    end
+
+    self.score = GetCurrentRaidScore()
+    self.ScoreUpdate(event, nil, nil, self.score)
+end
+
 function RaidTimer.TimerStart()
     local self = RaidTimer

@@ -413,6 +473,13 @@ function RaidTimer.TimerStart()
     self.Total_Timer:SetHidden(false)
     self.Raid_Score:SetHidden(false)

+    if GetAPIVersion() == 100014 then
+        self.Vitality_Bonus:SetHidden(false)
+        local currentVitality = GetRaidReviveCountersRemaining()
+        local maxVitality = GetCurrentRaidStartingReviveCounters()
+        self.Vitality_Bonus:SetText(zo_strformat(GetString(RAIDTIMER_VITALITY_BONUS), currentVitality, maxVitality))
+    end
+
     self.TimerUpdate()
     EVENT_MANAGER:RegisterForUpdate("RAID_TIMER_UPDATE", 1000, self.TimerUpdate)
 end
@@ -448,6 +515,9 @@ function RaidTimer.TimerStop(event, trialName, totalScore, totalTime)

     self.Total_Timer:SetHidden(true)
     self.Raid_Score:SetHidden(true)
+    if GetAPIVersion() == 100014 then
+        self.Vitality_Bonus:SetHidden(true)
+    end
     self.score = 0
     self.raidId = nil
     self.raidStart = nil
@@ -473,6 +543,11 @@ function RaidTimer.SaveLoc()
     self.savedVariables.TotalOffsetY = self.Total_Timer:GetTop()
     self.savedVariables.ScoreOffsetX = self.Raid_Score:GetLeft()
     self.savedVariables.ScoreOffsetY = self.Raid_Score:GetTop()
+
+    if GetAPIVersion() == 100014 then
+        self.savedVariables.VitalityOffsetX = self.Vitality_Bonus:GetLeft()
+        self.savedVariables.VitalityOffsetY = self.Vitality_Bonus:GetTop()
+    end
 end

 ---------Chat commands---------
@@ -506,10 +581,16 @@ function RaidTimer.Commands(text)
     elseif text =="show" then
         self.Total_Timer:SetHidden(false)
         self.Raid_Score:SetHidden(false)
+        if GetAPIVersion() == 100014 then
+            self.Vitality_Bonus:SetHidden(false)
+        end
         self.tempVars.showTimers = true
     elseif text =="hide" then
         self.Total_Timer:SetHidden(true)
         self.Raid_Score:SetHidden(true)
+        if GetAPIVersion() == 100014 then
+            self.Vitality_Bonus:SetHidden(true)
+        end
         self.tempVars.showTimers = false
     elseif text == "debug" then
         self.savedVariables.debug = not self.savedVariables.debug
@@ -521,8 +602,14 @@ function RaidTimer.Commands(text)

 end

+--workaround
+if(GetAPIVersion() == 100013 and ACTIVITY_TRACKER ~= nil) then
+    function GetAPIVersion() return 100014 end
+end
+
 EVENT_MANAGER:RegisterForEvent(RaidTimer.name, EVENT_ADD_ON_LOADED, RaidTimer.Initialize)
 EVENT_MANAGER:RegisterForEvent("RAID_TIMER_UPDATE", EVENT_RAID_TRIAL_SCORE_UPDATE, RaidTimer.ScoreUpdate)
+EVENT_MANAGER:RegisterForEvent("RAID_TIMER_UPDATE", EVENT_RAID_REVIVE_COUNTER_UPDATE, RaidTimer.ReviveUpdate)
 EVENT_MANAGER:RegisterForEvent("RAID_TIMER_START", EVENT_RAID_TRIAL_STARTED, RaidTimer.TimerStart)
 EVENT_MANAGER:RegisterForEvent("RAID_TIMER_STOP", EVENT_RAID_TRIAL_COMPLETE, RaidTimer.TimerStop)
 EVENT_MANAGER:RegisterForEvent("RAID_TIMER_STOP", EVENT_RAID_TRIAL_FAILED, RaidTimer.TimerStop)
diff --git a/RaidTimer.txt b/RaidTimer.txt
index 5254d5b..5b36103 100644
--- a/RaidTimer.txt
+++ b/RaidTimer.txt
@@ -1,7 +1,7 @@
 ## Title: |cEFEBBERaid Timer|r
 ## Author: Noshiz, |cEFEBBEGarkin|r, |c4779cesilentgecko|r
-## Version: 1.3.6
-## APIVersion: 100013
+## Version: 1.4.0
+## APIVersion: 100014
 ## SavedVariables: RTVars
 ## OptionalDependsOn: LibAddonMenu-2.0