Jump to content

Recommended Posts

Can anyone explain how arma figures out its math when creating dialog because I can have some precise calculations and it will work out for 3/4 controls but one does not compute the same, or even worse changing interface size just has completely different math

 

Very Large (Interface Size) - Essentially exactly how it should look

riKzREc.png

 

Large (Interface Size) - Third padding is differnt and total is short

0jjQ76Z.png

 

Normal (Interface Size) - Center padding is different and total is too long

8DO8MbB.png

 

Small (Interface Size) - Padding is decent but total comes short

dFafEKf.png


Is there an error in this math or is arma just dogshit, I don't use safezone or anything as such cause it scales bad with text or images in controls and defeats the purpose of interface size

// Defines
#define buttonPadding 0.0028
  #define buttonWidth (0.65 - (buttonPadding * 3)) / 4

  class CloseButtonKey: Life_RscButtonMenu
  {
    idc = -1;
    text = "Close"; //--- ToDo: Localize;
    onButtonClick = "closeDialog 0"; // 14.6375

    x = 0.1750;
    y = 0.75975;
    w = buttonWidth;
    h = 0.0400;

    colorText[] = {1,1,1,1};
    colorBackground[] = {0,0,0,0.8};
  };

class ButtonSlot1: Life_RscButtonMenu
{
  idc = 2408;

  x = __EVAL(0.1750 + ((buttonWidth * 1) + (buttonPadding * 1)));
  y = 0.75975;
  w = buttonWidth;
  h = 0.0400;

  colorText[] = {1,1,1,1};
  colorBackground[] = {0,0,0,0.8};
};

class ButtonSlot2: Life_RscButtonMenu
{
  idc = 2409;

  x = __EVAL(0.1750 + ((buttonWidth * 2) + (buttonPadding * 2)));
  y = 0.75975;
  w = buttonWidth;
  h = 0.0400;

  colorText[] = {1,1,1,1};
  colorBackground[] = {0,0,0,0.8};
};

class ButtonSlot3: Life_RscButtonMenu
{
  idc = 2410;

  x = __EVAL(0.1750 + ((buttonWidth * 3) + (buttonPadding * 3)));
  y = 0.75975;
  w = buttonWidth;
  h = 0.0400;

  colorText[] = {1,1,1,1};
  colorBackground[] = {0,0,0,0.8};
};

 

Share this post


Link to post
Share on other sites

Scaling your GUI the correct way is one of the big mysterys that hasn't been solved yet (afaik)...

What I can see in your code is that you are using the absolute values (x = 0.52231 etc). This way arma will be rounding some values. If you want really precise results you can use the pixelGrid system.

We can take a look at an example from A3 though (A3\ui_f\config.bin):

