Skip to content

Commit

Permalink
settings: presets: disable sensor ranges for lowest/low preset + redu…
Browse files Browse the repository at this point in the history
…ce max number of units where attack ranges is active depending on preset
  • Loading branch information
Ruwetuin committed Mar 23, 2024
1 parent 7b19d79 commit 5016279
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 21 deletions.
4 changes: 4 additions & 0 deletions language/en/interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,8 @@
"advplayerlist_side_descr": "show side/faction icon",
"advplayerlist_skill": "OpenSkill value",
"advplayerlist_skill_descr": "show the player openskill number (used for balancing algorithm)",
"advplayerlist_resources": "resource bars",
"advplayerlist_resources_descr": "displays the energy/metal resource bar values\n(if you have team members)",
"advplayerlist_income": "income values",
"advplayerlist_income_descr": "displays the energy/metal income values\n(if you have team members)",
"advplayerlist_cpuping": "cpu/ping number",
Expand Down Expand Up @@ -1381,6 +1383,8 @@
"attackrange_shiftonly_descr": "Show ranges only when shift is pressed",
"attackrange_cursorunitrange": "cursor hover range",
"attackrange_cursorunitrange_descr": "Show ranges when hovering over a unit",
"attackrange_numrangesmult": "Max units multiplier",
"attackrange_numrangesmult_descr": "Multiplier to the limit of max amount of units it will make attack ranges active for.",
"defrange": "Defense ranges",
"defrange_descr": "Displays range of defenses (enemy and ally)",
"defrange_allyair": "Ally Air",
Expand Down
16 changes: 1 addition & 15 deletions luaui/Widgets/gui_advplayerslist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3045,21 +3045,7 @@ function widget:MousePress(x, y, button)
if i ~= myTeamPlayerID then
clickedPlayerTime = os.clock()
clickedPlayerID = clickedPlayer.id
--local curMapDrawMode = Spring.GetMapDrawMode()
--Spring_SendCommands("specteam " .. player[i].team)
--if lockPlayerID then
-- LockCamera(player[i].ai and nil or i)
--else
-- if not fullView then
-- desiredLosmode = 'los'
-- desiredLosmodeChanged = os.clock()
-- if Spring.GetMapDrawMode() ~= 'los' then
-- Spring.SendCommands("togglelos")
-- end
-- end
--end
--CreateMainList()
--return true
-- handled in Update() after dblclick delay
end
end

Expand Down
19 changes: 13 additions & 6 deletions luaui/Widgets/gui_attackrange_gl4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ end
---------------------------------------------------------------------------------------------------------------------------
local shift_only = false -- only show ranges when shift is held down
local cursor_unit_range = true -- displays the range of the unit at the mouse cursor (if there is one)
local selectionDisableThreshold = 80 -- turns off when selection is above this number
local selectionDisableThreshold = 90 -- turns off when selection is above this number
local selectionDisableThresholdMult = 0.7

---------------------------------------------------------------------------------------------------------------------------
------------------ CONFIGURABLES --------------
Expand Down Expand Up @@ -1084,6 +1085,12 @@ function widget:Initialize()
cursor_unit_range = value
widget:Initialize()
end
WG.attackrange.getNumRangesMult = function()
return selectionDisableThresholdMult
end
WG.attackrange.setNumRangesMult = function(value)
selectionDisableThresholdMult = value
end
end

function widget:Shutdown()
Expand All @@ -1110,7 +1117,7 @@ local function RefreshSelectedUnits()
local newSelUnits = {}
for i, unitID in ipairs(selectedUnits) do
newSelUnits[unitID] = true
if not selUnits[unitID] and selUnitCount < selectionDisableThreshold then
if not selUnits[unitID] and selUnitCount < math.floor(selectionDisableThreshold * selectionDisableThresholdMult) then
AddSelectedUnit(unitID)
end
end
Expand Down Expand Up @@ -1490,7 +1497,7 @@ function widget:GetConfigData()
return {
shift_only = shift_only,
cursor_unit_range = cursor_unit_range,
--colorConfig = colorConfig,
selectionDisableThresholdMult = selectionDisableThresholdMult,
}
end

