Skip to content

Commit

Permalink
playerlist: large playercount scaling corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruwetuin committed Mar 26, 2024
1 parent ead160b commit f8afd83
Showing 1 changed file with 32 additions and 38 deletions.
70 changes: 32 additions & 38 deletions luaui/Widgets/gui_advplayerslist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -571,15 +571,15 @@ function SetModulesPositionX()
else
if mySpecStatus then
if module.spec then
if module.name == 'cpuping' or module.name == 'indent' or module.name == 'rank' or module.name == 'country' or module.name == 'side' or module.name == 'alliance' or module.name == 'id' or module.name == 'name' then
if module.name == 'cpuping' or module.name == 'indent' or module.name == 'rank' or module.name == 'country' or module.name == 'side' or module.name == 'ally' or module.name == 'id' or module.name == 'income' or module.name == 'name' then
pos = pos + (module.width*sizeMult)
else
pos = pos + module.width
end
end
else
if module.play then
if module.name == 'cpuping' or module.name == 'indent' or module.name == 'rank' or module.name == 'country' or module.name == 'side' or module.name == 'alliance' or module.name == 'id' or module.name == 'name' then
if module.name == 'cpuping' or module.name == 'indent' or module.name == 'rank' or module.name == 'country' or module.name == 'side' or module.name == 'ally' or module.name == 'id' or module.name == 'income' or module.name == 'name' then
pos = pos + (module.width*sizeMult)
else
pos = pos + module.width
Expand Down Expand Up @@ -2258,7 +2258,7 @@ function DrawResources(energy, energyStorage, energyShare, energyConversion, met
local barWidth = m_resources.width - paddingLeft - paddingRight
local y1Offset
local y2Offset
local sizeMult = playerScale + ((1-playerScale)*0.5)
local sizeMult = playerScale
if not dead then
y1Offset = 11 * sizeMult
y2Offset = 9 * sizeMult
Expand All @@ -2277,7 +2277,7 @@ function DrawResources(energy, energyStorage, energyShare, energyConversion, met
gl_Texture(pics["resbarPic"])
DrawRect(m_resources.posX + widgetPosX + paddingLeft, posY + y1Offset, m_resources.posX + widgetPosX + paddingLeft + ((barWidth / maxStorage) * metal), posY + y2Offset)

if (barWidth / maxStorage) * metal > 0.8 then
if playerScale >= 0.9 and (barWidth / maxStorage) * metal > 0.8 then
local glowsize = 10
gl_Color(1, 1, 1.2, 0.08)
gl_Texture(pics["barGlowCenterPic"])
Expand Down Expand Up @@ -2321,7 +2321,7 @@ function DrawResources(energy, energyStorage, energyShare, energyConversion, met
gl_Texture(pics["resbarPic"])
DrawRect(m_resources.posX + widgetPosX + paddingLeft, posY + y1Offset, m_resources.posX + widgetPosX + paddingLeft + ((barWidth / maxStorage) * energy), posY + y2Offset)

if (barWidth / maxStorage) * energy > 0.8 then
if playerScale >= 0.9 and (barWidth / maxStorage) * energy > 0.8 then
local glowsize = 10
gl_Color(1, 1, 0.2, 0.08)
gl_Texture(pics["barGlowCenterPic"])
Expand Down Expand Up @@ -2363,28 +2363,24 @@ function DrawResources(energy, energyStorage, energyShare, energyConversion, met
end
end

local function formatRes(number)
if number < 1000 then
return string.format("%d", number)
else
return string.format("%.1fk", number / 1000)
end
end

function DrawIncome(energy, metal, posY, dead)
local fontsize = dead and 4.5 or 8.5
local sizeMult = playerScale + ((1-playerScale)*0.33)
local sizeMult = playerScale + ((1-playerScale)*0.22)
fontsize = fontsize * sizeMult
font:Begin()
if energy > 0 then
font:Print(
'\255\255\255\050' .. string.formatSI(math.floor(energy)),
m_income.posX + widgetPosX + m_income.width - 2,
posY + ((fontsize*0.2)*sizeMult) + (dead and 1 or 0),
fontsize,
"or"
)
font:Print('\255\255\255\050'..formatRes(math.floor(energy)), m_income.posX + widgetPosX + m_income.width - 2, posY + ((fontsize*0.2)*sizeMult) + (dead and 1 or 0), fontsize, "or")
end
if metal > 0 then
font:Print(
'\255\235\235\235' .. string.formatSI(math.floor(metal)),
m_income.posX + widgetPosX + m_income.width - 2,
posY + ((fontsize*1.15)*sizeMult) + (dead and 1 or 0),
fontsize,
"or"
)
font:Print('\255\235\235\235'..formatRes(math.floor(metal)), m_income.posX + widgetPosX + m_income.width - 2, posY + ((fontsize*1.15)*sizeMult) + (dead and 1 or 0), fontsize, "or")
end
font:End()
end
Expand Down Expand Up @@ -2429,7 +2425,7 @@ end
function DrawRankImage(rankImage, posY)
gl_Color(1, 1, 1, 1)
gl_Texture(rankImage)
DrawRect(m_rank.posX + widgetPosX + (3*playerScale), posY + 8 - (7.5*playerScale), m_rank.posX + widgetPosX + (17*playerScale), posY + 8 + (7.5*playerScale))
DrawRect(m_rank.posX + widgetPosX + (3*playerScale), posY + (8*playerScale) - (7.5*playerScale), m_rank.posX + widgetPosX + (17*playerScale), posY + (8*playerScale) + (7.5*playerScale))
end

local function RectQuad(px, py, sx, sy)
Expand Down Expand Up @@ -2462,14 +2458,14 @@ function DrawCountry(country, posY)
if country ~= nil and country ~= "??" and VFS.FileExists(imgDir .. "flags/" .. string.upper(country) .. flagsExt) then
gl_Texture(imgDir .. "flags/" .. string.upper(country) .. flagsExt)
gl_Color(1, 1, 1, 1)
DrawRect(m_country.posX + widgetPosX + (3*playerScale), posY + 8 - ((flagHeight/2)*playerScale), m_country.posX + widgetPosX + (17*playerScale), posY + 8 + ((flagHeight/2)*playerScale))
DrawRect(m_country.posX + widgetPosX + (3*playerScale), posY + (8*playerScale) - ((flagHeight/2)*playerScale), m_country.posX + widgetPosX + (17*playerScale), posY + (8*playerScale) + ((flagHeight/2)*playerScale))
end
end

function DrawDot(posY)
gl_Color(1, 1, 1, 0.70)
gl_Texture(pics["currentPic"])
DrawRect(m_indent.posX + widgetPosX - 1, posY + 3, m_indent.posX + widgetPosX + (7*playerScale), posY + 11)
DrawRect(m_indent.posX + widgetPosX - 1, posY + (3*playerScale), m_indent.posX + widgetPosX + (7*playerScale), posY + (11*playerScale))
end

function DrawCamera(posY, active)
Expand Down Expand Up @@ -2582,8 +2578,8 @@ function DrawName(name, team, posY, dark, playerID, desynced)
else
font2:SetTextColor(0, 0, 0, 0.4)
font2:SetOutlineColor(0, 0, 0, 0.4)
font2:Print(nameText, m_name.posX + widgetPosX + 2 + xPadding, posY + 3, fontsize, "n") -- draws name
font2:Print(nameText, m_name.posX + widgetPosX + 4 + xPadding, posY + 3, fontsize, "n") -- draws name
font2:Print(nameText, m_name.posX + widgetPosX + 2 + xPadding, posY + (3*playerScale), fontsize, "n") -- draws name
font2:Print(nameText, m_name.posX + widgetPosX + 4 + xPadding, posY + (3*playerScale), fontsize, "n") -- draws name
font2:SetOutlineColor(0, 0, 0, 1)
end
if (not mySpecStatus) and anonymousMode ~= "disabled" and playerID ~= myPlayerID then
Expand All @@ -2595,23 +2591,23 @@ function DrawName(name, team, posY, dark, playerID, desynced)
font2:SetOutlineColor(0, 0, 0, 0.4)
font2:SetTextColor(0.45,0.45,0.45,1)
end
font2:Print(nameText, m_name.posX + widgetPosX + 3 + xPadding, posY + 4, fontsize, dark and "o" or "n")
font2:Print(nameText, m_name.posX + widgetPosX + 3 + xPadding, posY + (4*playerScale), fontsize, dark and "o" or "n")

--desynced = playerID == 1
if desynced then
font2:SetTextColor(1,0.45,0.45,1)
font2:Print(Spring.I18N('ui.playersList.desynced'), m_name.posX + widgetPosX + 5 + xPadding + (font2:GetTextWidth(nameText)*14), posY + 5.7 , 8, "o")
font2:Print(Spring.I18N('ui.playersList.desynced'), m_name.posX + widgetPosX + 5 + xPadding + (font2:GetTextWidth(nameText)*14), posY + (5.7*playerScale) , 8, "o")
elseif player[playerID] and not player[playerID].dead and player[playerID].incomeMultiplier and player[playerID].incomeMultiplier > 1 then
font2:SetTextColor(0.5,1,0.5,1)
font2:Print('+'..math.floor((player[playerID].incomeMultiplier-1)*100)..'%', m_name.posX + widgetPosX + 5 + xPadding + (font2:GetTextWidth(nameText)*14), posY + 5.7 , 8, "o")
font2:Print('+'..math.floor((player[playerID].incomeMultiplier-1)*100)..'%', m_name.posX + widgetPosX + 5 + xPadding + (font2:GetTextWidth(nameText)*14), posY + (5.7*playerScale) , 8, "o")
end
font2:End()

if ignored or desynced then
local x = m_name.posX + widgetPosX + 2 + xPadding
local y = posY + 7
local w = font2:GetTextWidth(nameText) * 14 + 2
local h = 2
local y = posY + (7*playerScale)
local w = (font2:GetTextWidth(nameText) * fontsize) + 2
local h = (2*playerScale)
if desynced then
gl_Color(1, 0.2, 0.2, 0.9)
else
Expand Down Expand Up @@ -2663,24 +2659,22 @@ function DrawID(playerID, posY, dark, dead)
if playerID < 10 then
spacer = " "
end
local fontsize = 10
fontsize = fontsize * (playerScale + ((1-playerScale)*0.25))
local fontsize = 9.5 * (playerScale + ((1-playerScale)*0.25))
local deadspace = 0
font:Begin()
if dead then
font:SetTextColor(1, 1, 1, 0.4)
else
font:SetTextColor(1, 1, 1, 0.66)
end
font:Print(spacer .. playerID, m_ID.posX + deadspace + widgetPosX + 4.5, posY + 5, fontsize, "on")
font:Print(spacer .. playerID, m_ID.posX + deadspace + widgetPosX + 4.5, posY + (5.3*playerScale), fontsize, "on")
font:End()
end

function DrawSkill(skill, posY, dark)
local fontsize = 9.5
fontsize = fontsize * (playerScale + ((1-playerScale)*0.25))
local fontsize = 9.5 * (playerScale + ((1-playerScale)*0.25))
font:Begin()
font:Print(skill, m_skill.posX + widgetPosX + m_skill.width - 2, posY + 5.3, fontsize, "or")
font:Print(skill, m_skill.posX + widgetPosX + m_skill.width - 2, posY + (5.3*playerScale), fontsize, "or")
font:End()
end

Expand Down Expand Up @@ -2711,7 +2705,7 @@ function DrawPingCpu(pingLvl, cpuLvl, posY, spec, alpha, cpu, fps)
end
if spec then
font:SetTextColor(grayvalue, grayvalue, grayvalue, 0.87 * alpha * grayvalue)
font:Print(fps, m_cpuping.posX + widgetPosX + (11*specScale), posY + (5.3*specScale), 9*specScale, "ro")
font:Print(fps, m_cpuping.posX + widgetPosX + (11*specScale), posY + (5.3*playerScale), 9*specScale, "ro")
else
font:SetTextColor(grayvalue, grayvalue, grayvalue, alpha * grayvalue)
font:Print(fps, m_cpuping.posX + widgetPosX + (11*playerScale), posY + (5.3*playerScale), 9.5*playerScale, "ro")
Expand Down

0 comments on commit f8afd83

Please sign in to comment.