Alignment to game version 8.3.5

Dekakaruk [04-05-23 - 12:03]
Alignment to game version 8.3.5

Zuqoth armoury assistant avaliable for keybind
Titles are properly saved and loaded, even when you acquire new ones
Fixed errors when opening armoury
Filename
ArmoryStyleManager.lua
ArmoryStyleManager.txt
bindings.xml
diff --git a/ArmoryStyleManager.lua b/ArmoryStyleManager.lua
index 856822a..ba53d30 100644
--- a/ArmoryStyleManager.lua
+++ b/ArmoryStyleManager.lua
@@ -2,19 +2,13 @@
 -- Load in global variables --
 -------------------------------------------------------------------------------------------------
 ArmoryStyleManager = {
-	name = "Armory Style Manager",
-	author = '@CyberOnEso',
-	version = '0.8',
-	requiredAPIVersion = 100034,
-	variableVersion = 1
-}
-
-ArmoryStyleManager.color = {
-	defaultText = GetInterfaceColor(INTERFACE_COLOR_TYPE_TEXT_COLORS, INTERFACE_TEXT_COLOR_NORMAL)
+	variableVersion = 1,
+	color = {
+		defaultText = GetInterfaceColor(INTERFACE_COLOR_TYPE_TEXT_COLORS, INTERFACE_TEXT_COLOR_NORMAL)
+	}
 }

 local name = "ArmoryStyleManager"
