-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathoptions.lua
More file actions
258 lines (236 loc) · 7.49 KB
/
options.lua
File metadata and controls
258 lines (236 loc) · 7.49 KB
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
local AddonName, Addon = ...
local LSM = LibStub("LibSharedMedia-3.0")
function Addon:CleanDB()
IPMTDB = {}
print(Addon.localization.DBCLEANED)
end
function Addon:ToggleDBTooltip(self, show)
if show then
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(Addon.localization.CLEANDBTT, .9, .9, 0, 1, true)
GameTooltip:Show()
else
GameTooltip:Hide()
end
end
function Addon:ToggleKeyRenameTooltip(self, show)
if show then
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(Addon.localization.RNMKEYSTT, .9, .9, 0, 1, true)
GameTooltip:Show()
else
GameTooltip:Hide()
end
end
function Addon:SetScale(value)
IPMTOptions.scale = value
Addon.fMain:SetScale(1 + IPMTOptions.scale / 100)
Addon.fOptions.scale.Text:SetText(Addon.localization.SCALE .. " (" .. (IPMTOptions.scale + 100) .. "%)")
end
function Addon:SetProgressFormat(value)
if IPMTOptions.progress ~= value then
IPMTOptions.progress = value
if not IPMTDungeon.keyActive then
for i, info in ipairs(Addon.frames) do
if info.label == 'progress' or info.label == 'prognosis' then
Addon.fMain[info.label].text:SetText(info.dummy.text[IPMTOptions.progress])
end
end
else
Addon:UpdateProgress()
end
if Addon.season.ShowTimer then
Addon.season:ShowTimer()
end
end
end
function Addon:SetProgressDirection(value)
if IPMTOptions.direction ~= value then
IPMTOptions.direction = value
if IPMTDungeon.keyActive then
Addon:UpdateProgress()
end
end
end
function Addon:SetTimerDirection(value)
if IPMTOptions.timerDir ~= value then
IPMTOptions.timerDir = value
Addon:RenderTimerbar()
end
end
function Addon:SetLimitProgress(value)
if IPMTOptions.limitProgress ~= value then
IPMTOptions.limitProgress = value
if IPMTDungeon.keyActive then
Addon:UpdateProgress()
end
end
end
function Addon:ToggleOptions()
if Addon.opened.options then
Addon:CloseOptions()
else
Addon:ShowOptions()
end
end
function Addon:ToggleMapButton(show)
local icon = LibStub("LibDBIcon-1.0")
Addon.DB.global.minimap.hide = not show
if not Addon.DB.global.minimap.hide then
icon:Show("IPMythicTimer")
else
icon:Hide("IPMythicTimer")
end
end
function Addon:ShowOptions()
if Addon.opened.options then
return
end
Addon.opened.options = true
if Addon.fOptions == nil then
Addon:RenderOptions()
end
Addon.fOptions:Show()
Addon.fMain:Show()
Addon.fMain:SetMovable(true)
Addon.fMain:EnableMouse(true)
Addon:FillDummy(true)
if Addon.season.options and Addon.season.options.ShowOptions then
Addon.season.options:ShowOptions()
end
end
function Addon:CloseOptions()
if not Addon.opened.options then
return
end
Addon.opened.options = false
Addon:CloseThemeEditor()
Addon:CloseImport()
Addon.fMain:SetMovable(false)
Addon.fMain:EnableMouse(false)
if not IPMTDungeon.keyActive then
Addon.fMain:Hide()
end
if IPMTDungeon.deathes and IPMTDungeon.deathes.list == nil or #IPMTDungeon.deathes.list == 0 then
Addon.fMain.deathTimer:Hide()
end
Addon.fMain.timer:EnableMouse(true)
Addon.fMain.deathTimer:EnableMouse(true)
Addon.fMain.bosses:EnableMouse(true)
Addon.fOptions:Hide()
Addon:HideHelp()
Addon:CloseKeyRename()
end
function Addon:InitOptions()
local globalVars = nil
if IPMTOptions ~= nil and IPMTOptions.global then
globalVars = IPMTOptions.global
end
local keysName = nil
if IPMTOptions ~= nil and IPMTOptions.keysName then
keysName = IPMTOptions.keysName
end
local news = nil
if IPMTOptions ~= nil and IPMTOptions.news then
news = IPMTOptions.news
end
IPMTOptions = Addon:CopyObject(Addon.defaultOption, IPMTOptions)
if globalVars ~= nil then
IPMTOptions.global = globalVars
end
if news ~= nil then
IPMTOptions.news = news
end
if keysName ~= nil then
IPMTOptions.keysName = keysName
end
if IPMTTheme[IPMTOptions.theme] == nil then
IPMTOptions.theme = 1
end
end
function Addon:ThemeAction(action)
if action == Addon.THEME_ACTIONS_COPY then
Addon:DuplicateTheme(IPMTTheme[IPMTOptions.theme])
elseif action == Addon.THEME_ACTIONS_IMPORT then
Addon:ShowImport()
elseif action == Addon.THEME_ACTIONS_EXPORT then
Addon:ShowExport()
else
Addon:DuplicateTheme(IPMTTheme[1])
end
end
function Addon:DuplicateTheme(theme, import)
local newTheme = Addon:CopyObject(theme)
local source = Addon.localization.COPY
if import == true then
source = Addon.localization.IMPORT
end
newTheme.name = newTheme.name .. " (" .. source .. ")"
table.insert(IPMTTheme, newTheme)
Addon.fOptions.theme:SelectItem(#IPMTTheme)
end
function Addon:ApplyTheme(themeID)
IPMTOptions.theme = themeID
local theme = IPMTTheme[IPMTOptions.theme]
Addon:ChangeDecor('main', theme.main, true)
for i, info in ipairs(Addon.frames) do
local frame = info.label
local elemInfo = theme.elements[frame]
Addon:MoveElement(frame, nil, true)
if info.canResize then
Addon:SetSize(frame, elemInfo.size.w, elemInfo.size.h)
end
if elemInfo.fontSize ~= nil then
Addon:SetFontSize(frame, elemInfo.fontSize, true)
Addon:SetJustifyH(frame, elemInfo.justifyH, true)
if elemInfo.justifyV then
Addon:SetJustifyV(frame, elemInfo.justifyV, true)
end
if elemInfo.color ~= nil then
if elemInfo.color.r ~= nil then
Addon:SetColor(frame, elemInfo.color, nil, true)
else
Addon:SetColor(frame, elemInfo.color[0], nil, true)
end
end
end
if elemInfo.iconSize then
Addon:SetIconSize(frame, elemInfo.iconSize, true)
end
if elemInfo.hidden then
Addon.fMain[frame]:Hide()
else
Addon.fMain[frame]:Show()
if frame ~= 'timerbar' then
Addon.fMain[frame]:SetBackdropColor(1,1,1, 0)
end
end
end
Addon:SetFont(theme.font, true)
Addon:SetFontStyle(theme.fontStyle, true)
Addon:SetDeathsFontStyle(theme.deaths.fontStyle, true)
for decorID, info in ipairs(theme.decors) do
Addon:RenderDecor(decorID)
end
for decorID = #theme.decors+1, #Addon.fMain.decors do
Addon.fMain.decors[decorID]:Hide()
end
if Addon.opened.themes then
Addon:FillThemeEditor()
end
if Addon.fOptions ~= nil then
Addon.fOptions.removeTheme:ToggleDisabled(IPMTOptions.theme == 1)
end
Addon.themeApplying = false
end
function Addon:RemoveTheme(themeID)
if themeID == 1 then
return
end
table.remove(IPMTTheme, themeID)
Addon.fOptions.theme:SelectItem(1)
end
function Addon:RestoreDefaultTheme()
IPMTTheme[1] = Addon:CopyObject(Addon.theme[1])
Addon.fOptions.theme:SelectItem(1)
end