/trunk
["Width"] = "Largeur", |
["Height"] = "Hauteur", |
["Model"] = "Modèle", |
["Refresh rate"] = "Rafraîchissement", |
["Left click"] = "Clic gauche", |
["Right click"] = "Clic droit", |
local frames = phUnitFramesConfig.frames; |
for i,frame in pairs(frames) do |
if not frame.refreshRate then |
frame.refreshRate = 30; |
end; |
self:createGroupFrame(frame); |
end; |
end; |
end); |
frame.update = self.updateGroupFrame; |
frame.lastUpdate = GetTime(); |
frame.lastChildIdx = 0; |
frame.updateUnits = self.updateUnits; |
frame.updateBars = self.updateBars; |
frame.lastUpdateUnits = GetTime(); |
frame.lastUpdateBars = GetTime(); |
frame:RegisterEvent("RAID_ROSTER_UPDATE"); |
--[[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); |
end);--]] |
frame:SetScript("OnUpdate",function(frame,timediff) |
frame:update(); |
frame:updateUnits(); |
frame:updateBars(); |
end); |
frame.text = frame:CreateFontString(nil,"ARTWORK"); |
frame.childs = {}; |
if config.units == "raid" then |
for i=1,25 do |
for i=1,40 do |
frame.childs[i] = phUnitFrame.create(frame); |
end; |
else |
{ text = 24, checked = (config.height==24), arg1 = frame, arg2 = 24, func = phUnitFrames.changeHeight }, |
} |
}, |
{ text = phLib.getLocale("Refresh rate"), notCheckable = true, hasArrow = true, menuList = { |
{ text = "1 Hz", checked = (config.refreshRate==1), arg1 = frame, arg2 = 1, func = phUnitFrames.changeRefreshRate }, |
{ text = "10 Hz", checked = (config.refreshRate==10), arg1 = frame, arg2 = 10, func = phUnitFrames.changeRefreshRate }, |
{ text = "20 Hz", checked = (config.refreshRate==20), arg1 = frame, arg2 = 20, func = phUnitFrames.changeRefreshRate }, |
{ text = "30 Hz", checked = (config.refreshRate==30), arg1 = frame, arg2 = 30, func = phUnitFrames.changeRefreshRate }, |
{ text = "40 Hz", checked = (config.refreshRate==40), arg1 = frame, arg2 = 40, func = phUnitFrames.changeRefreshRate }, |
{ text = "50 Hz", checked = (config.refreshRate==50), arg1 = frame, arg2 = 50, func = phUnitFrames.changeRefreshRate }, |
{ text = "60 Hz", checked = (config.refreshRate==60), arg1 = frame, arg2 = 60, func = phUnitFrames.changeRefreshRate }, |
} |
}, |
{ text = phLib.getLocale("Model"), notCheckable = true, hasArrow = true, menuList = configMenu }, |
}; |
EasyMenu(menu, phMenuFrame, "cursor", 0 , 0, "MENU", 5); |
phUnitFrames:createGroupFrame(frame.config,frame); |
end, |
changeRefreshRate = function(menu,frame,refreshRate) |
CloseDropDownMenus(); |
frame.config.refreshRate = refreshRate; |
end, |
changeFontSize = function(menu,frame,size) |
CloseDropDownMenus(); |
frame.config.fontsize = size; |
phUnitFrames:createGroupFrame(frame.config,frame); |
end, |
updateBars = function(frame) |
local refreshTime = 1.0 / frame.config.refreshRate; |
if (GetTime()-frame.lastUpdateBars) < refreshTime then |
return; |
end; |
frame.lastUpdateBars = GetTime(); |
local count = 0; |
local childs = frame.childs; |
local childCount = table.getn(childs); |
for i=1,childCount do |
if not childs[frame.lastChildIdx] then |
frame.lastChildIdx = 1; |
end; |
--childs[frame.lastChildIdx]:updateUnit(); |
childs[frame.lastChildIdx]:updateBars(); |
frame.lastChildIdx = frame.lastChildIdx + 1; |
if (GetTime()-frame.lastUpdateBars) >= refreshTime/2 then |
break; |
end; |
count = count + 1; |
end; |
--print(count); |
--print(GetTime()-frame.lastUpdateBars); |
end, |
updateGroupFrame = function(frame) |
updateUnits = function(frame) |
if GetTime() - frame.lastUpdate < 1 then |
if GetTime() - frame.lastUpdateUnits < 1.0 then |
return; |
end; |
frame.lastUpdate = GetTime(); |
frame.lastUpdateUnits = GetTime(); |
frame.lastUpdateBars = GetTime(); |
local childs = frame.childs; |
local childs = frame.childs; |
if not InCombatLockdown() then |
local config = frame.config; |
if config.units == "raid" then |
--[[for i,child in pairs(childs) do |
child:changeUnit("player"); |
local config = frame.config; |
if config.units == "raid" then |
--[[for i,child in pairs(childs) do |
child:changeUnit("player"); |
end;--]] |
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; |
if GetNumRaidMembers() > 0 then |
for i,child in pairs(childs) do |
child:changeUnit("raid"..i,i); |
end; |
else |
childs[1]:changeUnit("player"); |
for i=1,4 do |
childs[i+1]:changeUnit("party"..i); |
end; |
--childs[6]:changeUnit("playerpet"); |
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 |
for i,child in pairs(childs) do |
child:updateUnit(); |
child:updateBars(); |
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 |
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 = -4; |
end; |
child:SetPoint("TOP",lastframe,"BOTTOM",0,y); |
lastframe = child; |
lastrole = child.disp_role; |
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 = -4; |
end; |
child:SetPoint("TOP",lastframe,"BOTTOM",0,y); |
lastframe = child; |
lastrole = child.disp_role; |
end; |
end |
end, |
} |
local bar = frame:CreateTexture(); |
bar:SetTexture("Interface\\TargetingFrame\\UI-StatusBar"); |
bar:SetTexture("Interface\\AddOns\\phUnitFrames\\uiStatusBar"); |
bar:SetVertexColor(1,0,0,0.5); |
bar:SetPoint("TOPLEFT",frame,"TOPLEFT"); |
bar:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT"); |
frame.ibar = CreateFrame("StatusBar",nil,frame); |
frame.ibar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar"); |
frame.ibar:SetStatusBarTexture("Interface\\AddOns\\phUnitFrames\\uiStatusBar"); |
frame.ibar:SetMinMaxValues(0, 100); |
frame.ibar:SetValue(0); |
frame.ibar:SetStatusBarColor(0,0.5,0.5); |
frame.bar = CreateFrame("StatusBar",nil,frame); |
frame.bar:SetFrameLevel(frame.ibar:GetFrameLevel()+1); |
frame.bar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar"); |
frame.bar:SetStatusBarTexture("Interface\\AddOns\\phUnitFrames\\uiStatusBar"); |
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.licon = frame.bar:CreateTexture(nil,"OVERLAY"); |
frame.licon:SetPoint("LEFT",0,0); |
frame.licon:SetTexture("Interface\\AddOns\\phUnitFrames\\iconThreat"); |
frame.licon:Hide(); |
frame.icon = frame.bar:CreateTexture(nil,"OVERLAY"); |
frame.icon:SetPoint("RIGHT",0,0); |
frame.icon:Hide(); |
frame.loc = frame.bar:CreateFontString(nil,"ARTWORK"); |
frame.loc:SetFontObject(GameFontHighlightSmall); |
frame.loc:SetPoint("BOTTOMRIGHT",0,0); |
frame.loc:SetText("Very Very Long Location Name"); |
frame.loc:Hide(); |
frame.text = frame.bar:CreateFontString(nil,"ARTWORK"); |
frame.text:SetFontObject(GameFontHighlightSmall); |
frame.text:SetPoint("TOPLEFT",0,0); |
frame.text:SetPoint("LEFT",2,0); |
frame.text:SetText("Nom"); |
frame:SetScript("OnEnter",function(frame) |
frame:SetAlpha(1); |
frame.mouseover = true; |
GameTooltip:Hide(); |
end); |
frame:RegisterEvent("UNIT_HEALTH"); |
--[[ frame:RegisterEvent("UNIT_HEALTH"); |
frame:RegisterEvent("UNIT_MAXHEALTH"); |
frame:RegisterEvent("UNIT_AURA"); |
frame:RegisterEvent("UNIT_AURA"); |
frame:RegisterEvent("UNIT_NAME_UPDATE"); |
frame:RegisterEvent("UNIT_HEAL_PREDICTION"); |
frame:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE"); |
frame:SetScript("OnEvent",function(frame,event,...) |
if event == "PLAYER_TARGET_CHANGED" or "PLAYER_FOCUS_CHANGED" then |
phUnitFrame.update(frame,event); |
phUnitFrame.update(frame,event); |
end; |
end; |
end); |
end);--]] |
frame.auras = {}; |
frame.buffs = phUnitFrame.createAuraButtons(frame,model.buffs); |
frame.debuffs = phUnitFrame.createAuraButtons(frame,model.debuffs); |
RegisterUnitWatch(frame); |
frame.update = phUnitFrame.update; |
frame.changeUnit = phUnitFrame.changeUnit; |
frame.updateUnit = phUnitFrame.updateUnit; |
frame.updateBars = phUnitFrame.updateBars; |
else |
phUnitFrame.createAuraButtons(frame,model.buffs,frame.buffs); |
phUnitFrame.createAuraButtons(frame,model.debuffs,frame.debuffs); |
frame:SetWidth(config.width); |
frame:SetHeight(config.height); |
frame.text:SetFont(STANDARD_TEXT_FONT,config.fontsize); |
frame.loc:SetFont(STANDARD_TEXT_FONT,config.fontsize-3); |
frame.icon:SetWidth(config.height); |
frame.icon:SetHeight(config.height); |
frame.licon:SetWidth(config.height); |
frame.licon:SetHeight(config.height); |
phUnitFrame.createButtonAttributes(frame,model.spells); |
return frame; |
end, |
changeUnit = function(frame,unit) |
changeUnit = function(frame,unit,raidIdx) |
if unit then |
local guid = UnitGUID(unit); |
if guid then |
return; |
end; |
if unit == "target" then |
--[[if unit == "target" then |
frame:RegisterEvent("PLAYER_TARGET_CHANGED"); |
else |
frame:UnregisterEvent("PLAYER_TARGET_CHANGED"); |
frame:RegisterEvent("PLAYER_FOCUS_CHANGED"); |
else |
frame:UnregisterEvent("PLAYER_FOCUS_CHANGED"); |
end; |
end;--]] |
frame.unit = unit; |
frame.raidIdx = raidIdx; |
frame:SetAttribute ("unit",unit); |
for i,button in pairs(frame.buffs) do |
button:SetAttribute ("unit",unit); |
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: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); |
-- GameTooltip:AddLine(button:GetAlpha()); |
-- GameTooltip:AddLine(button:IsShown()); |
-- GameTooltip:AddLine(button.aura.icon); |
-- GameTooltip:AddLine(button.aura.duration); |
if button.tooltip and not InCombatLockdown() then |
GameTooltip:AddLine (" "); |
end; |
end, |
update = function(frame,event) |
updateUnit = function(frame,event) |
local unit = frame.unit; |
if not frame.mouseover then |
frame:SetAlpha(frame.alpha); |
end; |
frame.icon:SetTexCoord(0,1,0,1); |
frame.icon:SetVertexColor(1,1,1); |
frame.icon:Hide(); |
frame.loc:Hide(); |
frame.licon:Hide(); |
frame.text:SetPoint("LEFT",2,0); |
if not unit or not UnitExists(unit) then |
frame.text:SetTextColor(1,1,1); |
phUnitFrame.updateSimple(frame,unit); |
frame.bars = false; |
return; |
end |
frame.text:SetTextColor(c.r,c.g,c.b); |
if frame.config.showrole and role > 0 then |
frame.icon:SetTexture("Interface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES"); |
frame.icon:SetTexture("Interface\\AddOns\\phUnitFrames\\iconRoles"); |
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, 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:SetTexture("Interface\\AddOns\\phUnitFrames\\iconOffline"); |
frame.icon:Show(); |
frame.bars = false; |
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:SetTexture("Interface\\AddOns\\phUnitFrames\\iconGhost"); |
frame.icon:Show(); |
frame.bars = false; |
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:SetTexture("Interface\\AddOns\\phUnitFrames\\iconDead"); |
frame.icon:Show(); |
frame.bars = false; |
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(); |
if frame.raidIdx then |
local _,_,_,_,_,_,zone = GetRaidRosterInfo(raidIdx); |
frame.loc:SetText(zone); |
frame.loc:Show(); |
else |
frame.icon:SetTexture("Interface\\AddOns\\phUnitFrames\\iconAway"); |
frame.icon:Show(); |
end; |
frame.bars = false; |
return; |
end |
frame.bars = true; |
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; |
frame.bar:SetStatusBarColor(0,1,0); |
local threat = UnitThreatSituation(unit); |
if threat and threat >= 1 then |
frame.licon:SetVertexColor(GetThreatStatusColor(threat)); |
frame.licon:Show(); |
frame.text:SetPoint("LEFT",frame.licon,"RIGHT"); |
end; |
else |
frame.bar:SetStatusBarColor(1,0,0); |
frame.alpha = 0.9; |
end |
if UnitIsAFK(unit) then |
frame.icon:SetTexture("Interface\\FriendsFrame\\StatusIcon-Away"); |
if UnitIsAFK(unit) then |
frame.icon:SetTexture("Interface\\AddOns\\phUnitFrames\\iconAfk"); |
frame.icon:SetTexCoord(0, 1, 0, 1); |
frame.icon:Show(); |
end |
if not frame.order then |
frame.order = 100; |
end; |
end, |
updateBars = function(frame) |
local unit = frame.unit; |
if not frame.bars or not unit or not UnitExists(unit) then |
return; |
end |
if not UnitInRange(unit) then |
frame.alpha = 0.4; |
else |
frame.alpha = 0.9; |
end; |
frame.ibar:SetMinMaxValues(0,UnitHealthMax(unit)); |
local ival = UnitHealth(unit); |
local model = phUnitFramesModels[frame.config.model]; |
phUnitFrame.updateAuras(frame,frame.buffs,model.buffs); |
phUnitFrame.updateAuras(frame,frame.debuffs,model.debuffs); |
end, |
end, |
updateSimple = function(frame,msg) |
frame.alpha = 0.5; |
frame.text:SetText(msg); |
frame.ibar:SetMinMaxValues(0, 100); |
frame.ibar:SetValue(0); |
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; |
if button.isSecure then |
button:SetAlpha(0); |
else |
button:Hide(); |
end; |
end; |
for i,button in pairs(frame.debuffs) do |
button:SetAlpha(0); |
end; |
if button.isSecure then |
button:SetAlpha(0); |
else |
button:Hide(); |
end; |
end; |
end, |
updateAuras = function(frame,buttons,bconfig) |
else |
button.count:SetText(nil); |
end |
if aura.duration then |
if aura.duration and aura.duration > 0 then |
CooldownFrame_SetTimer(button.cooldown,aura.expirationTime-aura.duration,aura.duration,1); |
button.cooldown:Show(); |
--button.cooldown:SetAlpha(1); |
if not button.isSecure then |
button:Show(); |
end; |
if GameTooltip:IsOwned(button) then |
button:createTooltip(button.frame.unit); |
end; |
end, |
} |