-local EM = EVENT_MANAGER

 local COLLECTIBLE_TYPES = {
 	COLLECTIBLE_CATEGORY_TYPE_BODY_MARKING,
@@ -46,6 +40,7 @@ local ROLE_ICONS = {
 }

 local GRASHOROG_ID = 9745
+local ZUQOTH_ID = 10618

 local defaultData = {
 	builds = {
@@ -64,7 +59,7 @@ local defaultData = {
 				[12] = 0,
 				[13] = 0,
 				[14] = 0,
-				[15] = 0,
+				[15] = 0,
 				[16] = 0,
 				[17] = 0,
 				[18] = 0
@@ -85,7 +80,7 @@ local defaultData = {
 				[12] = 0,
 				[13] = 0,
 				[14] = 0,
-				[15] = 0,
+				[15] = 0,
 				[16] = 0,
 				[17] = 0,
 				[18] = 0
@@ -106,7 +101,7 @@ local defaultData = {
 				[12] = 0,
 				[13] = 0,
 				[14] = 0,
-				[15] = 0,
+				[15] = 0,
 				[16] = 0,
 				[17] = 0,
 				[18] = 0
@@ -127,7 +122,7 @@ local defaultData = {
 				[12] = 0,
 				[13] = 0,
 				[14] = 0,
-				[15] = 0,
+				[15] = 0,
 				[16] = 0,
 				[17] = 0,
 				[18] = 0
@@ -148,7 +143,7 @@ local defaultData = {
 				[12] = 0,
 				[13] = 0,
 				[14] = 0,
-				[15] = 0,
+				[15] = 0,
 				[16] = 0,
 				[17] = 0,
 				[18] = 0
@@ -169,7 +164,7 @@ local defaultData = {
 				[12] = 0,
 				[13] = 0,
 				[14] = 0,
-				[15] = 0,
+				[15] = 0,
 				[16] = 0,
 				[17] = 0,
 				[18] = 0
@@ -190,7 +185,7 @@ local defaultData = {
 				[12] = 0,
 				[13] = 0,
 				[14] = 0,
-				[15] = 0,
+				[15] = 0,
 				[16] = 0,
 				[17] = 0,
 				[18] = 0
@@ -211,7 +206,7 @@ local defaultData = {
 				[12] = 0,
 				[13] = 0,
 				[14] = 0,
-				[15] = 0,
+				[15] = 0,
 				[16] = 0,
 				[17] = 0,
 				[18] = 0
@@ -232,7 +227,7 @@ local defaultData = {
 				[12] = 0,
 				[13] = 0,
 				[14] = 0,
-				[15] = 0,
+				[15] = 0,
 				[16] = 0,
 				[17] = 0,
 				[18] = 0
@@ -253,7 +248,7 @@ local defaultData = {
 				[12] = 0,
 				[13] = 0,
 				[14] = 0,
-				[15] = 0,
+				[15] = 0,
 				[16] = 0,
 				[17] = 0,
 				[18] = 0
@@ -273,7 +268,6 @@ local CURSE_ICON = {

 local function CreateOverlay(parent, rel, relPoint, x, y, width, height, vAlign, hAlign)
 	local overlay = WINDOW_MANAGER:CreateControl(nil, parent, CT_LABEL)
-	overlay:SetResizeToFitDescendents(true)
 	overlay:SetInheritScale(false)
 	overlay:SetDrawTier(DT_HIGH)
 	overlay:SetDrawLayer(DL_OVERLAY)
@@ -286,7 +280,7 @@ end

 local function CreateButton(name, parent)
 	local button = WINDOW_MANAGER:CreateControl(name, parent, CT_BUTTON)
-
+
 	button:SetInheritScale(false)
 	button:SetDrawTier(DT_HIGH)
 	button:SetDrawLayer(DL_OVERLAY)
@@ -296,16 +290,16 @@ local function CreateButton(name, parent)
 	button:SetVerticalAlignment(TEXT_ALIGN_CENTER)
 	button:SetFont("ZoFontHeader")
 	button:SetNormalTexture("ESOUI/art/miscellaneous/gamepad/gp_icon_locked32.dds")
-
+
 	return button
 end


 local function isCurrentBuildLocked()
 	local currentBuildIndex = ARMORY_KEYBOARD.selectedBuildIndex
-	local currentBuildLocked = ArmoryStyleManager.savedVariables.builds[currentBuildIndex].locked
-
-	return currentBuildLocked
+	local currentBuildLocked = ArmoryStyleManager.savedVariables.builds[currentBuildIndex].locked
+
+	return currentBuildLocked
 end

 local function RefreshUI()
@@ -318,13 +312,13 @@ local function RefreshUI()
 	ArmoryStyleManager.CurseOutfitRow:GetNamedChild("Outfit"):SetAnchor(LEFT, ArmoryStyleManager.CurseOutfitRow:GetNamedChild("CurseType"), RIGHT, -ZO_ARMORY_KEYBOARD_MISC_ROW_LABEL_OFFSET_X/2, 0)

 	local textWidth = ArmoryStyleManager.CurseOutfitRow:GetNamedChild("Outfit"):GetTextWidth() + ArmoryStyleManager.Mundus:GetTextWidth()
-
+
 	if ArmoryStyleManager.savedVariables.currentBuildIndex == nil then
 		ARMORY_KEYBOARD.buildCountLabel:SetText(zo_strformat("Current Builds: <<1>>", GetNumUnlockedArmoryBuilds()))
 	else
 		ARMORY_KEYBOARD.buildCountLabel:SetText(zo_strformat("Current Build: <<1>>", GetArmoryBuildName(ArmoryStyleManager.savedVariables.currentBuildIndex)))
 	end
-
+
 	if not selectedBuildIndex then return false end

 	local nextButtonToUpdate = 1
@@ -362,37 +356,37 @@ local function RefreshUI()
 		polyIcon = GetCollectibleIcon(ArmoryStyleManager.savedVariables.builds[selectedBuildIndex].collectibles[COLLECTIBLE_CATEGORY_TYPE_POLYMORPH])
 		setNextButton(polyIcon)
 	end
-
+
 	-- Skin
 	if ArmoryStyleManager.savedVariables.builds[selectedBuildIndex].collectibles[COLLECTIBLE_CATEGORY_TYPE_SKIN] > 1 and not hasPoly then
 		skinIcon = GetCollectibleIcon(ArmoryStyleManager.savedVariables.builds[selectedBuildIndex].collectibles[COLLECTIBLE_CATEGORY_TYPE_SKIN])
 		setNextButton(skinIcon)
 	end
-
+
 	-- Hat
 	if ArmoryStyleManager.savedVariables.builds[selectedBuildIndex].collectibles[COLLECTIBLE_CATEGORY_TYPE_HAT] > 1 and ArmoryStyleManager.savedVariables.builds[ARMORY_KEYBOARD.selectedBuildIndex].collectibles[COLLECTIBLE_CATEGORY_TYPE_HAT] ~= 5002 and not hasPoly then
 		hatIcon = GetCollectibleIcon(ArmoryStyleManager.savedVariables.builds[selectedBuildIndex].collectibles[COLLECTIBLE_CATEGORY_TYPE_HAT])
 		setNextButton(hatIcon)
 	end
-
+
 	-- Costume
 	if ArmoryStyleManager.savedVariables.builds[selectedBuildIndex].collectibles[COLLECTIBLE_CATEGORY_TYPE_COSTUME] > 1 and not hasPoly then
 		costumeIcon = GetCollectibleIcon(ArmoryStyleManager.savedVariables.builds[selectedBuildIndex].collectibles[COLLECTIBLE_CATEGORY_TYPE_COSTUME])
 		setNextButton(costumeIcon)
 	end
-
+
 	-- Mount
 	if ArmoryStyleManager.savedVariables.builds[selectedBuildIndex].collectibles[COLLECTIBLE_CATEGORY_TYPE_MOUNT] > 1 then
 		mountIcon = GetCollectibleIcon(ArmoryStyleManager.savedVariables.builds[selectedBuildIndex].collectibles[COLLECTIBLE_CATEGORY_TYPE_MOUNT])
 		setNextButton(mountIcon)
 	end
-
+
 	-- Pet
 	if ArmoryStyleManager.savedVariables.builds[selectedBuildIndex].collectibles[COLLECTIBLE_CATEGORY_TYPE_VANITY_PET] > 1 then
 		petIcon = GetCollectibleIcon(ArmoryStyleManager.savedVariables.builds[selectedBuildIndex].collectibles[COLLECTIBLE_CATEGORY_TYPE_VANITY_PET])
 		setNextButton(petIcon)
 	end
-
+
 	-- Lock
 	if isCurrentBuildLocked() then
 		ArmoryStyleManager.lockButton:SetNormalTexture("ESOUI/art/miscellaneous/gamepad/gp_icon_locked32.dds")
@@ -401,7 +395,7 @@ local function RefreshUI()
 		ArmoryStyleManager.lockButton:SetNormalTexture("ESOUI/art/miscellaneous/gamepad/gp_icon_unlocked32.dds")
 		ArmoryStyleManager.lockButton:SetAnchor(RIGHT, ArmoryStyleManager.Collapse, RIGHT, -27, 0)
 	end
-
+
 	-- Role
 	local roleIcon = nil
 	local currentRole = ArmoryStyleManager.savedVariables.builds[selectedBuildIndex].role
@@ -417,24 +411,36 @@ local function RefreshUI()
 	end
 end

-function ArmoryStyleManager.SummonGrashorog()
-	local _, _, icon, _, unlocked, _, summoned = GetCollectibleInfo(GRASHOROG_ID)
-
+local function SummonAssistant(assistantId)
+	local _, _, icon, _, unlocked, _, summoned = GetCollectibleInfo(assistantId)
+
+	local summondedMsg = ""
+	local colour = ""
+
+	local iconLink = zo_strformat("|t20:20:<<1>>|t", icon)
+	local collectibleLink = zo_strformat("|H1:collectible:<<1>>|h|h", assistantId)
+
 	if unlocked then
-		UseCollectible(GRASHOROG_ID)
+		colour = "bfbfbf"
+		summondedMsg = "You summon"
+		if summoned then summondedMsg = "You dismiss" end
+
+		UseCollectible(assistantId)
+	else
+		colour = "bf0000"
+		summondedMsg = "You did not unlock the collectible, cannot summon"
 	end
-
-	local summondedMsg = "You summon"
-	local colour = "|cbfbfbf"
-	local iconLink = zo_strformat("|t20:20:<<1>>|t", icon)
-	local collectibleLink = zo_strformat("|H1:collectible:<<1>>|h|h", GRASHOROG_ID)
-
-	if summoned then summondedMsg = "You dismiss" end

-	local message = zo_strformat("<<1>><<2>><<3>><<4>>.", colour, summondedMsg, iconLink, collectibleLink)
+	local message = zo_strformat("|c<<1>><<2>>|r<<3>><<4>>.", colour, summondedMsg, iconLink, collectibleLink)
 	d(message)
-
-	return not summoned
+end
+
+function ArmoryStyleManager.SummonGrashorog()
+	SummonAssistant(GRASHOROG_ID)
+end
+
+function ArmoryStyleManager.SummonZuqoth()
+	SummonAssistant(ZUQOTH_ID)
 end

 -------------------------------------------------------------------------------------------------
@@ -444,28 +450,28 @@ local function InitSavedVariables()
 	ArmoryStyleManager.savedVariables = ZO_SavedVars:NewCharacterIdSettings("ArmoryStyleManagerData", ArmoryStyleManager.variableVersion, nil, defaultData)
 end

-local function ArmoryBuildUpdated(_, buildIndex)
+local function ArmoryBuildUpdated(_, buildIndex)
 	local collectibles = {}
 	for i, collectibleType in pairs(COLLECTIBLE_TYPES) do
 		collectibles[collectibleType] = GetActiveCollectibleByType(collectibleType)
 	end
 	ArmoryStyleManager.savedVariables.builds[buildIndex].collectibles = collectibles
-	ArmoryStyleManager.savedVariables.builds[buildIndex].title = GetCurrentTitleIndex()
+	ArmoryStyleManager.savedVariables.builds[buildIndex].title = GetTitle(GetCurrentTitleIndex())
 	ArmoryStyleManager.savedVariables.builds[buildIndex].role = GetSelectedLFGRole()
 	ArmoryStyleManager.savedVariables.builds[buildIndex].tabard = Id64ToString(GetItemUniqueId(BAG_WORN, EQUIP_SLOT_COSTUME))
-
+
 	RefreshUI()
 end


 local function ArmoryBuildLoaded(_, result, buildIndex)
 	if result ~= ARMORY_BUILD_RESTORE_RESULT_SUCCESS then return false end
-
+
 	ArmoryStyleManager.savedVariables.currentBuildIndex = buildIndex
-
+
 	for collectibleType, id in pairs(ArmoryStyleManager.savedVariables.builds[buildIndex].collectibles) do
 		local eqippedCollectible = GetActiveCollectibleByType(collectibleType)
-		if eqippedCollectible ~= id then
+		if eqippedCollectible ~= id then
 			if id ~= 0 then
 				if IsCollectibleUnlocked(id) and IsCollectibleUsable(id) and IsCollectibleValidForPlayer(id) then
 					UseCollectible(id)
@@ -478,13 +484,30 @@ local function ArmoryBuildLoaded(_, result, buildIndex)
 			end
 		end
 	end
-
+
 	local currentTitle = GetCurrentTitleIndex()
-	local newTitle = ArmoryStyleManager.savedVariables.builds[buildIndex].title
-	if currentTitle ~= newTitle then
+
+	local newTitleString = ArmoryStyleManager.savedVariables.builds[buildIndex].title
+	local newTitle = nil
+
+	local numTitles = GetNumTitles()
+	for titleIdx = 0, numTitles do
+		if GetTitle(titleIdx) == newTitleString then
+			newTitle = titleIdx
+			break
+		end
+	end
+
+	if newTitle == nil then
+		local errorMessage = "Invalid title saved, failed to load"
+		local colour = "cb0000"
+
+		local message = zo_strformat("<<1>>: |c<<2>><<3>>|r: <<4>>", name, colour, errorMessage, newTitleString)
+		d(message)
+	elseif currentTitle ~= newTitle then
 		SelectTitle(newTitle)
 	end
-
+
 	local newRole = ArmoryStyleManager.savedVariables.builds[buildIndex].role
 	local oldRole = GetSelectedLFGRole()
 	if newRole then
@@ -505,17 +528,17 @@ local function ArmoryBuildLoaded(_, result, buildIndex)
 	else
 		UnequipItem(EQUIP_SLOT_COSTUME)
 	end
-
+
 	RefreshUI()
 end

 local function RegisterEvents()
-	EM:RegisterForEvent(name, EVENT_ARMORY_BUILD_UPDATED , ArmoryBuildUpdated)
-	EM:RegisterForEvent(name, EVENT_ARMORY_BUILD_RESTORE_RESPONSE, ArmoryBuildLoaded)
+	EVENT_MANAGER:RegisterForEvent(name, EVENT_ARMORY_BUILD_UPDATED , ArmoryBuildUpdated)
+	EVENT_MANAGER:RegisterForEvent(name, EVENT_ARMORY_BUILD_RESTORE_RESPONSE, ArmoryBuildLoaded)
 end

 local function CreateUI(control)
-	local UIContainer = control:GetNamedChild("Container")
+	local UIContainer = control:GetNamedChild("Container")
 	local CurseOutfitRow = control:GetNamedChild("ContainerCurseOutfitRow")
 	local Header =  UIContainer:GetNamedChild("Header")
 	local Collapse =  Header:GetNamedChild("Collapse")
@@ -543,18 +566,18 @@ local function CreateUI(control)
 	end

 	ArmoryStyleManager.UIButtons = UIButtons
-
+
 	ArmoryStyleManager.lockButton = CreateButton("ArmoryStyleManager-lock", Header)
 	ArmoryStyleManager.lockButton:SetDimensions(32, 32)
 	ArmoryStyleManager.lockButton:SetAnchor(RIGHT, Collapse, RIGHT, -30, 0)
-
+
 	ArmoryStyleManager.lockButton:SetHandler("OnMouseUp",function(self)
 		local currentBuild = ArmoryStyleManager.savedVariables.builds[ARMORY_KEYBOARD.selectedBuildIndex]
 		ArmoryStyleManager.savedVariables.builds[ARMORY_KEYBOARD.selectedBuildIndex].locked = not currentBuild.locked
 		KEYBIND_STRIP:UpdateKeybindButtonGroup(ARMORY_KEYBOARD.keybindStripDescriptor)
 		RefreshUI()
 	end)
-
+
 	ArmoryStyleManager.roleButton = CreateButton("ArmoryStyleManager-role", CurseOutfitRow)
 	ArmoryStyleManager.roleButton:SetDimensions(45, 45)
 	ArmoryStyleManager.roleButton:SetAnchor(LEFT, Collapse, LEFT, -75, 0)
@@ -564,9 +587,9 @@ local function CreateUI(control)
 		ArmoryStyleManager.savedVariables.builds[ARMORY_KEYBOARD.selectedBuildIndex].roleActive = not currentBuild.roleActive
 		RefreshUI()
 	end)
-
+
 	RefreshUI()
-	return false
+	return false
 end

 -------------------------------------------------------------------------------------------------
@@ -575,13 +598,17 @@ end
 local function Initialize()
 	InitSavedVariables()
 	RegisterEvents()
-
+
 	local AmoryAssistantName = GetCollectibleInfo(GRASHOROG_ID)
 	ZO_CreateStringId("SI_BINDING_NAME_ARMORY_STYLE_MANAGER_SUMMON_GRASHOROG", zo_strformat("Summon <<1>>", AmoryAssistantName))
+
+	local AmoryAssistantName = GetCollectibleInfo(ZUQOTH_ID)
+	ZO_CreateStringId("SI_BINDING_NAME_ARMORY_STYLE_MANAGER_SUMMON_ZUQOTH", zo_strformat("Summon <<1>>", AmoryAssistantName))
+
 	ZO_PreHook("ZO_Armory_ExpandedEntry_OnInitialized", CreateUI)
 	ZO_PostHook("ZO_Armory_Keyboard_CollapsedEntry_OnMouseUp", RefreshUI)
 	ZO_PostHook(ARMORY_KEYBOARD, "RefreshBuilds", RefreshUI)
-
+
 	ARMORY_KEYBOARD.keybindStripDescriptor[2].enabled = function()
 				if isCurrentBuildLocked() then return false end
                 local function disabledAlertText()
@@ -589,7 +616,7 @@ local function Initialize()
                 end
                 return not ZO_ARMORY_MANAGER:IsBuildOperationInProgress(), disabledAlertText
             end
-
+
 	EVENT_MANAGER:UnregisterForEvent(name, EVENT_ADD_ON_LOADED)
 end

@@ -598,4 +625,4 @@ local function AddonLoaded(e, addonName)
 	Initialize()
 end

-EM:RegisterForEvent(name, EVENT_ADD_ON_LOADED, AddonLoaded)
\ No newline at end of file
+EVENT_MANAGER:RegisterForEvent(name, EVENT_ADD_ON_LOADED, AddonLoaded)
\ No newline at end of file
diff --git a/ArmoryStyleManager.txt b/ArmoryStyleManager.txt
index 69623b4..25428c9 100644
--- a/ArmoryStyleManager.txt
+++ b/ArmoryStyleManager.txt
@@ -1,8 +1,8 @@
-## APIVersion: 101034
+## APIVersion: 101037
 ## Title: |c9CD04CArmory Style Manager|r
-## Version: 0.8
-## AddOnVersion: 8
-## Author: |c5959D5@CyberOnEso|r,
+## Version: 0.9
+## AddOnVersion: 9
+## Author: |c5959D5@CyberOnEso|r, |c5959D5@Dekakaruk|r,
 ## Description: |c9CD04CSaves and loads your colletibles with your armory builds
 ## SavedVariables: ArmoryStyleManagerData
 ##
diff --git a/bindings.xml b/bindings.xml
index d37f8b3..b0a923f 100644
--- a/bindings.xml
+++ b/bindings.xml
@@ -4,6 +4,9 @@
             <Action name="ARMORY_STYLE_MANAGER_SUMMON_GRASHOROG">
                 <Down>ArmoryStyleManager.SummonGrashorog()</Down>
             </Action>
+            <Action name="ARMORY_STYLE_MANAGER_SUMMON_ZUQOTH">
+                <Down>ArmoryStyleManager.SummonZuqoth()</Down>
+            </Action>
         </Category>
     </Layer>
 </Bindings>
\ No newline at end of file