class RscDisplayPassword: RscStandardDisplay
{
	scriptName="RscDisplayPassword";
	scriptPath="GUI";
	onLoad="[""onLoad"",_this,""RscDisplayPassword"",'GUI'] call 	(uinamespace getvariable 'BIS_fnc_initDisplay')";
	onUnload="[""onUnload"",_this,""RscDisplayPassword"",'GUI'] call 	(uinamespace getvariable 'BIS_fnc_initDisplay')";
	movingEnable=0;
	simulationEnabled=0;
	class controlsbackground
	{
		class Vignette: RscVignette
		{
			idc=114998;
		};
		class TileGroup: RscControlsGroupNoScrollbars
		{
			idc=115099;
			x="safezoneXAbs";
			y="safezoneY";
			w="safezoneWAbs";
			h="safezoneH";
			class Controls
			{
				class Background: RscText
				{
					idc=114999;
					x=0;
					y=0;
					w="safezoneWAbs";
					h="safezoneH";
					colorBackground[]={0,0,0,0.5};
				};
			};
		};
		class TitleBackground: RscText
		{
			idc=1080;
			x="1 * 			(			((safezoneW / safezoneH) min 1.2) / 40) + 			(safezoneX)";
			y="15 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + 			(safezoneY + safezoneH - 			(			((safezoneW / safezoneH) min 1.2) / 1.2))";
			w="38 * 			(			((safezoneW / safezoneH) min 1.2) / 40)";
			h="1 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
			colorBackground[]=
			{
				"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.13])",
				"(profilenamespace getvariable ['GUI_BCG_RGB_G',0.54])",
				"(profilenamespace getvariable ['GUI_BCG_RGB_B',0.21])",
				"(profilenamespace getvariable ['GUI_BCG_RGB_A',0.8])"
			};
		};
		class MainBackground: RscText
		{
			idc=1081;
			x="1 * 			(			((safezoneW / safezoneH) min 1.2) / 40) + 			(safezoneX)";
			y="16.1 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + 			(safezoneY + safezoneH - 			(			((safezoneW / safezoneH) min 1.2) / 1.2))";
			w="38 * 			(			((safezoneW / safezoneH) min 1.2) / 40)";
			h="6.8 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
			colorBackground[]={0,0,0,0.69999999};
		};
	};
	class controls
	{
		delete B_OK;
		delete B_Cancel;
		class Title: RscTitle
		{
			style=0;
			idc=1000;
			text="$STR_DISP_PASSWORD_TITLE";
			x="1 * 			(			((safezoneW / safezoneH) min 1.2) / 40) + 			(safezoneX)";
			y="15 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + 			(safezoneY + safezoneH - 			(			((safezoneW / safezoneH) min 1.2) / 1.2))";
			w="15 * 			(			((safezoneW / safezoneH) min 1.2) / 40)";
			h="1 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
		};
		class PlayersName: Title
		{
			idc=601;
			style=1;
			colorBackground[]={0,0,0,0};
			x="16 * 			(			((safezoneW / safezoneH) min 1.2) / 40) + 			(safezoneX)";
			y="15 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + 			(safezoneY + safezoneH - 			(			((safezoneW / safezoneH) min 1.2) / 1.2))";
			w="23 * 			(			((safezoneW / safezoneH) min 1.2) / 40)";
			h="1 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
		};
		class TextPassword: RscText
		{
			idc=1002;
			text="$STR_DISP_PASSWORD";
			x="1.5 * 			(			((safezoneW / safezoneH) min 1.2) / 40) + 			(safezoneX)";
			y="18 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + 			(safezoneY + safezoneH - 			(			((safezoneW / safezoneH) min 1.2) / 1.2))";
			w="5 * 			(			((safezoneW / safezoneH) min 1.2) / 40)";
			h="1 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
		};
		class ValuePassword: RscEdit
		{
			idc=101;
			x="6.5 * 			(			((safezoneW / safezoneH) min 1.2) / 40) + 			(safezoneX)";
			y="18 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + 			(safezoneY + safezoneH - 			(			((safezoneW / safezoneH) min 1.2) / 1.2))";
			w="31 * 			(			((safezoneW / safezoneH) min 1.2) / 40)";
			h="1 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
		};
		class ButtonOk: RscButtonMenuOK
		{
			x="32.75 * 			(			((safezoneW / safezoneH) min 1.2) / 40) + 			(safezoneX)";
			y="23 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + 			(safezoneY + safezoneH - 			(			((safezoneW / safezoneH) min 1.2) / 1.2))";
			w="6.25 * 			(			((safezoneW / safezoneH) min 1.2) / 40)";
			h="1 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
		};
		class ButtonCancel: RscButtonMenuCancel
		{
			x="1 * 			(			((safezoneW / safezoneH) min 1.2) / 40) + 			(safezoneX)";
			y="23 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + 			(safezoneY + safezoneH - 			(			((safezoneW / safezoneH) min 1.2) / 1.2))";
			w="6.25 * 			(			((safezoneW / safezoneH) min 1.2) / 40)";
			h="1 * 			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
		};
	};
};

The diaog pops up when you enter a password protected server. I took it as an example bc it's short and has all relevant parts. All other dialogs are nearly made the same way (there are some "black sheeps" though). The formulas here are just as those you get when using 

"Default" call BIS_fnc_exportGUIBaseClasses;

Here are the defines:

// Default grid
#define GUI_GRID_WAbs ((safezoneW / safezoneH) min 1.2)
#define GUI_GRID_HAbs (GUI_GRID_WAbs / 1.2)
#define GUI_GRID_W (GUI_GRID_WAbs / 40)
#define GUI_GRID_H (GUI_GRID_HAbs / 25)
#define GUI_GRID_X (safezoneX)
#define GUI_GRID_Y (safezoneY + safezoneH - GUI_GRID_HAbs)
// Default text sizes
#define GUI_TEXT_SIZE_SMALL		(GUI_GRID_H * 0.8)
#define GUI_TEXT_SIZE_MEDIUM		(GUI_GRID_H * 1)
#define GUI_TEXT_SIZE_LARGE		(GUI_GRID_H * 1.2)

When you are creating a dialog (eg with the default A3 GUI Editor) your variables for position (x,y) and size (w,h) are given out as:

