View Single Post
03-04-16, 07:15 PM   #24
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by zork View Post
Any texture you want to create needs a frame to be created on.
A statusbar is just a subtype of the frame element with an additional set of functions.

Make sure to read all the statusbar functions.
http://wowprogramming.com/docs/widgets/StatusBar

To be honest I really don't understand your issue. The statusbar has a rich set of functions providing possible solutions for anything you want. If it does not have what you are looking for do not use a statusbar at all. Instead use a texture object and apply any transformations manually via :SetTexCoord().
http://wowprogramming.com/docs/widge...re/SetTexCoord

You can create a fake statusbar in oUF and hook the "OnValueChanged" event on the fake statusbar to trigger any math calculations on your texture.

Lua Code:
  1. local fakePowerBar = CreateFrame("Statusbar",nil,self)
  2. local powerBar = self:CreateTexture(nil,"BACKGROUND",nil,-8)
  3. powerBar:SetPoint("RIGHT") --or "LEFT", "TOP", "BOTTOM" ... whatever you need
  4. self.Power = fakePowerBar
  5. local function UpdatePowerBar(...)
  6.   print(...)
  7.   local ULx, ULy, LLx, LLy, URx, URy, LRx, LRy
  8.   local width, height
  9.   --calculations are pretty easy. Just take a piece of paper IRL and mark the corners. Now flip it in any direction you want. That is your conversion UL becomes UR and UR becomes UL and so on.
  10.   --What is important is since the texture needs to be cut off once you loose value you need to ajust the corners properly.
  11.   --Your texture will be stretched to full width/height, thus you need to adjust the size to make it look right.
  12.   powerBar:SetTexCoord(ULx, ULy, LLx, LLy, URx, URy, LRx, LRy)
  13.   powerBar:SetSize(width,height)
  14. end
  15.  
  16. self.Power:SetScript("OnValueChanged", UpdatePowerBar)
Hi again zork,

My issue is that Texture:SetTexCoord() simply not working on my code at all (well... within ouF). So, creating fake status bar did not fix the fault here ...

Since I'm guessing the problem(?) is between oUF and the place where Texture:SetTexCoord() function is called (as it works fine outside oUF), I'll go back to oUF forum and ask if they have any clues regarding this.

Last edited by Layback_ : 03-04-16 at 07:24 PM.
  Reply With Quote