1. "Legion style" unit frames in wotlk

    Hello,
    I'm trying to make my default Blizzard Unit Frames to look exactly like this one on Legion (I mean status text). Something like this:
    Health Bar: 100% ---------------- 50k
    Mana Bar: 55% ---------------- 12k

    Exactly:


    Actually Whoa Unit Frames do it well but it's not exactly like default frames ;/ They're "fat". I'm trying to do it on Thek Unit Frames (which are great by the way) and I achieved my goal only with Health status text, mana/energy isn't working. It wasn't even included in Thek Unit Frames ;/ So I copied health code and changed it to mana/energy but when I use skills the value does not change, only bar visually not text ;/

    I will be very very grateful if someone can help me with this, or maybe you can suggest other way to achieve this so I can have legion style status text on wotlk :)

    Sorry for my bad English btw ;/
    Edited: November 2, 2018



  2. Originally Posted by lekator
    Anyone ? :<
    Code:
    local function fixvalue(v)
    	if v >= 1e6 then
    		return ('%.1fm'):format(v/1e6):gsub('%.?0+([km])$','%1')
    	elseif v >= 1e4 then 
    		return ('%.1fk'):format(v/1e3):gsub('%.?0+([km])$','%1') 
    	else 
    		return v
    	end 
    end
    		
    local oldtextlist = {
    	PlayerFrameHealthBarText,
    	PlayerFrameManaBarText,
    		
    	TargetFrameTextureFrameHealthBarText,
    	TargetFrameTextureFrameManaBarText,
    		
    	FocusFrameTextureFrameHealthBarText,
    	FocusFrameTextureFrameManaBarText,
    }
    	
    local hideoldtext = function()
    	for i,v in pairs(oldtextlist) do
    		v:SetText()
    	end
    end
    
    local newtextlist = {
    	player = { 
    		healthpercent = {parent = PlayerFrameHealthBar, anchor = 'LEFT'},
    		healthvalue = {parent = PlayerFrameHealthBar,anchor = 'RIGHT'},
    		manapercent = {parent = PlayerFrameManaBar,anchor = 'LEFT'},
    		manavalue = {parent = PlayerFrameManaBar,anchor = 'RIGHT'},
    	},
    	target = {
    		healthpercent = {parent = TargetFrameHealthBar,anchor = 'LEFT'},
    		healthvalue = {parent = TargetFrameHealthBar,anchor = 'RIGHT'},
    		manapercent = {parent = TargetFrameManaBar,anchor = 'LEFT'},
    		manavalue = {parent = TargetFrameManaBar,anchor = 'RIGHT'},
    	},
    	focus = {
    		healthpercent = {parent = FocusFrameHealthBar,anchor = 'LEFT'},
    		healthvalue = {parent = FocusFrameHealthBar,anchor = 'RIGHT'},
    		manapercent = {parent = FocusFrameManaBar,anchor = 'LEFT'},
    		manavalue = {parent = FocusFrameManaBar,anchor = 'RIGHT'},
    	},
    }
    
    for unit,elements in pairs(newtextlist) do
    	for k, opts in pairs(elements) do
    		local fontsize = 14
    		local textname = unit..k
    		local offsetX = 5
    		local offsetY = 0
    		if opts.anchor == 'RIGHT' then 
    			offsetX = -5  
    		end
    		
    		if opts.text == nil then 
    			local f = CreateFrame('Frame',nil,opts.parent)
    			f:SetFrameLevel(10)
    			
    			local text = f:CreateFontString(name, 'OVERLAY')
    			text:SetFont(STANDARD_TEXT_FONT, fontsize, 'OUTLINE')
    			text:SetPoint(opts.anchor,opts.parent,opts.anchor,offsetX,offsetY)  
    			opts.text = text
    		end
    	end
    end
    
    local UpDateText = function()
    	hideoldtext()
    	
    	for unit, elements in pairs(newtextlist) do
    		for k,opts in pairs(elements) do
    			local Minvalue, Maxvalue = opts.parent:GetMinMaxValues()
    			local value = opts.parent:GetValue()
    			if k == 'healthpercent' or k == 'manapercent' then
    				if GetCVarBool('statusTextPercentage') then
    					local per = math.floor((value / Maxvalue) * 100)
    					opts.text:Show()
    					opts.text:SetText(per..'%')
    				else
    					opts.text:Hide()
    				end
    			elseif k == 'healthvalue' then
    				if(UnitIsDead(unit)) then
    					opts.text:SetText(' ')
    				elseif (UnitIsGhost(unit)) then
    					opts.text:SetText('Dead')
    				elseif not UnitIsConnected(unit) then
    					opts.text:SetText('DC')
    				else
    					opts.text:SetText(fixvalue(value))
    				end
    			elseif k == 'manavalue' then
    				if (unit == 'target' or unit == 'focus') and not UnitIsConnected(unit) or Maxvalue == 0 or value == 0 then
    					opts.text:SetText()
    				elseif (UnitIsDead(unit) or UnitIsGhost(unit)) then
    					opts.text:SetText()
    				else	
    					opts.text:SetText(fixvalue(value))
    				end
    			end
    		end
    	end
    end
    
    hooksecurefunc('TextStatusBar_Initialize', UpDateText)
    hooksecurefunc('TextStatusBar_OnEvent', UpDateText)
    hooksecurefunc('TextStatusBar_UpdateTextString', UpDateText)
    hooksecurefunc('TextStatusBar_OnValueChanged', UpDateText)
    hooksecurefunc('HideTextStatusBarText', UpDateText)
    Copy & paste the code into any existing LUA-file (or into thek: Unitframes; This AddOn contains 3 files: class.lua, config.lua or core.lua - you may choose either one)

    Looks like this:


    Requires you to have 'Display Percentages' enabled.

    Either through the interface options


    or directly setting the corresponding CVar ingame:
    /run SetCVar('statusTextPercentage',1)ReloadUI()

  3. Thank you so much !!!! Works just perfect :) Thank you, thank you :)

  4. Can you provide a working 3.3.5 Thek?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •