Go to most recent revision | Compare with Previous | Blame | View Log
--[[ Addon: Taos Group Ultimate Author: TProg Taonnor Created by @Taonnor ]]-- --[[ Global variables ]]-- local LOG_ACTIVE = false --[[ Class SimpleList ]]-- SimpleList = {} SimpleList.__index = SimpleList --[[ Class Members ]]-- --[[ Sets visibility of labels ]]-- function SimpleList.RefreshList() if (LOG_ACTIVE) then logTrace("SimpleList.RefreshList") end for i=1, GROUP_SIZE_MAX, 1 do local row = 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 if (LOG_ACTIVE) then logError("SimpleList.RefreshList, row nil " .. i) end end end end --[[ Updates list row ]]-- function SimpleList.UpdateListRow(player) if (LOG_ACTIVE) then logTrace("SimpleList.UpdateListRow") logDebug("player.PingTag: " .. tostring(player.PingTag), "player.GroupNumber: " .. tostring(player.GroupNumber), "player.PlayerName: " .. tostring(player.PlayerName), "player.IsPlayerDead: " .. tostring(player.IsPlayerDead), "player.AbilityID: " .. tostring(player.AbilityID), "player.UltimateName: " .. tostring(player.UltimateName), "player.UltimateIcon: " .. tostring(player.UltimateIcon), "player.RelativeUltimate: " .. tostring(player.RelativeUltimate)) end if (player) then local row = SimpleListControlContainerScrollChild:GetNamedChild("Row" .. player.GroupNumber) if (row ~= nil) then row:SetHidden(false) local localizedUltimateName = zo_strformat(SI_ABILITY_TOOLTIP_NAME, player.UltimateName) 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 if (LOG_ACTIVE) then logError("SimpleList.UpdateListRow, row nil " .. tostring(player.GroupNumber)) end end end end --[[ SetControlMovable sets the Movable and MouseEnabled flag in UI elements ]]-- function SimpleList.SetControlMovable(isMovable) if (LOG_ACTIVE) then logTrace("SimpleList.SetControlMovable") logDebug("isMovable: " .. tostring(isMovable)) end SimpleListControl:SetMovable(isMovable) SimpleListControl:SetMouseEnabled(isMovable) end --[[ RestorePosition sets SimpleList on settings position ]]-- function SimpleList.RestorePosition(posX, posY) if (LOG_ACTIVE) then logTrace("SimpleList.RestorePosition") logDebug("posX: " .. tostring(posX), "posY: " .. tostring(posY)) end SimpleListControl:ClearAnchors() SimpleListControl:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, posX, posY) end --[[ OnSimpleListMoveStop saves current SimpleList position to settings ]]-- function SimpleList.OnSimpleListMoveStop() if (LOG_ACTIVE) then logTrace("SimpleList.OnSimpleListMoveStop") end local left = SimpleListControl:GetLeft() local top = SimpleListControl:GetTop() SettingsHandler.SavedVariables.PosX = left SettingsHandler.SavedVariables.PosY = top if (LOG_ACTIVE) then logDebug("PosX set: " .. tostring(SettingsHandler.SavedVariables.PosX), "PosY set: " .. tostring(SettingsHandler.SavedVariables.PosY)) end end --[[ SetControlHidden sets hidden on control ]]-- function SimpleList.SetControlHidden(isHidden) if (LOG_ACTIVE) then logTrace("SimpleList.SetControlHidden") logDebug("isHidden: " .. tostring(isHidden)) end SimpleListControl:SetHidden(isHidden) end --[[ CreateSimpleListRows creates simple list rows ]]-- function SimpleList.CreateSimpleListRows() if (LOG_ACTIVE) then logTrace("SimpleList.CreateSimpleListRows") end for i=1, GROUP_SIZE_MAX, 1 do local row = CreateControlFromVirtual("$(parent)Row", SimpleListControlContainerScrollChild, "GroupUltimateSimpleListRow", i) if (LOG_ACTIVE) then logDebug("Row created " .. row:GetName()) end row:SetHidden(true) -- initial not visible if i == 1 then row:SetAnchor(TOPLEFT, SimpleListControlContainerScrollChild, TOPLEFT, 0, 0) else row:SetAnchor(TOP, lastRow, BOTTOM, 0, 0) end lastRow = row end end --[[ Initialize initializes SimpleList ]]-- function SimpleList.Initialize(isHidden, isMovable, posX, posY) if (LOG_ACTIVE) then logTrace("SimpleList.Initialize") logDebug("isHidden: " .. tostring(isHidden), "isMovable: " .. tostring(isMovable), "posX: " .. tostring(posX), "posY: " .. tostring(posY)) end SimpleList.SetControlHidden(isHidden) SimpleList.SetControlMovable(isMovable) SimpleList.RestorePosition(posX, posY) SimpleList.CreateSimpleListRows() CALLBACK_MANAGER:RegisterCallback("TGU-GroupChanged", SimpleList.RefreshList) CALLBACK_MANAGER:RegisterCallback("TGU-MapPingChanged", SimpleList.UpdateListRow) end