7erra/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
(Created page with "{{wip}} =GUI coordinates= Creating dialogs makes understanding the way Arma 3 handles the screen coordinates mandatory. This page is supposed to give an overview and explanati...")
 
(Overhaul of GUI coordinates)
Line 1: Line 1:
{{wip}}
{{wip}}
=GUI coordinates=
== Example ==
Creating dialogs makes understanding the way Arma 3 handles the screen coordinates mandatory. This page is supposed to give an overview and explanation of this topic.
{{GVI|arma3|1.66}}
==Considerations==
You can check some of the grid systems in interactive test menu in game:
There are three important things to keep in mind:
# Open [[Eden Editor]]
===1) Keeping the dialog on screen===
# Open debug console (Tools > Debug Console)
For this purpose the safeZone grid was introduced. Here is a quick rundown of all six commands:
# Execute this code: <syntaxhighlight lang="cpp">finddisplay 313 createdisplay "RscTestGrids";</syntaxhighlight>
 
A menu where you can see how all grid systems react to specific resolution, aspect ratio and interface size.
 
[[File:a3_GUI_grids.png|320px]]
* Hovering over each grid will show detailed description in tooltip.
* Data for each grid show the current size and max number of grids horizontally and vertically. Useful to making sure your menu proportions will work in all combinations.
* Click COPY TO CLIPBOARD button to copy a code with example that can be used directly in [[Config.cpp]] or [[Description.ext]].
 
== Grids ==
=== [[safeZone]] ===
To keep the dialog on screen the safeZone values were introduced. Here is a quick overview over the six commands:
{| class="wikitable"
{| class="wikitable"
|-
|-
! Command !! Explanation
! Command !! Explanation
|-
|-
| safeZoneX || The left edge of the screen on SINGLE monitor settings.
| [[safeZoneX]] || The left edge of the screen on SINGLE monitor settings.
|-
| [[safeZoneXAbs]] || The left edge of the screen on MULTIPLE monitors (Triple Head, three screens).
|-
| [[safeZoneY]] || The top edge of the screen.
|-
| [[safeZoneW]] || The width of of the screen in a SINGLE monitor setup (or the center one in case of triple head).
|-
| [[safeZoneWAbs]] || The width of a triple head setup. In case of a single monitor this is equal to safeZoneW.
|-
| [[safeZoneH]] || The height of the screen
|}
 
<syntaxhighlight lang="cpp">
//--- Text box which covers the top left quarter of the (center) screen
class TextboxTopLeftQuarter: RscText
{
x = safezoneX;
y = safezoneY;
w = 0.5 * safezoneW;
h = 0.5 * safezoneH;
};
//--- Textbox which covers the entire screen on a triple head setup
class TextboxFullTripleScreen: RscText
{
x = safeZoneXAbs;
y = safeZoneY;
w = safeZoneWAbs;
h = safeZoneH;
};
</syntaxhighlight >
 
=== GUI_GRID ===
The GUI_GRID is based on the safeZone grid and is used by the majority of the game's dialogs. The additional functionality is the possibility to stay on screen even with different user settings such as aspect ratio or UI scale. It also helps to keep a uniform style between dialogs. If you are using the base classes starting with "Rsc" then it is advisable to use this grid. The defines for use in configs and scripts can be accessed by adding the following line to your config:
<code>#include "\a3\ui_f\hpp\definecommongrids.inc"</code>
The following table will list the most commonly used grids which are defined in said file. To use them add the appropiate suffix _X, _Y, _W or _H to the variable name, eg GUI_GRID includes GUI_GRID_X, GUI_GRID_Y, GUI_GRID_W and GUI_GRID_H. The centering refers to the position in which the UI will stay even for different UI sizes. X means horizontally, Y is vertically.
{| class="wikitable"
|-
! Variable !! X !! Y !! Notes
|-
|-
| safeZoneXAbs || The left edge of the screen on MULTIPLE monitors (Triple Head, three screens).
| GUI_GRID || Left || Bottom || Example: Escape menu (RscDisplayInterrupt)
|-
|-
| safeZoneY|| The top edge of the screen.
| GUI_GRID_CENTER || Center || Middle || Example: RscDisplayTeamSwitch
|-
|-
| safeZoneW|| The width of of the screen in a SINGLE monitor setup (or the center one in case of triple head).
| GUI_GRID_TOPCENTER || Center || Top ||  
|-
|-
| safeZoneWAbs|| The width of a triple head setup. In case of a single monitor this is equal to safeZoneW.
| GUI_GRID_BOTTOMCENTER || Center || Bottom || Example: Revive UI
|-
|-
| safeZoneH|| The height of the screen
| GUI_GRID_CENTER_BOTTOM || Center || Bottom || Same as GUI_GRID_BOTTOMCENTER
|-
| GUI_GRID_TOPLEFT || Left || Top || Diary (the top left part of the map)
|}
|}


