Skip to content

Commit

Permalink
Show player divisions in scoreboard (FAForever#6160)
Browse files Browse the repository at this point in the history
## Description of the proposed changes
Show the division of players in the scoreboard instead of rating if
available (i.e. in matchmaker games)
Closes FAForever#4258 

## Testing done on the proposed changes
Tested them on a matchmaker replay, as well as a normal game to make
sure that the rating still shows up when no divisions are available.

The missing space between division and subdivision is because the added
space in the game options is not present in current replays. This is
just an artefact of the testing process and will be fixed once the
release happened.


![grafik](https://github.com/FAForever/fa/assets/52536103/023f29d1-29fd-4cb9-952d-d136b9f5d86b)


## Checklist

- [x] Changes are annotated, including comments where useful
- [x] Changes are documented in the changelog for the next game version
  • Loading branch information
BlackYps authored Jun 30, 2024
1 parent 7d1e965 commit 2e2b822
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/snippets/features.6160.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#6160) Show the division of players in the scoreboard instead of rating in matchmaker games
13 changes: 12 additions & 1 deletion lua/ui/game/score.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ local created = false

function updatePlayerName(line)
local playerName = line.name:GetText()
local playerDivision = sessionInfo.Options.Divisions[playerName]
local playerRating = sessionInfo.Options.Ratings[playerName] or 0
local playerClan = sessionInfo.Options.ClanTags[playerName]

Expand All @@ -55,11 +56,21 @@ function updatePlayerName(line)
playerClan = ""
end

if playerDivision then
playerDivision = ' [' .. (playerDivision:gsub("^.", string.upper)) .. ']'
else
playerDivision = ""
end

if playerRating then
playerRating = ' [' .. math.floor(playerRating+0.5) .. ']'
end

line.name:SetText(playerClan .. playerName .. playerRating)
if sessionInfo.Options.Divisions then
line.name:SetText(playerClan .. playerName .. playerDivision)
else
line.name:SetText(playerClan .. playerName .. playerRating)
end
end

function armyGroupHeight()
Expand Down
8 changes: 7 additions & 1 deletion lua/ui/lobby/autolobby.lua
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,13 @@ local function CheckForLaunch()
for k,v in gameInfo.PlayerOptions do
if v.Human and v.PL then
allRatings[v.PlayerName] = v.PL
allDivisions[v.PlayerName]= v.DIV .. v.SUBDIV
if v.DIV ~= "unlisted" then
local divisiontext = v.DIV
if v.SUBDIV and v.SUBDIV ~="" then
divisiontext = divisiontext .. ' ' .. v.SUBDIV
end
allDivisions[v.PlayerName]= divisiontext
end
-- Initialize peer launch statuses
peerLaunchStatuses[v.OwnerID] = false
end
Expand Down

0 comments on commit 2e2b822

Please sign in to comment.