WoWInterface SVN XMagePortals

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 10 to Rev 11
    Reverse comparison

Rev 10 → Rev 11

trunk/XMage_Portals/localization.enUS.lua New file
0,0 → 1,30
 
-- Grab a copy of the local data
local addonName, addonData = ...
 
 
addonData.Translate = {};
addonData.Translate.Locale = GetLocale();
 
addonData.Translate["RAID_TELEPORT"] = "XMage: Using Teleport Spell while in a Raid.";
addonData.Translate["PARTY_TELEPORT"] = "XMage: Using Teleport Spell while in a Party.";
addonData.Translate["SOLO_PORTAL"] = "XMage: Using Portal Spell while solo.";
 
addonData.Translate["PORTALS"] = "Portals";
addonData.Translate["TELEPORTS"] = "Teleports";
 
addonData.Translate["QUEST_REWARD"] = "Quest Reward";
addonData.Translate["DROP_ITEM"] = "Drop Item"
 
addonData.Translate["MAGEPORTS_LABEL"] = "MagePorts"
addonData.Translate["MAGEPORTS_DESC"] = "XMage : Portals and Teleports"
 
addonData.Translate["OPTIONS"] = "Options"
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"
\ No newline at end of file
trunk/XMage_Portals/XFrame.lua New file
0,0 → 1,106
 
-- localise the addon wide data table
local addonName,addonData = ...
 
-- Make a selected frame movable
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.BuildFrame = function(self,name,parent,options)
parent = parent or UIParent
local frame = CreateFrame("Frame",name,parent)
frame:SetWidth(options.FrameWidth)
frame:SetHeight(options.FrameHeight)
frame:SetAlpha(1.0)
frame:SetClampedToScreen(true)
frame:SetPoint("CENTER",UIParent,"CENTER",0,0)
if options.HasBorder then
self:AddBorder(frame)
end
if options.IsMovable then
self:SetMovable(frame)
end
return frame
end
 
addonData.AddBorder = function(self,frame)
local border = CreateFrame("Frame",_G[frame:GetName().."Border"],frame)
border:SetFrameLevel(frame:GetFrameLevel()-1)
border:SetFrameStrata(frame:GetFrameStrata())
border:ClearAllPoints()
border:SetPoint("TOPLEFT",-10,10)
border:SetPoint("BOTTOMRIGHT",35,-10)
 
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
},
}
border:SetBackdrop(backDrop)
border:SetBackdropBorderColor( 1, 1, 0, 1 )
border:SetBackdropColor( 0, 0, 0, 1 )
 
frame.border = border
end
 
 
addonData.BuildScrollFrame = function(self,name,parent,options)
parent = parent or UIParent
local frame = CreateFrame("ScrollFrame",name,parent,"UIPanelScrollFrameTemplate")
frame.ScrollBar = _G[frame:GetName() .. "ScrollBar"];
frame.ScrollBar:SetPoint("LEFT",frame,"RIGHT",5,0)
frame:SetWidth(options.FrameWidth - 55)
frame:SetHeight(options.FrameHeight - 20)
frame:SetPoint("CENTER",parent,"CENTER",10,-10)
if options.HasBorder then
self:AddBorder(frame)
end
if options.IsMovable then
self:SetMovable(frame)
end
return frame
end
trunk/XMage_Portals/localization.enGB.lua New file
0,0 → 1,30
 
-- Grab a copy of the local data
local addonName, addonData = ...
 
 
if (addonData.Translate.Locale == "enGB") then
 
addonData.Translate["RAID_TELEPORT"] = "XMage: Using Teleport Spell while in a Raid.";
addonData.Translate["PARTY_TELEPORT"] = "XMage: Using Teleport Spell while in a Party.";
addonData.Translate["SOLO_PORTAL"] = "XMage: Using Portal Spell while solo.";
 
addonData.Translate["PORTALS"] = "Portals";
addonData.Translate["TELEPORTS"] = "Teleports";
 
addonData.Translate["QUEST_REWARD"] = "Quest Reward";
addonData.Translate["DROP_ITEM"] = "Drop Item"
 
