vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | |||
3 | Parchment |
||
4 | |||
5 | This is just a simple mod for writing notes. I often want to do things and forget as I get playing, so thought this to be a good way to write down notes to remember. |
||
6 | |||
7 | Author: Valnar (AKA: Thor) |
||
8 | Website: www.destroyersofhope.com |
||
9 | Email: thor@destroyersofhope.com |
||
10 | Patch Notes: Located in the PatchNotes.txt file |
||
11 | |||
12 | --]] |
||
13 | |||
14 | -------------------------------- |
||
15 | -- Global Variables |
||
16 | -------------------------------- |
||
17 | PARCHMENT_VERSION = "3.11"; |
||
18 | PARCHMENT_DEFAULT_X = 0; |
||
19 | PARCHMENT_DEFAULT_Y = -104; |
||
20 | PARCHMENT_DEFAULT_TACK_X = 0; |
||
21 | PARCHMENT_DEFAULT_TACK_Y = -100; |
||
22 | PARCHMENT_CONFIG_LOADED = nil; |
||
23 | PARCHMENT_VARIABLES_LOADED = nil; |
||
24 | PARCHMENT_INITIAL_PLAYER = ""; -- First player that loads in |
||
25 | PARCHMENT_PLAYER = ""; -- The player we're viewing the Parchment for |
||
26 | PARCHMENT_TACK_HEIGHT = 27; -- Default height of the Tack window, 27 being the minimized size |
||
27 | PARCHMENT_DEFAULT_TACK_WIDTH = 300; |
||
28 | PARCHMENT_DEFAULT_BUTTONPOS = 320; |
||
29 | PARCHMENT_DEFAULT_ALPHA = 255; |
||
30 | PARCHMENT_CONFIRM_ACTION = ""; |
||
31 | PARCHMENT_CONFIRM_ACTION_TEXT = ""; |
||
32 | PARCHMENT_CONFIRM_ACTION_TITLE = ""; |
||
33 | PARCHMENT_TACK_BUTTONS = 10; |
||
34 | |||
35 | -------------------------------- |
||
36 | -- Bindings |
||
37 | -------------------------------- |
||
38 | BINDING_HEADER_PARCHMENTHEADER = "Parchment"; |
||
39 | SLASH_PARCHMENT1 = "/parchment"; |
||
40 | SLASH_PARCHMENT2 = "/par"; |
||
41 | |||
42 | -------------------------------- |
||
43 | -- Startup Functions |
||
44 | -------------------------------- |
||
45 | function Parchment_OnLoad() |
||
46 | -- Register events |
||
47 | this:RegisterForDrag("LeftButton"); |
||
48 | this:RegisterEvent("VARIABLES_LOADED"); |
||
49 | this:RegisterEvent("UNIT_NAME_UPDATE"); |
||
50 | this:RegisterEvent("ADDON_LOADED"); |
||
51 | |||
52 | SlashCmdList["PARCHMENT"] = function(msg) |
||
53 | Parchment_SlashCommandHandler(msg); |
||
54 | end |
||
55 | |||
56 | tinsert(UISpecialFrames,"ParchmentFrame"); |
||
57 | |||
58 | -- Register with ButtonHole |
||
59 | if ButtonHole then |
||
60 | ButtonHole.application.RegisterMod({id="Parchment032405", name="Parchment", tooltip="Easy Note Taking", buttonFrame="ParchmentButtonFrame", updateFunction="ParchmentButton_UpdatePosition"}); |
||
61 | end |
||
62 | end |
||
63 | |||
64 | ParchmentDetails = { |
||
65 | name = "Parchment", |
||
66 | version = PARCHMENT_VERSION, |
||
67 | releaseDate = "Oct. 28, 2005", |
||
68 | author = "Valnar", |
||
69 | email = "thor@destroyersofhope.com", |
||
70 | website = "http://www.destroyersofhope.com", |
||
71 | category = MYADDONS_CATEGORY_OTHERS, |
||
72 | frame = "ParchmentFrame", |
||
73 | optionsFrame = "ParchmentOptionsFrame" |
||
74 | }; |
||
75 | |||
76 | function Parchment_OnEvent(event) |
||
77 | if(event == "VARIABLES_LOADED") then |
||
78 | PARCHMENT_VARIABLES_LOADED = 1; |
||
79 | |||
80 | if(not PARCHMENT_CONFIG_LOADED) then |
||
81 | -- Only want to continue if we haven't loaded our config |
||
82 | PARCHMENT_INITIAL_PLAYER = UnitName("player"); |
||
83 | |||
84 | if (PARCHMENT_INITIAL_PLAYER ~= nil and PARCHMENT_INITIAL_PLAYER ~= UNKNOWNOBJECT) then |
||
85 | -- We have a valid player so initialize |
||
86 | Parchment_Init(); |
||
87 | end |
||
88 | end |
||
89 | elseif (event == "UNIT_NAME_UPDATE") then |
||
90 | if(not PARCHMENT_CONFIG_LOADED) then |
||
91 | -- Only want to continue if we haven't loaded our config |
||
92 | PARCHMENT_INITIAL_PLAYER = UnitName("player"); |
||
93 | |||
94 | if (PARCHMENT_INITIAL_PLAYER ~= nil and PARCHMENT_INITIAL_PLAYER ~= UNKNOWNOBJECT) then |
||
95 | -- We have a valid player so initialize |
||
96 | Parchment_Init(); |
||
97 | end |
||
98 | end |
||
99 | elseif(event == "ADDON_LOADED" and arg1 == "Parchment") then |
||
100 | -- Register the addon in myAddOns |
||
101 | if(myAddOnsFrame_Register) then |
||
102 | myAddOnsFrame_Register(ParchmentDetails); |
||
103 | end |
||
104 | end |
||
105 | end |
||
106 | |||
107 | function Parchment_Init() |
||
108 | if(PARCHMENT_VARIABLES_LOADED) then |
||
109 | -- Add the realm to the "player's name" for the config settings |
||
110 | PARCHMENT_INITIAL_PLAYER = PARCHMENT_INITIAL_PLAYER.."|"..GetCVar("realmName"); |
||
111 | |||
112 | if(not Parchment_Data) then |
||
113 | Parchment_Data = {}; |
||
114 | end |
||
115 | |||
116 | if(not Parchment_Data["General"]) then |
||
117 | Parchment_Data["General"] = {}; |
||
118 | end |
||
119 | |||
120 | if(Parchment_Data["General"].text == nil) then |
||
121 | Parchment_Data["General"].text = ""; |
||
122 | end |
||
123 | |||
124 | if(Parchment_Data["General"].tacked == nil) then |
||
125 | Parchment_Data["General"].tacked = false; |
||
126 | end |
||
127 | |||
128 | if(not Parchment_Data[PARCHMENT_INITIAL_PLAYER]) then |
||
129 | Parchment_Data[PARCHMENT_INITIAL_PLAYER] = {}; |
||
130 | end |
||
131 | |||
132 | if(Parchment_Data[PARCHMENT_INITIAL_PLAYER].text == nil) then |
||
133 | Parchment_Data[PARCHMENT_INITIAL_PLAYER].text = ""; |
||
134 | end |
||
135 | |||
136 | if(Parchment_Data[PARCHMENT_INITIAL_PLAYER].tacked == nil) then |
||
137 | Parchment_Data[PARCHMENT_INITIAL_PLAYER].tacked = false; |
||
138 | end |
||
139 | |||
140 | if(Parchment_Data[PARCHMENT_INITIAL_PLAYER].tack_expand == nil) then |
||
141 | Parchment_Data[PARCHMENT_INITIAL_PLAYER].tack_expand = true; |
||
142 | end |
||
143 | |||
144 | if(Parchment_Data[PARCHMENT_INITIAL_PLAYER].tack_button == nil) then |
||
145 | Parchment_Data[PARCHMENT_INITIAL_PLAYER].tack_button = 0; |
||
146 | end |
||
147 | |||
148 | if(not Parchment_Config) then |
||
149 | Parchment_Config = {}; |
||
150 | end |
||
151 | |||
152 | if(Parchment_Config.Locked == nil) then |
||
153 | Parchment_Config.Locked = false; |
||
154 | end |
||
155 | |||
156 | if(Parchment_Config.AllRealms == nil) then |
||
157 | Parchment_Config.AllRealms = false; |
||
158 | end |
||
159 | |||
160 | if(Parchment_Config.ButtonShow == nil) then |
||
161 | Parchment_Config.ButtonShow = true; |
||
162 | end |
||
163 | |||
164 | if(Parchment_Config.ButtonPos == nil) then |
||
165 | Parchment_Config.ButtonPos = PARCHMENT_DEFAULT_BUTTONPOS; |
||
166 | end |
||
167 | |||
168 | if(Parchment_Config.ShowTack == nil) then |
||
169 | Parchment_Config.ShowTack = false; |
||
170 | end |
||
171 | |||
172 | if(Parchment_Config.LockTack == nil) then |
||
173 | Parchment_Config.LockTack = false; |
||
174 | end |
||
175 | |||
176 | if(Parchment_Config.Minimized == nil) then |
||
177 | Parchment_Config.Minimized = false; |
||
178 | end |
||
179 | |||
180 | if(Parchment_Config.Alpha == nil) then |
||
181 | Parchment_Config.Alpha = PARCHMENT_DEFAULT_ALPHA; |
||
182 | end |
||
183 | |||
184 | if(Parchment_Config.TackBorder == nil) then |
||
185 | Parchment_Config.TackBorder = true; |
||
186 | end |
||
187 | |||
188 | if(Parchment_Config.TackWidth == nil) then |
||
189 | Parchment_Config.TackWidth = PARCHMENT_DEFAULT_TACK_WIDTH; |
||
190 | end |
||
191 | |||
192 | PARCHMENT_PLAYER = PARCHMENT_INITIAL_PLAYER; |
||
193 | PARCHMENT_CONFIG_LOADED = true; |
||
194 | ParchmentButton_UpdatePosition(); |
||
195 | ParchmentButton_Init(); |
||
196 | ParchmentTitleText:SetText("Parchment " .. PARCHMENT_VERSION); |
||
197 | Parchment_Update(); |
||
198 | end |
||
199 | end |
||
200 | |||
201 | function Parchment_SlashCommandHandler(msg) |
||
202 | if(not string.find(msg, "add ")) then |
||
203 | msg = string.lower(msg); |
||
204 | end |
||
205 | |||
206 | if(msg == "") then |
||
207 | ChatFrame1:AddMessage("|cffffff00/par toggle|r - This will toggle Parchment to be shown or hidden"); |
||
208 | ChatFrame1:AddMessage("|cffffff00/par defaults|r - Resets all Options to default values"); |
||
209 | ChatFrame1:AddMessage("|cffffff00/par lock /par unlock|r - Lock Parchment in place or unlock it"); |
||
210 | ChatFrame1:AddMessage("|cffffff00/par reset|r - Resets Parchment to its default screen position"); |
||
211 | ChatFrame1:AddMessage("|cffffff00/par allrealms /par thisrealm|r - View Chapters for all realms or just your current one"); |
||
212 | ChatFrame1:AddMessage("|cffffff00/par showbutton /par hidebutton|r - Show or hide the minimap button"); |
||
213 | ChatFrame1:AddMessage("|cffffff00/par tack /par untack|r - Tack the current Chapter to the Tack window"); |
||
214 | ChatFrame1:AddMessage("|cffffff00/par showtack /par hidetack|r - Show or hide the Tack window"); |
||
215 | ChatFrame1:AddMessage("|cffffff00/par locktack /par unlocktack|r - Lock or unlock the Tack window for movement"); |
||
216 | ChatFrame1:AddMessage("|cffffff00/par resettack - Resets the Tack|r window to its default screen position"); |
||
217 | ChatFrame1:AddMessage("|cffffff00/par showborder /par hideborder|r - Show or hide the Tack window border"); |
||
218 | ChatFrame1:AddMessage("|cffffff00/par add all/realm Name|r - This will add a Chapter to Parchment where 'all' indicates it will be seen from any Realm/Server, or 'realm' for it to be a Realm based Chapter, and Name is what you want to call that Chapter. Example, to add a Chapter called Engineering for all realms you'd do /par add all Engineering - |cffffff00NOTE:|r Use only single words for Chapter names"); |
||
219 | ChatFrame1:AddMessage("|cffffff00/par width size|r - Change the width of the Tack window, so /par width 200 would resize the Tack window to 200 pixels wide, the default being 300"); |
||
220 | ChatFrame1:AddMessage("|cffffff00Left clicking a Chapter|r in the Tack window will expand or collapse the text"); |
||
221 | ChatFrame1:AddMessage("|cffffff00Right clicking a Chapter|r in the Tack window will open Parchment to that Chapter"); |
||
222 | ChatFrame1:AddMessage("|cffffff00Shift + left clicking a Chapter|r in the Tack window will untack that Chapter"); |
||
223 | elseif(msg == "toggle") then |
||
224 | ToggleParchment(); |
||
225 | elseif(msg == "defaults") then |
||
226 | Parchment_Load_Defaults(); |
||
227 | elseif(msg == "lock") then |
||
228 | Parchment_Config.Locked = true; |
||
229 | Parchment_Update(); |
||
230 | ChatFrame1:AddMessage("Parchment is now locked in place"); |
||
231 | elseif(msg == "unlock") then |
||
232 | Parchment_Config.Locked = false; |
||
233 | Parchment_Update(); |
||
234 | ChatFrame1:AddMessage("Parchment is now unlocked for movement"); |
||
235 | elseif(msg == "reset") then |
||
236 | Parchment_SetPosition("FORCED"); |
||
237 | elseif(msg == "resettack") then |
||
238 | ParchmentTack_SetPosition(); |
||
239 | elseif(msg == "allrealms") then |
||
240 | Parchment_Config.AllRealms = true; |
||
241 | ChatFrame1:AddMessage("Viewing Chapters for all realms"); |
||
242 | Parchment_Update(); |
||
243 | elseif(msg == "thisrealm") then |
||
244 | Parchment_Config.AllRealms = false; |
||
245 | ChatFrame1:AddMessage("Viewing only Chapters from this realm"); |
||
246 | Parchment_Update(); |
||
247 | elseif(msg == "showbutton") then |
||
248 | Parchment_Config.ButtonShow = true; |
||
249 | ChatFrame1:AddMessage("Minimap button now being shown"); |
||
250 | Parchment_Update(); |
||
251 | ParchmentButtonFrame:Show(); |
||
252 | elseif(msg == "hidebutton") then |
||
253 | Parchment_Config.ButtonShow = false; |
||
254 | ChatFrame1:AddMessage("Minimap button show being hidden"); |
||
255 | Parchment_Update(); |
||
256 | ParchmentButtonFrame:Hide(); |
||
257 | elseif(msg == "tack") then |
||
258 | Parchment_Data[PARCHMENT_PLAYER].tacked = true; |
||
259 | ChatFrame1:AddMessage("This Chapter is now tacked"); |
||
260 | Parchment_Update(); |
||
261 | elseif(msg == "untack") then |
||
262 | Parchment_Data[PARCHMENT_PLAYER].tacked = false; |
||
263 | ChatFrame1:AddMessage("This Chapter is now untacked"); |
||
264 | Parchment_Update(); |
||
265 | elseif(msg == "hidetack") then |
||
266 | Parchment_Config.ShowTack = false; |
||
267 | ChatFrame1:AddMessage("The Tack window is now hidden"); |
||
268 | Parchment_Tack_Frame:Hide(); |
||
269 | Parchment_Update(); |
||
270 | elseif(msg == "showtack") then |
||
271 | Parchment_Config.ShowTack = true; |
||
272 | ChatFrame1:AddMessage("The Tack window is now shown"); |
||
273 | Parchment_Tack_Frame:Show(); |
||
274 | Parchment_Update(); |
||
275 | elseif(msg == "locktack") then |
||
276 | Parchment_Config.LockTack = true; |
||
277 | ChatFrame1:AddMessage("The Tack window is now locked"); |
||
278 | Parchment_Update(); |
||
279 | elseif(msg == "unlocktack") then |
||
280 | Parchment_Config.LockTack = false; |
||
281 | ChatFrame1:AddMessage("The Tack window is now unlocked"); |
||
282 | Parchment_Update(); -- Tack can be open while Parchment isn't so update it |
||
283 | elseif(msg == "hideborder") then |
||
284 | Parchment_Config.TackBorder = false; |
||
285 | ChatFrame1:AddMessage("The Tack window border is now hidden"); |
||
286 | Parchment_Update(); |
||
287 | elseif(msg == "showborder") then |
||
288 | Parchment_Config.TackBorder = true; |
||
289 | ChatFrame1:AddMessage("The Tack window border is now shown"); |
||
290 | Parchment_Update(); |
||
291 | elseif(string.find(msg, "width ")) then |
||
292 | local width = Parchment_Split(msg," ")[2]; |
||
293 | |||
294 | Parchment_Config.TackWidth = width; |
||
295 | Parchment_Update(); |
||
296 | elseif(string.find(msg, "add ")) then |
||
297 | local where = Parchment_Split(msg," ")[2]; |
||
298 | local new_parchment = Parchment_Split(msg, " ")[3]; |
||
299 | |||
300 | if(where) then |
||
301 | if(where == "realm") then |
||
302 | new_parchment = new_parchment.."|"..GetCVar("realmName"); |
||
303 | end |
||
304 | if(not Parchment_Data[new_parchment]) then |
||
305 | Parchment_Data[new_parchment] = {}; |
||
306 | Parchment_Data[new_parchment].text = ""; |
||
307 | Parchment_Data[new_parchment].tacked = false; |
||
308 | Parchment_Data[new_parchment].tack_expand = true; |
||
309 | Parchment_Data[new_parchment].tack_button = 0; |
||
310 | |||
311 | ChatFrame1:AddMessage(new_parchment .. " has been added to Parchment"); |
||
312 | PARCHMENT_PLAYER = new_parchment; |
||
313 | Parchment_Update(); |
||
314 | else |
||
315 | ChatFrame1:AddMessage(new_parchment .. " already exists in Parchment"); |
||
316 | end |
||
317 | else |
||
318 | ChatFrame1:AddMessage("You need to specify 'all' or 'realm' when adding a new Chapter"); |
||
319 | end |
||
320 | end |
||
321 | end |
||
322 | |||
323 | ------------------------------- |
||
324 | -- Parchment Frame Functions |
||
325 | ------------------------------- |
||
326 | function Parchment_OnDragStart() |
||
327 | local par = getglobal("ParchmentFrame"); |
||
328 | |||
329 | if(Parchment_Config.Locked == false) then |
||
330 | par:StartMoving(); |
||
331 | end |
||
332 | end |
||
333 | |||
334 | function Parchment_OnDragStop() |
||
335 | local par = getglobal("ParchmentFrame"); |
||
336 | |||
337 | if(Parchment_Config.Locked == false) then |
||
338 | par:StopMovingOrSizing(); |
||
339 | end |
||
340 | end |
||
341 | |||
342 | function ToggleParchment() |
||
343 | if(ParchmentFrame:IsVisible()) then |
||
344 | Parchment_OnHide(); |
||
345 | else |
||
346 | Parchment_OnShow(); |
||
347 | end |
||
348 | end |
||
349 | |||
350 | function ToggleTack() |
||
351 | if(Parchment_Tack_Frame:IsVisible()) then |
||
352 | Parchment_SlashCommandHandler("hidetack"); |
||
353 | else |
||
354 | Parchment_SlashCommandHandler("showtack"); |
||
355 | end |
||
356 | end |
||
357 | |||
358 | function Parchment_OnShow() |
||
359 | PlaySound("igQuestListOpen"); |
||
360 | ShowUIPanel(ParchmentFrame); |
||
361 | ParchmentDataFrame:Show(); |
||
362 | end |
||
363 | |||
364 | function Parchment_OnHide() |
||
365 | local par = getglobal("ParchmentFrame"); |
||
366 | |||
367 | if(par.isMoving) then |
||
368 | par:StopMovingOrSizing(); |
||
369 | end |
||
370 | |||
371 | ParchmentSaveText(); |
||
372 | PlaySound("igQuestListClose"); |
||
373 | ParchmentDataFrame:Hide(); |
||
374 | ParchmentOptionsFrame:Hide(); |
||
375 | ParchmentConfirmFrame:Hide(); |
||
376 | ParchmentAddChapterFrame:Hide(); |
||
377 | HideUIPanel(ParchmentFrame); |
||
378 | Parchment_Update(); |
||
379 | end |
||
380 | |||
381 | function ParchmentDataFrame_OnShow() |
||
382 | -- Dropdown |
||
383 | UIDropDownMenu_Initialize(Parchment_UserDropdown, Parchment_UserDropdown_Init); |
||
384 | UIDropDownMenu_SetWidth(120, Parchment_UserDropdown); |
||
385 | |||
386 | -- Tooltips |
||
387 | Parchment_UserDropdown.tooltip = "You are viewing this player's Chapter"; |
||
388 | ParchmentDeleteButton.tooltip = "Click this to remove the selected character from Parchment"; |
||
389 | Parchment_Tack.tooltip = "Click to Tack this Chapter"; |
||
390 | |||
391 | -- Text |
||
392 | ParchmentSetText(); |
||
393 | getglobal(Parchment_Tack:GetName().."Text"):SetText("Tack"); |
||
394 | Parchment_Update(); |
||
395 | end |
||
396 | |||
397 | function ParchmentOptionsFrame_OnShow() |
||
398 | -- Tooltips |
||
399 | ParchmentResetButton.tooltip = "Moves Parchment to its default position"; |
||
400 | ParchmentLock_Check.tooltip = "Check to lock Parchment in place"; |
||
401 | ParchmentAllRealms.tooltip = "Check to view Chapters on all realms"; |
||
402 | ParchmentShowButton.tooltip = "Check to show the minimap icon"; |
||
403 | ParchmentShowTackButton.tooltip = "Check to show the Tack window"; |
||
404 | ParchmentLockTackButton.tooltip = "Check to lock the Tack window in place"; |
||
405 | ParchmentTackBorder.tooltip = "Check to show the border on the Tack window"; |
||
406 | ParchmentTackResetButton.tooltip = "Moves the Tack window to its default position"; |
||
407 | ParchmentAddChapterButton.tooltip = "Add a new Chapter to Parchment"; |
||
408 | |||
409 | -- Text |
||
410 | getglobal(ParchmentLock_Check:GetName().."Text"):SetText("|cffcc0000Lock Parchment|r"); |
||
411 | getglobal(ParchmentAllRealms:GetName().."Text"):SetText("|cffcc0000View All Realms|r"); |
||
412 | getglobal(ParchmentShowButton:GetName().."Text"):SetText("|cffcc0000Show Minimap Icon|r"); |
||
413 | getglobal(ParchmentShowTackButton:GetName().."Text"):SetText("|cffcc0000Show Tack Window|r"); |
||
414 | getglobal(ParchmentLockTackButton:GetName().."Text"):SetText("|cffcc0000Lock Tack Window|r"); |
||
415 | getglobal(ParchmentTackBorder:GetName().."Text"):SetText("|cffcc0000Show Tack Window Border|r"); |
||
416 | |||
417 | getglobal(Parchment_Slider:GetName().."Text"):SetText("|cffcc0000Minimap Button Position"); |
||
418 | getglobal(Parchment_Slider:GetName().."High"):SetText(); |
||
419 | getglobal(Parchment_Slider:GetName().."Low"):SetText(); |
||
420 | |||
421 | getglobal(Parchment_Alpha:GetName().."Text"):SetText("|cffcc0000Transparency"); |
||
422 | getglobal(Parchment_Alpha:GetName().."High"):SetText(); |
||
423 | getglobal(Parchment_Alpha:GetName().."Low"):SetText(); |
||
424 | |||
425 | -- Set Sliders |
||
426 | Parchment_Slider:SetValue(Parchment_Config.ButtonPos); |
||
427 | Parchment_Alpha:SetValue(Parchment_Config.Alpha); |
||
428 | |||
429 | Parchment_Update(); |
||
430 | end |
||
431 | |||
432 | ------------------------------- |
||
433 | -- Button Functions |
||
434 | ------------------------------- |
||
435 | function Parchment_Cancel() |
||
436 | ParchmentSetText(); |
||
437 | HideUIPanel(ParchmentFrame); |
||
438 | end |
||
439 | |||
440 | function Parchment_Clear() |
||
441 | PARCHMENT_CONFIRM_ACTION_TEXT = "Are you sure you wish to clear all text from this Chapter?"; |
||
442 | PARCHMENT_CONFIRM_ACTION = "clear"; |
||
443 | PARCHMENT_CONFIRM_ACTION_TITLE = "Confirm Clear"; |
||
444 | getglobal("ParchmentConfirmFrameInfo"):SetText(PARCHMENT_CONFIRM_ACTION_TEXT); |
||
445 | getglobal("ParchmentConfirmFrameTitle"):SetText(PARCHMENT_CONFIRM_ACTION_TITLE); |
||
446 | ParchmentConfirmFrame:Show(); |
||
447 | end |
||
448 | |||
449 | function Parchment_Load_Defaults() |
||
450 | Parchment_Config.Locked = false; |
||
451 | Parchment_Config.AllRealms = false; |
||
452 | Parchment_Config.ButtonShow = true; |
||
453 | ParchmentButton_UpdatePosition(); |
||
454 | Parchment_Config.ShowTack = false; |
||
455 | Parchment_Config.ButtonPos = PARCHMENT_DEFAULT_BUTTONPOS; |
||
456 | Parchment_Config.ShowTack = false; |
||
457 | Parchment_Config.LockTack = false; |
||
458 | Parchment_Config.Minimized = false; |
||
459 | Parchment_Config.TackBorder = true; |
||
460 | Parchment_Config.TackWidth = PARCHMENT_DEFAULT_TACK_WIDTH; |
||
461 | Parchment_Config.Alpha = PARCHMENT_DEFAULT_ALPHA; |
||
462 | |||
463 | Parchment_Slider:SetValue(Parchment_Config.ButtonPos); |
||
464 | Parchment_Alpha:SetValue(Parchment_Config.Alpha); |
||
465 | |||
466 | Parchment_SlashCommandHandler("reset"); |
||
467 | Parchment_SlashCommandHandler("resettack"); |
||
468 | |||
469 | Parchment_Update(); |
||
470 | end |
||
471 | |||
472 | function Parchment_SetPosition(forced) |
||
473 | local par = getglobal("ParchmentFrame"); |
||
474 | |||
475 | if(forced == "FORCED") then |
||
476 | par:ClearAllPoints(); |
||
477 | par:SetPoint("TOPLEFT","UIParent","TOPLEFT", PARCHMENT_DEFAULT_X, PARCHMENT_DEFAULT_Y); |
||
478 | end |
||
479 | end |
||
480 | |||
481 | function ParchmentTack_SetPosition() |
||
482 | local tack = getglobal("Parchment_Tack_Frame"); |
||
483 | |||
484 | tack:ClearAllPoints(); |
||
485 | tack:SetPoint("TOPLEFT","UIParent","TOPLEFT", PARCHMENT_DEFAULT_TACK_X, PARCHMENT_DEFAULT_TACK_Y); |
||
486 | end |
||
487 | |||
488 | function Parchment_Delete_Character() |
||
489 | PARCHMENT_CONFIRM_ACTION_TEXT = "Are you sure you wish to delete this Chapter?"; |
||
490 | PARCHMENT_CONFIRM_ACTION = "delete"; |
||
491 | PARCHMENT_CONFIRM_ACTION_TITLE = "Confirm Delete"; |
||
492 | getglobal("ParchmentConfirmFrameInfo"):SetText(PARCHMENT_CONFIRM_ACTION_TEXT); |
||
493 | getglobal("ParchmentConfirmFrameTitle"):SetText(PARCHMENT_CONFIRM_ACTION_TITLE); |
||
494 | ParchmentConfirmFrame:Show(); |
||
495 | end |
||
496 | |||
497 | function ParchmentTab_OnClick(tab) |
||
498 | if(not tab) then |
||
499 | tab = this:GetID(); |
||
500 | end |
||
501 | |||
502 | ParchmentConfirmFrame:Hide(); |
||
503 | |||
504 | if(tab == 1) then |
||
505 | ParchmentOptionsFrame:Hide(); |
||
506 | ParchmentDataFrame:Show(); |
||
507 | else |
||
508 | ParchmentDataFrame:Hide(); |
||
509 | ParchmentOptionsFrame:Show(); |
||
510 | end |
||
511 | |||
512 | PlaySound("igCharacterInfoTab"); |
||
513 | end |
||
514 | |||
515 | function ParchmentAddChapterButton_OnClick() |
||
516 | if not(ParchmentAddChapterFrame:IsVisible()) then |
||
517 | ParchmentAddChapterFrame:Show(); |
||
518 | end |
||
519 | end |
||
520 | |||
521 | ------------------------------- |
||
522 | -- Checkbox Functions |
||
523 | ------------------------------- |
||
524 | function ParchmentTackBorder_OnClick() |
||
525 | local action; |
||
526 | local checked = this:GetChecked(); |
||
527 | |||
528 | if(not checked) then |
||
529 | action = "hideborder"; |
||
530 | PlaySound("igMainMenuOptionCheckBoxOff"); |
||
531 | else |
||
532 | action = "showborder"; |
||
533 | PlaySound("igMainMenuOptionCheckBoxOn"); |
||
534 | end |
||
535 | |||
536 | Parchment_SlashCommandHandler(action); |
||
537 | end |
||
538 | |||
539 | function Parchment_Tack_Character() |
||
540 | local action; |
||
541 | local checked = this:GetChecked(); |
||
542 | |||
543 | if(not checked) then |
||
544 | action = "untack"; |
||
545 | PlaySound("igMainMenuOptionCheckBoxOff"); |
||
546 | else |
||
547 | action = "tack"; |
||
548 | PlaySound("igMainMenuOptionCheckBoxOn"); |
||
549 | end |
||
550 | |||
551 | Parchment_SlashCommandHandler(action); |
||
552 | end |
||
553 | |||
554 | function ParchmentTack_OnClick() |
||
555 | local action; |
||
556 | local checked = this:GetChecked(); |
||
557 | |||
558 | if(not checked) then |
||
559 | action = "hidetack"; |
||
560 | PlaySound("igMainMenuOptionCheckBoxOff"); |
||
561 | else |
||
562 | action = "showtack"; |
||
563 | PlaySound("igMainMenuOptionCheckBoxOn"); |
||
564 | end |
||
565 | |||
566 | Parchment_SlashCommandHandler(action); |
||
567 | end |
||
568 | |||
569 | function ParchmentLockTack_OnClick() |
||
570 | local action; |
||
571 | local checked = this:GetChecked(); |
||
572 | |||
573 | if(not checked) then |
||
574 | action = "unlocktack"; |
||
575 | PlaySound("igMainMenuOptionCheckBoxOff"); |
||
576 | else |
||
577 | action = "locktack"; |
||
578 | PlaySound("igMainMenuOptionCheckBoxOn"); |
||
579 | end |
||
580 | |||
581 | Parchment_SlashCommandHandler(action); |
||
582 | end |
||
583 | |||
584 | function ParchmentButton_Toggle() |
||
585 | local action; |
||
586 | local checked = this:GetChecked(); |
||
587 | |||
588 | if(not checked) then |
||
589 | action = "hidebutton"; |
||
590 | PlaySound("igMainMenuOptionCheckBoxOff"); |
||
591 | else |
||
592 | action = "showbutton"; |
||
593 | PlaySound("igMainMenuOptionCheckBoxOn"); |
||
594 | end |
||
595 | |||
596 | Parchment_SlashCommandHandler(action); |
||
597 | end |
||
598 | |||
599 | function ParchmentLock_CheckOnClick() |
||
600 | local action; |
||
601 | local checked = this:GetChecked(); |
||
602 | |||
603 | if(not checked) then |
||
604 | action = "unlock"; |
||
605 | PlaySound("igMainMenuOptionCheckBoxOff"); |
||
606 | else |
||
607 | action = "lock"; |
||
608 | PlaySound("igMainMenuOptionCheckBoxOn"); |
||
609 | end |
||
610 | |||
611 | Parchment_SlashCommandHandler(action); |
||
612 | end |
||
613 | |||
614 | function ParchmentAllRealms_CheckOnClick() |
||
615 | local action; |
||
616 | local checked = this:GetChecked(); |
||
617 | |||
618 | if(not checked) then |
||
619 | action = "thisrealm"; |
||
620 | PlaySound("igMainMenuOptionCheckBoxOff"); |
||
621 | else |
||
622 | action = "allrealms"; |
||
623 | PlaySound("igMainMenuOptionCheckBoxOn"); |
||
624 | end |
||
625 | |||
626 | Parchment_SlashCommandHandler(action); |
||
627 | end |
||
628 | |||
629 | ------------------------------- |
||
630 | -- Player Dropdown Functions |
||
631 | ------------------------------- |
||
632 | function Parchment_UserDropdown_OnClick() |
||
633 | ParchmentSaveText(); |
||
634 | PARCHMENT_PLAYER = this.value; |
||
635 | ParchmentSetText(); |
||
636 | Parchment_Update(); |
||
637 | end |
||
638 | |||
639 | function Parchment_UserDropdown_Init() |
||
640 | local info; |
||
641 | |||
642 | for key, value in Parchment_Data do |
||
643 | local thisRealm = Parchment_Split(key, "|")[2]; |
||
644 | info = {}; |
||
645 | |||
646 | if(thisRealm) then |
||
647 | if(Parchment_Config.AllRealms) then |
||
648 | info.text = Parchment_Split(key,"|")[1].." of "..Parchment_Split(key,"|")[2]; |
||
649 | else |
||
650 | if(thisRealm == GetCVar("realmName")) then |
||
651 | info.text = Parchment_Split(key,"|")[1]; |
||
652 | end |
||
653 | end |
||
654 | else |
||
655 | info.text = key; -- This is General or a created Chapter, not a player |
||
656 | end |
||
657 | |||
658 | if(info.text) then -- Should be the fix to the blank space showing from other realms when set to this realm |
||
659 | info.value = key; |
||
660 | info.func = Parchment_UserDropdown_OnClick; |
||
661 | UIDropDownMenu_AddButton(info); |
||
662 | end |
||
663 | end |
||
664 | end |
||
665 | |||
666 | ------------------------------- |
||
667 | -- Internal Functions |
||
668 | ------------------------------- |
||
669 | function ParchmentSaveText() |
||
670 | Parchment_Data[PARCHMENT_PLAYER].text = ParchmentEditBox:GetText(); |
||
671 | end |
||
672 | |||
673 | function ParchmentSetText() |
||
674 | ParchmentEditBox:SetText(Parchment_Data[PARCHMENT_PLAYER].text); |
||
675 | Parchment_Text_Length:SetText(strlen(ParchmentEditBox:GetText()).." Characters"); |
||
676 | end |
||
677 | |||
678 | function Parchment_UpdateTextLength() |
||
679 | Parchment_Text_Length:SetText(strlen(ParchmentEditBox:GetText()).." Characters"); |
||
680 | end |
||
681 | |||
682 | function Parchment_Update() |
||
683 | if(ParchmentDataFrame:IsVisible()) then |
||
684 | UIDropDownMenu_SetSelectedValue(Parchment_UserDropdown, PARCHMENT_PLAYER); |
||
685 | |||
686 | local thisRealm = Parchment_Split(PARCHMENT_PLAYER, "|")[2]; |
||
687 | |||
688 | if(thisRealm) then |
||
689 | if(Parchment_Config.AllRealms) then |
||
690 | UIDropDownMenu_SetText(Parchment_Split(PARCHMENT_PLAYER,"|")[1].." of "..Parchment_Split(PARCHMENT_PLAYER,"|")[2], Parchment_UserDropdown); |
||
691 | else |
||
692 | UIDropDownMenu_SetText(Parchment_Split(PARCHMENT_PLAYER,"|")[1], Parchment_UserDropdown); |
||
693 | end |
||
694 | else |
||
695 | UIDropDownMenu_SetText(PARCHMENT_PLAYER, Parchment_UserDropdown); |
||
696 | end |
||
697 | |||
698 | Parchment_Tack:SetChecked(Parchment_Data[PARCHMENT_PLAYER].tacked); |
||
699 | elseif(ParchmentOptionsFrame:IsVisible()) then |
||
700 | ParchmentLock_Check:SetChecked(Parchment_Config.Locked); |
||
701 | ParchmentAllRealms:SetChecked(Parchment_Config.AllRealms); |
||
702 | ParchmentShowButton:SetChecked(Parchment_Config.ButtonShow); |
||
703 | ParchmentShowTackButton:SetChecked(Parchment_Config.ShowTack); |
||
704 | ParchmentLockTackButton:SetChecked(Parchment_Config.LockTack); |
||
705 | ParchmentTackBorder:SetChecked(Parchment_Config.TackBorder); |
||
706 | end |
||
707 | |||
708 | if(Parchment_Config.ShowTack == true) then |
||
709 | Parchment_Update_Tack(); |
||
710 | end |
||
711 | end |
||
712 | |||
713 | function Parchment_Split(toCut, separator) |
||
714 | local splitted = {}; |
||
715 | local i = 0; |
||
716 | local regEx = "([^" .. separator .. "]*)" .. separator .. "?"; |
||
717 | |||
718 | for item in string.gfind(toCut .. separator, regEx) do |
||
719 | i = i + 1; |
||
720 | splitted[i] = Parchment_Trim(item) or ''; |
||
721 | end |
||
722 | splitted[i] = nil; |
||
723 | return splitted; |
||
724 | end |
||
725 | |||
726 | function Parchment_Trim (s) |
||
727 | return (string.gsub(s, "^%s*(.-)%s*$", "%1")); |
||
728 | end |
||
729 | |||
730 | function Parchment_UpdateAlpha() |
||
731 | Parchment_Tack_Frame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b, Parchment_Config.Alpha); |
||
732 | |||
733 | end |