WoWInterface SVN zz_Coords

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 68 to Rev 69
    Reverse comparison

Rev 68 → Rev 69

trunk/zz_Coords/core.lua
25,7 → 25,6
local db
local delayMapUpdate = .4
local delayOnUpdate = .5
local WorldMapFrame = TestWorldMapFrame and TestWorldMapFrame or WorldMapFrame
local function isoutbound()
mf = GetMouseFocus()
if(mf) then
218,15 → 217,15
end
zoneText = limitLength(zoneText,db['maxLength'])
end
local alreadyprinted = false
-- local alreadyprinted = false
local function MapFrame_OnUpdate()
C_Timer.After(delayMapUpdate, MapFrame_OnUpdate)
if(not alreadyprinted) then
--[[ if(not alreadyprinted) then
alreadyprinted=true
for k,v in pairs(WorldMapFrame) do
print(k,v)
end
end
end ]]
if(not WorldMapFrame.ScrollContainer:IsVisible()) then return end
setPlayerCoords()
local x,y = WorldMapFrame.ScrollContainer:GetCursorPosition()
235,8 → 234,9
local height = WorldMapFrame.ScrollContainer:GetHeight();
local adjustedY = addon['round']((centerY + (height/2) - y) / height * 100,1);
local adjustedX = addon['round']((x - (centerX - (width/2))) / width * 100,1);
local adjustedX, adjustedY = addon['GetXY']()
zz_CoordsMapFrameCoordText:SetText(format("%s%s",isoutbound() and L['outbound'] or L['COORDFMTSTRING']( mapFrame,adjustedX, adjustedY), playerCoords))
-- WorldMapFrameTitleText:SetText(adjustedX..", "..adjustedY)
WorldMapFrameTitleText:SetText(adjustedX..", "..adjustedY)
positionFrame()
if(isoutbound()) then
MouseOut(mapFrame)
trunk/zz_Coords/provider.lua
1,12 → 1,61
local name, addon = ...
local parentName = addon['parentName'] or "BrokerPack"
local childName = "zz_Coords"
-- Provides a basic interface for something that manages the adding, updating, and removing of data like icons, blobs or text to the map canvas
local MapCanvasDataProviderMixin = {};
local zzDataProvider = {};
local coordText
local mapframe
local zzDebug = false
 
function MapCanvasDataProviderMixin:OnAdded(owningMap)
function zzDataProvider:GetMap()
return self.owningMap;
end
local function GetXY()
local map = WorldMapFrame.ScrollContainer
local x, y = map:GetNormalizedCursorPosition();
local adjustedX = addon['round'](x * 100,1)
local adjustedY = addon['round'](y * 100,1)
return adjustedX,adjustedY
end
addon['GetXY'] = GetXY
local function update()
if(coordText) then
local x,y = GetXY()
local str = ""
local mapID = zzDataProvider:GetMap():GetMapID()
if(mapID) then
str = format("%s MapID: %i",str,mapID)
end
local
if(not(x == 100 or y==100 or x==0 or y==0)) then
str = format("%s Mouse: %i,%i",str,x,y)
end
coordText:SetText(str)
end
end
function zzDataProvider:OnAdded(owningMap)
-- Optionally override in your mixin, called when this provider is added to a map canvas
self.owningMap = owningMap;
if(not coordText or not mapframe) then
mapframe = CreateFrame("Frame", "zz_CoordsMapFrame2", WorldMapFrame)
mapframe:SetWidth(300)
mapframe:SetHeight(20)
mapframe:SetPoint("BOTTOMLEFT", WorldMapFrame, "BOTTOMLEFT", 10, 5)
mapframe:SetFrameStrata("HIGH")
mapframe.elapsed = 0
coordText = mapframe:CreateFontString(nil, "OVERLAY","GameFontNormal")
coordText:SetAllPoints(mapframe)
coordText:SetJustifyH("LEFT")
mapframe:SetScript("OnUpdate", function(self, elapsed)
self.elapsed = self.elapsed + elapsed
if(self.elapsed<0.2) then return end
self.elapsed = 0
update()
end)
end
end
 
function MapCanvasDataProviderMixin:OnRemoved(owningMap)
function zzDataProvider:OnRemoved(owningMap)
-- Optionally override in your mixin, called when this provider is removed from a map canvas
assert(owningMap == self.owningMap);
self.owningMap = nil;
19,112 → 68,87
end
end
 
function MapCanvasDataProviderMixin:RemoveAllData()
function zzDataProvider:RemoveAllData()
-- Override in your mixin, this method should remove everything that has been added to the map
if(mapframe) then
mapframe:Hide()
mapframe = nil
coordText = nil
end
end
 
function MapCanvasDataProviderMixin:RefreshAllData(fromOnShow)
function zzDataProvider:RefreshAllData(fromOnShow)
-- Override in your mixin, this method should assume the map is completely blank, and refresh any data necessary on the map
update()
end
 
function MapCanvasDataProviderMixin:OnShow()
function zzDataProvider:OnShow()
-- Override in your mixin, called when the map canvas is shown
end
 
