WoWInterface SVN phUnitFrames

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

trunk/phUnitFrames.lua New file
0,0 → 1,308

phUnitFrames = {
 
init = function(self)
 
SLASH_PHUNITFRAMES1 = '/showauraids';
SlashCmdList["PHUNITFRAMES"] = function(msg,editbox)
local unit = "player"
for i=1,100 do
local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(unit,i,"HELPFUL");
if name == nil then
break;
end;
print(name,spellId,icon);
end;
end;
 
phMenuFrame = CreateFrame("Frame", "phMenuFrame", UIParent, "UIDropDownMenuTemplate");
 
local frames = phUnitFramesConfig.frames;
for i,frame in pairs(frames) do
self:createGroupFrame(frame);
end;
 
--[[ phUnitFramesConfig.Focus = phLib.deepcopy(phUnitFramesDefaultConfig);
phUnitFramesConfig.Focus.title = "Focus";
phUnitFramesConfig.Focus.units = { "target","focus" };
phUnitFramesConfig.Focus.point = "TOPRIGHT";
phUnitFramesConfig.Focus.x = -80;
phUnitFramesConfig.Focus.y = -500;
self:createGroupFrame(phUnitFramesConfig.Focus);--]]
 
print("phUnitFrames initialized");
end,
 
hideBlizzardFrame = function(self,frameName)
local frame = _G[frameName];
local func;
func = frame:GetScript("OnEvent");
if func then
phBlizzardFrames[frameName.."OnEvent"] = func;
frame:SetScript("OnEvent",nil);
end;
frame:Hide();
end,
 
showBlizzardFrame = function(self,frameName)
local frame = _G[frameName];
local func;
func = phBlizzardFrames[frameName.."OnEvent"];
if func then
frame:SetScript("OnEvent",func);
end;
frame:Show();
end,
 
togglePartyFrame = function(self)
if InCombatLockdown() then
return;
end;
 
if phUnitFramesConfig.showBlizzardPartyFrame then
phUnitFramesConfig.showBlizzardPartyFrame = false;
else
phUnitFramesConfig.showBlizzardPartyFrame = true;
end;
for i=1, MAX_PARTY_MEMBERS, 1 do
if phUnitFramesConfig.showBlizzardPartyFrame then
self:showBlizzardFrame("PartyMemberFrame"..i);
else
self:hideBlizzardFrame("PartyMemberFrame"..i);
end;
end
end,
 
createGroupFrame = function(self,config,frame)
 
if not frame then
frame = CreateFrame("Button",nil,UIParent);
frame:SetPoint(config.point,config.x,config.y);
frame.config = config;
 
frame:SetMovable(true);
frame:RegisterForDrag("LeftButton");
frame:SetScript("OnDragStart",function(self) self:StartMoving(); end);
frame:SetScript("OnDragStop",function(self) self:StopMovingOrSizing(); end);
 
frame:RegisterForClicks("AnyUp");
frame:SetScript("OnClick",function(self,button,down)
if button == "RightButton" then
phUnitFrames.createGroupMenu(frame);
end;
end);
 
frame.update = self.updateGroupFrame;
frame.lastUpdate = GetTime();
 
frame:RegisterEvent("RAID_ROSTER_UPDATE");
frame:RegisterEvent("PARTY_MEMBERS_CHANGED");
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
frame:RegisterEvent("PLAYER_REGEN_DISABLED");
frame:RegisterEvent("PLAYER_REGEN_ENABLED");
frame:SetScript("OnEvent",function(frame,event,...)
frame:update();
end);
frame:SetScript("OnUpdate",function(frame,timediff)
if GetTime() - frame.lastUpdate >= 1 then
frame:update();
end;
end);
 
frame.text = frame:CreateFontString(nil,"ARTWORK");
frame.text:SetFontObject(GameFontHighlightSmall);
frame.text:SetPoint("CENTER",0,0);
 
frame.childs = {};
if config.units == "raid" then
for i=1,25 do
frame.childs[i] = phUnitFrame.create(frame);
end;
else
for i,unit in pairs(config.units) do
frame.childs[i] = phUnitFrame.create(frame);
frame.childs[i]:changeUnit(unit);
end
end;
 
else
frame.config = config;
for i,child in ipairs(frame.childs) do
phUnitFrame.create(frame,child);
end;
end;
 
frame.text:SetText(config.title);
frame:SetWidth(config.width);
frame:SetHeight(config.height);
frame.text:SetFont(STANDARD_TEXT_FONT,config.fontsize);
 
frame:Show();
 
return frame;
end,
 
createGroupMenu = function(frame)
local config = frame.config;
 
local configMenu = {};
for idx,model in pairs(phUnitFramesModels) do
table.insert(configMenu,{ text = model.name, checked = (config.model == idx), arg1 = frame, arg2 = idx, func = phUnitFrames.changeModel });
end;
 
local menu = {
{ text = "Afficher les fenetres par defaut", checked = phUnitFramesConfig.showBlizzardPartyFrame,
func = function()
phUnitFrames:togglePartyFrame();
end
},
{ text = "Afficher le role", checked = config.showrole, arg1 = frame, func = phUnitFrames.changeShowRole },
{ text = "Largeur", notCheckable = true, hasArrow = true, menuList = {
{ text = 100, checked = (config.width==100), arg1 = frame, arg2 = 100, func = phUnitFrames.changeWidth },
{ text = 125, checked = (config.width==125), arg1 = frame, arg2 = 125, func = phUnitFrames.changeWidth },
{ text = 150, checked = (config.width==150), arg1 = frame, arg2 = 150, func = phUnitFrames.changeWidth },
{ text = 175, checked = (config.width==175), arg1 = frame, arg2 = 175, func = phUnitFrames.changeWidth },
{ text = 200, checked = (config.width==200), arg1 = frame, arg2 = 200, func = phUnitFrames.changeWidth },
}
},
{ text = "Hauteur", notCheckable = true, hasArrow = true, menuList = {
{ text = 12, checked = (config.height==12), arg1 = frame, arg2 = 12, func = phUnitFrames.changeHeight },
{ text = 14, checked = (config.height==14), arg1 = frame, arg2 = 14, func = phUnitFrames.changeHeight },
{ text = 16, checked = (config.height==16), arg1 = frame, arg2 = 16, func = phUnitFrames.changeHeight },
{ text = 18, checked = (config.height==18), arg1 = frame, arg2 = 18, func = phUnitFrames.changeHeight },
{ text = 20, checked = (config.height==20), arg1 = frame, arg2 = 20, func = phUnitFrames.changeHeight },
}
},
{ text = "Modele", notCheckable = true, hasArrow = true, menuList = configMenu },
};
EasyMenu(menu, phMenuFrame, "cursor", 0 , 0, "MENU", 5);
end,
 
changeModel = function(menu,frame,idx)
CloseDropDownMenus();
frame.config.model = idx;
phUnitFrames:createGroupFrame(frame.config,frame);
end,
 
changeShowRole = function(menu,frame)
CloseDropDownMenus();
if frame.config.showrole then
frame.config.showrole = false;
else
frame.config.showrole = true;
end;
end,
 
changeWidth = function(menu,frame,size)
CloseDropDownMenus();
frame.config.width = size;
phUnitFrames:createGroupFrame(frame.config,frame);
end,
 
changeHeight = function(menu,frame,size)
CloseDropDownMenus();
frame.config.height = size;
frame.config.fontsize = size-4;
phUnitFrames:createGroupFrame(frame.config,frame);
end,
 
changeFontSize = function(menu,frame,size)
CloseDropDownMenus();
frame.config.fontsize = size;
phUnitFrames:createGroupFrame(frame.config,frame);
end,
 
updateGroupFrame = function(frame)
 
if GetTime() - frame.lastUpdate < 1 then
return;
end;
frame.lastUpdate = GetTime();
 
local childs = frame.childs;
if not InCombatLockdown() then
local config = frame.config;
if config.units == "raid" then
if GetNumRaidMembers() > 0 then
for i,child in pairs(childs) do
child:changeUnit("raid"..i);
end;
else
childs[1]:changeUnit("player");
for i=1,4 do
childs[i+1]:changeUnit("party"..i);
end;
for i=6,table.getn(childs) do
childs[i]:changeUnit(nil);
end;
end;
end;
end;
 
for i,child in pairs(childs) do
child:update();
end
 
if not InCombatLockdown() then
local order = {};
for i,child in pairs(childs) do
if child.unit and UnitExists(child.unit) then
table.insert(order,child);
end;
end
 
table.sort(order,function(a,b)
if a == nil or b == nil then
return true;
end;
if a.disp_role == b.disp_role then
if a.order == b.order then
return a.name < b.name;
end;
return a.order < b.order;
end;
return a.disp_role < b.disp_role
end);
 
local lastframe = frame;
local lastrole;
for i,child in ipairs(order) do
child:ClearAllPoints();
local y = 0;
if not lastrole or lastrole ~= child.disp_role then
y = -2;
end;
child:SetPoint("TOP",lastframe,"BOTTOM",0,y);
lastframe = child;
lastrole = child.disp_role;
end;
end
 
end,
 
}
 
local frame = CreateFrame("FRAME","phMainFrame");
frame:RegisterEvent("VARIABLES_LOADED");
frame:SetScript("OnEvent",function(self,event,...)
phUnitFrames:init();
end);
 
phBlizzardFrames = {};
phPlayerRoles = {};
 
phUnitFramesConfig = {
showBlizzardPartyFrame = true;
frames = {
{
title = "Raid",
units = "raid",
point = "TOPLEFT", x = 80, y = -80,
width = 175,
height = 18,
fontsize = 14,
model = 1,
}
},
};
 
trunk/phUnitFrames.toc New file
0,0 → 1,13
## Interface: 40000
## Title: phUnitFrames
## Author: phylyp
## Version: 4.0.1
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariables: phPlayerRoles
## SavedVariablesPerCharacter: phUnitFramesConfig
phVars.lua
phLib.lua
phUnitFramesModels.lua
phUnitFrame.lua
phUnitFrames.lua
trunk/phUnitFramesModels.lua New file
0,0 → 1,179
phUnitFramesModels = {
{
name = "Defaut",
spells = {
{ type1="target" }, -- Cible
{ type2="assist" }, -- Assister
{ ["shift-type1"]="focus" }, -- Focus
},
buffs = {
max = 5,
filter = "HELPFUL",
left = "RIGHT",
right = "LEFT",
rest = {},
combat = {},
spells = {},
},
debuffs = {
max = 5,
filter = "HARMFUL",
left = "LEFT",
right = "RIGHT",
types = { "Magic","Disease","Poison","Curse" },
rest = {},
combat = {},
spells = {},
}
},
{
name = "Pretre Sacre",
spells = {
{ type1="target" }, -- Cible
{ type2="assist" }, -- Assister
{ ["shift-type1"]="focus" }, -- Focus
{ ["ctrl-type1"]="spell", ["ctrl-spell1"]=47788 }, -- Esprit Gardien
{ ["ctrl-type2"]="spell", ["ctrl-spell2"]=6346 }, -- Gardian Peur
},
buffs = {
max = 5,
filter = "HELPFUL",
left = "RIGHT",
right = "LEFT",
rest = {
6307,79105, -- Endu
79107, -- Ombre
 
588, -- Feu Intérieur
 
47788, -- Esprit Gardien
6346, -- Gardian Peur
 
77487, -- Orbre d'ombre
 
139, -- Renovation
17, -- Bouclier
41635, -- Priere de Guérison
 
70772, -- Bonus T10
},
combat = {
47788, -- Esprit Gardian
6346, -- Gardian Peur
 
77487, -- Orbre d'ombre
 
139, -- Renovation
17, -- Bouclier
41635, -- Priere de Guérison
 
70772, -- Bonus T10
 
15357, -- Inspiration
},
spells = {
{
{ type1="spell", spell1=139 }, -- Renovation
{ type2="spell", spell2=17 }, -- Bouclier
{ ["shift-type1"]="spell", ["shift-spell1"]=21562 }, -- Endu
},
{
{ ["shift-type1"]="spell", ["shift-spell1"]=27683 }, -- Ombre
}
},
},
debuffs = {
max = 5,
filter = "HARMFUL",
left = "LEFT",
right = "RIGHT",
types = { "Magic","Disease" },
rest = {
6788, -- Ame affaiblie
},
combat = {
6788, -- Ame affaiblie
},
spells = {
[1] = {
[1] = { type1="spell", spell1=527 }, -- Magie
},
[2] = {
[1] = { type1="spell", spell1=528 }, -- Maladie
},
},
},
},
{
name = "Paladin Protection",
spells = {
{ type1="spell", spell1=31789 }, -- Défense vertueuse
{ type2="spell", spell2=633 }, -- Imposition des mains
{ ["shift-type1"]="target" }, -- Cibler
{ ["shift-type2"]="assist" }, -- Assister
{ ["ctrl-type1"]="focus" }, -- Focus
},
buffs = {
max = 5,
filter = "HELPFUL",
left = "RIGHT",
right = "LEFT",
rest = {
79063, -- Béné des rois
79102, -- Béné puissance
 
465, -- Aura Dévotion
7294, -- Aura Vindicte
19746, -- Aura de concentration
32223, -- Aura de croisé
 
498, -- Protection divine
1022, -- Main de protec
1038, -- Main de salut
1044, -- Main de liberté
 
},
combat = {
465, -- Aura Dévotion
7294, -- Aura Vindicte
19746, -- Aura de concentration
32223, -- Aura de croisé
 
79063, -- Béné des rois
79102, -- Béné puissance
 
498, -- Protection divine
1022, -- Main de protec
1038, -- Main de salut
1044, -- Main de liberté
},
spells = {
{
{ type1="spell", spell1=1022 }, -- Main de protec
{ type2="spell", spell2=498 }, -- Protection divine
},
{
{ type1="spell", spell1=1044 }, -- Main de liberté
{ type2="spell", spell2=1038 }, -- Main de salut
}
},
},
debuffs = {
max = 5,
filter = "HARMFUL",
left = "LEFT",
right = "RIGHT",
types = { "Poison","Disease" },
rest = {},
combat = {},
spells = {
[1] = {
[1] = { type1="spell", spell1=4987 }, -- Poison
},
[2] = {
[1] = { type1="spell", spell1=4987 }, -- Maladie
},
},
},
}
};
trunk/phUnitFramesConfig.lua New file
0,0 → 1,83
phUnitFramesModels = {
showBlizzardPartyFrame = true;
["Raid Pretre Sacre"] = {
width = 175,
height = 18,
fontsize = 14,
spells = {
{ type1="target" }, -- Cible
{ type2="assist" }, -- Assister
{ ["shift-type1"]="focus" }, -- Focus
{ ["ctrl-type1"]="spell", ["ctrl-spell1"]=47788 }, -- Esprit Gardien
{ ["ctrl-type2"]="spell", ["ctrl-spell2"]=6346 }, -- Gardian Peur
},
buffs = {
max = 4,
filter = "HELPFUL",
left = "RIGHT",
right = "LEFT",
rest = {
6307,79105, -- Endu
79107, -- Ombre
 
588, -- Feu Intérieur
 
47788, -- Esprit Gardien
6346, -- Gardian Peur
 
77487, -- Orbre d'ombre
 
139, -- Renovation
17, -- Bouclier
41635, -- Priere de Guérison
 
70772, -- Bonus T10
},
combat = {
47788, -- Esprit Gardian
6346, -- Gardian Peur
 
77487, -- Orbre d'ombre
 
139, -- Renovation
17, -- Bouclier
41635, -- Priere de Guérison
 
70772, -- Bonus T10
 
15357, -- Inspiration
},
spells = {
{
{ type1="spell", spell1=139 }, -- Renovation
{ type2="spell", spell2=17 }, -- Bouclier
{ ["shift-type1"]="spell", ["shift-spell1"]=21562 }, -- Endu
},
{
{ ["shift-type1"]="spell", ["shift-spell1"]=27683 }, -- Ombre
}
},
},
debuffs = {
max = 5,
filter = "HARMFUL",
left = "LEFT",
right = "RIGHT",
types = { "Magic","Disease" },
rest = {
6788, -- Ame affaiblie
},
combat = {
6788, -- Ame affaiblie
},
spells = {
[1] = {
[1] = { type1="spell", spell1=527 }, -- Magie
},
[2] = {
[1] = { type1="spell", spell1=528 }, -- Maladie
},
},
},
}
};
trunk/phLib.lua New file
0,0 → 1,23

 
phLib = {
 
deepcopy = function(object)
local lookup_table = {}
local function _copy(object)
if type(object) ~= "table" then
return object
elseif lookup_table[object] then
return lookup_table[object]
end
local new_table = {}
lookup_table[object] = new_table
for index, value in pairs(object) do
new_table[_copy(index)] = _copy(value)
end
return new_table
end
return _copy(object)
end,
 
}
trunk/phUnitFrame.lua New file
0,0 → 1,494

