mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-30 13:41:23 +00:00
Move camera settings to a menu script
This commit is contained in:
parent
6917384fc1
commit
5b97a93169
5 changed files with 45 additions and 47 deletions
|
@ -13,6 +13,7 @@ GLOBAL: scripts/omw/usehandlers.lua
|
||||||
GLOBAL: scripts/omw/worldeventhandlers.lua
|
GLOBAL: scripts/omw/worldeventhandlers.lua
|
||||||
PLAYER: scripts/omw/mechanics/playercontroller.lua
|
PLAYER: scripts/omw/mechanics/playercontroller.lua
|
||||||
PLAYER: scripts/omw/playercontrols.lua
|
PLAYER: scripts/omw/playercontrols.lua
|
||||||
|
MENU: scripts/omw/camera/settings.lua
|
||||||
PLAYER: scripts/omw/camera/camera.lua
|
PLAYER: scripts/omw/camera/camera.lua
|
||||||
PLAYER: scripts/omw/input/actionbindings.lua
|
PLAYER: scripts/omw/input/actionbindings.lua
|
||||||
PLAYER: scripts/omw/input/smoothmovement.lua
|
PLAYER: scripts/omw/input/smoothmovement.lua
|
||||||
|
|
|
@ -5,6 +5,7 @@ local util = require('openmw.util')
|
||||||
local self = require('openmw.self')
|
local self = require('openmw.self')
|
||||||
local nearby = require('openmw.nearby')
|
local nearby = require('openmw.nearby')
|
||||||
local async = require('openmw.async')
|
local async = require('openmw.async')
|
||||||
|
local storage = require('openmw.storage')
|
||||||
local I = require('openmw.interfaces')
|
local I = require('openmw.interfaces')
|
||||||
|
|
||||||
local Actor = require('openmw.types').Actor
|
local Actor = require('openmw.types').Actor
|
||||||
|
@ -28,7 +29,7 @@ input.registerAction {
|
||||||
defaultValue = 0,
|
defaultValue = 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
local settings = require('scripts.omw.camera.settings').thirdPerson
|
local settings = storage.playerSection('SettingsOMWCameraThirdPerson')
|
||||||
local head_bobbing = require('scripts.omw.camera.head_bobbing')
|
local head_bobbing = require('scripts.omw.camera.head_bobbing')
|
||||||
local third_person = require('scripts.omw.camera.third_person')
|
local third_person = require('scripts.omw.camera.third_person')
|
||||||
local pov_auto_switch = require('scripts.omw.camera.first_person_auto_switch')
|
local pov_auto_switch = require('scripts.omw.camera.first_person_auto_switch')
|
||||||
|
|
|
@ -2,12 +2,13 @@ local camera = require('openmw.camera')
|
||||||
local self = require('openmw.self')
|
local self = require('openmw.self')
|
||||||
local util = require('openmw.util')
|
local util = require('openmw.util')
|
||||||
local async = require('openmw.async')
|
local async = require('openmw.async')
|
||||||
|
local storage = require('openmw.storage')
|
||||||
|
|
||||||
local Actor = require('openmw.types').Actor
|
local Actor = require('openmw.types').Actor
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local settings = require('scripts.omw.camera.settings').headBobbing
|
local settings = storage.playerSection('SettingsOMWCameraHeadBobbing')
|
||||||
|
|
||||||
local doubleStepLength, stepHeight, maxRoll
|
local doubleStepLength, stepHeight, maxRoll
|
||||||
|
|
||||||
|
@ -58,4 +59,3 @@ function M.update(dt, smoothedSpeed)
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,8 @@ local function boolSetting(prefix, key, default)
|
||||||
return {
|
return {
|
||||||
key = key,
|
key = key,
|
||||||
renderer = 'checkbox',
|
renderer = 'checkbox',
|
||||||
name = prefix..key,
|
name = prefix .. key,
|
||||||
description = prefix..key..'Description',
|
description = prefix .. key .. 'Description',
|
||||||
default = default,
|
default = default,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -26,8 +26,8 @@ local function floatSetting(prefix, key, default)
|
||||||
return {
|
return {
|
||||||
key = key,
|
key = key,
|
||||||
renderer = 'number',
|
renderer = 'number',
|
||||||
name = prefix..key,
|
name = prefix .. key,
|
||||||
description = prefix..key..'Description',
|
description = prefix .. key .. 'Description',
|
||||||
default = default,
|
default = default,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -70,33 +70,29 @@ I.Settings.registerGroup({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
local settings = {
|
local thirdPerson = storage.playerSection(thirdPersonGroup)
|
||||||
thirdPerson = storage.playerSection(thirdPersonGroup),
|
local headBobbing = storage.playerSection(headBobbingGroup)
|
||||||
headBobbing = storage.playerSection(headBobbingGroup),
|
|
||||||
}
|
|
||||||
|
|
||||||
local function updateViewOverShoulderDisabled()
|
local function updateViewOverShoulderDisabled()
|
||||||
local shoulderDisabled = not settings.thirdPerson:get('viewOverShoulder')
|
local shoulderDisabled = not thirdPerson:get('viewOverShoulder')
|
||||||
I.Settings.updateRendererArgument(thirdPersonGroup, 'shoulderOffsetX', {disabled = shoulderDisabled})
|
I.Settings.updateRendererArgument(thirdPersonGroup, 'shoulderOffsetX', { disabled = shoulderDisabled })
|
||||||
I.Settings.updateRendererArgument(thirdPersonGroup, 'shoulderOffsetY', {disabled = shoulderDisabled})
|
I.Settings.updateRendererArgument(thirdPersonGroup, 'shoulderOffsetY', { disabled = shoulderDisabled })
|
||||||
I.Settings.updateRendererArgument(thirdPersonGroup, 'autoSwitchShoulder', {disabled = shoulderDisabled})
|
I.Settings.updateRendererArgument(thirdPersonGroup, 'autoSwitchShoulder', { disabled = shoulderDisabled })
|
||||||
I.Settings.updateRendererArgument(thirdPersonGroup, 'zoomOutWhenMoveCoef', {disabled = shoulderDisabled})
|
I.Settings.updateRendererArgument(thirdPersonGroup, 'zoomOutWhenMoveCoef', { disabled = shoulderDisabled })
|
||||||
|
|
||||||
local move360Disabled = not settings.thirdPerson:get('move360')
|
local move360Disabled = not thirdPerson:get('move360')
|
||||||
I.Settings.updateRendererArgument(thirdPersonGroup, 'move360TurnSpeed', {disabled = move360Disabled})
|
I.Settings.updateRendererArgument(thirdPersonGroup, 'move360TurnSpeed', { disabled = move360Disabled })
|
||||||
end
|
end
|
||||||
|
|
||||||
local function updateHeadBobbingDisabled()
|
local function updateHeadBobbingDisabled()
|
||||||
local disabled = not settings.headBobbing:get('enabled')
|
local disabled = not headBobbing:get('enabled')
|
||||||
I.Settings.updateRendererArgument(headBobbingGroup, 'step', {disabled = disabled, min = 1})
|
I.Settings.updateRendererArgument(headBobbingGroup, 'step', { disabled = disabled, min = 1 })
|
||||||
I.Settings.updateRendererArgument(headBobbingGroup, 'height', {disabled = disabled})
|
I.Settings.updateRendererArgument(headBobbingGroup, 'height', { disabled = disabled })
|
||||||
I.Settings.updateRendererArgument(headBobbingGroup, 'roll', {disabled = disabled, min = 0, max = 90})
|
I.Settings.updateRendererArgument(headBobbingGroup, 'roll', { disabled = disabled, min = 0, max = 90 })
|
||||||
end
|
end
|
||||||
|
|
||||||
updateViewOverShoulderDisabled()
|
updateViewOverShoulderDisabled()
|
||||||
updateHeadBobbingDisabled()
|
updateHeadBobbingDisabled()
|
||||||
|
|
||||||
settings.thirdPerson:subscribe(async:callback(updateViewOverShoulderDisabled))
|
thirdPerson:subscribe(async:callback(updateViewOverShoulderDisabled))
|
||||||
settings.headBobbing:subscribe(async:callback(updateHeadBobbingDisabled))
|
headBobbing:subscribe(async:callback(updateHeadBobbingDisabled))
|
||||||
|
|
||||||
return settings
|
|
||||||
|
|
|
@ -3,10 +3,11 @@ local util = require('openmw.util')
|
||||||
local self = require('openmw.self')
|
local self = require('openmw.self')
|
||||||
local nearby = require('openmw.nearby')
|
local nearby = require('openmw.nearby')
|
||||||
local async = require('openmw.async')
|
local async = require('openmw.async')
|
||||||
|
local storage = require('openmw.storage')
|
||||||
|
|
||||||
local Actor = require('openmw.types').Actor
|
local Actor = require('openmw.types').Actor
|
||||||
|
|
||||||
local settings = require('scripts.omw.camera.settings').thirdPerson
|
local settings = storage.playerSection('SettingsOMWCameraThirdPerson')
|
||||||
|
|
||||||
local MODE = camera.MODE
|
local MODE = camera.MODE
|
||||||
local STATE = { RightShoulder = 0, LeftShoulder = 1, Combat = 2, Swimming = 3 }
|
local STATE = { RightShoulder = 0, LeftShoulder = 1, Combat = 2, Swimming = 3 }
|
||||||
|
@ -46,7 +47,7 @@ local state = defaultShoulder
|
||||||
|
|
||||||
local function ray(from, angle, limit)
|
local function ray(from, angle, limit)
|
||||||
local to = from + util.transform.rotateZ(angle) * util.vector3(0, limit, 0)
|
local to = from + util.transform.rotateZ(angle) * util.vector3(0, limit, 0)
|
||||||
local res = nearby.castRay(from, to, {collisionType = camera.getCollisionType()})
|
local res = nearby.castRay(from, to, { collisionType = camera.getCollisionType() })
|
||||||
if res.hit then
|
if res.hit then
|
||||||
return (res.hitPos - from):length()
|
return (res.hitPos - from):length()
|
||||||
else
|
else
|
||||||
|
@ -79,7 +80,7 @@ end
|
||||||
local function calculateDistance(smoothedSpeed)
|
local function calculateDistance(smoothedSpeed)
|
||||||
local smoothedSpeedSqr = smoothedSpeed * smoothedSpeed
|
local smoothedSpeedSqr = smoothedSpeed * smoothedSpeed
|
||||||
return (M.baseDistance + math.max(camera.getPitch(), 0) * 50
|
return (M.baseDistance + math.max(camera.getPitch(), 0) * 50
|
||||||
+ smoothedSpeedSqr / (smoothedSpeedSqr + 300*300) * zoomOutWhenMoveCoef)
|
+ smoothedSpeedSqr / (smoothedSpeedSqr + 300 * 300) * zoomOutWhenMoveCoef)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function updateState()
|
local function updateState()
|
||||||
|
@ -161,4 +162,3 @@ function M.update(dt, smoothedSpeed)
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue