-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoptions.lua
196 lines (176 loc) · 7.28 KB
/
options.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
local folderName = ...
local cosFix = LibStub("AceAddon-3.0"):GetAddon(folderName)
local dynamicCamLoaded = _G.C_AddOns.IsAddOnLoaded("DynamicCam")
local defaults = {
profile = {
debugOutput = true,
enabled = true,
cvars = {
test_cameraOverShoulder = 1.5,
test_cameraDynamicPitch = 1,
test_cameraDynamicPitchBaseFovPad = 0.7,
test_cameraDynamicPitchBaseFovPadFlying = 0.95,
test_cameraDynamicPitchBaseFovPadDownScale = 1,
}
}
}
local optionsTable = {
type = 'group',
args = {
debugOutput = {
order = 3,
type = 'toggle',
name = "Debug Output",
desc = "Print a message in the chat window when a new factor needs to be defined for a mount or player model.\n",
descStyle = "inline",
width = "full",
get = function() return cosFix.db.profile.debugOutput end,
set = function(_, newValue) cosFix.db.profile.debugOutput = newValue end,
},
-- These settings are only shown when DynamicCam is not loaded.
cvarSettings = {
order = 4,
type = 'group',
name = "Basic camera variables",
hidden = dynamicCamLoaded,
inline = true,
args = {
description = {
order = 1,
type = 'description',
name = "As you are using " .. folderName .. " as a stand alone addon, you can set some basic variables here.\nWe recommend, however, to use " .. folderName .. " as a plugin to DynamicCam which provides a lot more customisation options and camera movement easing.\n",
width = "full",
},
enabled = {
order = 2,
type = 'toggle',
name = "Enable all",
descStyle = "inline",
width = "full",
get = function() return cosFix.db.profile.enabled end,
set = function(_, newValue)
cosFix.db.profile.enabled = newValue
if (newValue) then
cosFix:OnEnable()
else
cosFix:OnDisable()
end
end,
},
test_cameraOverShoulder = {
order = 3,
type = 'range',
name = "Camera Shoulder Offset",
disabled = function() return not cosFix.db.profile.enabled end,
desc = "Moves the camera left or right from your character.",
min = -15,
max = 15,
step = .1,
width = "full",
get = function() return cosFix.db.profile.cvars.test_cameraOverShoulder end,
set = function(_, newValue)
-- If offset changes sign while mounted, we need to update currentModelFactor!
if IsMounted() then
local oldOffset = cosFix.db.profile.cvars.test_cameraOverShoulder
if (oldOffset < 0 and newValue >= 0) or (oldOffset >= 0 and newValue < 0) then
cosFix.currentModelFactor = cosFix:CorrectShoulderOffset()
end
end
cosFix.db.profile.cvars.test_cameraOverShoulder = newValue
cosFix:CosFixSetCVar("test_cameraOverShoulder", newValue)
end,
},
dynamicPitch = {
order = 4,
type = 'group',
name = "DynamicPitch",
disabled = function() return not cosFix.db.profile.enabled end,
inline = true,
args = {
test_cameraDynamicPitchBaseFovPad = {
order = 1,
type = 'range',
name = "BaseFovPad",
desc = "Adjusting how far the camera is pitched up or down. The value of 1.0 disables the setting.",
min = 0,
max = 1,
step = .01,
width = 1.08,
get = function() return cosFix.db.profile.cvars.test_cameraDynamicPitchBaseFovPad end,
set = function(_, newValue)
cosFix.db.profile.cvars.test_cameraDynamicPitchBaseFovPad = newValue
SetCVar("test_cameraDynamicPitch", 1)
SetCVar("test_cameraDynamicPitchBaseFovPad", newValue)
end,
},
test_cameraDynamicPitchBaseFovPadFlying = {
order = 2,
type = 'range',
name = "BaseFovPad (Flying)",
desc = "The same as BaseFovPad for while you are flying.",
min = .01,
max = 1,
step = .01,
width = 1.08,
get = function() return cosFix.db.profile.cvars.test_cameraDynamicPitchBaseFovPadFlying end,
set = function(_, newValue)
cosFix.db.profile.cvars.test_cameraDynamicPitchBaseFovPadFlying = newValue
SetCVar("test_cameraDynamicPitch", 1)
SetCVar("test_cameraDynamicPitchBaseFovPadFlying", newValue)
end,
},
test_cameraDynamicPitchBaseFovPadDownScale = {
order = 3,
type = 'range',
name = "BaseFovPadDownScale",
desc = "A multiplier for how much pitch is applied. Higher values allow the character to be further down the screen.",
min = .0,
max = 1,
step = .01,
width = 1.08,
get = function() return cosFix.db.profile.cvars.test_cameraDynamicPitchBaseFovPadDownScale end,
set = function(_, newValue)
cosFix.db.profile.cvars.test_cameraDynamicPitchBaseFovPadDownScale = newValue
SetCVar("test_cameraDynamicPitch", 1)
SetCVar("test_cameraDynamicPitchBaseFovPadDownScale", newValue)
end,
},
},
},
restoreDefaults = {
order = 5,
type = 'execute',
name = "Restore defaults",
disabled = function() return not cosFix.db.profile.enabled end,
desc = "Restore settings to the preference of the " .. folderName .. " developer.",
width = "full",
func = function()
for variable, value in pairs(defaults.profile.cvars) do
cosFix.db.profile.cvars[variable] = value
end
cosFix:SetVariables()
end,
},
},
},
},
}
function cosFix:InitializeDatabase()
self.db = LibStub("AceDB-3.0"):New("cosFixDB", defaults, true)
end
function cosFix:OpenOptionsMenu()
InterfaceOptionsFrame_OpenToCategory(self.optionsMenu)
InterfaceOptionsFrame_OpenToCategory(self.optionsMenu)
end
function cosFix:OpenSetFactorFrame()
self.setFactorFrame:Show()
end
function cosFix:InitializeOptions()
LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable(folderName, optionsTable)
self.optionsMenu = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(folderName, folderName)
self:RegisterChatCommand(folderName, "OpenOptionsMenu")
self:RegisterChatCommand("cosfix", "OpenOptionsMenu")
self:RegisterChatCommand("cf", "OpenOptionsMenu")
self:RegisterChatCommand("defineOffset", "OpenSetFactorFrame")
self:RegisterChatCommand("cfsf", "OpenSetFactorFrame")
end