Go to most recent revision | Compare with Previous | Blame | View Log
--[[ Addon: Taos Group Ultimate Author: TProg Taonnor Created by @Taonnor ]]-- --[[ Global variables ]]-- local DEBUG_ACTIVE = true --[[ Class SimpleList ]]-- SimpleList = {} --[[ Class Members ]]-- --[[ Sets visibility of labels ]]-- function SimpleList.RefreshList() logDebug("SimpleList.RefreshList()") for i=1, GROUP_SIZE_MAX, 1 do local row = SimpleListControlContainerScrollChild:GetNamedChild("Row" .. i) if (row ~= nil) then if (DoesUnitExist("group" .. i)) then row:GetNamedChild("SenderNameValueLabel"):SetText(GetUnitName("group" .. i)) row:GetNamedChild("UltimateValueLabel"):SetText("-") row:GetNamedChild("ReadyValueLabel"):SetText("0") row:SetHidden(false) else row:SetHidden(true) row:GetNamedChild("SenderNameValueLabel"):SetText("-") row:GetNamedChild("UltimateValueLabel"):SetText("-") row:GetNamedChild("ReadyValueLabel"):SetText("0") end else logDebug("row nil " .. i) end end end --[[ Updates list row ]]-- function SimpleList.UpdateListRow(rowId, ultimateName, relativeUltimate, isPlayerDead) logDebug("SimpleList.UpdateListRow()") if (rowId ~= nil and rowId ~= "" and ultimateName ~= nil and ultimateName ~= "" and relativeUltimate ~= nil and relativeUltimate >= 0 and relativeUltimate <= 100) then local row = SimpleListControlContainerScrollChild:GetNamedChild("Row" .. rowId) if (row ~= nil) then row:GetNamedChild("UltimateValueLabel"):SetText(ultimateName) row:GetNamedChild("ReadyValueLabel"):SetText(relativeUltimate) if (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 (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 logDebug("row nil " .. rowId) end else logDebug("ignored; rowId: " .. rowId .. ", ultimateName: " .. ultimateName .. ", relativeUltimate: " .. relativeUltimate) end end --[[ UpdateMovable sets the Movable and MouseEnabled flag in UI elements ]]-- function SimpleList.SetMovable(isMovable) SimpleListControl:SetMovable(isMovable) SimpleListControl:SetMouseEnabled(isMovable) end --[[ RestorePosition sets SimpleList on settings position ]]-- function SimpleList.RestorePosition(posX, posY) SimpleListControl:ClearAnchors() SimpleListControl:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, posX, posY) end --[[ OnGroupUltimateSimpleListMoveStop saves current SimpleList position to settings ]]-- function SimpleList.OnGroupUltimateSimpleListMoveStop() local left = SimpleListControl:GetLeft() local top = SimpleListControl:GetTop() Settings.SavedVariables.PosX = left Settings.SavedVariables.PosY = top end function SimpleList.SetHidden(isHidden) SimpleListControl:SetHidden(isHidden) end --[[ CreateGroupUltimateSimpleListRows creates group ultimate rows ]]-- function SimpleList.CreateGroupUltimateSimpleListRows() for i=1, GROUP_SIZE_MAX, 1 do local row = CreateControlFromVirtual("$(parent)Row", SimpleListControlContainerScrollChild, "GroupUltimateSimpleListRow", i) 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) SimpleList:SetHidden(isHidden) SimpleList:SetMovable(isMovable) SimpleList:RestorePosition(posX, posY) SimpleList:CreateGroupUltimateSimpleListRows() CALLBACK_MANAGER:RegisterCallback("TGU-GroupChanged", SimpleList.RefreshList) CALLBACK_MANAGER:RegisterCallback("TGU-MapPingChanged", SimpleList.UpdateListRow) end