addonData.Translate["MAGEPORTS_LABEL"] = "MagePorts"
addonData.Translate["MAGEPORTS_DESC"] = "XMage : Portals and Teleports"
 
addonData.Translate["OPTIONS"] = "Options"
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
\ No newline at end of file
trunk/XMage_Portals/XMage_Portals.lua New file
0,0 → 1,34
 
-- 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)
trunk/XMage_Portals/PatchNotes.txt New file
0,0 → 1,7
 
Version: 5.0.4.16016.120829.01
Features introduced :
- All Portals and Teleports visible with info on when you get them
- Advises when you try to Portal while solo or Teleport while grouped
- Docks within an nUI Infopanel automatically
- Customizable with drop down menu
trunk/XMage_Portals/XMP_SecureSpellButton.lua New file
0,0 → 1,79
 
-- 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 spellKnown = ( GetSpellInfo(spellName) ~= nil )
local isSolo = true
local isGrouped = ( GetNumGroupMembers() > 0 )
 
if ( isGrouped ) then
isSolo = false
end
if ( not spellKnown ) 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,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.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
 
trunk/XMage_Portals/XMP_SpellCooldown.lua New file
0,0 → 1,49
 
-- 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
 
trunk/XMage_Portals/XMP_ValidateSpellCast.lua New file
0,0 → 1,87
 
-- 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 = ( 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" );
 
trunk/XMage_Portals/XMage_Portals.toc New file
0,0 → 1,29
## Interface: 50001
## Title: XMage : [|cffeda55f Portals |r]
## Author: Tina Kirby AKA Xrystal
## Version: 5.0.4.16016.120829.01
## Notes: This mod creates a frame of portals and teleports and optionally allows the user to place it into a nUI infopanel |n|cffeda55fv5.0.4.16016.120829.01|r
## RequiredDeps:
## OptionalDeps: nUI
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariables: XMagePortsDB
 
localization.enUS.lua
localization.enGB.lua
 
XMP_Options.lua
XMP_Data.lua
 
XFrame.lua
 
XMP_SpellCooldown.lua
XMP_SpellTooltip.lua
XMP_SecureSpellButton.lua
XMP_ValidateSpellCast.lua
XMP_Frame.lua
XMP_nUIPanel.lua
 
XMage_Portals.lua
 
 
trunk/XMage_Portals/XMP_Data.lua New file
0,0 → 1,381
 
-- 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.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,
},
 
 
}
 
trunk/XMage_Portals/XMP_Frame.lua New file
0,0 → 1,206
 
-- Grab a copy of the local data
local addonName, addonData = ...
local Translate = addonData.Translate
local expansionLevel = GetExpansionLevel()
 
-- Option Data which we need to customize the layout somewhat
addonData.Options = {
FrameWidth = 325,
FrameHeight = 150,
IsMovable = true,
HasBorder = true,
}
 
-- Create the Portal and Teleport Buttons
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,"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,"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
 
-- Update the Title Texts
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" );
 
-- 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("");
 
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()
 
-- 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.CreateFrame = function(self)
 
if ( IsAddOnLoaded("nUI") ) then
self.Options.HasBorder = false
self.Options.IsMovable = false
end
 
local frame = addonData:BuildFrame("XMPFrame",UIParent,self.Options)
 
frame = self:CreateButtons(frame)
frame = self:CreateText(frame)
frame = self:ArrangeLayout(frame)
 
return frame
 
end
 
trunk/XMage_Portals/XMP_SpellTooltip.lua New file
0,0 → 1,35
 
-- 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 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 ( 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
 
 
trunk/XMage_Portals/XMP_Options.lua New file
0,0 → 1,174
 
-- Grab a copy of the local data
local addonName, addonData = ...
local Translate = addonData.Translate
 
XMagePortsDB = {
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["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 == "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) 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) 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) 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) 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) 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) 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
 
trunk/XMage_Portals/XMP_nUIPanel.lua New file
0,0 → 1,128
-- 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