x = 1 * GUI_GRID_W + GUI_GRID_X;
y = 2 * GUI_GRID_H + GUI_GRID_Y;
w = 3 * GUI_GRID_W;
h = 4 * GUI_GRID_H;

If you replace the variables (GUI_GRID_...) then you get what is written in the config. Since the config was binarized all of the #defined variables are replaced with the actual command/value. Therefore you won't see those in the config.

 

Two more things:

1) The GUI_GRID in the default GUI Editor is really broken and not usable unless you use a fix *cough*

2) The newest grid is not the GUI_GRID but the UI_GRID. It is used since the 3den update and relies partially on safezone but when it comes to size (w, h) it uses pixel perfect values by making use of the new pixelGrid commands.

 

There are some other approaches but those are the two "official" ones. Here on the forum are some other discussions about sizing your dialog:

https://forums.bohemia.net/forums/topic/189872-gui-position-and-text-size-with-pixelgrid-pixelw-pixelh/

https://forums.bohemia.net/forums/topic/219480-pixel-grid-system-gui-sizeposition-immune-to-ui-scaling-and-resolution-how/

And another really interesting topic which I can't find atm 😞 

 

What I also really can recommend is the website of our lord and saviour, KillzoneKid:

http://killzonekid.com/arma-scripting-tutorials-gui-part-3/

 

You might have some questions now but so do I still 😄 

  • Like 2

Share this post


Link to post
Share on other sites

Test

Why can't I post anything else?

 

@Larrow provided me with some extensive information for the Pixel Grid System which I found extremely helpful. It broke everything down into smaller steps and explained a lot. Plus some monitor/ArmA history lol. I was going post it here as it maybe useful to others but the forums won't let me. I can't provide a direct link as it wasn't on the forum threads. ArmA'd

  • Like 1

Share this post


Link to post
Share on other sites
On 2/28/2019 at 11:53 PM, NumbNutsJunior said:

I don't use safezone or anything as such cause it scales bad with text or images in controls and defeats the purpose of interface size

Just by the fact of using numbers in your ui elements x,y,w and h you are using safezone values.

 

There is an area in the middle of the screen known as the absolute area, this area is always 4:3 and is based off of your screen height and ui size. The area goes from values [0,0] to [1,1] and the center of your screen is always [0.5,0.5].

UI sizes are VLarge(1), Large(0.85), Normal(0.7),Small(0.55),VSmall(0.47). This number represents the percentage of your screens vertical height that is represented by the absolute area. So if your monitors height is 1080 pixels and you are using ui size VLarge then the absolutes height will be 1080, if you are using VSmall then the absolute areas height will be (1080 * 0.47) = 507 pixels high.

This absolute height is used to calculate safezoneH, if your ui size is VLarge then safezoneH is 1. If ui size is VSmall then 1080 / 507 = 2.127... . As the absolute area is always center on your screen and is always 0,0 to 1,1 then using a ui size of anything but VLarge the remaining screen area is split into top and bottom margins so 2.127 - 1(absolute area) = 1.127 / 2 = 0.563... this is your safezoneY value, remembering that it must be below 0(begining of absolute area) so it must be a negative number -0.563... .

 

Exactly the same is done for your monitors width. We have already said above that VSmall means your absolute height is 507 pixels, as the absolute is 4:3 then the absolutes area width must be 507 / 3 * 4 = 676 pixels. 1920 / 676 = 2.84 this is your safezoneW. Again this area has left and right margins 2.84 - 1(absolute area) = 1.84 / 2 = 0.92 which again must be a negative number safezoneX = -0.92.

 

So as your ui size changes so does the value representing the total width and height.

_resolution = [ 1920, 1080 ];
_uiSize = 1; //VLarge

_screenH = _resolution select 1; //1080
_absoluteH = _screenH * _uiSize; //1080
_safezoneH = _screenH / _absoluteH; //1
_safeZoneY = ( 0 - ( 1 - 1 )) / 2; //-0

_screenW = _resolution select 0; //1920
_absoluteW = _absoluteH / 3 * 4; //1440
_safezoneW = _screenW / _absoluteW; //1.333r
_safezoneX = ( 0 - ( _safezoneW - 1 )) / 2; //-0.1666r

hint format[ "Safezones @ ui size %1\nvertical\nsafezoneH\nreal: %2\ncalculated: %3\nsafezoneY\nreal: %4\ncalculated: %5\nhorizontal\nsafezoneW\nreal: %6\ncalculated: %7\nsafezoneX\nreal: %8\ncalculated: %9",
	_uiSize, safeZoneH, _safezoneH, safeZoneY, _safeZoneY, safeZoneWAbs, _safezoneW, safeZoneXAbs, _safezoneX
];


