WoWInterface SVN SoopUI

[/] [trunk/] [3.0.0rc1/] [SoopUI/] [Modules/] [Minimap/] [sMinimap.lua] - Rev 7

Compare with Previous | Blame | View Log

--      ___         ___         ___         ___      ___               
--     /  /\       /  /\       /  /\       /  /\    /__/\      ___     
--    /  /:/_     /  /::\     /  /::\     /  /::\   \  \:\    /  /\    
--   /  /:/ /\   /  /:/\:\   /  /:/\:\   /  /:/\:\   \  \:\  /  /:/    
--  /  /:/ /::\ /  /:/  \:\ /  /:/  \:\ /  /:/~/:___  \  \:\/__/::\    
-- /__/:/ /:/\:/__/:/ \__\:/__/:/ \__\:/__/:/ /:/__/\  \__\:\__\/\:\__ 
-- \  \:\/:/~/:\  \:\ /  /:\  \:\ /  /:\  \:\/:/\  \:\ /  /:/  \  \:\/\
--  \  \::/ /:/ \  \:\  /:/ \  \:\  /:/ \  \::/  \  \:\  /:/    \__\::/
--   \__\/ /:/   \  \:\/:/   \  \:\/:/   \  \:\   \  \:\/:/     /__/:/ 
--     /__/:/     \  \::/     \  \::/     \  \:\   \  \::/      \__\/  
--     \__\/       \__\/       \__\/       \__\/    \__\/              
--                       v * e * r * s * i * o * n * 3
----------------------------------------------------------------------------
-- sMinimap
----------------------------------------------------------------------------

if not Soop["minimap"].enable == true then return end

local font = Soop["media"].font
local fontsize = 10
local fontflag = "OUTLINE"
local Scale = 1
local classcolors = true -- class color text

Minimap:ClearAllPoints()
Minimap:SetPoint("CENTER", minimaplol, "CENTER", 0, 0)
MinimapCluster:EnableMouse(false)
Minimap:SetSize(Soop["minimap"].size,Soop["minimap"].size)
Minimap:SetMaskTexture('Interface\\ChatFrame\\ChatFrameBackground')
Minimap:SetHitRectInsets(0, 0, 24*Scale, 24*Scale)
Minimap:SetFrameLevel(4)
Minimap:SetScale(Scale)
Minimap:SetArchBlobRingScalar(0);
Minimap:SetQuestBlobRingScalar(0);


if(IsAddOnLoaded('!ClassColors') and CUSTOM_CLASS_COLORS) then
        color = CUSTOM_CLASS_COLORS[select(2, UnitClass("player"))]
end

if classcolors == true then
        color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[select(2,UnitClass("player"))]
else
        color = {r=255/255, g=255/255, b=255/255 } 
end     

-- Hide in Combat
----------------------------------------------------------------------------
if Soop["minimap"].hideincombat then
local mmd = CreateFrame("Frame")
mmd:RegisterEvent("PLAYER_REGEN_ENABLED")
mmd:RegisterEvent("PLAYER_REGEN_DISABLED")
mmd:HookScript("OnEvent", function(self, event)
        if event == "PLAYER_REGEN_ENABLED" then
                MinimapCluster:Show()
        elseif event == "PLAYER_REGEN_DISABLED" then
                MinimapCluster:Hide()
                
        end
end)
end

local oldOnClick = Minimap:GetScript("OnMouseUp")
Minimap:SetScript("OnMouseUp", function(self,click)
        if(click=="RightButton") then
                ToggleDropDownMenu(1, nil, MiniMapTrackingDropDown, "cursor", 0, 0)
        elseif(click=="MiddleButton") then
                if (not CalendarFrame) then LoadAddOn("Blizzard_Calendar") end Calendar_Toggle() 
        else 
                oldOnClick(self)
        end
end)

-- Dungeon Difficulty
----------------------------------------------------------------------------
local rd = CreateFrame("Frame", nil, Minimap)
rd:SetSize(24, 8)
rd:RegisterEvent("PLAYER_ENTERING_WORLD")
rd:RegisterEvent("PLAYER_DIFFICULTY_CHANGED")
rd:RegisterEvent("GUILD_PARTY_STATE_UPDATED")

