local baseColor = Settings.BaseColor;
local healthColor = Settings.HealthColor;
local powerColors = Settings.PowerColors;
-local width = Settings.Width;
local M = {};
OmaUFEvents = M;
max = frame.health.max;
if current > max then
-- error state, still over maximum
- frame.health:SetWidth(width);
+ frame.health:SetWidth(frame.width);
return;
end
elseif max > 0 then
- frame.health:SetWidth(current/frame.health.max*width);
+ frame.health:SetWidth(current/frame.health.max*frame.width);
else
- frame.health:SetWidth(width);
+ frame.health:SetWidth(frame.width);
return;
end
elseif not UnitIsConnected(unit) then
frame.healthText:SetText("DC");
frame.healthText:Show();
- elseif max > 0 and current < max then
- frame.healthText:SetText(ceil(current/max*100));
+ elseif max > 0 then
+ if current > 1200000000 then -- 1.2B
+ frame.healthText:SetFormattedText("%.1fB", current / 1000000000);
+ elseif current > 1200000 then -- 1.2M
+ frame.healthText:SetFormattedText("%.1fM", current / 1000000);
+ elseif current > 1000 then -- 1K
+ frame.healthText:SetFormattedText("%.1fK", current / 1000);
+ else
+ frame.healthText:SetFormattedText("%d", current)
+ end
frame.healthText:Show();
else
frame.healthText:Hide();
max = frame.mana.max;
if current > max then
-- error
- frame.mana:SetWidth(width);
+ frame.mana:SetWidth(frame.width);
return;
end
end
if max > 0 then
- frame.mana:SetWidth(UnitPower(unit)/max*width);
+ frame.mana:SetWidth(UnitPower(unit)/max*frame.width);
frame.mana:Show();
else
- frame.mana:SetWidth(width);
+ frame.mana:SetWidth(frame.width);
frame.mana:Show();
end
end
end
local function updateName(frame, unit)
+ if not frame.name then return end
local name = UnitName(unit);
if not name then return end
frame.name:SetText(ssub(name, 1, 10));
local incoming = UnitGetIncomingHeals(unit) or 0;
if incoming > 0 then
local max = frame.health.max;
- local space = width - frame.health:GetWidth() + 1;
- local pred = (incoming / max) * width;
+ local space = frame.width - frame.health:GetWidth() + 1;
+ local pred = (incoming / max) * frame.width;
frame.healpred:SetWidth(min(space, pred));
frame.healpred:Show();
else
local shield = UnitGetTotalAbsorbs(unit) or 0;
if shield > 0 then
local max = frame.health.max;
- local space = width - frame.health:GetWidth();
- shield = (shield / max) * width;
+ local space = frame.width - frame.health:GetWidth();
+ shield = (shield / max) * frame.width;
if space == 0 then
frame.shield:Hide();
frame.shieldhl:Show();
if absorb > 0 then
local max = frame.health.max;
local space = frame.health:GetWidth();
- absorb = (absorb / max) * width;
+ absorb = (absorb / max) * frame.width;
frame.healabsorb:SetWidth(min(space, absorb));
frame.healabsorb:Show();
else
end
local function updateLevelText(frame, unit, levelup)
+ if not frame.level then return end
if levelup then
-- PLAYER_LEVEL_UP
frame.level:SetText(levelup);
end,
["UNIT_NAME_UPDATE"] = function(frame)
updateName(frame, frame.displayed);
- updateHealthColor(frame, frame.unit);
+ updateHealthColor(frame, frame.displayed);
end,
["UNIT_CONNECTION"] = function(frame)
updateHealthText(frame, frame.displayed);
end,
["UNIT_FACTION"] = function(frame)
updatePVP(frame, frame.unit);
- updateHealthColor(frame, frame.unit);
+ updateHealthColor(frame, frame.displayed);
end,
["PARTY_LEADER_CHANGED"] = function(frame)
updateLeaderIcon(frame, frame.unit);
updateStatus(frame, frame.unit);
updatePVP(frame, frame.unit);
updateLeaderIcon(frame, frame.unit);
- updateHealthColor(frame, frame.unit);
+ updateHealthColor(frame, frame.displayed);
end,
};
eventFuncs["UNIT_HEALTH_FREQUENT"] = eventFuncs["UNIT_HEALTH"];