LeoAltholic.hidden = true

function LeoAltholic:OnWindowMoveStop()
    LeoAltholic.savedVariables.position = {
        left = LeoAltholicWindow:GetLeft(),
        top = LeoAltholicWindow:GetTop()
    }
end

function LeoAltholic:isHidden()
    return LeoAltholic.hidden
end

function LeoAltholic.RestorePosition()
    local position = LeoAltholic.savedVariables.position or { left = 100; top = 100; }
    local left = position.left
    local top = position.top

    LeoAltholicWindow:ClearAnchors()
    LeoAltholicWindow:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, left, top)
end

function LeoAltholic.ShowUI()
    SCENE_MANAGER:ShowTopLevel(LeoAltholicWindow)
    LeoAltholicWindow:SetHidden(false)
    LeoAltholic.hidden = false;
    LeoAltholic.ShowTab(LeoAltholic.savedVariables.activeTab or "Bio")
end

function LeoAltholic.HideUI()
    SCENE_MANAGER:HideTopLevel(LeoAltholicWindow)
    LeoAltholicWindow:SetHidden(true)
    LeoAltholic.hidden = true;
end

function LeoAltholic.ToggleUI()
    if LeoAltholic:isHidden() then
        LeoAltholic.ShowUI()
    else
        LeoAltholic.HideUI()
    end
end

function LeoAltholic.ShowTab(tab)
    LeoAltholic.savedVariables.activeTab = tab
    LeoAltholicWindowTitle:SetText(LeoAltholic.displayName .. " v" .. LeoAltholic.version .. " - " .. tab)
    local control
    for _,panel in ipairs(LeoAltholic.panelList) do
        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindow' .. panel .. 'Panel')
        control:SetHidden(true)
    end
    local control = WINDOW_MANAGER:GetControlByName("LeoAltholicWindow" .. tab .. "Panel")
    control:SetHidden(false)
end

