local _, PocketPlot = ... local LSM = LibStub("LibSharedMedia-3.0") local fonts = AceGUIWidgetLSMlists.font local _, class = UnitClass("player") local Minimap = Minimap local GameTooltip = GameTooltip local GetPlayerMapPosition = C_Map.GetPlayerMapPosition local GetBestMapForUnit = C_Map.GetBestMapForUnit local db, clockBG, clockTime, classColor, coords, coordframe, wasIndoors PocketPlot.bg = CreateFrame("Frame", "PocketPlotBG", Minimap) local bg = PocketPlot.bg PocketPlot.bgTex = bg:CreateTexture("PocketPlotBGTexture") local bgTex = PocketPlot.bgTex local f = CreateFrame("Frame") --events frame PocketPlot.SetShape = function() Minimap:SetMaskTexture("Interface\\AddOns\\PocketPlot\\media\\"..db.shape) if db.shape == "Faded Circle" then bgTex:SetTexture("Interface\\AddOns\\PocketPlot\\media\\Circle") elseif db.shape == "Faded Edges" or db.shape == "Faded Square" then bgTex:SetTexture("Interface\\AddOns\\PocketPlot\\media\\Square") else bgTex:SetTexture("Interface\\AddOns\\PocketPlot\\media\\"..db.shape) end --so minimap buttons follow the border of the map, for any addons that support it GetMinimapShape = function() return PocketPlot.minimapButtonPaths[db.shape] or "ROUND" end end PocketPlot.ClassColors = function() if db.classbg then bgTex:SetVertexColor(classColor.r, classColor.g, classColor.b, db.alpha) else bgTex:SetVertexColor(db.bg.r, db.bg.g, db.bg.b, db.alpha) end if db.classfont then clockTime:SetTextColor(classColor.r, classColor.g, classColor.b) coords:SetTextColor(classColor.r, classColor.g, classColor.b) else clockTime:SetTextColor(1,1,1) coords:SetTextColor(1,1,1) end end PocketPlot.SetFonts = function() MinimapZoneText:SetFont(LSM:Fetch("font", db.lsmfont), db.zoneSize, db.fontFlag) --font and font size for zone text coords:SetFont(LSM:Fetch("font",db.lsmfont), db.coordSize, db.fontFlag) clockTime:SetFont(LSM:Fetch("font", db.lsmfont), db.clockSize, db.fontFlag) end PocketPlot.CoordPosition = function() local clockshown = db.clock local coordshown = db.coords TimeManagerClockButton:ClearAllPoints() coordframe:ClearAllPoints() if not db.top then if clockshown and not coordshown then clockTime:SetJustifyH("CENTER") TimeManagerClockButton:SetPoint("TOP", Minimap, "BOTTOM", 0, 0 + db.textOffset) end if coordshown and not clockshown then coords:SetJustifyH("CENTER") coordframe:SetPoint("TOP", Minimap, "BOTTOM", 0, 0 + db.textOffset) end if clockshown and coordshown then clockTime:SetJustifyH("LEFT") TimeManagerClockButton:SetPoint("TOPLEFT", Minimap, "BOTTOMLEFT", 2, 0 + db.textOffset) coords:SetJustifyH("RIGHT") coordframe:SetPoint("TOPRIGHT", Minimap, "BOTTOMRIGHT", 0, 0 + db.textOffset) end else if clockshown and not coordshown then clockTime:SetJustifyH("CENTER") TimeManagerClockButton:SetPoint("BOTTOM", Minimap, "TOP", 2, 0 + db.textOffset) end if coordshown and not clockshown then coords:SetJustifyH("CENTER") coordframe:SetPoint("BOTTOM", Minimap, "TOP", 0, 0 + db.textOffset) end if clockshown and coordshown then clockTime:SetJustifyH("LEFT") TimeManagerClockButton:SetPoint("BOTTOMLEFT", Minimap, "TOPLEFT", 0, 0 + db.textOffset) coords:SetJustifyH("RIGHT") coordframe:SetPoint("BOTTOMRIGHT", Minimap, "TOPRIGHT", 0, 0 + db.textOffset) end end end local throttle, posData = 0 local function UpdateCoords(self, elapsed) throttle = throttle + elapsed if throttle >= .3 then local mapID = GetBestMapForUnit("player") posData = GetPlayerMapPosition(mapID, "player") --posData:GetXY() ? if posData then coords:SetFormattedText("%.1f/%.1f", posData.x*100, posData.y*100) else coords:SetText("--/--") end throttle = 0 end end PocketPlot.CombatHide = function() if db.combatHide then f:RegisterEvent("PLAYER_REGEN_ENABLED") f:RegisterEvent("PLAYER_REGEN_DISABLED") else f:UnregisterEvent("PLAYER_REGEN_ENABLED") f:UnregisterEvent("PLAYER_REGEN_DISABLED") end end PocketPlot.PetBattleHide = function() if db.battleHide then f:RegisterEvent("PET_BATTLE_OPENING_START") f:RegisterEvent("PET_BATTLE_CLOSE") else f:UnregisterEvent("PET_BATTLE_OPENING_START") f:UnregisterEvent("PET_BATTLE_CLOSE") end if C_PetBattles.IsInBattle() and db.battleHide then Minimap:Hide() else Minimap:Show() end end PocketPlot.MinimapFade = function() if db.mmAlpha < 1 then f:RegisterEvent("ZONE_CHANGED_INDOORS") f:RegisterEvent("ZONE_CHANGED") f:RegisterEvent("MINIMAP_UPDATE_ZOOM") else f:UnregisterEvent("ZONE_CHANGED_INDOORS") f:UnregisterEvent("ZONE_CHANGED") f:UnregisterEvent("MINIMAP_UPDATE_ZOOM") end if not IsIndoors() then Minimap:SetAlpha(db.mmAlpha) end end local function MapSetup() Minimap:SetScale(db.scale) Minimap:SetFrameStrata(db.strata) Minimap:SetFrameLevel(db.level) --ZONE TEXT MinimapZoneTextButton:SetParent("Minimap") MinimapZoneTextButton:ClearAllPoints() MinimapZoneTextButton:SetPoint("TOP", Minimap, "TOP", 0, -1 + db.zoneTextOffset) --where the zone text is located MinimapZoneTextButton:SetFrameLevel(db.level + 2) MinimapZoneText:ClearAllPoints() MinimapZoneText:SetPoint("CENTER") if not db.zoneText then MinimapZoneTextButton:Hide() end --BORDER/SIZE MinimapBorder:Hide() MinimapBorderTop:Hide() PocketPlot.SetShape() bg:SetFrameLevel(db.level - 1) bg:SetPoint("CENTER", Minimap, "CENTER") bgTex:SetAllPoints() local size = Minimap:GetWidth() + db.insets bg:SetHeight(size) bg:SetWidth(size) --ZOOM WITH MOUSEWHEEL MinimapZoomIn:Hide() MinimapZoomOut:Hide() Minimap:EnableMouseWheel(true) Minimap:SetScript("OnMouseWheel", function(_, zoom) if zoom > 0 then Minimap_ZoomIn() else Minimap_ZoomOut() end end) --CLOCK clockBG, clockTime = TimeManagerClockButton:GetRegions() clockBG:Hide() clockTime:SetAllPoints(TimeManagerClockButton) if not db.clock then TimeManagerClockButton:Hide() end --BATTLEGROUND AND LFG QUEUE ICON QueueStatusMinimapButtonBorder:Hide() QueueStatusMinimapButton:ClearAllPoints() QueueStatusMinimapButton:SetPoint("BOTTOMLEFT", Minimap, "BOTTOMLEFT", 27, -4) --NEW MAIL ICON MiniMapMailBorder:Hide() MiniMapMailFrame:ClearAllPoints() MiniMapMailFrame:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMRIGHT", 4, -5) MiniMapMailIcon:SetTexture("Interface\\Minimap\\Tracking\\Mailbox.blp") --COORDINATES coordframe = CreateFrame("Frame", nil, Minimap) PocketPlot.coordframe = coordframe coordframe:SetHeight(28) coordframe:SetWidth(100) coordframe:EnableMouse(true) coords = coordframe:CreateFontString(nil, "OVERLAY") coords:SetParent(coordframe) coords:SetShadowOffset(1,-1) coords:SetShadowColor(0,0,0,1) coords:SetAllPoints(coordframe) coordframe:SetScript("OnEnter", function(self) GameTooltip:SetOwner(self, "ANCHOR_LEFT") GameTooltip:AddLine("Location Functions", 1,1,1) GameTooltip:AddLine("Click to display the world map.") GameTooltip:AddLine("Shift-click to input your coordinates into chat.") GameTooltip:Show() end) coordframe:SetScript("OnLeave", function() GameTooltip:Hide() end) coordframe:SetScript("OnMouseUp", function() if IsShiftKeyDown() then ChatFrame1EditBox:Show() ChatFrame1EditBox:SetFocus() ChatFrame1EditBox:Insert("["..coords:GetText().."]") else ToggleFrame(WorldMapFrame) end end) coordframe:Hide() --prevent OnUpdate from running until we're ready SetMapToCurrentZone() --force update for GetPlayerMapPosition() coordframe:SetScript("OnUpdate", UpdateCoords) if db.coords then coordframe:Show() end --CALENDAR BUTTON GameTimeFrame:SetAlpha(0) --Set alpha to 0 so that it's still hidden, but we'll see the ? flash for new invites GameTimeFrame:EnableMouse(false) GameTimeCalendarInvitesTexture:SetParent("Minimap") --TRACKING ICON/MENU --hidden, opens with shift-right click MiniMapTracking:ClearAllPoints() MiniMapTracking:SetPoint("CENTER", Minimap, "CENTER") MiniMapTracking:Hide() --CLICKS ON MINIMAP local oldOnClick = Minimap:GetScript("OnMouseUp") Minimap:SetScript("OnMouseUp", function(self, click) if click == "RightButton" then if IsShiftKeyDown() then MiniMapTrackingButton:Click() else GameTimeFrame_OnClick(GameTimeFrame) end else oldOnClick(self) end end) --FONTS & COLORS PocketPlot.SetFonts() PocketPlot.ClassColors() --FINISHING TOUCHES MiniMapWorldMapButton:Hide() if db.hideNorth then MinimapNorthTag:SetAlpha(0) --using SetAlpha because it reappears when toggling rotate minimap setting MinimapCompassTexture:SetAlpha(0) end MinimapCluster:EnableMouse(false) end local function PlayerLogin() db = PocketPlot.db LSM:Register("font", "Negotiate Free", "Interface\\AddOns\\PocketPlot\\media\\negotiate_free.ttf") classColor = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] or RAID_CLASS_COLORS[class] if CUSTOM_CLASS_COLORS then CUSTOM_CLASS_COLORS:RegisterCallback(PocketPlot.ClassColors) end MapSetup() PocketPlot.CoordPosition() PocketPlot.CombatHide() PocketPlot.PetBattleHide() PocketPlot.MinimapFade() PlayerLogin = nil end f:RegisterEvent("PLAYER_LOGIN") f:SetScript("OnEvent", function(self, event) if event == "PLAYER_LOGIN" then PlayerLogin() elseif event == "PLAYER_REGEN_DISABLED" or event == "PET_BATTLE_OPENING_START" then Minimap:Hide() elseif event == "PLAYER_REGEN_ENABLED" or event == "PET_BATTLE_CLOSE" then Minimap:Show() elseif event == "ZONE_CHANGED_INDOORS" or event == "MINIMAP_UPDATE_ZOOM" or event == "ZONE_CHANGED" then if IsIndoors() then Minimap:SetAlpha(1) Minimap:SetZoom(1) Minimap:SetZoom(0) else Minimap:SetAlpha(db.mmAlpha) end end end)