function MapCanvasDataProviderMixin:OnHide()
function zzDataProvider:OnHide()
-- Override in your mixin, called when the map canvas is closed
end
 
function MapCanvasDataProviderMixin:OnMapInsetSizeChanged(mapInsetIndex, expanded)
function zzDataProvider:OnMapInsetSizeChanged(mapInsetIndex, expanded)
-- Optionally override in your mixin, called when a map inset changes sizes
end
 
function MapCanvasDataProviderMixin:OnMapInsetMouseEnter(mapInsetIndex)
function zzDataProvider:OnMapInsetMouseEnter(mapInsetIndex)
-- Optionally override in your mixin, called when a map inset gains mouse focus
end
 
function MapCanvasDataProviderMixin:OnMapInsetMouseLeave(mapInsetIndex)
function zzDataProvider:OnMapInsetMouseLeave(mapInsetIndex)
-- Optionally override in your mixin, called when a map inset loses mouse focus
end
 
function MapCanvasDataProviderMixin:OnCanvasScaleChanged()
function zzDataProvider:OnCanvasScaleChanged()
-- Optionally override in your mixin, called when the canvas scale changes
end
 
function MapCanvasDataProviderMixin:OnCanvasPanChanged()
function zzDataProvider:OnCanvasPanChanged()
-- Optionally override in your mixin, called when the pan location changes
end
 
function MapCanvasDataProviderMixin:OnCanvasSizeChanged()
function zzDataProvider:OnCanvasSizeChanged()
-- Optionally override in your mixin, called when the canvas size changes
end
 
function MapCanvasDataProviderMixin:OnEvent(event, ...)
function zzDataProvider:OnEvent(event, ...)
-- Override in your mixin to accept events register via RegisterEvent
end
 
function MapCanvasDataProviderMixin:OnGlobalAlphaChanged()
function zzDataProvider:OnGlobalAlphaChanged()
-- Optionally override in your mixin if your data provider obeys global alpha, called when the global alpha changes
end
 
function MapCanvasDataProviderMixin:OnMapChanged()
function zzDataProvider:OnMapChanged()
-- Optionally override in your mixin, called when map ID changes
self:RefreshAllData();
end
 
-- Provides a basic interface for something that is visible on the map canvas, like icons, blobs or text
local MapCanvasPinMixin = {};
 
function MapCanvasPinMixin:OnLoad()
-- Override in your mixin, called when this pin is created
function zzDataProvider:RegisterEvent(event)
-- Since data providers aren't frames this provides a similar method of event registration, but always calls self:OnEvent(event, ...)
if not self.registeredEvents then
self.registeredEvents = {}
end
if not self.registeredEvents[event] then
self.registeredEvents[event] = true;
self:GetMap():AddDataProviderEvent(event);
end
end
 
function MapCanvasPinMixin:OnAcquired(...) -- the arguments here are anything that are passed into AcquirePin after the pinTemplate
-- Override in your mixin, called when this pin is being acquired by a data provider but before its added to the map
function zzDataProvider:UnregisterEvent(event)
if self.registeredEvents and self.registeredEvents[event] then
self.registeredEvents[event] = nil;
self:GetMap():RemoveDataProviderEvent(event);
end
end
 
function MapCanvasPinMixin:OnReleased()
-- Override in your mixin, called when this pin is being released by a data provider and is no longer on the map
function zzDataProvider:SignalEvent(event, ...)
if self.registeredEvents and self.registeredEvents[event] then
self:OnEvent(event, ...);
end
end
 
function MapCanvasPinMixin:OnClick(button)
-- Override in your mixin, called when this pin is clicked
end
 
function MapCanvasPinMixin:OnMouseEnter()
-- Override in your mixin, called when the mouse enters this pin
end
 
function MapCanvasPinMixin:OnMouseLeave()
-- Override in your mixin, called when the mouse leaves this pin
end
 
function MapCanvasPinMixin:OnMouseDown()
-- Override in your mixin, called when the mouse is pressed on this pin
end
 
function MapCanvasPinMixin:OnMouseUp()
-- Override in your mixin, called when the mouse is released
end
 
function MapCanvasPinMixin:OnMapInsetSizeChanged(mapInsetIndex, expanded)
-- Optionally override in your mixin, called when a map inset changes sizes
end
 
function MapCanvasPinMixin:OnMapInsetMouseEnter(mapInsetIndex)
-- Optionally override in your mixin, called when a map inset gains mouse focus
end
 
function MapCanvasPinMixin:OnMapInsetMouseLeave(mapInsetIndex)
-- Optionally override in your mixin, called when a map inset loses mouse focus
end
 
 
 
function MapCanvasPinMixin:OnCanvasPanChanged()
-- Optionally override in your mixin, called when the pan location changes
end
 
function MapCanvasPinMixin:OnCanvasSizeChanged()
-- Optionally override in your mixin, called when the canvas size changes
end
WorldMapFrame:AddDataProvider(zzDataProvider)
\ No newline at end of file