vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local Original_ChatFrame_SendTell; |
2 | local CTrg_Function_Hooked = nil; |
||
3 | local CTrg_Status_On = true; |
||
4 | |||
5 | function ClickTarget_HookFunction() |
||
6 | --[[ Original_ChatFrame_SendTell = ChatFrame_SendTell; |
||
7 | ChatFrame_SendTell = ClickTarget_ChatFrame_SendTell; ]] |
||
8 | oldSetItemRef = SetItemRef; |
||
9 | SetItemRef = ClickTarget_SetItemRef; |
||
10 | CTrg_Function_Hooked = true; |
||
11 | end |
||
12 | |||
13 | function ClickTarget_UnhookFunction() |
||
14 | if (ChatFrame_SendTell==ClickTarget_ChatFrame_SendTell) then |
||
15 | ChatFrame_SendTell = Original_ChatFrame_SendTell; |
||
16 | CTrg_Function_Hooked = nil; |
||
17 | end; |
||
18 | end |
||
19 | |||
20 | function ClickTarget_OnLoad() |
||
21 | ClickTarget_HookFunction(); |
||
22 | if (CTrg_invite==nil) then |
||
23 | local CTrg_invite = true; |
||
24 | end; |
||
25 | |||
26 | SlashCmdList["CLICKTARGETSLASH"] = ClickTarget_Slash; |
||
27 | SLASH_CLICKTARGETSLASH1 = "/clicktarget"; |
||
28 | SLASH_CLICKTARGETSLASH2 = "/ctrg"; |
||
29 | end |
||
30 | |||
31 | function ClickTarget_Slash(msg) |
||
32 | msg = string.lower(msg); |
||
33 | if (msg == "invite") then |
||
34 | if (CTrg_invite) then |
||
35 | CTrg_invite = false; |
||
36 | DEFAULT_CHAT_FRAME:AddMessage("ClickTarget alt-inviting disabled"); |
||
37 | elseif (not CTrg_invite) then |
||
38 | CTrg_invite = true; |
||
39 | DEFAULT_CHAT_FRAME:AddMessage("ClickTarget alt-inviting enabled"); |
||
40 | end; |
||
41 | else |
||
42 | DEFAULT_CHAT_FRAME:AddMessage("/clicktaget invite - toggle alt-clicking for invite"); |
||
43 | DEFAULT_CHAT_FRAME:AddMessage("/ctrg can be used instead of /clicktarget"); |
||
44 | end; |
||
45 | end |
||
46 | |||
47 | function ClickTarget_OnEvent(event) |
||
48 | if (event=="UNIT_FOCUS") then |
||
49 | ClickTarget_Focus(); |
||
50 | elseif (event=="VARIABLES_LOADED") then |
||
51 | ClickTarget_OnLoad(); |
||
52 | end; |
||
53 | end |
||
54 | |||
55 | function ClickTarget_Focus() |
||
56 | if (IsAltKeyDown() and UnitIsPlayer("target") and CTrg_invite) then |
||
57 | InviteByName(UnitName("target")); |
||
58 | end; |
||
59 | end |
||
60 | |||
61 | function ClickTarget_SetItemRef(link) |
||
62 | local frameName = this:GetName(); |
||
63 | if (strsub(strlower(link), 1, 6) == "player") then |
||
64 | name = strsub(link, 8); |
||
65 | if (name and (strlen(name) > 0)) then |
||
66 | local _,_,realname = string.find(name,'([^%s]+)$'); |
||
67 | if (IsControlKeyDown() and arg3 == "RightButton") then |
||
68 | if (TargetLogHistoryFrame) then |
||
69 | TargetLog_AddGrudge(realname, "false"); |
||
70 | end |
||
71 | elseif (IsControlKeyDown()) then |
||
72 | TargetByName(realname); |
||
73 | elseif (IsAltKeyDown() and arg3 == "RightButton") then |
||
74 | AddFriend(realname); |
||
75 | elseif (IsAltKeyDown() and CTrg_invite) then |
||
76 | InviteByName(realname); |
||
77 | elseif (IsShiftKeyDown()) then |
||
78 | SendWho("n-"..realname); |
||
79 | elseif (arg3 == "RightButton" and ChatFrameEditBox:IsVisible()) then |
||
80 | ChatFrameEditBox:Insert(realname .. " "); |
||
81 | else |
||
82 | DEFAULT_CHAT_FRAME.editBox.chatType = "WHISPER"; |
||
83 | DEFAULT_CHAT_FRAME.editBox.tellTarget = realname; |
||
84 | ChatEdit_UpdateHeader(DEFAULT_CHAT_FRAME.editBox); |
||
85 | if (not DEFAULT_CHAT_FRAME.editBox:IsVisible()) then |
||
86 | ChatFrame_OpenChat("", DEFAULT_CHAT_FRAME); |
||
87 | end |
||
88 | end |
||
89 | end |
||
90 | return; |
||
91 | end |
||
92 | oldSetItemRef(link); |
||
93 | end |