diff --git a/Dongle.lua b/Dongle.lua index 804eb98..9cfa1cd 100644 --- a/Dongle.lua +++ b/Dongle.lua @@ -35,8 +35,8 @@ local g = getfenv(0) if not g.DongleStub or g.DongleStub:IsNewerVersion(major, minor) then local lib = setmetatable({}, { - __call = function(t,k) - if type(t.versions) == "table" and t.versions[k] then + __call = function(t,k) + if type(t.versions) == "table" and t.versions[k] then return t.versions[k].instance else error("Cannot find a library with name '"..tostring(k).."'", 2) @@ -66,7 +66,7 @@ if not g.DongleStub or g.DongleStub:IsNewerVersion(major, minor) then local oldmajor,oldminor = versionData.instance:GetVersion() return minor > oldminor end - + local function NilCopyTable(src, dest) for k,v in pairs(dest) do dest[k] = nil end for k,v in pairs(src) do dest[k] = v end @@ -96,7 +96,7 @@ if not g.DongleStub or g.DongleStub:IsNewerVersion(major, minor) then ["instance"] = newInstance, ["deactivate"] = deactivate, } - + self.versions[major] = versionData if type(activate) == "function" then table.insert(self.log, string.format("Activate: %s, %s", major, minor)) @@ -104,12 +104,12 @@ if not g.DongleStub or g.DongleStub:IsNewerVersion(major, minor) then end return newInstance end - + local oldDeactivate = versionData.deactivate local oldInstance = versionData.instance - + versionData.deactivate = deactivate - + local skipCopy if type(activate) == "function" then table.insert(self.log, string.format("Activate: %s, %s", major, minor)) @@ -134,7 +134,7 @@ if not g.DongleStub or g.DongleStub:IsNewerVersion(major, minor) then local function Activate(new, old) -- This code ensures that we'll move the versions table even - -- if the major version names are different, in the case of + -- if the major version names are different, in the case of -- DongleStub if not old then old = g.DongleStub end @@ -144,7 +144,7 @@ if not g.DongleStub or g.DongleStub:IsNewerVersion(major, minor) then end g.DongleStub = new end - + -- Actually trigger libary activation here local stub = g.DongleStub or lib lib = stub:Register(lib, Activate) @@ -535,7 +535,7 @@ local function OnUpdate(frame, elapsed) else safecall(schedule.func, schedule.name) end - + if schedule.repeating then schedule.timeToFire = schedule.timeToFire + schedule.repeating HeapBubbleDown(1) @@ -1044,7 +1044,7 @@ function Dongle.GetProfiles(db, tbl) i = i + 1 tbl[i] = db.keys.profile end - + return tbl, i end @@ -1304,9 +1304,9 @@ do function PLAYER_LOGIN() if lockPlayerLogin then return end - + lockPlayerLogin = true - + local obj = table.remove(loadorder, 1) while obj do if type(obj.Enable) == "function" then @@ -1314,7 +1314,7 @@ do end obj = table.remove(loadorder, 1) end - + lockPlayerLogin = false end end @@ -1323,7 +1323,7 @@ local function ADDON_LOADED(event, ...) local obj = table.remove(loadqueue, 1) while obj do table.insert(loadorder, obj) - + if type(obj.Initialize) == "function" then safecall(obj.Initialize, obj) end diff --git a/PerfectRaid.toc b/PerfectRaid.toc index 1a23969..f7fa2dd 100644 --- a/PerfectRaid.toc +++ b/PerfectRaid.toc @@ -1,4 +1,4 @@ -## Interface: 80000 +## Interface: 80200 ## Title: PerfectRaid ## Version: @project-version@ ## Author: Cladhaire diff --git a/PerfectRaid.xml b/PerfectRaid.xml index 1102784..9d5fdef 100644 --- a/PerfectRaid.xml +++ b/PerfectRaid.xml @@ -19,7 +19,7 @@ </EdgeSize> </Backdrop> <Frames> - <Button name="$parentHeader"> + <Button name="$parentHeader"> <Size> <AbsDimension x="350" y="64"/> </Size> @@ -76,7 +76,7 @@ self.Title = getglobal(name.."Title") </OnLoad> <OnHide> - PlaySound("UChatScrollButton"); + PlaySound(SOUNDKIT.IG_CHAT_SCROLL_UP); </OnHide> </Scripts> </Frame> diff --git a/PerfectRaid_Roles.lua b/PerfectRaid_Roles.lua index e0495d8..fc6b054 100644 --- a/PerfectRaid_Roles.lua +++ b/PerfectRaid_Roles.lua @@ -1,124 +1,128 @@ ---[[------------------------------------------------------------------------- - * - * RaidRoles module for PerfectRaid addon. - * - * Written by: Panoramix - * Version: 1.0 - * ----------------------------------------------------------------------------]] - -local RaidRoles = PerfectRaid:NewModule("PerfectRaid-Roles") -local L = PerfectRaidLocals -local utils, frames - -function RaidRoles:Initialize() - - frames = PerfectRaid.frames - utils = PerfectRaid.utils - - self:RegisterMessage("DONGLE_PROFILE_CHANGED") - self:RegisterMessage("PERFECTRAID_CONFIG_CHANGED") -end - --- Update Raid Roles when profiles changes -function RaidRoles:DONGLE_PROFILE_CHANGED(event, addon, svname, name) - if svname == "PerfectRaidDB" then - RaidRoles:ShowRaidRoles(PerfectRaid.db.profile.showroles) - end -end - --- Update Raid Roles when config is changed -function RaidRoles:PERFECTRAID_CONFIG_CHANGED(event, addon, svname, name) - self:ShowRaidRoles(PerfectRaid.db.profile.showroles) -end - --- Update Raid Roles when addon is enabled -function RaidRoles:Enable() - self:ShowRaidRoles(PerfectRaid.db.profile.showroles) -end - --- Show/Hide raid icons depending on value -function RaidRoles:ShowRaidRoles(value) - if value then - self:RegisterEvent( "PLAYER_ROLES_ASSIGNED", "UpdateAllUnits" ) - else - self:UnregisterEvent("PLAYER_ROLES_ASSIGNED" ) - end - self:UpdateAllUnits() -end - --- Request full update for all units -function RaidRoles:FullUpdate() - self:UpdateAllUnits() -end - -function RaidRoles:UpdateAllUnits() - - local showRoles = PerfectRaid.db.profile.showroles - local showTank = PerfectRaid.db.profile.showroletank - local showDamager = PerfectRaid.db.profile.showroledamager - local showHealer = PerfectRaid.db.profile.showrolehealer - - - for unit, tbl in pairs(frames) do - local role = UnitGroupRolesAssigned( unit ) - - if role == "NONE" then - if GetPartyAssignment("MAINTANK", unit) or GetPartyAssignment("MAINASSIST", unit) then - role = "TANK" - end - end - - if ( role and frames and frames[unit] ) then - - for frame in pairs( frames[unit] ) do - - local parent = frame:GetParent() - local options = PerfectRaid.db.profile.headers[parent.idx] - - -- create indicator and texture - if (not frame.raidrole) then - frame.raidrole = CreateFrame("Frame", nil, frame.leftbox) - frame.raidrole:SetHeight(frame:GetHeight() * 0.75) - frame.raidrole:SetWidth(frame:GetHeight() * 0.75) - frame.raidrole:SetFrameLevel(frame.leftbox:GetFrameLevel()+1) - - frame.raidroletex = frame.raidrole:CreateTexture(nil, "OVERLAY") - frame.raidroletex:SetAllPoints() - frame.raidroletex:SetTexture("Interface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES") - end - - -- position frame according to align - if options.alignright then - frame.raidrole:ClearAllPoints() - frame.raidrole:SetParent(frame.rightbox) - frame.raidrole:SetPoint("TOPRIGHT", 0, 0) - - else - frame.raidrole:ClearAllPoints() - frame.raidrole:SetParent(frame.leftbox) - frame.raidrole:SetPoint("TOPLEFT", 0, 0) - end - - - if ( showRoles and showTank and role == "TANK" ) then - frame.raidroletex:SetTexCoord(0, 19/64, 22/64, 41/64) - frame.raidroletex:Show() - - elseif ( showRoles and showHealer and role == "HEALER" ) then - frame.raidroletex:SetTexCoord(20/64, 39/64, 1/64, 20/64) - frame.raidroletex:Show() - - elseif ( showRoles and showDamager and role == "DAMAGER" ) then - frame.raidroletex:SetTexCoord(20/64, 39/64, 22/64, 41/64) - frame.raidroletex:Show() - - else - frame.raidroletex:Hide() - end - - end - end - - end -end +--[[------------------------------------------------------------------------- + * + * RaidRoles module for PerfectRaid addon. + * + * Written by: Panoramix + * Version: 1.0 + * +---------------------------------------------------------------------------]] + +if not (WOW_PROJECT_ID == WOW_PROJECT_MAINLINE) then + return +end + +local RaidRoles = PerfectRaid:NewModule("PerfectRaid-Roles") +local L = PerfectRaidLocals +local utils, frames + +function RaidRoles:Initialize() + + frames = PerfectRaid.frames + utils = PerfectRaid.utils + + self:RegisterMessage("DONGLE_PROFILE_CHANGED") + self:RegisterMessage("PERFECTRAID_CONFIG_CHANGED") +end + +-- Update Raid Roles when profiles changes +function RaidRoles:DONGLE_PROFILE_CHANGED(event, addon, svname, name) + if svname == "PerfectRaidDB" then + RaidRoles:ShowRaidRoles(PerfectRaid.db.profile.showroles) + end +end + +-- Update Raid Roles when config is changed +function RaidRoles:PERFECTRAID_CONFIG_CHANGED(event, addon, svname, name) + self:ShowRaidRoles(PerfectRaid.db.profile.showroles) +end + +-- Update Raid Roles when addon is enabled +function RaidRoles:Enable() + self:ShowRaidRoles(PerfectRaid.db.profile.showroles) +end + +-- Show/Hide raid icons depending on value +function RaidRoles:ShowRaidRoles(value) + if value then + self:RegisterEvent( "PLAYER_ROLES_ASSIGNED", "UpdateAllUnits" ) + else + self:UnregisterEvent("PLAYER_ROLES_ASSIGNED" ) + end + self:UpdateAllUnits() +end + +-- Request full update for all units +function RaidRoles:FullUpdate() + self:UpdateAllUnits() +end + +function RaidRoles:UpdateAllUnits() + + local showRoles = PerfectRaid.db.profile.showroles + local showTank = PerfectRaid.db.profile.showroletank + local showDamager = PerfectRaid.db.profile.showroledamager + local showHealer = PerfectRaid.db.profile.showrolehealer + + + for unit, tbl in pairs(frames) do + local role = UnitGroupRolesAssigned( unit ) + + if role == "NONE" then + if GetPartyAssignment("MAINTANK", unit) or GetPartyAssignment("MAINASSIST", unit) then + role = "TANK" + end + end + + if ( role and frames and frames[unit] ) then + + for frame in pairs( frames[unit] ) do + + local parent = frame:GetParent() + local options = PerfectRaid.db.profile.headers[parent.idx] + + -- create indicator and texture + if (not frame.raidrole) then + frame.raidrole = CreateFrame("Frame", nil, frame.leftbox) + frame.raidrole:SetHeight(frame:GetHeight() * 0.75) + frame.raidrole:SetWidth(frame:GetHeight() * 0.75) + frame.raidrole:SetFrameLevel(frame.leftbox:GetFrameLevel()+1) + + frame.raidroletex = frame.raidrole:CreateTexture(nil, "OVERLAY") + frame.raidroletex:SetAllPoints() + frame.raidroletex:SetTexture("Interface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES") + end + + -- position frame according to align + if options.alignright then + frame.raidrole:ClearAllPoints() + frame.raidrole:SetParent(frame.rightbox) + frame.raidrole:SetPoint("TOPRIGHT", 0, 0) + + else + frame.raidrole:ClearAllPoints() + frame.raidrole:SetParent(frame.leftbox) + frame.raidrole:SetPoint("TOPLEFT", 0, 0) + end + + + if ( showRoles and showTank and role == "TANK" ) then + frame.raidroletex:SetTexCoord(0, 19/64, 22/64, 41/64) + frame.raidroletex:Show() + + elseif ( showRoles and showHealer and role == "HEALER" ) then + frame.raidroletex:SetTexCoord(20/64, 39/64, 1/64, 20/64) + frame.raidroletex:Show() + + elseif ( showRoles and showDamager and role == "DAMAGER" ) then + frame.raidroletex:SetTexCoord(20/64, 39/64, 22/64, 41/64) + frame.raidroletex:Show() + + else + frame.raidroletex:Hide() + end + + end + end + + end +end