local rdt = rd:CreateFontString(nil, "OVERLAY")
rdt:SetPoint("TOP", Minimap, "TOP", 0, -5)
rdt:SetFont(font, fontsize, fontflag)

rd:SetScript("OnEvent", function()
        local _, _, difficulty, _, maxPlayers = GetInstanceInfo()

        if difficulty == 0 then
                rdt:SetText("")
        elseif maxPlayers == 3 then
                rdt:SetText("3")
        elseif difficulty == 1 then
                rdt:SetText("5")
        elseif difficulty == 2 then
                rdt:SetText("5H")
        elseif difficulty == 3 then
                rdt:SetText("10")
        elseif difficulty == 4 then
                rdt:SetText("25")
        elseif difficulty == 5 then
                rdt:SetText("10H")
        elseif difficulty == 6 then
                rdt:SetText("25H")
        elseif difficulty == 7 then
                rdt:SetText("LFR")
        elseif difficulty == 8 then
                rdt:SetText("5CM")
        elseif difficulty == 9 then
                rdt:SetText("40")
        end

        if GuildInstanceDifficulty:IsShown() then
                rdt:SetTextColor(color.r, color.g, color.b)
        else
                rdt:SetTextColor(color.r, color.g, color.b)
        end
end)

local function StripTextures(object, kill)
        for i=1, object:GetNumRegions() do
                local region = select(i, object:GetRegions())
                if region:GetObjectType() == "Texture" then
                        if kill then
                                region:Hide()
                        else
                                region:SetTexture(nil)
                        end
                end
        end             
end

-- Battleground queue
----------------------------------------------------------------------------
QueueStatusMinimapButton:SetParent(Minimap)
QueueStatusMinimapButton:ClearAllPoints()
QueueStatusMinimapButton:SetPoint("TOPRIGHT", 0, 0)
QueueStatusMinimapButtonBorder:Hide()
StripTextures(QueueStatusFrame)
CreateShadow(QueueStatusFrame)

MiniMapWorldMapButton:Hide()

local function UpdateLFGTooltip()
        QueueStatusFrame:ClearAllPoints()
        QueueStatusFrame:SetPoint("TOPRIGHT", QueueStatusMinimapButton, "TOPLEFT", 0, 0)
end
QueueStatusFrame:HookScript("OnShow", UpdateLFGTooltip)
QueueStatusFrame:SetFrameStrata("TOOLTIP")

MiniMapMailFrame:ClearAllPoints()
MiniMapMailFrame:SetPoint("BOTTOMRIGHT", Minimap, 0, 0)
MiniMapMailFrame:SetFrameStrata("LOW")
MiniMapMailIcon:SetTexture("Interface\\AddOns\\SoopUI\\Media\\mail.tga")
MiniMapMailBorder:Hide()

MiniMapTracking:ClearAllPoints()
MiniMapTracking:SetParent(Minimap)
MiniMapTracking:SetPoint('TOPLEFT', 0, 0)
MiniMapTracking:SetAlpha(0)
MiniMapTrackingBackground:Hide()
MiniMapTrackingButtonBorder:SetTexture(nil)
MiniMapTrackingButton:SetHighlightTexture(nil)
MiniMapTrackingIconOverlay:SetTexture(nil)
MiniMapTrackingIcon:SetTexCoord(0.065, 0.935, 0.065, 0.935)
MiniMapTrackingIcon:SetWidth(20)
MiniMapTrackingIcon:SetHeight(20)

-- Minimap frame
----------------------------------------------------------------------------
sMinimap = CreateFrame("Frame", "sMinimap", UIParent)
sMinimap:RegisterEvent("ADDON_LOADED")
sMinimap:SetScript("OnEvent", function(self, event, addon)

    sMinimap.tracking = CreateFrame("Frame", nil, Minimap)
        
        MiniMapTrackingButton:SetScript("OnEnter",function()
                MiniMapTracking:SetAlpha(1)
        sMinimap.tracking:SetAlpha(1)
        end)

    Minimap:SetScript("OnLeave", function()
        MiniMapTracking:SetAlpha(0)
        sMinimap.tracking:SetAlpha(0)
    end)
        
        MiniMapTrackingButton:SetScript("OnLeave", function()
        MiniMapTracking:SetAlpha(0)
        sMinimap.tracking:SetAlpha(0)
    end)
        
        MiniMapTrackingButton:SetScript("OnMouseUp", function(self,click)
            if(click=="RightButton") then
                    ToggleDropDownMenu(1, nil, MiniMapTrackingDropDown, "cursor", 0, 0)
                elseif(click=="MiddleButton") then
                        if (not CalendarFrame) then LoadAddOn("Blizzard_Calendar") end Calendar_Toggle() 
                end
        end)
        sMinimap.tracking.text = t
    self:UnregisterEvent(event)
end)

