Skip to content

Commit

Permalink
Display game version information to the user (FAForever#6403)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas authored Aug 9, 2024
1 parent 9b7492f commit 7f5ce74
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 34 deletions.
38 changes: 28 additions & 10 deletions lua/globalInit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,32 @@ end

-- Inform the developer that a Lua environment is created
local version, gametype, commit = import("/lua/version.lua").GetVersionData()
SPEW(
string.format(
"Lua environment initialized with game version %s, game type %s and at commit hash %s",
version,
gametype,
commit
local trace = debug.traceback():lower()
if trace:find("siminit.lua") then
SPEW(
string.format(
"Lua sim environment initialized with game version %s, game type %s and at commit hash %s",
version,
gametype,
commit
)
)
)

-- Helps the developer understand the type of environment created
SPEW(debug.traceback())
elseif trace:find("sessioninit.lua") then
SPEW(
string.format(
"Lua session environment initialized with game version %s, game type %s and at commit hash %s",
version,
gametype,
commit
)
)
elseif trace:find("userinit.lua") then
SPEW(
string.format(
"Lua user environment initialized with game version %s, game type %s and at commit hash %s",
version,
gametype,
commit
)
)
end
6 changes: 5 additions & 1 deletion lua/ui/game/score.lua
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,13 @@ function SetupPlayerLines()
end

-- add replay ID
local version, gametype, commit = import("/lua/version.lua").GetVersionData()

mapData.MapDescription = LOC(description) ..
"\r\n\r\n" .. LOC("<LOC map_version>Map version") .. ": " .. tostring(sessionInfo.map_version) ..
"\r\n" .. LOC("<LOC replay_id>Replay ID") .. ": " .. tostring(UIUtil.GetReplayId())
"\r\n" .. LOC("<LOC replay_id>Replay ID") .. ": " .. tostring(UIUtil.GetReplayId()) ..
"\r\n" ..
"\r\n" .. "Game version: " .. version .. "\r\n" .. "Game type: " .. gametype .. "\r\n" .. "Commit: " .. commit

-- add ladder icon
mapData.Ranked = sessionInfo.Options.Ranked or false
Expand Down
40 changes: 20 additions & 20 deletions lua/ui/game/tooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ local mouseoverDisplay = false
local createThread = false

-- creates a tooltip box from ID table and with optional parameters
-- @param ID table e.g. { text = 'tooltip header', body = 'tooltip description' }
-- @param extended boolean indicates whether to just create tooltip header or also tooltip description
-- @param width number is optional width of tooltip or it is auto calculated based on length of header/description
-- @param forced boolean determine if the tooltip should override hiding tooltips set in game options
-- @param padding number is optional space between tooltip description text and border of tooltip
-- @param descFontSize number is optional font size for description text of tooltip
-- @param textFontSize number is optional font size for header text of tooltip
-- @param position string is optional string indicating position of tooltip relative to its parent: left, right, center (default)
---@param ID table e.g. { text = 'tooltip header', body = 'tooltip description' }
---@param extended? boolean indicates whether to just create tooltip header or also tooltip description
---@param width? number is optional width of tooltip or it is auto calculated based on length of header/description
---@param forced? boolean determine if the tooltip should override hiding tooltips set in game options
---@param padding? number is optional space between tooltip description text and border of tooltip
---@param descFontSize? number is optional font size for description text of tooltip
---@param textFontSize? number is optional font size for header text of tooltip
---@param position? string is optional string indicating position of tooltip relative to its parent: left, right, center (default)
function CreateMouseoverDisplay(parent, ID, delay, extended, width, forced, padding, descFontSize, textFontSize, position)

-- values used throughout the function
Expand Down Expand Up @@ -186,12 +186,12 @@ function CreateToolTip(parent, text)
end

-- creates a tooltip box with title text and/or description and with optional parameters
-- @param text string displayed in header of tooltip
-- @param desc string displayed in description of tooltip, this text is wrapped into multiple if longer than width
-- @param width number is optional width of tooltip or it is auto calculated based on length of header/description
-- @param padding is optional space between tooltip description text and border of tooltip
-- @param descFontSize number is optional font size for description text of tooltip
-- @param textFontSize number is optional font size for header text of tooltip
---@param text string displayed in header of tooltip
---@param desc string displayed in description of tooltip, this text is wrapped into multiple if longer than width
---@param width? number is optional width of tooltip or it is auto calculated based on length of header/description
---@param padding? number is optional space between tooltip description text and border of tooltip
---@param descFontSize? number is optional font size for description text of tooltip
---@param textFontSize? number is optional font size for header text of tooltip
function CreateExtendedToolTip(parent, text, desc, width, padding, descFontSize, textFontSize)
text = LOC(text)
desc = LOC(desc)
Expand Down Expand Up @@ -363,12 +363,12 @@ end
-- creates a tooltip box with specified title and description
---@param title string displayed in tooltip header
---@param description string displayed in tooltip body
---@param delay number is optional milliseconds used to delay tooltip popup
---@param width number is optional width of tooltip or it is auto calculated based on length of header/description
---@param padding number is optional space between tooltip description text and border of tooltip
---@param descFontSize number is optional font size for description text of tooltip
---@param textFontSize number is optional font size for header text of tooltip
---@param position string is optional string indicating position of tooltip relative to its parent: left, right, center (default)
---@param delay? number is optional milliseconds used to delay tooltip popup
---@param width? number is optional width of tooltip or it is auto calculated based on length of header/description
---@param padding? number is optional space between tooltip description text and border of tooltip
---@param descFontSize? number is optional font size for description text of tooltip
---@param textFontSize? number is optional font size for header text of tooltip
---@param position? string is optional string indicating position of tooltip relative to its parent: left, right, center (default)
function AddControlTooltipManual(control, title, description, delay, width, padding, descFontSize, textFontSize, position)

if not control.oldHandleEvent then
Expand Down
10 changes: 7 additions & 3 deletions lua/ui/lobby/lobby.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3146,11 +3146,15 @@ function CreateUI(maxPlayers)
GUI.logo = Bitmap(GUI, '/textures/ui/common/scx_menu/lan-game-lobby/logo.dds')
LayoutHelpers.AtLeftTopIn(GUI.logo, GUI, 1, 1)

-- Version texts
local bool ShowPatch = false
GUI.gameVersionText = UIUtil.CreateText(GUI.panel, "Game Patch " .. GameVersion(), 9, UIUtil.bodyFont)
local version, gametype, commit = import("/lua/version.lua").GetVersionData()
GUI.gameVersionText = UIUtil.CreateText(GUI.panel, "Game version " .. version, 9, UIUtil.bodyFont)
GUI.gameVersionText:SetColor('677983')
GUI.gameVersionText:SetDropShadow(true)

Tooltip.AddControlTooltipManual(GUI.gameVersionText, 'Version control', string.format(
'Game version: %s\nGame type: %s\nCommit hash: %s', version, gametype, commit
))

LayoutHelpers.AtLeftTopIn(GUI.gameVersionText, GUI.panel, 70, 3)

-- Player Slots
Expand Down

0 comments on commit 7f5ce74

Please sign in to comment.