From de0d6a13fb230d6767a1da58dd0c3527a741f5b2 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Wed, 25 Feb 2026 13:32:39 -0800 Subject: [PATCH 1/6] Annotate GetUnitRolloverInfo --- lua/keymap/selectedinfo.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/keymap/selectedinfo.lua b/lua/keymap/selectedinfo.lua index 60bf802304f..e9ddfad1fbc 100644 --- a/lua/keymap/selectedinfo.lua +++ b/lua/keymap/selectedinfo.lua @@ -26,6 +26,10 @@ local selectionOverlay = { Tooltip = "overlay_selection", } +--- Gets rollover information for the given unit. +--- This replicates `GetRolloverInfo` but for any unit. +---@param unit UserUnit +---@return RolloverInfo function GetUnitRolloverInfo(unit, skipFocus) local info = {} From 091f7df2f5e63ed52cd83042ab982d5d08fcd8db Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Wed, 25 Feb 2026 13:32:55 -0800 Subject: [PATCH 2/6] Remove unnecessary argument --- lua/keymap/selectedinfo.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/keymap/selectedinfo.lua b/lua/keymap/selectedinfo.lua index e9ddfad1fbc..ca083b16e8b 100644 --- a/lua/keymap/selectedinfo.lua +++ b/lua/keymap/selectedinfo.lua @@ -81,7 +81,7 @@ function GetUnitRolloverInfo(unit, skipFocus) info.tacticalSiloMaxStorageCount = missileInfo.tacticalSiloMaxStorageCount info.tacticalSiloStorageCount = missileInfo.tacticalSiloStorageCount - info.customName = unit:GetCustomName(unit) + info.customName = unit:GetCustomName() info.userUnit = unit info.armyIndex = unit:GetArmy() - 1 From 18b27c1934b8c241c82159a1aec9dc072be418e1 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Wed, 25 Feb 2026 13:34:15 -0800 Subject: [PATCH 3/6] Move legacy code to bottom of file --- lua/keymap/selectedinfo.lua | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lua/keymap/selectedinfo.lua b/lua/keymap/selectedinfo.lua index ca083b16e8b..85968c34628 100644 --- a/lua/keymap/selectedinfo.lua +++ b/lua/keymap/selectedinfo.lua @@ -14,18 +14,6 @@ ---@field userUnit? UserUnit ---@field workProgress number - -local Prefs = import("/lua/user/prefs.lua") -local options = Prefs.GetFromCurrentProfile('options') - -local selectionOverlay = { - key = 'selection', - Label = "Selection", - Pref = 'range_RenderSelected', - Type = 3, - Tooltip = "overlay_selection", -} - --- Gets rollover information for the given unit. --- This replicates `GetRolloverInfo` but for any unit. ---@param unit UserUnit @@ -87,3 +75,16 @@ function GetUnitRolloverInfo(unit, skipFocus) return info end + +--#region Backwards compatibility +local Prefs = import("/lua/user/prefs.lua") +local options = Prefs.GetFromCurrentProfile('options') + +local selectionOverlay = { + key = 'selection', + Label = "Selection", + Pref = 'range_RenderSelected', + Type = 3, + Tooltip = "overlay_selection", +} +--#endregion From 1d9db33d2fc25bdfd49e32ffaca125bdd8cfb3ba Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Sun, 1 Mar 2026 12:13:23 -0800 Subject: [PATCH 4/6] Create other.7052.md --- changelog/snippets/other.7052.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/snippets/other.7052.md diff --git a/changelog/snippets/other.7052.md b/changelog/snippets/other.7052.md new file mode 100644 index 00000000000..4b445b1c4e9 --- /dev/null +++ b/changelog/snippets/other.7052.md @@ -0,0 +1 @@ +- (#7052) Clean up code style and add annotations in `SelectedInfo.lua`. From 45fd377a44c6c38f54df1f5b88e93d442922f71a Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Sun, 15 Mar 2026 18:46:37 -0700 Subject: [PATCH 5/6] Fix usage and annotation of `UserUnit:GetCustomName` --- engine/User/UserUnit.lua | 3 ++- lua/keymap/selectedinfo.lua | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/User/UserUnit.lua b/engine/User/UserUnit.lua index dc87cc93ed0..2dd1bba0b4e 100644 --- a/engine/User/UserUnit.lua +++ b/engine/User/UserUnit.lua @@ -138,8 +138,9 @@ function UserUnit:GetCreator() end --- Returns the current custom name, `nil` if none +---@param unit UserUnit ---@return string | nil -function UserUnit:GetCustomName() +function UserUnit:GetCustomName(unit) end --- Returns a table of economy data diff --git a/lua/keymap/selectedinfo.lua b/lua/keymap/selectedinfo.lua index 85968c34628..fa7dde3516d 100644 --- a/lua/keymap/selectedinfo.lua +++ b/lua/keymap/selectedinfo.lua @@ -69,7 +69,7 @@ function GetUnitRolloverInfo(unit, skipFocus) info.tacticalSiloMaxStorageCount = missileInfo.tacticalSiloMaxStorageCount info.tacticalSiloStorageCount = missileInfo.tacticalSiloStorageCount - info.customName = unit:GetCustomName() + info.customName = unit:GetCustomName(unit) info.userUnit = unit info.armyIndex = unit:GetArmy() - 1 From e89af70b1794b3282c9ac839914333134ea728e9 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Sun, 15 Mar 2026 18:49:42 -0700 Subject: [PATCH 6/6] Change param to any Tested with selection:GetCustomName(nil) and sel[1]:GetCustomName(sel[2]) --- engine/User/UserUnit.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/User/UserUnit.lua b/engine/User/UserUnit.lua index 2dd1bba0b4e..472e248bf1c 100644 --- a/engine/User/UserUnit.lua +++ b/engine/User/UserUnit.lua @@ -138,9 +138,9 @@ function UserUnit:GetCreator() end --- Returns the current custom name, `nil` if none ----@param unit UserUnit +---@param filler any ---@return string | nil -function UserUnit:GetCustomName(unit) +function UserUnit:GetCustomName(filler) end --- Returns a table of economy data