From cf8fd5ba8578308245ef81f629975256e3417dd7 Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Sat, 5 Jun 2010 23:09:55 +0200 Subject: [PATCH] Add the tags to the main file --- oUF_P3lim.lua | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ oUF_P3lim.toc | 1 - oUF_P3limTags.lua | 70 ----------------------------------------------------- 3 files changed, 68 insertions(+), 71 deletions(-) delete mode 100644 oUF_P3limTags.lua diff --git a/oUF_P3lim.lua b/oUF_P3lim.lua index 51b2225..858bbc5 100644 --- a/oUF_P3lim.lua +++ b/oUF_P3lim.lua @@ -11,6 +11,74 @@ local BACKDROP = { bgFile = TEXTURE, insets = {top = -1, bottom = -1, left = -1, right = -1} } +local function ShortenValue(value) + if(value >= 1e6) then + return ('%.2fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1') + elseif(value >= 1e4) then + return ('%.1fk'):format(value / 1e3):gsub('%.?0+([km])$', '%1') + else + return value + end +end + +for name, func in pairs({ + ['threat'] = function(unit) + local tanking, status, percent = UnitDetailedThreatSituation('player', 'target') + if(percent and percent > 0) then + return ('%s%d%%|r'):format(Hex(GetThreatStatusColor(status)), percent) + end + end, + ['health'] = function(unit) + local min, max = UnitHealth(unit), UnitHealthMax(unit) + local status = not UnitIsConnected(unit) and 'Offline' or UnitIsGhost(unit) and 'Ghost' or UnitIsDead(unit) and 'Dead' + + if(status) then + return status + elseif(unit == 'target' and UnitCanAttack('player', unit)) then + return ('%s (%d|cff0090ff%%|r)'):format(ShortenValue(min), min / max * 100) + elseif(unit == 'player' and min ~= max) then + return ('|cffff8080%d|r %d|cff0090ff%%|r'):format(min - max, min / max * 100) + elseif(min ~= max) then + return ('%s |cff0090ff/|r %s'):format(ShortenValue(min), ShortenValue(max)) + else + return max + end + end, + ['power'] = function(unit) + local power = UnitPower(unit) + if(power > 0) then + local _, type = UnitPowerType(unit) + local colors = _COLORS.power + return ('%s%d|r'):format(Hex(colors[type] or colors['RUNES']), power) + end + end, + ['druid'] = function(unit) + local min, max = UnitPower(unit, 0), UnitPowerMax(unit, 0) + if(UnitPowerType(unit) ~= 0 and min ~= max) then + return ('|cff0090ff%d%%|r'):format(min / max * 100) + end + end, + ['name'] = function(unit) + local reaction = UnitReaction(unit, 'player') + + local r, g, b = 1, 1, 1 + if((UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) or not UnitIsConnected(unit)) then + r, g, b = 3/5, 3/5, 3/5 + elseif(not UnitIsPlayer(unit) and reaction) then + r, g, b = unpack(_COLORS.reaction[reaction]) + elseif(UnitFactionGroup(unit) and UnitIsEnemy(unit, 'player') and UnitIsPVP(unit)) then + r, g, b = 1, 0, 0 + end + + return ('%s%s|r'):format(Hex(r, g, b), UnitName(unit)) + end +}) do + oUF.Tags['p3lim:'..name] = func +end + +oUF.TagEvents['p3lim:name'] = 'UNIT_NAME_UPDATE UNIT_REACTION UNIT_FACTION' +oUF.TagEvents['p3lim:threat'] = 'UNIT_THREAT_LIST_UPDATE' + local function SpawnMenu(self) ToggleDropDownMenu(1, nil, _G[string.gsub(self.unit, '^.', string.upper)..'FrameDropDown'], 'cursor') end diff --git a/oUF_P3lim.toc b/oUF_P3lim.toc index 3e5a7b0..55e88c9 100644 --- a/oUF_P3lim.toc +++ b/oUF_P3lim.toc @@ -6,5 +6,4 @@ ## RequiredDeps: oUF ## OptionalDeps: oUF_DebuffHighlight, oUF_Experience -oUF_P3limTags.lua oUF_P3lim.lua diff --git a/oUF_P3limTags.lua b/oUF_P3limTags.lua deleted file mode 100644 index c9ad1b6..0000000 --- a/oUF_P3limTags.lua +++ /dev/null @@ -1,70 +0,0 @@ -local format = string.format -local gsub = string.gsub - -local function ShortenValue(value) - if(value >= 1e6) then - return ('%.2fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1') - elseif(value >= 1e4) then - return ('%.1fk'):format(value / 1e3):gsub('%.?0+([km])$', '%1') - else - return value - end -end - -for name, func in pairs({ - ['threat'] = function(unit) - local tanking, status, percent = UnitDetailedThreatSituation('player', 'target') - if(percent and percent > 0) then - return ('%s%d%%|r'):format(Hex(GetThreatStatusColor(status)), percent) - end - end, - ['health'] = function(unit) - local min, max = UnitHealth(unit), UnitHealthMax(unit) - local status = not UnitIsConnected(unit) and 'Offline' or UnitIsGhost(unit) and 'Ghost' or UnitIsDead(unit) and 'Dead' - - if(status) then - return status - elseif(unit == 'target' and UnitCanAttack('player', unit)) then - return ('%s (%d|cff0090ff%%|r)'):format(ShortenValue(min), min / max * 100) - elseif(unit == 'player' and min ~= max) then - return ('|cffff8080%d|r %d|cff0090ff%%|r'):format(min - max, min / max * 100) - elseif(min ~= max) then - return ('%s |cff0090ff/|r %s'):format(ShortenValue(min), ShortenValue(max)) - else - return max - end - end, - ['power'] = function(unit) - local power = UnitPower(unit) - if(power > 0) then - local _, type = UnitPowerType(unit) - local colors = _COLORS.power - return ('%s%d|r'):format(Hex(colors[type] or colors['RUNES']), power) - end - end, - ['druid'] = function(unit) - local min, max = UnitPower(unit, 0), UnitPowerMax(unit, 0) - if(UnitPowerType(unit) ~= 0 and min ~= max) then - return ('|cff0090ff%d%%|r'):format(min / max * 100) - end - end, - ['name'] = function(unit) - local reaction = UnitReaction(unit, 'player') - - local r, g, b = 1, 1, 1 - if((UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) or not UnitIsConnected(unit)) then - r, g, b = 3/5, 3/5, 3/5 - elseif(not UnitIsPlayer(unit) and reaction) then - r, g, b = unpack(_COLORS.reaction[reaction]) - elseif(UnitFactionGroup(unit) and UnitIsEnemy(unit, 'player') and UnitIsPVP(unit)) then - r, g, b = 1, 0, 0 - end - - return ('%s%s|r'):format(Hex(r, g, b), UnitName(unit)) - end -}) do - oUF.Tags['p3lim:'..name] = func -end - -oUF.TagEvents['p3lim:name'] = 'UNIT_NAME_UPDATE UNIT_REACTION UNIT_FACTION' -oUF.TagEvents['p3lim:threat'] = 'UNIT_THREAT_LIST_UPDATE' -- 1.7.9.5