vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 function Parchment_Tack_OnLoad()
2 this:RegisterForDrag("LeftButton");
3 end
4  
5 function ParchmentChapterTitleButton_OnLoad()
6 this:RegisterForClicks("LeftButtonUp", "RightButtonUp");
7 end
8  
9 function ParchmentChapterTitleButton_OnClick(button)
10 local temp_id = this:GetID();
11  
12 for key, value in Parchment_Data do
13 if(Parchment_Data[key].tack_button == temp_id) then
14 if(button == "LeftButton") then
15 if(IsShiftKeyDown()) then
16 Parchment_SlashCommandHandler("untack");
17 else
18 if(Parchment_Data[key].tack_expand == true) then
19 Parchment_Data[key].tack_expand = false;
20 else
21 Parchment_Data[key].tack_expand = true;
22 end
23 end
24  
25 Parchment_Update_Tack();
26 else
27 if(ParchmentFrame:IsVisible()) then
28 PARCHMENT_PLAYER = key;
29 ParchmentSetText();
30 Parchment_Update();
31 else
32 PARCHMENT_PLAYER = key;
33 ToggleParchment();
34 end
35 end
36 end
37 end
38 end
39  
40 function Parchment_Update_Tack()
41 Parchment_Tack_Frame:Show();
42 Parchment_Tack_Frame:SetWidth(Parchment_Config.TackWidth); -- Set our width here so text can scale height correctly
43  
44 -- Is visible and is supposed to be visible, redundant so clean up later
45 -- Let's set our alpha
46 Parchment_UpdateAlpha();
47  
48 if(Parchment_Config.TackBorder == false) then
49 Parchment_Tack_Frame:SetBackdropBorderColor(0.0, 0.0, 0.0, 0.0);
50 else
51 Parchment_Tack_Frame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b, 1.0);
52 end
53  
54 if(Parchment_Config.Minimized == false) then
55 -- It's visible, flagged as shown in our variable (redundant really), and not minimized so continue so we can adjust the height accordingly
56 local thisRealm = nil;
57 local character = nil;
58 local button_id = 1;
59 -- local box_width = Parchment_Tack_Frame:GetWidth() - 35; -- Frame size -10 for wrapping
60  
61 for i = 1, PARCHMENT_TACK_BUTTONS do
62 getglobal("ParchmentChapterTitleButton" .. i .. "Text"):SetText("");
63 getglobal("ParchmentChapterTitleButton" .. i .. "Text"):Show();
64 getglobal("ParchmentChapterTitleButton" .. i):Show();
65  
66 getglobal("ParchmentChapterTextButton" .. i .. "Text"):SetText("");
67 getglobal("ParchmentChapterTextButton" .. i .. "Text"):Show();
68 getglobal("ParchmentChapterTextButton" .. i):Show();
69 end
70  
71 for key, value in Parchment_Data do
72 Parchment_Data[key].tack_button = 0;
73 character = nil;
74  
75 if(button_id <= PARCHMENT_TACK_BUTTONS) then
76 if(Parchment_Data[key].tacked) then
77 if(Parchment_Data[key].tack_expand == nil) then
78 Parchment_Data[key].tack_expand = true; -- For backwards compatibility
79 end
80  
81 if(Parchment_Data[key].tack_button == nil) then
82 Parchment_Data[key].tack_button = 0; -- For backwards compatibility
83 end
84  
85 thisRealm = Parchment_Split(key, "|")[2];
86  
87 if(thisRealm) then
88 if(Parchment_Config.AllRealms) then
89 character = Parchment_Split(key,"|")[1].." of "..Parchment_Split(key,"|")[2];
90 else
91 if(thisRealm == GetCVar("realmName")) then
92 character = Parchment_Split(key,"|")[1];
93 end
94 end
95 else
96 character = key;
97 end
98  
99 if(character ~= nil) then
100 if(Parchment_Data[key].tack_expand == true and Parchment_Data[key].text ~= "") then
101 character = "- " .. character;
102 elseif(Parchment_Data[key].text ~= "") then
103 character = "+ " .. character;
104 end
105  
106 getglobal("ParchmentChapterTitleButton" .. button_id .. "Text"):SetText("|c00FFFFFF"..character.."|r");
107 Parchment_Data[key].tack_button = button_id;
108 end
109  
110 if(character ~= nil and Parchment_Data[key].text ~= "" and Parchment_Data[key].tack_expand == true) then
111 getglobal("ParchmentChapterTextButton" .. button_id .. "Text"):SetText(Parchment_Data[key].text );
112 end
113  
114 if(character ~= nil) then
115 button_id = button_id + 1; -- Increase the button id if we are setting data to a button
116 end
117 end
118 end
119 end
120  
121 Parchment_Tack_Resize();
122  
123 else
124 Parchment_Config.Minimized = false; -- change to false so when we pass to the min function it minimzies
125 Parchment_Tack_Minimize();
126 end
127 end
128  
129 function Parchment_Tack_Resize()
130 local box_width = 0;
131 local title_height = 0;
132 local text_height = 0;
133 local total_height = 0;
134  
135 -- Minimized height is 27, defined in PARCHMENT_TACK_HEIGHT, may have to add that and padding to get the right height
136 box_width = Parchment_Tack_Frame:GetWidth() - 35; -- Frame size -10 for wrapping
137  
138 for i = 1, PARCHMENT_TACK_BUTTONS do
139 title_text = getglobal("ParchmentChapterTitleButton" .. i .. "Text");
140 title_button = getglobal("ParchmentChapterTitleButton" .. i);
141 text_text = getglobal("ParchmentChapterTextButton" .. i .. "Text");
142 text_button = getglobal("ParchmentChapterTextButton" .. i);
143  
144 if (title_text:IsVisible()) then
145 title_text:SetWidth(box_width);
146  
147 total_height = total_height + title_text:GetHeight();
148  
149 title_button:SetWidth(title_text:GetWidth());
150 title_button:SetHeight(title_text:GetHeight());
151 end
152 if (text_text:IsVisible()) then
153 text_text:SetWidth(box_width);
154  
155 total_height = total_height + text_text:GetHeight();
156  
157 text_button:SetWidth(text_text:GetWidth());
158 text_button:SetHeight(text_text:GetHeight());
159 end
160 end
161  
162 Parchment_Tack_Frame:SetHeight(total_height + 50);
163 end
164  
165 function Parchment_Tack_Minimize()
166 if(Parchment_Config.Minimized == true) then
167 Parchment_Config.Minimized = false;
168 Parchment_Update_Tack();
169 else
170 Parchment_Config.Minimized = true;
171 Parchment_Tack_Frame:SetHeight(PARCHMENT_TACK_HEIGHT);
172  
173 for i = 1, PARCHMENT_TACK_BUTTONS do
174 getglobal("ParchmentChapterTitleButton" .. i .. "Text"):Hide();
175 getglobal("ParchmentChapterTitleButton" .. i):Hide();
176 getglobal("ParchmentChapterTextButton" .. i .. "Text"):Hide();
177 getglobal("ParchmentChapterTextButton" .. i):Hide();
178 end
179  
180 end
181 end
182  
183 function ParchmentTack_OnDragStart()
184 local par = getglobal("Parchment_Tack_Frame");
185  
186 if(Parchment_Config.LockTack == false) then
187 par:StartMoving();
188 end
189 end
190  
191 function ParchmentTack_OnDragStop()
192 local par = getglobal("Parchment_Tack_Frame");
193  
194 if(Parchment_Config.LockTack == false) then
195 par:StopMovingOrSizing();
196 end
197 end