Expand All @@ -1501,7 +1508,7 @@ function widget:SetConfigData(data)
if data.cursor_unit_range ~= nil then
cursor_unit_range = data.cursor_unit_range
end
--if data.colorConfig ~= nil then
-- colorConfig = data.colorConfig
--end
if data.selectionDisableThresholdMult ~= nil then
selectionDisableThresholdMult = data.selectionDisableThresholdMult
end
end
26 changes: 26 additions & 0 deletions luaui/Widgets/gui_options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1873,6 +1873,8 @@ function init()
shadowslider = 1,
grass = false,
cusgl4 = false,
losrange = false,
attackrange_numrangesmult = 0.3,
},
low = {
bloomdeferred = true,
Expand All @@ -1891,6 +1893,8 @@ function init()
shadowslider = 3,
grass = false,
cusgl4 = true,
losrange = false,
attackrange_numrangesmult = 0.5,
},
medium = {
bloomdeferred = true,
Expand All @@ -1909,6 +1913,8 @@ function init()
shadowslider = 4,
grass = true,
cusgl4 = true,
losrange = true,
attackrange_numrangesmult = 0.7,
},
high = {
bloomdeferred = true,
Expand All @@ -1927,6 +1933,8 @@ function init()
shadowslider = 5,
grass = true,
cusgl4 = true,
losrange = true,
attackrange_numrangesmult = 0.9,
},
ultra = {
bloomdeferred = true,
Expand All @@ -1945,6 +1953,8 @@ function init()
shadowslider = 6,
grass = true,
cusgl4 = true,
losrange = true,
attackrange_numrangesmult = 1,
},
custom = {},
}
Expand Down Expand Up @@ -3471,6 +3481,14 @@ function init()
saveOptionValue('AdvPlayersList', 'advplayerlist_api', 'SetModuleActive', { 'm_active_Table', 'cpuping' }, value, { 'cpuping', value })
end,
},
{ id = "advplayerlist_resources", group = "ui", category = types.dev, name = widgetOptionColor .. " " .. Spring.I18N('ui.settings.option.advplayerlist_resources'), type = "bool", value = true, description = Spring.I18N('ui.settings.option.advplayerlist_resources_descr'),
onload = function(i)
loadWidgetData("AdvPlayersList", "advplayerlist_resources", { 'm_active_Table', 'resources' })
end,
onchange = function(i, value)
saveOptionValue('AdvPlayersList', 'advplayerlist_api', 'SetModuleActive', { 'm_active_Table', 'resources' }, value, { 'resources', value })
end,
},
{ id = "advplayerlist_income", group = "ui", category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N('ui.settings.option.advplayerlist_income'), type = "bool", value = true, description = Spring.I18N('ui.settings.option.advplayerlist_income_descr'),
onload = function(i)
loadWidgetData("AdvPlayersList", "advplayerlist_income", { 'm_active_Table', 'income' })
Expand Down Expand Up @@ -4054,6 +4072,14 @@ function init()
saveOptionValue('Attack Range GL4', 'attackrange', 'setCursorUnitRange', { 'cursor_unit_range' }, value)
end,
},
{ id = "attackrange_numrangesmult", group = "game", category = types.dev, name = Spring.I18N('ui.settings.option.attackrange_numrangesmult'), type = "slider", min = 0.3, max = 1, step = 0.1, value = (WG['attackrange'] ~= nil and WG['attackrange'].getOpacity ~= nil and WG['attackrange'].getNumRangesMult()) or 1, description = Spring.I18N('ui.settings.option.attackrange_numrangesmult_descr'),
onload = function(i)
loadWidgetData("Attack Range GL4", "attackrange_numrangesmult", { 'selectionDisableThresholdMult' })
end,
onchange = function(i, value)
saveOptionValue('Attack Range GL4', 'attackrange', 'setNumRangesMult', { 'selectionDisableThresholdMult' }, value)
end,
},

{ id = "defrange", group = "ui", category = types.basic, widget = "Defense Range", name = Spring.I18N('ui.settings.option.defrange'), type = "bool", value = GetWidgetToggleValue("Defense Range"), description = Spring.I18N('ui.settings.option.defrange_descr') },
{ id = "defrange_allyair", group = "ui", category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N('ui.settings.option.defrange_allyair'), type = "bool", value = (WG['defrange'] ~= nil and WG['defrange'].getAllyAir ~= nil and WG['defrange'].getAllyAir()), description = Spring.I18N('ui.settings.option.defrange_allyair_descr'),
Expand Down

0 comments on commit 5016279

Please sign in to comment.