From 93b19d0156ed1d98b67a782cc1f80d5421126fbf Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Thu, 2 Feb 2023 03:37:48 +0100 Subject: [PATCH 1/2] Reduce triggers, reuse variable. --- [gameplay]/scoreboard/dxscoreboard_client.lua | 18 +++++++++++++++--- [gameplay]/scoreboard/dxscoreboard_exports.lua | 6 +----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/[gameplay]/scoreboard/dxscoreboard_client.lua b/[gameplay]/scoreboard/dxscoreboard_client.lua index c64058656..6ad90bb77 100644 --- a/[gameplay]/scoreboard/dxscoreboard_client.lua +++ b/[gameplay]/scoreboard/dxscoreboard_client.lua @@ -134,8 +134,11 @@ function doDrawScoreboard( rtPass, onlyAnim, sX, sY ) -- -- In/out animation -- - local currentSeconds = getTickCount() / 1000 + + local currentTick = getTickCount() + local currentSeconds = currentTick/1000 local deltaSeconds = currentSeconds - scoreboardDimensions.lastSeconds + scoreboardDimensions.lastSeconds = currentSeconds deltaSeconds = math.clamp( 0, deltaSeconds, 1/25 ) @@ -330,7 +333,7 @@ function doDrawScoreboard( rtPass, onlyAnim, sX, sY ) -- -- Update the scoreboard content -- - local currentTick = getTickCount() + if (currentTick - scoreboardTicks.lastUpdate > scoreboardTicks.updateInterval and (scoreboardToggled or scoreboardForced)) or forceScoreboardUpdate then forceScoreboardUpdate = false scoreboardContent = {} @@ -869,7 +872,6 @@ function scoreboardAddColumn(name, width, friendlyName, priority, textFunction, return false end - addEvent( "doScoreboardAddColumn", true ) addEventHandler( "doScoreboardAddColumn", root, function ( name, width, friendlyName, priority, fromResource, isImage, imageW, imageH ) @@ -877,6 +879,16 @@ addEventHandler( "doScoreboardAddColumn", root, end ) +function onClientScoreboardCreateColumns(columnsToAdd) + for columnID = 1, #columnsToAdd do + local columnData = columnsToAdd[columnID] + + scoreboardAddColumn(columnData.name, columnData.width, columnData.friendlyName, columnData.priority, nil, columnData.isImage, columnData.imageW, columnData.imageH) + end +end +addEvent("onClientScoreboardCreateColumns", true) +addEventHandler("onClientScoreboardCreateColumns", localPlayer, onClientScoreboardCreateColumns) + -- removeColumn function scoreboardRemoveColumn(name) if type(name) ~= "string" then diff --git a/[gameplay]/scoreboard/dxscoreboard_exports.lua b/[gameplay]/scoreboard/dxscoreboard_exports.lua index aac1c932c..5976d1e47 100644 --- a/[gameplay]/scoreboard/dxscoreboard_exports.lua +++ b/[gameplay]/scoreboard/dxscoreboard_exports.lua @@ -206,11 +206,7 @@ function onPlayerResourceStartScoreboard(startedResource) return false end - for columnID = 1, #scoreboardColumns do - local columnData = scoreboardColumns[columnID] - - triggerClientEvent(source, "doScoreboardAddColumn", source, columnData.name, columnData.width, columnData.friendlyName, columnData.priority, nil, columnData.isImage, columnData.imageW, columnData.imageH) - end + triggerClientEvent(source, "onClientScoreboardCreateColumns", source, scoreboardColumns) end addEventHandler("onPlayerResourceStart", root, onPlayerResourceStartScoreboard) From a0fb4d6595736d3a7ec99f8e48e35d68027a9a95 Mon Sep 17 00:00:00 2001 From: srslyyyy <51768772+srslyyyy@users.noreply.github.com> Date: Thu, 2 Feb 2023 03:45:11 +0100 Subject: [PATCH 2/2] Add return early, save columns count to variable. --- [gameplay]/scoreboard/dxscoreboard_client.lua | 1106 +++++++++-------- 1 file changed, 555 insertions(+), 551 deletions(-) diff --git a/[gameplay]/scoreboard/dxscoreboard_client.lua b/[gameplay]/scoreboard/dxscoreboard_client.lua index 6ad90bb77..e1490988b 100644 --- a/[gameplay]/scoreboard/dxscoreboard_client.lua +++ b/[gameplay]/scoreboard/dxscoreboard_client.lua @@ -129,228 +129,357 @@ function iif( cond, arg1, arg2 ) end function doDrawScoreboard( rtPass, onlyAnim, sX, sY ) - if #scoreboardColumns ~= 0 then + local columnsCount = #scoreboardColumns + local shouldDrawScoreboard = columnsCount > 0 - -- - -- In/out animation - -- + if not shouldDrawScoreboard then + return false + end - local currentTick = getTickCount() - local currentSeconds = currentTick/1000 - local deltaSeconds = currentSeconds - scoreboardDimensions.lastSeconds + -- + -- In/out animation + -- - scoreboardDimensions.lastSeconds = currentSeconds - deltaSeconds = math.clamp( 0, deltaSeconds, 1/25 ) + local currentTick = getTickCount() + local currentSeconds = currentTick/1000 + local deltaSeconds = currentSeconds - scoreboardDimensions.lastSeconds - if scoreboardToggled or scoreboardForced then - local phases = { - [1] = { - ["width"] = s(10), - ["height"] = s(5), + scoreboardDimensions.lastSeconds = currentSeconds + deltaSeconds = math.clamp( 0, deltaSeconds, 1/25 ) - ["incToWidth"] = s(10), - ["incToHeight"] = s(5), + if scoreboardToggled or scoreboardForced then + local phases = { + [1] = { + ["width"] = s(10), + ["height"] = s(5), - ["decToWidth"] = 0, - ["decToHeight"] = 0 - }, - [2] = { - ["width"] = s(40), - ["height"] = s(5), + ["incToWidth"] = s(10), + ["incToHeight"] = s(5), - ["incToWidth"] = calculateWidth(), - ["incToHeight"] = s(5), + ["decToWidth"] = 0, + ["decToHeight"] = 0 + }, + [2] = { + ["width"] = s(40), + ["height"] = s(5), - ["decToWidth"] = s(10), - ["decToHeight"] = s(5) + ["incToWidth"] = calculateWidth(), + ["incToHeight"] = s(5), - }, - [3] = { - ["width"] = calculateWidth(), - ["height"] = s(30), + ["decToWidth"] = s(10), + ["decToHeight"] = s(5) - ["incToWidth"] = calculateWidth(), - ["incToHeight"] = calculateHeight(), + }, + [3] = { + ["width"] = calculateWidth(), + ["height"] = s(30), - ["decToWidth"] = calculateWidth(), - ["decToHeight"] = s(5) - } + ["incToWidth"] = calculateWidth(), + ["incToHeight"] = calculateHeight(), + + ["decToWidth"] = calculateWidth(), + ["decToHeight"] = s(5) } + } - if not useAnimation then - scoreboardDimensions.width = calculateWidth() - scoreboardDimensions.height = calculateHeight() - scoreboardDimensions.phase = #phases - end + if not useAnimation then + scoreboardDimensions.width = calculateWidth() + scoreboardDimensions.height = calculateHeight() + scoreboardDimensions.phase = #phases + end - local maxChange = deltaSeconds * 30*drawSpeed - local maxWidthDiff = math.clamp( -maxChange, phases[scoreboardDimensions.phase].incToWidth - scoreboardDimensions.width, maxChange ) - local maxHeightDiff = math.clamp( -maxChange, phases[scoreboardDimensions.phase].incToHeight - scoreboardDimensions.height, maxChange ) + local maxChange = deltaSeconds * 30*drawSpeed + local maxWidthDiff = math.clamp( -maxChange, phases[scoreboardDimensions.phase].incToWidth - scoreboardDimensions.width, maxChange ) + local maxHeightDiff = math.clamp( -maxChange, phases[scoreboardDimensions.phase].incToHeight - scoreboardDimensions.height, maxChange ) + if scoreboardDimensions.width < phases[scoreboardDimensions.phase].incToWidth then + scoreboardDimensions.width = scoreboardDimensions.width + maxWidthDiff * phases[scoreboardDimensions.phase].width + if scoreboardDimensions.width > phases[scoreboardDimensions.phase].incToWidth then + scoreboardDimensions.width = phases[scoreboardDimensions.phase].incToWidth + end + elseif scoreboardDimensions.width > phases[scoreboardDimensions.phase].incToWidth and not scoreboardDrawn then + scoreboardDimensions.width = scoreboardDimensions.width - maxWidthDiff * phases[scoreboardDimensions.phase].width if scoreboardDimensions.width < phases[scoreboardDimensions.phase].incToWidth then - scoreboardDimensions.width = scoreboardDimensions.width + maxWidthDiff * phases[scoreboardDimensions.phase].width - if scoreboardDimensions.width > phases[scoreboardDimensions.phase].incToWidth then - scoreboardDimensions.width = phases[scoreboardDimensions.phase].incToWidth - end - elseif scoreboardDimensions.width > phases[scoreboardDimensions.phase].incToWidth and not scoreboardDrawn then - scoreboardDimensions.width = scoreboardDimensions.width - maxWidthDiff * phases[scoreboardDimensions.phase].width - if scoreboardDimensions.width < phases[scoreboardDimensions.phase].incToWidth then - scoreboardDimensions.width = phases[scoreboardDimensions.phase].incToWidth - end + scoreboardDimensions.width = phases[scoreboardDimensions.phase].incToWidth end + end + if scoreboardDimensions.height < phases[scoreboardDimensions.phase].incToHeight then + scoreboardDimensions.height = scoreboardDimensions.height + maxHeightDiff * phases[scoreboardDimensions.phase].height + if scoreboardDimensions.height > phases[scoreboardDimensions.phase].incToHeight then + scoreboardDimensions.height = phases[scoreboardDimensions.phase].incToHeight + end + elseif scoreboardDimensions.height > phases[scoreboardDimensions.phase].incToHeight and not scoreboardDrawn then + scoreboardDimensions.height = scoreboardDimensions.height - maxHeightDiff * phases[scoreboardDimensions.phase].height if scoreboardDimensions.height < phases[scoreboardDimensions.phase].incToHeight then - scoreboardDimensions.height = scoreboardDimensions.height + maxHeightDiff * phases[scoreboardDimensions.phase].height - if scoreboardDimensions.height > phases[scoreboardDimensions.phase].incToHeight then - scoreboardDimensions.height = phases[scoreboardDimensions.phase].incToHeight - end - elseif scoreboardDimensions.height > phases[scoreboardDimensions.phase].incToHeight and not scoreboardDrawn then - scoreboardDimensions.height = scoreboardDimensions.height - maxHeightDiff * phases[scoreboardDimensions.phase].height - if scoreboardDimensions.height < phases[scoreboardDimensions.phase].incToHeight then - scoreboardDimensions.height = phases[scoreboardDimensions.phase].incToHeight - end + scoreboardDimensions.height = phases[scoreboardDimensions.phase].incToHeight end + end - if scoreboardDimensions.width == phases[scoreboardDimensions.phase].incToWidth and - scoreboardDimensions.height == phases[scoreboardDimensions.phase].incToHeight then - if phases[scoreboardDimensions.phase + 1] then - scoreboardDimensions.phase = scoreboardDimensions.phase + 1 - else - if not scoreboardDrawn then - bindKey( "mouse2", "both", showTheCursor ) - bindKey( "mouse_wheel_up", "down", scrollScoreboard, -1 ) - bindKey( "mouse_wheel_down", "down", scrollScoreboard, 1 ) - addEventHandler( "onClientClick", root, scoreboardClickHandler ) - if not (windowSettings and isElement( windowSettings )) then - showCursor( false ) - end - triggerServerEvent( "requestServerInfo", localPlayer ) + if scoreboardDimensions.width == phases[scoreboardDimensions.phase].incToWidth and + scoreboardDimensions.height == phases[scoreboardDimensions.phase].incToHeight then + if phases[scoreboardDimensions.phase + 1] then + scoreboardDimensions.phase = scoreboardDimensions.phase + 1 + else + if not scoreboardDrawn then + bindKey( "mouse2", "both", showTheCursor ) + bindKey( "mouse_wheel_up", "down", scrollScoreboard, -1 ) + bindKey( "mouse_wheel_down", "down", scrollScoreboard, 1 ) + addEventHandler( "onClientClick", root, scoreboardClickHandler ) + if not (windowSettings and isElement( windowSettings )) then + showCursor( false ) end - scoreboardDrawn = true + triggerServerEvent( "requestServerInfo", localPlayer ) end + scoreboardDrawn = true end - elseif scoreboardDimensions.width ~= 0 and scoreboardDimensions.height ~= 0 then - local phases = { - [1] = { - ["width"] = s(10), - ["height"] = s(5), - - ["incToWidth"] = s(10), - ["incToHeight"] = s(5), - - ["decToWidth"] = 0, - ["decToHeight"] = 0 - }, - [2] = { - ["width"] = s(40), - ["height"] = s(5), - - ["incToWidth"] = calculateWidth(), - ["incToHeight"] = s(5), - - ["decToWidth"] = s(10), - ["decToHeight"] = s(5) - - }, - [3] = { - ["width"] = calculateWidth(), - ["height"] = s(30), - - ["incToWidth"] = calculateWidth(), - ["incToHeight"] = calculateHeight(), - - ["decToWidth"] = calculateWidth(), - ["decToHeight"] = s(5) - } + end + elseif scoreboardDimensions.width ~= 0 and scoreboardDimensions.height ~= 0 then + local phases = { + [1] = { + ["width"] = s(10), + ["height"] = s(5), + + ["incToWidth"] = s(10), + ["incToHeight"] = s(5), + + ["decToWidth"] = 0, + ["decToHeight"] = 0 + }, + [2] = { + ["width"] = s(40), + ["height"] = s(5), + + ["incToWidth"] = calculateWidth(), + ["incToHeight"] = s(5), + + ["decToWidth"] = s(10), + ["decToHeight"] = s(5) + + }, + [3] = { + ["width"] = calculateWidth(), + ["height"] = s(30), + + ["incToWidth"] = calculateWidth(), + ["incToHeight"] = calculateHeight(), + + ["decToWidth"] = calculateWidth(), + ["decToHeight"] = s(5) } + } - if scoreboardDrawn then - unbindKey( "mouse2", "both", showTheCursor ) - unbindKey( "mouse_wheel_up", "down", scrollScoreboard, -1 ) - unbindKey( "mouse_wheel_down", "down", scrollScoreboard, 1 ) - removeEventHandler( "onClientClick", root, scoreboardClickHandler ) - if not (windowSettings and isElement( windowSettings )) then - showCursor( false ) - end + if scoreboardDrawn then + unbindKey( "mouse2", "both", showTheCursor ) + unbindKey( "mouse_wheel_up", "down", scrollScoreboard, -1 ) + unbindKey( "mouse_wheel_down", "down", scrollScoreboard, 1 ) + removeEventHandler( "onClientClick", root, scoreboardClickHandler ) + if not (windowSettings and isElement( windowSettings )) then + showCursor( false ) end - scoreboardDrawn = false + end + scoreboardDrawn = false - if not useAnimation then - scoreboardDimensions.width = 0 - scoreboardDimensions.height = 0 - scoreboardDimensions.phase = 1 - end + if not useAnimation then + scoreboardDimensions.width = 0 + scoreboardDimensions.height = 0 + scoreboardDimensions.phase = 1 + end - local maxChange = deltaSeconds * 30*drawSpeed - local maxWidthDiff = math.clamp( -maxChange, scoreboardDimensions.width - phases[scoreboardDimensions.phase].decToWidth, maxChange ) - local maxHeightDiff = math.clamp( -maxChange, scoreboardDimensions.height - phases[scoreboardDimensions.phase].decToHeight, maxChange ) + local maxChange = deltaSeconds * 30*drawSpeed + local maxWidthDiff = math.clamp( -maxChange, scoreboardDimensions.width - phases[scoreboardDimensions.phase].decToWidth, maxChange ) + local maxHeightDiff = math.clamp( -maxChange, scoreboardDimensions.height - phases[scoreboardDimensions.phase].decToHeight, maxChange ) + if scoreboardDimensions.width > phases[scoreboardDimensions.phase].decToWidth then + scoreboardDimensions.width = scoreboardDimensions.width - maxWidthDiff * phases[scoreboardDimensions.phase].width + if scoreboardDimensions.width < phases[scoreboardDimensions.phase].decToWidth then + scoreboardDimensions.width = phases[scoreboardDimensions.phase].decToWidth + end + elseif scoreboardDimensions.width < phases[scoreboardDimensions.phase].decToWidth then + scoreboardDimensions.width = scoreboardDimensions.width - maxWidthDiff * phases[scoreboardDimensions.phase].width if scoreboardDimensions.width > phases[scoreboardDimensions.phase].decToWidth then - scoreboardDimensions.width = scoreboardDimensions.width - maxWidthDiff * phases[scoreboardDimensions.phase].width - if scoreboardDimensions.width < phases[scoreboardDimensions.phase].decToWidth then - scoreboardDimensions.width = phases[scoreboardDimensions.phase].decToWidth - end - elseif scoreboardDimensions.width < phases[scoreboardDimensions.phase].decToWidth then - scoreboardDimensions.width = scoreboardDimensions.width - maxWidthDiff * phases[scoreboardDimensions.phase].width - if scoreboardDimensions.width > phases[scoreboardDimensions.phase].decToWidth then - scoreboardDimensions.width = phases[scoreboardDimensions.phase].decToWidth - end + scoreboardDimensions.width = phases[scoreboardDimensions.phase].decToWidth end + end + if scoreboardDimensions.height > phases[scoreboardDimensions.phase].decToHeight then + scoreboardDimensions.height = scoreboardDimensions.height - maxHeightDiff * phases[scoreboardDimensions.phase].height + if scoreboardDimensions.height < phases[scoreboardDimensions.phase].decToHeight then + scoreboardDimensions.height = phases[scoreboardDimensions.phase].decToHeight + end + elseif scoreboardDimensions.height < phases[scoreboardDimensions.phase].decToHeight then + scoreboardDimensions.height = scoreboardDimensions.height - maxHeightDiff * phases[scoreboardDimensions.phase].height if scoreboardDimensions.height > phases[scoreboardDimensions.phase].decToHeight then - scoreboardDimensions.height = scoreboardDimensions.height - maxHeightDiff * phases[scoreboardDimensions.phase].height - if scoreboardDimensions.height < phases[scoreboardDimensions.phase].decToHeight then - scoreboardDimensions.height = phases[scoreboardDimensions.phase].decToHeight - end - elseif scoreboardDimensions.height < phases[scoreboardDimensions.phase].decToHeight then - scoreboardDimensions.height = scoreboardDimensions.height - maxHeightDiff * phases[scoreboardDimensions.phase].height - if scoreboardDimensions.height > phases[scoreboardDimensions.phase].decToHeight then - scoreboardDimensions.height = phases[scoreboardDimensions.phase].decToHeight - end + scoreboardDimensions.height = phases[scoreboardDimensions.phase].decToHeight end + end - if scoreboardDimensions.width == phases[scoreboardDimensions.phase].decToWidth and - scoreboardDimensions.height == phases[scoreboardDimensions.phase].decToHeight and - scoreboardDimensions.width ~= 0 and scoreboardDimensions.height ~= 0 then + if scoreboardDimensions.width == phases[scoreboardDimensions.phase].decToWidth and + scoreboardDimensions.height == phases[scoreboardDimensions.phase].decToHeight and + scoreboardDimensions.width ~= 0 and scoreboardDimensions.height ~= 0 then - scoreboardDimensions.phase = scoreboardDimensions.phase - 1 - if scoreboardDimensions.phase < 1 then scoreboardDimensions.phase = 1 end - end + scoreboardDimensions.phase = scoreboardDimensions.phase - 1 + if scoreboardDimensions.phase < 1 then scoreboardDimensions.phase = 1 end end + end - -- - -- Draw scoreboard background - -- - if (not rtPass or onlyAnim) and scoreboardDimensions.width ~= 0 and scoreboardDimensions.height ~= 0 then - dxDrawRectangle( (sX/2)-(scoreboardDimensions.width/2), (sY/2)-(scoreboardDimensions.height/2), scoreboardDimensions.width, scoreboardDimensions.height, cScoreboardBackground, drawOverGUI ) + -- + -- Draw scoreboard background + -- + if (not rtPass or onlyAnim) and scoreboardDimensions.width ~= 0 and scoreboardDimensions.height ~= 0 then + dxDrawRectangle( (sX/2)-(scoreboardDimensions.width/2), (sY/2)-(scoreboardDimensions.height/2), scoreboardDimensions.width, scoreboardDimensions.height, cScoreboardBackground, drawOverGUI ) + end + + -- Check if anything else to do + if not scoreboardDrawn or onlyAnim then + return + end + + -- + -- Update the scoreboard content + -- + + if (currentTick - scoreboardTicks.lastUpdate > scoreboardTicks.updateInterval and (scoreboardToggled or scoreboardForced)) or forceScoreboardUpdate then + forceScoreboardUpdate = false + scoreboardContent = {} + local index = 1 + + local sortTableIndex = 1 + local sortTable = {} + local players = getElementsByType("player") + + for key = 1, #players do + local player = players[key] + + if not getPlayerTeam( player ) or not (showTeams or (serverInfo.forceshowteams and not serverInfo.forcehideteams)) or serverInfo.forcehideteams then + sortTable[sortTableIndex] = {} + + for key2 = 1, columnsCount do + local column = scoreboardColumns[key2] + local content + + if column.name == "name" then + local playerName = getPlayerName( player ) + if serverInfo.allowcolorcodes then + if string.find( playerName, "#%x%x%x%x%x%x" ) then + local colorCodes = {} + while( string.find( playerName, "#%x%x%x%x%x%x" ) ) do + local startPos, endPos = string.find( playerName, "#%x%x%x%x%x%x" ) + if startPos then + colorCode = string.sub( playerName, startPos, endPos ) + table.insert( colorCodes, { { getColorFromString( colorCode ) }, startPos } ) + playerName = string.gsub( playerName, "#%x%x%x%x%x%x", "", 1 ) + end + end + content = { playerName, colorCodes } + else + content = playerName + end + else + content = playerName + end + elseif column.name == "ping" then + content = getPlayerPing( player ) + else + content = getElementData( player, column.name ) + end + content = iif( content and column.name ~= "name" and type( content ) ~= "table", tostring( content ), content ) + if column.textFunction then + if content and column.name == "name" and type( content ) == "table" then + content[1] = column.textFunction( content[1], player ) + else + content = column.textFunction( content, player ) + end + end + sortTable[sortTableIndex][column.name] = content + sortTable[sortTableIndex]["__SCOREBOARDELEMENT__"] = player + end + sortTableIndex = sortTableIndex + 1 + end end - -- Check if anything else to do - if not scoreboardDrawn or onlyAnim then - return + if sortBy.what ~= "__NONE__" then table.sort( sortTable, scoreboardSortFunction ) end + + for key = 1, #sortTable do + local value = sortTable[key] + + scoreboardContent[index] = value + index = index + 1 end - -- - -- Update the scoreboard content - -- + if (showTeams or (serverInfo.forceshowteams and not serverInfo.forcehideteams)) and not serverInfo.forcehideteams then + -- And then the teams + local teamSortTableIndex = 1 + local teamSortTable = {} + local teams = getElementsByType("team") + + sortTable = {} + + for key = 1, #teams do + local team = teams[key] + + -- Add teams to sorting table first + + teamSortTable[teamSortTableIndex] = {} + + for key2 = 1, columnsCount do + local column = scoreboardColumns[key2] + local content + + if column.name == "name" then + local teamName = getTeamName( team ) + local teamMemberCount = #getPlayersInTeam( team ) + teamName = iif( teamName, tostring( teamName ), "-" ) + teamMemberCount = iif( teamMemberCount, tostring( teamMemberCount ), "0" ) + teamName = teamName .. " (" .. teamMemberCount .. " player" .. iif( teamMemberCount == "1", "", "s" ) .. ")" + if serverInfo.allowcolorcodes then + if string.find( teamName, "#%x%x%x%x%x%x" ) then + local colorCodes = {} + while( string.find( teamName, "#%x%x%x%x%x%x" ) ) do + local startPos, endPos = string.find( teamName, "#%x%x%x%x%x%x" ) + if startPos then + colorCode = string.sub( teamName, startPos, endPos ) + table.insert( colorCodes, { { getColorFromString( colorCode ) }, startPos } ) + teamName = string.gsub( teamName, "#%x%x%x%x%x%x", "", 1 ) + end + end + content = { teamName, colorCodes } + else + content = teamName + end + else + content = teamName + end + else + content = getElementData( team, column.name ) + end + content = iif( content and column.name ~= "name" and type( content ) ~= "table", tostring( content ), content ) + if column.textFunction then + if content and column.name == "name" and type( content ) == "table" then + content[1] = column.textFunction( content[1], team ) + else + content = column.textFunction( content, team ) + end + end + teamSortTable[teamSortTableIndex][column.name] = content + teamSortTable[teamSortTableIndex]["__SCOREBOARDELEMENT__"] = team + end + teamSortTableIndex = teamSortTableIndex + 1 + + -- and then the players - if (currentTick - scoreboardTicks.lastUpdate > scoreboardTicks.updateInterval and (scoreboardToggled or scoreboardForced)) or forceScoreboardUpdate then - forceScoreboardUpdate = false - scoreboardContent = {} - local index = 1 + local playersInTeam = getPlayersInTeam(team) - local sortTableIndex = 1 - local sortTable = {} - local players = getElementsByType("player") + sortTableIndex = 1 + sortTable[team] = {} - for key = 1, #players do - local player = players[key] + for key2 = 1, #playersInTeam do + local player = playersInTeam[key2] - if not getPlayerTeam( player ) or not (showTeams or (serverInfo.forceshowteams and not serverInfo.forcehideteams)) or serverInfo.forcehideteams then - sortTable[sortTableIndex] = {} + sortTable[team][sortTableIndex] = {} - for key2 = 1, #scoreboardColumns do - local column = scoreboardColumns[key2] + for key3 = 1, columnsCount do + local column = scoreboardColumns[key3] local content if column.name == "name" then @@ -386,450 +515,325 @@ function doDrawScoreboard( rtPass, onlyAnim, sX, sY ) content = column.textFunction( content, player ) end end - sortTable[sortTableIndex][column.name] = content - sortTable[sortTableIndex]["__SCOREBOARDELEMENT__"] = player + sortTable[team][sortTableIndex][column.name] = content + sortTable[team][sortTableIndex]["__SCOREBOARDELEMENT__"] = player end sortTableIndex = sortTableIndex + 1 end + if sortBy.what ~= "__NONE__" then table.sort( sortTable[team], scoreboardSortFunction ) end end - if sortBy.what ~= "__NONE__" then table.sort( sortTable, scoreboardSortFunction ) end + if sortBy.what ~= "__NONE__" then table.sort( teamSortTable, scoreboardSortFunction ) end - for key = 1, #sortTable do - local value = sortTable[key] + for key = 1, #teamSortTable do + local content = teamSortTable[key] + local team = content["__SCOREBOARDELEMENT__"] + local sortTableTeam = sortTable[team] - scoreboardContent[index] = value + scoreboardContent[index] = content index = index + 1 - end - if (showTeams or (serverInfo.forceshowteams and not serverInfo.forcehideteams)) and not serverInfo.forcehideteams then - -- And then the teams - local teamSortTableIndex = 1 - local teamSortTable = {} - local teams = getElementsByType("team") - - sortTable = {} - - for key = 1, #teams do - local team = teams[key] - - -- Add teams to sorting table first - - teamSortTable[teamSortTableIndex] = {} - - for key2 = 1, #scoreboardColumns do - local column = scoreboardColumns[key2] - local content - - if column.name == "name" then - local teamName = getTeamName( team ) - local teamMemberCount = #getPlayersInTeam( team ) - teamName = iif( teamName, tostring( teamName ), "-" ) - teamMemberCount = iif( teamMemberCount, tostring( teamMemberCount ), "0" ) - teamName = teamName .. " (" .. teamMemberCount .. " player" .. iif( teamMemberCount == "1", "", "s" ) .. ")" - if serverInfo.allowcolorcodes then - if string.find( teamName, "#%x%x%x%x%x%x" ) then - local colorCodes = {} - while( string.find( teamName, "#%x%x%x%x%x%x" ) ) do - local startPos, endPos = string.find( teamName, "#%x%x%x%x%x%x" ) - if startPos then - colorCode = string.sub( teamName, startPos, endPos ) - table.insert( colorCodes, { { getColorFromString( colorCode ) }, startPos } ) - teamName = string.gsub( teamName, "#%x%x%x%x%x%x", "", 1 ) - end - end - content = { teamName, colorCodes } - else - content = teamName - end - else - content = teamName - end - else - content = getElementData( team, column.name ) - end - content = iif( content and column.name ~= "name" and type( content ) ~= "table", tostring( content ), content ) - if column.textFunction then - if content and column.name == "name" and type( content ) == "table" then - content[1] = column.textFunction( content[1], team ) - else - content = column.textFunction( content, team ) - end - end - teamSortTable[teamSortTableIndex][column.name] = content - teamSortTable[teamSortTableIndex]["__SCOREBOARDELEMENT__"] = team - end - teamSortTableIndex = teamSortTableIndex + 1 - - -- and then the players - - local playersInTeam = getPlayersInTeam(team) - - sortTableIndex = 1 - sortTable[team] = {} - - for key2 = 1, #playersInTeam do - local player = playersInTeam[key2] - - sortTable[team][sortTableIndex] = {} - - for key3 = 1, #scoreboardColumns do - local column = scoreboardColumns[key3] - local content - - if column.name == "name" then - local playerName = getPlayerName( player ) - if serverInfo.allowcolorcodes then - if string.find( playerName, "#%x%x%x%x%x%x" ) then - local colorCodes = {} - while( string.find( playerName, "#%x%x%x%x%x%x" ) ) do - local startPos, endPos = string.find( playerName, "#%x%x%x%x%x%x" ) - if startPos then - colorCode = string.sub( playerName, startPos, endPos ) - table.insert( colorCodes, { { getColorFromString( colorCode ) }, startPos } ) - playerName = string.gsub( playerName, "#%x%x%x%x%x%x", "", 1 ) - end - end - content = { playerName, colorCodes } - else - content = playerName - end - else - content = playerName - end - elseif column.name == "ping" then - content = getPlayerPing( player ) - else - content = getElementData( player, column.name ) - end - content = iif( content and column.name ~= "name" and type( content ) ~= "table", tostring( content ), content ) - if column.textFunction then - if content and column.name == "name" and type( content ) == "table" then - content[1] = column.textFunction( content[1], player ) - else - content = column.textFunction( content, player ) - end - end - sortTable[team][sortTableIndex][column.name] = content - sortTable[team][sortTableIndex]["__SCOREBOARDELEMENT__"] = player - end - sortTableIndex = sortTableIndex + 1 - end - if sortBy.what ~= "__NONE__" then table.sort( sortTable[team], scoreboardSortFunction ) end + for key2 = 1, #sortTableTeam do + local value = sortTableTeam[key2] + + scoreboardContent[index] = value + index = index + 1 end + end + end - if sortBy.what ~= "__NONE__" then table.sort( teamSortTable, scoreboardSortFunction ) end - - for key = 1, #teamSortTable do - local content = teamSortTable[key] - local team = content["__SCOREBOARDELEMENT__"] - local sortTableTeam = sortTable[team] + scoreboardTicks.lastUpdate = currentTick + end - scoreboardContent[index] = content - index = index + 1 + -- + -- Draw scoreboard content + -- + if scoreboardDrawn then + scoreboardDimensions.height = calculateHeight() + scoreboardDimensions.width = calculateWidth() - for key2 = 1, #sortTableTeam do - local value = sortTableTeam[key2] - - scoreboardContent[index] = value - index = index + 1 - end - end - end + local topX, topY = (sX/2)-(calculateWidth()/2), (sY/2)-(calculateHeight()/2) + local index = firstVisibleIndex + local maxPerWindow = getMaxPerWindow() - scoreboardTicks.lastUpdate = currentTick + if firstVisibleIndex > #scoreboardContent-maxPerWindow+1 then + firstVisibleIndex = 1 end - -- - -- Draw scoreboard content - -- - if scoreboardDrawn then - scoreboardDimensions.height = calculateHeight() - scoreboardDimensions.width = calculateWidth() - - local topX, topY = (sX/2)-(calculateWidth()/2), (sY/2)-(calculateHeight()/2) - local index = firstVisibleIndex - local maxPerWindow = getMaxPerWindow() + if firstVisibleIndex > 1 then + dxDrawImage( sX/2-8, topY-15, 17, 11, "arrow.png", 0, 0, 0, cWhite, drawOverGUI ) + end + if firstVisibleIndex+maxPerWindow <= #scoreboardContent and #scoreboardContent > maxPerWindow then + dxDrawImage( sX/2-8, topY+scoreboardDimensions.height+4, 17, 11, "arrow.png", 180, 0, 0, cWhite, drawOverGUI ) + end - if firstVisibleIndex > #scoreboardContent-maxPerWindow+1 then - firstVisibleIndex = 1 - end + local y = topY+s(5) + if serverInfo.server and showServerInfo then + dxDrawText( "Server: " .. serverInfo.server, topX+s(5), y, topX+scoreboardDimensions.width-s(10), y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ), cServerInfo, fontscale(serverInfoFont, s(0.75)), serverInfoFont, "left", "top", false, false, drawOverGUI ) + end + if serverInfo.players and showServerInfo then + local players = getElementsByType("player") + local text = "Players: "..#players.."/"..serverInfo.players + local textWidth = dxGetTextWidth( text, fontscale(serverInfoFont, s(0.75)), serverInfoFont ) - if firstVisibleIndex > 1 then - dxDrawImage( sX/2-8, topY-15, 17, 11, "arrow.png", 0, 0, 0, cWhite, drawOverGUI ) - end - if firstVisibleIndex+maxPerWindow <= #scoreboardContent and #scoreboardContent > maxPerWindow then - dxDrawImage( sX/2-8, topY+scoreboardDimensions.height+4, 17, 11, "arrow.png", 180, 0, 0, cWhite, drawOverGUI ) - end + dxDrawText( text, topX+scoreboardDimensions.width-s(5)-textWidth, y, topX+scoreboardDimensions.width-s(5), y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ), cServerInfo, fontscale(serverInfoFont, s(0.75)), serverInfoFont, "left", "top", false, false, drawOverGUI ) + end + if (serverInfo.server or serverInfo.players) and showServerInfo then y = y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end + if serverInfo.gamemode and showGamemodeInfo then + dxDrawText( "Gamemode: " .. serverInfo.gamemode, topX+s(5), y, topX+scoreboardDimensions.width-s(10), y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ), cServerInfo, fontscale(serverInfoFont, s(0.75)), serverInfoFont, "left", "top", false, false, drawOverGUI ) + end + if serverInfo.map and showGamemodeInfo then + local text = "Map: " .. serverInfo.map + local textWidth = dxGetTextWidth( text, fontscale(serverInfoFont, s(0.75)), serverInfoFont ) + dxDrawText( text, topX+scoreboardDimensions.width-s(5)-textWidth, y, topX+scoreboardDimensions.width-s(5), y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ), cServerInfo, fontscale(serverInfoFont, s(0.75)), serverInfoFont, "left", "top", false, false, drawOverGUI ) + end + if (serverInfo.gamemode or serverInfo.map) and showGamemodeInfo then y = y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end + y = y+s(3) - local y = topY+s(5) - if serverInfo.server and showServerInfo then - dxDrawText( "Server: " .. serverInfo.server, topX+s(5), y, topX+scoreboardDimensions.width-s(10), y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ), cServerInfo, fontscale(serverInfoFont, s(0.75)), serverInfoFont, "left", "top", false, false, drawOverGUI ) + local textLength = dxGetTextWidth( "Hold RMB to enable scrolling/sorting", fontscale(rmbFont, s(0.75)), rmbFont ) + local textHeight = dxGetFontHeight( fontscale(rmbFont, s(0.75)), rmbFont ) + dxDrawText( "Hold RMB to enable scrolling/sorting", sX/2-(textLength/2), topY+scoreboardDimensions.height-textHeight-s(2), sX/2+(textLength/2), topY+scoreboardDimensions.height-s(2), cWhite, fontscale(serverInfoFont, s(0.75)), rmbFont, "left", "top", false, false, drawOverGUI ) + + local bottomX, bottomY = topX+scoreboardDimensions.width, topY+scoreboardDimensions.height + textLength = dxGetTextWidth( "settings...", fontscale(sbFont, s(sbFontScale)), sbFont ) + textHeight = dxGetFontHeight( fontscale(sbFont, s(sbFontScale)), sbFont ) + dxDrawText( "settings...", bottomX-s(sbOutOffset+1+sbInOffset)-textLength, bottomY-s(sbOutOffset+1+sbInOffset)-textHeight, bottomX-s(sbOutOffset+1+sbInOffset), bottomY-s(sbOutOffset+1+sbInOffset), cSettingsBox, fontscale(sbFont, s(sbFontScale)), sbFont, "left", "top", false, false, drawOverGUI ) + dxDrawLine( bottomX-s(sbOutOffset+2*sbInOffset+2)-textLength, bottomY-s(sbOutOffset+2*sbInOffset+1)-textHeight, bottomX-s(sbOutOffset+2*sbInOffset+2)-textLength, bottomY-s(sbOutOffset+1), cSettingsBox, 1, drawOverGUI ) + dxDrawLine( bottomX-s(sbOutOffset+1), bottomY-s(sbOutOffset+2*sbInOffset+1)-textHeight, bottomX-s(sbOutOffset+1), bottomY-s(sbOutOffset+1), cSettingsBox, 1, drawOverGUI ) + dxDrawLine( bottomX-s(sbOutOffset+2*sbInOffset+2)-textLength, bottomY-s(sbOutOffset+2*sbInOffset+1)-textHeight, bottomX-s(sbOutOffset+1), bottomY-s(sbOutOffset+2*sbInOffset+1)-textHeight, cSettingsBox, 1, drawOverGUI ) + dxDrawLine( bottomX-s(sbOutOffset+2*sbInOffset+2)-textLength, bottomY-s(sbOutOffset+1), bottomX-s(sbOutOffset+1), bottomY-s(sbOutOffset+1), cSettingsBox, 1, drawOverGUI ) + + local x1 = s(10) + + for key = 1, columnsCount do + local column = scoreboardColumns[key] + + if x1 ~= s(10) then + local height = s(5) + if (serverInfo.server or serverInfo.players) and showServerInfo then height = height+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end + if (serverInfo.gamemode or serverInfo.map) and showGamemodeInfo then height = height+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end + height = height+s(3) + dxDrawLine( topX + x1 - s(5), y + s(1), topX + x1 - s(5), y + scoreboardDimensions.height-height-s(2)-textHeight-s(5), cBorder, s(1), drawOverGUI ) end - if serverInfo.players and showServerInfo then - local players = getElementsByType("player") - local text = "Players: "..#players.."/"..serverInfo.players - local textWidth = dxGetTextWidth( text, fontscale(serverInfoFont, s(0.75)), serverInfoFont ) - dxDrawText( text, topX+scoreboardDimensions.width-s(5)-textWidth, y, topX+scoreboardDimensions.width-s(5), y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ), cServerInfo, fontscale(serverInfoFont, s(0.75)), serverInfoFont, "left", "top", false, false, drawOverGUI ) - end - if (serverInfo.server or serverInfo.players) and showServerInfo then y = y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end - if serverInfo.gamemode and showGamemodeInfo then - dxDrawText( "Gamemode: " .. serverInfo.gamemode, topX+s(5), y, topX+scoreboardDimensions.width-s(10), y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ), cServerInfo, fontscale(serverInfoFont, s(0.75)), serverInfoFont, "left", "top", false, false, drawOverGUI ) + if sortBy.what == column.name then + local _, _, _, a = fromcolor( cHeader ) + dxDrawText( column.friendlyName or "-", topX+x1+s(1+9), y+s(1), topX+x1+s(1+column.width), y+s(1)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), tocolor( 0, 0, 0, a ), fontscale(columnFont, s(1)), columnFont, "left", "top", true, false, drawOverGUI ) + dxDrawText( column.friendlyName or "-", topX+x1+s(9), y, topX+x1+s(column.width), y+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), cHeader, fontscale(columnFont, s(1)), columnFont, "left", "top", true, false, drawOverGUI ) + dxDrawRectangle( topX+x1, iif( sortBy.dir == 1, y+s(8), y+s(6) ), s(5), s(1), cWhite, drawOverGUI ) + dxDrawRectangle( topX+x1+s(1), y+s(7), s(3), s(1), cWhite, drawOverGUI ) + dxDrawRectangle( topX+x1+s(2), iif( sortBy.dir == 1, y+s(6), y+s(8) ), s(1), s(1), cWhite, drawOverGUI ) + else + local _, _, _, a = fromcolor( cHeader ) + dxDrawText( column.friendlyName or "-", topX+x1+s(1), y+s(1), topX+x1+s(1+column.width), y+s(1)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), tocolor( 0, 0, 0, a ), fontscale(columnFont, s(1)), columnFont, "left", "top", true, false, drawOverGUI ) + dxDrawText( column.friendlyName or "-", topX+x1, y, topX+x1+s(column.width), y+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), cHeader, fontscale(columnFont, s(1)), columnFont, "left", "top", true, false, drawOverGUI ) end - if serverInfo.map and showGamemodeInfo then - local text = "Map: " .. serverInfo.map - local textWidth = dxGetTextWidth( text, fontscale(serverInfoFont, s(0.75)), serverInfoFont ) - dxDrawText( text, topX+scoreboardDimensions.width-s(5)-textWidth, y, topX+scoreboardDimensions.width-s(5), y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ), cServerInfo, fontscale(serverInfoFont, s(0.75)), serverInfoFont, "left", "top", false, false, drawOverGUI ) - end - if (serverInfo.gamemode or serverInfo.map) and showGamemodeInfo then y = y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end - y = y+s(3) - - local textLength = dxGetTextWidth( "Hold RMB to enable scrolling/sorting", fontscale(rmbFont, s(0.75)), rmbFont ) - local textHeight = dxGetFontHeight( fontscale(rmbFont, s(0.75)), rmbFont ) - dxDrawText( "Hold RMB to enable scrolling/sorting", sX/2-(textLength/2), topY+scoreboardDimensions.height-textHeight-s(2), sX/2+(textLength/2), topY+scoreboardDimensions.height-s(2), cWhite, fontscale(serverInfoFont, s(0.75)), rmbFont, "left", "top", false, false, drawOverGUI ) - local bottomX, bottomY = topX+scoreboardDimensions.width, topY+scoreboardDimensions.height - textLength = dxGetTextWidth( "settings...", fontscale(sbFont, s(sbFontScale)), sbFont ) - textHeight = dxGetFontHeight( fontscale(sbFont, s(sbFontScale)), sbFont ) - dxDrawText( "settings...", bottomX-s(sbOutOffset+1+sbInOffset)-textLength, bottomY-s(sbOutOffset+1+sbInOffset)-textHeight, bottomX-s(sbOutOffset+1+sbInOffset), bottomY-s(sbOutOffset+1+sbInOffset), cSettingsBox, fontscale(sbFont, s(sbFontScale)), sbFont, "left", "top", false, false, drawOverGUI ) - dxDrawLine( bottomX-s(sbOutOffset+2*sbInOffset+2)-textLength, bottomY-s(sbOutOffset+2*sbInOffset+1)-textHeight, bottomX-s(sbOutOffset+2*sbInOffset+2)-textLength, bottomY-s(sbOutOffset+1), cSettingsBox, 1, drawOverGUI ) - dxDrawLine( bottomX-s(sbOutOffset+1), bottomY-s(sbOutOffset+2*sbInOffset+1)-textHeight, bottomX-s(sbOutOffset+1), bottomY-s(sbOutOffset+1), cSettingsBox, 1, drawOverGUI ) - dxDrawLine( bottomX-s(sbOutOffset+2*sbInOffset+2)-textLength, bottomY-s(sbOutOffset+2*sbInOffset+1)-textHeight, bottomX-s(sbOutOffset+1), bottomY-s(sbOutOffset+2*sbInOffset+1)-textHeight, cSettingsBox, 1, drawOverGUI ) - dxDrawLine( bottomX-s(sbOutOffset+2*sbInOffset+2)-textLength, bottomY-s(sbOutOffset+1), bottomX-s(sbOutOffset+1), bottomY-s(sbOutOffset+1), cSettingsBox, 1, drawOverGUI ) - - local x1 = s(10) + x1 = x1 + s(column.width + 10) + end - for key = 1, #scoreboardColumns do - local column = scoreboardColumns[key] + dxDrawLine( topX+s(5), y+s(1)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), topX+scoreboardDimensions.width-s(5), y+s(1)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), cBorder, s(1), drawOverGUI ) - if x1 ~= s(10) then - local height = s(5) - if (serverInfo.server or serverInfo.players) and showServerInfo then height = height+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end - if (serverInfo.gamemode or serverInfo.map) and showGamemodeInfo then height = height+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end - height = height+s(3) - dxDrawLine( topX + x1 - s(5), y + s(1), topX + x1 - s(5), y + scoreboardDimensions.height-height-s(2)-textHeight-s(5), cBorder, s(1), drawOverGUI ) + y = y+s(5)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ) + while ( index < firstVisibleIndex+maxPerWindow and scoreboardContent[index] ) do + local x = s(10) + local element = scoreboardContent[index]["__SCOREBOARDELEMENT__"] + local team, player + + if element and isElement( element ) and getElementType( element ) == "team" then + dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), cTeam, drawOverGUI ) + -- Highlight the the row on which the cursor lies on + if checkCursorOverRow( rtPass, topX+s(5), topX+scoreboardDimensions.width-s(5), y, y+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ) ) then + dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), cHighlight, drawOverGUI ) end - - if sortBy.what == column.name then - local _, _, _, a = fromcolor( cHeader ) - dxDrawText( column.friendlyName or "-", topX+x1+s(1+9), y+s(1), topX+x1+s(1+column.width), y+s(1)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), tocolor( 0, 0, 0, a ), fontscale(columnFont, s(1)), columnFont, "left", "top", true, false, drawOverGUI ) - dxDrawText( column.friendlyName or "-", topX+x1+s(9), y, topX+x1+s(column.width), y+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), cHeader, fontscale(columnFont, s(1)), columnFont, "left", "top", true, false, drawOverGUI ) - dxDrawRectangle( topX+x1, iif( sortBy.dir == 1, y+s(8), y+s(6) ), s(5), s(1), cWhite, drawOverGUI ) - dxDrawRectangle( topX+x1+s(1), y+s(7), s(3), s(1), cWhite, drawOverGUI ) - dxDrawRectangle( topX+x1+s(2), iif( sortBy.dir == 1, y+s(6), y+s(8) ), s(1), s(1), cWhite, drawOverGUI ) - else - local _, _, _, a = fromcolor( cHeader ) - dxDrawText( column.friendlyName or "-", topX+x1+s(1), y+s(1), topX+x1+s(1+column.width), y+s(1)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), tocolor( 0, 0, 0, a ), fontscale(columnFont, s(1)), columnFont, "left", "top", true, false, drawOverGUI ) - dxDrawText( column.friendlyName or "-", topX+x1, y, topX+x1+s(column.width), y+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), cHeader, fontscale(columnFont, s(1)), columnFont, "left", "top", true, false, drawOverGUI ) + -- Highlight selected row + if selectedRows[element] then + dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), cHighlight, drawOverGUI ) end - x1 = x1 + s(column.width + 10) - end - - dxDrawLine( topX+s(5), y+s(1)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), topX+scoreboardDimensions.width-s(5), y+s(1)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), cBorder, s(1), drawOverGUI ) - - y = y+s(5)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ) - while ( index < firstVisibleIndex+maxPerWindow and scoreboardContent[index] ) do - local x = s(10) - local element = scoreboardContent[index]["__SCOREBOARDELEMENT__"] - local team, player + for key = 1, columnsCount do + local column = scoreboardColumns[key] + local r, g, b, a = fromcolor(cContent) - if element and isElement( element ) and getElementType( element ) == "team" then - dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), cTeam, drawOverGUI ) - -- Highlight the the row on which the cursor lies on - if checkCursorOverRow( rtPass, topX+s(5), topX+scoreboardDimensions.width-s(5), y, y+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ) ) then - dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), cHighlight, drawOverGUI ) + if not useColors then + r, g, b = 255, 255, 255 end - -- Highlight selected row - if selectedRows[element] then - dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), cHighlight, drawOverGUI ) - end - - for key = 1, #scoreboardColumns do - local column = scoreboardColumns[key] - local r, g, b, a = fromcolor(cContent) - - if not useColors then - r, g, b = 255, 255, 255 - end - local theX = x - local content = scoreboardContent[index][column.name] + local theX = x + local content = scoreboardContent[index][column.name] - if content and column.name == "name" then + if content and column.name == "name" then - if useColors then - r, g, b = getTeamColor( element ) - end - - theX = x - s(3) + if useColors then + r, g, b = getTeamColor( element ) end - if content then - if serverInfo.allowcolorcodes and type( content ) == "table" and column.name == "name" then - local playerName = content[1] - local colorCodes = content[2] - local xPos = topX + theX - - for k = 1, #colorCodes do - local v = colorCodes[k] - local firstCodePos = v[2] - local secondCodePos = colorCodes[k+1] and colorCodes[k+1][2]-1 or #playerName - - if firstCodePos ~= 1 and k == 1 then - local secondPos = firstCodePos-1 - local firstPos = 1 - local partOfName = string.sub( playerName, firstPos, secondPos ) - local textLength5 = dxGetTextWidth( partOfName, fontscale(contentFont, s(1)), contentFont ) - dxDrawText( partOfName, xPos+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) - dxDrawText( partOfName, xPos, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) - xPos = xPos + textLength5 - end - - if useColors then - r, g, b = v[1][1], v[1][2], v[1][3] - end + theX = x - s(3) + end - local partOfName = string.sub( playerName, firstCodePos, secondCodePos ) - local textLength4 = dxGetTextWidth( partOfName, fontscale(contentFont, s(1)), contentFont ) - + if content then + if serverInfo.allowcolorcodes and type( content ) == "table" and column.name == "name" then + local playerName = content[1] + local colorCodes = content[2] + local xPos = topX + theX + + for k = 1, #colorCodes do + local v = colorCodes[k] + local firstCodePos = v[2] + local secondCodePos = colorCodes[k+1] and colorCodes[k+1][2]-1 or #playerName + + if firstCodePos ~= 1 and k == 1 then + local secondPos = firstCodePos-1 + local firstPos = 1 + local partOfName = string.sub( playerName, firstPos, secondPos ) + local textLength5 = dxGetTextWidth( partOfName, fontscale(contentFont, s(1)), contentFont ) dxDrawText( partOfName, xPos+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) dxDrawText( partOfName, xPos, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) - xPos = xPos + textLength4 + xPos = xPos + textLength5 end - elseif type( content ) == "table" and column.name ~= "name" then - if content.type == "image" and content.src then - local itemHeight = dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ) - content.height = content.height or itemHeight - content.width = content.width or itemHeight - local itemWidth = content.height/itemHeight * content.width - - content.color = content.color or tocolor(255,255,255,255) - content.rot = content.rot or 0 - content.rotOffX = content.rotOffX or 0 - content.rotOffY = content.rotOffY or 0 - - dxDrawImage ( topX+theX, y, itemWidth, itemHeight, content.src, content.rot, content.rotOffX, content.rotOffY, content.color, drawOverGUI ) + + if useColors then + r, g, b = v[1][1], v[1][2], v[1][3] end - else - dxDrawText( content, topX+theX+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) - dxDrawText( content, topX+theX, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) + + local partOfName = string.sub( playerName, firstCodePos, secondCodePos ) + local textLength4 = dxGetTextWidth( partOfName, fontscale(contentFont, s(1)), contentFont ) + + dxDrawText( partOfName, xPos+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) + dxDrawText( partOfName, xPos, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) + xPos = xPos + textLength4 end + elseif type( content ) == "table" and column.name ~= "name" then + if content.type == "image" and content.src then + local itemHeight = dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ) + content.height = content.height or itemHeight + content.width = content.width or itemHeight + local itemWidth = content.height/itemHeight * content.width + + content.color = content.color or tocolor(255,255,255,255) + content.rot = content.rot or 0 + content.rotOffX = content.rotOffX or 0 + content.rotOffY = content.rotOffY or 0 + + dxDrawImage ( topX+theX, y, itemWidth, itemHeight, content.src, content.rot, content.rotOffX, content.rotOffY, content.color, drawOverGUI ) + end + else + dxDrawText( content, topX+theX+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) + dxDrawText( content, topX+theX, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) end - x = x + s(column.width + 10) - end - elseif element and isElement( element ) and getElementType( element ) == "player" then - -- Highlight local player's name - if element == localPlayer then - dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), cSelection, drawOverGUI ) end - -- Highlight the the row on which the cursor lies on - if checkCursorOverRow( rtPass, topX+s(5), topX+scoreboardDimensions.width-s(5), y, y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ) ) then - dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), cHighlight, drawOverGUI ) - end - -- Highlight selected row - if selectedRows[element] then - dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), cHighlight, drawOverGUI ) - end - - for key = 1, #scoreboardColumns do - local column = scoreboardColumns[key] - local r, g, b, a = fromcolor(cContent) + x = x + s(column.width + 10) + end + elseif element and isElement( element ) and getElementType( element ) == "player" then + -- Highlight local player's name + if element == localPlayer then + dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), cSelection, drawOverGUI ) + end + -- Highlight the the row on which the cursor lies on + if checkCursorOverRow( rtPass, topX+s(5), topX+scoreboardDimensions.width-s(5), y, y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ) ) then + dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), cHighlight, drawOverGUI ) + end + -- Highlight selected row + if selectedRows[element] then + dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), cHighlight, drawOverGUI ) + end - if not useColors then - r, g, b = 255, 255, 255 - end + for key = 1, columnsCount do + local column = scoreboardColumns[key] + local r, g, b, a = fromcolor(cContent) - local theX = x - local content = scoreboardContent[index][column.name] + if not useColors then + r, g, b = 255, 255, 255 + end - if content and column.name == "name" then + local theX = x + local content = scoreboardContent[index][column.name] - if useColors then - r, g, b = getPlayerNametagColor( element ) - end + if content and column.name == "name" then - if getPlayerTeam( element ) and (showTeams or (serverInfo.forceshowteams and not serverInfo.forcehideteams)) and not serverInfo.forcehideteams then theX = x + s(12) end + if useColors then + r, g, b = getPlayerNametagColor( element ) end - if content then - if serverInfo.allowcolorcodes and type( content ) == "table" and column.name == "name" then - local playerName = content[1] - local colorCodes = content[2] - local xPos = topX + theX - - for k = 1, #colorCodes do - local v = colorCodes[k] - local firstCodePos = v[2] - local secondCodePos = colorCodes[k+1] and colorCodes[k+1][2]-1 or #playerName - - if firstCodePos ~= 1 and k == 1 then - local secondPos = firstCodePos-1 - local firstPos = 1 - local partOfName = string.sub( playerName, firstPos, secondPos ) - local textLength3 = dxGetTextWidth( partOfName, fontscale(contentFont, s(1)), contentFont ) - - dxDrawText( partOfName, xPos+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) - dxDrawText( partOfName, xPos, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) - xPos = xPos + textLength3 - end - - if useColors then - r, g, b = v[1][1], v[1][2], v[1][3] - end + if getPlayerTeam( element ) and (showTeams or (serverInfo.forceshowteams and not serverInfo.forcehideteams)) and not serverInfo.forcehideteams then theX = x + s(12) end + end - local partOfName = string.sub( playerName, firstCodePos, secondCodePos ) - local textLength2 = dxGetTextWidth( partOfName, fontscale(contentFont, s(1)), contentFont ) + if content then + if serverInfo.allowcolorcodes and type( content ) == "table" and column.name == "name" then + local playerName = content[1] + local colorCodes = content[2] + local xPos = topX + theX + + for k = 1, #colorCodes do + local v = colorCodes[k] + local firstCodePos = v[2] + local secondCodePos = colorCodes[k+1] and colorCodes[k+1][2]-1 or #playerName + + if firstCodePos ~= 1 and k == 1 then + local secondPos = firstCodePos-1 + local firstPos = 1 + local partOfName = string.sub( playerName, firstPos, secondPos ) + local textLength3 = dxGetTextWidth( partOfName, fontscale(contentFont, s(1)), contentFont ) dxDrawText( partOfName, xPos+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) dxDrawText( partOfName, xPos, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) - xPos = xPos + textLength2 + xPos = xPos + textLength3 end - elseif column.isImage then - if type(content)=="table" then - if fileExists (content[1]) then - dxDrawImage( topX+theX, y+s(1), (column.imageW or 17)*scoreboardScale, (column.imageH or 11)*scoreboardScale, content[1], 0, 0, 0, cWhite, drawOverGUI ) - dxDrawText( content[2], topX+theX+s(1)+((column.imageW or 17)*scoreboardScale)+2, y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) - dxDrawText( content[2], topX+theX+((column.imageW or 17)*scoreboardScale)+2, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) - else - dxDrawText( content[2], topX+theX+s(1)+(0*scoreboardScale), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) - dxDrawText( content[2], topX+theX+(0*scoreboardScale), y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) + if useColors then + r, g, b = v[1][1], v[1][2], v[1][3] + end + + local partOfName = string.sub( playerName, firstCodePos, secondCodePos ) + local textLength2 = dxGetTextWidth( partOfName, fontscale(contentFont, s(1)), contentFont ) + + dxDrawText( partOfName, xPos+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) + dxDrawText( partOfName, xPos, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) + xPos = xPos + textLength2 + end + + elseif column.isImage then + if type(content)=="table" then + if fileExists (content[1]) then + dxDrawImage( topX+theX, y+s(1), (column.imageW or 17)*scoreboardScale, (column.imageH or 11)*scoreboardScale, content[1], 0, 0, 0, cWhite, drawOverGUI ) + dxDrawText( content[2], topX+theX+s(1)+((column.imageW or 17)*scoreboardScale)+2, y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) + dxDrawText( content[2], topX+theX+((column.imageW or 17)*scoreboardScale)+2, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) + else + dxDrawText( content[2], topX+theX+s(1)+(0*scoreboardScale), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) + dxDrawText( content[2], topX+theX+(0*scoreboardScale), y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) - end - else - if fileExists (content) then - dxDrawImage( topX+theX, y+s(1), column.imageW or 17, column.imageH or 15, content[1], 0, 0, 0, cWhite, drawOverGUI ) end + else + if fileExists (content) then + dxDrawImage( topX+theX, y+s(1), column.imageW or 17, column.imageH or 15, content[1], 0, 0, 0, cWhite, drawOverGUI ) end - elseif type( content ) == "table" and column.name ~= "name" then - if content.type == "image" and content.src then - local itemHeight = dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ) - content.height = content.height or itemHeight - content.width = content.width or itemHeight - local itemWidth = itemHeight/content.height * content.width + end + elseif type( content ) == "table" and column.name ~= "name" then + if content.type == "image" and content.src then + local itemHeight = dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ) + content.height = content.height or itemHeight + content.width = content.width or itemHeight + local itemWidth = itemHeight/content.height * content.width - content.color = content.color or tocolor(255,255,255,255) - content.rot = content.rot or 0 - content.rotOffX = content.rotOffX or 0 - content.rotOffY = content.rotOffY or 0 + content.color = content.color or tocolor(255,255,255,255) + content.rot = content.rot or 0 + content.rotOffX = content.rotOffX or 0 + content.rotOffY = content.rotOffY or 0 - dxDrawImage ( topX+theX, y, itemWidth, itemHeight, content.src, content.rot, content.rotOffX, content.rotOffY, content.color, drawOverGUI ) + dxDrawImage ( topX+theX, y, itemWidth, itemHeight, content.src, content.rot, content.rotOffX, content.rotOffY, content.color, drawOverGUI ) - end - else - dxDrawText( content, topX+theX+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) - dxDrawText( content, topX+theX, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) end + else + dxDrawText( content, topX+theX+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) + dxDrawText( content, topX+theX, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) end - x = x + s(column.width + 10) end + x = x + s(column.width + 10) end - local font = iif( element and isElement( element ) and getElementType( element ) == "team", teamHeaderFont, contentFont ) - y = y + dxGetFontHeight( fontscale(font, scoreboardScale), font ) - index = index + 1 end + local font = iif( element and isElement( element ) and getElementType( element ) == "team", teamHeaderFont, contentFont ) + y = y + dxGetFontHeight( fontscale(font, scoreboardScale), font ) + index = index + 1 end end end