_resolution = [ 1920, 1080 ];
_uiSize = 0.47; //VSmall

_screenH = _resolution select 1; //1080
_absoluteH = _screenH * _uiSize; //507.6
_safezoneH = _screenH / _absoluteH; //2.127...
_safeZoneY = ( 0 - ( _safezoneH - 1 )) / 2; //-0.563...

_screenW = _resolution select 0; //1920
_absoluteW = _absoluteH / 3 * 4; //676.8
_safezoneW = _screenW / _absoluteW; //2.836...
_safezoneX = ( 0 - ( _safezoneW - 1 )) / 2; //-0.918...

hint format[ "Safezones @ ui size %1\nvertical\nsafezoneH\nreal: %2\ncalculated: %3\nsafezoneY\nreal: %4\ncalculated: %5\nhorizontal\nsafezoneW\nreal: %6\ncalculated: %7\nsafezoneX\nreal: %8\ncalculated: %9",
	_uiSize, safeZoneH, _safezoneH, safeZoneY, _safeZoneY, safeZoneWAbs, _safezoneW, safeZoneXAbs, _safezoneX
];



_resolution = getResolution select [ 0, 2 ];
_uiSize = getResolution select 5;

_screenH = _resolution select 1;
_absoluteH = _screenH * _uiSize;
_safezoneH = _screenH / _absoluteH;
_safeZoneY = ( 0 - ( _safezoneH - 1 )) / 2;

_screenW = _resolution select 0;
_absoluteW = _absoluteH / 3 * 4;
_safezoneW = _screenW / _absoluteW;
_safezoneX = ( 0 - ( _safezoneW - 1 )) / 2;

hint format[ "Safezones @ ui size %1\nvertical\nsafezoneH\nreal: %2\ncalculated: %3\nsafezoneY\nreal: %4\ncalculated: %5\nhorizontal\nsafezoneW\nreal: %6\ncalculated: %7\nsafezoneX\nreal: %8\ncalculated: %9",
	_uiSize, safeZoneH, _safezoneH, safeZoneY, _safeZoneY, safeZoneWAbs, _safezoneW, safeZoneXAbs, _safezoneX
];

Forgiving rounding and string conversion errors these numbers should be pretty close.

 

As the overall number representing the screens width and height changes based on ui size, then so does the size of your constant value used in your ui element.

This is also the same for your padding and because it is a very small number you get pixel errors. 2.836(safezoneWabs) / 1920(horizontal screen in pixels) = each pixel is 0.0014775... of safezoneWabs. Your padding is 0.0028 so just under 2 pixels, add this to your arbitrary button width * number of buttons, your going to be off in pixel precision.

 

Conversation @HazJ mentioned that repeats some of the above but also breaks down the x,y,w and h values that are used in BI ui's as shown in @7erra post.

Spoiler
On 9/6/2018 at 11:44 AM, HazJ said:

Like for example:



// taken from thread above
x="14.6 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)";
y="2 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)";
w="24.4 * (((safezoneW / safezoneH) min 1.2) / 40)";
h="22 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";

What is the 14.6 exactly? I know it is x but 14.6 of what? What is the min 1.2 / 2 all about, etc?

 

On 9/7/2018 at 12:54 PM, Larrow said:
On 9/6/2018 at 11:44 AM, HazJ said:

What is the 14.6 exactly?

14.6 grids, where each grid is an arbitrary number made up from splitting the "BI's deemed safe width of the screen" into 40 segments.

 

We need to do a bit of history first, the Arma engine is a legacy system. Back in 2001 when Operation Flashpoint (the first civilian option) was first released there was very little in the wide screen market and the engine was already tailored as based on 4:3 screen ratio.

 

With this in mind, that 4:3 was the prevalent monitor size, everything thing about the old ui system(pre pixel grid) is based off of 4:3. The whole ui system and what is know as the absolute area uses 4:3. Draw a rectangle in the ui from 0,0 to 1,1 this is the absolute area, it is always 4:3. When you change your ui size settings in the option menu all you are doing is shrinking expanding this area. As everything is based off of this area if you shrink it then the ui elements become smaller and visa versa(although the area never becomes larger than your screen height).

 

SAFEZONES.bmp?raw=1

Click for larger image

 

