From c251274ee2642bc89651c8eabd372cca629f54e3 Mon Sep 17 00:00:00 2001 From: shagu Date: Wed, 27 Feb 2019 20:40:13 +0100 Subject: [PATCH] afkcam: add clock and reduce camera speed --- modules/afkcam.lua | 70 ++++++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/modules/afkcam.lua b/modules/afkcam.lua index 196e82ae..a6aa4c94 100644 --- a/modules/afkcam.lua +++ b/modules/afkcam.lua @@ -1,26 +1,35 @@ pfUI:RegisterModule("afkcam", function () - - local _, class = UnitClass("player") - local color = RAID_CLASS_COLORS[class] local MARKED_AFK_CAPTURE = string.gsub(_G.MARKED_AFK_MESSAGE, "%%s", "(.+)") local social_chats = { - "CHAT_MSG_WHISPER", - "CHAT_MSG_PARTY", - "CHAT_MSG_RAID", - "CHAT_MSG_RAID_LEADER", - "CHAT_MSG_RAID_WARNING", - "CHAT_MSG_BATTLEGROUND", - "CHAT_MSG_BATTLEGROUND_LEADER", - "CHAT_MSG_GUILD", - "CHAT_MSG_OFFICER"} - + "CHAT_MSG_SAY", + "CHAT_MSG_WHISPER", + "CHAT_MSG_PARTY", + "CHAT_MSG_RAID", + "CHAT_MSG_RAID_LEADER", + "CHAT_MSG_RAID_WARNING", + "CHAT_MSG_GUILD", + "CHAT_MSG_OFFICER" + } + local afkcam = CreateFrame("Frame", "pfAFKCam", WorldFrame) local overlay = CreateFrame("Button", "pfAFKCamOverlay", afkcam) + overlay.top = overlay:CreateTexture("pfAFKGradientTop", "BACKGROUND") + overlay.top:SetPoint("TOPLEFT", overlay, "TOPLEFT") + overlay.top:SetPoint("TOPRIGHT", overlay, "TOPRIGHT") + overlay.top:SetHeight(100) + overlay.top:SetTexture(1,1,1,1) + overlay.top:SetGradientAlpha("VERTICAL", 0,0,0,0, 0,0,0,1) + + overlay.bottom = overlay:CreateTexture("pfAFKGradientTop", "BACKGROUND") + overlay.bottom:SetPoint("BOTTOMLEFT", overlay, "BOTTOMLEFT") + overlay.bottom:SetPoint("BOTTOMRIGHT", overlay, "BOTTOMRIGHT") + overlay.bottom:SetHeight(100) + overlay.bottom:SetTexture(1,1,1,1) + overlay.bottom:SetGradientAlpha("VERTICAL", 0,0,0,1, 0,0,0,0) + overlay:SetFrameStrata("DIALOG") overlay:SetAllPoints(WorldFrame) - overlay.tex = overlay:CreateTexture("pfAFKCamOverlayShade", "OVERLAY") - overlay.tex:SetAllPoints(overlay) - overlay.tex:SetTexture(color.r,color.g,color.b,.05) + overlay:SetScript("OnMouseUp",function() SendChatMessage("","AFK") this._parent:stop() @@ -41,14 +50,13 @@ pfUI:RegisterModule("afkcam", function () chat:EnableMouse(false) chat:EnableMouseWheel(true) chat:SetHeight(150) - chat:SetPoint("TOPLEFT",overlay,"TOPLEFT") - chat:SetPoint("TOPRIGHT",overlay,"TOPRIGHT") + chat:SetWidth(500) + chat:SetPoint("BOTTOMLEFT",overlay,"BOTTOMLEFT", 10, 10) chat:SetTimeVisible(1800.0) chat:SetMaxLines(500) chat:SetFading(false) chat:SetJustifyH("LEFT") - --chat:SetInsertMode("TOP") -- not supported for scrollingmessageframe till 2.3 - chat:SetFont(pfUI.font_default, C.global.font_size + 2, "OUTLINE") + chat:SetFont(pfUI.font_default, C.global.font_size + 1, "OUTLINE") chat:SetScript("OnEvent", function() if not this:IsVisible() then return end local info = _G.ChatTypeInfo[string.gsub(event,"CHAT_MSG_","")] @@ -78,7 +86,21 @@ pfUI:RegisterModule("afkcam", function () overlay._parent = afkcam afkcam.overlay = overlay - + + clock = CreateFrame("Frame", "pfAFKClock", overlay) + clock:SetAllPoints(overlay) + clock.time = clock:CreateFontString("Status", "OVERLAY") + clock.time:SetFont("Interface\\AddOns\\pfUI\\fonts\\Hooge.ttf", 32, "THICKOUTLINE") + clock.time:SetJustifyH("CENTER") + clock.time:SetPoint("TOP", 0, -10) + clock:SetScript("OnUpdate", function() + if C.global.twentyfour == "0" then + clock.time:SetText(date("%I|cff33ffcc:|r%M %p")) + else + clock.time:SetText(date("%H|cff33ffcc:|r%M")) + end + end) + function afkcam:start() afkcam._speed = GetCVar("cameraYawMoveSpeed") afkcam._ownname = GetCVar("UnitNameOwn") @@ -91,13 +113,13 @@ pfUI:RegisterModule("afkcam", function () if afkcam._ownname == "0" then SetCVar("UnitNameOwn", "1") end - SetCVar("cameraYawMoveSpeed","15") + SetCVar("cameraYawMoveSpeed","8") MoveViewRightStart() afkcam.overlay:Show() afkcam.overlay.chat:Clear() afkcam._spinning = true end - + function afkcam:stop() MoveViewRightStop() SetCVar("cameraYawMoveSpeed",afkcam._speed) @@ -110,7 +132,7 @@ pfUI:RegisterModule("afkcam", function () afkcam.overlay:Hide() afkcam._spinning = false end - + afkcam:SetScript("OnEvent", function() if event == "CHAT_MSG_SYSTEM" then if (arg1 == _G.MARKED_AFK) or strfind(arg1, MARKED_AFK_CAPTURE) then