vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 BINDING_HEADER_QUESTIE = "Questie"
2 BINDING_NAME_QUESTIEOPTIONS = "Open Questie Options"
3 BINDING_NAME_QUESTIETOGGLE = "Toggle Questie On or Off"
4  
5 Questie_Options = AceLibrary("AceAddon-2.0"):new("AceHook-2.1")
6  
7 function Questie_Options:OnInitialize()
8 self:Hook("CloseWindows", true)
9 end
10  
11 function Questie_Options:CloseWindows()
12 local found = self.hooks.CloseWindows()
13 if QuestieOptionsForm:IsVisible() then
14 QuestieOptionsForm:Hide()
15 return 1
16 end
17 return found
18 end
19  
20 local QO_FormName = "QuestieOptionsForm"
21  
22 function Questie:OptionsForm_Init()
23 QO_arrowenabled = getglobal(QO_FormName.."ArrowEnabledCheck")
24 QO_showobjectives = getglobal(QO_FormName.."AlwaysShowObjectivesCheck")
25 QO_boldcolors = getglobal(QO_FormName.."BoldColorsCheck")
26 QO_clusterquests = getglobal(QO_FormName.."ClusterQuestsCheck")
27 QO_corpsearrow = getglobal(QO_FormName.."CorpseArrowCheck")
28 QO_hideminimapicons = getglobal(QO_FormName.."HideMinimapIconsCheck")
29 QO_maxlevelfilter = getglobal(QO_FormName.."MaxLevelFilterCheck")
30 QO_maxshowlevel = getglobal(QO_FormName.."MaxShowLevelSlider")
31 QO_maxshowlevel_current = getglobal(QO_FormName.."MaxShowLevelSlider".."Current")
32 QO_minimapbutton = getglobal(QO_FormName.."MinimapButtonCheck")
33 QO_minlevelfilter = getglobal(QO_FormName.."MinLevelFilterCheck")
34 QO_minshowlevel = getglobal(QO_FormName.."MinShowLevelSlider")
35 QO_minshowlevel_current = getglobal(QO_FormName.."MinShowLevelSlider".."Current")
36 QO_resizeworldmap = getglobal(QO_FormName.."ResizeWorldmapCheck")
37 QO_showmapnotes = getglobal(QO_FormName.."ShowMapNotesCheck")
38 QO_hideobjectives = getglobal(QO_FormName.."HideObjectives")
39 QO_showprofessionquests = getglobal(QO_FormName.."ShowProfessionQuestsCheck")
40 QO_showtooltips = getglobal(QO_FormName.."ShowToolTipsCheck")
41 QO_showtrackerheader = getglobal(QO_FormName.."ShowTrackerHeaderCheck")
42 QO_trackerbackground = getglobal(QO_FormName.."TrackerBackgroundCheck")
43 QO_trackerenabled = getglobal(QO_FormName.."TrackerEnabledCheck")
44 QO_trackerlist = getglobal(QO_FormName.."TrackerListCheck")
45 QO_trackerscale = getglobal(QO_FormName.."TrackerScaleSlider")
46 QO_trackerscale_current = getglobal(QO_FormName.."TrackerScaleSlider".."Current")
47 QO_trackertransparency = getglobal(QO_FormName.."TrackerTransparencySlider")
48 QO_trackertransparency_current = getglobal(QO_FormName.."TrackerTransparencySlider".."Current")
49 QO_usequestlinks = getglobal(QO_FormName.."UseQuestLinksCheck")
50 QO_versionlabel = getglobal(QO_FormName.."VersionLabel".."Label")
51 end
52  
53 function Questie:OptionsForm_Display()
54 Questie:OptionsForm_Init()
55  
56 QO_arrowenabled:SetChecked(QuestieConfig["arrowEnabled"])
57  
58 QO_showobjectives:SetChecked(QuestieConfig["alwaysShowObjectives"])
59  
60 QO_boldcolors:SetChecked(QuestieConfig["boldColors"])
61  
62 QO_corpsearrow:SetChecked(QuestieConfig["corpseArrow"])
63  
64 QO_clusterquests:SetChecked(QuestieConfig["clusterQuests"])
65  
66 QO_hideminimapicons:SetChecked(QuestieConfig["hideMinimapIcons"])
67  
68 QO_minimapbutton:SetChecked(QuestieConfig["minimapButton"])
69  
70 QO_maxlevelfilter:SetChecked(QuestieConfig["maxLevelFilter"])
71  
72 QO_maxshowlevel:SetValue(QuestieConfig["maxShowLevel"])
73 QO_maxshowlevel_current:SetText(tostring(QuestieConfig["maxShowLevel"]))
74  
75 QO_minlevelfilter:SetChecked(QuestieConfig["minLevelFilter"])
76  
77 QO_minshowlevel:SetValue(QuestieConfig["minShowLevel"])
78 QO_minshowlevel_current:SetText(tostring(QuestieConfig["minShowLevel"]))
79  
80 QO_resizeworldmap:SetChecked(QuestieConfig["resizeWorldmap"])
81  
82 QO_showmapnotes:SetChecked(QuestieConfig["showMapNotes"])
83  
84 QO_hideobjectives:SetChecked(QuestieConfig["hideObjectives"])
85  
86 QO_showprofessionquests:SetChecked(QuestieConfig["showProfessionQuests"])
87  
88 QO_showtooltips:SetChecked(QuestieConfig["showToolTips"])
89  
90 QO_showtrackerheader:SetChecked(QuestieConfig["showTrackerHeader"])
91  
92 QO_trackerbackground:SetChecked(QuestieConfig["trackerBackground"])
93  
94 QO_trackerenabled:SetChecked(QuestieConfig["trackerEnabled"])
95  
96 QO_trackerlist:SetChecked(QuestieConfig["trackerList"])
97  
98 QO_trackerscale:SetValue(QuestieConfig["trackerScale"] * 100)
99 QO_trackerscale_current:SetText(tostring(QuestieConfig["trackerScale"] * 100).."%")
100  
101 QO_trackertransparency:SetValue(QuestieConfig["trackerAlpha"] * 100)
102 QO_trackertransparency_current:SetText(tostring(QuestieConfig["trackerAlpha"] * 100).."%")
103  
104 QO_usequestlinks:SetChecked(QuestieConfig["useQuestLinks"])
105  
106 QO_versionlabel:SetText("Version: " .. tostring(QuestieConfig["getVersion"]))
107  
108 QuestieOptionsForm:SetScale(GetCVar("uiScale"))
109 QuestieOptionsForm:Show()
110 end
111  
112 function Questie:OptionsForm_CancelOptions()
113 QuestieOptionsForm:Hide()
114 end
115  
116 function Questie:OptionsForm_ApplyOptions()
117  
118 QuestieConfig.alwaysShowObjectives = Questie:toboolean(QO_showobjectives:GetChecked())
119  
120 QuestieConfig.arrowEnabled = Questie:toboolean(QO_arrowenabled:GetChecked())
121  
122 QuestieConfig.boldColors = Questie:toboolean(QO_boldcolors:GetChecked())
123  
124 QuestieConfig.clusterQuests = Questie:toboolean(QO_clusterquests:GetChecked())
125  
126 QuestieConfig.corpseArrow = Questie:toboolean(QO_corpsearrow:GetChecked())
127  
128 QuestieConfig.hideMinimapIcons = Questie:toboolean(QO_hideminimapicons:GetChecked())
129  
130 QuestieConfig.minimapButton = Questie:toboolean(QO_minimapbutton:GetChecked())
131  
132 QuestieConfig.maxLevelFilter = Questie:toboolean(QO_maxlevelfilter:GetChecked())
133  
134 QuestieConfig.maxShowLevel = QO_maxshowlevel:GetValue()
135  
136 QuestieConfig.minLevelFilter = Questie:toboolean(QO_minlevelfilter:GetChecked())
137  
138 QuestieConfig.minShowLevel = QO_minshowlevel:GetValue()
139  
140 QuestieConfig.showMapNotes = Questie:toboolean(QO_showmapnotes:GetChecked())
141  
142 QuestieConfig.hideObjectives = Questie:toboolean(QO_hideobjectives:GetChecked())
143  
144 QuestieConfig.showProfessionQuests = Questie:toboolean(QO_showprofessionquests:GetChecked())
145  
146 QuestieConfig.trackerAlpha = tonumber((QO_trackertransparency:GetValue()) / 100)
147  
148 QuestieConfig.useQuestLinks = Questie:toboolean(QO_usequestlinks:GetChecked())
149  
150 -- Compare opening values and values attempting to be set, if any are different a reload will be needed
151 local CachedValues = {
152 ["resizeWorldmap"] = QuestieConfig.resizeWorldmap,
153 ["showToolTips"] = QuestieConfig.showToolTips,
154 ["showTrackerHeader"] = QuestieConfig.showTrackerHeader,
155 ["trackerBackground"] = QuestieConfig.trackerBackground,
156 ["trackerEnabled"] = QuestieConfig.trackerEnabled,
157 ["trackerList"] = QuestieConfig.trackerList, -- Changes list direction, true = bottom>top, false = top>bottom
158 ["trackerScale"] = tonumber(QuestieConfig.trackerScale)
159 }
160  
161 QuestieConfig.resizeWorldmap = Questie:toboolean(QO_resizeworldmap:GetChecked())
162 QuestieConfig.showToolTips = Questie:toboolean(QO_showtooltips:GetChecked())
163 QuestieConfig.showTrackerHeader = Questie:toboolean(QO_showtrackerheader:GetChecked())
164 QuestieConfig.trackerBackground = Questie:toboolean(QO_trackerbackground:GetChecked())
165 QuestieConfig.trackerEnabled = Questie:toboolean(QO_trackerenabled:GetChecked())
166 QuestieConfig.trackerList = Questie:toboolean(QO_trackerlist:GetChecked())
167 QuestieConfig.trackerScale = tonumber(QO_trackerscale:GetValue() / 100)
168  
169 DEFAULT_CHAT_FRAME:AddMessage("Questie Options Applied", 1, 0.75, 0)
170  
171 local bDisplayWarning = false
172 local WarningMessage = "|cFFFFFF00Some options require a ReloadUI to apply:|n|n"
173 if(QuestieConfig.resizeWorldmap ~= CachedValues.resizeWorldmap) then
174 WarningMessage = WarningMessage.."Resize World Map|n"
175 bDisplayWarning = true
176 end
177 if(QuestieConfig.showToolTips ~= CachedValues.showToolTips) then
178 WarningMessage = WarningMessage.."Show Tool Tips|n"
179 bDisplayWarning = true
180 end
181 if(QuestieConfig.showTrackerHeader ~= CachedValues.showTrackerHeader) then
182 WarningMessage = WarningMessage.."Show Tracker Header|n"
183 bDisplayWarning = true
184 end
185 if(QuestieConfig.trackerBackground ~= CachedValues.trackerBackground) then
186 WarningMessage = WarningMessage.."Tracker Background|n"
187 bDisplayWarning = true
188 end
189 if(QuestieConfig.trackerEnabled ~= CachedValues.trackerEnabled) then
190 WarningMessage = WarningMessage.."Tracker Enabled|n"
191 bDisplayWarning = true
192 end
193 if(QuestieConfig.trackerList ~= CachedValues.trackerList) then
194 WarningMessage = WarningMessage.."Tracker List|n"
195 bDisplayWarning = true
196 end
197 if(QuestieConfig.trackerScale ~= CachedValues.trackerScale) then
198 WarningMessage = WarningMessage.."Tracker Scale|n"
199 bDisplayWarning = true
200 end
201 WarningMessage = WarningMessage.."|nDo you want to reload now or revert these settings?|r"
202  
203 if(bDisplayWarning) then
204 StaticPopupDialogs["OPTIONS_WARNING_F"] = {
205 text = WarningMessage,
206 button1 = TEXT("Reload"),
207 button2 = TEXT("Revert"),
208 OnAccept = function()
209 ReloadUI()
210 end,
211 OnCancel = function()
212 -- Reset to cached values since user opted not to reloadui
213 QuestieConfig.resizeWorldmap = CachedValues.resizeWorldmap
214 QuestieConfig.showToolTips = CachedValues.showToolTips
215 QuestieConfig.showTrackerHeader = CachedValues.showTrackerHeader
216 QuestieConfig.trackerBackground = CachedValues.trackerBackground
217 QuestieConfig.trackerEnabled = CachedValues.trackerEnabled
218 QuestieConfig.trackerList = CachedValues.trackerList
219 QuestieConfig.trackerScale = CachedValues.trackerScale
220 Questie:AddEvent("TRACKER", 0)
221 DEFAULT_CHAT_FRAME:AddMessage("Questie Options that required a UI Reload have been reverted", 1, 0.75, 0)
222 end,
223 timeout = 60,
224 exclusive = 1,
225 hideOnEscape = 1
226 }
227 StaticPopup_Show("OPTIONS_WARNING_F")
228 else
229 if (QuestieConfig.showMapNotes == false) and (IsQuestieActive == true) then
230 QuestieConfig.showMapNotes = true
231 Questie:Toggle()
232 elseif (QuestieConfig.showMapNotes == true) and (IsQuestieActive == false) then
233 QuestieConfig.showMapNotes = false
234 Questie:Toggle()
235 else
236 Questie:AddEvent("DRAWNOTES", 0.1)
237 Questie:AddEvent("TRACKER", 0.2)
238 end
239 if (QuestieConfig.minimapButton == true) then
240 Questie.minimapButton:Show()
241 else
242 Questie.minimapButton:Hide()
243 end
244 end
245 RemoveCrazyArrow()
246 QuestieOptionsForm:Hide()
247 end
248  
249 function Questie:OptionsForm_SettingOnEnter(SettingsName)
250 QuestieOptionsToolTip:SetOwner(this, "ANCHOR_RIGHT", -(this:GetWidth() / 2), 10)
251  
252 local language = QuestieLanguage or "enUS"
253  
254 QuestieOptionsToolTip:AddLine(
255 QuestieInterfaceTexts["Settings"][SettingsName][language]["name"]..
256 " (Default: "..
257 QuestieInterfaceTexts["Settings"][SettingsName][language]["default"]..
258 ")",
259 1, 1, 0)
260  
261 if QuestieInterfaceTexts["Settings"][SettingsName]["requiresReload"] then
262 QuestieOptionsToolTip:AddLine("Requires ReloadUI", 1, 0, 0)
263 end
264  
265 QuestieOptionsToolTip:AddLine(QuestieInterfaceTexts["Settings"][SettingsName][language]["description"], 1, 1, 1, true)
266  
267 QuestieOptionsToolTip:Show()
268 end
269  
270 function Questie:OptionsForm_SettingOnLeave()
271 QuestieOptionsToolTip:Hide()
272 end
273  
274 function Questie:OptionsForm_SettingOnValueChanged()
275 if(this:GetName() == QO_FormName.."MaxShowLevelSlider") then
276 if(QO_maxshowlevel_current ~= nil) then
277 QO_maxshowlevel_current:SetText(tostring(this:GetValue()))
278 end
279 elseif(this:GetName() == QO_FormName.."MinShowLevelSlider") then
280 if(QO_minshowlevel_current ~= nil) then
281 QO_minshowlevel_current:SetText(tostring(this:GetValue()))
282 end
283 elseif(this:GetName() == QO_FormName.."TrackerTransparencySlider") then
284 if(QO_trackertransparency_current ~= nil) then
285 QO_trackertransparency_current:SetText(tostring(this:GetValue()).."%")
286 end
287 elseif(this:GetName() == QO_FormName.."TrackerScaleSlider") then
288 if(QO_trackerscale_current ~= nil) then
289 QO_trackerscale_current:SetText(tostring(this:GetValue()).."%")
290 end
291 end
292 end