phUnitFrame = {
create = function(parent,frame)
local config = parent.config;
local model = phUnitFramesModels[config.model];
 
if not frame then
frame = CreateFrame("Button",nil,parent,"SecureUnitButtonTemplate");
frame:SetPoint("CENTER",0,0);
 
-- Barre
 
frame.config = config;
frame.alpha = 0.9;
frame.order = 100;
frame.name = "?";
frame.disp_role = 0;
frame.createTooltip = phUnitFrame.createTooltip;
 
frame.bar = CreateFrame("StatusBar",nil,frame);
frame.bar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar");
frame.bar:SetMinMaxValues(0, 100);
frame.bar:SetValue(100);
frame.bar:SetStatusBarColor(0,1,0);
frame.bar:SetPoint("TOPLEFT",frame,"TOPLEFT");
frame.bar:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT");
 
frame.icon = frame.bar:CreateTexture(nil,"OVERLAY");
frame.icon:SetPoint("RIGHT",0,0);
frame.icon:Hide();
 
frame.text = frame.bar:CreateFontString(nil,"ARTWORK");
frame.text:SetFontObject(GameFontHighlightSmall);
frame.text:SetPoint("TOPLEFT",0,0);
frame.text:SetText("Nom");
 
frame:SetScript("OnEnter",function(frame)
frame:SetAlpha(1);
frame.mouseover = true;
frame:createTooltip(frame.unit);
end);
frame:SetScript("OnLeave",function(frame)
frame.mouseover = false;
frame:SetAlpha(frame.alpha);
GameTooltip:Hide();
end);
 
frame:RegisterEvent("UNIT_HEALTH");
frame:RegisterEvent("UNIT_MAXHEALTH");
frame:RegisterEvent("UNIT_AURA");
frame:RegisterEvent("UNIT_NAME_UPDATE");
frame:SetScript("OnEvent",function(frame,event,...)
if event == "PLAYER_TARGET_CHANGED" or "PLAYER_FOCUS_CHANGED" then
phUnitFrame.update(frame);
elseif frame.unit then
local unit = ...;
if UnitIsUnit(unit,frame.unit) then
phUnitFrame.update(frame);
end;
end;
end);
 
frame.buffs = phUnitFrame.createAuraButtons(frame,model.buffs);
frame.debuffs = phUnitFrame.createAuraButtons(frame,model.debuffs);
 
RegisterUnitWatch(frame);
frame.update = phUnitFrame.update;
frame.changeUnit = phUnitFrame.changeUnit;
else
phUnitFrame.createAuraButtons(frame,model.buffs,frame.buffs);
phUnitFrame.createAuraButtons(frame,model.debuffs,frame.debuffs);
end;
 
frame:SetWidth(config.width);
frame:SetHeight(config.height);
frame.text:SetFont(STANDARD_TEXT_FONT,config.fontsize);
frame.icon:SetWidth(config.height);
frame.icon:SetHeight(config.height);
phUnitFrame.createButtonAttributes(frame,model.spells);
 
return frame;
end,
 
changeUnit = function(frame,unit)
if frame.unit == unit then
return;
end;
if unit == "target" then
frame:RegisterEvent("PLAYER_TARGET_CHANGED");
else
frame:UnregisterEvent("PLAYER_TARGET_CHANGED");
end;
if unit == "focus" then
frame:RegisterEvent("PLAYER_FOCUS_CHANGED");
else
frame:UnregisterEvent("PLAYER_FOCUS_CHANGED");
end;
frame.unit = unit;
frame:SetAttribute ("unit",unit);
for i,button in pairs(frame.buffs) do
button:SetAttribute ("unit",unit);
end;
for i,button in pairs(frame.debuffs) do
button:SetAttribute ("unit",unit);
end;
local guid = UnitGUID(unit);
if guid then
frame.role = phPlayerRoles[guid];
end;
end,
 
createAuraButtons = function(frame,bconfig,list)
if not list then
list = {};
end;
local lastbutton = frame;
local config = frame.config;
for i=1,bconfig.max do
local button = list[i];
if not button then
button = CreateFrame("Button",nil,frame,"SecureUnitButtonTemplate");
button.frame = frame;
button.createTooltip = phUnitFrame.createTooltip;
 
button.icon = button:CreateTexture(nil,"BACKGROUND");
button.icon:SetTexture("Interface\\TargetingFrame\\UI-StatusBar");
button.icon:SetAllPoints(button);
 
button.cooldown = CreateFrame("Cooldown",nil,button,"CooldownFrameTemplate");
button.cooldown:SetPoint("CENTER",0,0);
button.cooldown:SetReverse(true);
 
button.count = button:CreateFontString(nil,"ARTWORK");
button.count:SetFontObject(NumberFontNormalSmall);
button.count:SetPoint("BOTTOMRIGHT",4,0);
button.count:SetText("99");
 
button:SetScript("OnEnter",function(button)
button:createTooltip(button.frame.unit);
end);
button:SetScript("OnUpdate",function(button)
if GameTooltip:IsOwned(button) then
button:createTooltip(button.frame.unit);
end;
end);
button:SetScript("OnLeave",function(button)
GameTooltip:Hide();
end);
 
list[i] = button;
end;
 
button:SetPoint(bconfig.left,lastbutton,bconfig.right);
button:SetWidth(config.height);
button:SetHeight(config.height);
 
if bconfig.types and bconfig.types[i] then
button.type = bconfig.types[i];
else
button.type = nil;
end
 
phUnitFrame.createButtonAttributes(button,bconfig.spells[i]);
 
lastbutton = button;
end
return list;
end,
 
createButtonAttributes = function(button,spells)
button:RegisterForClicks ("AnyUp");
button:SetAttribute("alt-ctrl-type2","menu");
button.menu = phUnitFrame.buttonMenu;
button:SetAttribute("type1",nil);
button:SetAttribute("type2",nil);
button:SetAttribute("shift-type1",nil);
button:SetAttribute("shift-type2",nil);
button:SetAttribute("ctrl-type1",nil);
button:SetAttribute("ctrl-type2",nil);
if not spells then
button.tooltip = nil;
return;
end;
button.tooltip = {};
for count=1,table.getn(spells) do
local name = "?";
local action = "?";
for attr,value in pairs(spells[count]) do
button:SetAttribute(attr,value);
if attr == "type1" then
action = "|cff69ccf0 Clic gauche |r ";
elseif attr == "type2" then
action = "|cff69ccf0 Clic droit |r ";
elseif attr == "shift-type1" then
action = "|cff69ccf0 Shift+Clic gauche |r ";
elseif attr == "shift-type2" then
action = "|cff69ccf0 Shift+Clic droit |r ";
elseif attr == "ctrl-type1" then
action = "|cff69ccf0 Ctrl+Clic gauche |r ";
elseif attr == "ctrl-type2" then
action = "|cff69ccf0 Ctrl+Clic droit |r ";
elseif string.find(attr,"spell") then
local spellname, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange = GetSpellInfo(value);
if rank and rank ~= "" then
name = spellname.." ("..rank..")";
elseif spellname then
name = spellname;
else
name = "?";
end;
if button.icon then
button.icon:SetTexture(icon);
end;
end;
if value == "target" then
name = "Cibler";
elseif value == "assist" then
name = "Assister";
elseif value == "focus" then
name = "Modifier focus";
end;
end;
button.tooltip[count] = action..name;
end;
end,
 
buttonMenu = function(button)
if button.unit then
local menu = {
{ text = "Role", notCheckable = true, hasArrow = true, menuList = {
{ text = "Defaut", checked = (not button.role), arg1 = button, arg2 = nil, func = phUnitFrame.changeRole },
{ text = "Tank", checked = (button.role == 1), arg1 = button, arg2 = 1, func = phUnitFrame.changeRole },
{ text = "DPS", checked = (button.role == 2), arg1 = button, arg2 = 2, func = phUnitFrame.changeRole },
{ text = "Soin", checked = (button.role == 3), arg1 = button, arg2 = 3, func = phUnitFrame.changeRole },
}
}
};
EasyMenu(menu, phMenuFrame, "cursor", 0 , 0, "MENU", 5);
end
end,
 
changeRole = function(menu,button,newrole,checked)
button.role = newrole;
local guid = UnitGUID(button.unit);
if guid then
phPlayerRoles[guid] = newrole;
end;
CloseDropDownMenus();
end,
 
createTooltip = function(button,unit)
if unit and UnitExists(unit) then
GameTooltip:SetOwner(button, "ANCHOR_BOTTOMRIGHT", 0, 0);
if button.auraIndex and button.filter then
GameTooltip:SetUnitAura(unit,button.auraIndex,button.filter);
else
GameTooltip:SetUnit(unit);
end
if button.tooltip then
GameTooltip:AddLine (" ");
GameTooltip:AddLine ("Lancer des sorts sur "..UnitName(unit).." :",1,1,1);
for i,msg in pairs(button.tooltip) do
GameTooltip:AddLine (msg);
end;
end;
GameTooltip:Show();
end;
end,
 
update = function(frame)
local unit = frame.unit;
 
if not unit or not UnitExists(unit) then
phUnitFrame.updateSimple(frame,unit);
return;
end
 
local role = frame.role;
if not role then
local r = UnitGroupRolesAssigned(unit);
if not r then role = 0;
elseif r == "TANK" then role = 1;
elseif r == "DAMAGER" then role = 2;
elseif r == "HEALER" then role = 3;
else role = 0;
end;
end;
frame.disp_role = role;
 
if frame.config.showrole and role > 0 then
frame.icon:SetTexture("Interface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES");
if role == 1 then
frame.icon:SetTexCoord(0, 19/64, 22/64, 41/64);
elseif role == 2 then
frame.icon:SetTexCoord(20/64, 39/64, 22/64, 41/64);
elseif role == 3 then
frame.icon:SetTexCoord(20/64, 39/64, 1/64, 20/64);
end;
frame.icon:Show();
else
frame.icon:Hide();
end;
 
if not UnitIsConnected(unit) then
phUnitFrame.updateSimple(frame,UnitName(unit));
frame.icon:SetTexture("Interface\\CharacterFrame\\Disconnect-Icon");
frame.icon:SetTexCoord(0.25, 0.75, 0.20, 0.80);
frame.icon:Show();
return;
end;
 
if UnitIsGhost(unit) then
phUnitFrame.updateSimple(frame,UnitName(unit));
frame.icon:SetTexture("Interface\\TAXIFRAME\\UI-Taxi-Icon-Gray"); -- Bottes avec ailes
frame.icon:SetTexCoord(0, 1, 0, 1);
frame.icon:Show();
return;
end
if UnitIsDead(unit) then
phUnitFrame.updateSimple(frame,UnitName(unit));
frame.icon:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcon_8"); -- Crane blanc
frame.icon:SetTexCoord(0, 1, 0, 1);
frame.icon:Show();
return;
end
if not UnitIsVisible(unit) then
phUnitFrame.updateSimple(frame,UnitName(unit));
frame.icon:SetTexture("Interface\\GossipFrame\\TaxiGossipIcon"); -- Ailes
frame.icon:SetTexCoord(0, 1, 0, 1);
frame.icon:Show();
return;
end
 
 
if UnitIsFriend("player",unit) then
frame.bar:SetStatusBarColor(0,1,0);
if not UnitIsVisible(unit) or not UnitInRange(unit) then
frame.alpha = 0.4;
else
frame.alpha = 0.9;
end;
else
frame.bar:SetStatusBarColor(1,0,0);
frame.alpha = 0.9;
end
 
if not frame.mouseover then
frame:SetAlpha(frame.alpha);
end;
if UnitIsAFK(unit) then
frame.icon:SetTexture("Interface\\FriendsFrame\\StatusIcon-Away");
frame.icon:SetTexCoord(0, 1, 0, 1);
frame.icon:Show();
end
frame.name = UnitName(unit);
local _,className = UnitClass(unit);
local c = RAID_CLASS_COLORS[className];
if not c then
c = { r=1,g=1,b=1 };
end;
frame.text:SetTextColor(c.r,c.g,c.b);
frame.text:SetText(frame.name);
 
frame.order = PHCLASS_ORDER[className];
if not frame.order then
frame.order = 100;
end;
 
frame.bar:SetMinMaxValues(0,UnitHealthMax(unit));
frame.bar:SetValue(UnitHealth(unit));
 
local model = phUnitFramesModels[frame.config.model];
phUnitFrame.updateAuras(frame,frame.buffs,model.buffs);
phUnitFrame.updateAuras(frame,frame.debuffs,model.debuffs);
 
end,
 
updateSimple = function(frame,msg)
frame.alpha = 0.5;
if not frame.mouseover then
frame:SetAlpha(frame.alpha);
end;
frame.text:SetText(msg);
frame.bar:SetStatusBarColor(0.5,0.5,0.5);
frame.bar:SetMinMaxValues(0, 100);
frame.bar:SetValue(100);
for i,button in pairs(frame.buffs) do
button:SetAlpha(0);
end;
for i,button in pairs(frame.debuffs) do
button:SetAlpha(0);
end;
end,
 
updateAuras = function(frame,buttons,bconfig)
local list = {};
for i=1,100 do
local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(frame.unit,i,bconfig.filter);
if name == nil then
break;
end;
local aura = {
index = i,
type = debuffType,
icon = icon,
count = count,
duration = duration,
expirationTime = expirationTime,
};
--print(name,spellId);
if not list[spellId] then
list[spellId] = aura;
else
list[spellId].count = list[spellId].count + 1;
end
end;
 
for i=1,table.getn(buttons) do
buttons[i]:SetAlpha(0);
end;
 
local b;
for i=1,table.getn(buttons) do
local button = buttons[i];
if not button.type then
b = i;
break;
end;
local found;
for spellId,aura in pairs(list) do
if aura.type == button.type or (aura.type == nil and button.type == "None") then
found = spellId;
break;
end;
end;
if found then
phUnitFrame.updateAura(button,bconfig.filter,list[found]);
list[found] = nil;
end;
end
 
if not buttons[b] then
return;
end;
 
local order = bconfig.rest;
if InCombatLockdown() then
order = bconfig.combat;
end;
 
for j=1,table.getn(order) do
local spellId = order[j];
if list[spellId] then
phUnitFrame.updateAura(buttons[b],bconfig.filter,list[spellId]);
b = b + 1;
if not buttons[b] then
return;
end;
end;
end;
--[[
local j = 1;
for i=1,table.getn(buttons) do
local button = buttons[i];
if button.type == nil and list[j] ~= nil then
phUnitFrame.updateAura(button,filter,list[j]);
j = j + 1;
endz
end;
 
--]]
end,
 
updateAura = function(button,filter,aura)
button.filter = filter;
button.auraIndex = aura.index;
if (aura.count > 1) then
button.count:SetText(aura.count);
else
button.count:SetText(nil);
end
if aura.duration then
CooldownFrame_SetTimer(button.cooldown,aura.expirationTime-aura.duration,aura.duration,1);
button.cooldown:SetAlpha(1);
else
buff.cooldown:SetAlpha(0);
end;
button.icon:SetTexture(aura.icon);
button:SetAlpha(1);
end,
 
}
 
 
trunk/phVars.lua New file
0,0 → 1,12
PHCLASS_ORDER = {
["WARRIOR"] = 1,
["DEATHKNIGHT"] = 2,
["PALADIN"] = 3,
["SHAMAN"] = 4,
["ROGUE"] = 5,
["HUNTER"] = 6,
["WARLOCK"] = 7,
["MAGE"] = 8,
["DRUID"] = 9,
["PRIEST"] = 10,
};