function LeoAltholic.InitializeCharacterFrames()
    for x,char in pairs(LeoAltholic.GetCharacters()) do
        local backgroundColor = {0.13,0.13,0.13,1 }
        if char.bio.name == LeoAltholic.CharName then
            backgroundColor = {0.18,0.18,0.18,1 }
        end

        local frame = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_CharacterFrame'..x,LeoAltholicWindowBioPanelScrollChild,CT_CONTROL)
        frame:SetAnchor(TOPLEFT,LeoAltholicWindowBioPanelScrollChild,TOPLEFT,0,(x - 1) * 109)

        local bg = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'BG',frame,CT_BACKDROP)
        bg:SetAnchor(TOPLEFT,frame,TOPLEFT,2,2)
        bg:SetDimensions(898,105)
        bg:SetCenterColor(unpack(backgroundColor))
        bg:SetEdgeColor(0.22,0.22,0.22,1)
        bg:SetEdgeTexture('',1,1,1)

        local btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'Alliance',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,10,35)
        btn:SetDimensions(60,90)
        btn:SetHorizontalAlignment(1)
        btn:SetVerticalAlignment(0)
        btn:SetFont('ZoFontWinH3')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'Name',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,80,20)
        btn:SetDimensions(180,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH3')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'RaceClass',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,80,50)
        btn:SetDimensions(450,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'LevelLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,250,4)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("Level: ")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'Level',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,340,4)
        btn:SetDimensions(50,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'AllianceRankLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,250,34)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("Rank: ")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'AllianceRank',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,340,34)
        btn:SetDimensions(150,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'BountyLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,250,64)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("Bounty: ")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'Bounty',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,340,64)
        btn:SetDimensions(150,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'AttributePointsLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,500,4)
        btn:SetDimensions(150,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("Attribute Points: ")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'AttributePoints',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,660,4)
        btn:SetDimensions(50,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'PlayedLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,500,34)
        btn:SetDimensions(150,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("Played: ")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'Played',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,660,34)
        btn:SetDimensions(100,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'RidingLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,500,64)
        btn:SetDimensions(150,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("Riding: ")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowBioPanel_Character'..x..'Riding',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,660,64)
        btn:SetDimensions(400,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        frame = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_CharacterFrame'..x,LeoAltholicWindowStatsPanelScrollChild,CT_CONTROL)
        frame:SetAnchor(TOPLEFT,LeoAltholicWindowStatsPanelScrollChild,TOPLEFT,0,(x - 1) * 109)

        bg = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'BG',frame,CT_BACKDROP)
        bg:SetAnchor(TOPLEFT,frame,TOPLEFT,2,2)
        bg:SetDimensions(898,105)
        bg:SetCenterColor(unpack(backgroundColor))
        bg:SetEdgeColor(0.22,0.22,0.22,1)
        bg:SetEdgeTexture('',1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'Alliance',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,10,35)
        btn:SetDimensions(60,90)
        btn:SetHorizontalAlignment(1)
        btn:SetVerticalAlignment(0)
        btn:SetFont('ZoFontWinH3')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'Name',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,80,20)
        btn:SetDimensions(180,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH3')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'RaceClass',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,80,50)
        btn:SetDimensions(450,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'AttributePointsLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,240,4)
        btn:SetDimensions(150,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("Points: ")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'AttributePoints',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,400,4)
        btn:SetDimensions(100,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'MaxAttributesLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,240,34)
        btn:SetDimensions(150,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("Maximum: ")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'MaxAttributes',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,400,34)
        btn:SetDimensions(150,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'RecoveryAttributesLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,240,64)
        btn:SetDimensions(150,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("Recovery: ")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'RecoveryAttributes',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,400,64)
        btn:SetDimensions(150,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'SpellPointsLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,540,4)
        btn:SetDimensions(140,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("Spell Crit: ")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'SpellPoints',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,690,4)
        btn:SetDimensions(100,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'WeaponPointsLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,540,34)
        btn:SetDimensions(140,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("Weapon Crit: ")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowStatsPanel_Character'..x..'WeaponPoints',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,690,34)
        btn:SetDimensions(100,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)


        frame = WINDOW_MANAGER:CreateControl('LeoAltholicWindowSkillsPanel_CharacterFrame'..x,LeoAltholicWindowSkillsPanelScrollChild,CT_CONTROL)
        frame:SetAnchor(TOPLEFT,LeoAltholicWindowSkillsPanelScrollChild,TOPLEFT,0,(x - 1) * 109)

        bg = WINDOW_MANAGER:CreateControl('LeoAltholicWindowSkillsPanel_Character'..x..'BG',frame,CT_BACKDROP)
        bg:SetAnchor(TOPLEFT,frame,TOPLEFT,2,2)
        bg:SetDimensions(898,105)
        bg:SetCenterColor(unpack(backgroundColor))
        bg:SetEdgeColor(0.22,0.22,0.22,1)
        bg:SetEdgeTexture('',1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowSkillsPanel_Character'..x..'Alliance',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,10,35)
        btn:SetDimensions(60,90)
        btn:SetHorizontalAlignment(1)
        btn:SetVerticalAlignment(0)
        btn:SetFont('ZoFontWinH3')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowSkillsPanel_Character'..x..'Name',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,80,20)
        btn:SetDimensions(180,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH3')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowSkillsPanel_Character'..x..'RaceClass',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,80,50)
        btn:SetDimensions(450,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())

        frame = WINDOW_MANAGER:CreateControl('LeoAltholicWindowChampionPanel_CharacterFrame'..x,LeoAltholicWindowChampionPanelScrollChild,CT_CONTROL)
        frame:SetAnchor(TOPLEFT,LeoAltholicWindowChampionPanelScrollChild,TOPLEFT,0,(x - 1) * 139)

        bg = WINDOW_MANAGER:CreateControl('LeoAltholicWindowChampionPanel_Character'..x..'BG',frame,CT_BACKDROP)
        bg:SetAnchor(TOPLEFT,frame,TOPLEFT,2,2)
        bg:SetDimensions(898,135)
        bg:SetCenterColor(unpack(backgroundColor))
        bg:SetEdgeColor(0.22,0.22,0.22,1)
        bg:SetEdgeTexture('',1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowChampionPanel_Character'..x..'Alliance',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,10,35)
        btn:SetDimensions(60,90)
        btn:SetHorizontalAlignment(1)
        btn:SetVerticalAlignment(0)
        btn:SetFont('ZoFontWinH3')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowChampionPanel_Character'..x..'Name',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,80,20)
        btn:SetDimensions(180,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH3')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowChampionPanel_Character'..x..'RaceClass',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,80,50)
        btn:SetDimensions(450,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())

        local col = {}
        col[ATTRIBUTE_MAGICKA] = 240
        col[ATTRIBUTE_HEALTH] = 440
        col[ATTRIBUTE_STAMINA] = 640

        for _, attribute in ipairs({ATTRIBUTE_MAGICKA, ATTRIBUTE_HEALTH, ATTRIBUTE_STAMINA}) do
            btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowChampionPanel_Character'..x..attribute..'Label',frame,CT_BUTTON)
            btn:SetAnchor(TOPLEFT,frame,TOPLEFT,col[attribute],4)
            btn:SetDimensions(150,35)
            btn:SetHorizontalAlignment(2)
            btn:SetVerticalAlignment(1)
            btn:SetFont('ZoFontWinH4')
            btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
            if attribute == ATTRIBUTE_MAGICKA then
                btn:SetText("|t24:24:esoui/art/tutorial/champion_points_magicka_icon.dds|t")
            elseif attribute == ATTRIBUTE_HEALTH then
                btn:SetText("|t24:24:esoui/art/tutorial/champion_points_health_icon.dds|t")
            elseif attribute == ATTRIBUTE_STAMINA then
                btn:SetText("|t24:24:esoui/art/tutorial/champion_points_stamina_icon.dds|t")
            end

            btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowChampionPanel_Character'..x..attribute,frame,CT_BUTTON)
            btn:SetAnchor(TOPLEFT,frame,TOPLEFT,col[attribute] + 160,4)
            btn:SetDimensions(100,35)
            btn:SetHorizontalAlignment(0)
            btn:SetVerticalAlignment(1)
            btn:SetFont('ZoFontWinH4')
            btn:SetNormalFontColor(1,1,1,1)

            local row = 34
            for i = 1, GetNumChampionDisciplines() do
                local dAttribute = GetChampionDisciplineAttribute(i)
                if dAttribute == attribute then
                    local dispName = GetChampionDisciplineName(i)

                    btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowChampionPanel_Character'..x..i..'DiscLabel',frame,CT_BUTTON)
                    btn:SetAnchor(TOPLEFT,frame,TOPLEFT,col[attribute],row)
                    btn:SetDimensions(150,35)
                    btn:SetHorizontalAlignment(2)
                    btn:SetVerticalAlignment(1)
                    btn:SetFont('ZoFontWinH4')
                    btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
                    btn:SetText(dispName)

                    btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowChampionPanel_Character'..x..i..'Disc',frame,CT_BUTTON)
                    btn:SetAnchor(TOPLEFT,frame,TOPLEFT,col[attribute] + 160,row)
                    btn:SetDimensions(100,35)
                    btn:SetHorizontalAlignment(0)
                    btn:SetVerticalAlignment(1)
                    btn:SetFont('ZoFontWinH4')
                    btn:SetNormalFontColor(1,1,1,1)

                    row = row + 30
                end
            end
        end



        frame = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_CharacterFrame'..x,LeoAltholicWindowInventoryPanelScrollChild,CT_CONTROL)
        frame:SetAnchor(TOPLEFT,LeoAltholicWindowInventoryPanelScrollChild,TOPLEFT,0,(x - 1) * 109)

        bg = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'BG',frame,CT_BACKDROP)
        bg:SetAnchor(TOPLEFT,frame,TOPLEFT,2,2)
        bg:SetDimensions(898,105)
        bg:SetCenterColor(unpack(backgroundColor))
        bg:SetEdgeColor(0.22,0.22,0.22,1)
        bg:SetEdgeTexture('',1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'Alliance',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,10,35)
        btn:SetDimensions(60,90)
        btn:SetHorizontalAlignment(1)
        btn:SetVerticalAlignment(0)
        btn:SetFont('ZoFontWinH3')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'Name',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,80,20)
        btn:SetDimensions(180,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH3')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'RaceClass',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,80,50)
        btn:SetDimensions(450,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'BagLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,250,4)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("|t30:30:esoui/art/mainmenu/menubar_inventory_up.dds|t")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'Bag',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,340,4)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'SoulGemsLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,250,34)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("|t20:20:esoui/art/currency/currency_seedcrystal_16.dds|t")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'SoulGems',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,340,34)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'GoldLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,250,64)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("|t20:20:esoui/art/currency/currency_gold.dds|t")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'Gold',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,340,64)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'APLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,400,4)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("|t24:24:esoui/art/currency/alliancepoints.dds|t")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'AP',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,490,4)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'TelVarLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,400,34)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("|t24:24:esoui/art/currency/currency_telvar.dds|t")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'TelVar',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,490,34)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'WritLabel',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,400,64)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(2)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
        btn:SetText("|t24:24:esoui/art/currency/currency_writvoucher.dds|t")

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowInventoryPanel_Character'..x..'Writ',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,490,64)
        btn:SetDimensions(80,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(1,1,1,1)


        frame = WINDOW_MANAGER:CreateControl('LeoAltholicWindowResearchPanel_CharacterFrame'..x,LeoAltholicWindowResearchPanelScrollChild,CT_CONTROL)
        frame:SetAnchor(TOPLEFT,LeoAltholicWindowResearchPanelScrollChild,TOPLEFT,0,(x - 1) * 259)

        bg = WINDOW_MANAGER:CreateControl('LeoAltholicWindowResearchPanel_Character'..x..'BG',frame,CT_BACKDROP)
        bg:SetAnchor(TOPLEFT,frame,TOPLEFT,2,2)
        bg:SetDimensions(898,255)
        bg:SetCenterColor(unpack(backgroundColor))
        bg:SetEdgeColor(0.22,0.22,0.22,1)
        bg:SetEdgeTexture('',1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowResearchPanel_Character'..x..'Alliance',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,10,35)
        btn:SetDimensions(60,90)
        btn:SetHorizontalAlignment(1)
        btn:SetVerticalAlignment(0)
        btn:SetFont('ZoFontWinH3')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowResearchPanel_Character'..x..'Name',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,80,20)
        btn:SetDimensions(180,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH3')
        btn:SetNormalFontColor(1,1,1,1)

        btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowResearchPanel_Character'..x..'RaceClass',frame,CT_BUTTON)
        btn:SetAnchor(TOPLEFT,frame,TOPLEFT,80,50)
        btn:SetDimensions(450,35)
        btn:SetHorizontalAlignment(0)
        btn:SetVerticalAlignment(1)
        btn:SetFont('ZoFontWinH4')
        btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())

        local crafts = {"Blacksmithing", "Clothing", "Woodworking", "Jewelry Crafting" }
        for index,craft in ipairs(crafts) do
            local anchorX = 280 + ((1-(index%2)) * 330)
            local anchorY = 4 + ((math.floor(index/3)) * 120)
            btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowResearchPanel_Character'..x..craft..'Label',frame,CT_BUTTON)
            btn:SetAnchor(TOPLEFT, frame, TOPLEFT, anchorX, anchorY)
            btn:SetDimensions(150,35)
            btn:SetHorizontalAlignment(0)
            btn:SetVerticalAlignment(1)
            btn:SetFont('ZoFontWinH4')
            btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())
            btn:SetText(craft)

            for i = 1, 3 do
                btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowResearchPanel_Character'..x..craft..i,frame,CT_BUTTON)
                btn:SetAnchor(TOPLEFT,frame,TOPLEFT, anchorX, anchorY + (30 * i))
                btn:SetDimensions(200,35)
                btn:SetHorizontalAlignment(0)
                btn:SetVerticalAlignment(1)
                btn:SetFont('ZoFontWinH4')
                btn:SetNormalFontColor(1,1,1,1)

                btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowResearchPanel_Character'..x..craft..i.."Timer",frame,CT_BUTTON)
                btn:SetAnchor(TOPLEFT,frame,TOPLEFT, anchorX + 180, anchorY + (30 * i))
                btn:SetDimensions(200,35)
                btn:SetHorizontalAlignment(0)
                btn:SetVerticalAlignment(1)
                btn:SetFont('ZoFontWinH4')
                btn:SetNormalFontColor(1,1,1,1)
            end

            btn = WINDOW_MANAGER:CreateControl('LeoAltholicWindowResearchPanel_Character'..x..craft..'Count',frame,CT_BUTTON)
            btn:SetAnchor(TOPLEFT, frame, TOPLEFT, anchorX + 180, anchorY)
            btn:SetDimensions(80,35)
            btn:SetHorizontalAlignment(0)
            btn:SetVerticalAlignment(1)
            btn:SetFont('ZoFontWinH4')
            btn:SetNormalFontColor(ZO_NORMAL_TEXT:UnpackRGBA())

        end

    end
end

function LeoAltholic.GetTime(seconds)
    if seconds and seconds > 0 then
        seconds = tostring(ZO_FormatTime(seconds,TIME_FORMAT_STYLE_COLONS,TIME_FORMAT_PRECISION_SECONDS))
        local ts,endtime,y={},'',0
        for x in string.gmatch(seconds,'%d+') do ts[y] = x; y = y + 1; end
        if y == 4 then
            if tonumber(ts[1]) < 10 then ts[1] = '0'..ts[1] end
            endtime = ts[0]..'d '..ts[1]..':'..ts[2]..'h'
        end
        if y == 3 then
            if tonumber(ts[0]) < 10 then ts[0] = '0'..ts[0] end
            endtime = ts[0]..':'..ts[1]..'h'
        end
        if y == 2 then endtime = ts[0]..'min' end
        return endtime
    else return '|cFF4020finished|r' end
end

function LeoAltholic.DisplayCharacterFrames()
    local control
    for _,panel in ipairs(LeoAltholic.panelList) do
        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindow' .. panel .. 'PanelScrollChild')
        control:SetHeight(#LeoAltholic.GetCharacters() * 110)
    end
    control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowResearchPanelScrollChild')
    control:SetHeight(#LeoAltholic.GetCharacters() * 260)

    for x,char in pairs(LeoAltholic.GetCharacters()) do

        for _,panel in ipairs(LeoAltholic.panelList) do
            control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindow' .. panel .. 'Panel_Character'..x..'Alliance')
            local icon = ZO_GetAllianceIcon(char.bio.alliance.id)
            control:SetText("|cF1FF77|t50:90:" .. icon .. "|t|r ")
            control:SetMouseEnabled(true)
            control:SetHandler('OnMouseEnter', function(self) ZO_Tooltips_ShowTextTooltip(self, RIGHT, char.bio.alliance.name) end)
            control:SetHandler("OnMouseExit", function () ZO_Tooltips_HideTextTooltip() end)

            control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindow' .. panel .. 'Panel_Character'..x..'Name')
            control:SetText(char.bio.name)

            control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindow' .. panel .. 'Panel_Character'..x..'RaceClass')
            control:SetText(char.bio.race .. " " .. char.bio.class)
        end

        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowBioPanel_Character'..x..'Level')
        if char.bio.isChampion then
            control:SetText("|t24:24:esoui/art/champion/champion_icon.dds|t" .. char.bio.championPoints)
        else
            control:SetText(char.bio.level)
        end

        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowBioPanel_Character'..x..'AllianceRank')
        control:SetText(GetAvARankName(char.bio.gender, char.bio.alliance.rank))

        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowBioPanel_Character'..x..'AttributePoints')
        control:SetText(char.attributes.unspent)

        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowBioPanel_Character'..x..'Played')
        control:SetText(LeoAltholic.GetTime(char.secondsPlayed))

        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowBioPanel_Character'..x..'Bounty')
        control:SetText(char.bounty .. " |t14:14:esoui/art/currency/currency_gold.dds|t")

        local riding = '|t20:20:esoui/art/mounts/ridingskill_speed.dds|t ' .. char.attributes.riding.speed .. '%' ..
                ' |t20:20:esoui/art/mounts/ridingskill_stamina.dds|t ' .. char.attributes.riding.stamina ..
                ' |t20:20:esoui/art/mounts/ridingskill_capacity.dds|t ' .. char.attributes.riding.capacity ..
                ' |t22:22:esoui/art/miscellaneous/timer_32.dds|t ' .. LeoAltholic.GetTime(char.attributes.riding.time - GetTimeStamp())

        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowBioPanel_Character'..x..'Riding')
        control:SetText(riding)

        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowStatsPanel_Character'..x..'AttributePoints')
        control:SetText("|c596cfd" .. char.attributes.magicka.points .. "|r / |cCB110E" .. char.attributes.health.points .. "|r / |c21A121" .. char.attributes.stamina.points .. "|r")

        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowStatsPanel_Character'..x..'MaxAttributes')
        control:SetText("|c596cfd" .. char.attributes.magicka.max .. "|r / |cCB110E" .. char.attributes.health.max .. "|r / |c21A121" .. char.attributes.stamina.max .. "|r")

        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowStatsPanel_Character'..x..'RecoveryAttributes')
        control:SetText("|c596cfd" .. char.attributes.magicka.recovery .. "|r / |cCB110E" .. char.attributes.health.recovery .. "|r / |c21A121" .. char.attributes.stamina.recovery .. "|r")

        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowStatsPanel_Character'..x..'SpellPoints')
        control:SetText(string.format("%.1f%%", char.attributes.spell.criticalChance))

        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowStatsPanel_Character'..x..'WeaponPoints')
        control:SetText(string.format("%.1f%%", char.attributes.weapon.criticalChance))

        for _, attribute in ipairs({ATTRIBUTE_MAGICKA, ATTRIBUTE_HEALTH, ATTRIBUTE_STAMINA}) do
            control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowChampionPanel_Character'..x..attribute)
            local total = char.champion[attribute].spent + char.champion[attribute].unspent
            local color = '|c21A121'
            if char.champion[attribute].unspent > 0 then
                color = '|cCB110E'
            end
            control:SetText(color .. char.champion[attribute].spent .. '/' .. total .. '|r')
        end
        for i = 1, GetNumChampionDisciplines() do
            local dAttribute = GetChampionDisciplineAttribute(i)
            control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowChampionPanel_Character'..x..i..'Disc')
            control:SetText(char.champion[dAttribute].disciplines[i].spent)
        end

        local color = '|c21A121'
        if char.inventory.free <= 25 then color = '|c596cfd' end
        if char.inventory.free <= 10 then color = '|cCB110E' end
        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowInventoryPanel_Character'..x..'Bag')
        control:SetText(color .. char.inventory.used .. "|r / " .. char.inventory.size)
        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowInventoryPanel_Character'..x..'SoulGems')
        control:SetText("|c21A121" .. char.inventory.soulGemFilled .. '|r / ' .. char.inventory.soulGemEmpty)
        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowInventoryPanel_Character'..x..'Gold')
        control:SetText(LeoAltholic.formatNumber(char.inventory.gold))
        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowInventoryPanel_Character'..x..'AP')
        control:SetText(LeoAltholic.formatNumber(char.inventory.ap))
        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowInventoryPanel_Character'..x..'TelVar')
        control:SetText(LeoAltholic.formatNumber(char.inventory.telvar))
        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowInventoryPanel_Character'..x..'Writ')
        control:SetText(LeoAltholic.formatNumber(char.inventory.writVoucher))

        for _,craft in pairs(LeoAltholic.craftResearch) do
            local i = 1
            local researching = 0
            local craftName = GetCraftingSkillName(craft)
            for line = 1, GetNumSmithingResearchLines(craft) do
                local lineName, lineIcon = GetSmithingResearchLineInfo(craft, line)
                for trait = 1, LeoAltholic.maxTraits do
                    local traitType = GetSmithingResearchLineTraitInfo(craft, line, trait)
                    local traitName = GetString('SI_ITEMTRAITTYPE',traitType)
                    local traitData = char.research[craftName][lineName][traitName]
                    if type(traitData) == 'number' then
                        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowResearchPanel_Character'..x..craftName..i)
                        control:SetText(' |t28:28:'..lineIcon..'|t  ' .. traitName)
                        control:SetHandler('OnMouseEnter', function(self) ZO_Tooltips_ShowTextTooltip(self, TOP, lineName) end)
                        control:SetHandler("OnMouseExit", function () ZO_Tooltips_HideTextTooltip() end)
                        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowResearchPanel_Character'..x..craftName..i.."Timer")
                        control:SetText(LeoAltholic.GetTime(traitData - GetTimeStamp()))
                        i = i + 1
                        researching = researching + 1
                    end
                end
            end
            control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowResearchPanel_Character'..x..craftName..'Count')
            local color = '|c21A121'
            if researching < char.research[craftName].max then
                color = '|cCB110E'
            end
            control:SetText(color .. researching .. '/' .. char.research[craftName].max .. '|r')
        end
    end
end

function LeoAltholic:OnUpdate()
    if LeoAltholic:isHidden() then
        return
    end

    local control
    for x,char in pairs(LeoAltholic.GetCharacters()) do

        local riding = '|t20:20:esoui/art/mounts/ridingskill_speed.dds|t ' .. char.attributes.riding.speed .. '%' ..
                ' |t20:20:esoui/art/mounts/ridingskill_stamina.dds|t ' .. char.attributes.riding.stamina ..
                ' |t20:20:esoui/art/mounts/ridingskill_capacity.dds|t ' .. char.attributes.riding.capacity ..
                ' |t22:22:esoui/art/miscellaneous/timer_32.dds|t ' .. LeoAltholic.GetTime(char.attributes.riding.time - GetTimeStamp())
        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowBioPanel_Character'..x..'Riding')
        control:SetText(riding)

        for _,craft in pairs(LeoAltholic.craftResearch) do
            local i = 1
            local craftName = GetCraftingSkillName(craft)
            for line = 1, GetNumSmithingResearchLines(craft) do
                local lineName, lineIcon = GetSmithingResearchLineInfo(craft, line)
                for trait = 1, LeoAltholic.maxTraits do
                    local traitType = GetSmithingResearchLineTraitInfo(craft, line, trait)
                    local traitName = GetString('SI_ITEMTRAITTYPE',traitType)
                    local traitData = char.research[craftName][lineName][traitName]
                    if type(traitData) == 'number' then
                        control = WINDOW_MANAGER:GetControlByName('LeoAltholicWindowResearchPanel_Character'..x..craftName..i.."Timer")
                        control:SetText(LeoAltholic.GetTime(traitData - GetTimeStamp()))
                        i = i + 1
                    end
                end
            end
        end
    end

end

ZO_CreateStringId('SI_BINDING_NAME_LEOALTHOLIC_TOGGLE_WINDOW', "Show/Hide Main Window")