Lets just take width into account and forget about the height for now. so your 14.6 line reads...



(((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)

The deemed safe width is the ratio of the width of the screen divided by its height with a maximum taken of 1.2 wide. Remember a screen is always wider than it is tall, by basing everything of the height your never going to be off screen. If your screen is 4:3 then 3 times 1.2 is 3.6 which is smaller than the screens width of 4.

 

You will also notice if you look at the calculation for height, that it only differs by again dividing the min of 1.2 by 1.2 so 1, one whole height of your screen.

 

So lets break this whole equation down. Dont think about safezoneW/H as just a number think of it as your monitor ratio 4:3, 16:9, 16:10, 21:9 etc

Lets take a 16:9 monitor as our example.. starting with the left side of the equation



(((safezoneW / safezoneH) min 1.2) / 40)


((( 16 / 9) min 1.2) /40)

So..

16/9 = 1.777r  <<Your monitors height goes into your monitors width 1.777r times, remember a monitor is generally always wider than it is tall,

1.777r min 1.2 = 1.2  <<BI deems 1.2 times the height of your monitor in width as safe( nothing is going to be off screen )

1.2 / 40 <<Split this length up into 40 segments( grids )

 

And the right side of the equation...



+ (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)

Weve already seen part of this above so..



+ (safezoneX + (safezoneW - (1.2)/2)

SafezoneW is the number of times the absolute area fits into your screens width. Remember the absolute areas height is not always your screen height, as mentioned before this changes with your game options ui size. Lets just take it for the moment that the absolute areas(4:3) height is your screen height so 9.

If the absolute areas height is 9 then its width must be..

9/3 = 3 << /3 as in 4:3

3*4 = 12 << *4 as in 4:3, 12 is the absolute areas width

16/12 = 1.333r << 16 as in your monitors width, the absolute area fits into your screen width 1.333 times.

This is your safezoneW value 1.333r

 

You can see this in the debug console.. well as near as damn it. Put these into watch lines and notice the relationships.



//Screen width in pixels / absolute area width
( getResolution select 0 ) / ( getResolution select 2 )
safeZoneW

//Screen height in pixels / absolute area height
( getResolution select 1 ) / ( getResolution select 3 )
safeZoneH

Where getResolution select 5 is the scale size of the absolute area versus screen height.



//Screen height in pixels * ui scale
( getresolution select 1 ) * ( getResolution select 5)
//absolute area height
getResolution select 3

 

Anyway onwards...



+ (safezoneX + (1.333 - 1.2)/2)


+ (safezoneX + 0.133 / 2 )

So 0.133 is the width left over after taking away BI's deemed safe width.

0.133/2 = 0.0665 <<divided by 2 gives you left and right margin sizes.



+ (safezoneX + 0.0665)

As the center of the screen is 0.5,0.5 and 0,0 and 1,1 are the outter edges of the absolute area then safezoneX must always be a negative number (unless your using a 4:3 monitor and your ui scale is 1, where safezoneX would be 0). Adding the margin width(0.0665) to safezoneX will give you the starting point of BI's deemed safe area.

 

So the whole thing is...



14.6 * grids + safewidth margin

The ui elements left hand edge is 14.6 grids into BI's deemed safe area.

 

Now the whole problem comes when you want to make pixel perfect ui's. Lets say your monitor is 1920 pixels wide, yes safezoneX is obviously pixel 1 and safezoneX + safezoneW is pixel 1920, safezoneX + (safezonew/2) is also reasonable being pixel 960, but what pixel is an arbitrary value of 1.2 / 40 * 14.6 ? This could obviously fall in between definitive pixel numbers and is why if you were to make a straight vertical 1 pixel width line and move it across the screen it can flicker or display at slightly different widths as it falls across pixel boundaries when using arbitrary safezone values.

 

This is the reason the pixel grid system was implemented. Using some values defined in the games config (uiScaleMaxGrids and uiScaleFactor) it handles splitting the screen up for you into grid size chunks that are pixel perfect no mater the users screen size resolution and ui scale, and pixelW and pixelH are safezone values that are exactly a pixel.

 

Now you could design your whole ui based off of pixelW/H but that would quickly become tiresome specifying 100 pixel across and 300 pixels wide etc. Using pixel grids as long as you take your base anchors from safezoneX or safezoneX + safezoneW or safezoneX + (safezoneW / 2) and the same for H, which I mentioned above must be pixel perfect just by their relationship to the edge of your screen, everything just comes in handy grid sizes.

On top of this there are three different grid modes to choose from pixelGridBase, pixelGridNoUIScale and pixelGrid.

 

Quote

pixelGridBase: Returns grid size based on screen resolution.

pixelGridNoUIScale: Returns grid size based on screen resolution and configs

pixelGrid: Returns grid size based on screen resolution, interface size and configs

 

Multiply the choosen grid system by the pixelW or H will give you safezone values that are pixel perfect measurements. One caveat is that you must only multiply grid sizes by n / uiScaleFactor.



w = pixelW * pixelGrid * ( # / getNumber( configfile >> "uiScaleFactor" );

Where # is the number of grids you require.

 

On 9/8/2018 at 12:05 AM, Larrow said:


#define scaleFactor getNumber( configfile >> "uiScaleFactor" )
#define GRID_X( num ) ( pixelW * pixelGrid * (( num * 2 ) / scaleFactor )) 
#define GRID_Y( num ) ( pixelH * pixelGrid * (( num * 2 ) / scaleFactor )) 


class myUi {
	idd =1001;
	
	class controls {
		
		class myPictrue : RscPicture {
			x = safeZoneX + ( safezoneW / 2 ) - GRID_X( 2 );
			y = safeZoneY + ( safezoneW / 2 ) - GRID_Y( 2 );
			w = GRID_X( 4 );
			h = GRID_Y( 4 );
		};
	};
};

A pixelGrid is pretty small, put this in the debugconsole



test = pixelW * pixelGrid * (( 1 )/getNumber( configfile >> "uiScaleFactor" ))

Then in a watch line place...



test / pixelW

The watch line will show you how many pixels a grid(with scaleFactor) actually is.

 

On my machine, resolution and scale a pixelGrid is 8 pixels wide. Once divided by uiScaleFactor a grid is actually pretty small(mine comes back as 2 pixels) so its a good idea to scale your grids to a value you like for what your working on(this is the *2 in the example above). It may even pay you to add some check to the define to make sure num is always an integer, so you don't end up with fractions of a pixel. 

 

 

  • Like 4

Share this post


Link to post
Share on other sites

PDF !!! PDF !!! PDF !!! TUTORIAL !!! TUTORIAL !!! TUTORIAL !!!

🤣😂🤣😂

Good work!

  • Haha 1

Share this post


Link to post
Share on other sites
On 3/1/2019 at 6:17 PM, Larrow said:

_resolution = getResolution select [ 0, 2 ];
_uiSize = getResolution select 4;

_screenH = _resolution select 1;
_absoluteH = _screenH * _uiSize;
_safezoneH = _screenH / _absoluteH;
_safeZoneY = ( 0 - ( _safezoneH - 1 )) / 2;

_screenW = _resolution select 0;
_absoluteW = _absoluteH / 3 * 4;
_safezoneW = _screenW / _absoluteW;
_safezoneX = ( 0 - ( _safezoneW - 1 )) / 2;

hint format[ "Safezones @ ui size %1\nvertical\nsafezoneH\nreal: %2\ncalculated: %3\nsafezoneY\nreal: %4\ncalculated: %5\nhorizontal\nsafezoneW\nreal: %6\ncalculated: %7\nsafezoneX\nreal: %8\ncalculated: %9",
	_uiSize, safeZoneH, _safezoneH, safeZoneY, _safeZoneY, safeZoneWAbs, _safezoneW, safeZoneXAbs, _safezoneX
];

 

Found a mistake. The uiSize param is the sixth one. So it has to be

_uiSize = getResolution select 5;

Otherwise the calculated results won't be the same as the actual ones.

 

Example output (modified, rpt): 

13:19:09 [1920,1080,677,508,1.77778,0.47] // getResolution
13:19:09 "Safezones @ ui size: 0.47"
13:19:09 "vertical, safezoneH, real: 2.12677"
13:19:09 "calculated: 2.12766"
13:19:09 "safeZoneY real: -0.563386"
13:19:09 "safeZoneY calc: -0.56383"
13:19:09 "safeZoneW real: 2.83634"
13:19:09 "safeZoneW calc: 2.83688"
13:19:09 "safeZoneX real: -0.918168"
13:19:09 "safeZoneX calc: -0.91844"
Spoiler

k4DhPRw.jpg

 

Edited by 7erra
  • Like 1

Share this post


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

Found a mistake. The uiSize param is the fifth sixth one. So it has to be


_uiSize = getResolution select 5;

😃 see counting is hard. Thanks for heads up, fixed my code.

  • Like 2

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

×