Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 16d3369
Showing
3 changed files
with
373 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
--[[ | ||
xanAchievementMover Localization | ||
--]] | ||
XANACHIEVEMENTMOVER_L = GetLocale() == "zhCN" and { | ||
["|cFF99CC33%s|r [v|cFFDF2B2B%s|r] loaded: /xanam"] = "|cFF99CC33%s|r [v|cFFDF2B2B%s|r] loaded: /xanam", | ||
["/xanam anchor - toggles the anchors to move the frames"] = "/xanam anchor - toggles the anchors to move the frames", | ||
["xanAchievementMover [DUNGEON POPUP]\n\nRight click when finished dragging"] = "xanAchievementMover [DUNGEON POPUP]\n\nRight click when finished dragging", | ||
["xanAchievementMover [ACHIEVEMENT 1]"] = "xanAchievementMover [ACHIEVEMENT 1]", | ||
["xanAchievementMover [ACHIEVEMENT 2]"] = "xanAchievementMover [ACHIEVEMENT 2]", | ||
} | ||
-- or GetLocale() == "ruRU" and { | ||
-- ["|cFF99CC33%s|r [v|cFFDF2B2B%s|r] loaded: /xanam"] = "|cFF99CC33%s|r [v|cFFDF2B2B%s|r] loaded: /xanam", | ||
-- ["/xanam anchor - toggles the anchors to move the frames"] = "/xanam anchor - toggles the anchors to move the frames", | ||
-- } or GetLocale() == "zhTW" and { | ||
-- ["|cFF99CC33%s|r [v|cFFDF2B2B%s|r] loaded: /xanam"] = "|cFF99CC33%s|r [v|cFFDF2B2B%s|r] loaded: /xanam", | ||
-- ["/xanam anchor - toggles the anchors to move the frames"] = "/xanam anchor - toggles the anchors to move the frames", | ||
-- } or GetLocale() == "frFR" and { | ||
-- ["|cFF99CC33%s|r [v|cFFDF2B2B%s|r] loaded: /xanam"] = "|cFF99CC33%s|r [v|cFFDF2B2B%s|r] loaded: /xanam", | ||
-- ["/xanam anchor - toggles the anchors to move the frames"] = "/xanam anchor - toggles the anchors to move the frames", | ||
-- } or GetLocale() == "koKR" and { | ||
-- ["|cFF99CC33%s|r [v|cFFDF2B2B%s|r] loaded: /xanam"] = "|cFF99CC33%s|r [v|cFFDF2B2B%s|r] loaded: /xanam", | ||
-- ["/xanam anchor - toggles the anchors to move the frames"] = "/xanam anchor - toggles the anchors to move the frames", | ||
-- } or GetLocale() == "deDE" and { | ||
-- ["|cFF99CC33%s|r [v|cFFDF2B2B%s|r] loaded: /xanam"] = "|cFF99CC33%s|r [v|cFFDF2B2B%s|r] loaded: /xanam", | ||
-- ["/xanam anchor - toggles the anchors to move the frames"] = "/xanam anchor - toggles the anchors to move the frames", | ||
-- } | ||
or { } | ||
setmetatable(XANACHIEVEMENTMOVER_L, {__index = function(self, key) rawset(self, key, key); return key; end}) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,326 @@ | ||
|
||
local L = XANACHIEVEMENTMOVER_L | ||
|
||
local f = CreateFrame("frame","xanAchievementMover",UIParent) | ||
f:SetScript("OnEvent", function(self, event, ...) if self[event] then return self[event](self, event, ...) end end) | ||
|
||
---------------------- | ||
-- POSITION FIX -- | ||
---------------------- | ||
|
||
local function customFixAnchors(...) | ||
local frame, frame2, frameD, frameG = AchievementAlertFrame1, AchievementAlertFrame2, DungeonCompletionAlertFrame1, GuildChallengeAlertFrame | ||
|
||
--check for dungeon shown | ||
if (frameD:IsShown()) then | ||
f:LoadPositionHook("DungeonCompletionAlertFrame1", "xanAchievementMover_Anchor") | ||
end | ||
|
||
--check for guild challenge shown | ||
if (frameG:IsShown()) then | ||
f:LoadPositionHook("GuildChallengeAlertFrame", "xanAchievementMover_Anchor") | ||
end | ||
|
||
--position the achievements | ||
for i=1, MAX_ACHIEVEMENT_ALERTS do | ||
local achframe = _G["AchievementAlertFrame"..i]; | ||
if ( achframe and achframe:IsShown() ) then | ||
achframe:ClearAllPoints() | ||
if i == 1 then | ||
f:LoadPositionHook("AchievementAlertFrame1", "xanAchievementMover_Ach1") | ||
elseif _G["AchievementAlertFrame"..(i-1)] then | ||
achframe:SetPoint("TOPLEFT", _G["AchievementAlertFrame"..(i-1)], "BOTTOMLEFT", 0, 4) | ||
end | ||
end | ||
end | ||
|
||
end | ||
|
||
---------------------- | ||
-- Enable -- | ||
---------------------- | ||
|
||
function f:PLAYER_LOGIN() | ||
|
||
if not XanAM_DB then XanAM_DB = {} end | ||
|
||
--hook to rearrange the positions of the dungeon and achievement alert frames | ||
AlertFrame_FixAnchors = customFixAnchors | ||
|
||
self:DrawAnchor() | ||
self:RestoreLayout("xanAchievementMover_Anchor") | ||
|
||
SLASH_XANACHIEVEMENTMOVER1 = "/xanam"; | ||
SlashCmdList["XANACHIEVEMENTMOVER"] = xanAchievementMover_SlashCommand; | ||
|
||
local ver = GetAddOnMetadata("xanAchievementMover","Version") or '1.0' | ||
DEFAULT_CHAT_FRAME:AddMessage(string.format(L["|cFF99CC33%s|r [v|cFFDF2B2B%s|r] loaded: /xanam"], "xanAchievementMover", ver or "1.0")) | ||
|
||
self:UnregisterEvent("PLAYER_LOGIN") | ||
self.PLAYER_LOGIN = nil | ||
end | ||
|
||
function xanAchievementMover_SlashCommand(cmd) | ||
|
||
local a,b,c=strfind(cmd, "(%S+)"); --contiguous string of non-space characters | ||
|
||
if a then | ||
if c and c:lower() == "anchor" then | ||
if not _G["xanAchievementMover_Anchor"] then return end | ||
_G["xanAchievementMover_Anchor"]:Show() | ||
return true | ||
end | ||
end | ||
|
||
DEFAULT_CHAT_FRAME:AddMessage("xanAchievementMover"); | ||
DEFAULT_CHAT_FRAME:AddMessage(L["/xanam anchor - toggles the anchors to move the frames"]); | ||
end | ||
|
||
function f:DrawAnchor() | ||
|
||
--lets do the dungeon one first ;) | ||
local frame = CreateFrame("Frame", "xanAchievementMover_Anchor", UIParent) | ||
|
||
frame:SetFrameStrata("DIALOG") | ||
frame:SetWidth(DungeonCompletionAlertFrame1:GetWidth()) | ||
frame:SetHeight(DungeonCompletionAlertFrame1:GetHeight()) | ||
|
||
frame:EnableMouse(true) | ||
frame:SetMovable(true) | ||
|
||
frame:SetScript("OnMouseDown",function(self, button) | ||
if button == "LeftButton" then | ||
self.isMoving = true | ||
self:StartMoving() | ||
else | ||
self:Hide() | ||
end | ||
|
||
end) | ||
frame:SetScript("OnMouseUp",function(self) | ||
if( self.isMoving ) then | ||
self.isMoving = nil | ||
self:StopMovingOrSizing() | ||
|
||
f:SaveLayout(self:GetName()) | ||
f:SaveLayout("xanAchievementMover_Ach1") | ||
end | ||
end) | ||
|
||
local stringA = frame:CreateFontString() | ||
stringA:SetAllPoints(frame) | ||
stringA:SetFontObject("GameFontNormalSmall") | ||
stringA:SetText(L["xanAchievementMover [DUNGEON POPUP]\n\nRight click when finished dragging"]) | ||
|
||
frame:SetBackdrop({ | ||
edgeFile = "Interface/Tooltips/UI-Tooltip-Border", | ||
tile = true, | ||
tileSize = 16, | ||
edgeSize = 16, | ||
insets = { left = 5, right = 5, top = 5, bottom = 5 } | ||
}) | ||
frame:SetBackdropColor(0.15, 0.49, 1, 1) | ||
frame:SetBackdropBorderColor(0.15, 0.49, 1, 1) | ||
|
||
frame.bg = frame:CreateTexture(nil, "BACKGROUND") | ||
frame.bg:SetTexCoord(0, 0.546875, 0.28515, 0.5664) | ||
frame.bg:SetWidth(70) | ||
frame.bg:SetHeight(72) | ||
frame.bg:SetTexture("Interface\\LFGFrame\\UI-LFG-DUNGEONTOAST") | ||
frame.bg:SetPoint("BOTTOMLEFT") | ||
|
||
frame.bg1 = frame:CreateTexture(nil, "BACKGROUND") | ||
frame.bg1:SetTexCoord(0.5546875, 0.671875, 0.28515, 0.5664) | ||
frame.bg1:SetWidth(15) | ||
frame.bg1:SetHeight(72) | ||
frame.bg1:SetTexture("Interface\\LFGFrame\\UI-LFG-DUNGEONTOAST") | ||
frame.bg1:SetPoint("BOTTOMRIGHT") | ||
|
||
frame.bg2 = frame:CreateTexture(nil, "BACKGROUND") | ||
frame.bg2:SetTexCoord(0, 0.9921875, 0, 0.28125) | ||
frame.bg2:SetWidth(127) | ||
frame.bg2:SetHeight(72) | ||
frame.bg2:SetTexture("Interface\\LFGFrame\\UI-LFG-DUNGEONTOAST") | ||
frame.bg2:SetPoint("BOTTOMLEFT", 69, 0) | ||
|
||
frame.bg3 = frame:CreateTexture(nil, "BACKGROUND") | ||
frame.bg3:SetTexCoord(0, 0.9921875, 0.58203, 0.86328) | ||
frame.bg3:SetWidth(127) | ||
frame.bg3:SetHeight(72) | ||
frame.bg3:SetTexture("Interface\\LFGFrame\\UI-LFG-DUNGEONTOAST") | ||
frame.bg3:SetPoint("BOTTOMRIGHT", -14, 0) | ||
|
||
|
||
--achievement popup 1 | ||
local frameAch1 = CreateFrame("Frame", "xanAchievementMover_Ach1", xanAchievementMover_Anchor) | ||
|
||
frameAch1:SetFrameStrata("DIALOG") | ||
frameAch1:SetWidth(300) | ||
frameAch1:SetHeight(88) | ||
frameAch1:ClearAllPoints() | ||
frameAch1:SetPoint("CENTER", xanAchievementMover_Anchor, "BOTTOM", 0, -(frame:GetHeight()/2 + 4) ) | ||
|
||
frameAch1:EnableMouse(true) | ||
frameAch1:SetMovable(true) | ||
|
||
frameAch1:SetScript("OnMouseDown",function(self, button) | ||
if button == "LeftButton" then | ||
self:GetParent().isMoving = true | ||
self:GetParent():StartMoving() | ||
end | ||
|
||
end) | ||
frameAch1:SetScript("OnMouseUp",function(self) | ||
if( self:GetParent().isMoving ) then | ||
self:GetParent().isMoving = nil | ||
self:GetParent():StopMovingOrSizing() | ||
f:SaveLayout(self:GetParent():GetName()) | ||
f:SaveLayout("xanAchievementMover_Ach1") | ||
end | ||
end) | ||
|
||
local stringAch1 = frameAch1:CreateFontString() | ||
stringAch1:SetAllPoints(frameAch1) | ||
stringAch1:SetFontObject("GameFontNormalSmall") | ||
stringAch1:SetText(L["xanAchievementMover [ACHIEVEMENT 1]"]) | ||
|
||
frameAch1:SetBackdrop({ | ||
edgeFile = "Interface/Tooltips/UI-Tooltip-Border", | ||
tile = true, | ||
tileSize = 16, | ||
edgeSize = 16, | ||
insets = { left = 5, right = 5, top = 5, bottom = 5 } | ||
}) | ||
frameAch1:SetBackdropColor(153/255, 204/255, 51/255, 1) | ||
frameAch1:SetBackdropBorderColor(153/255, 204/255, 51/255, 1) | ||
|
||
frameAch1.bg = frameAch1:CreateTexture(nil, "BACKGROUND") | ||
frameAch1.bg:SetTexCoord(0, .605, 0, .703) | ||
frameAch1.bg:SetTexture("Interface\\AchievementFrame\\UI-Achievement-Alert-Background") | ||
frameAch1.bg:SetAllPoints(true) | ||
|
||
--achievement popup 2 | ||
local frameAch2 = CreateFrame("Frame", "xanAchievementMover_Ach2", xanAchievementMover_Anchor) | ||
|
||
frameAch2:SetFrameStrata("DIALOG") | ||
frameAch2:SetWidth(300) | ||
frameAch2:SetHeight(88) | ||
frameAch2:ClearAllPoints() | ||
frameAch2:SetPoint("TOPLEFT", frameAch1, "BOTTOMLEFT", 0, 4) | ||
|
||
frameAch2:EnableMouse(true) | ||
frameAch2:SetMovable(true) | ||
|
||
frameAch2:SetScript("OnMouseDown",function(self, button) | ||
if button == "LeftButton" then | ||
self:GetParent().isMoving = true | ||
self:GetParent():StartMoving() | ||
end | ||
|
||
end) | ||
frameAch2:SetScript("OnMouseUp",function(self) | ||
if( self:GetParent().isMoving ) then | ||
self:GetParent().isMoving = nil | ||
self:GetParent():StopMovingOrSizing() | ||
f:SaveLayout(self:GetParent():GetName()) | ||
f:SaveLayout("xanAchievementMover_Ach1") | ||
end | ||
end) | ||
|
||
local stringAch2 = frameAch2:CreateFontString() | ||
stringAch2:SetAllPoints(frameAch2) | ||
stringAch2:SetFontObject("GameFontNormalSmall") | ||
stringAch2:SetText(L["xanAchievementMover [ACHIEVEMENT 2]"]) | ||
|
||
frameAch2:SetBackdrop({ | ||
edgeFile = "Interface/Tooltips/UI-Tooltip-Border", | ||
tile = true, | ||
tileSize = 16, | ||
edgeSize = 16, | ||
insets = { left = 5, right = 5, top = 5, bottom = 5 } | ||
}) | ||
frameAch2:SetBackdropColor(153/255, 204/255, 51/255, 1) | ||
frameAch2:SetBackdropBorderColor(153/255, 204/255, 51/255, 1) | ||
|
||
frameAch2.bg = frameAch2:CreateTexture(nil, "BACKGROUND") | ||
frameAch2.bg:SetTexCoord(0, .605, 0, .703) | ||
frameAch2.bg:SetTexture("Interface\\AchievementFrame\\UI-Achievement-Alert-Background") | ||
frameAch2.bg:SetAllPoints(true) | ||
|
||
frame:Hide() | ||
end | ||
|
||
function f:SaveLayout(frame) | ||
if type(frame) ~= "string" then return end | ||
if not _G[frame] then return end | ||
if not XanAM_DB then XanAM_DB = {} end | ||
|
||
local opt = XanAM_DB[frame] or nil | ||
|
||
if not opt then | ||
XanAM_DB[frame] = { | ||
["point"] = "CENTER", | ||
["relativePoint"] = "CENTER", | ||
["xOfs"] = 0, | ||
["yOfs"] = 0, | ||
} | ||
opt = XanAM_DB[frame] | ||
return | ||
end | ||
|
||
local point, relativeTo, relativePoint, xOfs, yOfs = _G[frame]:GetPoint() | ||
opt.point = point | ||
opt.relativePoint = relativePoint | ||
opt.xOfs = xOfs | ||
opt.yOfs = yOfs | ||
end | ||
|
||
function f:RestoreLayout(frame) | ||
if type(frame) ~= "string" then return end | ||
if not _G[frame] then return end | ||
if not XanAM_DB then XanAM_DB = {} end | ||
|
||
local opt = XanAM_DB[frame] or nil | ||
|
||
if not opt then | ||
XanAM_DB[frame] = { | ||
["point"] = "CENTER", | ||
["relativePoint"] = "CENTER", | ||
["xOfs"] = 0, | ||
["yOfs"] = 0, | ||
} | ||
opt = XanAM_DB[frame] | ||
end | ||
|
||
_G[frame]:ClearAllPoints() | ||
_G[frame]:SetPoint(opt.point, UIParent, opt.relativePoint, opt.xOfs, opt.yOfs) | ||
end | ||
|
||
function f:LoadPositionHook(frame, frameAttach) | ||
if type(frame) ~= "string" then return end | ||
if type(frameAttach) ~= "string" then return end | ||
if not _G[frame] then return end | ||
if not _G[frameAttach] then return end | ||
if not XanAM_DB then XanAM_DB = {} end | ||
|
||
local opt = XanAM_DB[frame] or nil | ||
|
||
if not opt then | ||
XanAM_DB[frame] = { | ||
["point"] = "CENTER", | ||
["relativePoint"] = "CENTER", | ||
["xOfs"] = 0, | ||
["yOfs"] = 0, | ||
} | ||
opt = XanAM_DB[frame] | ||
end | ||
|
||
_G[frame]:ClearAllPoints() | ||
_G[frame]:SetPoint(opt.point, _G[frameAttach], opt.relativePoint, opt.xOfs, opt.yOfs) | ||
end | ||
|
||
------------------------------ | ||
-- Event Handlers -- | ||
------------------------------ | ||
|
||
if IsLoggedIn() then f:PLAYER_LOGIN() else f:RegisterEvent("PLAYER_LOGIN") end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Interface: 40300 | ||
## Title: xanAchievementMover | ||
## Notes: A simple addon that allows the user to move the Achievement and Dungeon notifications. | ||
## Author: Xruptor | ||
## Version: 1.0 | ||
## SavedVariables: XanAM_DB | ||
|
||
localization\localization.lua | ||
xanAchievementMover.lua |