Added saving ultimates by player

torsten.philipp [03-30-18 - 21:25]
Added saving ultimates by player
Filename
TaosGroupTools/Defaults.lua
TaosGroupTools/logic/MapPingHandler.lua
TaosGroupTools/logic/SettingsHandler.lua
TaosGroupTools/ui/groupultimate/GroupUltimateSelector.lua
diff --git a/TaosGroupTools/Defaults.lua b/TaosGroupTools/Defaults.lua
index 4820276..8027349 100644
--- a/TaosGroupTools/Defaults.lua
+++ b/TaosGroupTools/Defaults.lua
@@ -24,7 +24,11 @@ TGT_DEFAULTS =
     ["SelectorPosY"]             = 0,
     -- Lane settings
     ["IsSortingActive"]          = false,
-    ["StaticUltimateID"]         = 29861,
+    ["StaticUltimateID"]         =
+    {
+        { "Default", 29861 },
+        { "Taonnor Annare", 29861 },
+    },
     ["SwimlaneUltimateGroupIds"] =
     {
         [1] = 29861,
diff --git a/TaosGroupTools/logic/MapPingHandler.lua b/TaosGroupTools/logic/MapPingHandler.lua
index dc4475b..2897d6c 100644
--- a/TaosGroupTools/logic/MapPingHandler.lua
+++ b/TaosGroupTools/logic/MapPingHandler.lua
@@ -80,12 +80,12 @@ function TGT_MapPingHandler.OnTimedUpdate(eventCode)

 	if (IsUnitGrouped("player") == false and TGT_MapPingHandler.IsMocked == false) then return end -- only if player is in group and system is not mocked

-    local abilityGroup = TGT_UltimateGroupHandler.GetUltimateGroupByAbilityId(TGT_SettingsHandler.SavedVariables.StaticUltimateID)
+    local abilityGroup = TGT_UltimateGroupHandler.GetUltimateGroupByAbilityId(TGT_SettingsHandler.GetStaticUltimateIDSettings())

     if (abilityGroup ~= nil) then
 	    TGT_Communicator.SendData(abilityGroup)
     else
-        _logger:logError("TGT_MapPingHandler.OnTimedUpdate, abilityGroup is nil, change ultimate. StaticID: " .. tostring(TGT_SettingsHandler.SavedVariables.StaticUltimateID))
+        _logger:logError("TGT_MapPingHandler.OnTimedUpdate, abilityGroup is nil, change ultimate. StaticID: " .. tostring(TGT_SettingsHandler.GetStaticUltimateIDSettings()))
     end
 end

diff --git a/TaosGroupTools/logic/SettingsHandler.lua b/TaosGroupTools/logic/SettingsHandler.lua
index 742e50d..04b9261 100644
--- a/TaosGroupTools/logic/SettingsHandler.lua
+++ b/TaosGroupTools/logic/SettingsHandler.lua
@@ -19,7 +19,7 @@ TGT_SWIMLANE_ULTIMATE_GROUP_ID_CHANGED = "TGT-SwimlaneUltimateGroupIdChanged"
 local LOG_ACTIVE = false
 local _logger = nil

-local SETTINGS_VERSION = 5
+local SETTINGS_VERSION = 6

 --[[
 	Table TGT_SettingsHandler
@@ -63,12 +63,31 @@ function TGT_SettingsHandler.SetStaticUltimateIDSettings(staticUltimateID)
         _logger:logDebug("staticUltimateID", staticUltimateID)
     end

-    TGT_SettingsHandler.SavedVariables.StaticUltimateID = staticUltimateID
+    TGT_SettingsHandler.SavedVariables.StaticUltimateID[GetUnitName("player")] = staticUltimateID

     CALLBACK_MANAGER:FireCallbacks(TGT_STATIC_ULTIMATE_ID_CHANGED, staticUltimateID)
 end

 --[[
+	Gets StaticUltimateID
+]]--
+function TGT_SettingsHandler.GetStaticUltimateIDSettings()
+    if (LOG_ACTIVE) then
+        _logger:logTrace("TGT_SettingsHandler.GetStaticUltimateIDSettings")
+    end
+
+    -- Find player ID
+    for playerName, ultimateId in ipairs(TGT_SettingsHandler.SavedVariables.StaticUltimateID) do
+        if (playerName == GetUnitName("player")) then
+            return ultimateId
+        end
+    end
+
+    -- If not found, return default
+    return TGT_SettingsHandler.SavedVariables.StaticUltimateID["Default"]
+end
+
+--[[
 	Sets StaticUltimateIDSettings and fires TGT_SWIMLANE_ULTIMATE_GROUP_ID_CHANGED callbacks
 ]]--
 function TGT_SettingsHandler.SetSwimlaneUltimateGroupIdSettings(swimlane, ultimateGroup)
diff --git a/TaosGroupTools/ui/groupultimate/GroupUltimateSelector.lua b/TaosGroupTools/ui/groupultimate/GroupUltimateSelector.lua
index 6ca3f9b..d7b7c15 100644
--- a/TaosGroupTools/ui/groupultimate/GroupUltimateSelector.lua
+++ b/TaosGroupTools/ui/groupultimate/GroupUltimateSelector.lua
@@ -161,7 +161,7 @@ function TGT_GroupUltimateSelector.SetControlActive()
     else
         TGT_GroupUltimateSelector.SetControlMovable(TGT_SettingsHandler.SavedVariables.Movable)
         TGT_GroupUltimateSelector.RestorePosition(TGT_SettingsHandler.SavedVariables.SelectorPosX, TGT_SettingsHandler.SavedVariables.SelectorPosY)
-        TGT_GroupUltimateSelector.SetUltimateIcon(TGT_SettingsHandler.SavedVariables.StaticUltimateID)
+        TGT_GroupUltimateSelector.SetUltimateIcon(TGT_SettingsHandler.GetStaticUltimateIDSettings())

         CALLBACK_MANAGER:RegisterCallback(TGT_MOVABLE_CHANGED, TGT_GroupUltimateSelector.SetControlMovable)
         CALLBACK_MANAGER:RegisterCallback(TGT_STATIC_ULTIMATE_ID_CHANGED, TGT_GroupUltimateSelector.SetUltimateIcon)