local name, addon = ... addon['name'] = name addon['parentName'] = name addon['modsDir'] = 'Mods' local hooked = {} --[[*** Settings Start***]] local HideBorder = true -- Hides the editboxborder when not active local UnClamp = true -- Make the window movable (take care! you can move it out of your screen) local HideFriendButton = true -- Hide the friendsbutton local Unsticky = true -- Dont remember whispers for next enter local NoSay = true -- Dont default chat to say local realm local defaults = { ['cvars'] = { ['autoLootDefault'] = "1", -- ['consolidateBuffs'] = "0", }, ['dests'] = { ["Tirion"] = "Ritalein", ["Arygos"] = "Pastorella", ["Thrall"] = "Gurnsey", } } defaults['dests'][GetRealmName()] = defaults['dests'][GetRealmName()] or UnitName("player") local dest = defaults['dests'][GetRealmName()] local options = { } local rep = ERR_FRIEND_ONLINE_SS:gsub("%%s", "(.+)"):gsub("[%[%]]", "%%%1") local rosterOfficer = {} local rosterNotice = {} local db local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0") local function OnClick(self, button) if(IsShiftKeyDown() and button == "LeftButton") then addon['db']['global']['ldbicons'][name]['hide'] = not addon['db']['global']['ldbicons'][name]['hide'] if(ldbicon) then if(addon['db']['global']['ldbicons'][name]['hide']) then ldbicon:Hide(name) else ldbicon:Show(name) end end else if(InterfaceOptionsFrame:IsVisible() and not InCombatLockdown()) then InterfaceOptionsFrame:Hide() else InterfaceOptionsFrame_OpenToCategory(name) InterfaceOptionsFrame_OpenToCategory(name) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory end end end local postmaster = { ['Der Postmeister'] = true, ['The Postmaster'] = true, } local itemList = { "52306","52307","52308","52309","43248","52492", -- cata "83793","83794", -- mop "115990","115993", -- wod } local function itemCount() local cnt = 0 for _,v in ipairs(itemList) do cnt = cnt + GetItemCount(v) end return cnt end local function sendItem(id) for _,v in ipairs(itemList) do if(tonumber(v) == tonumber(id)) then return true end end return false end local function guildRoster(nameC) for i=1, GetNumGuildMembers() do local name, _, _, _, _, _, note, officernote = GetGuildRosterInfo(i) -- local name, rank, rankIndex, level, classDisplayName, zone, note, officernote, isOnline, status, class, achievementPoints, achievementRank, isMobile, canSoR, repStanding = GetGuildRosterInfo(index) local n = strsplit("-",name) if(name == nameC or n == nameC) then rosterOfficer[nameC] = officernote rosterNotice[nameC] = note return (rosterOfficer[nameC] and rosterOfficer[nameC]~="") and rosterOfficer[nameC] or (rosterNotice[nameC] or "") else -- end end for i=1,C_FriendList.GetNumFriends() do local name, _, _, _, _, _, note = C_FriendList.GetFriendInfo(i) if(name==nameC) then return note and note or "" end end for i=1,BNGetNumFriends() do local _, characterName, messageText, noteText if(BNGetFriendInfo) then _, _, _, _, characterName, _, _, _, _, _, _, messageText, noteText = BNGetFriendInfo(i) else local res = C_BattleNet.GetFriendAccountInfo(i) if(res and res['gameAccountInfo']) then characterName, messageText, noteText = res['gameAccountInfo']['characterName'],res['customMessage'],res['note'] end end if(characterName==nameC) then local line = "" if(noteText) then line = line .. noteText end if(messageText) then if(noteText) then line = line .. " | " end line = line .. messageText end return line end end print(format("Line 68-Debug zz_UI (%s)",nameC)) return "" end local function addNoticeR(link) return guildRoster(select(2,strsplit(":",select(3,string.find(link, "^|H(.+)|h%[.*%]"))))) end local function addNotice(self, event, msg, author, ...) if(msg and rep and string.find(msg,rep)) then return false, gsub(msg, " ", format(" (%s) ",addNoticeR(msg)) or " ",1), author, ... end return false end local function focusToggle(self) local name = self:GetName() if(self:HasFocus()) then _G[name..'Left']:Show() _G[name..'Right']:Show() _G[name..'Mid']:Show() else _G[name..'Left']:Hide() _G[name..'Right']:Hide() _G[name..'Mid']:Hide() end end local function hookFrame(self) if(not hooked[self]) then self:HookScript("OnEditFocusGained",focusToggle) self:HookScript("OnEditFocusLost",focusToggle) hooked[self] = true end return end local garrisonMaps = { [1152] = true, -- FW Horde Garrison Level 1 [1330] = true, -- FW Horde Garrison Level 2 [1153] = true, -- FW Horde Garrison Level 3 [1154] = true, -- FW Horde Garrison Level 4 [1158] = true, -- SMV Alliance Garrison Level 1 [1331] = true, -- SMV Alliance Garrison Level 2 [1159] = true, -- SMV Alliance Garrison Level 3 [1160] = true, -- SMV Alliance Garrison Level 4 } local function InGarrison() local name, instanceType, difficultyID, difficultyName, maxPlayers, dynamicDifficulty, isDynamic, instanceMapID, instanceGroupSize = GetInstanceInfo() if(garrisonMaps[instanceMapID]) then return true end return false end local function apply(eb) local d = 'PARTY' local i, t = IsInInstance() if (t=='raid') then d = 'RAID' elseif ((t=='party' and not InGarrison()) or t=='pvp') then d = 'INSTANCE_CHAT' elseif (not i and GetNumGroupMembers()>0) then d = 'PARTY' elseif IsInGuild() then d = 'GUILD' end eb:SetAttribute("chatType", d) -- eb:SetAttribute("stickyType", d) end local function chatHoverIn(cf,link,text) local typ = string.match(link, "^(.-):") -- print(typ,link) --[[ print(typ,link) local tbl = { strsplit(":", link) } for k,v in pairs(tbl) do print(v) end ]]-- if(typ == "item" or typ == "enchant" or typ == "spell" or typ == "quest" or typ == "currency") then GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR") GameTooltip:SetHyperlink(link) ShowUIPanel(GameTooltip) elseif(typ == "player") then local typ, name = string.match(link, "^(.-):(.*):(.*):") if(name) then GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR") GameTooltip:SetUnit(name) ShowUIPanel(GameTooltip) end end end local function chatHoverOut(cf,link,text) HideUIPanel(GameTooltip) end local function OnText(message) addon:OnText(name, message) end local ClassColorUnits = { ["target"] = { ["name"] = "TargetFrame", ["back"] = "TargetFrame", ["x-offset"] = -104, ["y-offset"] = 60, ["x-offset2"] = 6, ["y-offset2"] = -22, }, ["player"] = { ["name"] = "PlayerFrame", ["back"] = "PlayerFrameBackground", ["x-offset"] = 0, ["y-offset"] = 22, ["x-offset2"] = 0, ["y-offset2"] = 0, }, ["focus"] = { ["name"] = "FocusFrame", ["back"] = "FocusFrame", ["x-offset"] = -104, ["y-offset"] = 60, ["x-offset2"] = 6, ["y-offset2"] = -22, }, } local function updateClassColor(unit) if(unit and UnitExists(unit)) then local _,class = UnitClass(unit) if(class and RAID_CLASS_COLORS[class]) then if(ClassColorUnits[unit]) then local uf = _G[ClassColorUnits[unit]['name']] local bg = _G[ClassColorUnits[unit]['back']] if(not uf['unitClassColorBack']) then uf['unitClassColorBack'] = uf:CreateTexture(nil, "ARTWORK") uf['unitClassColorBack']:SetPoint("TOPLEFT", bg, ClassColorUnits[unit]['x-offset2'], ClassColorUnits[unit]['y-offset2']) uf['unitClassColorBack']:SetPoint("BOTTOMRIGHT", bg, ClassColorUnits[unit]['x-offset'], ClassColorUnits[unit]['y-offset']) uf['unitClassColorBack']:SetTexture("Interface\\TargetingFrame\\UI-StatusBar") end local col = RAID_CLASS_COLORS[class] if(not UnitIsPlayer(unit)) then uf['unitClassColorBack']:SetVertexColor(0, 0, 0, 0) else uf['unitClassColorBack']:SetVertexColor(col['r'], col['g'], col['b'],1) end end end end end local function OnEvent(self, event, arg1, ...) if(arg1 == name and event=="ADDON_LOADED") then if(PlayerFrame:IsUserPlaced()) then PlayerFrame:SetMoveable(false) else PlayerFrame:SetUserPlaced(true) PlayerFrame:ClearAllPoints() PlayerFrame:SetPoint("RIGHT", UIParent, "CENTER", 0, -140) end if(not TargetFrame:IsUserPlaced()) then TargetFrame:SetUserPlaced(true) TargetFrame:ClearAllPoints() TargetFrame:SetPoint("TOPLEFT", PlayerFrame, "TOPRIGHT",0,0) else TargetFrame:SetMoveable(false) end self:UnregisterEvent(event) -- Remove the cancel button (Reduce the taint caused by InterfaceOptionsFrame src: http://www.wowinterface.com/forums/showpost.php?p=275119&postcount=17 ) InterfaceOptionsFrameCancel:Hide() InterfaceOptionsFrameOkay:SetAllPoints(InterfaceOptionsFrameCancel) -- Make clicking cancel the same as clicking okay InterfaceOptionsFrameCancel:SetScript("OnClick", function() InterfaceOptionsFrameOkay:Click() end) if(HideFriendButton) then local fb = _G['QuickJoinToastButton'] if(fb) then fb:UnregisterAllEvents() if(not hooked[fb]) then fb:HookScript("OnShow", function(self) self:Hide() end) hooked[fb] = true end fb:Hide() end end if(Unsticky) then ChatTypeInfo['WHISPER']['sticky'] = 0 ChatTypeInfo['BN_WHISPER']['sticky'] = 0 end elseif(event == "PLAYER_TARGET_CHANGED") then updateClassColor("target") elseif(event == "PLAYER_FOCUS_CHANGED") then updateClassColor("focus") elseif(event == "MAIL_SHOW") then -- sf_new() elseif(event == "UNIT_INVENTORY_CHANGED") then if(itemCount()<12) then return end if(UnitName("player") == dest) then self:UnregisterEvent(event) return end if(SendMailFrame:IsVisible())then local a,b = 0,0 local link,numberOfSlots local info,id = {},0 local full = 0 while(a<=NUM_BAG_SLOTS) do numberOfSlots = GetContainerNumSlots(a) b = 1 while(b<=numberOfSlots) do link = GetContainerItemLink(a, b) if(link) then id = addon:getItemId(link) -- print(id,link) if(sendItem(id)) then local _, itemCount, locked, _, _ = GetContainerItemInfo(a, b) if(not locked) then UseContainerItem(a, b) full = full + 1 if(full >= 12) then SendMail(dest,"Post",nil) full = 0 SELECTED_CHAT_FRAME:AddMessage("Sending") break end end end end b = b + 1 end a = a + 1 end end elseif(event == "UPDATE_CHAT_WINDOWS") then ChatFrame1:SetUserPlaced(true) ChatFrame1:SetClampedToScreen(false) ChatFrame1:ClearAllPoints() ChatFrame1:SetWidth(353) ChatFrame1:SetHeight(148) ChatFrame1:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT",32,30) local iname = "Friendlog" local ifound = false for i = 1, NUM_CHAT_WINDOWS do local cf = _G['ChatFrame'..i] cf.oldAlpha = cf.oldAlpha or 0 -- Fix 'max-bug' in FCF.lua cf:HookScript("OnHyperlinkEnter",chatHoverIn) cf:HookScript("OnHyperlinkLeave",chatHoverOut) local cfname, _, _, _, _, _, shown, _, _, _ = GetChatWindowInfo(i) if(cfname == iname) then ifound = true end if(UnClamp) then local cf = _G['ChatFrame'..i] cf:SetClampedToScreen(false) cf:Raise() end if(HideBorder) then local ef = _G['ChatFrame'..i..'EditBox'] focusToggle(ef) hookFrame(ef) end end if(not ifound) then local frame = FCF_OpenNewWindow(iname) FCF_CopyChatSettings(frame, DEFAULT_CHAT_FRAME) FCF_DockUpdate() end self:UnregisterEvent(event) elseif(event == 'PLAYER_ENTERING_WORLD') then for i = 1, NUM_CHAT_WINDOWS do if(NoSay) then local eb = _G['ChatFrame'..i..'EditBox'] apply(eb) if(not hooked['NoSay']) then hooked['NoSay'] = true end end end updateClassColor("player") elseif(event == 'MAIL_INBOX_UPDATE') then for i=GetInboxNumItems(),1,-1 do local packageIcon, stationeryIcon, sender, subject, money, CODAmount, daysLeft, hasItem, wasRead, wasReturned, textCreated, canReply, isGM =GetInboxHeaderInfo(i) if(postmaster[sender]) then if(money and money >0) then TakeInboxMoney(i) end if(hasItem) then for j = 1, ATTACHMENTS_MAX_RECEIVE do local name, texture, count, quality, canUse = GetInboxItem(i, j) if(name) then TakeInboxItem(i,j) end end end C_Timer.After(5, function() DeleteInboxItem(i) end) end end elseif(event == 'CHAT_MSG_SYSTEM') then -- http://www.wowinterface.com/downloads/info23035-AFKQuit.html if(arg1 and arg1 == IDLE_MESSAGE) then ForceQuit() end end end --[[ Start Healthbar color Phanx http://www.wowinterface.com/forums/showthread.php?p=302918#post302918 --]] local function OnMinMaxChanged(bar, minValue, maxValue) bar.maxValue = maxValue end local function SetValue(bar, value) bar:real_SetValue(value) local percent = value / bar.maxValue if percent > 0.5 then bar:SetStatusBarColor(2 * (1 - percent), 1, 0) else bar:SetStatusBarColor(1, 2 * percent, 0) end end local function HandleBar(bar) local _, maxValue = bar:GetMinMaxValues() bar.maxValue = maxValue bar.lockColor = true bar:HookScript("OnMinMaxChanged", OnMinMaxChanged) bar.real_SetValue = bar.SetValue bar.SetValue = SetValue end --[[ End Healthbar color Phanx http://www.wowinterface.com/forums/showthread.php?p=302918#post302918 --]] local function UpdateChar() local name = UnitName('player') local uname = name.."-"..realm local _,class = UnitClass("player") db['chardb'] = db['chardb'] or {} db['chardb'][uname] = db['chardb'][uname] or {} db['chardb'][uname]['level'] = UnitLevel("player") db['chardb'][uname]['class'] = class end local function getPref(pref) return db[pref[#pref]] end local function setPref(pref,value) db[pref[#pref]] = value end local function getUNames() local n = {} for k,v in pairs(db['chardb']) do n[#n+1] = k end return n end local brokers = {} function addon:RegisterBroker(brokerName, brokerFunc, default, defaults) brokers[brokerName] = { ['func'] = brokerFunc, ['default'] = default, ['defaults'] = defaults, } end do addon['preloads'][#addon['preloads'] + 1] = function(...) db = addon['db']['profile'][name] for broker, tab in pairs(brokers) do if(type(tab['defaults']) == 'table') then addon['db']['profile'][broker] = addon['db']['profile'][broker] or tab['defaults'] else addon['db']['profile'][broker] = addon['db']['profile'][broker] or {} end end for k, v in pairs(db['cvars']) do C_CVar.SetCVar(k,v) end end local function init(self, ...) realm = GetRealmName() options = addon:InitConfig(name, true, { ['type'] = "launcher", ['OnClick'] = OnClick }, getPref, setPref) for broker, tab in pairs(brokers) do addon:AddConfigEntry(name,"toggle",broker.."toggle",broker,"Enable/Disable "..broker.." on next reload",1,nil,nil,nil,nil,addon['options']['args'][name]) if(addon['db']['profile'][broker..'toggle'] or addon['db']['profile'][broker..'toggle'] == nil) then tab['func']() end end ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", addNotice) HandleBar(PlayerFrameHealthBar) HandleBar(TargetFrameHealthBar) UpdateChar() end addon:startup(name, name, init, nil, defaults) addon:RegisterFunc(addon:IsClassic() and {'MAIL_INBOX_UPDATE','PLAYER_TARGET_CHANGED','UPDATE_CHAT_WINDOWS','ADDON_LOADED','PLAYER_ENTERING_WORLD','CHAT_MSG_SYSTEM','MAIL_SHOW','MAIL_CLOSED'} or {'MAIL_INBOX_UPDATE','PLAYER_TARGET_CHANGED','PLAYER_FOCUS_CHANGED','UPDATE_CHAT_WINDOWS','ADDON_LOADED','PLAYER_ENTERING_WORLD','CHAT_MSG_SYSTEM','MAIL_SHOW','MAIL_CLOSED'},"OnEvent", OnEvent) end -- addon:RegisterEventThrottle(name,'UNIT_INVENTORY_CHANGED', 0.07, OnEvent)