===2) Considering different settings===
The GUI_GRID divides the screen into 40 parts on the horizontal axis and into 25 vertically. Therefore no content should have negative x or y values nor should it exceed a width of 40 or a height of 25. Using a height of 25 or width of 40 is not the same as using screen height or width because the GUI_GRID will get smaller with smaller UI sizes as it should be. Examples:
These are the settings that can be changed and will influence your dialog:
<syntaxhighlight lang="cpp">
* Screen resolution and aspect ratio: 1920x1080 (16:9), 1366x768 (16:9), 1024x768 (4:3), etc.)
//--- Okay, will use entire available space:
* UI scale: Ranges from Very Small to Very Large
x = GUI_GRID_CENTER_X + 0 * GUI_GRID_CENTER_W;
* Triple Head setups
y = GUI_GRID_CENTER_Y + 0 * GUI_GRID_CENTER_H;
w = 40 * GUI_GRID_CENTER_W;
h = 25 * GUI_GRID_CENTER_H;
</syntaxhighlight >
<syntaxhighlight lang="cpp">
//--- NOT okay:
x = GUI_GRID_CENTER_X - 1 * GUI_GRID_CENTER_W;
y = GUI_GRID_CENTER_Y - 1 * GUI_GRID_CENTER_H;
w = 50 * GUI_GRID_CENTER_W;
h = 30 * GUI_GRID_CENTER_H;
</syntaxhighlight >
The second example will dissapear on certain settings on the left and top edge as well as exceed the screen's width and height.
 
=== [[Pixel Grid System|Pixel Grid]] ===
====  [[pixelW]] / [[pixelH]] ====
Actual pixel size, remains constant. On displays with too fine resolution (e.g., 4K), it can get too small for practical use.
 
<syntaxhighlight lang="cpp">class MyControl: RscText
{
x = safezoneX + 100 * pixelW;
y = safezoneY + 100 * pixelH;
w = 100 * pixelW;
h = 100 * pixelH;
};</syntaxhighlight >
 
==== [[pixelGrid]] ====
Pixel accurate grid introduced to replace GUI_GRID. Respects both resolution and interface size, but always returns whole number which can be divided by up to 4 and still be a whole number. Due to this rounding, some interface sizes may use the same value.
 
<syntaxhighlight lang="cpp">class MyControl: RscText
{
x = safezoneX + 10 * pixelGrid  * pixelW;
y = safezoneY + 10 * pixelGrid  * pixelH;
w = 20 * pixelGrid * pixelW;
h = 20 * pixelGrid * pixelH;
};</syntaxhighlight >
 
==== [[pixelGridNoUIScale]] ====
Similar to pixelGrid, but affected only by resolution, not interface size. Usually used to keep some important elements, e.g., spotlight buttons in the main menu.
 
<syntaxhighlight lang="cpp">class MyControl: RscText
{
x = safezoneX + 10 * pixelGridNoUIScale * pixelW;
y = safezoneY + 10 * pixelGridNoUIScale * pixelH;
w = 20 * pixelGridNoUIScale * pixelW;
h = 20 * pixelGridNoUIScale * pixelH;
};</syntaxhighlight >


For this purpose the GUI_GRID was introduced. It's purpose is to keep a uniform style on all dialogs and is the grid system used across nearly all Arma 3 dialogs.
[[Category: Dialogs|GUI Coordinates]]

Revision as of 19:09, 16 March 2020

Template:wip

Example

Arma 3 logo black.png1.66 You can check some of the grid systems in interactive test menu in game:

  1. Open Eden Editor
  2. Open debug console (Tools > Debug Console)
  3. Execute this code:
    finddisplay 313 createdisplay "RscTestGrids";
    

A menu where you can see how all grid systems react to specific resolution, aspect ratio and interface size.

a3 GUI grids.png

  • Hovering over each grid will show detailed description in tooltip.
  • Data for each grid show the current size and max number of grids horizontally and vertically. Useful to making sure your menu proportions will work in all combinations.
  • Click COPY TO CLIPBOARD button to copy a code with example that can be used directly in Config.cpp or Description.ext.

Grids

safeZone

To keep the dialog on screen the safeZone values were introduced. Here is a quick overview over the six commands:

