/
-- Grab a copy of the local data |
local addonName, addonData = ... |
addonData.Translate = {}; |
addonData.Translate.Locale = GetLocale(); |
addonData.Translate["RAID_TELEPORT"] = "XMagePorts: Using Teleport Spell while in a Raid."; |
addonData.Translate["PARTY_TELEPORT"] = "XMagePorts: Using Teleport Spell while in a Party."; |
addonData.Translate["SOLO_PORTAL"] = "XMagePorts: Using Portal Spell while solo."; |
addonData.Translate["PORTALS"] = "Portals"; |
addonData.Translate["TELEPORTS"] = "Teleports"; |
addonData.Translate["RESTOCK_REAGENTS"] = "XMagePorts: Restock reagents?"; |
addonData.Translate["QUEST_REWARD"] = "Quest Reward"; |
addonData.Translate["DROP_ITEM"] = "Drop Item" |
addonData.Translate["MAGEPORTS_LABEL"] = "MagePorts" |
addonData.Translate["MAGEPORTS_DESC"] = "XMagePorts - Mage Portals and Teleports" |
addonData.Translate["OPTIONS"] = "Options" |
addonData.Translate["MAX_RESTOCK"] = "Max Restock Quantity" |
addonData.Translate["UPDATE_INTERVAL"] = "Update Interval" |
addonData.Translate["FONT_SIZE"] = "Font Size" |
addonData.Translate["COOLDOWN_SIZE"] = "Cooldown Size" |
addonData.Translate["NOT_AVAILABLE_ALPHA"] = "Not Available Alpha" |
addonData.Translate["NOT_IDEAL_ALPHA"] = "Not Ideal Alpha" |
addonData.Translate["AVAILABLE_ALPHA"] = "Available Alpha" |
addonData.Translate["COLLAPSE"] = "Collapse" |
addonData.Translate["EXPAND"] = "Expand" |
-- Grab a copy of the local data |
local addonName, addonData = ... |
if (addonData.Translate.Locale == "enGB") then |
addonData.Translate["RAID_TELEPORT"] = "XMagePorts: Using Teleport Spell while in a Raid."; |
addonData.Translate["PARTY_TELEPORT"] = "XMagePorts: Using Teleport Spell while in a Party."; |
addonData.Translate["SOLO_PORTAL"] = "XMagePorts: Using Portal Spell while solo."; |
addonData.Translate["PORTALS"] = "Portals"; |
addonData.Translate["TELEPORTS"] = "Teleports"; |
addonData.Translate["RESTOCK_REAGENTS"] = "XMagePorts: Restock reagents?"; |
addonData.Translate["QUEST_REWARD"] = "Quest Reward"; |
addonData.Translate["DROP_ITEM"] = "Drop Item" |
addonData.Translate["MAGEPORTS_LABEL"] = "MagePorts" |
addonData.Translate["MAGEPORTS_DESC"] = "XMagePorts - Mage Portals and Teleports" |
addonData.Translate["OPTIONS"] = "Options" |
addonData.Translate["MAX_RESTOCK"] = "Max Restock Quantity" |
addonData.Translate["UPDATE_INTERVAL"] = "Update Interval" |
addonData.Translate["FONT_SIZE"] = "Font Size" |
addonData.Translate["COOLDOWN_SIZE"] = "Cooldown Size" |
addonData.Translate["NOT_AVAILABLE_ALPHA"] = "Not Available Alpha" |
addonData.Translate["NOT_IDEAL_ALPHA"] = "Not Ideal Alpha" |
addonData.Translate["AVAILABLE_ALPHA"] = "Available Alpha" |
addonData.Translate["COLLAPSE"] = "Collapse" |
addonData.Translate["EXPAND"] = "Expand" |
end |
-- Grab a copy of the local data |
local addonName, addonData = ... |
local Translate = addonData.Translate |
local expansionLevel = GetExpansionLevel() |
addonData.UpdateAlpha = function(self,button) |
if ( not button ) then return end |
if ( not button.spellID ) then return end |
local spellName, spellRank, spellIcon = GetSpellInfo(button.spellID); |
local reagentName = select(2,GetItemInfo(button.reagentID)) or nil |
local reagentCount = GetItemCount(button.reagentID) or 0 |
local spellKnown = ( GetSpellInfo(spellName) ~= nil ) |
local isSolo = true |
local isGrouped = ( expansionLevel < 4 and ( GetNumPartyMembers() > 0 or GetNumRaidMembers() > 0 ) ) or ( expansionLevel == 4 and GetNumGroupMembers() > 0 ) |
if ( isGrouped ) then |
isSolo = false |
end |
if ( not spellKnown or reagentCount == 0 ) then |
button:SetAlpha(XMagePortsDB.NotAvailableAlpha) |
else |
if ( ( isSolo and button.spellType == "PORTAL" ) or ( isGrouped and button.spellType == "TELEPORT" ) ) then |
button:SetAlpha(XMagePortsDB.NotIdealAlpha) |
else |
button:SetAlpha(XMagePortsDB.AvailableAlpha) |
end |
end |
end |
addonData.CreateSecureSpellButton = function(self,spellID,reagentID,spellType) |
-- Protected Function call to catch errors |
local retOK, spellName, spellRank, spellIcon = pcall (GetSpellInfo, spellID); |
-- This spell isn't available yet so don't worry about it |
if ( not spellName ) then return nil end |
local spellKnown = IsSpellKnown(spellID) |
local buttonName = "XMP_" .. spellID |
local Button = CreateFrame("Button",buttonName,UIParent,"ActionButtonTemplate,SecureActionButtonTemplate") |
Button:SetWidth(36) |
Button:SetHeight(36) |
Button.spellID = spellID |
Button.reagentID = reagentID |
Button.spellType = spellType |
Button:SetAttribute("type","spell") |
Button:SetAttribute("spell",spellName) |
local fontStructure = {} |
fontStructure.Size = 16 |
fontStructure.Color = { r = 255, g = 255, b = 255, a = 255 } |
fontStructure.Template = "NumberFontNormalLargeYellow" |
self:CreateCooldown(Button,spellIcon,fontStructure) |
Button:RegisterEvent("PLAYER_LOGIN") |
Button:RegisterEvent("PARTY_CONVERTED_TO_RAID") |
Button:RegisterEvent("PARTY_INVITE_CANCEL") |
Button:RegisterEvent("PARTY_INVITE_REQUEST") |
Button:RegisterEvent("LEARNED_SPELL_IN_TAB"); |
Button:RegisterEvent("PLAYER_ENTERING_WORLD"); |
Button:RegisterEvent("UNIT_SPELLCAST_START"); |
Button:RegisterEvent("UNIT_SPELLCAST_STOP"); |
Button:SetScript("OnEvent",function(self,event,...) |
addonData:UpdateAlpha(button) |
end) |
Button:Show() |
return Button |
end |
-- Grab a copy of the local data |
local addonName, addonData = ... |
local Translate = addonData.Translate |
addonData.UpdateCooldown = function(self,button,fontStructure) |
local spellName = button:GetAttribute("spell") |
if (not spellName) then return end |
local spellKnown = ( GetSpellInfo(spellName) ~= nil) |
if ( not spellKnown ) then return end |
local cdStart,cdDuration,cdEnabled = GetSpellCooldown(spellName) |
if ( cdDuration < 2 ) then return end |
local timeNow = GetTime() |
local diffTime = timeNow - cdStart |
local cdCounter = math.floor(cdDuration - diffTime) |
if ( cdStart > 0 and cdEnabled > 0 and cdDuration > 0 ) then |
button.cooldown:SetCooldown(cdStart,cdDuration) |
button.Counter:SetText(cdCounter) |
end |
button.Counter:Show() |
button.cooldown:Show() |
end |
addonData.CreateCooldown = function(self,button,texturePath,fontStructure) |
button.icon:SetAllPoints(button) |
button.icon:SetTexture(texturePath) |
button.icon:Show() |
button.cooldown:SetAllPoints(button) |
button.cooldown:Show() |
button.Counter = button.cooldown:CreateFontString(button:GetName().."Counter","ARTWORK",fontStructure.Template) |
fontStructure.Path,dumpVar,fontStructure.Flags = button.Counter:GetFont() |
button.Counter:SetFont(fontStructure.Path,fontStructure.Size,fontStructure.Flags) |
button.Counter:SetAllPoints(button.cooldown) |
button.Counter:SetText("") |
button.Counter:SetJustifyV("CENTER") |
button.Counter:SetJustifyH("CENTER") |
button.Counter:SetTextColor(fontStructure.Color.r,fontStructure.Color.g,fontStructure.Color.b,fontStructure.Color.a) |
button.Counter:Show() |
button.cooldown:RegisterEvent("SPELL_UPDATE_COOLDOWN") |
button.cooldown:SetScript("OnEvent",function(self,event,...) addonData:UpdateCooldown(button,fontStructure) end) |
button.cooldown:SetScript("OnUpdate",function(self,timeElapsed) addonData:UpdateCooldown(button,fontStructure) end) |
button.cooldown:Hide() |
end |
-- Grab a copy of the local data |
local addonName, addonData = ... |
local Translate = addonData.Translate |
local expansionLevel = GetExpansionLevel() |
addonData.ValidateSpellCast = function(self,status,caster,spellName,spellRank) |
if ( caster ~= "player" or not spellName ) then |
return false |
end |
local spellID = nil |
local spellDump = nil |
local spellLink = GetSpellLink(spellName,"") |
if ( not spellLink ) then |
return false |
end |
local found, spellDump, spellString = string.find(spellLink,"^|c%x+|H(.+)|h%[.*%]") |
if ( found ) then |
spellDump,spellID = strsplit(":",spellString) |
end |
spellID = tonumber(spellID) |
if ( not spellID ) then |
return false |
end |
local portalSpell = false |
local teleportSpell = false |
for i,v in pairs(self.PortalDB) do |
v.spellID = tonumber(v.spellID) |
if ( v.spellID == spellID ) then |
portalSpell = true |
break |
end |
end |
for i,v in pairs(self.TeleportDB) do |
v.spellID = tonumber(v.spellID) |
if ( v.spellID == spellID ) then |
teleportSpell = true |
break |
end |
end |
if ( status == "STOP" ) then |
if ( portalSpell or teleportSpell ) then |
return true |
end |
return false |
end |
local isGrouped = ( expansionLevel < 4 and ( GetNumPartyMembers() > 0 or GetNumRaidMembers() > 0 ) ) or ( expansionLevel == 4 and GetNumGroupMembers() > 0 ) |
if ( isGrouped ) then |
if ( teleportSpell ) then |
UIErrorsFrame:AddMessage(Translate["PARTY_TELEPORT"], 1.0,1.0,0.0) |
end |
else |
if ( portalSpell ) then |
UIErrorsFrame:AddMessage(Translate["SOLO_PORTAL"], 1.0,1.0,0.0) |
end |
end |
if ( portalSpell or teleportSpell ) then |
return true |
end |
return false |
end |
local function OnEvent(self,event,...) |
local arg1,arg2,arg3 = ... |
if event == "UNIT_SPELLCAST_START" then |
if ( addonData:ValidateSpellCast("START", arg1, arg2, arg3) ) then |
end |
elseif event == "UNIT_SPELLCAST_STOP" then |
if ( addonData:ValidateSpellCast("STOP", arg1, arg2, arg3) ) then |
end |
end |
end |
local SpellCastEventWatcher = CreateFrame("Frame","XMP_ValidateSpellCasts",UIParent) |
SpellCastEventWatcher:SetScript( "OnEvent", OnEvent ); |
SpellCastEventWatcher:RegisterEvent( "UNIT_SPELLCAST_START" ); |
SpellCastEventWatcher:RegisterEvent( "UNIT_SPELLCAST_STOP" ); |
-- Grab a copy of the local data |
local addonName, addonData = ... |
local Translate = addonData.Translate |
addonData.CreateFrames = function(self) |
local playerClass, fileClass = UnitClass("player"); |
if ( fileClass ~= "MAGE" ) then return end |
addonData.XMPFrame = addonData:CreateFrame() |
if ( addonData.XMPFrame ) then |
addonData.OptionsButton = addonData:CreateOptionsButton() |
addonData.OptionsMenu = addonData:CreateMenu() |
addonData.InfoPanel = addonData:CreateInfopanel() |
end |
end |
local function OnEvent(self,event,...) |
local arg1,arg2,arg3,arg4,arg5 = ... |
if ( event == "VARIABLES_LOADED" ) then |
addonData:CreateFrames(); |
elseif ( event == "PLAYER_ENTERING_WORLD") then |
if ( addonData.XMPFrame ) then |
addonData.XMPFrame:Show() |
else |
addonData:CreateFrames(); |
if ( addonData.XMPFrame ) then addonData.XMPFrame:Show() end |
end |
end |
end |
local XMPEventWatcher = CreateFrame("Frame","XMPEvents",UIParent) |
XMPEventWatcher:RegisterEvent("VARIABLES_LOADED") |
XMPEventWatcher:RegisterEvent("PLAYER_ENTERING_WORLD") |
XMPEventWatcher:SetScript("OnEvent",OnEvent) |
-- Grab a copy of the local data |
local addonName, addonData = ... |
local Translate = addonData.Translate |
addonData.ExpansionDB = { |
[0] = EXPANSION_NAME0, -- Classic ( 1 to 50 ) |
[1] = EXPANSION_NAME1, -- The Burning Crusade ( 51 to 70 ) |
[2] = EXPANSION_NAME2, -- Wrath of the Lich King ( 70 to 80 ) |
[3] = EXPANSION_NAME3, -- Cataclysm ( 80 to 85 ) |
[4] = EXPANSION_NAME4, -- Mists of Pandaria ( 85 to 90 ) |
} |
addonData.ReagentDB = { |
-- Teleport Rune |
[1] = { |
ID = 17031, |
maxQty = XMagePortsDB.MaxRestockQty, |
levelRequired = 20, |
}, |
-- Portal Rune |
[2] = { |
ID = 17032, |
maxQty = XMagePortsDB.MaxRestockQty, |
levelRequired = 35, |
}, |
} |
addonData.PortalDB = { |
-- Stormwind |
[1] = { |
expansionRequired = 0, |
levelRequired = 40, |
dropItem = false, |
questReward = false, |
spellID = 10059, |
faction = FACTION_ALLIANCE, |
}, |
-- Ironforge |
[2] = { |
expansionRequired = 0, |
levelRequired = 40, |
dropItem = false, |
questReward = false, |
spellID = 11416, |
faction = FACTION_ALLIANCE, |
}, |
-- Orgrimmar |
[3] = { |
expansionRequired = 0, |
levelRequired = 40, |
dropItem = false, |
questReward = false, |
spellID = 11417, |
faction = FACTION_HORDE, |
}, |
-- Undercity |
[4] = { |
expansionRequired = 0, |
levelRequired = 40, |
dropItem = false, |
questReward = false, |
spellID = 11418, |
faction = FACTION_HORDE, |
}, |
-- Darnassus |
[5] = { |
expansionRequired = 0, |
levelRequired = 50, |
dropItem = false, |
questReward = false, |
spellID = 11419, |
faction = FACTION_ALLIANCE, |
}, |
-- Thunderbluff |
[6] = { |
expansionRequired = 0, |
levelRequired = 50, |
dropItem = false, |
questReward = false, |
spellID = 11420, |
faction = FACTION_HORDE, |
}, |
-- Exodar |
[7] = { |
expansionRequired = 1, |
levelRequired = 40, |
dropItem = false, |
questReward = false, |
spellID = 32266, |
faction = FACTION_ALLIANCE, |
}, |
-- Silvermoon |
[8] = { |
expansionRequired = 1, |
levelRequired = 40, |
dropItem = false, |
questReward = false, |
spellID = 32267, |
faction = FACTION_HORDE, |
}, |
-- Shattrath |
[9] = { |
expansionRequired = 1, |
levelRequired = 65, |
dropItem = false, |
questReward = false, |
spellID = 33691, |
faction = FACTION_ALLIANCE, |
}, |
-- Shattrath |
[10] = { |
expansionRequired = 1, |
levelRequired = 65, |
dropItem = false, |
questReward = false, |
spellID = 35717, |
faction = FACTION_HORDE, |
}, |
-- Theramore |
[11] = { |
expansionRequired = 0, |
levelRequired = 35, |
dropItem = false, |
questReward = false, |
spellID = 49360, |
faction = FACTION_ALLIANCE, |
}, |
-- Stonard |
[12] = { |
expansionRequired = 0, |
levelRequired = 35, |
dropItem = false, |
questReward = false, |
spellID = 49361, |
faction = FACTION_HORDE, |
}, |
-- Dalaran |
[13] = { |
expansionRequired = 2, |
levelRequired = 74, |
dropItem = false, |
questReward = false, |
spellID = 53142, |
faction = FACTION_ALLIANCE, |
}, |
-- Dalaran |
[14] = { |
expansionRequired = 2, |
levelRequired = 74, |
dropItem = false, |
questReward = false, |
spellID = 53142, |
faction = FACTION_HORDE, |
}, |
-- Tol Barad |
[15] = { |
expansionRequired = 3, |
levelRequired = 85, |
dropItem = false, |
questReward = false, |
spellID = 88345, |
faction = FACTION_ALLIANCE, |
}, |
-- Tol Barad |
[16] = { |
expansionRequired = 3, |
levelRequired = 85, |
dropItem = false, |
questReward = false, |
spellID = 88346, |
faction = FACTION_HORDE, |
}, |
-- Ancient Dalaran |
[17] = { |
expansionRequired = 4, |
levelRequired = 90, |
dropItem = true, |
questReward = false, |
spellID = 120146, |
faction = FACTION_HORDE, |
}, |
-- Ancient Dalaran |
[18] = { |
expansionRequired = 4, |
levelRequired = 90, |
dropItem = true, |
questReward = false, |
spellID = 120146, |
faction = FACTION_ALLIANCE, |
}, |
} |
addonData.TeleportDB = { |
-- Stormwind |
[1] = { |
expansionRequired = 0, |
levelRequired = 20, |
dropItem = false, |
questReward = false, |
spellID = 3561, |
faction = FACTION_ALLIANCE, |
}, |
-- Ironforge |
[2] = { |
expansionRequired = 0, |
levelRequired = 20, |
dropItem = false, |
questReward = false, |
spellID = 3562, |
faction = FACTION_ALLIANCE, |
}, |
-- Undercity |
[3] = { |
expansionRequired = 0, |
levelRequired = 20, |
dropItem = false, |
questReward = false, |
spellID = 3563, |
faction = FACTION_HORDE, |
}, |
-- Thunder Bluff |
[4] = { |
expansionRequired = 0, |
levelRequired = 30, |
dropItem = false, |
questReward = false, |
spellID = 3566, |
faction = FACTION_HORDE, |
}, |
-- Darnassus |
[5] = { |
expansionRequired = 0, |
levelRequired = 30, |
dropItem = false, |
questReward = false, |
spellID = 3565, |
faction = FACTION_ALLIANCE, |
}, |
-- Orgrimmar |
[6] = { |
expansionRequired = 0, |
levelRequired = 20, |
dropItem = false, |
questReward = false, |
spellID = 3567, |
faction = FACTION_HORDE, |
}, |
-- Exodar |
[7] = { |
expansionRequired = 1, |
levelRequired = 20, |
dropItem = false, |
questReward = false, |
spellID = 32271, |
faction = FACTION_ALLIANCE, |
}, |
-- Silvermoon |
[8] = { |
expansionRequired = 1, |
levelRequired =20, |
dropItem = false, |
questReward = false, |
spellID = 32272, |
faction = FACTION_HORDE, |
}, |
-- Shattrath |
[9] = { |
expansionRequired = 1, |
levelRequired = 60, |
dropItem = false, |
questReward = false, |
spellID = 33690, |
faction = FACTION_ALLIANCE, |
}, |
-- Shattrath |
[10] = { |
expansionRequired = 1, |
levelRequired = 60, |
dropItem = false, |
questReward = false, |
spellID = 35715, |
faction = FACTION_HORDE, |
}, |
-- Theramore |
[11] = { |
expansionRequired = 0, |
levelRequired = 35, |
dropItem = false, |
questReward = false, |
spellID = 49359, |
faction = FACTION_ALLIANCE, |
}, |
-- Stonard |
[12] = { |
expansionRequired = 0, |
levelRequired = 35, |
dropItem = false, |
questReward = false, |
spellID = 49358, |
faction = FACTION_HORDE, |
}, |
-- Dalaran |
[13] = { |
expansionRequired = 2, |
levelRequired = 71, |
dropItem = false, |
questReward = true, |
spellID = 53140, |
faction = FACTION_ALLIANCE, |
}, |
-- Dalaran |
[14] = { |
expansionRequired = 2, |
levelRequired = 71, |
dropItem = false, |
questReward = true, |
spellID = 53140, |
faction = FACTION_HORDE, |
}, |
-- Tol Barad |
[15] = { |
expansionRequired = 3, |
levelRequired = 85, |
dropItem = false, |
questReward = false, |
spellID = 88342, |
faction = FACTION_ALLIANCE, |
}, |
-- Tol Barad |
[16] = { |
expansionRequired = 3, |
levelRequired = 85, |
dropItem = false, |
questReward = false, |
spellID = 88344, |
faction = FACTION_HORDE, |
}, |
-- Ancient Dalaran |
[17] = { |
expansionRequired = 4, |
levelRequired = 90, |
dropItem = true, |
questReward = false, |
spellID = 120145, |
faction = FACTION_HORDE, |
}, |
-- Ancient Dalaran |
[18] = { |
expansionRequired = 4, |
levelRequired = 90, |
dropItem = true, |
questReward = false, |
spellID = 120145, |
faction = FACTION_ALLIANCE, |
}, |
} |
## Interface: 40300 |
## Title: XMagePorts [|cffeda55f v1.01.00 |r] |
## Author: Xrystal |
## Version: 1.01.00 |
## Notes: This mod creates a frame of portals and teleports and optionally allows the user to place it into a nUI infopanel |
## RequiredDeps: |
## OptionalDeps: nUI |
## DefaultState: Enabled |
## LoadOnDemand: 0 |
## SavedVariables: XMagePortsDB |
localization.enUS.lua |
localization.enGB.lua |
XMP_Options.lua |
XMP_Data.lua |
XMP_Restock.lua |
XMP_SpellCooldown.lua |
XMP_SpellTooltip.lua |
XMP_SecureSpellButton.lua |
XMP_ValidateSpellCast.lua |
XMP_Frame.lua |
XMP_nUIPanel.lua |
XMagePorts.lua |
-- Grab a copy of the local data |
local addonName, addonData = ... |
local Translate = addonData.Translate |
local expansionLevel = GetExpansionLevel() |
addonData.CreateButtons = function(self,frame) |
self.PortalButtons = {}; |
self.TeleportButtons = {}; |
local Faction = UnitFactionGroup("player"); |
-- First the Portals |
for i,v in pairs(self.PortalDB) do |
if ( string.find(v.faction,Faction) ) then |
local Button = self:CreateSecureSpellButton(v.spellID,self.ReagentDB[2].ID,"PORTAL"); |
if ( Button ) then |
Button:SetScript("OnEnter",function(self) |
addonData:ShowTooltip(self) |
end ) |
Button:SetScript("OnLeave",function(self) |
addonData:HideTooltip(self) |
end ) |
Button:SetParent(nil) |
Button:SetParent(frame); |
Button.levelRequired = v.levelRequired |
Button.expansionRequired = v.expansionRequired |
Button.dropItem = v.dropItem |
Button.questReward = v.questReward |
Button:Show() |
table.insert(self.PortalButtons,Button); |
end |
end |
end |
-- Now the Teleports |
for i,v in pairs(self.TeleportDB) do |
if ( string.find(v.faction,Faction) ) then |
local Button = self:CreateSecureSpellButton(v.spellID,self.ReagentDB[1].ID,"TELEPORT"); |
if ( Button ) then |
Button:SetScript("OnEnter",function(self) |
addonData:ShowTooltip(self) |
end ) |
Button:SetScript("OnLeave",function(self) |
addonData:HideTooltip(self) |
end ) |
Button:SetParent(nil) |
Button:SetParent(frame); |
Button.levelRequired = v.levelRequired |
Button.expansionRequired = v.expansionRequired |
Button.dropItem = v.dropItem |
Button.questReward = v.questReward |
Button:Show() |
table.insert(self.TeleportButtons,Button); |
end |
end |
end |
return frame |
end |
addonData.UpdateText = function(self,frame) |
local fontPath, fontSize, fontFlags |
if ( XMagePortsDB.DisplayText ) then |
fontPath, fontSize, fontFlags = frame.PortalTitle:GetFont() |
frame.PortalTitle:SetFont(fontPath,XMagePortsDB.FontSize,fontFlags); |
frame.PortalTitle:SetText(Translate["PORTALS"]); |
fontPath, fontSize, fontFlags = frame.TeleportTitle:GetFont() |
frame.TeleportTitle:SetFont(fontPath,XMagePortsDB.FontSize,fontFlags); |
frame.TeleportTitle:SetText(Translate["TELEPORTS"]); |
else |
frame.PortalTitle:SetText(""); |
frame.TeleportTitle:SetText(""); |
end |
end |
addonData.CreateText = function(self,frame) |
-- Create the Portal Heading |
frame.PortalHeading = CreateFrame("Frame","XMP_PortalHeading",frame); |
-- create the Portal Title |
frame.PortalTitle = frame.PortalHeading:CreateFontString("XMP_PortalTitle", 'BACKGROUND', "GameFontNormal"); |
frame.PortalTitle:SetPoint( "LEFT" ); |
-- Create the Portal Count |
if ( expansionLevel < 4 ) then |
frame.PortalCount = frame.PortalHeading:CreateFontString("XMP_PortalCount", 'BACKGROUND', "GameFontNormal"); |
frame.PortalCount:SetPoint( "RIGHT" ); |
frame.PortalCount:SetText(""); |
end |
-- size frame to suit parent |
frame.PortalHeading:SetWidth(frame:GetWidth()); |
frame.PortalHeading:SetHeight(frame.PortalTitle:GetStringHeight() + 5 ); |
-- Create the Teleport Heading Frame |
frame.TeleportHeading = CreateFrame("Frame","XMP_TeleportHeading",frame); |
-- Create the Teleport Title |
frame.TeleportTitle = frame.TeleportHeading:CreateFontString("MagePorts_Frame_TeleportTitle", 'BACKGROUND', "GameFontNormal"); |
frame.TeleportTitle:SetPoint( "LEFT" ); |
frame.TeleportTitle:SetText(""); |
-- Create the Teleport Count |
if ( expansionLevel < 4 ) then |
-- Create the Teleport Reagent Count |
frame.TeleportCount = frame.TeleportHeading:CreateFontString("MagePorts_Frame_TeleportCount", 'BACKGROUND', "GameFontNormal"); |
frame.TeleportCount:SetPoint( "RIGHT" ); |
frame.TeleportCount:SetText(""); |
end |
self:UpdateText(frame) |
-- Size Frame to suit parent width and text height |
frame.TeleportHeading:SetWidth(frame:GetWidth()); |
frame.TeleportHeading:SetHeight(frame.TeleportTitle:GetStringHeight() + 5 ); |
-- Show the frames |
frame.PortalHeading:Show() |
frame.TeleportHeading:Show() |
frame.PortalTitle:Show() |
frame.TeleportTitle:Show() |
if ( expansionLevel < 4 ) then |
frame.PortalCount:Show() |
frame.TeleportCount:Show() |
end |
-- Return the created frame |
return frame |
end |
addonData.ArrangeLayout = function(self,frame) |
-- If the Portal Buttons table not created |
if ( not addonData.PortalButtons) then return end |
local cellCount = #addonData.PortalButtons; |
-- if there are no items in the table |
if ( cellCount < 1 ) then return end |
local cellSize = addonData.PortalButtons[1]:GetWidth(); |
local cellGap = cellSize * 0.25; |
frame.PortalHeading:SetPoint( "BOTTOMLEFT", addonData.PortalButtons[1], "TOPLEFT", -cellGap , cellGap); |
frame.PortalHeading:SetPoint( "BOTTOMRIGHT", addonData.PortalButtons[cellCount], "TOPRIGHT", cellGap , cellGap); |
frame.TeleportHeading:SetPoint( "BOTTOMLEFT", addonData.TeleportButtons[1], "TOPLEFT", -cellGap , cellGap); |
frame.TeleportHeading:SetPoint( "BOTTOMRIGHT", addonData.TeleportButtons[cellCount], "TOPRIGHT", cellGap , cellGap); |
local cellCount = #self.PortalButtons; |
local cellWidth = ( frame:GetWidth() / cellCount ); |
local btnSize = cellWidth * 0.8; |
local btnGap = cellWidth * 0.1; |
local verticalOffsetPortal = frame:GetHeight() / 5; |
local verticalOffsetTeleport = frame:GetHeight() / 4; |
for i=1,cellCount do |
self.PortalButtons[i]:SetWidth( btnSize ); |
self.PortalButtons[i]:SetHeight( btnSize ); |
self.TeleportButtons[i]:SetWidth( btnSize ); |
self.TeleportButtons[i]:SetHeight( btnSize ); |
end |
local odd = ( cellCount % 2 ) == 1; |
local midwayLeft = nil; |
local midwayRight = nil; |
if ( odd ) then |
midwayLeft = math.ceil( cellCount / 2 ); |
else |
midwayLeft = math.floor( cellCount / 2 ); |
midwayRight = midwayLeft + 1; |
end |
-- Reposition Portal Buttons and Fontstrings |
if ( not midwayRight ) then |
self.PortalButtons[midwayLeft]:SetPoint( "CENTER", frame, "CENTER", btnGap/2, verticalOffsetPortal); |
self.TeleportButtons[midwayLeft]:SetPoint( "CENTER", frame, "CENTER", btnGap/2, -verticalOffsetTeleport); |
else |
self.PortalButtons[midwayLeft]:SetPoint( "RIGHT", frame, "CENTER", -btnGap/2, verticalOffsetPortal ); |
self.PortalButtons[midwayRight]:SetPoint( "LEFT", frame, "CENTER", btnGap/2, verticalOffsetPortal ); |
self.TeleportButtons[midwayLeft]:SetPoint( "RIGHT", frame, "CENTER", -btnGap/2, -verticalOffsetTeleport ); |
self.TeleportButtons[midwayRight]:SetPoint( "LEFT", frame, "CENTER", btnGap/2, -verticalOffsetTeleport ); |
end |
for i = 1, midwayLeft - 1 do |
self.PortalButtons[i]:SetPoint( "RIGHT", self.PortalButtons[i+1], "LEFT", -btnGap, 0 ); |
self.TeleportButtons[i]:SetPoint( "RIGHT", self.TeleportButtons[i+1], "LEFT", -btnGap, 0 ); |
end |
for i = midwayLeft + 1, cellCount do |
self.PortalButtons[i]:SetPoint( "LEFT", self.PortalButtons[i-1], "RIGHT", btnGap, 0 ); |
self.TeleportButtons[i]:SetPoint( "LEFT", self.TeleportButtons[i-1], "RIGHT", btnGap, 0 ); |
end |
return frame |
end |
addonData.SetMovable = function(self,frame) |
-- If the mouse is ready to move start moving the frame |
frame.OnMouseDown = function(self) |
-- If the frame isn't locked then start moving the frame |
if ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) then |
self:StartMoving(); |
self.isMoving = true; |
end |
end |
-- If the mouse has stopped moving stop moving frame |
frame.OnMouseUp = function(self) |
-- If frame is moving then stop |
if ( self.isMoving ) then |
self:StopMovingOrSizing(); |
self.isMoving = false; |
end |
end |
-- If the scroll frame is hidden stop moving |
frame.OnHide = function(self) |
-- If frame is moving then stop |
if ( self.isMoving ) then |
self:StopMovingOrSizing(); |
self.isMoving = false; |
end |
end |
frame:RegisterForDrag("LeftButton"); |
frame:EnableMouse(true); |
frame:SetMovable(true); |
frame:SetScript("OnMouseDown",function(self) self:OnMouseDown() end); |
frame:SetScript("OnMouseUp",function(self) self:OnMouseUp() end); |
frame:SetScript("OnHide",function(self) self:OnHide() end); |
end |
addonData.CreateFrame = function(self) |
-- Create the Frame itself |
local frame = CreateFrame("Frame","XMPFrame",UIParent); |
frame:SetWidth(325); |
frame:SetHeight(150); |
frame:SetAlpha(1.0); |
frame:SetClampedToScreen(true); |
frame:SetPoint("CENTER",UIParent,"CENTER",0,0); |
if ( not IsAddOnLoaded("nUI") ) then |
local backDrop = { |
bgFile = "Interface/Tooltips/UI-Tooltip-Background", |
edgeFile = "Interface/Tooltips/UI-Tooltip-Border", |
tile = true, |
tileSize = 16, |
edgeSize = 16, |
insets = |
{ |
left = 4, |
right = 4, |
top = 4, |
bottom = 4 |
}, |
} |
frame:SetBackdrop(backDrop); |
frame:SetBackdropBorderColor( 0, 0, 0, 1 ); |
frame:SetBackdropColor( 0, 0, 0, 1 ); |
self:SetMovable(frame) |
end |
frame = self:CreateButtons(frame) |
frame = self:CreateText(frame) |
frame = self:ArrangeLayout(frame) |
return frame |
end |
-- Grab a copy of the local data |
local addonName, addonData = ... |
local Translate = addonData.Translate |
local expansionLevel = GetExpansionLevel() |
addonData.UpdateReagentCounts = function(self) |
if ( not self.XMPFrame ) then return end |
if ( expansionLevel == 4 ) then return end |
local reagentName,reagentLink = GetItemInfo(self.ReagentDB[1].ID); |
local reagentCount = GetItemCount(self.ReagentDB[1].ID) or 0; |
if ( XMagePortsDB.DisplayText and reagentLink ) then |
local fontPath, fontSize, fontFlags = self.XMPFrame.TeleportCount:GetFont() |
self.XMPFrame.TeleportCount:SetFont(fontPath,XMagePortsDB.FontSize,fontFlags); |
self.XMPFrame.TeleportCount:SetText(reagentLink .. " : " .. reagentCount); |
else |
self.XMPFrame.TeleportCount:SetText(""); |
end |
reagentName,reagentLink = GetItemInfo(self.ReagentDB[2].ID); |
reagentCount = GetItemCount(self.ReagentDB[2].ID) or 0; |
if ( XMagePortsDB.DisplayText and reagentLink) then |
local fontPath, fontSize, fontFlags = self.XMPFrame.PortalCount:GetFont() |
self.XMPFrame.PortalCount:SetFont(fontPath,XMagePortsDB.FontSize,fontFlags); |
self.XMPFrame.PortalCount:SetText(reagentLink .. " : " .. reagentCount); |
else |
self.XMPFrame.PortalCount:SetText(""); |
end |
end |
local function OnEvent(self,event,...) |
-- No need for reagents in Expansion 4 |
if ( expansionLevel == 4 ) then return end |
local arg1,arg2,arg3 = ... |
if event == "MERCHANT_SHOW" then |
addonData:ReagentRestock() |
addonData:UpdateReagentCounts() |
elseif event == "MERCHANT_CLOSED" then |
StaticPopup_Hide("RESTOCK_REAGENTS") |
addonData:UpdateReagentCounts() |
elseif event == "PLAYER_LOGIN" or event == "ITEM_PUSH" or event == "BAG_UPDATE" then |
addonData:UpdateReagentCounts() |
end |
end |
local RestockEventWatcher = CreateFrame("Frame","XMP_RestockEvents",UIParent) |
RestockEventWatcher:SetScript( "OnEvent", OnEvent ); |
RestockEventWatcher:RegisterEvent( "MERCHANT_SHOW" ); |
RestockEventWatcher:RegisterEvent( "MERCHANT_CLOSED" ); |
RestockEventWatcher:RegisterEvent( "PLAYER_LOGIN" ); |
RestockEventWatcher:RegisterEvent( "ITEM_PUSH" ); |
RestockEventWatcher:RegisterEvent( "BAG_UPDATE" ); |
-- Reagent Restock |
addonData.ReagentRestock = function(self,confirmed) |
local ReagentVendor = false; |
local ReagentsLow = false; |
local RestockList = {}; |
local PlayerLevel = UnitLevel("player"); |
-- Create a list of Reagents to Restock |
for i,reagent in pairs(self.ReagentDB) do |
if ( PlayerLevel > ( reagent.levelRequired - 1 ) ) then |
local name = GetItemInfo(reagent.ID); |
local qty = GetItemCount(reagent.ID); |
RestockList[name] = false; |
if ( qty < reagent.maxQty ) then |
ReagentsLow = true; |
RestockList[name] = true; |
end |
end |
end |
-- If we have the max we need of each reagent then no need to continue |
if ( not ReagentsLow ) then return; end |
-- Check to see if this is a reagent vendor |
-- If it is and we have confirmed restocking then buy the reagents |
ReagentVendor = false; |
for i = 1, GetMerchantNumItems(), 1 do |
local name, _, price, quantity = GetMerchantItemInfo(i); |
if ( RestockList[name] ) then |
ReagentVendor = true; |
if ( confirmed ) then |
local count = GetItemCount(name); |
local restock = 0; |
for j,reagent in pairs(self.ReagentDB) do |
local dbName = GetItemInfo(reagent.ID); |
if ( dbName == name ) then |
if ( count < reagent.maxQty ) then |
restock = reagent.maxQty - count; |
BuyMerchantItem(i,restock); |
break; |
end |
end |
end |
else |
break; |
end |
end |
end |
-- If this is a reagent vendor then pop up the question to restock |
if ( ReagentVendor ) then |
StaticPopup_Show("RESTOCK_REAGENTS"); |
end |
end |
-- Pop Up Dialog |
StaticPopupDialogs["RESTOCK_REAGENTS"] = { |
text = Translate["RESTOCK_REAGENTS"], |
button1 = YES, |
button2 = NO, |
OnAccept = function() addonData:ReagentRestock(true); end, |
timeout = 0, |
whileDead = 0, |
hideOnEscape = 1 |
}; |
-- Grab a copy of the local data |
local addonName, addonData = ... |
local Translate = addonData.Translate |
local expansionLevel = GetExpansionLevel() |
addonData.HideTooltip = function(self) |
GameTooltip:Hide() |
end |
addonData.ShowTooltip = function(self,button) |
local spellName = button:GetAttribute("spell") |
local spellID = button.spellID |
local reagentCount = GetItemCount(button.reagentID) |
local spellKnown = ( GetSpellInfo(spellName) ~= nil ) |
GameTooltip:SetOwner(button,"ANCHOR_CURSOR") |
GameTooltip:SetSpellByID(spellID) |
GameTooltip:AddLine(string.format(LEVEL_REQUIRED,button.levelRequired),1.0,1.0,1.0,1.0) |
GameTooltip:AddLine(addonData.ExpansionDB[button.expansionRequired],1.0,1.0,0.0,1.0) |
if ( button.questReward ) then |
GameTooltip:AddLine(Translate["QUEST_REWARD"],1.0,1.0,1.0) |
end |
if ( button.dropItem ) then |
GameTooltip:AddLine(Translate["DROP_ITEM"],1.0,1.0,1.0) |
end |
if ( not spellKnown ) then |
GameTooltip:AddLine(SPELL_FAILED_NOT_KNOWN,1.0,1.0,1.0) |
elseif ( expansionLevel < 4 and reagentCount < 1 ) then |
GameTooltip:AddLine(ERR_SPELL_FAILED_REAGENTS_GENERIC,1.0,1.0,1.0) |
elseif ( cdDuration == 0 ) then |
GameTooltip:AddLine(AVAILABLE,1.0,1.0,1.0) |
elseif ( cdEnabled and cdDuration ~= 0 ) then |
GameTooltip:AddLine(ON_COOLDOWN,1.0,1.0,1.0) |
end |
GameTooltip:Show() |
end |
-- Grab a copy of the local data |
local addonName, addonData = ... |
local Translate = addonData.Translate |
XMagePortsDB = { |
MaxRestockQty = 10, |
UpdateInterval = 30, |
FontSize = 12, |
CooldownSize = 20, |
NotAvailableAlpha = 0.1, |
NotIdealAlpha = 0.5, |
AvailableAlpha = 1.0, |
DisplayText = true, |
} |
local CreateMenuItems = function(frame,level,menuList) |
local info |
if ( menuList == nil ) then |
info = UIDropDownMenu_CreateInfo() |
info.text = Translate["OPTIONS"] |
info.isTitle = true |
info.notCheckable = true |
UIDropDownMenu_AddButton(info,level) |
info = UIDropDownMenu_CreateInfo() |
info.text = Translate["MAX_RESTOCK"] |
info.hasArrow = true |
info.menuList = "RestockQty" |
info.notCheckable = true |
UIDropDownMenu_AddButton(info,level) |
info = UIDropDownMenu_CreateInfo() |
info.text = Translate["UPDATE_INTERVAL"] |
info.hasArrow = true |
info.menuList = "UpdateInterval" |
info.notCheckable = true |
UIDropDownMenu_AddButton(info,level) |
info = UIDropDownMenu_CreateInfo() |
info.text = Translate["FONT_SIZE"] |
info.hasArrow = true |
info.menuList = "FontSize" |
info.notCheckable = true |
UIDropDownMenu_AddButton(info,level) |
info = UIDropDownMenu_CreateInfo() |
info.text = Translate["COOLDOWN_SIZE"] |
info.hasArrow = true |
info.menuList = "CooldownSize" |
info.notCheckable = true |
UIDropDownMenu_AddButton(info,level) |
info = UIDropDownMenu_CreateInfo() |
info.text = Translate["NOT_AVAILABLE_ALPHA"] |
info.hasArrow = true |
info.menuList = "NotAvailableAlpha" |
info.notCheckable = true |
UIDropDownMenu_AddButton(info,level) |
info = UIDropDownMenu_CreateInfo() |
info.text = Translate["NOT_IDEAL_ALPHA"] |
info.hasArrow = true |
info.menuList = "NotIdealAlpha" |
info.notCheckable = true |
UIDropDownMenu_AddButton(info,level) |
info = UIDropDownMenu_CreateInfo() |
info.text = Translate["AVAILABLE_ALPHA"] |
info.hasArrow = true |
info.menuList = "AvailableAlpha" |
info.notCheckable = true |
UIDropDownMenu_AddButton(info,level) |
if ( not IsAddOnLoaded("nUI") ) then |
info = UIDropDownMenu_CreateInfo() |
if ( addonData.XMPFrame:IsShown() ) then |
info.text = Translate["COLLAPSE"] |
else |
info.text = Translate["EXPAND"] |
end |
info.hasArrow = false |
info.menuList = nil |
info.notCheckable = true |
info.func = function() |
if addonData.XMPFrame:IsShown() then |
addonData.XMPFrame:Hide() |
else |
addonData.XMPFrame:Show() |
end |
addonData.OptionsButton:Show() |
end |
UIDropDownMenu_AddButton(info,level) |
end |
elseif ( menuList == "RestockQty" ) then |
for i,v in pairs({ 5,10,15,20 }) do |
info = UIDropDownMenu_CreateInfo() |
info.value = v |
info.text = v |
info.checked = ( v == XMagePortsDB.MaxRestockQty ) |
info.notCheckable = false |
info.func = function() XMagePortsDB.MaxRestockQty = v addonData:UpdateText(addonData.XMPFrame) addonData:UpdateReagentCounts() end |
UIDropDownMenu_AddButton(info,level) |
end |
elseif ( menuList == "UpdateInterval" ) then |
for i,v in pairs({ 10,20,30,40,50,60 }) do |
info = UIDropDownMenu_CreateInfo() |
info.value = v |
info.text = v |
info.checked = ( v == XMagePortsDB.UpdateInterval ) |
info.notCheckable = false |
info.func = function() XMagePortsDB.UpdateInterval = v addonData:UpdateText(addonData.XMPFrame) addonData:UpdateReagentCounts() end |
UIDropDownMenu_AddButton(info,level) |
end |
elseif ( menuList == "FontSize" ) then |
for i,v in pairs({ 10,12,14,16,18,20 }) do |
info = UIDropDownMenu_CreateInfo() |
info.value = v |
info.text = v |
info.checked = ( v == XMagePortsDB.FontSize ) |
info.notCheckable = false |
info.func = function() XMagePortsDB.FontSize = v addonData:UpdateText(addonData.XMPFrame) addonData:UpdateReagentCounts() end |
UIDropDownMenu_AddButton(info,level) |
end |
elseif ( menuList == "CooldownSize" ) then |
for i,v in pairs({ 15,20,25,30 }) do |
info = UIDropDownMenu_CreateInfo() |
info.value = v |
info.text = v |
info.checked = ( v == XMagePortsDB.CooldownSize ) |
info.notCheckable = false |
info.func = function() XMagePortsDB.CooldownSize = v addonData:UpdateText(addonData.XMPFrame) addonData:UpdateReagentCounts() end |
UIDropDownMenu_AddButton(info,level) |
end |
elseif ( menuList == "NotAvailableAlpha" ) then |
for i,v in pairs({ 0.1,0.2,0.3,0.4,0.5 }) do |
info = UIDropDownMenu_CreateInfo() |
info.value = v |
info.text = v |
info.checked = ( v == XMagePortsDB.NotAvailableAlpha ) |
info.notCheckable = false |
info.func = function() XMagePortsDB.NotAvailableAlpha = v addonData:UpdateText(addonData.XMPFrame) addonData:UpdateReagentCounts() end |
UIDropDownMenu_AddButton(info,level) |
end |
elseif ( menuList == "NotIdealAlpha" ) then |
for i,v in pairs({ 0.3,0.4,0.5,0.6,0.7 }) do |
info = UIDropDownMenu_CreateInfo() |
info.value = v |
info.text = v |
info.checked = ( v == XMagePortsDB.NotIdealAlpha ) |
info.notCheckable = false |
info.func = function() XMagePortsDB.NotIdealAlpha = v addonData:UpdateText(addonData.XMPFrame) addonData:UpdateReagentCounts() end |
UIDropDownMenu_AddButton(info,level) |
end |
elseif ( menuList == "AvailableAlpha" ) then |
for i,v in pairs({ 0.5,0.6,0.7,0.8,0.9 }) do |
info = UIDropDownMenu_CreateInfo() |
info.value = v |
info.text = v |
info.checked = ( v == XMagePortsDB.AvailableAlpha ) |
info.notCheckable = false |
info.func = function() XMagePortsDB.AvailableAlpha = v addonData:UpdateText(addonData.XMPFrame) addonData:UpdateReagentCounts() end |
UIDropDownMenu_AddButton(info,level) |
end |
end |
end |
addonData.CreateMenu = function(self) |
local menu = CreateFrame("Frame","XMPOptions",self.XMPFrame,"UIDropDownMenuTemplate") |
menu.displayMode = "MENU" |
menu.initialize = CreateMenuItems |
return menu |
end |
addonData.CreateOptionsButton = function(self) |
local frame = CreateFrame("Button","XMP_Options",UIParent,"OptionsButtonTemplate") |
frame:SetText(addonName) |
frame:SetWidth(100) |
frame:SetHeight(20) |
frame:SetPoint("CENTER",self.XMPFrame,"CENTER",0,0) |
frame:SetPoint("TOP",self.XMPFrame,"TOP",0,20) |
frame:Show() |
frame:SetScript("OnClick", function(self, button, down) |
ToggleDropDownMenu(1, nil, addonData.OptionsMenu, "cursor", 0, 0) |
end) |
frame:RegisterForClicks("LeftButtonUp","RightButtonUp") |
return frame |
end |
-- Grab a copy of the local data |
local addonName, addonData = ... |
local Translate = addonData.Translate |
addonData.CreateInfopanel = function(self) |
-- If nUI isn't loaded then don't worry about this part |
if ( not IsAddOnLoaded("nUI")) then return nil end |
-- Make sure we have access to the nUI tables |
if not nUI_InfoPanels then nUI_InfoPanels = {}; end |
-- Allocate a unique Infopanel ID |
nUI_INFOMODE_MAGEPORTS = 18; |
nUI_INFOPANEL_MAGEPORTS = "nUI_InfoPanel_XMagePorts"; |
-- Set the Infopanel Table values |
nUI_InfoPanels[nUI_INFOPANEL_MAGEPORTS ] = |
{ |
enabled = true, |
desc = Translate["MAGEPORTS_DESC"], -- player friendly name/description of the panel |
label = Translate["MAGEPORTS_LABEL"], -- label to use on the panel selection button face |
rotation = nUI_INFOMODE_MAGEPORTS, -- index or position this panel appears on/in when clicking the selector button |
full_size = true; -- this plugin requires the entire info panel port without the button bag |
options = |
{ |
enabled = true, |
}, |
}; |
-- Initialise the Infopanel Plugin Frame |
local plugin = CreateFrame( "Frame", nUI_INFOPANEL_MAGEPORTS, nUI_Dashboard.Anchor ); |
plugin.active = true; |
-- Infopanel Plugin Event Management |
local function onInfoPanelEvent(self,event,...) |
local arg1 = ...; |
if event == "VARIABLES_LOADED" then |
InfoPanel.active = true; |
end |
end |
plugin:SetScript( "OnEvent", onInfoPanelEvent ); |
plugin:RegisterEvent( "VARIABLES_LOADED" ); |
-- Initialisation of Infopanel plugin |
plugin.initPanel = function( container, options ) |
plugin.container = container; |
plugin.options = options; |
if options and options.enabled then |
plugin.setEnabled( true ); |
end |
end |
-- SizeChange of Infopanel plugin |
plugin.sizeChanged = function( scale, height, width ) |
local options = plugin.options; |
plugin.scale = scale; |
-- Grab addon information and unlock frame for movement |
local MagePortsFrame = plugin.MagePorts; |
nUI_Movers:lockFrame( MagePortsFrame, false, nil ); |
-- Resize and Reposition according to scale and size of new container |
MagePortsFrame:SetWidth( width ); |
MagePortsFrame:SetHeight( height ); |
-- Rearrange Icons as needed |
addonData:ArrangeLayout(MagePortsFrame) |
-- Lock addon frame for movement |
nUI_Movers:lockFrame( MagePortsFrame, true, nil ); |
end |
-- Enabling of the Infopanel plugin |
plugin.setEnabled = function( enabled ) |
if plugin.enabled ~= enabled then |
plugin.enabled = enabled; |
if not enabled then |
local MagePorts = plugin.MagePorts; |
local MagePortsOptions = plugin.MagePortsOptions |
if MagePorts.saved_parent then |
nUI_Movers:lockFrame( MagePorts, false, nil ); |
MagePortsOptions:SetParent( UIParent ); |
MagePorts:SetParent( MagePorts.saved_parent ); |
MagePorts:SetBackdropBorderColor( MagePorts.border_color ); |
MagePorts:SetBackdropColor( MagePorts.backdrop_color ); |
end |
else |
local MagePorts = addonData.XMPFrame; |
local MagePortsOptions = addonData.OptionsButton |
plugin.MagePorts = MagePorts; |
plugin.MagePortsOptions = MagePortsOptions |
if not MagePorts.saved_parent then |
MagePorts.saved_parent = MagePorts:GetParent(); |
MagePorts.border_color = MagePorts:GetBackdropBorderColor(); |
MagePorts.backdrop_color = MagePorts:GetBackdropColor(); |
end |
MagePortsOptions:SetParent( plugin.container ); |
MagePortsOptions:SetPoint( "TOP", plugin.container, "TOP", 0, 20 ); |
MagePorts:SetParent( plugin.container ); |
MagePorts:SetPoint( "TOPLEFT", plugin.container, "TOPLEFT", 0, -15 ); |
MagePorts:SetPoint( "BOTTOMRIGHT", plugin.container, "BOTTOMRIGHT", 0, 5 ); |
MagePorts:SetFrameStrata( plugin.container:GetFrameStrata() ); |
MagePorts:SetFrameLevel( plugin.container:GetFrameLevel()+1 ); |
MagePorts:SetBackdropBorderColor( 0, 0, 0, 0 ); |
MagePorts:SetBackdropColor( 0, 0, 0, 0 ); |
nUI_Movers:lockFrame( MagePorts, true, nil ); |
end |
end |
end |
-- Selection of the Infopanel plugin frame |
plugin.setSelected = function( selected ) |
if selected ~= plugin.selected then |
plugin.selected = selected; |
if selected then |
else |
end |
end |
end |
return plugin; |
end |