Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions language/en/interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,10 @@
"smartselect_includebuildings_descr": "When rectangle-drag-selecting an area, include building units too?\n\nDisabled: non-mobile units will be excluded (hold Shift to override)\nNote: Construction Turrets will always be selected",
"smartselect_includebuilders": "include builders (if above is off)",
"smartselect_includebuilders_descr": "When rectangle-drag-selecting an area, exclude builder units (hold Shift to override)",
"smartselect_includeradar": "include radar units (if above is off)",
"smartselect_includeradar_descr": "When rectangle-drag-selecting an area, exclude radar units (hold Shift to override)",
"smartselect_includejammer": "include jammer units (if above is off)",
"smartselect_includejammer_descr": "When rectangle-drag-selecting an area, exclude jammer units (hold Shift to override)",
"onlyfighterspatrol": "Only fighters patrol",
"onlyfighterspatrol_descr": "Only fighters obey a factory's patrol route after leaving airlab.",
"fightersfly": "Set fighters on Fly mode",
Expand Down
19 changes: 18 additions & 1 deletion luaui/Widgets/gui_options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4605,7 +4605,20 @@ function init()
saveOptionValue('SmartSelect', 'smartselect', 'setIncludeBuilders', { 'includeBuilders' }, value)
end,
},

{ id = "smartselect_includeradar", group = "game", category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N('ui.settings.option.smartselect_includeradar'), type = "bool", value = false, description = Spring.I18N('ui.settings.option.smartselect_includeradar_descr'),
onload = function(i)
end,
onchange = function(i, value)
saveOptionValue('SmartSelect', 'smartselect', 'setIncludeRadar', { 'includeRadar' }, value)
end,
},
{ id = "smartselect_includejammer", group = "game", category = types.basic, name = widgetOptionColor .. " " .. Spring.I18N('ui.settings.option.smartselect_includejammer'), type = "bool", value = false, description = Spring.I18N('ui.settings.option.smartselect_includejammer_descr'),
onload = function(i)
end,
onchange = function(i, value)
saveOptionValue('SmartSelect', 'smartselect', 'setIncludeJammer', { 'includeJammer' }, value)
end,
},

{ id = "prioconturrets", group = "game", category = types.basic, widget = "Priority Construction Turrets", name = Spring.I18N('ui.settings.option.prioconturrets'), type = "bool", value = GetWidgetToggleValue("Priority Construction Turrets"), description = Spring.I18N('ui.settings.option.prioconturrets_descr') },

Expand Down Expand Up @@ -6425,9 +6438,13 @@ function init()
if WG['smartselect'] == nil then
options[getOptionByID('smartselect_includebuildings')] = nil
options[getOptionByID('smartselect_includebuilders')] = nil
options[getOptionByID('smartselect_includeradar')] = nil
options[getOptionByID('smartselect_includejammer')] = nil
else
options[getOptionByID('smartselect_includebuildings')].value = WG['smartselect'].getIncludeBuildings()
options[getOptionByID('smartselect_includebuilders')].value = WG['smartselect'].getIncludeBuilders()
options[getOptionByID('smartselect_includeradar')].value = WG['smartselect'].getIncludeRadar()
options[getOptionByID('smartselect_includejammer')].value = WG['smartselect'].getIncludeJammer()
end

if WG['snow'] ~= nil and WG['snow'].getSnowMap ~= nil then
Expand Down
34 changes: 31 additions & 3 deletions luaui/Widgets/unit_smart_select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ local referenceX, referenceY
local selectBuildingsWithMobile = false -- whether to select buildings when mobile units are inside selection rectangle
local includeNanosAsMobile = true
local includeBuilders = false
local includeRadar = false
local includeJammer = false

-- selection modifiers
local mods = {
Expand Down Expand Up @@ -78,6 +80,8 @@ local combatFilter = {}
local builderFilter = {}
local buildingFilter = {}
local mobileFilter = {}
local radarFilter = {}
local jammerFilter = {}
local customFilter = {}

for udid, udef in pairs(UnitDefs) do
Expand All @@ -89,6 +93,8 @@ for udid, udef in pairs(UnitDefs) do
local builder = (udef.canReclaim and udef.reclaimSpeed > 0) or (udef.canResurrect and udef.resurrectSpeed > 0) or (udef.canRepair and udef.repairSpeed > 0) or (udef.buildOptions and udef.buildOptions[1])
local building = (isMobile == false)
local combat = (not builder) and isMobile and (#udef.weapons > 0)
local radar = udef.customParams and udef.customParams.unitgroup == "util" and udef.radarDistance > 0
local jammer = udef.customParams and udef.customParams.unitgroup == "util" and udef.radarDistanceJam > 0

if string.find(udef.name, 'armspid') or string.find(udef.name, 'leginfestor') then
builder = false
Expand All @@ -97,6 +103,8 @@ for udid, udef in pairs(UnitDefs) do
builderFilter[udid] = builder
buildingFilter[udid] = building
mobileFilter[udid] = isMobile
radarFilter[udid] = radar
jammerFilter[udid] = jammer
end

local dualScreen
Expand Down Expand Up @@ -375,7 +383,7 @@ function widget:Update(dt)
uid = mouseSelection[i]
udid = spGetUnitDefID(uid)
if buildingFilter[udid] == false then
if includeBuilders or not builderFilter[udid] then
if (includeBuilders or not builderFilter[udid]) and (includeRadar or not radarFilter[udid]) and (includeJammer or not jammerFilter[udid]) then
tmp[#tmp + 1] = uid
else
tmp2[#tmp2 + 1] = uid
Expand Down Expand Up @@ -592,7 +600,7 @@ function widget:Initialize()
uid = mouseSelection[i]
udid = spGetUnitDefID(uid)
if buildingFilter[udid] == false then
if includeBuilders or not builderFilter[udid] then
if (includeBuilders or not builderFilter[udid]) and (includeRadar or not radarFilter[udid]) and (includeJammer or not jammerFilter[udid]) then
tmp[#tmp + 1] = uid
else
tmp2[#tmp2 + 1] = uid
Expand Down Expand Up @@ -656,6 +664,18 @@ function widget:Initialize()
WG['smartselect'].setIncludeBuilders = function(value)
includeBuilders = value
end
WG['smartselect'].getIncludeRadar = function()
return includeRadar
end
WG['smartselect'].setIncludeRadar = function(value)
includeRadar = value
end
WG['smartselect'].getIncludeJammer = function()
return includeJammer
end
WG['smartselect'].setIncludeJammer = function(value)
includeJammer = value
end

widget:ViewResize()
end
Expand All @@ -664,7 +684,9 @@ function widget:GetConfigData()
return {
selectBuildingsWithMobile = selectBuildingsWithMobile,
includeNanosAsMobile = includeNanosAsMobile,
includeBuilders = includeBuilders
includeBuilders = includeBuilders,
includeRadar = includeRadar,
includeJammer = includeJammer
}
end

Expand All @@ -678,4 +700,10 @@ function widget:SetConfigData(data)
if data.includeBuilders ~= nil then
includeBuilders = data.includeBuilders
end
if data.includeRadar ~= nil then
includeRadar = data.includeRadar
end
if data.includeJammer ~= nil then
includeJammer = data.includeJammer
end
end