Go to most recent revision | Compare with Previous | Blame | View Log
--[[ Addon: Taos Group Ultimate Author: TProg Taonnor Created by @Taonnor ]]-- --[[ Local variables ]]-- local LOG_ACTIVE = false local _logger = nil --[[ Table TGU_SimpleList ]]-- TGU_SimpleList = {} TGU_SimpleList.__index = TGU_SimpleList --[[ Table Members ]]-- --[[ Sets visibility of labels ]]-- function TGU_SimpleList.RefreshList() if (LOG_ACTIVE) then _logger:logTrace("TGU_SimpleList.RefreshList") end for i=1, GROUP_SIZE_MAX, 1 do local row = TGU_SimpleListControlContainerScrollChild:GetNamedChild("Row" .. i) if (row ~= nil) then local groupId = "group" .. i local unitExists = DoesUnitExist(groupId) if (unitExists == false) then row:SetHidden(true) else row:GetNamedChild("SenderNameValueLabel"):SetText(GetUnitName(groupId)) row:GetNamedChild("UltimateValueLabel"):SetText("-") row:GetNamedChild("ReadyValueLabel"):SetText("0") row:SetHidden(false) end else _logger:logError("TGU_SimpleList.RefreshList, row nil " .. i) end end end --[[ Updates list row ]]-- function TGU_SimpleList.UpdateListRow(player) if (LOG_ACTIVE) then _logger:logTrace("TGU_SimpleList.UpdateListRow") end if (player) then local row = TGU_SimpleListControlContainerScrollChild:GetNamedChild("Row" .. player.GroupNumber) if (row ~= nil) then row:SetHidden(false) local localizedUltimateName = zo_strformat(SI_ABILITY_TOOLTIP_NAME, player.UltimateName) local nameLength = string.len(localizedUltimateName) if (nameLength > 22) then localizedUltimateName = string.sub(localizedUltimateName, 0, 22) .. "..." end row:GetNamedChild("SenderNameValueLabel"):SetText(player.PlayerName) row:GetNamedChild("UltimateValueLabel"):SetText(localizedUltimateName) row:GetNamedChild("ReadyValueLabel"):SetText(player.RelativeUltimate) if (player.IsPlayerDead) then row:GetNamedChild("SenderNameValueLabel"):SetColor(1.0, 0.0, 0.0, 1) row:GetNamedChild("UltimateValueLabel"):SetColor(1.0, 0.0, 0.0, 1) row:GetNamedChild("ReadyValueLabel"):SetColor(1.0, 0.0, 0.0, 1) elseif (player.RelativeUltimate == 100) then row:GetNamedChild("SenderNameValueLabel"):SetColor(0.0, 1.0, 0.0, 1) row:GetNamedChild("UltimateValueLabel"):SetColor(0.0, 1.0, 0.0, 1) row:GetNamedChild("ReadyValueLabel"):SetColor(0.0, 1.0, 0.0, 1) else row:GetNamedChild("SenderNameValueLabel"):SetColor(1.0, 1.0, 1.0, 1) row:GetNamedChild("UltimateValueLabel"):SetColor(1.0, 1.0, 1.0, 1) row:GetNamedChild("ReadyValueLabel"):SetColor(1.0, 1.0, 1.0, 1) end else _logger:logError("TGU_SimpleList.UpdateListRow, row nil " .. tostring(player.GroupNumber)) end end end --[[ SetControlMovable sets the Movable and MouseEnabled flag in UI elements ]]-- function TGU_SimpleList.SetControlMovable(isMovable) if (LOG_ACTIVE) then _logger:logTrace("TGU_SimpleList.SetControlMovable") _logger:logDebug("isMovable", isMovable) end TGU_SimpleListControl:GetNamedChild("MovableControl"):SetHidden(isMovable == false) TGU_SimpleListControl:SetMovable(isMovable) TGU_SimpleListControl:SetMouseEnabled(isMovable) end --[[ RestorePosition sets TGU_SimpleList on settings position ]]-- function TGU_SimpleList.RestorePosition(posX, posY) if (LOG_ACTIVE) then _logger:logTrace("TGU_SimpleList.RestorePosition") _logger:logDebug("posX, posY", posX, posY) end TGU_SimpleListControl:ClearAnchors() TGU_SimpleListControl:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, posX, posY) end --[[ OnSimpleListMoveStop saves current TGU_SimpleList position to settings ]]-- function TGU_SimpleList.OnSimpleListMoveStop() if (LOG_ACTIVE) then _logger:logTrace("TGU_SimpleList.OnSimpleListMoveStop") end local left = TGU_SimpleListControl:GetLeft() local top = TGU_SimpleListControl:GetTop() TGU_SettingsHandler.SavedVariables.PosX = left TGU_SettingsHandler.SavedVariables.PosY = top if (LOG_ACTIVE) then _logger:logDebug("PosX, PosY", TGU_SettingsHandler.SavedVariables.PosX, TGU_SettingsHandler.SavedVariables.PosY) end end --[[ SetControlHidden sets hidden on control ]]-- function TGU_SimpleList.SetControlHidden() if (LOG_ACTIVE) then _logger:logTrace("TGU_SimpleList.SetControlHidden") end local isHidden = TGU_SettingsHandler.IsSimpleListVisible() == false if (LOG_ACTIVE) then _logger:logDebug("isHidden", isHidden) end if (isHidden) then CALLBACK_MANAGER:UnregisterCallback(TGU_GROUP_CHANGED, TGU_SimpleList.RefreshList) CALLBACK_MANAGER:UnregisterCallback(TGU_PLAYER_DATA_CHANGED, TGU_SimpleList.UpdateListRow) CALLBACK_MANAGER:UnregisterCallback(TGU_MOVABLE_CHANGED, TGU_SimpleList.SetControlMovable) else TGU_SimpleList.SetControlMovable(TGU_SettingsHandler.SavedVariables.Movable) TGU_SimpleList.RestorePosition(TGU_SettingsHandler.SavedVariables.PosX, TGU_SettingsHandler.SavedVariables.PosY) CALLBACK_MANAGER:RegisterCallback(TGU_GROUP_CHANGED, TGU_SimpleList.RefreshList) CALLBACK_MANAGER:RegisterCallback(TGU_PLAYER_DATA_CHANGED, TGU_SimpleList.UpdateListRow) CALLBACK_MANAGER:RegisterCallback(TGU_MOVABLE_CHANGED, TGU_SimpleList.SetControlMovable) end TGU_SimpleListControl:SetHidden(isHidden) end --[[ CreateSimpleListRows creates simple list rows ]]-- function TGU_SimpleList.CreateSimpleListRows() if (LOG_ACTIVE) then _logger:logTrace("TGU_SimpleList.CreateSimpleListRows") end for i=1, GROUP_SIZE_MAX, 1 do local row = CreateControlFromVirtual("$(parent)Row", TGU_SimpleListControlContainerScrollChild, "GroupUltimateSimpleListRow", i) if (LOG_ACTIVE) then _logger:logDebug("Row created " .. row:GetName()) end row:SetHidden(true) -- initial not visible if i == 1 then row:SetAnchor(TOPLEFT, TGU_SimpleListControlContainerScrollChild, TOPLEFT, 0, 0) else row:SetAnchor(TOP, lastRow, BOTTOM, 0, 0) end lastRow = row end end --[[ Initialize initializes TGU_SimpleList ]]-- function TGU_SimpleList.Initialize(logger) if (LOG_ACTIVE) then logger:logTrace("TGU_SimpleList.Initialize") end _logger = logger TGU_SimpleList.CreateSimpleListRows() -- TGU_SimpleList.SetControlHidden() -- Will be called via TGU-IsZoneChanged CALLBACK_MANAGER:RegisterCallback(TGU_STYLE_CHANGED, TGU_SimpleList.SetControlHidden) CALLBACK_MANAGER:RegisterCallback(TGU_IS_ZONE_CHANGED, TGU_SimpleList.SetControlHidden) end