ID:2182568
 
Not really sure what the word is but is there a way to 'anchor' screen objects? Certain gui objects don't show up based on a players resolution. For example the macro bar at the bottom is cut off for people with lower resolutions, while with a higher resolution I am able to see the whole macro bar and then some. How can I auto-fit screen objects so they don't get cut off for some people.
If your map is using the default stretch-to-fit, there's no way that cutting off the HUD objects should be possible. But if you're using zoom=1, then you need to account for that when you do the resize.

Screen objects can auto-fit to the number of tiles displayed by a map--that is, to client.view--but not to artificial confines imposed on it by the skin. If you want to do that, you'll have to add an on-size command to the map element (make it an instant verb), and use that to adjust HUD objects.
Inner screen area is the number of pixels actually displayed.

Outer screen area is the number of pixels in the viewport.


Calculating outer screen area:

VIEW_WIDTH*TILE_WIDTH x VIEW_HEIGHT*TILE_HEIGHT

Calculating inner screen area:

MAP_WIDTH/MAP_ZOOM x MAP_HEIGHT/MAP_ZOOM


Using inner and outer screen dimensions gives us more information about the edges of the screen:

(inner_w-outer_w)/2 = BUFFER_X
(inner_h-outer_h)/2 = BUFFER_Y

BUFFER_X and BUFFER_Y are how far from the edge of the map element's edges the viewport's edges are.

If you want to keep things from being cut off from the edges of the map element, you need to buffer them according to:

-max(0,buffer_x) (left)
-max(0,buffer_y) (bottom)
max(0,buffer_x) (right)
max(o,buffer_y) (top)

My advice would be to not use EAST, NORTH, SOUTH, WEST based screen position anchors at all and instead use CENTER-based anchors.

If you are capturing on-resize events, you should always know how big a client's screen area is and therefore can easily calculate where hud objects should be placed.

If you base your coordinates using CENTER in their screen objects and then use the buffering calculations, you will never overlap the edges. Simply loop through all hud objects that have anchors and update their location whenever an on-resize event fires.

For more information, see this tutorial, which nobody ever reads:

http://www.byond.com/forum/?post=1816091