Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 70 additions & 13 deletions common/configs/keybind_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,6 @@
"label": "commands.patrol",
"alwaysModifier": "shift"
},
{
"action": "wantcloak",
"label": "actions.orders.cloak",
"alwaysModifier": "any"
},
{
"action": "stop",
"label": "commands.stop",
Expand Down Expand Up @@ -285,13 +280,25 @@
"description": "commands.repeat_tooltip"
},
{
"prefix": "trajectory_toggle ",
"label": "actions.unitStates.trajectory",
"members": [
"0",
"1",
"2"
]
"action": "wantcloak",
"label": "actions.orders.cloak",
"description": "commands.wantcloak_tooltip",
"alwaysModifier": "any"
},
{
"action": "trajectory_toggle 0",
"label": "actions.unitStates.trajectoryLow",
"description": "commands.trajectory_toggle_tooltip"
},
{
"action": "trajectory_toggle 1",
"label": "actions.unitStates.trajectoryHigh",
"description": "commands.trajectory_toggle_tooltip"
},
{
"action": "trajectory_toggle 2",
"label": "actions.unitStates.trajectoryAuto",
"description": "commands.trajectory_toggle_tooltip"
},
{
"action": "firestate 0",
Expand Down Expand Up @@ -322,6 +329,51 @@
"action": "movestate 2",
"label": "actions.unitStates.moveRoam",
"description": "commands.movestate_tooltip"
},
{
"action": "idlemode",
"label": "actions.unitStates.idleMode",
"description": "commands.idlemode_tooltip"
},
{
"action": "idlemode 0",
"label": "actions.unitStates.idleModeFly",
"description": "commands.idlemode_tooltip"
},
{
"action": "idlemode 1",
"label": "actions.unitStates.idleModeLand",
"description": "commands.idlemode_tooltip"
},
{
"action": "priority",
"label": "actions.unitStates.buildPriority",
"description": "commands.priority_tooltip"
},
{
"action": "priority 0",
"label": "actions.unitStates.buildPriorityLow",
"description": "commands.priority_tooltip"
},
{
"action": "priority 1",
"label": "actions.unitStates.buildPriorityHigh",
"description": "commands.priority_tooltip"
},
{
"action": "aplandat",
"label": "actions.unitStates.airPlantExit",
"description": "commands.aplandat_tooltip"
},
{
"action": "aplandat 0",
"label": "actions.unitStates.airPlantExitFly",
"description": "commands.aplandat_tooltip"
},
{
"action": "aplandat 1",
"label": "actions.unitStates.airPlantExitLand",
"description": "commands.aplandat_tooltip"
}
]
},
Expand Down Expand Up @@ -509,7 +561,8 @@
},
{
"action": "factoryqueuemode",
"label": "actions.factory.queueMode"
"label": "actions.factory.queueMode",
"description": "commands.factoryqueuemode_tooltip"
},
{
"prefix": "factoryguard ",
Expand Down Expand Up @@ -726,6 +779,10 @@
"action": "unit_stats",
"label": "actions.interfaceDisplay.unitStats"
},
{
"action": "customgameinfo",
"label": "actions.interfaceDisplay.gameInfo"
},
{
"action": "savegame",
"label": "actions.interfaceDisplay.saveGame"
Expand Down
16 changes: 16 additions & 0 deletions common/configs/keybind_defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,10 @@
"keyset": "sc_i",
"action": "unit_stats"
},
{
"keyset": "Ctrl+sc_i",
"action": "customgameinfo"
},
{
"keyset": "sc_j",
"action": "loadunits"
Expand Down Expand Up @@ -2162,6 +2166,10 @@
"keyset": "sc_i",
"action": "unit_stats"
},
{
"keyset": "Ctrl+sc_i",
"action": "customgameinfo"
},
{
"keyset": "sc_j",
"action": "loadunits"
Expand Down Expand Up @@ -4309,6 +4317,10 @@
"keyset": "Any+space",
"action": "unit_stats"
},
{
"keyset": "sc_i",
"action": "customgameinfo"
},
{
"keyset": "Ctrl+Shift+sc_o",
"action": "cameraflip"
Expand Down Expand Up @@ -5996,6 +6008,10 @@
"keyset": "Any+space",
"action": "unit_stats"
},
{
"keyset": "sc_i",
"action": "customgameinfo"
},
{
"keyset": "Ctrl+Shift+sc_o",
"action": "cameraflip"
Expand Down
4 changes: 2 additions & 2 deletions gamedata/icontypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2994,11 +2994,11 @@ local icontypes = {
},
legshot = {
bitmap = "icons/bot_t2_impulse2x.png",
size = 1.60000002,
size = 1.35,
},
babylegshot = {
bitmap = "icons/kbot_t2_shotgun.png",
size = 1.60000002,
size = 1.0,
},
legsnapper = {
bitmap = "icons/corroach_0.9.png",
Expand Down
18 changes: 15 additions & 3 deletions language/en/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,24 @@
"onoffOn": "Turn unit on",
"repeatOff": "Repeat off",
"repeatOn": "Repeat on",
"trajectory": "Trajectory %{n}",
"trajectoryLow": "Trajectory: Low",
"trajectoryHigh": "Trajectory: High",
"trajectoryAuto": "Trajectory: Auto",
"fireHold": "Fire state: Hold fire",
"fireReturn": "Fire state: Return fire",
"fireAtWill": "Fire state: Fire at will",
"moveHold": "Move state: Hold position",
"moveManeuver": "Move state: Maneuver",
"moveRoam": "Move state: Roam"
"moveRoam": "Move state: Roam",
"idleMode": "Toggle aircraft idle mode",
"idleModeFly": "Aircraft idle: Fly",
"idleModeLand": "Aircraft idle: Land",
"buildPriority": "Toggle builder priority",
"buildPriorityLow": "Builder priority: Low",
"buildPriorityHigh": "Builder priority: High",
"airPlantExit": "Toggle air plant exit mode",
"airPlantExitFly": "Air plant exit: Fly",
"airPlantExitLand": "Air plant exit: Land"
},
"controlGroups": {
"select": "Select control group %{n}",
Expand All @@ -185,7 +196,7 @@
"spacingDown": "Decrease build spacing"
},
"factory": {
"queueMode": "Toggle factory repeat mode",
"queueMode": "Toggle factory queue/quota mode",
"loadPreset": "Load factory preset %{n}",
"savePreset": "Save factory preset %{n}",
"showPresets": "Show factory presets",
Expand Down Expand Up @@ -230,6 +241,7 @@
"interfaceDisplay": {
"settings": "Settings",
"unitStats": "Unit stats",
"gameInfo": "Game info",
"saveGame": "Save game",
"screenshot": "Take screenshot",
"firingRange": "Display firing range",
Expand Down
21 changes: 17 additions & 4 deletions language/en/interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,18 @@
"unitCount": "(%{count} units)",
"unitOne": "(1 unit)",
"milestones": "Milestones",
"graph": {
"composition": "Composition",
"compositionDesc": "The team's unit value split by kind over the game, as shares of the whole.",
"foldHint": "Click to fold this team's players away, and again to show them.",
"legendHint": "Click to highlight this team and show its milestones; right-click to hide it.",
"blockHint": "The players of this ally team; each square is one of them.",
"all": "All",
"allHint": "Every team alike, with all their milestones on the chart.",
"waiting": "The first samples arrive after 15 seconds.",
"noData": "Nothing to plot for this stat yet."
},
"milestone": {
"factory": "First factory",
"tech2": "Tech 2",
"tech3": "Tech 3",
"nuke": "First nuke",
Expand All @@ -406,18 +416,21 @@
"combat": "Combat",
"units": "Units",
"composition": "Composition",
"activity": "Activity",
"graphs": "Graphs"
"activity": "Activity"
},
"switch": {
"graphs": "Graphs",
"graphsDesc": "The picked group's stats as charts over the game instead of the table.",
"groupByTeam": "Group by team",
"groupByTeamDesc": "Players under their team, with the team's totals above them. Off, every player is listed in one sorted list.",
"shareOfTeam": "Share of team",
"shareOfTeamDesc": "Every amount as the share of the team's total it makes up, so it shows who carried. Ratios and levels stay as they are.",
"perMinute": "Per minute",
"perMinuteDesc": "Totals divided by the minutes each team was in the game, so a short game or an early exit compares fairly.",
"bars": "Bars",
"barsDesc": "A bar behind every number, scaled to the largest in its column."
"barsDesc": "A bar behind every number, scaled to the largest in its column.",
"milestones": "Milestones",
"milestonesDesc": "The highlighted team's milestones as unit pictures on the chart, every team's when none is highlighted; hover one for what it was."
},
"damage": "Damage",
"damageDealt": "Dealt",
Expand Down
46 changes: 23 additions & 23 deletions luarules/gadgets/api_teamstats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ local BUCKETS = { "army", "air", "sea", "defense", "strategic", "factories", "bu
-- a team finishes and `lost` on every unit it loses; a milestone is kept once per team,
-- or every time when `every` is set. The unit that reached it is stored with it.
local MILESTONES = {
{
key = "factory",
built = function(ud)
return ud.isFactory
end,
},
{
key = "tech2",
built = function(ud)
Expand Down Expand Up @@ -129,6 +123,7 @@ local SAMPLED = {
"teamKillValue",
"comKills",
"comLost",
"actionsPerMinute",
}
local countKey, valueKey = {}, {}
for i = 1, #BUCKETS do
Expand Down Expand Up @@ -377,6 +372,9 @@ local function readLive(teamID, out)
out.energyStorage = storage or 0
out.convCapacity = spGetTeamRulesParam(teamID, "mmCapacity") or 0
out.convUse = spGetTeamRulesParam(teamID, "mmUse") or 0
-- The APM broadcast gadget's last figure for the team, so the rate has a history.
local apm = GG.teamAPM
out.actionsPerMinute = apm and apm[teamID] or 0
---@type number
local active = 0
for unitID, buildSpeed in pairs(builders[teamID]) do
Expand Down Expand Up @@ -612,12 +610,13 @@ local function GetTeamStatsInfo()
}
end

-- For other unsynced gadgets, as globals.
-- For other unsynced gadgets, through the shared table: GG.TeamStats.GetLive(teamID),
-- GetHistory(teamID, from), GetMilestones(teamID), GetInfo(). The same gate applies.
local exports = {
GetTeamStatsLive = GetTeamStatsLive,
GetTeamStatsHistory = GetTeamStatsHistory,
GetTeamStatsMilestones = GetTeamStatsMilestones,
GetTeamStatsInfo = GetTeamStatsInfo,
GetLive = GetTeamStatsLive,
GetHistory = GetTeamStatsHistory,
GetMilestones = GetTeamStatsMilestones,
GetInfo = GetTeamStatsInfo,
}

----------------------------------------------------------------
Expand All @@ -629,16 +628,21 @@ local exports = {
---@diagnostic disable-next-line: undefined-global
local Script = Script

-- A widget takes part by registering globals: `TeamStatsLive(all, frame)` is handed
-- the live values of every team the viewer may see, keyed by team, every LIVE_PERIOD
-- frames for as long as it is registered; `TeamStatsHistoryRequest()` returning
-- { [teamID] = fromIndex } is answered through `TeamStatsHistory(teamID, history)`
-- with the samples from that index on (see GetTeamStatsHistory for the shape), so a
-- caller holding the first n samples asks for what came after them.
-- LuaUI takes part by registering globals (luaui/Widgets/api_teamstats.lua holds them
-- for every widget): `TeamStatsLive(all, frame)` is handed the live values of every
-- team the viewer may see, keyed by team, every LIVE_PERIOD frames for as long as it is
-- registered; `TeamStatsInfo(info)` is handed the layout while it is registered;
-- `TeamStatsHistoryRequest()` returning { [teamID] = fromIndex } is answered through
-- `TeamStatsHistory(teamID, history)` with the samples from that index on (see
-- GetTeamStatsHistory for the shape), so a caller holding the first n samples asks for
-- what came after them.
local function serveLuaUI(frame)
if Script.LuaUI("TeamStatsLive") then
Script.LuaUI.TeamStatsLive(GetTeamStatsLive(), frame)
end
if Script.LuaUI("TeamStatsInfo") then
Script.LuaUI.TeamStatsInfo(GetTeamStatsInfo())
end
if Script.LuaUI("TeamStatsHistoryRequest") and Script.LuaUI("TeamStatsHistory") then
local wanted = Script.LuaUI.TeamStatsHistoryRequest()
if type(wanted) == "table" then
Expand Down Expand Up @@ -683,13 +687,9 @@ function gadget:Initialize()
---@cast unitDefID -?
unitCreated(unitID, unitDefID, Spring.GetUnitTeam(unitID))
end
for name, fn in pairs(exports) do
gadgetHandler:RegisterGlobal(name, fn)
end
GG.TeamStats = exports
end

function gadget:Shutdown()
for name in pairs(exports) do
gadgetHandler:DeregisterGlobal(name)
end
GG.TeamStats = nil
end
7 changes: 7 additions & 0 deletions luarules/gadgets/game_apm_broadcast.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,24 @@ if gadgetHandler:IsSyncedCode() then
totalTeamActions[teamID] = nil
end
else -- unsynced
-- The last figure per team, kept for other unsynced gadgets: the team stats gadget
-- samples it into its history.
local teamAPM = {}

local function handleApmEvent(_, teamID, apm)
teamAPM[teamID] = apm
if Script.LuaUI("ApmEvent") then
Script.LuaUI.ApmEvent(teamID, apm)
end
end

function gadget:Initialize()
GG.teamAPM = teamAPM
gadgetHandler:AddSyncAction("apmBroadcast", handleApmEvent)
end

function gadget:Shutdown()
GG.teamAPM = nil
gadgetHandler:RemoveSyncAction("apmBroadcast")
end
end
Loading
Loading