@@ -166,6 +166,7 @@ function Camera.followTracker(playerSettings, player, camera, tracker, disableSm
166166 else
167167 camera .centerPos = tracker .centerPos
168168 camera .zoom = Camera .zoom (camera , tracker )
169+ Camera .sanitizeZoom (camera , playerSettings , player )
169170 end
170171
171172 Camera .refreshChartTags (player , camera , captureBox , camera .centerPos , camera .zoom )
@@ -196,19 +197,7 @@ function Camera.followTrackerSmooth(playerSettings, player, camera, tracker)
196197 transitionData .transitionTicksLeft = transitionData .transitionTicksLeft - 1
197198
198199 camera .centerPos , camera .zoom = Camera .CameraTransition .lerp (transitionData )
199-
200- if camera .zoom < minZoom then
201- if playerSettings .noticeMaxZoom == nil then
202- player .print ({ " max-zoom" }, { r = 1 })
203- player .print ({ " msg-once" })
204- playerSettings .noticeMaxZoom = true
205- end
206-
207- camera .zoom = minZoom
208- else
209- -- Max (min actually) zoom is not reached (anymore)
210- playerSettings .noticeMaxZoom = nil
211- end
200+ Camera .sanitizeZoom (camera , playerSettings , player )
212201
213202 if transitionData .transitionTicksLeft <= 0 then
214203 -- Transition finished
@@ -241,6 +230,25 @@ function Camera.zoom(camera, tracker)
241230 return math.min (zoomX , zoomY , maxZoom )
242231end
243232
233+ -- Check if the camera zoom is valid
234+ --- @param camera Camera.camera
235+ --- @param playerSettings playerSettings
236+ --- @param player LuaPlayer
237+ function Camera .sanitizeZoom (camera , playerSettings , player )
238+ if camera .zoom < minZoom then
239+ if playerSettings .noticeMaxZoom == nil then
240+ player .print ({ " max-zoom" }, { r = 1 })
241+ player .print ({ " msg-once" })
242+ playerSettings .noticeMaxZoom = true
243+ end
244+
245+ camera .zoom = minZoom
246+ else
247+ -- Max (min actually) zoom is not reached (anymore)
248+ playerSettings .noticeMaxZoom = nil
249+ end
250+ end
251+
244252--- @param camera Camera.camera
245253--- @param activeTracker Tracker.tracker
246254function Camera .getScreenshotInterval (camera , activeTracker )
@@ -254,7 +262,12 @@ function Camera.getScreenshotInterval(camera, activeTracker)
254262 return camera .screenshotInterval
255263end
256264
257- function Camera .setWidth (camera , width )
265+ -- Set the camera (resolution) width
266+ --- @param playerSettings playerSettings
267+ --- @param player LuaPlayer
268+ --- @param camera Camera.camera
269+ --- @param width any Camera (resolution ) width
270+ function Camera .setWidth (playerSettings , player , camera , width )
258271 width = tonumber (width )
259272
260273 if width == nil or width < 320 then
@@ -268,13 +281,17 @@ function Camera.setWidth(camera, width)
268281 local _ , activeTracker = Tracker .findActiveTracker (camera .trackers , camera .surfaceName )
269282 if activeTracker ~= nil then
270283 -- Force update zoom level to make sure the tracked area stays the same
271- --- @diagnostic disable-next-line : param-type-mismatch player (Data ) can be nil when disableSmooth is true
272- Camera .followTracker (nil , nil , camera , activeTracker , true )
284+ Camera .followTracker (playerSettings , player , camera , activeTracker , true )
273285 end
274286 end
275287end
276288
277- function Camera .setHeight (camera , height )
289+ -- Set the camera (resolution) height
290+ --- @param playerSettings playerSettings
291+ --- @param player LuaPlayer
292+ --- @param camera Camera.camera
293+ --- @param height any Camera (resolution ) height
294+ function Camera .setHeight (playerSettings , player , camera , height )
278295 height = tonumber (height )
279296
280297 if height == nil or height < 240 then
@@ -288,8 +305,7 @@ function Camera.setHeight(camera, height)
288305 local _ , activeTracker = Tracker .findActiveTracker (camera .trackers , camera .surfaceName )
289306 if activeTracker ~= nil then
290307 -- Force update zoom level to make sure the tracked area stays the same
291- --- @diagnostic disable-next-line : param-type-mismatch player (Data ) can be nil when disableSmooth is true
292- Camera .followTracker (nil , nil , camera , activeTracker , true )
308+ Camera .followTracker (playerSettings , player , camera , activeTracker , true )
293309 end
294310 end
295311end
0 commit comments