• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Problem with re-positionating the unit portrait

Level 24
Joined
Jun 26, 2020
Messages
1,928
Hello, I wanna move the portrait to make a custom inventory system, it is suposed to look like this:
1723953592688.png

But looks like this:
1723953614059.png

I don't know what is happening, this the script:
Lua:
BlzFrameClearAllPoints(Portrait)
BlzFrameSetPoint(Portrait, FRAMEPOINT_TOPLEFT, InventoryMenu, FRAMEPOINT_TOPLEFT, 0.022500, -0.062500)
BlzFrameSetPoint(Portrait, FRAMEPOINT_BOTTOMRIGHT, InventoryMenu, FRAMEPOINT_BOTTOMRIGHT, -0.025000, 0.062500)
 
the portrait frame position and visuals/size depends on the resolution ratio. For portrait 0/0 is the left bottom corner regardless of resolution and x=0.8 is always most right. To pos it into your box you first need to figure out how much additional space there is at the left screen side.

This thing might help you in doing that, I got it from niklas or screw the trees.
BlzGetLocalClientWidth()/BlzGetLocalClientHeight()*0.6
 
Level 24
Joined
Jun 26, 2020
Messages
1,928
I was testing a lot for what to do because I wanna the frame works for any resolution, so this is the best I could do:
Lua:
local extraWidth = ((BlzGetLocalClientWidth()/BlzGetLocalClientHeight() * 0.6) - 0.8) / 2
minX, maxX = -extraWidth, 0.8+extraWidth
Lua:
local x = 0.1525000 + minX*0.1*BlzGetLocalClientWidth()/BlzGetLocalClientHeight()
BlzFrameSetAbsPoint(Portrait, FRAMEPOINT_TOPLEFT, x, 0.362500)
BlzFrameSetAbsPoint(Portrait, FRAMEPOINT_BOTTOMRIGHT, x + 0.1*1.333*BlzGetLocalClientHeight()/BlzGetLocalClientWidth(), 0.292500)
Is still not perfect, but is the closest I could do (it only looks good in the 4:3 resolution):
1724033732657.png
 
Top