vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 function DART_Compile_Scripts()
2 for ti = 1, DART_Get_MaxTextureIndex() do
3 for i=1,DART_NUMBER_OF_SCRIPTS do
4 if (DART_Settings[DART_INDEX][ti].scripts[i]) then
5 RunScript("function DART_Texture"..ti.."_Script_"..DART_SCRIPT_LABEL[i].."(param, ti)\n "..DART_Settings[DART_INDEX][ti].scripts[i].." \nend");
6 else
7 RunScript("function DART_Texture"..ti.."_Script_"..DART_SCRIPT_LABEL[i].."()\nend");
8 end
9 if (i == 14) then
10 this = getglobal("DART_Texture_"..ti);
11 getglobal("DART_Texture"..ti.."_Script_"..DART_SCRIPT_LABEL[i])("", ti);
12 end
13 end
14 end
15 end
16  
17 function DART_Get_Offsets(element, baseframe, settings)
18 baseframe = getglobal(baseframe);
19 local xoffset, yoffset = DL_Get_Offsets(element, baseframe, DART_ATTACH_POINTS[settings.attachpoint[1]], DART_ATTACH_POINTS[settings.attachto[1]]);
20 return xoffset, yoffset;
21 end
22  
23 function DART_Get_Position(frame, attach, scale)
24 local x, y;
25 attach = DART_ATTACH_POINTS[attach];
26 if (attach == "TOPLEFT") then
27 x = frame:GetLeft();
28 y = frame:GetTop();
29 elseif (attach == "TOP") then
30 x = frame:GetLeft() + (frame:GetRight() - frame:GetLeft()) / 2;
31 y = frame:GetTop();
32 elseif (attach == "TOPRIGHT") then
33 x = frame:GetRight();
34 y = frame:GetTop();
35 elseif (attach == "LEFT") then
36 x = frame:GetLeft();
37 y = frame:GetBottom() + (frame:GetTop() - frame:GetBottom()) / 2;
38 elseif (attach == "CENTER") then
39 x = frame:GetLeft() + (frame:GetRight() - frame:GetLeft()) / 2;
40 y = frame:GetBottom() + (frame:GetTop() - frame:GetBottom()) / 2;
41 elseif (attach == "RIGHT") then
42 x = frame:GetRight();
43 y = frame:GetBottom() + (frame:GetTop() - frame:GetBottom()) / 2;
44 elseif (attach == "BOTTOMLEFT") then
45 x = frame:GetLeft();
46 y = frame:GetBottom();
47 elseif (attach == "BOTTOM") then
48 x = frame:GetLeft() + (frame:GetRight() - frame:GetLeft()) / 2;
49 y = frame:GetBottom();
50 elseif (attach == "BOTTOMRIGHT") then
51 x = frame:GetRight();
52 y = frame:GetBottom();
53 end
54 x = DL_round(x, 2);
55 y = DL_round(y, 2);
56 return x, y;
57 end
58  
59 function DART_Initialize(override)
60 if (DART_INITIALIZED) then return; end
61  
62 if (DART_DL_VERSION > DL_VERSION) then
63 ScriptErrors_Message:SetText("** You need to install the latest version of the Discord Library, v"..DART_DL_VERSION..", for Discord Art to work right. It should be included in the same .zip file from which you extracted this mod. **");
64 ScriptErrors:Show();
65 return;
66 end
67  
68 if (not DART_Settings) then
69 DART_Settings = {};
70 DART_Settings.CustomTextures = {};
71 end
72  
73 if (not DART_Settings[DART_TEXT.Default]) then
74 DART_Initialize_DefaultSettings();
75 end
76  
77 DART_PROFILE_INDEX = UnitName("player").." : "..GetCVar("realmName");
78 if (DART_Settings[DART_PROFILE_INDEX]) then
79 DART_INDEX = DART_Settings[DART_PROFILE_INDEX];
80 else
81 DART_INDEX = DART_TEXT.Default;
82 DART_Settings[DART_PROFILE_INDEX] = DART_TEXT.Default;
83 end
84  
85 if (not override) then
86 DART_INITIALIZED = true;
87 end
88  
89 if (DART_CUSTOM_SETTINGS) then
90 local index = DART_TEXT.Custom;
91 DART_Settings[index] = {};
92 DL_Copy_Table(DART_CUSTOM_SETTINGS, DART_Settings[index]);
93 end
94  
95 if (not override) then
96 DART_Initialize_NewSettings();
97 DART_Initialize_Everything();
98 end
99 end
100  
101 function DART_Initialize_DefaultSettings()
102 local index = DART_TEXT.Default;
103 DART_Settings[index] = {};
104 if (DART_DEFAULT_SETTINGS) then
105 DL_Copy_Table(DART_DEFAULT_SETTINGS, DART_Settings[index]);
106 else
107 DART_Settings[index].updatespeed = 30;
108 DART_Settings[index].optionsscale = 1;
109 DART_Set_DefaultSettings(index, 1);
110 end
111 end
112  
113 function DART_CreateAllFrames()
114 if (not DART_INITIALIZED) then
115 DART_Initialize(1)
116 end
117 for ti in pairs(DART_Settings[DART_INDEX]) do
118 if (type(ti) == "number") then
119 local texture = getglobal("DART_Texture_"..ti);
120 if (not texture) then
121 DART_Create_Texture(ti, 1);
122 end
123 end
124 end
125 end
126  
127 function DART_Initialize_Everything()
128 DART_Set_OnUpdateSpeed();
129 DART_CreateAllFrames()
130 for ti in pairs(DART_Settings[DART_INDEX]) do
131 if (type(ti) == "number") then
132 DART_Initialize_Texture(ti);
133 end
134 end
135 local ti = 0;
136 while (true) do
137 ti = ti + 1;
138 local texture = getglobal("DART_Texture_"..ti);
139 if (texture) then
140 if (not DART_Settings[DART_INDEX][ti]) then
141 texture:Hide();
142 texture:UnregisterAllEvents();
143 end
144 else
145 break;
146 end
147 end
148 if (DART_Options) then
149 DART_Initialize_TextureList();
150 DART_Set_OptionsScale();
151 DART_Initialize_TextureOptions();
152 DART_Initialize_MiscOptions();
153 end
154 DART_Compile_Scripts();
155 end
156  
157 function DART_Get_MaxTextureIndex()
158 local ti = 0;
159 while (true) do
160 ti = ti + 1;
161 if (not DART_Settings[DART_INDEX][ti]) then
162 return ti - 1;
163 end
164 end
165 end
166  
167 function DART_Initialize_NewSettings()
168 local maxIndex = DART_Get_MaxTextureIndex();
169 if (not DART_Settings[DART_INDEX]["INITIALIZED1.0d"]) then
170 for ti = 1, maxIndex do
171 DART_Settings[DART_INDEX][ti].parent = "UIParent";
172 DART_Settings[DART_INDEX][ti].strata = "BACKGROUND";
173 DART_Settings[DART_INDEX][ti].bgtexture = "Interface\\AddOns\\DiscordLibrary\\PlainBackdrop";
174 DART_Settings[DART_INDEX][ti].bordertexture = "Interface\\Tooltips\\UI-Tooltip-Border";
175 DART_Settings[DART_INDEX][ti].Backdrop = { tile=true, tileSize=16, edgeSize=16, left=5, right=5, top=5, bottom=5};
176 end
177 end
178 if (not DART_Settings[DART_INDEX]["INITIALIZED1.1"]) then
179 for ti = 1, maxIndex do
180 DART_Settings[DART_INDEX][ti].framelevel = 0;
181 end
182 end
183 if (not DART_Settings[DART_INDEX]["INITIALIZED1.5"]) then
184 for ti = 1, maxIndex do
185 DART_Settings[DART_INDEX][ti].drawlayer = "ARTWORK";
186 DART_Settings[DART_INDEX][ti].blendmode = "DISABLE";
187 DART_Settings[DART_INDEX][ti].text.drawlayer = "OVERLAY";
188 end
189 end
190  
191 DART_Settings[DART_INDEX]["INITIALIZED1.5"] = true;
192 DART_Settings[DART_INDEX]["INITIALIZED1.1"] = true;
193 DART_Settings[DART_INDEX]["INITIALIZED1.0d"] = true;
194 end
195  
196 function DART_Create_Texture(ti, override)
197 if (not ti) then
198 ti = DART_Get_MaxTextureIndex() + 1;
199 DART_Set_DefaultSettings(DART_INDEX, ti);
200 end
201  
202 CreateFrame("Button", "DART_Texture_"..ti, UIParent);
203  
204 local frame = getglobal("DART_Texture_"..ti);
205  
206 frame:CreateTexture("DART_Texture_"..ti.."_Texture", "ARTWORK");
207 frame:CreateTexture("DART_Texture_"..ti.."_Highlight", "OVERLAY");
208 frame:CreateFontString("DART_Texture_"..ti.."_Text", "OVERLAY");
209  
210 frame:SetID(ti);
211 frame:SetMovable(1);
212 frame:RegisterForDrag("LeftButton", "RightButton");
213 frame:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp", "Button4Up", "Button5Up");
214 frame.baseframelevel = frame:GetFrameLevel();
215  
216 local texture = getglobal("DART_Texture_"..ti.."_Texture");
217 texture:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0);
218 texture:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, 0);
219  
220 local highlight = getglobal("DART_Texture_"..ti.."_Highlight");
221 highlight:Hide();
222 highlight:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0);
223 highlight:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, 0);
224 highlight:SetTexture("Interface\AddOns\DiscordLibrary\PlainBackdrop");
225 highlight:SetBlendMode("ADD");
226  
227 local text = getglobal("DART_Texture_"..ti.."_Text");
228 text:SetFontObject(GameFontNormal);
229 text:SetPoint("CENTER", frame, "CENTER", 0, 0);
230  
231 frame:SetScript("OnClick", DART_Texture_OnClick);
232 frame:SetScript("OnEvent", DART_Texture_OnEvent);
233 frame:SetScript("OnEnter", DART_Texture_OnEnter);
234 frame:SetScript("OnShow", DART_Texture_OnShow);
235 frame:SetScript("OnHide", DART_Texture_OnHide);
236 frame:SetScript("OnLeave", DART_Texture_OnLeave);
237 frame:SetScript("OnMouseUp", DART_Texture_OnMouseUp);
238 frame:SetScript("OnMouseDown", DART_Texture_OnMouseDown);
239 frame:SetScript("OnMouseWheel", DART_Texture_OnMouseWheel);
240 frame:SetScript("OnReceiveDrag", DART_Texture_OnReceiveDrag);
241 frame:SetScript("OnDragStart", DART_Texture_OnDragStart);
242 frame:SetScript("OnDragStop", DART_Texture_OnDragStop);
243 frame:SetScript("OnUpdate", DART_Texture_OnUpdate);
244  
245 if (not override) then
246 DART_Initialize_Texture(ti);
247 end
248 if (DART_Options) then
249 DART_Initialize_TextureList();
250 end
251 end
252  
253 function DART_Initialize_Texture(textureIndex)
254 local settings = DART_Settings[DART_INDEX][textureIndex];
255 local texture = getglobal("DART_Texture_"..textureIndex);
256  
257 texture.activeConditions = {};
258 texture.updatetimer = 0;
259 texture.totalelapsed = 0;
260 DART_FauxShow(textureIndex);
261  
262 texture:ClearAllPoints();
263 for i=1,4 do
264 if (settings.attachframe[i] and settings.attachframe[i] ~= "") then
265 if (not getglobal(settings.attachframe[i])) then
266 settings.attachframe[i] = "UIParent";
267 end
268 texture:SetPoint(DART_ATTACH_POINTS[settings.attachpoint[i]], settings.attachframe[i], DART_ATTACH_POINTS[settings.attachto[i]], settings.xoffset[i], settings.yoffset[i]);
269  
270 end
271 end
272  
273 texture:SetBackdrop({bgFile = settings.bgtexture, edgeFile = settings.bordertexture, tile = settings.Backdrop.tile, tileSize = settings.Backdrop.tileSize, edgeSize = settings.Backdrop.edgeSize, insets = { left = settings.Backdrop.left, right = settings.Backdrop.right, top = settings.Backdrop.top, bottom = settings.Backdrop.bottom }});
274  
275 if (getglobal(settings.parent)) then
276 texture:SetParent(settings.parent);
277 else
278 DART_Settings[DART_INDEX][textureIndex].parent = "UIParent";
279 texture:SetParent(settings.parent);
280 end
281 texture:SetFrameStrata(settings.strata);
282 getglobal(texture:GetName().."_Texture"):SetDrawLayer(settings.drawlayer);
283 getglobal(texture:GetName().."_Texture"):SetBlendMode(settings.blendmode);
284  
285 DART_Texture(textureIndex, settings.texture, settings.coords);
286 DART_Scale(textureIndex, settings.scale);
287 DART_Height(textureIndex, settings.height);
288 DART_Width(textureIndex, settings.width);
289 DART_Color(textureIndex, settings.color.r, settings.color.g, settings.color.b, settings.alpha);
290 DART_BackgroundColor(textureIndex, settings.bgcolor.r, settings.bgcolor.g, settings.bgcolor.b, settings.bgalpha);
291 DART_BorderColor(textureIndex, settings.bordercolor.r, settings.bordercolor.g, settings.bordercolor.b, settings.borderalpha);
292 if (settings.hide) then
293 DART_Hide(textureIndex);
294 else
295 DART_Show(textureIndex);
296 end
297 if (settings.hidebg) then
298 texture:SetBackdropColor(0, 0, 0, 0);
299 texture:SetBackdropBorderColor(0, 0, 0, 0);
300 end
301 DART_Padding(textureIndex, settings.padding);
302 if (settings.disablemouse) then
303 texture:EnableMouse(false);
304 else
305 texture:EnableMouse(1);
306 end
307 if (settings.disableMousewheel) then
308 texture:EnableMouseWheel(false);
309 else
310 texture:EnableMouseWheel(1);
311 end
312  
313 local text = getglobal("DART_Texture_"..textureIndex.."_Text");
314 if (settings.font) then
315 local fontSet;
316 if (string.find(settings.font, "\\")) then
317 fontSet = text:SetFont(settings.font, settings.text.height);
318 elseif (settings.font == "") then
319 fontSet = text:SetFont("Fonts\\FRIZQT__.TTF", 12);
320 else
321 fontSet = text:SetFont("Interface\\AddOns\\DiscordArt\\CustomFonts\\"..settings.font, settings.text.height);
322 end
323 if (not fontSet) then
324 DL_Error("Texture #"..textureIndex.." - Attempt to load a font that doesn't exist.");
325 end
326 end
327 text:SetDrawLayer(settings.text.drawlayer);
328  
329 DART_Text(textureIndex, settings.text.text);
330 DART_TextAlpha(textureIndex, settings.text.alpha);
331 DART_TextColor(textureIndex, settings.text.color.r, settings.text.color.g, settings.text.color.b, settings.text.alpha);
332 DART_TextHeight(textureIndex, settings.text.height);
333 DART_TextWidth(textureIndex, settings.text.width);
334 DART_TextFontSize(textureIndex, settings.text.fontsize);
335 if (settings.text.hide) then
336 DART_TextHide(textureIndex);
337 else
338 DART_TextShow(textureIndex);
339 end
340  
341 text:ClearAllPoints();
342 text:SetPoint(DART_ATTACH_POINTS[settings.text.attachpoint], texture:GetName(), DART_ATTACH_POINTS[settings.text.attachto], settings.text.xoffset, settings.text.yoffset);
343 text:SetJustifyV(DART_ATTACH_POINTS[settings.text.justifyV]);
344 text:SetJustifyH(DART_ATTACH_POINTS[settings.text.justifyH]);
345  
346 if (settings.highlighttexture) then
347 if (string.find(settings.highlighttexture, "\\")) then
348 getglobal("DART_Texture_"..textureIndex.."_Highlight"):SetTexture(settings.highlighttexture);
349 else
350 getglobal("DART_Texture_"..textureIndex.."_Highlight"):SetTexture("Interface\\AddOns\\DiscordArt\\CustomTextures\\"..settings.highlighttexture);
351 end
352 end
353 DART_HighlightColor(textureIndex, settings.highlightcolor.r, settings.highlightcolor.g, settings.highlightcolor.b, settings.highlightalpha);
354  
355 setglobal("BINDING_NAME_DART_TEXTURE_"..textureIndex, settings.name);
356  
357 if (not settings.framelevel) then settings.framelevel = 0; end
358 local frameLvl = texture.baseframelevel + settings.framelevel;
359 frameLvl = DL_round(frameLvl, 0);
360 if (frameLvl <= 0) then
361 frameLvl = 1;
362 end
363 texture:SetFrameLevel(frameLvl);
364 end
365  
366 function DART_Load_Options()
367 if (DART_Options) then return; end
368 UIParentLoadAddOn("DiscordArtOptions");
369 DART_Initialize_TextureList();
370 DART_Initialize_ProfileList();
371 DL_Set_OptionsTitle("DART_Options", "DiscordArtOptions\\title", DART_VERSION);
372 DL_Layout_Menu("DART_DropMenu");
373 DL_Layout_ScrollButtons("DART_ScrollMenu_Button", 10, DART_Options_SelectTexture);
374 DL_Init_MenuControl(DART_BaseOptions_SelectTexture, DART_TEXTURE_INDEX);
375 DL_Init_MenuControl(DART_TextureOptions_NudgeIndex, DART_NUDGE_INDEX);
376 DART_TextureOptions_FrameLevel_Label:ClearAllPoints();
377 DART_TextureOptions_FrameLevel_Label:SetPoint("BOTTOM", DART_TextureOptions_FrameLevel, "TOP", 0, 0);
378 DART_ControlOptions_ParamLabel:SetText(DART_TEXT.Parameters);
379 DART_ControlOptions_ResponseLabel:SetText(DART_TEXT.Parameters);
380 DL_Layout_ScrollButtons("DART_ControlOptions_ConditionMenu_Button", 7);
381 DART_ControlOptions_Response_Label:ClearAllPoints();
382 DART_ControlOptions_Response_Label:SetPoint("BOTTOM", DART_ControlOptions_Response, "TOP", 0, 0);
383 DART_ControlOptions_Condition_Label:ClearAllPoints();
384 DART_ControlOptions_Condition_Label:SetPoint("BOTTOM", DART_ControlOptions_Condition, "TOP", 0, 0);
385 DART_Set_OptionsScale();
386 DART_Initialize_TextureOptions();
387 DART_Initialize_MiscOptions();
388 end
389  
390 function DART_Main_OnLoad()
391 DiscordLib_RegisterInitFunc(DART_Initialize);
392 DiscordLib_RegisterFrameCreationFunc(DART_CreateAllFrames);
393  
394 SlashCmdList["DART"] = DART_Slash_Handler;
395 SLASH_DART1 = "/dart";
396 SLASH_DART2 = "/discordart";
397 end
398  
399 function DART_Options_SetProfile(index)
400 if (not index) and DART_Options then
401 index = DART_MiscOptions_SetProfile_Setting:GetText();
402 end
403 if (index == "" or (not index)) then return; end
404 DART_INDEX = index;
405 DART_Settings[DART_PROFILE_INDEX] = index;
406 DART_Initialize_NewSettings();
407 DART_Initialize_Everything();
408 DL_Feedback(DART_TEXT.ProfileLoaded..index);
409 end
410  
411 function DART_Options_Toggle()
412 if (not DART_Options) then
413 DART_Load_Options();
414 end
415 if (DART_Options:IsVisible()) then
416 DART_Options:Hide();
417 else
418 DART_Options:Show();
419 end
420 end
421  
422 function DART_Set_DefaultSettings(index, ti)
423 DART_Settings[index][ti] = {};
424 DART_Settings[index][ti].hide = true;
425 DART_Settings[index][ti].hidebg = true;
426 DART_Settings[index][ti].xoffset = {};
427 DART_Settings[index][ti].yoffset = {};
428 DART_Settings[index][ti].attachpoint = {};
429 DART_Settings[index][ti].attachto = {};
430 DART_Settings[index][ti].drawlayer = "ARTWORK";
431 DART_Settings[index][ti].blendmode = "DISABLE";
432 for i=1,4 do
433 DART_Settings[index][ti].xoffset[i] = 0;
434 DART_Settings[index][ti].yoffset[i] = 0;
435 DART_Settings[index][ti].attachpoint[i] = 5;
436 DART_Settings[index][ti].attachto[i] = 5;
437 end
438 DART_Settings[index][ti].attachframe = {};
439 DART_Settings[index][ti].attachframe[1] = "UIParent";
440 DART_Settings[index][ti].alpha = 1;
441 DART_Settings[index][ti].height = 50;
442 DART_Settings[index][ti].width = 50;
443 DART_Settings[index][ti].scale = 1;
444 DART_Settings[index][ti].color = {r=1, g=1, b=1};
445 DART_Settings[index][ti].bgcolor = {r=0, g=0, b=0};
446 DART_Settings[index][ti].bordercolor = {r=1, g=1, b=1};
447 DART_Settings[index][ti].highlightcolor = {r=1, g=1, b=0};
448 DART_Settings[index][ti].bgalpha = 1;
449 DART_Settings[index][ti].borderalpha = 1;
450 DART_Settings[index][ti].highlightalpha = .3;
451 DART_Settings[index][ti].padding = 5;
452 DART_Settings[index][ti].texture = "";
453 DART_Settings[index][ti].coords = { 0, 1, 0, 1 };
454 DART_Settings[index][ti].text = { text="", hide=true, color={r=1, g=1, b=1}, height=20, width=100, attachpoint=2, attachto=2, xoffset=0, yoffset=0, justifyH=5, justifyV=5, alpha=1, fontsize=16};
455 DART_Settings[index][ti].text.drawlayer = "OVERLAY";
456 DART_Settings[index][ti].name = DART_TEXT.Texture..ti;
457 DART_Settings[index][ti].scripts = {};
458 DART_Settings[index][ti].parent = "UIParent";
459 DART_Settings[index][ti].strata = "BACKGROUND";
460 DART_Settings[index][ti].bgtexture = "Interface\\AddOns\\DiscordLibrary\\PlainBackdrop";
461 DART_Settings[index][ti].bordertexture = "Interface\\Tooltips\\UI-Tooltip-Border";
462 DART_Settings[index][ti].Backdrop = { tile=true, tileSize=16, edgeSize=16, left=5, right=5, top=5, bottom=5};
463 DART_Settings[index][ti].framelevel = 0;
464 end
465  
466 function DART_Set_OnUpdateSpeed()
467 if (not DART_Settings[DART_INDEX].updatespeed) then
468 DART_Settings[DART_INDEX].updatespeed = 30;
469 end
470 DART_UPDATE_SPEED = 1 / DART_Settings[DART_INDEX].updatespeed;
471 end
472  
473 function DART_Set_OptionsScale()
474 DART_Options:SetScale(DART_Settings[DART_INDEX].optionsscale);
475 DART_Options:ClearAllPoints();
476 DART_Options:SetPoint("CENTER", "UIParent", "CENTER", 0, 0);
477 end
478  
479 function DART_Slash_Handler(msg)
480 local command, param;
481 local index = string.find(msg, " ");
482  
483 if( index) then
484 command = string.sub(msg, 1, (index - 1));
485 param = string.sub(msg, (index + 1) );
486 else
487 command = msg;
488 end
489  
490 DART_Options_Toggle();
491 end
492  
493 function DART_Texture_OnClick()
494 this:StopMovingOrSizing()
495 DART_Texture_Process(7, arg1);
496 end
497  
498 function DART_Texture_OnDragStart()
499 if (not DART_DRAGGING_UNLOCKED) then return; end
500 if ((not DART_Settings[DART_INDEX][this:GetID()].attachframe[2]) or DART_Settings[DART_INDEX][this:GetID()].attachframe[2] == "") then
501 this.moving = true;
502 this:StartMoving();
503 else
504 DL_Debug(DART_TEXT.DragWarning);
505 end
506 end
507  
508 function DART_Texture_OnDragStop()
509 if (this.moving) then
510 this.moving = nil;
511 this:StopMovingOrSizing();
512 local settings = DART_Settings[DART_INDEX][this:GetID()];
513 local xoffset, yoffset = DART_Get_Offsets(this, settings.attachframe[1], settings);
514 this:ClearAllPoints();
515 this:SetPoint(DART_ATTACH_POINTS[settings.attachpoint[1]], settings.attachframe[1], DART_ATTACH_POINTS[settings.attachto[1]], xoffset, yoffset);
516 DART_Settings[DART_INDEX][this:GetID()].xoffset[1] = xoffset;
517 DART_Settings[DART_INDEX][this:GetID()].yoffset[1] = yoffset;
518 if (DART_Options and this:GetID() == DART_TEXTURE_INDEX) then
519 DART_Initialize_TextureOptions();
520 end
521 end
522 end
523  
524 function DART_Texture_OnEnter()
525 if (DART_Settings[DART_INDEX][this:GetID()].highlight) then
526 getglobal(this:GetName().."_Highlight"):Show();
527 end
528 DART_Texture_Process(3);
529 end
530  
531 function DART_Texture_OnEvent()
532 DART_Texture_Process(2, event);
533 end
534  
535 function DART_Texture_OnHide()
536 if (this.moving) then
537 this.moving = nil;
538 this:StopMovingOrSizing();
539 end
540 DART_Texture_Process(6);
541 end
542  
543 function DART_Texture_OnLeave()
544 if (DART_Settings[DART_INDEX][this:GetID()].highlight) then
545 getglobal(this:GetName().."_Highlight"):Hide();
546 end
547 DART_Texture_Process(4);
548 end
549  
550 function DART_Texture_OnLoad()
551 this:RegisterForDrag("LeftButton", "RightButton");
552 this:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp", "Button4Up", "Button5Up");
553 this.baseframelevel = this:GetFrameLevel();
554 end
555  
556 function DART_Texture_OnMouseDown()
557 DART_Texture_Process(9, arg1);
558 end
559  
560 function DART_Texture_OnMouseUp()
561 DART_Texture_Process(8, arg1);
562 end
563  
564 function DART_Texture_OnMouseWheel()
565 DART_Texture_Process(12, arg1);
566 end
567  
568 function DART_Texture_OnReceiveDrag()
569 DART_Texture_Process(13);
570 end
571  
572 function DART_Texture_OnShow()
573 DART_Texture_Process(5);
574 end
575  
576 function DART_Texture_OnUpdate()
577 if (not DART_INITIALIZED) then return; end
578 if (this.flashing) then
579 this.flashtime = this.flashtime - arg1;
580 if (this.flashtime < 0) then
581 this.flashtime = .5;
582 if (this.direction) then
583 this.direction = nil;
584 else
585 this.direction = 1;
586 end
587 end
588 if (this.direction) then
589 this:SetAlpha(1 - this.flashtime);
590 else
591 this:SetAlpha(.5 + this.flashtime);
592 end
593 end
594 this.updatetimer = this.updatetimer - arg1;
595 this.totalelapsed = this.totalelapsed + arg1;
596 if (this.updatetimer > 0) then return; end
597 this.updatetimer = DART_UPDATE_SPEED;
598  
599 local id = this:GetID();
600 local conditions = DART_Settings[DART_INDEX][id].Conditions;
601 if (conditions) then
602 local condition, response;
603 for i = 1, #conditions do
604 condition = conditions[i].condition;
605 response = conditions[i].response;
606 this = getglobal("DART_Texture_"..id);
607 local active;
608 if (condition == 0) then
609 active = true;
610 this.activeConditions[i] = nil;
611 elseif (condition == 9 or condition == 10) then
612 active = DL_CheckCondition[condition](this);
613 else
614 active = DL_CheckCondition[condition](conditions[i]);
615 end
616 for _,override in pairs(conditions[i].overrides) do
617 if (this.activeConditions[override]) then
618 active = nil;
619 break;
620 end
621 end
622  
623 if (active and (not this.activeConditions[i]) and response ~= 0) then
624 if (response == 1) then
625 DART_FauxHide(id);
626 elseif (response == 2) then
627 DART_FauxShow(id);
628 elseif (response == 3) then
629 DART_FauxHide(conditions[i].texture);
630 elseif (response == 4) then
631 DART_FauxShow(conditions[i].texture);
632 elseif (response == 5) then
633 getglobal("DART_Texture_"..id.."_Text"):Hide();
634 elseif (response == 6) then
635 getglobal("DART_Texture_"..id.."_Text"):Show();
636 elseif (response == 7) then
637 this:ClearAllPoints();
638 this:SetPoint(DART_ATTACH_POINTS[DART_Settings[DART_INDEX][id].attachpoint[1]], DART_Settings[DART_INDEX][id].attachframe[1], DART_ATTACH_POINTS[DART_Settings[DART_INDEX][id].attachto[1]], DART_Settings[DART_INDEX][id].xoffset[1], DART_Settings[DART_INDEX][id].yoffset[1] - conditions[i].amount);
639 elseif (response == 8) then
640 this:ClearAllPoints();
641 this:SetPoint(DART_ATTACH_POINTS[DART_Settings[DART_INDEX][id].attachpoint[1]], DART_Settings[DART_INDEX][id].attachframe[1], DART_ATTACH_POINTS[DART_Settings[DART_INDEX][id].attachto[1]], DART_Settings[DART_INDEX][id].xoffset[1] - conditions[i].amount, DART_Settings[DART_INDEX][id].yoffset[1]);
642 elseif (response == 9) then
643 this:ClearAllPoints();
644 this:SetPoint(DART_ATTACH_POINTS[DART_Settings[DART_INDEX][id].attachpoint[1]], DART_Settings[DART_INDEX][id].attachframe[1], DART_ATTACH_POINTS[DART_Settings[DART_INDEX][id].attachto[1]], DART_Settings[DART_INDEX][id].xoffset[1] + conditions[i].amount, DART_Settings[DART_INDEX][id].yoffset[1]);
645 elseif (response == 10) then
646 this:ClearAllPoints();
647 this:SetPoint(DART_ATTACH_POINTS[DART_Settings[DART_INDEX][id].attachpoint[1]], DART_Settings[DART_INDEX][id].attachframe[1], DART_ATTACH_POINTS[DART_Settings[DART_INDEX][id].attachto[1]], conditions[i].rx, conditions[i].ry);
648 elseif (response == 11) then
649 this:ClearAllPoints();
650 this:SetPoint(DART_ATTACH_POINTS[DART_Settings[DART_INDEX][id].attachpoint[1]], DART_Settings[DART_INDEX][id].attachframe[1], DART_ATTACH_POINTS[DART_Settings[DART_INDEX][id].attachto[1]], DART_Settings[DART_INDEX][id].xoffset[1], DART_Settings[DART_INDEX][id].yoffset[1] + conditions[i].amount);
651 elseif (response == 12) then
652 getglobal("DART_Texture_"..id.."_Texture"):SetAlpha(conditions[i].alpha);
653 elseif (response == 13) then
654 this:SetBackdropColor(DART_Settings[DART_INDEX][id].bgcolor.r, DART_Settings[DART_INDEX][id].bgcolor.g, DART_Settings[DART_INDEX][id].bgcolor.b, conditions[i].alpha);
655 elseif (response == 14) then
656 this:SetBackdropColor(conditions[i].color.r, conditions[i].color.g, conditions[i].color.b, DART_Settings[DART_INDEX][id].bgalpha);
657 elseif (response == 15) then
658 local texture = getglobal("DART_Texture_"..id.."_Texture");
659 local padding = conditions[i].padding;
660 texture:ClearAllPoints();
661 texture:SetPoint("TOPLEFT", this, "TOPLEFT", padding, -padding);
662 texture:SetPoint("BOTTOMRIGHT", this, "BOTTOMRIGHT", -padding, padding);
663 texture = getglobal("DART_Texture_"..id.."_Highlight");
664 texture:ClearAllPoints();
665 texture:SetPoint("TOPLEFT", this, "TOPLEFT", padding, -padding);
666 texture:SetPoint("BOTTOMRIGHT", this, "BOTTOMRIGHT", -padding, padding);
667 elseif (response == 16) then
668 this:SetBackdropBorderColor(DART_Settings[DART_INDEX][id].bordercolor.r, DART_Settings[DART_INDEX][id].bordercolor.g, DART_Settings[DART_INDEX][id].bordercolor.b, conditions[i].alpha);
669 elseif (response == 17) then
670 this:SetBackdropBorderColor(conditions[i].color.r, conditions[i].color.g, conditions[i].color.b, DART_Settings[DART_INDEX][id].borderalpha);
671 elseif (response == 18) then
672 getglobal("DART_Texture_"..id.."_Texture"):SetVertexColor(conditions[i].color.r, conditions[i].color.g, conditions[i].color.b, DART_Settings[DART_INDEX][id].alpha);
673 elseif (response == 19) then
674 local text = getglobal("DART_Texture_"..id.."_Text");
675 if (string.find(DART_Settings[DART_INDEX][id].font, "\\")) then
676 text:SetFont(DART_Settings[DART_INDEX][id].font, conditions[i].amount);
677 elseif (DART_Settings[DART_INDEX][id].font == "") then
678 text:SetFont("Fonts\\FRIZQT__.TTF", conditions[i].amount);
679 else
680 fontSet = text:SetFont("Interface\\AddOns\\DiscordArt\\CustomFonts\\"..DART_Settings[DART_INDEX][id].font, conditions[i].amount);
681 end
682 elseif (response == 20) then
683 this:SetHeight(conditions[i].amount);
684 elseif (response == 21) then
685 getglobal("DART_Texture_"..id.."_Highlight"):SetAlpha(conditions[i].alpha);
686 elseif (response == 22) then
687 getglobal("DART_Texture_"..id.."_Highlight"):SetVertexColor(conditions[i].color.r, conditions[i].color.g, conditions[i].color.b, DART_Settings[DART_INDEX][id].highlightalpha);
688 elseif (response == 23) then
689 this:SetScale(conditions[i].amount);
690 elseif (response == 24) then
691 getglobal("DART_Texture_"..id.."_Text"):SetAlpha(conditions[i].alpha);
692 elseif (response == 25) then
693 getglobal("DART_Texture_"..id.."_Text"):SetTextColor(conditions[i].color.r, conditions[i].color.g, conditions[i].color.b, DART_Settings[DART_INDEX][id].text.alpha);
694 elseif (response == 26) then
695 getglobal("DART_Texture_"..id.."_Text"):SetText(conditions[i].rtext);
696 elseif (response == 27) then
697 getglobal("DART_Texture_"..id.."_Texture"):SetTexture(conditions[i].rtext);
698 elseif (response == 28) then
699 this:SetWidth(conditions[i].amount);
700 elseif (response == 29) then
701 DART_StartFlashing(id);
702 elseif (response == 30) then
703 DART_StopFlashing(id);
704 end
705 end
706  
707 getglobal("DART_Texture_"..id).activeConditions[i] = active;
708 end
709 end
710  
711 DART_Texture_Process(1, this.totalelapsed);
712 this.totalelapsed = 0;
713 end
714  
715 function DART_Texture_Process(script, param, textureIndex)
716 if (not DART_INITIALIZED) then return; end
717 if (not textureIndex) then
718 textureIndex = this:GetID();
719 end
720 if (DART_Options and DART_ScriptOptions_ScrollFrame_Text:IsVisible()) then return; end
721 if (script == 1) then
722 if (not this.timer) then
723 this.timer = DART_UPDATE_SPEED;
724 end
725 this.timer = this.timer - param;
726 if (this.timer > 0) then
727 return;
728 else
729 this.timer = DART_UPDATE_SPEED;
730 end
731 end
732 if (getglobal("DART_Texture"..textureIndex.."_Script_"..DART_SCRIPT_LABEL[script])) then
733 getglobal("DART_Texture"..textureIndex.."_Script_"..DART_SCRIPT_LABEL[script])(param, textureIndex);
734 end
735 end
736  
737 function DART_Toggle_Dragging()
738 if (DART_DRAGGING_UNLOCKED) then
739 DART_DRAGGING_UNLOCKED = nil;
740 if (DART_Options) then
741 DART_Options_DragToggle:SetText(DART_TEXT.UnlockDragging);
742 end
743 else
744 DART_DRAGGING_UNLOCKED = true;
745 if (DART_Options) then
746 DART_Options_DragToggle:SetText(DART_TEXT.LockDragging);
747 end
748 end
749 end