function GetMinimapShape() return "SQUARE" end

-- Hide shit we dont want
----------------------------------------------------------------------------
local dummy = function() end
local frames = {
    "MiniMapVoiceChatFrame",
    "MiniMapWorldMapButton",
    "MinimapZoneTextButton",
    "MiniMapMailBorder",
    "MiniMapInstanceDifficulty",
    "MinimapNorthTag",
    "MinimapZoomOut",
    "MinimapZoomIn",
    "MinimapBackdrop",
    "GameTimeFrame",
    "GuildInstanceDifficulty",
        "MiniMapChallengeMode",
        "MinimapBorderTop",
}
GameTimeFrame:SetAlpha(0)
GameTimeFrame:EnableMouse(false)
GameTimeCalendarInvitesTexture:SetParent("Minimap")

for i in pairs(frames) do
    _G[frames[i]]:Hide()
    _G[frames[i]].Show = dummy
end

Minimap:SetScript('OnMouseUp', function(self, button)
Minimap:StopMovingOrSizing()
    if (button == 'RightButton') then
        ToggleDropDownMenu(1, nil, MiniMapTrackingDropDown, self, - (Minimap:GetWidth() * 0.7), -3)
    elseif (button == 'MiddleButton') then
        ToggleCalendar()
    else
        Minimap_OnClick(self)
    end
end)

-- Mousewheel Zoom
----------------------------------------------------------------------------
Minimap:EnableMouseWheel(true)
Minimap:SetScript("OnMouseWheel", function(_, zoom)
    if zoom > 0 then
        Minimap_ZoomIn()
    else
        Minimap_ZoomOut()
    end
end)

-- Clock
----------------------------------------------------------------------------
if not IsAddOnLoaded("Blizzard_TimeManager") then
        LoadAddOn("Blizzard_TimeManager")
end
local clockFrame, clockTime = TimeManagerClockButton:GetRegions()
clockFrame:Hide()
clockTime:SetFont(Soop["media"].font, fontsize, fontflag)
clockTime:SetShadowOffset(0,0)
clockTime:SetTextColor(color.r, color.g, color.b)
TimeManagerClockButton:ClearAllPoints()
TimeManagerClockButton:SetPoint("BOTTOM", Minimap, "BOTTOM", 0, -9)
TimeManagerClockButton:SetScript('OnShow', nil)
TimeManagerClockButton:Hide()
TimeManagerClockButton:SetScript('OnClick', function(self, button)
        if(button=="RightButton") then
                if(self.alarmFiring) then
                        PlaySound('igMainMenuQuit')
                        TimeManager_TurnOffAlarm()
                else
                        ToggleTimeManager()
                end
        else
                ToggleCalendar()
        end
end)  
TimeManagerFrame:ClearAllPoints()
TimeManagerFrame:SetPoint("CENTER", Minimap, "CENTER", 0, 0)
TimeManagerFrame:SetClampedToScreen(true)
TimeManagerFrame:SetToplevel(true)

SlashCmdList["CALENDAR"] = function()
        ToggleCalendar()
end
SLASH_CALENDAR1 = "/cl"
SLASH_CALENDAR2 = "/calendar"

local cal = CreateFrame("Frame", nil, Minimap)
GameTimeFrame:HookScript("OnShow", cal.Show)
GameTimeFrame:SetScript("OnEvent", function(self, event, addon)
        
        
end)

if CalendarGetNumPendingInvites() ~= 0 then
                clockTime:SetTextColor(.67,.35,.35)
        else
                clockTime:SetTextColor(color.r, color.g, color.b)
end

Compare with Previous | Blame