WIM_ButtonsHooked = false; WIM_TradeSkillIsHooked = false; WIM_CraftSkillIsHooked = false; WIM_InspectIsHooked = false; function WIM_ChatFrame_ReplyTell(chatFrame) if(WIM_Data.hookWispParse and WIM_Data.enableWIM and WIM_Data.popOnSend and not (WIM_Data.popCombat and UnitAffectingCombat("player"))) then if ( not chatFrame ) then chatFrame = DEFAULT_CHAT_FRAME; end local lastTell = ChatEdit_GetLastTellTarget(); if ( lastTell ~= "" ) then WIM_PostMessage(lastTell, "", 5, "", "*CLEAR*"); end else WIM_ChatFrame_ReplyTell_orig(chatFrame); end end function WIM_ChatFrame_ReplyTell2(chatFrame) if(WIM_Data.hookWispParse and WIM_Data.enableWIM and WIM_Data.popOnSend and not (WIM_Data.popCombat and UnitAffectingCombat("player"))) then if ( not chatFrame ) then chatFrame = DEFAULT_CHAT_FRAME; end local lastTell = ChatEdit_GetLastToldTarget(); if ( lastTell ~= "" ) then WIM_PostMessage(lastTell, "", 5, "", "*CLEAR*"); end else WIM_ChatFrame_ReplyTell2_orig(chatFrame); end end function WIM_FriendsFrame_SendMessage() if(WIM_Data.enableWIM) then local name = GetFriendInfo(FriendsFrame.selectedFriend); WIM_PostMessage(name, "", 5, "", ""); else WIM_FriendsFrame_SendMessage_orig(); end end function WIM_ChatEdit_ExtractTellTarget(editBox, msg) -- Grab the first "word" in the string local target = gsub(msg, "(%s*)([^%s]+)(.*)", "%2", 1); if ( (strlen(target) <= 0) or (strsub(target, 1, 1) == "|") ) then return; end if(WIM_Data.hookWispParse and WIM_Data.enableWIM and WIM_Data.popOnSend and not (WIM_Data.popCombat and UnitAffectingCombat("player"))) then target = string.gsub(target, "^%l", string.upper) WIM_PostMessage(target, "", 5, "", ""); editBox:SetText(""); editBox:Hide(); else WIM_ChatEdit_ExtractTellTarget_orig(editBox, msg); end end function WIM_HookInspect() if(WIM_InspectIsHooked) then return; end if(SuperInspectFrame) then WIM_SuperInspect_InspectPaperDollItemSlotButton_OnClick_orig = SuperInspect_InspectPaperDollItemSlotButton_OnClick; SuperInspect_InspectPaperDollItemSlotButton_OnClick = WIM_SuperInspect_InspectPaperDollItemSlotButton_OnClick; WIM_InspectIsHooked = true; end --DEFAULT_CHAT_FRAME:AddMessage("Hooking Complete."); end function WIM_AllInOneInventoryFrameItemButton_OnClick(button, ignShift) if ( IsShiftKeyDown() ) then if ( WIM_EditBoxInFocus ) then local bag, slot = AllInOneInventory_GetIdAsBagSlot(this:GetID()); WIM_EditBoxInFocus:Insert(GetContainerItemLink(bag, slot)); end end WIM_AllInOneInventoryFrameItemButton_OnClick_orig(button, ignShift); end function WIM_SuperInspect_InspectPaperDollItemSlotButton_OnClick(button, ignoreModifiers) local itemLink = this.link; if ( IsShiftKeyDown() ) then if ( WIM_EditBoxInFocus ) then local link = "|c"..this.c.."|H"..itemLink.."|h["..GetItemInfo(itemLink).."]|h|r"; WIM_EditBoxInFocus:Insert(link); end end WIM_SuperInspect_InspectPaperDollItemSlotButton_OnClick_orig(button, ignoreModifiers); end function WIM_EngInventory_ItemButton_OnClick(arg1, arg2) if(arg1 == "LeftButton" and IsShiftKeyDown()) then if(WIM_EditBoxInFocus) then local bar, position, itm, bagnum, slotnum; if (EngInventory_buttons[this:GetName()] ~= nil) then bar = EngInventory_buttons[this:GetName()]["bar"]; position = EngInventory_buttons[this:GetName()]["position"]; bagnum = EngInventory_bar_positions[bar][position]["bagnum"]; slotnum = EngInventory_bar_positions[bar][position]["slotnum"]; itm = EngInventory_item_cache[bagnum][slotnum]; if(itm) then WIM_EditBoxInFocus:Insert(GetContainerItemLink(itm["bagnum"], itm["slotnum"])); return; end end end end WIM_EngInventory_ItemButton_OnClick_orig(arg1, arg2); end function WIM_FriendsFrame_OnEvent() if(event == "WHO_LIST_UPDATE") then local numWhos, totalCount = GetNumWhoResults(); if(numWhos > 0) then for i=1, numWhos do local name, guild, level, race, class, zone = GetWhoInfo(i); if(WIM_Windows[name] and name ~= "" and name ~= nil) then if(WIM_Windows[name].waiting_who) then WIM_Windows[name].waiting_who = false; WIM_Windows[name].class = class; WIM_Windows[name].level = level; WIM_Windows[name].race = race; WIM_Windows[name].guild = guild; WIM_Windows[name].location = zone; WIM_SetWhoInfo(name); SetWhoToUI(0); return; end end end else SetWhoToUI(0); return; end end WIM_FriendsFrame_OnEvent_orig(event); end function WIM_SetItemRef (link, text, button) if (WIM_isLinkURL(link)) then WIM_DisplayURL(link); return; end if(WIM_EditBoxInFocus and IsShiftKeyDown()) then if (strsub(link, 1, 6) == "player") then local namelink = strsub(link, 8); local name, lineid = strsplit(":", namelink); if ( name and (strlen(name) > 0) ) then name = gsub(name, "([^%s]*)%s+([^%s]*)%s+([^%s]*)", "%3"); name = gsub(name, "([^%s]*)%s+([^%s]*)", "%2"); WIM_EditBoxInFocus:Insert(name); end else WIM_EditBoxInFocus:Insert(text); end end WIM_SetItemRef_orig(link, text, button); end --Core hooking function. Allows compatibilty across all wow frames. function WIM_ChatEdit_InsertLink(text) if(WIM_EditBoxInFocus and IsShiftKeyDown()) then WIM_EditBoxInFocus:Insert(text); return true; else if ( ChatFrameEditBox:IsVisible() ) then ChatFrameEditBox:Insert(text); return true; else WIM_ChatEdit_InsertLink_orig(text); end end end function WIM_IgnoreMore(theUser) if(IsAddOnLoaded("IgnoreMore")) then local realm = GetRealmName() .. "-" .. UnitFactionGroup("player"); if(IgM_SV.enabled and type(IgM_SV.list) == "table" and type(IgM_SV.list[realm]) == "table" and type(IgM_SV.list[realm][theUser]) == "table") then return 2; else return 0; end else return 0; end end function WIM_SetUpHooks() if(WIM_ButtonsHooked) then return; end --Hook ChatFrame_ReplyTell & ChatFrame_ReplyTell2 WIM_ChatFrame_ReplyTell_orig = ChatFrame_ReplyTell; ChatFrame_ReplyTell = WIM_ChatFrame_ReplyTell; WIM_ChatFrame_ReplyTell2_orig = ChatFrame_ReplyTell2; ChatFrame_ReplyTell2 = WIM_ChatFrame_ReplyTell2; --Hook ChatEdit_InsertLink (If other addons follow this convension all will work the way it should. WIM_ChatEdit_InsertLink_orig = ChatEdit_InsertLink; ChatEdit_InsertLink = WIM_ChatEdit_InsertLink; --Hook Friends Frame Send Message Button WIM_FriendsFrame_SendMessage_orig = FriendsFrame_SendMessage; FriendsFrame_SendMessage = WIM_FriendsFrame_SendMessage; --Hook Chat Frame Whisper Parse WIM_ChatEdit_ExtractTellTarget_orig = ChatEdit_ExtractTellTarget; ChatEdit_ExtractTellTarget = WIM_ChatEdit_ExtractTellTarget; --Hook FriendsFrame_OnEvent WIM_FriendsFrame_OnEvent_orig = FriendsFrame_OnEvent; FriendsFrame_OnEvent = WIM_FriendsFrame_OnEvent; --Hook ChatFrame_OnEvent WIM_ChatFrame_MessageEventHandler_orig = ChatFrame_MessageEventHandler; ChatFrame_MessageEventHandler = WIM_ChatFrame_MessageEventHandler; --Hook SetItemRef WIM_SetItemRef_orig = SetItemRef; SetItemRef = WIM_SetItemRef; --Hook AllInOneInventory WIM_AllInOneInventoryFrameItemButton_OnClick_orig = AllInOneInventoryFrameItemButton_OnClick; AllInOneInventoryFrameItemButton_OnClick = WIM_AllInOneInventoryFrameItemButton_OnClick; --Hook EngInventory WIM_EngInventory_ItemButton_OnClick_orig = EngInventory_ItemButton_OnClick; EngInventory_ItemButton_OnClick = WIM_EngInventory_ItemButton_OnClick; WIM_ButtonsHooked = true; end function WIM_AddonDetectToHook(theAddon) if(theAddon == "SuperInspect_UI" or theAddon == "Blizzard_InspectUI") then WIM_HookInspect(); end end