From 1011e0d1e10c6aa93b5fba0fe95d473456e410eb Mon Sep 17 00:00:00 2001 From: EgoMoose Date: Thu, 7 Nov 2024 00:28:44 +0000 Subject: [PATCH] (0.650.0.6500743) --- src/PlayerModulePatched/CameraModule/init.lua | 95 +++++++++++-------- .../CameraModule/init.lua | 95 +++++++++++-------- src/VersionInfo.json | 4 +- wally.toml | 2 +- 4 files changed, 113 insertions(+), 83 deletions(-) diff --git a/src/PlayerModulePatched/CameraModule/init.lua b/src/PlayerModulePatched/CameraModule/init.lua index 80c4a69..64079c8 100644 --- a/src/PlayerModulePatched/CameraModule/init.lua +++ b/src/PlayerModulePatched/CameraModule/init.lua @@ -64,6 +64,9 @@ local UserInputService = game:GetService("UserInputService") local VRService = game:GetService("VRService") local UserGameSettings = UserSettings():GetService("UserGameSettings") +local CommonUtils = script.Parent:WaitForChild("CommonUtils") +local FlagUtil = require(CommonUtils:WaitForChild("FlagUtil")) + -- Static camera utils local CameraUtils = require(script:WaitForChild("CameraUtils")) local CameraInput = require(script:WaitForChild("CameraInput")) @@ -103,6 +106,7 @@ do PlayerScripts:RegisterComputerCameraMovementMode(Enum.ComputerCameraMovementMode.CameraToggle) end +local FFlagUserRespectLegacyCameraOptions = FlagUtil.getUserFlag("UserRespectLegacyCameraOptions") function CameraModule.new() local self = setmetatable({},CameraModule) @@ -142,7 +146,11 @@ function CameraModule.new() end end - self:ActivateCameraController(self:GetCameraControlChoice()) + if FFlagUserRespectLegacyCameraOptions then + self:ActivateCameraController() + else + self:ActivateCameraController(self:GetCameraControlChoice()) + end self:ActivateOcclusionModule(Players.LocalPlayer.DevCameraOcclusionMode) self:OnCurrentCameraChanged() -- Does initializations and makes first camera controller RunService:BindToRenderStep("cameraRenderUpdate", Enum.RenderPriority.Camera.Value, function(dt) self:Update(dt) end) @@ -286,46 +294,43 @@ function CameraModule:ShouldUseVehicleCamera() return isEligibleSubject and isEligibleType and isEligibleOcclusionMode end --- When supplied, legacyCameraType is used and cameraMovementMode is ignored (should be nil anyways) --- Next, if userCameraCreator is passed in, that is used as the cameraCreator -function CameraModule:ActivateCameraController(cameraMovementMode, legacyCameraType: Enum.CameraType?) +function CameraModule:ActivateCameraController(cameraMovementMode, legacyCameraType: Enum.CameraType?) -- remove args with FFlagUserRespectLegacyCameraOptions + if FFlagUserRespectLegacyCameraOptions then + -- legacyCameraType should always be respected + legacyCameraType = (workspace.CurrentCamera :: Camera).CameraType + cameraMovementMode = self:GetCameraMovementModeFromSettings() + end local newCameraCreator = nil - if legacyCameraType~=nil then - --[[ - This function has been passed a CameraType enum value. Some of these map to the use of - the LegacyCamera module, the value "Custom" will be translated to a movementMode enum - value based on Dev and User settings, and "Scriptable" will disable the camera controller. - --]] - + -- Some legacy CameraTypes map to the use of + -- the LegacyCamera module, the value "Custom" will be translated to a movementMode enum + -- value based on Dev and User settings, and "Scriptable" will disable the camera controller. + if (if FFlagUserRespectLegacyCameraOptions then true else legacyCameraType ~= nil) then if legacyCameraType == Enum.CameraType.Scriptable then if self.activeCameraController then self.activeCameraController:Enable(false) self.activeCameraController = nil end return - elseif legacyCameraType == Enum.CameraType.Custom then cameraMovementMode = self:GetCameraMovementModeFromSettings() - elseif legacyCameraType == Enum.CameraType.Track then -- Note: The TrackCamera module was basically an older, less fully-featured -- version of ClassicCamera, no longer actively maintained, but it is re-implemented in -- case a game was dependent on its lack of ClassicCamera's extra functionality. cameraMovementMode = Enum.ComputerCameraMovementMode.Classic - elseif legacyCameraType == Enum.CameraType.Follow then cameraMovementMode = Enum.ComputerCameraMovementMode.Follow - elseif legacyCameraType == Enum.CameraType.Orbital then cameraMovementMode = Enum.ComputerCameraMovementMode.Orbital - - elseif legacyCameraType == Enum.CameraType.Attach or - legacyCameraType == Enum.CameraType.Watch or - legacyCameraType == Enum.CameraType.Fixed then + elseif + legacyCameraType == Enum.CameraType.Attach + or legacyCameraType == Enum.CameraType.Watch + or legacyCameraType == Enum.CameraType.Fixed + then newCameraCreator = LegacyCamera else - warn("CameraScript encountered an unhandled Camera.CameraType value: ",legacyCameraType) + warn("CameraScript encountered an unhandled Camera.CameraType value: ", legacyCameraType) end end @@ -382,12 +387,20 @@ function CameraModule:ActivateCameraController(cameraMovementMode, legacyCameraT end if self.activeCameraController then - if cameraMovementMode~=nil then + if FFlagUserRespectLegacyCameraOptions then + -- These functions can be removed in the future and the logic of managing cameraType/cameraMovementMode should be moved + -- into a higher level class so that activeCameraControllers can be single function. self.activeCameraController:SetCameraMovementMode(cameraMovementMode) - elseif legacyCameraType~=nil then - -- Note that this is only called when legacyCameraType is not a type that -- was convertible to a ComputerCameraMovementMode value, i.e. really only applies to LegacyCamera self.activeCameraController:SetCameraType(legacyCameraType) + else + if cameraMovementMode~=nil then + self.activeCameraController:SetCameraMovementMode(cameraMovementMode) + elseif legacyCameraType~=nil then + -- Note that this is only called when legacyCameraType is not a type that + -- was convertible to a ComputerCameraMovementMode value, i.e. really only applies to LegacyCamera + self.activeCameraController:SetCameraType(legacyCameraType) + end end end end @@ -529,24 +542,26 @@ end -- Formerly getCurrentCameraMode, this function resolves developer and user camera control settings to -- decide which camera control module should be instantiated. The old method of converting redundant enum types -function CameraModule:GetCameraControlChoice() - local player = Players.LocalPlayer - - if player then - if UserInputService:GetLastInputType() == Enum.UserInputType.Touch or UserInputService.TouchEnabled then - -- Touch - if player.DevTouchCameraMode == Enum.DevTouchCameraMovementMode.UserChoice then - return CameraUtils.ConvertCameraModeEnumToStandard( UserGameSettings.TouchCameraMovementMode ) - else - return CameraUtils.ConvertCameraModeEnumToStandard( player.DevTouchCameraMode ) - end - else - -- Computer - if player.DevComputerCameraMode == Enum.DevComputerCameraMovementMode.UserChoice then - local computerMovementMode = CameraUtils.ConvertCameraModeEnumToStandard(UserGameSettings.ComputerCameraMovementMode) - return CameraUtils.ConvertCameraModeEnumToStandard(computerMovementMode) +if not FFlagUserRespectLegacyCameraOptions then + function CameraModule:GetCameraControlChoice() + local player = Players.LocalPlayer + + if player then + if UserInputService:GetLastInputType() == Enum.UserInputType.Touch or UserInputService.TouchEnabled then + -- Touch + if player.DevTouchCameraMode == Enum.DevTouchCameraMovementMode.UserChoice then + return CameraUtils.ConvertCameraModeEnumToStandard( UserGameSettings.TouchCameraMovementMode ) + else + return CameraUtils.ConvertCameraModeEnumToStandard( player.DevTouchCameraMode ) + end else - return CameraUtils.ConvertCameraModeEnumToStandard(player.DevComputerCameraMode) + -- Computer + if player.DevComputerCameraMode == Enum.DevComputerCameraMovementMode.UserChoice then + local computerMovementMode = CameraUtils.ConvertCameraModeEnumToStandard(UserGameSettings.ComputerCameraMovementMode) + return CameraUtils.ConvertCameraModeEnumToStandard(computerMovementMode) + else + return CameraUtils.ConvertCameraModeEnumToStandard(player.DevComputerCameraMode) + end end end end diff --git a/src/PlayerModuleUnpatched/CameraModule/init.lua b/src/PlayerModuleUnpatched/CameraModule/init.lua index 5ceaf2b..35efbcc 100644 --- a/src/PlayerModuleUnpatched/CameraModule/init.lua +++ b/src/PlayerModuleUnpatched/CameraModule/init.lua @@ -52,6 +52,9 @@ local UserInputService = game:GetService("UserInputService") local VRService = game:GetService("VRService") local UserGameSettings = UserSettings():GetService("UserGameSettings") +local CommonUtils = script.Parent:WaitForChild("CommonUtils") +local FlagUtil = require(CommonUtils:WaitForChild("FlagUtil")) + -- Static camera utils local CameraUtils = require(script:WaitForChild("CameraUtils")) local CameraInput = require(script:WaitForChild("CameraInput")) @@ -91,6 +94,7 @@ do PlayerScripts:RegisterComputerCameraMovementMode(Enum.ComputerCameraMovementMode.CameraToggle) end +local FFlagUserRespectLegacyCameraOptions = FlagUtil.getUserFlag("UserRespectLegacyCameraOptions") function CameraModule.new() local self = setmetatable({},CameraModule) @@ -130,7 +134,11 @@ function CameraModule.new() end end - self:ActivateCameraController(self:GetCameraControlChoice()) + if FFlagUserRespectLegacyCameraOptions then + self:ActivateCameraController() + else + self:ActivateCameraController(self:GetCameraControlChoice()) + end self:ActivateOcclusionModule(Players.LocalPlayer.DevCameraOcclusionMode) self:OnCurrentCameraChanged() -- Does initializations and makes first camera controller RunService:BindToRenderStep("cameraRenderUpdate", Enum.RenderPriority.Camera.Value, function(dt) self:Update(dt) end) @@ -274,46 +282,43 @@ function CameraModule:ShouldUseVehicleCamera() return isEligibleSubject and isEligibleType and isEligibleOcclusionMode end --- When supplied, legacyCameraType is used and cameraMovementMode is ignored (should be nil anyways) --- Next, if userCameraCreator is passed in, that is used as the cameraCreator -function CameraModule:ActivateCameraController(cameraMovementMode, legacyCameraType: Enum.CameraType?) +function CameraModule:ActivateCameraController(cameraMovementMode, legacyCameraType: Enum.CameraType?) -- remove args with FFlagUserRespectLegacyCameraOptions + if FFlagUserRespectLegacyCameraOptions then + -- legacyCameraType should always be respected + legacyCameraType = (workspace.CurrentCamera :: Camera).CameraType + cameraMovementMode = self:GetCameraMovementModeFromSettings() + end local newCameraCreator = nil - if legacyCameraType~=nil then - --[[ - This function has been passed a CameraType enum value. Some of these map to the use of - the LegacyCamera module, the value "Custom" will be translated to a movementMode enum - value based on Dev and User settings, and "Scriptable" will disable the camera controller. - --]] - + -- Some legacy CameraTypes map to the use of + -- the LegacyCamera module, the value "Custom" will be translated to a movementMode enum + -- value based on Dev and User settings, and "Scriptable" will disable the camera controller. + if (if FFlagUserRespectLegacyCameraOptions then true else legacyCameraType ~= nil) then if legacyCameraType == Enum.CameraType.Scriptable then if self.activeCameraController then self.activeCameraController:Enable(false) self.activeCameraController = nil end return - elseif legacyCameraType == Enum.CameraType.Custom then cameraMovementMode = self:GetCameraMovementModeFromSettings() - elseif legacyCameraType == Enum.CameraType.Track then -- Note: The TrackCamera module was basically an older, less fully-featured -- version of ClassicCamera, no longer actively maintained, but it is re-implemented in -- case a game was dependent on its lack of ClassicCamera's extra functionality. cameraMovementMode = Enum.ComputerCameraMovementMode.Classic - elseif legacyCameraType == Enum.CameraType.Follow then cameraMovementMode = Enum.ComputerCameraMovementMode.Follow - elseif legacyCameraType == Enum.CameraType.Orbital then cameraMovementMode = Enum.ComputerCameraMovementMode.Orbital - - elseif legacyCameraType == Enum.CameraType.Attach or - legacyCameraType == Enum.CameraType.Watch or - legacyCameraType == Enum.CameraType.Fixed then + elseif + legacyCameraType == Enum.CameraType.Attach + or legacyCameraType == Enum.CameraType.Watch + or legacyCameraType == Enum.CameraType.Fixed + then newCameraCreator = LegacyCamera else - warn("CameraScript encountered an unhandled Camera.CameraType value: ",legacyCameraType) + warn("CameraScript encountered an unhandled Camera.CameraType value: ", legacyCameraType) end end @@ -370,12 +375,20 @@ function CameraModule:ActivateCameraController(cameraMovementMode, legacyCameraT end if self.activeCameraController then - if cameraMovementMode~=nil then + if FFlagUserRespectLegacyCameraOptions then + -- These functions can be removed in the future and the logic of managing cameraType/cameraMovementMode should be moved + -- into a higher level class so that activeCameraControllers can be single function. self.activeCameraController:SetCameraMovementMode(cameraMovementMode) - elseif legacyCameraType~=nil then - -- Note that this is only called when legacyCameraType is not a type that -- was convertible to a ComputerCameraMovementMode value, i.e. really only applies to LegacyCamera self.activeCameraController:SetCameraType(legacyCameraType) + else + if cameraMovementMode~=nil then + self.activeCameraController:SetCameraMovementMode(cameraMovementMode) + elseif legacyCameraType~=nil then + -- Note that this is only called when legacyCameraType is not a type that + -- was convertible to a ComputerCameraMovementMode value, i.e. really only applies to LegacyCamera + self.activeCameraController:SetCameraType(legacyCameraType) + end end end end @@ -517,24 +530,26 @@ end -- Formerly getCurrentCameraMode, this function resolves developer and user camera control settings to -- decide which camera control module should be instantiated. The old method of converting redundant enum types -function CameraModule:GetCameraControlChoice() - local player = Players.LocalPlayer - - if player then - if UserInputService:GetLastInputType() == Enum.UserInputType.Touch or UserInputService.TouchEnabled then - -- Touch - if player.DevTouchCameraMode == Enum.DevTouchCameraMovementMode.UserChoice then - return CameraUtils.ConvertCameraModeEnumToStandard( UserGameSettings.TouchCameraMovementMode ) - else - return CameraUtils.ConvertCameraModeEnumToStandard( player.DevTouchCameraMode ) - end - else - -- Computer - if player.DevComputerCameraMode == Enum.DevComputerCameraMovementMode.UserChoice then - local computerMovementMode = CameraUtils.ConvertCameraModeEnumToStandard(UserGameSettings.ComputerCameraMovementMode) - return CameraUtils.ConvertCameraModeEnumToStandard(computerMovementMode) +if not FFlagUserRespectLegacyCameraOptions then + function CameraModule:GetCameraControlChoice() + local player = Players.LocalPlayer + + if player then + if UserInputService:GetLastInputType() == Enum.UserInputType.Touch or UserInputService.TouchEnabled then + -- Touch + if player.DevTouchCameraMode == Enum.DevTouchCameraMovementMode.UserChoice then + return CameraUtils.ConvertCameraModeEnumToStandard( UserGameSettings.TouchCameraMovementMode ) + else + return CameraUtils.ConvertCameraModeEnumToStandard( player.DevTouchCameraMode ) + end else - return CameraUtils.ConvertCameraModeEnumToStandard(player.DevComputerCameraMode) + -- Computer + if player.DevComputerCameraMode == Enum.DevComputerCameraMovementMode.UserChoice then + local computerMovementMode = CameraUtils.ConvertCameraModeEnumToStandard(UserGameSettings.ComputerCameraMovementMode) + return CameraUtils.ConvertCameraModeEnumToStandard(computerMovementMode) + else + return CameraUtils.ConvertCameraModeEnumToStandard(player.DevComputerCameraMode) + end end end end diff --git a/src/VersionInfo.json b/src/VersionInfo.json index 38467e9..a0010ea 100644 --- a/src/VersionInfo.json +++ b/src/VersionInfo.json @@ -1,4 +1,4 @@ { - "version": "0.649.0.6490878", - "guid": "version-7cc6d2bdac2f4837" + "version": "0.650.0.6500743", + "guid": "version-0fe66fbb77d84a42" } \ No newline at end of file diff --git a/wally.toml b/wally.toml index 16c95f0..eade87e 100644 --- a/wally.toml +++ b/wally.toml @@ -1,6 +1,6 @@ [package] name = "upliftgames/playermodule" -version = "649.0.6490878" +version = "650.0.6500743" registry = "https://github.com/UpliftGames/wally-index" realm = "shared"