Added swimlane visibility

torsten.philipp [03-31-18 - 19:56]
Added swimlane visibility
Filename
TaosGroupTools/Defaults.lua
TaosGroupTools/i18n/de.lua
TaosGroupTools/i18n/en.lua
TaosGroupTools/i18n/fr.lua
TaosGroupTools/logic/SettingsHandler.lua
TaosGroupTools/ui/SettingsWindow.lua
TaosGroupTools/ui/groupultimate/CompactSwimlaneList.lua
TaosGroupTools/ui/groupultimate/SwimlaneList.lua
diff --git a/TaosGroupTools/Defaults.lua b/TaosGroupTools/Defaults.lua
index 0af1a47..3869451 100644
--- a/TaosGroupTools/Defaults.lua
+++ b/TaosGroupTools/Defaults.lua
@@ -24,6 +24,7 @@ TGT_DEFAULTS =
     ["SelectorPosY"]             = 0,
     -- Lane settings
     ["IsSortingActive"]          = false,
+    ["Swimlanes"]                = 6,
     ["StaticUltimateID"]         =
     {
         ["Default"] = 29861,
diff --git a/TaosGroupTools/i18n/de.lua b/TaosGroupTools/i18n/de.lua
index 807d35e..9b569d7 100644
--- a/TaosGroupTools/i18n/de.lua
+++ b/TaosGroupTools/i18n/de.lua
@@ -17,6 +17,8 @@ local strings = {
     TGT_OPTIONS_STYLE_SIMPLE =           "Simple-Liste",
     TGT_OPTIONS_STYLE_SWIM =             "Schwimmbahn-Liste",
     TGT_OPTIONS_STYLE_SHORT_SWIM =       "Kompakte Schwimmbahn-Liste",
+    TGT_OPTIONS_SWIMLANES_LABEL =        "Sichtbare Schwimmbahnen auswählen",
+    TGT_OPTIONS_SWIMLANES_TOOLTIP =      "Wähle den gewünschten Wert für sichtbare Schwimmbahnen aus. 1-6 Schwimmbahnen möglich.",
     TGT_DESCRIPTIONS_NEGATE =            "Magienegation Ultimates der Zauberer Klasse",
     TGT_DESCRIPTIONS_ATRO =              "Atronach Ultimates der Zauberer Klasse",
     TGT_DESCRIPTIONS_OVER =              "Überladung Ultimates der Zauberer Klasse",
diff --git a/TaosGroupTools/i18n/en.lua b/TaosGroupTools/i18n/en.lua
index ec257e3..1095d6a 100644
--- a/TaosGroupTools/i18n/en.lua
+++ b/TaosGroupTools/i18n/en.lua
@@ -17,6 +17,8 @@ local strings = {
     TGT_OPTIONS_STYLE_SIMPLE =           "Simple-List",
     TGT_OPTIONS_STYLE_SWIM =             "Swimlane-List",
     TGT_OPTIONS_STYLE_SHORT_SWIM =       "Compact Swimlane-List",
+    TGT_OPTIONS_SWIMLANES_LABEL =        "Choose visible swimlanes",
+    TGT_OPTIONS_SWIMLANES_TOOLTIP =      "Choose your value for visible swimlanes. 1-6 swimlanes are possible.",
     TGT_DESCRIPTIONS_NEGATE =            "Negate ultimates from Sorcerer class",
     TGT_DESCRIPTIONS_ATRO =              "Atronach ultimates from Sorcerer class",
     TGT_DESCRIPTIONS_OVER =              "Overload ultimates from Sorcerer class",
diff --git a/TaosGroupTools/i18n/fr.lua b/TaosGroupTools/i18n/fr.lua
index 92b1099..573bbdf 100644
--- a/TaosGroupTools/i18n/fr.lua
+++ b/TaosGroupTools/i18n/fr.lua
@@ -17,6 +17,8 @@ local strings = {
     TGT_OPTIONS_STYLE_SIMPLE =           "Simple-List",
     TGT_OPTIONS_STYLE_SWIM =             "Swimlane-List",
     TGT_OPTIONS_STYLE_SHORT_SWIM =       "Compact Swimlane-List",
+    TGT_OPTIONS_SWIMLANES_LABEL =        "Choose visible swimlanes",
+    TGT_OPTIONS_SWIMLANES_TOOLTIP =      "Choose your value for visible swimlanes. 1-6 swimlanes are possible.",
     TGT_DESCRIPTIONS_NEGATE =            "Negate ultimates from Sorcerer class",
     TGT_DESCRIPTIONS_ATRO =              "Atronach ultimates from Sorcerer class",
     TGT_DESCRIPTIONS_OVER =              "Overload ultimates from Sorcerer class",
diff --git a/TaosGroupTools/logic/SettingsHandler.lua b/TaosGroupTools/logic/SettingsHandler.lua
index da6d8a6..3a66dee 100644
--- a/TaosGroupTools/logic/SettingsHandler.lua
+++ b/TaosGroupTools/logic/SettingsHandler.lua
@@ -12,6 +12,7 @@ TGT_MOVABLE_CHANGED = "TGT-MovableChanged"
 TGT_IS_ZONE_CHANGED = "TGT-IsZoneChanged"
 TGT_STATIC_ULTIMATE_ID_CHANGED = "TGT-StaticUltimateIDChanged"
 TGT_SWIMLANE_ULTIMATE_GROUP_ID_CHANGED = "TGT-SwimlaneUltimateGroupIdChanged"
+TGT_SWIMLANES_CHANGED = "TGT-SwimlanesChanged"

 --[[
 	Local variables
@@ -102,6 +103,20 @@ function TGT_SettingsHandler.SetSwimlaneUltimateGroupIdSettings(swimlane, ultima
 end

 --[[
+	Sets StaticUltimateIDSettings and fires TGT_SWIMLANE_ULTIMATE_GROUP_ID_CHANGED callbacks
+]]--
+function TGT_SettingsHandler.SetSwimlanesSettings(swimlanes)
+    if (LOG_ACTIVE) then
+        _logger:logTrace("TGT_SettingsHandler.SetSwimlanesSettings")
+        _logger:logDebug("swimlanes", swimlanes)
+    end
+
+    TGT_SettingsHandler.SavedVariables.Swimlanes = swimlanes
+
+    CALLBACK_MANAGER:FireCallbacks(TGT_SWIMLANES_CHANGED, swimlanes)
+end
+
+--[[
 	Sets MovableSettings and fires TGT-MovableChanged callbacks
 ]]--
 function TGT_SettingsHandler.SetMovableSettings(movable)
diff --git a/TaosGroupTools/ui/SettingsWindow.lua b/TaosGroupTools/ui/SettingsWindow.lua
index 0d2d736..9477145 100644
--- a/TaosGroupTools/ui/SettingsWindow.lua
+++ b/TaosGroupTools/ui/SettingsWindow.lua
@@ -35,13 +35,13 @@ function TGT_SettingsWindow.AddGroupUltimateOptions()

 	local optionsData = {
         -- Submenu Group Ultimate Options
-        {   type = "submenu",
-			name = GetString(TGT_OPTIONS_GROUP_ULTIMATE_HEADER),
+        {   type            = "submenu",
+			name            = GetString(TGT_OPTIONS_GROUP_ULTIMATE_HEADER),
             controls = {
                 -- Only AvA visible
-                {   type = "checkbox",
-			        name = GetString(TGT_OPTIONS_ONLY_AVA_LABEL),
-			        tooltip = GetString(TGT_OPTIONS_ONLY_AVA_TOOLTIP),
+                {   type        = "checkbox",
+			        name        = GetString(TGT_OPTIONS_ONLY_AVA_LABEL),
+			        tooltip     = GetString(TGT_OPTIONS_ONLY_AVA_TOOLTIP),
 			        getFunc =
                        function()
                            return TGT_SettingsHandler.SavedVariables.OnlyAva
@@ -50,12 +50,12 @@ function TGT_SettingsWindow.AddGroupUltimateOptions()
                        function(value)
                            TGT_SettingsHandler.SetOnlyAvaSettings(value)
 			           end,
-			        default = TGT_DEFAULTS.OnlyAva
+			        default     = TGT_DEFAULTS.OnlyAva
 		        },
                 -- Sorting active
-                {   type = "checkbox",
-			        name = GetString(TGT_OPTIONS_USE_SORTING_LABEL),
-			        tooltip = GetString(TGT_OPTIONS_USE_SORTING_TOOLTIP),
+                {   type        = "checkbox",
+			        name        = GetString(TGT_OPTIONS_USE_SORTING_LABEL),
+			        tooltip     = GetString(TGT_OPTIONS_USE_SORTING_TOOLTIP),
 			        getFunc =
                        function()
                            return TGT_SettingsHandler.SavedVariables.IsSortingActive
@@ -64,13 +64,13 @@ function TGT_SettingsWindow.AddGroupUltimateOptions()
                        function(value)
                            TGT_SettingsHandler.SetIsSortingActiveSettings(value)
 			           end,
-			        default = TGT_DEFAULTS.IsSortingActive
+			        default     = TGT_DEFAULTS.IsSortingActive
 		        },
                 -- Style
-                {   type = "dropdown",
-			        name = GetString(TGT_OPTIONS_STYLE_LABEL),
-			        tooltip = GetString(TGT_OPTIONS_STYLE_TOOLTIP),
-                    choices = styleChoices,
+                {   type        = "dropdown",
+			        name        = GetString(TGT_OPTIONS_STYLE_LABEL),
+			        tooltip     = GetString(TGT_OPTIONS_STYLE_TOOLTIP),
+                    choices     = styleChoices,
 			        getFunc =
                        function()
                            return styleChoices[TGT_SettingsHandler.SavedVariables.Style]
@@ -84,8 +84,25 @@ function TGT_SettingsWindow.AddGroupUltimateOptions()
                               end
                            end
 			           end,
-			        default = styleChoices[TGT_DEFAULTS.Style]
+			        default     = styleChoices[TGT_DEFAULTS.Style]
 		        },
+                -- Visible Swimlanes
+                {   type        = "slider",
+                    name        = GetString(TGT_OPTIONS_SWIMLANES_LABEL),
+                    tooltip     = GetString(TGT_OPTIONS_SWIMLANES_TOOLTIP),
+                    min         = 1,
+                    max         = 6,
+                    step        = 1,
+                    getFunc =
+                        function()
+                            return TGT_SettingsHandler.SavedVariables.Swimlanes
+                        end,
+                    setFunc =
+                        function(value)
+                            TGT_SettingsHandler.SetSwimlanesSettings(value)
+                        end,
+                    default     = TGT_DEFAULTS.Swimlanes,
+                },
             },
         },
 	}
diff --git a/TaosGroupTools/ui/groupultimate/CompactSwimlaneList.lua b/TaosGroupTools/ui/groupultimate/CompactSwimlaneList.lua
index e493591..542e1af 100644
--- a/TaosGroupTools/ui/groupultimate/CompactSwimlaneList.lua
+++ b/TaosGroupTools/ui/groupultimate/CompactSwimlaneList.lua
@@ -307,6 +307,24 @@ function TGT_CompactSwimlaneList.SetControlHidden(isHidden)
 end

 --[[
+	SetSwimlanesVisible sets swimlanes visibility on base of settings
+]]--
+function TGT_CompactSwimlaneList.SetSwimlanesVisible(visibleSwimlanes)
+    if (LOG_ACTIVE) then
+        _logger:logTrace("TGT_CompactSwimlaneList.SetSwimlanesVisible")
+        _logger:logDebug("visibleSwimlanes", visibleSwimlanes)
+    end
+
+    for i=1, SWIMLANES, 1 do
+        if (i > visibleSwimlanes) then
+            TGT_CompactSwimlaneList.Swimlanes[i].SwimlaneControl:SetHidden(true)
+        else
+            TGT_CompactSwimlaneList.Swimlanes[i].SwimlaneControl:SetHidden(false)
+        end
+    end
+end
+
+--[[
 	SetControlActive sets hidden on control
 ]]--
 function TGT_CompactSwimlaneList.SetControlActive()
@@ -328,12 +346,11 @@ function TGT_CompactSwimlaneList.SetControlActive()
         CALLBACK_MANAGER:UnregisterCallback(TGT_MOVABLE_CHANGED, TGT_CompactSwimlaneList.SetControlMovable)
         CALLBACK_MANAGER:UnregisterCallback(TGT_SWIMLANE_ULTIMATE_GROUP_ID_CHANGED, TGT_CompactSwimlaneList.SetSwimlaneUltimate)
         CALLBACK_MANAGER:UnregisterCallback(TAO_HUD_HIDDEN_STATE_CHANGED, TGT_CompactSwimlaneList.SetControlHidden)
-
-        -- Invis
-        TGT_CompactSwimlaneList.SetControlHidden(isHidden)
+        CALLBACK_MANAGER:UnregisterCallback(TGT_SWIMLANES_CHANGED, TGT_CompactSwimlaneList.SetSwimlanesVisible)
     else
         TGT_CompactSwimlaneList.SetControlMovable(TGT_SettingsHandler.SavedVariables.Movable)
         TGT_CompactSwimlaneList.RestorePosition(TGT_SettingsHandler.SavedVariables.PosX, TGT_SettingsHandler.SavedVariables.PosY)
+        TGT_CompactSwimlaneList.SetSwimlanesVisible(TGT_SettingsHandler.SavedVariables.Swimlanes)

         -- Start timeout timer
 	    EVENT_MANAGER:RegisterForUpdate(TGT_CompactSwimlaneList.Name, REFRESHRATE, TGT_CompactSwimlaneList.RefreshList)
@@ -343,6 +360,7 @@ function TGT_CompactSwimlaneList.SetControlActive()
         CALLBACK_MANAGER:RegisterCallback(TGT_MOVABLE_CHANGED, TGT_CompactSwimlaneList.SetControlMovable)
         CALLBACK_MANAGER:RegisterCallback(TGT_SWIMLANE_ULTIMATE_GROUP_ID_CHANGED, TGT_CompactSwimlaneList.SetSwimlaneUltimate)
         CALLBACK_MANAGER:RegisterCallback(TAO_HUD_HIDDEN_STATE_CHANGED, TGT_CompactSwimlaneList.SetControlHidden)
+        CALLBACK_MANAGER:RegisterCallback(TGT_SWIMLANES_CHANGED, TGT_CompactSwimlaneList.SetSwimlanesVisible)
     end
 end

diff --git a/TaosGroupTools/ui/groupultimate/SwimlaneList.lua b/TaosGroupTools/ui/groupultimate/SwimlaneList.lua
index 046d6ef..c7db2cc 100644
--- a/TaosGroupTools/ui/groupultimate/SwimlaneList.lua
+++ b/TaosGroupTools/ui/groupultimate/SwimlaneList.lua
@@ -306,6 +306,24 @@ function TGT_SwimlaneList.SetControlHidden(isHidden)
 end

 --[[
+	SetSwimlanesVisible sets swimlanes visibility on base of settings
+]]--
+function TGT_SwimlaneList.SetSwimlanesVisible(visibleSwimlanes)
+    if (LOG_ACTIVE) then
+        _logger:logTrace("TGT_SwimlaneList.SetSwimlanesVisible")
+        _logger:logDebug("visibleSwimlanes", visibleSwimlanes)
+    end
+
+    for i=1, SWIMLANES, 1 do
+        if (i > visibleSwimlanes) then
+            TGT_SwimlaneList.Swimlanes[i].SwimlaneControl:SetHidden(true)
+        else
+            TGT_SwimlaneList.Swimlanes[i].SwimlaneControl:SetHidden(false)
+        end
+    end
+end
+
+--[[
 	SetControlActive sets hidden on control
 ]]--
 function TGT_SwimlaneList.SetControlActive()
@@ -327,9 +345,11 @@ function TGT_SwimlaneList.SetControlActive()
         CALLBACK_MANAGER:UnregisterCallback(TGT_MOVABLE_CHANGED, TGT_SwimlaneList.SetControlMovable)
         CALLBACK_MANAGER:UnregisterCallback(TGT_SWIMLANE_ULTIMATE_GROUP_ID_CHANGED, TGT_SwimlaneList.SetSwimlaneUltimate)
         CALLBACK_MANAGER:UnregisterCallback(TAO_HUD_HIDDEN_STATE_CHANGED, TGT_SwimlaneList.SetControlHidden)
+        CALLBACK_MANAGER:UnregisterCallback(TGT_SWIMLANES_CHANGED, TGT_SwimlaneList.SetSwimlanesVisible)
     else
         TGT_SwimlaneList.SetControlMovable(TGT_SettingsHandler.SavedVariables.Movable)
         TGT_SwimlaneList.RestorePosition(TGT_SettingsHandler.SavedVariables.PosX, TGT_SettingsHandler.SavedVariables.PosY)
+        TGT_SwimlaneList.SetSwimlanesVisible(TGT_SettingsHandler.SavedVariables.Swimlanes)

         -- Start timeout timer
 	    EVENT_MANAGER:RegisterForUpdate(TGT_SwimlaneList.Name, REFRESHRATE, TGT_SwimlaneList.RefreshList)
@@ -339,6 +359,7 @@ function TGT_SwimlaneList.SetControlActive()
         CALLBACK_MANAGER:RegisterCallback(TGT_MOVABLE_CHANGED, TGT_SwimlaneList.SetControlMovable)
         CALLBACK_MANAGER:RegisterCallback(TGT_SWIMLANE_ULTIMATE_GROUP_ID_CHANGED, TGT_SwimlaneList.SetSwimlaneUltimate)
         CALLBACK_MANAGER:RegisterCallback(TAO_HUD_HIDDEN_STATE_CHANGED, TGT_SwimlaneList.SetControlHidden)
+        CALLBACK_MANAGER:RegisterCallback(TGT_SWIMLANES_CHANGED, TGT_SwimlaneList.SetSwimlanesVisible)
     end
 end