Skip to content

Commit

Permalink
Improve scoreboard (FAForever#3633)
Browse files Browse the repository at this point in the history
Adds the share conditions to the scoreboard. Adds tooltip for 
the share condition, explaining what it means. Adds information 
to the share condition tooltip on how to find the remaining 
game options. Adds a tooltip for the map name to include the
map description. The replay ID can be found in the map description.

This last one is a bit unintuitive, but the replay ID is 99% of the time
not relevant information. It would take up UI space if we'd just put 
it there regardless. 

Once the map generator is updated the settings used to generate
the map are set as its map description. That way you can view those
settings in game when required.
  • Loading branch information
Penguin5 authored Dec 28, 2021
1 parent f8f182b commit 50ec4a8
Showing 14 changed files with 181 additions and 42 deletions.
2 changes: 1 addition & 1 deletion loc/CN/strings_db.lua
Original file line number Diff line number Diff line change
@@ -4261,7 +4261,7 @@ gamemain_0000="载入地图中…"
gamemain_0001="正在等待其他玩家…"
gamesel_0000="主持:%s"
gamesel_0001="玩家:%d / %d"
gamesel_0002="地图:%s"
gamesel_0002="%s"
gamesel_0003="主持:%s"
gamesel_0004="玩家:%d / %d"
gamesel_0005="地图:%s"
2 changes: 1 addition & 1 deletion loc/CZ/strings_db.lua
Original file line number Diff line number Diff line change
@@ -4462,7 +4462,7 @@ gamemain_0000="Nahrává se mapa..."
gamemain_0001="Čeká se na další hráče..."
gamesel_0000="Hostitel: %s"
gamesel_0001="Hráči: %d / %d"
gamesel_0002="Mapa: %s"
gamesel_0002="%s"
gamesel_0003="Hostitel: %s"
gamesel_0004="Hráči: %d / %d"
gamesel_0005="Mapa: %s"
2 changes: 1 addition & 1 deletion loc/DE/strings_db.lua
Original file line number Diff line number Diff line change
@@ -4460,7 +4460,7 @@ gamemain_0000="Lade Karte ..."
gamemain_0001="Warte auf andere Spieler ..."
gamesel_0000="Host: %s"
gamesel_0001="Spieler: %d / %d"
gamesel_0002="Karte: %s"
gamesel_0002="%s"
gamesel_0003="Host: %s"
gamesel_0004="Spieler: %d / %d"
gamesel_0005="Karte: %s"
2 changes: 1 addition & 1 deletion loc/ES/strings_db.lua
Original file line number Diff line number Diff line change
@@ -4446,7 +4446,7 @@ gamemain_0000="Cargando mapa..."
gamemain_0001="Esperando a jugadores..."
gamesel_0000="Anfitrión: %s"
gamesel_0001="Jugadores: %d / %d"
gamesel_0002="Mapa: %s"
gamesel_0002="%s"
gamesel_0003="Anfitrión: %s"
gamesel_0004="Jugadores: %d / %d"
gamesel_0005="Mapa: %s"
2 changes: 1 addition & 1 deletion loc/FR/strings_db.lua
Original file line number Diff line number Diff line change
@@ -6912,7 +6912,7 @@ ThelUuthow="Thel-Uuthow"
ZanAishahesh="Zan-Aishahesh"
gamesel_0000="Hôte : %s"
gamesel_0001="Joueurs : %d / %d"
gamesel_0002="Carte : %s"
gamesel_0002="%s"
gamesel_0003="Hôte : %s"
gamesel_0004="Joueurs : %d / %d"
gamesel_0005="Carte : %s"
2 changes: 1 addition & 1 deletion loc/IT/strings_db.lua
Original file line number Diff line number Diff line change
@@ -6927,7 +6927,7 @@ ThelUuthow="Thel-Uuthow"
ZanAishahesh="Zan-Aishahesh"
gamesel_0000="Host: %s"
gamesel_0001="Giocatori: %d / %d"
gamesel_0002="Mappa: %s"
gamesel_0002="%s"
gamesel_0003="Host: %s"
gamesel_0004="Giocatori: %d / %d"
gamesel_0005="Mappa: %s"
2 changes: 1 addition & 1 deletion loc/PL/strings_db.lua
Original file line number Diff line number Diff line change
@@ -4461,7 +4461,7 @@ gamemain_0000="Wczytuję mapę..."
gamemain_0001="Oczekiwanie na pozostałych graczy..."
gamesel_0000="Gospodarz: %s"
gamesel_0001="Gracze: %d / %d"
gamesel_0002="Mapa: %s"
gamesel_0002="%s"
gamesel_0003="Gospodarz: %s"
gamesel_0004="Gracze: %d / %d"
gamesel_0005="Mapa: %s"
2 changes: 1 addition & 1 deletion loc/RU/strings_db.lua
Original file line number Diff line number Diff line change
@@ -4593,7 +4593,7 @@ gamemain_0000="Загрузка карты…"
gamemain_0001="Ожидание игроков…"
gamesel_0000="Сервер: %s"
gamesel_0001="Игроки: %d / %d"
gamesel_0002="Карта: %s"
gamesel_0002="%s"
gamesel_0003="Сервер: %s"
gamesel_0004="Игроки: %d / %d"
gamesel_0005="Карта: %s"
2 changes: 1 addition & 1 deletion loc/TW/strings_db.lua
Original file line number Diff line number Diff line change
@@ -4260,7 +4260,7 @@ gamemain_0000="載入地圖中…"
gamemain_0001="等候其他玩者…"
gamesel_0000="主持:%s"
gamesel_0001="玩者:%d / %d"
gamesel_0002="地圖:%s"
gamesel_0002="%s"
gamesel_0003="主持:%s"
gamesel_0004="玩者:%d / %d"
gamesel_0005="地圖:%s"
2 changes: 1 addition & 1 deletion loc/TZM/strings_db.lua
Original file line number Diff line number Diff line change
@@ -6922,7 +6922,7 @@ ThelUuthow="Thel-Uuthow"
ZanAishahesh="Zan-Aishahesh"
gamesel_0000="Hôte : %s"
gamesel_0001="Joueurs : %d / %d"
gamesel_0002="Carte : %s"
gamesel_0002="%s"
gamesel_0003="Hôte : %s"
gamesel_0004="Joueurs : %d / %d"
gamesel_0005="Carte : %s"
2 changes: 1 addition & 1 deletion loc/US/strings_db.lua
Original file line number Diff line number Diff line change
@@ -3977,7 +3977,7 @@ fmv_timeline_0030="General Samantha Clarke is killed in battle."
gamemain_0001="Waiting For Other Players..."
gamesel_0000="Host: %s"
gamesel_0001="Players: %d / %d"
gamesel_0002="Map: %s"
gamesel_0002="%s"
gamesel_0003="Host: %s"
gamesel_0004="Players: %d / %d"
gamesel_0005="Map: %s"
2 changes: 1 addition & 1 deletion lua/terranunits.lua
Original file line number Diff line number Diff line change
@@ -339,7 +339,7 @@ TTransportBeaconUnit = Class(TransportBeaconUnit) {}
--------------------------------------------------------------
-- WALKING LAND UNITS
--------------------------------------------------------------
TWalkingLandUnit = Class(WalkingLandUnit) {}
TWalkingLandUnit = Class(WalkingLandUnit) { }

--------------------------------------------------------------
-- WALL STRUCTURES
118 changes: 95 additions & 23 deletions lua/ui/game/score.lua
Original file line number Diff line number Diff line change
@@ -234,6 +234,21 @@ local function ResourceClickProcessing(self, event, uiGroup, resType)
end
end

-- table to convert key to LOC value
local ShareNameLookup = { }
ShareNameLookup["FullShare"] = "lobui_0742"
ShareNameLookup["ShareUntilDeath"] = "lobui_0744"
ShareNameLookup["TransferToKiller"] = "lobui_0762"
ShareNameLookup["Defectors"] = "lobui_0766"
ShareNameLookup["CivilianDeserter"] = "lobui_0764"

local ShareDescriptionLookup = { }
ShareDescriptionLookup["FullShare"] = "lobui_0743"
ShareDescriptionLookup["ShareUntilDeath"] = "lobui_0745"
ShareDescriptionLookup["TransferToKiller"] = "lobui_0763"
ShareDescriptionLookup["Defectors"] = "lobui_0767"
ShareDescriptionLookup["CivilianDeserter"] = "lobui_0765"

function SetupPlayerLines()
local function CreateArmyLine(data, armyIndex)
local group = Group(controls.bgStretch)
@@ -412,28 +427,68 @@ function SetupPlayerLines()
observerLine.speedSlider:SetValue(gameSpeed)
end

-- data = {
-- ShareConditionsTitle :: String
-- ShareConditionsDescription :: String
-- Size :: String
-- MapTitle :: String
-- MapDescription :: String
-- }

local function CreateMapNameLine(data)
local group = Group(controls.bgStretch)

group.name = UIUtil.CreateText(group, data.mapname, 10, UIUtil.bodyFont)
group.name:DisableHitTest()
LayoutHelpers.AtLeftIn(group.name, group)
LayoutHelpers.AtVerticalCenterIn(group.name, group)
group.name:SetColor('ffffffff')
local offset = 0
local previous = false

if sessionInfo.Options.Ranked then
group.ranked = Bitmap(group)
group.ranked:SetTexture("/textures/ui/powerlobby/rankedscore.dds")
LayoutHelpers.SetDimensions(group.ranked, 16, 16)
group.ranked:DisableHitTest()
LayoutHelpers.AtRightTopIn(group.ranked, group, -1)
local function AddDash()
local dash = UIUtil.CreateText(group, " - ", 10, UIUtil.bodyFont)
LayoutHelpers.RightOf(dash, previous)
LayoutHelpers.AtVerticalCenterIn(dash, previous)
dash:SetColor('ffffffff')
return dash
end

group.name.Right:Set(group.Right)
group.name:SetClipToWidth(true)
-- ui for share conditions
group.ShareConditions = UIUtil.CreateText(group, data.ShareConditionsTitle, 10, UIUtil.bodyFont)
Tooltip.AddForcedControlTooltipManual(group.ShareConditions, data.ShareConditionsTitle, data.ShareConditionsDescription)
LayoutHelpers.AtLeftIn(group.ShareConditions, group)
LayoutHelpers.AtVerticalCenterIn(group.ShareConditions, group)
group.ShareConditions:SetColor('ffffffff')
previous = group.ShareConditions
previous = AddDash()

-- ui for map name
group.Size = UIUtil.CreateText(group, tostring(data.Size.Width) .. "x" .. tostring(data.Size.Height), 10, UIUtil.bodyFont)
LayoutHelpers.RightOf(group.Size, previous)
LayoutHelpers.AtVerticalCenterIn(group.Size, group)
group.Size:SetColor('ffffffff')
previous = group.Size
previous = AddDash()

-- ui for map name
group.MapName = UIUtil.CreateText(group, data.MapTitle, 10, UIUtil.bodyFont)
Tooltip.AddForcedControlTooltipManual(group.MapName, data.MapTitle, data.MapDescription)
LayoutHelpers.RightOf(group.MapName, previous)
LayoutHelpers.AtVerticalCenterIn(group.MapName, group)
group.MapName:SetColor('ffffffff')
previous = group.MapName

-- ui for ranked icon
local rankedOffset = 32
if data.Ranked then
group.RankedIcon = Bitmap(group)
group.RankedIcon:SetTexture("/textures/ui/powerlobby/rankedscore.dds")
LayoutHelpers.SetDimensions(group.RankedIcon, 16, 16)
LayoutHelpers.AtRightTopIn(group.RankedIcon, group, -1)
rankedOffset = 32
end

-- make it extent and clip text
group.MapName.Right:Set(function() return group.Right() - rankedOffset end)
group.MapName:SetClipToWidth(true)
LayoutHelpers.SetHeight(group, 19)
group.Width:Set(controls.armyGroup.Width)
group:DisableHitTest()

return group
end
@@ -456,18 +511,35 @@ function SetupPlayerLines()
line.name:SetText(playerClan .. playerName .. playerRating)
end

mapData = {}
mapData.Sizekm = {Width = math.floor(sessionInfo.size[1] / 51.2), Height = math.floor(sessionInfo.size[2] / 51.2)}
mapData.mapname = LOCF("<LOC gamesel_0002>Map: %s", sessionInfo.name)..' ('..mapData.Sizekm.Width..' x '..mapData.Sizekm.Height..')'
local replayID = UIUtil.GetReplayId()
if replayID then
mapData.mapname = mapData.mapname..', ID: '..replayID
local mapData = {}

-- add share information to the score board
mapData.ShareConditionsTitle = LOC("<LOC " .. ShareNameLookup[sessionInfo.Options.Share] .. ">")
mapData.ShareConditionsDescription = LOC("<LOC " .. ShareDescriptionLookup[sessionInfo.Options.Share] .. ">")
mapData.ShareConditionsDescription = mapData.ShareConditionsDescription .. "\r\n\r\n" .. LOC("<LOC info_game_settings_dialog>Other game settings can be found in the map information dialog (F12).")

-- add size to the score board
mapData.Size = { Width = math.floor(sessionInfo.size[1] / 51.2), Height = math.floor(sessionInfo.size[2] / 51.2) }

-- add map title / description to the scoreboard
mapData.MapTitle = LOCF("<LOC gamesel_0002>%s", sessionInfo.name)
local description = sessionInfo.description
if not description or description == "" then
description = "No description set by the author."
end

controls.armyLines[index] = CreateMapNameLine(mapData)
-- add replay ID
mapData.MapDescription = LOC(description) .. "\r\n\r\n" .. LOC("<LOC replay_id>Replay ID") .. ": " .. tostring(UIUtil.GetReplayId())

-- add ladder icon
mapData.Ranked = sessionInfo.Options.Ranked or false

-- construct UI elements
local mapUI = CreateMapNameLine(mapData)
controls.armyLines[index] = mapUI

resModeSwitch.icon = UIUtil.CreateText(controls.armyGroup, '⃝', 13, 'Calibri')
resModeSwitch.icon.Depth:Set(resModeSwitch.icon.Depth() + 1)
resModeSwitch.icon.Depth:Set(mapUI.Depth() + 1)
LayoutHelpers.AtLeftTopIn(resModeSwitch.icon, controls.armyLines[table.getn(controls.armyLines) - 1], 0, -1)
LayoutHelpers.AtHorizontalCenterIn(resModeSwitch.icon, controls.armyLines[1].energy)
resModeSwitch.text = UIUtil.CreateText(resModeSwitch.icon, 'I', 10, UIUtil.bodyFont)
@@ -614,7 +686,7 @@ function _OnBeat()
line = data
end
end
LayoutHelpers.Below(resModeSwitch.icon, line.energy, -1)
LayoutHelpers.Below(resModeSwitch.icon, line.energy, 1)
currentScores = false -- dont render score UI until next score update
end

Loading

0 comments on commit 50ec4a8

Please sign in to comment.