This commit is contained in:
Robin 2021-01-13 16:13:33 +01:00
commit d15e7273f1
11 changed files with 478 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "Common"]
path = Common
url = https://git.grml.de/rilgamon/Common.git

3
Bindings.xml Normal file
View File

@ -0,0 +1,3 @@
<Bindings>
<Binding name="COORDS_TOGGLE" header="COORDS" category="ADDONS">zzCoords_MinimapToggle()</Binding>
</Bindings>

1
Common Submodule

@ -0,0 +1 @@
Subproject commit 762c59c6c6abc6ecaa71f3e36bb2c6dd16b8e0ed

188
core.lua Normal file
View File

@ -0,0 +1,188 @@
local name, addon = ...
local childName = "zz_Coords"
local defaults = {
["colorLDB"] = true,
["ShowZone"] = false,
["ShowSubZone"] = true,
["ShowTooltip"] = false,
["windowX"] = 10,
["windowY"] = 5
}
local options = {
}
local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local ldbicon = LibStub("LibDBIcon-1.0")
local db, playerCoords, zoneText, coordsline
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
local delayOnUpdate = .5
function addon:GetPlayerCoords()
return playerCoords
end
local function setPlayerCoords()
playerCoords = "-, -"
local mapID = C_Map.GetBestMapForUnit("player")
if(mapID) then
local pmp = C_Map.GetPlayerMapPosition(mapID,"player")
if(pmp) then
local x,y = pmp:GetXY()
if(x and y) then
playerCoords = format("%.1f, %.1f", x*100, y*100)
end
end
end
end
local colorlist = {
['friendly'] = "00ff00",
['arena'] = "ffff00",
['sanctuary'] = "9999ff",
}
local function pvpColor(txt)
local col
local pvpType, isFFA, faction = GetZonePVPInfo()
if(colorlist[pvpType]) then
col = colorlist[pvpType]
elseif(pvpType == "hostile" or pvpType == "combat" or pvpType=="contested") then
col = faction == select(2,UnitFactionGroup('player')) and "886600" or "ff0000"
else
return txt
end
return addon:colorize(txt, col)
end
local function OnText(message)
addon:OnText(childName, message or "")
end
local function OnTooltip(tip)
local p = tip:GetParent()
if(p.tooltip) then
tip = p.tooltip
end
tip:AddLine(childName)
tip:AddLine(GetRealZoneText())
tip:AddLine(GetSubZoneText())
tip:AddLine(format("%s: %s",childName,tostring(playerCoords)))
tip:AddLine(L['HINT'])
tip:AddLine(L['HINT2'])
tip:AddLine(L['HINT3'])
tip:AddLine(L['HINT4'])
end
local function OnButton(self, button)
if(button == 'RightButton') then
if(IsShiftKeyDown()) then
zzCoords_MinimapToggle()
else
InterfaceOptionsFrame_OpenToCategory(childName)
InterfaceOptionsFrame_OpenToCategory(childName)
end
elseif(button == "LeftButton") then
if(IsShiftKeyDown()) then
local db = addon['db']['global']['ldbicons']
db[childName]['hide'] = not db[childName]['hide']
if(ldbicon) then
if(db[childName]['hide']) then
ldbicon:Hide(childName)
else
ldbicon:Show(childName)
end
end
else
ToggleFrame(WorldMapFrame)
end
end
end
local function OnDataUpdate()
setPlayerCoords()
if(zoneText and zoneText~="") then
if(db['hideLDBCoords']) then
coordsline = "%s"
else
coordsline = "%s (%s)"
end
OnText(format(coordsline,(db['colorLDB'] and pvpColor(zoneText) or zoneText) or "", playerCoords or ""))
else
if(db['hideLDBCoords']) then
OnText("")
else
OnText(playerCoords or "")
end
end
C_Timer.After(delayOnUpdate, OnDataUpdate)
end
local function limitLength(info, maxlength)
if(info and maxlength) then
if(maxlength > 0 and info:len() > maxlength) then
info = info:sub(1,maxlength).."~"
end
end
return info
end
local function ZONED()
zoneText = db['ShowZone'] and GetRealZoneText() or ""
if(db['ShowSubZone']) then
if(GetSubZoneText() and GetSubZoneText()~="") then
if(db['ShowZone']) then
zoneText = zoneText ~= GetSubZoneText() and format("%s, %s",zoneText,GetSubZoneText()) or zoneText
else
zoneText = GetSubZoneText()
end
elseif(not db['ShowZone']) then
zoneText = GetRealZoneText()
end
end
zoneText = limitLength(zoneText,db['maxLength'])
if(not db['hideMapCoords']) then
addon['mapframe']:Show()
else
addon['mapframe']:Hide()
end
end
local function getPref(pref)
return db[pref[#pref]]
end
local function setPref(pref,value)
db[pref[#pref]] = value
ZONED()
end
local function init()
options = addon:InitConfig(childName, true, {
['type'] = "data source",
['OnTooltipShow'] = OnTooltip,
['OnClick'] = OnButton,
}, getPref, setPref)
db = addon['db']['profile'][childName]
C_Timer.After(delayOnUpdate, OnDataUpdate)
BINDING_HEADER_COORDS = childName
BINDING_NAME_COORDS_TOGGLE = L["Toggle Minimap"]
addon:AddConfigEntry(childName,"toggle","hideLDBCoords",L['Hide LDB coords'],L['This hides the coords-display in your broker display'],2,nil,nil,nil,nil,options['args'][childName])
addon:AddConfigEntry(childName,"toggle","colorLDB",L['Colorized Zone'],L['Show PvP informations about current area'],1,nil,nil,nil,nil,options['args'][childName])
addon:AddConfigEntry(childName,"toggle","hideMapCoords",L['Hide Map coords'],L['This hides the coords-display at the bottom of your map'],2,nil,nil,nil,nil,options['args'][childName])
addon:AddConfigEntry(childName,"toggle","ShowZone",L['Show Zone'],nil,1,nil,nil,nil,nil,options['args'][childName])
addon:AddConfigEntry(childName,"toggle","ShowSubZone",L['Show Subzone'],nil,1,nil,nil,nil,nil,options['args'][childName])
addon:AddConfigEntry(childName,"toggle","ShowMapID",L['Show MapID'],nil,2,nil,nil,nil,nil,options['args'][childName])
addon:AddConfigEntry(childName,"range","maxLength",L['Max Length'],L['Limits the maximum length of the zone'],1,0,255,1,false,options['args'][childName])
addon:AddConfigEntry(childName,"header",'windowXY',L['Mapcoords Window'],nil,6,nil,nil,nil,nil,options['args'][childName])
addon:AddConfigEntry(childName,"range","windowX",L['Window X'],L['Adjusts the X-Offset on windowed map'],7,-512,512,1,false,options['args'][childName])
addon:AddConfigEntry(childName,"range","windowY",L['Window Y'],L['Adjusts the Y-Offset on windowed map'],8,-512,512,1,false,options['args'][childName])
addon:RegisterFunc({"ZONE_CHANGED_NEW_AREA","ZONE_CHANGED","ZONE_CHANGED_INDOORS","NEW_WMO_CHUNK"},"OnEvent", ZONED)
ZONED()
end
function zzCoords_MinimapToggle()
if(MinimapCluster:IsVisible()) then
MinimapCluster:Hide()
else
MinimapCluster:Show()
end
end
addon:startup(name, childName, init, true, defaults)

BIN
icon2.tga Normal file

Binary file not shown.

6
license.txt Normal file
View File

@ -0,0 +1,6 @@
The following license excludes the libraries (Libs) included. See the libraries directory or website.
This AddOn is public domain. That means you can change it, rename it or paint it yellow.
My name (Rilgamon) is valid only for WoWInterface.com and curse.com.
If you use/offer this addon on another website please remove my name.
If you want to give me credit you can replace it with a link to my profile on WoWInterface.com.

43
locale_deDE.lua Normal file
View File

@ -0,0 +1,43 @@
local addonname, addon = ...
local name = "zz_Coords"
local L = LibStub("AceLocale-3.0"):NewLocale(name, "deDE", false)
if L then
L[name] = name
L[name..' Settings'] = name..' Settings'
L['Hide Map coords'] = "Verstecke Map-Koordinaten"
L['Show MapID'] = "Zeige MapID auf der Weltkarte"
L['This hides the coords-display at the bottom of your map'] = "Deaktiviert die Anzeige der Koordinaten auf der Map"
L['outbound'] = "Zeiger: - -- Spieler: "
L['Player'] = "Spieler"
L['Cursor'] = "Zeiger"
L['COORDFMTSTRING'] = function(self,x,y) return format("Zeiger: %.1f, %.1f -- Spieler: ",addon:round(x,1),addon:round(y,1)) end
L['HINT'] = "|c0000ff00Linksklick|r |c00ffffff\195\182ffnet die Karte|r"
L['HINT2'] = "|c0000ff00Rechtsklick|r |c00ffffff\195\182ffnet Einstellungen|r"
L['HINT3'] = "|c0000ff00Shift-Linksklick|r |c00ffffffschaltet Minimapicon an/aus|r"
L['HINT4'] = "|c0000ff00Shift-Rechtsklick|r |c00ffffffschaltet Minimap an/aus|r"
L['Show Zone'] = "Zeige Zone"
L['Show Subzone'] = "Zeige Subzone"
L["Toggle Minimap"] = "Minimap ein-/ausschalten"
L['Max Length'] = "Max. L\195\164nge"
L['Limits the maximum length of the zone'] = "Limitiert die Anzeigel\195\164nge der Zone"
L['Mapcoords Screen'] = "Kartenkoordinaten Vollbild"
L['Mapcoords Window'] = "Kartenkoordinaten Fenster"
L['Screen X'] = "Vollbild X"
L['Adjusts the X-Offset on fullscreenmap'] = "Positioniert die X-Kartenkoordinate im Vollbild"
L['Screen Y'] = "Vollbild Y"
L['Adjusts the Y-Offset on fullscreenmap'] = "Positioniert die Y-Kartenkoordinate im Vollbild"
L['Window X'] = "Fenster X"
L['Adjusts the X-Offset on windowed map'] = "Positioniert die Y-Kartenkoordinate im Fenstermodus"
L['Window Y'] = "Fenster Y"
L['Adjusts the Y-Offset on windowed map'] = "Positioniert die Y-Kartenkoordinate im Fenstermodus"
L['Hide LDB coords'] = "Verstecke LDB-Koordinaten"
L['This hides the coords-display in your broker display'] = "Zeigt die Koordinaten im Display-Broker nicht an"
L['Colorized Zone'] = "Farbige Zone"
L['Show PvP informations about current area'] = "Zeigt PvP Informationen zur Zone farblich an"
end
-- ö \195\182 ß \195\159
-- ü \195\188 ä \195\164
-- Ä \195\132
-- ö \195\182
-- Ü \195\156

37
locale_enUS.lua Normal file
View File

@ -0,0 +1,37 @@
local addonname, addon = ...
local name = "zz_Coords"
local L = LibStub("AceLocale-3.0"):NewLocale(name, "enUS", true)
if L then
L[name] = name
L[name..' Settings'] = format("%s Settings",name)
L['Hide Map coords'] = true
L['Show MapID'] = "Show MapID on worldmap"
L['This hides the coords-display at the bottom of your map'] = true
L['outbound'] = "Cursor: - -- Player: "
L['Player'] = true
L['Cursor'] = true
L['COORDFMTSTRING'] = function(self,x,y) return format("Cursor: %.1f, %.1f -- Player: ",addon:round(x,1),addon:round(y,1)) end
L['HINT'] = "|c0000ff00Leftclick|r |c00ffffffto open the world map|r"
L['HINT2'] = "|c0000ff00Rightclick|r |c00ffffffto open preferences|r"
L['HINT3'] = "|c0000ff00Shift-Leftclick|r |c00fffffftoggles minimap icon|r"
L['HINT4'] = "|c0000ff00Shift-Rightclick|r |c00fffffftoggles minimap|r"
L['Show Zone'] = true
L['Show Subzone'] = true
L["Toggle Minimap"] = true
L['Max Length'] = true
L['Limits the maximum length of the zone'] = true
L['Mapcoords Screen'] = true
L['Mapcoords Window'] = true
L['Screen X'] = true
L['Adjusts the X-Offset on fullscreenmap'] = true
L['Screen Y'] = true
L['Adjusts the Y-Offset on fullscreenmap'] = true
L['Window X'] = true
L['Adjusts the X-Offset on windowed map'] = true
L['Window Y'] = true
L['Adjusts the Y-Offset on windowed map'] = true
L['Hide LDB coords'] = true
L['This hides the coords-display in your broker display'] = true
L['Colorized Zone'] = true
L['Show PvP informations about current area'] = true
end

6
pack.xml Normal file
View File

@ -0,0 +1,6 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<script file="locale_deDE.lua"/>
<script file="locale_enUS.lua"/>
<Script file="core.lua"/>
<Script file="provider.lua"/>
</Ui>

175
provider.lua Normal file
View File

@ -0,0 +1,175 @@
local name, addon = ...
local childName = "zz_Coords"
local zzDataProvider = {};
local coordText,db,mapframe
function zzDataProvider:GetMap()
return self.owningMap;
end
function addon:GetXY()
local x, y = WorldMapFrame.ScrollContainer:GetNormalizedCursorPosition();
local adjustedX = x * 100
local adjustedY = y * 100
return adjustedX,adjustedY
end
local function update()
if(not addon['db']['profile'][childName]) then return end
if(not db) then
db = addon['db']['profile'][childName]
end
if(coordText) then
db['screenX'] = db['screenX'] or 10
db['screenY'] = db['screenY'] or 5
db['windowX'] = db['windowX'] or 10
db['windowY'] = db['windowY'] or 5
local x,y = addon:GetXY()
local str = ""
local mapID = zzDataProvider:GetMap():GetMapID()
if(mapID and db['ShowMapID']) then
str = format("%s MapID: %i",str,mapID)
end
if(not(x == 100 or y==100 or x==0 or y==0)) then
str = format("%s Mouse: %.1f / %.1f",str,x,y)
end
if(mapID) then
local pmp = C_Map.GetPlayerMapPosition(mapID,"player")
if(pmp) then
local x,y = pmp:GetXY()
if(x and y) then
str = format("%s Player: %.1f / %.1f",str,x * 100,y * 100)
end
pmp = nil
end
end
coordText:SetText(str)
if(not db['hideMapCoords']) then
mapframe:SetWidth(coordText:GetStringWidth()+4)
mapframe:SetPoint("BOTTOMLEFT", WorldMapFrame, "BOTTOMLEFT", db['windowX'], db['windowY'])
mapframe:Show()
else
mapframe:Hide()
end
end
end
function zzDataProvider:OnAdded(owningMap)
self.owningMap = owningMap;
if(not coordText or not mapframe) then
mapframe = CreateFrame("Frame", "zz_CoordsMapFrame", WorldMapFrame, BackdropTemplateMixin and "BackdropTemplate" or nil)
mapframe:SetWidth(600)
mapframe:SetHeight(20)
mapframe:SetFrameStrata("HIGH")
mapframe:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
})
mapframe:SetBackdropColor(0,0,0,1);
mapframe.elapsed = 0
mapframe:SetScript("OnEnter", function(self)
self:SetBackdropColor(0,0,0,0);
coordText:Hide()
end)
mapframe:SetScript("OnLeave", function(self)
coordText:Show()
self:SetBackdropColor(0,0,0,1);
end)
mapframe:EnableMouse(1)
coordText = mapframe:CreateFontString(nil, "OVERLAY","GameFontNormal")
coordText:SetAllPoints(mapframe)
coordText:SetJustifyH("LEFT")
coordText:SetShadowColor(1,1,1,.2)
coordText:SetShadowOffset(1,-1)
mapframe:SetScript("OnUpdate", function(self, elapsed)
self.elapsed = self.elapsed + elapsed
if(self.elapsed<0.2) then return end
self.elapsed = 0
update()
end)
addon['mapframe'] = mapframe
end
end
function zzDataProvider:OnRemoved(owningMap)
assert(owningMap == self.owningMap);
self.owningMap = nil;
if self.registeredEvents then
for event in pairs(self.registeredEvents) do
owningMap:UnregisterEvent(event);
end
self.registeredEvents = nil;
end
end
function zzDataProvider:RemoveAllData()
if(mapframe) then
mapframe:Hide()
mapframe = nil
coordText = nil
end
end
function zzDataProvider:RefreshAllData()
update()
end
function zzDataProvider:OnShow()
end
function zzDataProvider:OnHide()
end
function zzDataProvider:OnMapInsetSizeChanged(mapInsetIndex, expanded)
end
function zzDataProvider:OnMapInsetMouseEnter(mapInsetIndex)
end
function zzDataProvider:OnMapInsetMouseLeave(mapInsetIndex)
end
function zzDataProvider:OnCanvasScaleChanged()
end
function zzDataProvider:OnCanvasPanChanged()
end
function zzDataProvider:OnCanvasSizeChanged()
end
function zzDataProvider:OnEvent(event, ...)
end
function zzDataProvider:OnGlobalAlphaChanged()
end
function zzDataProvider:OnMapChanged()
self:RefreshAllData()
end
function zzDataProvider:RegisterEvent(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 zzDataProvider:UnregisterEvent(event)
if self.registeredEvents and self.registeredEvents[event] then
self.registeredEvents[event] = nil;
self:GetMap():RemoveDataProviderEvent(event);
end
end
function zzDataProvider:SignalEvent(event, ...)
if self.registeredEvents and self.registeredEvents[event] then
self:OnEvent(event, ...);
end
end
if(type(WorldMapFrame.AddDataProvider) == 'function') then
WorldMapFrame:AddDataProvider(zzDataProvider)
else
zzDataProvider:OnAdded()
end

16
zz_Coords.toc Normal file
View File

@ -0,0 +1,16 @@
## Interface: 90002
## X-Repository: https://svn.grml.de/zz_Coords
## X-WoWI-ID: 15431
## X-Curse-Project-ID: 22760
## X-TOC-Classic: 11302
## Title: Coords
## Notes: Map coords
## Notes-deDE: Karten-Koordinaten
## Author: Rilgamon
## SavedVariables: zz_CoordsDB
## LoadManagers: AddonLoader
## X-LoadOn-Always: delayed
## OptionalDeps: Ace3,BrokerPack,zzLibCommon
Common\common.xml
pack.xml