Skip to content

Commit

Permalink
(0.650.0.6500743)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgoMoose authored and github-actions[bot] committed Nov 7, 2024
1 parent af5f4cf commit 1011e0d
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 83 deletions.
95 changes: 55 additions & 40 deletions src/PlayerModulePatched/CameraModule/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -103,6 +106,7 @@ do
PlayerScripts:RegisterComputerCameraMovementMode(Enum.ComputerCameraMovementMode.CameraToggle)
end

local FFlagUserRespectLegacyCameraOptions = FlagUtil.getUserFlag("UserRespectLegacyCameraOptions")

function CameraModule.new()
local self = setmetatable({},CameraModule)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
95 changes: 55 additions & 40 deletions src/PlayerModuleUnpatched/CameraModule/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -91,6 +94,7 @@ do
PlayerScripts:RegisterComputerCameraMovementMode(Enum.ComputerCameraMovementMode.CameraToggle)
end

local FFlagUserRespectLegacyCameraOptions = FlagUtil.getUserFlag("UserRespectLegacyCameraOptions")

function CameraModule.new()
local self = setmetatable({},CameraModule)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/VersionInfo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "0.649.0.6490878",
"guid": "version-7cc6d2bdac2f4837"
"version": "0.650.0.6500743",
"guid": "version-0fe66fbb77d84a42"
}
2 changes: 1 addition & 1 deletion wally.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down

0 comments on commit 1011e0d

Please sign in to comment.