1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 03:54:40 +00:00
OpenMW/files/data/scripts/omw/camera/settings.lua

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

99 lines
3.4 KiB
Lua
Raw Normal View History

2022-05-14 11:37:32 +00:00
local storage = require('openmw.storage')
local async = require('openmw.async')
local I = require('openmw.interfaces')
I.Settings.registerPage({
2024-01-10 19:32:34 +00:00
key = 'OMWCamera',
l10n = 'OMWCamera',
name = 'Camera',
description = 'settingsPageDescription',
2022-05-14 11:37:32 +00:00
})
local thirdPersonGroup = 'SettingsOMWCameraThirdPerson'
local headBobbingGroup = 'SettingsOMWCameraHeadBobbing'
local function boolSetting(prefix, key, default)
return {
key = key,
renderer = 'checkbox',
2024-01-10 19:32:34 +00:00
name = prefix .. key,
description = prefix .. key .. 'Description',
2022-05-14 11:37:32 +00:00
default = default,
}
end
local function floatSetting(prefix, key, default)
return {
key = key,
renderer = 'number',
2024-01-10 19:32:34 +00:00
name = prefix .. key,
description = prefix .. key .. 'Description',
2022-05-14 11:37:32 +00:00
default = default,
}
end
I.Settings.registerGroup({
key = thirdPersonGroup,
page = 'OMWCamera',
l10n = 'OMWCamera',
name = 'thirdPersonSettings',
permanentStorage = true,
order = 0,
settings = {
boolSetting('', 'viewOverShoulder', false),
2022-05-14 11:37:32 +00:00
floatSetting('', 'shoulderOffsetX', 30),
floatSetting('', 'shoulderOffsetY', -10),
boolSetting('', 'autoSwitchShoulder', false),
2022-05-14 11:37:32 +00:00
floatSetting('', 'zoomOutWhenMoveCoef', 20),
boolSetting('', 'previewIfStandStill', false),
boolSetting('', 'deferredPreviewRotation', false),
boolSetting('', 'ignoreNC', false),
boolSetting('', 'move360', false),
floatSetting('', 'move360TurnSpeed', 5),
boolSetting('', 'slowViewChange', false),
boolSetting('', 'povAutoSwitch', false),
2022-05-14 11:37:32 +00:00
},
})
I.Settings.registerGroup({
key = headBobbingGroup,
page = 'OMWCamera',
l10n = 'OMWCamera',
name = 'headBobbingSettings',
permanentStorage = true,
order = 1,
settings = {
boolSetting('headBobbing_', 'enabled', false),
2022-05-14 11:37:32 +00:00
floatSetting('headBobbing_', 'step', 90),
floatSetting('headBobbing_', 'height', 3),
floatSetting('headBobbing_', 'roll', 0.2),
},
})
2024-01-10 19:32:34 +00:00
local thirdPerson = storage.playerSection(thirdPersonGroup)
local headBobbing = storage.playerSection(headBobbingGroup)
2022-05-14 11:37:32 +00:00
local function updateViewOverShoulderDisabled()
2024-01-10 19:32:34 +00:00
local shoulderDisabled = not thirdPerson:get('viewOverShoulder')
I.Settings.updateRendererArgument(thirdPersonGroup, 'shoulderOffsetX', { disabled = shoulderDisabled })
I.Settings.updateRendererArgument(thirdPersonGroup, 'shoulderOffsetY', { disabled = shoulderDisabled })
I.Settings.updateRendererArgument(thirdPersonGroup, 'autoSwitchShoulder', { disabled = shoulderDisabled })
I.Settings.updateRendererArgument(thirdPersonGroup, 'zoomOutWhenMoveCoef', { disabled = shoulderDisabled })
2024-01-10 19:32:34 +00:00
local move360Disabled = not thirdPerson:get('move360')
I.Settings.updateRendererArgument(thirdPersonGroup, 'move360TurnSpeed', { disabled = move360Disabled })
2022-05-14 11:37:32 +00:00
end
local function updateHeadBobbingDisabled()
2024-01-10 19:32:34 +00:00
local disabled = not headBobbing:get('enabled')
I.Settings.updateRendererArgument(headBobbingGroup, 'step', { disabled = disabled, min = 1 })
I.Settings.updateRendererArgument(headBobbingGroup, 'height', { disabled = disabled })
I.Settings.updateRendererArgument(headBobbingGroup, 'roll', { disabled = disabled, min = 0, max = 90 })
2022-05-14 11:37:32 +00:00
end
updateViewOverShoulderDisabled()
updateHeadBobbingDisabled()
2024-01-10 19:32:34 +00:00
thirdPerson:subscribe(async:callback(updateViewOverShoulderDisabled))
headBobbing:subscribe(async:callback(updateHeadBobbingDisabled))