Jump to content
sizraide

Converting safeZone to pixelGrid

Recommended Posts

I want my GUI dialogs to stay consistent in size with different ratio aspects.

At the moment my dialogs stay consistent in size with different resolutions.

 

How do I convert this (for example):

x = 0.00492199 * safezoneW;
y = 0.014 * safezoneH;
w = 0.132891 * safezoneW;
h = 0.056 * safezoneH;

To something like this (taken from Dynamic Recon Ops)?

x = "safezoneX + (5 * pixelGridNoUIScale * pixelW)";
y = "safezoneY + (0.25 * pixelGridNoUIScale * pixelH)";
w = "15 * pixelGridNoUIScale * pixelW";	
h = "15 * pixelGridNoUIScale * pixelH";	


I hope I made sense, thanks.

Share this post


Link to post
Share on other sites
x = 0.00492199 * safezoneW;

Well, this is basically saying start at .4% of the screen's width. ( from 0 x which is not the left side of the screen )

x = "safezoneX + (5 * pixelGridNoUIScale * pixelW)";

this is saying start at the left edge of the screen( safeZoneX ) plus 5 grids converted to pixel widths. Where a pixel width is in screen space dimensions( width of screen ).

So...

//Divide value by width of a pixel, rounded to the nearest pixel.
_numPixels = round( 0.00492199 / pixelW );
//num pixels divide by number of pixels in a pixel grid
_numGrids = _numPixels / pixelGridNoUIScale;

This will give you how many pixels grids your original value was. Rounded so your position is pixel-perfect.
Which you can then plug into your UI.
So...

x = _numGrids * ( pixelW * pixelGridNoUIScale );

Replace _numGrids with the answer from the previous calculation.

 

This, Arma 3: Pixel Grid System ,maybe helpful.

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, Larrow said:

x = 0.00492199 * safezoneW;

Well, this is basically saying start at .4% of the screen's width. ( from 0 x which is not the left side of the screen )


x = "safezoneX + (5 * pixelGridNoUIScale * pixelW)";

this is saying start at the left edge of the screen( safeZoneX ) plus 5 grids converted to pixel widths. Where a pixel width is in screen space dimensions( width of screen ).

So...


//Divide value by width of a pixel, rounded to the nearest pixel.
_numPixels = round( 0.00492199 / pixelW );
//num pixels divide by number of pixels in a pixel grid
_numGrids = _numPixels / pixelGridNoUIScale;

This will give you how many pixels grids your original value was. Rounded so your position is pixel-perfect.
Which you can then plug into your UI.
So...


x = _numGrids * ( pixelW * pixelGridNoUIScale );

Replace _numGrids with the answer from the previous calculation.

 

This, Arma 3: Pixel Grid System ,maybe helpful.


Considering I have hundred of classes in my .hpp files to convert the positions.


Would it be possible to just run a function that converts there x, y, w, h to pixelGrid?

class MenuFrame_StartButton_BG: RscPicture
{
    idc = -1;
    text = "#(argb,8,8,3)color(0.05,0.05,0.05,1)";
    x = 0.849453 * safezoneW + safezoneX;
    y = 0.934 * safezoneH + safezoneY;
    w = 0.152578 * safezoneW;
    h = 0.07 * safezoneH;
    onLoad = "[_this # 0] call DES_fnc_changeToPixelGrid;"; // <-- For example.
};

Because right now my dialog in 16:9 1920 x 1080 looks like this:
https://imgur.com/a/sKaihj4

And in 21:9 2560 x 1080, it looks like this:
https://imgur.com/undefined

I want all aspect ratios to have consistent size in dialogs and text, just the way the dialog looks like in 21:9.

Share this post


Link to post
Share on other sites
1 hour ago, sizraide said:

Would it be possible to just run a function that converts there x, y, w, h to pixelGrid?

Yes, but it is slow and looks like crap and would have to be done every time the ui is shown.

Could possibly do it with macros so its updated as the game loads the config. Would still mean you have to go through and update all x,y,w,h definitions though.

Share this post


Link to post
Share on other sites
1 minute ago, Larrow said:

Yes, but it is slow and looks like crap and would have to be done every time the ui is shown.

Could possibly do it with macros so its updated as the game loads the config. Would still mean you have to go through and update all x,y,w,h definitions though.

 

I haven't seen anywhere where I can convert my grid (ctrl + G) to pixelGrid definitions, if it helps.

Because I am willing to recreate the entire dialog.

Share this post


Link to post
Share on other sites

To be honest if your gonna swap to pixelGrid system I would redefine your grid size from scratch based on grids, rather than arbitrary screen percentages.

Maybe these previous discussions help? Dialog Math, Safezone Values and PixelGrid

Share this post


Link to post
Share on other sites
7 minutes ago, Larrow said:

To be honest if your gonna swap to pixelGrid system I would redefine your grid size from scratch based on grids, rather than arbitrary screen percentages.

Maybe these previous discussions help? Dialog Math and PixelGrid

 

Thanks, I'll take a look into it.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×