From 6ef77f23d5894c1027f331e81fd217102aeeabf1 Mon Sep 17 00:00:00 2001 From: loveridge Date: Tue, 14 Jan 2025 19:13:48 -0700 Subject: [PATCH] use the engine camera height limiter --- .../Widgets/camera_minimum_height_limiter.lua | 60 ------------------- luaui/Widgets/gui_options.lua | 6 +- 2 files changed, 4 insertions(+), 62 deletions(-) delete mode 100644 luaui/Widgets/camera_minimum_height_limiter.lua diff --git a/luaui/Widgets/camera_minimum_height_limiter.lua b/luaui/Widgets/camera_minimum_height_limiter.lua deleted file mode 100644 index 48967315dd..0000000000 --- a/luaui/Widgets/camera_minimum_height_limiter.lua +++ /dev/null @@ -1,60 +0,0 @@ -function widget:GetInfo() - return { - name = "Camera Minimum Height", - desc = "Prevents you from zooming all the way to the ground, all the way to desired level - configurable in settings", - author = "Damgam", - date = "2022", - license = "GNU GPL, v2 or later", - layer = -3, - enabled = true, - } -end - - - -local defaultDesiredLevel = 300 -local desiredLevel = Spring.GetConfigInt("MinimumCameraHeight", defaultDesiredLevel) -local optionRefresh = 0 -local fastUpdateRate = false -local vsx,vsy = Spring.GetViewGeometry() - -function widget:ViewResize() - vsx,vsy = Spring.GetViewGeometry() -end - -local sec = 0 -function widget:Update(dt) - sec = sec + dt - if sec > (fastUpdateRate and 0.001 or 0.15) then - sec = 0 - if WG['advplayerlist_api'] and WG['advplayerlist_api'].GetLockPlayerID() ~= nil then - return - end - local x,y,z = Spring.GetCameraPosition() - local desc, params = Spring.TraceScreenRay(vsx/2, vsy/2, true) - if params and params[3] then - local dist = math.distance3d(x, y, z, params[1], params[2], params[3]) - fastUpdateRate = dist < (desiredLevel + 200) - if dist < desiredLevel then - local camstate = Spring.GetCameraState() - if camstate.name == "ta" then - if camstate.height < desiredLevel then - camstate.height = desiredLevel - Spring.SetCameraState(camstate, Spring.GetConfigFloat("CameraTransitionTime", 0)) - end - elseif camstate.name == "spring" then - if camstate.dist < desiredLevel then - camstate.dist = desiredLevel - Spring.SetCameraState(camstate, Spring.GetConfigFloat("CameraTransitionTime", 0)) - end - end - end - - optionRefresh = optionRefresh + 1 - if optionRefresh > 20 then - optionRefresh = 0 - desiredLevel = Spring.GetConfigInt("MinimumCameraHeight", defaultDesiredLevel) - end - end - end -end \ No newline at end of file diff --git a/luaui/Widgets/gui_options.lua b/luaui/Widgets/gui_options.lua index abb4d4ad33..575fc03fa6 100644 --- a/luaui/Widgets/gui_options.lua +++ b/luaui/Widgets/gui_options.lua @@ -3093,6 +3093,8 @@ function init() { id = "mincamheight", group = "control", category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N('ui.settings.option.mincamheight'), type = "slider", min = 0, max = 1500, step = 1, value = Spring.GetConfigInt("MinimumCameraHeight", 300), description = Spring.I18N('ui.settings.option.mincamheight_descr'), onchange = function(i, value) Spring.SetConfigInt("MinimumCameraHeight", value) + Spring.SetConfigInt("CamSpringMinZoomDistance", value) + Spring.SetConfigInt("OverheadMinZoomDistance", value) end, }, { id = "camerashake", group = "control", category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N('ui.settings.option.camerashake'), type = "slider", min = 0, max = 200, step = 10, value = 80, description = Spring.I18N('ui.settings.option.camerashake_descr'), @@ -3789,7 +3791,7 @@ function init() }, --{ id = "highlightselunits", group = "ui", category = types.basic, widget = "Highlight Selected Units GL4", name = Spring.I18N('ui.settings.option.highlightselunits'), type = "bool", value = GetWidgetToggleValue("Highlight Selected Units GL4"), description = Spring.I18N('ui.settings.option.highlightselunits_descr') }, - + { id = "highlightselunits", group = "ui", category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N('ui.settings.option.highlightselunits'), type = "bool", value = true, description = Spring.I18N('ui.settings.option.selectedunits_teamcoloropacity_descr'), onload = function(i) loadWidgetData("Selected Units GL4", "highlightselunits", { 'selectionHighlight' }) @@ -3816,7 +3818,7 @@ function init() --}, -- { id = "highlightunit", group = "ui", category = types.advanced, widget = "Highlight Unit GL4", name = Spring.I18N('ui.settings.option.highlightunit'), type = "bool", value = GetWidgetToggleValue("Highlight Unit GL4"), description = Spring.I18N('ui.settings.option.highlightunit_descr') }, - + { id = "highlightunit", group = "ui", category = types.advanced, name = widgetOptionColor .. " " .. Spring.I18N('ui.settings.option.highlightunit'), type = "bool", value = true, description = Spring.I18N('ui.settings.option.highlightunit_descr'), onload = function(i) loadWidgetData("Selected Units GL4", "highlightunit", { 'mouseoverHighlight' })