Command Explanation
safeZoneX The left edge of the screen on SINGLE monitor settings.
safeZoneXAbs The left edge of the screen on MULTIPLE monitors (Triple Head, three screens).
safeZoneY The top edge of the screen.
safeZoneW The width of of the screen in a SINGLE monitor setup (or the center one in case of triple head).
safeZoneWAbs The width of a triple head setup. In case of a single monitor this is equal to safeZoneW.
safeZoneH The height of the screen
//--- Text box which covers the top left quarter of the (center) screen
class TextboxTopLeftQuarter: RscText
{
	x = safezoneX;
	y = safezoneY;
	w = 0.5 * safezoneW;
	h = 0.5 * safezoneH;
};
//--- Textbox which covers the entire screen on a triple head setup
class TextboxFullTripleScreen: RscText
{
	x = safeZoneXAbs;
	y = safeZoneY;
	w = safeZoneWAbs;
	h = safeZoneH;
};

GUI_GRID

The GUI_GRID is based on the safeZone grid and is used by the majority of the game's dialogs. The additional functionality is the possibility to stay on screen even with different user settings such as aspect ratio or UI scale. It also helps to keep a uniform style between dialogs. If you are using the base classes starting with "Rsc" then it is advisable to use this grid. The defines for use in configs and scripts can be accessed by adding the following line to your config: #include "\a3\ui_f\hpp\definecommongrids.inc" The following table will list the most commonly used grids which are defined in said file. To use them add the appropiate suffix _X, _Y, _W or _H to the variable name, eg GUI_GRID includes GUI_GRID_X, GUI_GRID_Y, GUI_GRID_W and GUI_GRID_H. The centering refers to the position in which the UI will stay even for different UI sizes. X means horizontally, Y is vertically.

Variable X Y Notes
GUI_GRID Left Bottom Example: Escape menu (RscDisplayInterrupt)
GUI_GRID_CENTER Center Middle Example: RscDisplayTeamSwitch
GUI_GRID_TOPCENTER Center Top
GUI_GRID_BOTTOMCENTER Center Bottom Example: Revive UI
GUI_GRID_CENTER_BOTTOM Center Bottom Same as GUI_GRID_BOTTOMCENTER
GUI_GRID_TOPLEFT Left Top Diary (the top left part of the map)

The GUI_GRID divides the screen into 40 parts on the horizontal axis and into 25 vertically. Therefore no content should have negative x or y values nor should it exceed a width of 40 or a height of 25. Using a height of 25 or width of 40 is not the same as using screen height or width because the GUI_GRID will get smaller with smaller UI sizes as it should be. Examples:

//--- Okay, will use entire available space:
x = GUI_GRID_CENTER_X + 0 * GUI_GRID_CENTER_W;
y = GUI_GRID_CENTER_Y + 0 * GUI_GRID_CENTER_H;
w = 40 * GUI_GRID_CENTER_W;
h = 25 * GUI_GRID_CENTER_H;
//--- NOT okay:
x = GUI_GRID_CENTER_X - 1 * GUI_GRID_CENTER_W;
y = GUI_GRID_CENTER_Y - 1 * GUI_GRID_CENTER_H;
w = 50 * GUI_GRID_CENTER_W;
h = 30 * GUI_GRID_CENTER_H;

The second example will dissapear on certain settings on the left and top edge as well as exceed the screen's width and height.

Pixel Grid

pixelW / pixelH

Actual pixel size, remains constant. On displays with too fine resolution (e.g., 4K), it can get too small for practical use.

class MyControl: RscText
{
	x = safezoneX + 100 * pixelW;
	y = safezoneY + 100 * pixelH;
	w = 100 * pixelW;
	h = 100 * pixelH;
};

pixelGrid

Pixel accurate grid introduced to replace GUI_GRID. Respects both resolution and interface size, but always returns whole number which can be divided by up to 4 and still be a whole number. Due to this rounding, some interface sizes may use the same value.

class MyControl: RscText
{
	x = safezoneX + 10 * pixelGrid  * pixelW;
	y = safezoneY + 10 * pixelGrid  * pixelH;
	w = 20 * pixelGrid * pixelW;
	h = 20 * pixelGrid * pixelH;
};

pixelGridNoUIScale

Similar to pixelGrid, but affected only by resolution, not interface size. Usually used to keep some important elements, e.g., spotlight buttons in the main menu.

class MyControl: RscText
{
	x = safezoneX + 10 * pixelGridNoUIScale * pixelW;
	y = safezoneY + 10 * pixelGridNoUIScale * pixelH;
	w = 20 * pixelGridNoUIScale * pixelW;
	h = 20 * pixelGridNoUIScale * pixelH;
};