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
14 changes: 14 additions & 0 deletions language/en/interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,11 @@
"file": "File",
"author": "Author",
"islocal": "local",
"isrml": "rml",
"iserror": "error",
"category": {
"changed": "Changed",
"local": "Your own",
"all": "All",
"interface": "Interface",
"commands": "Commands",
Expand Down Expand Up @@ -750,8 +754,16 @@
"enabledonly": "Enabled only",
"byorder": "By load order",
"total": "total",
"defaulton": "default enabled",
"defaultoff": "default disabled",
"profiler": "Cost",
"byload": "By cost",
"alldesc": "Every widget the game knows about, whether it is running or not.",
"changeddesc": "Every widget switched to something other than what it ships as - on when it ships off, or off when it ships on. What this game has been customised into, and exactly what Factory defaults would undo.",
"prefixdesc": "Widgets whose file begins with %{prefix}.",
"otherdesc": "Widgets whose file begins with something this panel has no category for.",
"countsdesc": "The count reads how many are running out of how many there are.",
"localdesc": "The widgets in your own LuaUI folder rather than the ones the game ships. They carry a local tag on the row too.",
"localonlydesc": "Show only the widgets in your own LuaUI folder, leaving out the ones the game ships.",
"enabledonlydesc": "Show only the widgets the config says to load - running or not - so what is off stays out of the way.",
"byorderdesc": "Order the list the way the widgets load, which is the order their call-ins run in. Anything not running has no place in that order and follows at the end.",
Expand All @@ -761,6 +773,8 @@
"loadsetdesc": "Switches on every widget in the chosen set and switches off everything else, so the list ends up exactly as the set describes it.",
"order": "Load order",
"cleardata": "Reset",
"showdata": "Show data",
"close": "Close",
"cleardatatitle": "Clear saved settings",
"cleardatawarn": "Throws away everything %{name} has saved - its options, its window position, whatever it remembers - and it starts again from its defaults. Nothing else in the list is touched.",
"cleardatarestartwarn": "Throws away everything %{name} has saved - its options, its window position, whatever it remembers. It is running, so it is switched off and on again to start from its defaults. Nothing else in the list is touched.",
Expand Down
111 changes: 2 additions & 109 deletions luarules/gadgets/game_quick_start.lua
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,7 @@ local function getCommanderBuildQueue(commanderID)
generateOverlapLines(commanderID)
end

Spring.Echo(string.format("=== Validating Build Queue for Commander %d (Team %d) ===", commanderID, comData.teamID))

for i, cmd in ipairs(commands) do
for _, cmd in ipairs(commands) do
if isBuildCommand(cmd.id) then
local unitDefID = -cmd.id
local spawnParams = {
Expand All @@ -394,7 +392,6 @@ local function getCommanderBuildQueue(commanderID)
cmdTag = cmd.tag,
}
local unitDef = unitDefs[unitDefID]
local unitDefName = unitDef and unitDef.name or "UNKNOWN"
local distance = distance2d(comData.spawnX, comData.spawnZ, spawnParams.x, spawnParams.z)
local isTraversable = traversabilityGrid.canMoveToPosition(
commanderID,
Expand All @@ -410,14 +407,6 @@ local function getCommanderBuildQueue(commanderID)
comData.overlapLines
)

local validationResults = {
distanceCheck = distance <= INSTANT_BUILD_RANGE,
traversableCheck = isTraversable,
notPastLinesCheck = not isPastFriendlyLines,
distance = distance,
maxDistance = INSTANT_BUILD_RANGE,
}

if distance <= INSTANT_BUILD_RANGE and isTraversable and not isPastFriendlyLines then
local budgetCost = defMetergies[unitDefID] or 0

Expand All @@ -437,62 +426,17 @@ local function getCommanderBuildQueue(commanderID)

totalBudgetCost = totalBudgetCost + budgetCost
if totalBudgetCost > comData.budget then
Spring.Echo(
string.format(
" [%d] %s at (%.1f, %.1f, %.1f) facing: %d - REJECTED (Budget exceeded: %.1f > %.1f)",
i,
unitDefName,
spawnParams.x,
spawnParams.y,
spawnParams.z,
spawnParams.facing,
totalBudgetCost,
comData.budget
)
)
comData.commandsToRemove = commandsToRemove
return spawnQueue
end

if cmd.tag then
table.insert(commandsToRemove, cmd.tag)
end
else
local failReasons = {}
if not validationResults.distanceCheck then
table.insert(
failReasons,
string.format(
"OutOfRange(%.1f > %.1f)",
validationResults.distance,
validationResults.maxDistance
)
)
end
if not validationResults.traversableCheck then
table.insert(failReasons, "NotTraversable")
end
if not validationResults.notPastLinesCheck then
table.insert(failReasons, "PastFriendlyLines")
end
local failReasonsStr = table.concat(failReasons, ", ")
Spring.Echo(
string.format(
" [%d] %s at (%.1f, %.1f, %.1f) facing: %d - REJECTED (%s)",
i,
unitDefName,
spawnParams.x,
spawnParams.y,
spawnParams.z,
spawnParams.facing,
failReasonsStr
)
)
end
end
end
comData.commandsToRemove = commandsToRemove
Spring.Echo(string.format("=== Accepted %d/%d build queue items ===", #spawnQueue, #commands))
return spawnQueue
end

Expand Down Expand Up @@ -890,22 +834,11 @@ end

local function tryToSpawnBuild(commanderID, unitDefID, buildX, buildY, buildZ, facing)
local unitDef, comData = unitDefs[unitDefID], commanders[commanderID]
local unitDefName = unitDef and unitDef.name or "UNKNOWN"
local discount = getFactoryDiscount(unitDef, commanderID)
local cost = defMetergies[unitDefID] - discount

local unitID = spCreateUnit(unitDef.name, buildX, buildY, buildZ, facing, comData.teamID)
if not unitID then
Spring.Echo(
string.format(
" SPAWN FAILED: %s at (%.1f, %.1f, %.1f) facing: %d - CreateUnit returned nil (terrain/collision conflict)",
unitDefName,
buildX,
buildY,
buildZ,
facing
)
)
return false, nil
end

Expand Down Expand Up @@ -959,19 +892,13 @@ function gadget:GameFrame(frame)
break
end
local loop = modOptions.quick_start ~= "factory_discount_only"
if loop and gameFrameTryCount == 1 then
Spring.Echo("=== Beginning Quick Start Spawn Phase ===")
end
while loop do
loop = false
for commanderID, comData in pairs(commanders) do
if comData.spawnQueue then
for i, buildItem in ipairs(comData.spawnQueue) do
for _, buildItem in ipairs(comData.spawnQueue) do
local buildType = optionDefIDToTypes[buildItem.id]
local unitDef = unitDefs[buildItem.id]
local unitDefName = unitDef and unitDef.name or "UNKNOWN"
local buildX, buildY, buildZ = buildItem.x, buildItem.y, buildItem.z
local hadCoordinates = buildX and buildY and buildZ
if not buildX or not buildZ or not buildY then
buildX, buildY, buildZ = getBuildSpace(commanderID, buildType)
end
Expand All @@ -981,40 +908,6 @@ function gadget:GameFrame(frame)
if success then
loop = true
end
else
local failReasons = {}
if not buildItem.id then
table.insert(failReasons, "NoUnitDefID")
end
if not buildX then
table.insert(
failReasons,
hadCoordinates and "InvalidCoordinates" or "NoBuildSpaceAvailable"
)
end
if comData.budget <= 0 then
table.insert(failReasons, "NoBudget")
end
if #failReasons > 0 then
local failReasonsStr = table.concat(failReasons, ", ")
local coordsStr = buildItem.x
and string.format(
"(%.1f, %.1f, %.1f)",
buildItem.x,
buildItem.y or 0,
buildItem.z
)
or "(no coords)"
Spring.Echo(
string.format(
" SPAWN SKIPPED: %s at %s facing: %d - %s",
unitDefName,
coordsStr,
facing,
failReasonsStr
)
)
end
end
end
end
Expand Down
12 changes: 10 additions & 2 deletions luaui/Include/keybind_dropdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@
local inset = floor((y2 - y1) * 0.3)

Selector(x1, y1, x2, y2)
if mx >= x1 and mx <= x2 and my >= y1 and my <= y2 then
-- A control with nothing to choose from does not light under the cursor. Lighting is
-- what tells a player something will happen when they press, and here nothing will.
if not self.disabled and mx >= x1 and mx <= x2 and my >= y1 and my <= y2 then

Check warning on line 132 in luaui/Include/keybind_dropdown.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

undefined-field

Undefined field `disabled`.
Highlight(x1, y1, x2, y2, floor(WG.FlowUI.elementCorner * 0.66), controlHoverOpacity, white)
end

Expand All @@ -137,7 +139,7 @@
local arrowH = floor((y2 - y1) * 0.16)
local arrowX = x2 - inset - arrowH
local arrowY = floor((y1 + y2) * 0.5 + arrowH * 0.5)
gl.Color(1, 1, 1, self.open and 0.9 or 0.55)
gl.Color(1, 1, 1, self.disabled and 0.25 or (self.open and 0.9 or 0.55))

Check warning on line 142 in luaui/Include/keybind_dropdown.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

undefined-field

Undefined field `disabled`.
chevronX, chevronY, chevronH = arrowX, arrowY, arrowH
gl.BeginEnd(GL.TRIANGLES, chevronVertices)
gl.Color(1, 1, 1, 1)
Expand Down Expand Up @@ -195,6 +197,12 @@
end

function Dropdown:mousePress(x, y)
if self.disabled then

Check warning on line 200 in luaui/Include/keybind_dropdown.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

undefined-field

Undefined field `disabled`.
self.open = false

return false
end

if self.open then
for i, r in ipairs(self.optRects) do
if x >= r.x1 and x <= r.x2 and y >= r.y1 and y <= r.y2 then
Expand Down
15 changes: 13 additions & 2 deletions luaui/Include/keybind_editor_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2165,8 +2165,15 @@ end
-- `grab` does - this chunk is at Lua's ceiling of 200 locals.
local function categoryRect(i)
local top = sidebarTop() - (i - 1 - hover.cat) * metrics.catRowHeight
-- The right edge gives way to the bar when there is one. Without that an entry runs
-- under it and its hover plate disappears beneath the bar rather than stopping beside
-- it. The page count is worked out inline: this chunk is at Lua's 200.
local right = area.x1 + sidebarW
if #categories > math.max(1, floor((sidebarTop() - listBottom()) / metrics.catRowHeight)) then
right = right - metrics.catInset - metrics.catBarW - metrics.catInset
end

return area.x1, top - metrics.catRowHeight, area.x1 + sidebarW, top
return area.x1, top - metrics.catRowHeight, right, top
end

-- Scrolls the category column by `delta` entries and answers how far it can be scrolled
Expand Down Expand Up @@ -2316,7 +2323,11 @@ local function drawSidebar(hoverIdx)
local bx2 = area.x1 + sidebarW - metrics.catInset
Scroller(
bx2 - metrics.catBarW,
listBottom(),
-- Over the entries rather than the whole card: the last row rarely lands exactly on
-- the bottom, and a bar running past it reads as dead space at the foot of the column
-- - and its thumb then says more fits than does.
sidebarTop()
- math.max(1, floor((sidebarTop() - listBottom()) / metrics.catRowHeight)) * metrics.catRowHeight,
bx2,
sidebarTop(),
#categories * metrics.catRowHeight,
Expand Down
24 changes: 17 additions & 7 deletions luaui/Widgets/gui_changelog_info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,24 @@ local function sidebarTop()
return listTop - metrics.sidebarDrop
end

-- How many entries the column has room for, and how far it can be scrolled.
local function catPageRows()
return mathMax(1, mathFloor((sidebarTop() - listBottom) / metrics.catRowHeight))
end

-- `i` is the entry's place in `versions`, not its place on screen: the two differ by
-- however far the column is scrolled.
local function categoryRect(i)
local top = sidebarTop() - (i - 1 - catScroll) * metrics.catRowHeight
-- The right edge gives way to the bar when there is one. Without that the count reads
-- right up against it and the hover plate runs underneath it, which looks like the
-- plate is behind the bar rather than the bar being beside the row.
local right = area.x1 + metrics.sidebarW
if #versions > catPageRows() then
right = right - metrics.catInset - metrics.catBarW - metrics.catInset
end

return area.x1, top - metrics.catRowHeight, area.x1 + metrics.sidebarW, top
return area.x1, top - metrics.catRowHeight, right, top
end

-- The month entry under x,y, or nil. Half-open on the shared edge, so one point never
Expand All @@ -432,11 +444,6 @@ local function sidebarIndexAt(x, y)
return i
end

-- How many entries the column has room for, and how far it can be scrolled.
local function catPageRows()
return mathMax(1, mathFloor((sidebarTop() - listBottom) / metrics.catRowHeight))
end

local function maxCatScroll()
return mathMax(0, #versions - catPageRows())
end
Expand Down Expand Up @@ -504,9 +511,12 @@ local function drawSidebar()
-- there are more months than the card has room for.
if maxCatScroll() > 0 then
local bx2 = area.x1 + metrics.sidebarW - metrics.catInset
-- Over the entries, not over the whole card: the last row rarely lands exactly on the
-- bottom, and a bar running past it reads as a column with dead space at its foot -
-- and makes the thumb say more fits than does.
UiScroller(
bx2 - metrics.catBarW,
listBottom,
sidebarTop() - catPageRows() * metrics.catRowHeight,
bx2,
sidebarTop(),
#versions * metrics.catRowHeight,
Expand Down
24 changes: 17 additions & 7 deletions luaui/Widgets/gui_gameinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1198,12 +1198,24 @@ local function sidebarTop()
return listTop - metrics.sidebarDrop
end

-- How many entries the column has room for, and how far it can be scrolled.
local function catPageRows()
return mathMax(1, mathFloor((sidebarTop() - listBottom) / metrics.catRowHeight))
end

-- `i` is the entry's place in `categories`, not its place on screen: the two differ by
-- however far the column is scrolled.
local function categoryRect(i)
local top = sidebarTop() - (i - 1 - catScroll) * metrics.catRowHeight
-- The right edge gives way to the bar when there is one. Without that the count reads
-- right up against it and the hover plate runs underneath it, which looks like the
-- plate is behind the bar rather than the bar being beside the row.
local right = area.x1 + metrics.sidebarW
if #categories > catPageRows() then
right = right - metrics.catInset - metrics.catBarW - metrics.catInset
end

return area.x1, top - metrics.catRowHeight, area.x1 + metrics.sidebarW, top
return area.x1, top - metrics.catRowHeight, right, top
end

-- The category entry under x,y, or nil. Half-open on the shared edge, like the rows, so
Expand All @@ -1227,11 +1239,6 @@ local function sidebarIndexAt(x, y)
return i
end

-- How many entries the column has room for, and how far it can be scrolled.
local function catPageRows()
return mathMax(1, mathFloor((sidebarTop() - listBottom) / metrics.catRowHeight))
end

local function maxCatScroll()
return mathMax(0, #categories - catPageRows())
end
Expand Down Expand Up @@ -1789,9 +1796,12 @@ local function drawSidebar()
-- there are more categories than the card has room for.
if maxCatScroll() > 0 then
local bx2 = area.x1 + metrics.sidebarW - metrics.catInset
-- Over the entries, not over the whole card: the last row rarely lands exactly on the
-- bottom, and a bar running past it reads as a column with dead space at its foot -
-- and makes the thumb say more fits than does.
UiScroller(
bx2 - metrics.catBarW,
listBottom,
sidebarTop() - catPageRows() * metrics.catRowHeight,
bx2,
sidebarTop(),
#categories * metrics.catRowHeight,
Expand Down
Loading
Loading