Skip to content

Commit 8a8bfa1

Browse files
committed
layout manual
1 parent b47e3f7 commit 8a8bfa1

File tree

10 files changed

+88
-3
lines changed

10 files changed

+88
-3
lines changed

docs/en/manuals/gui-layouts.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ You also need to specify that the engine should use your new profiles. Open *gam
3232

3333
If you want the engine to automatically switch between portrait and landscape layouts on device rotation, check the *Dynamic Orientation* box. The engine will dynamically select a matching layout and also change the selection if the device changes orientation.
3434

35+
### Auto Layout Selection (Display Profiles)
36+
37+
Display Profiles resource has an “Auto Layout Selection” option (ON by default). When ON, the engine automatically selects the best matching GUI layout both when the scene is created and when the window/display size changes. When OFF, the engine will not change layouts automatically—use `gui.set_layout()` from your GUI script to switch layouts manually. This setting is stored in the Display Profiles file and affects all GUI scene.
38+
3539
## GUI layouts
3640

3741
The current set of display profiled can be used to create layout variants of your GUI node setup. To add a new layout to a GUI scene, right-click the *Layouts* icon in the *Outline* view and select <kbd>Add ▸ Layout ▸ ...</kbd>:
@@ -52,7 +56,7 @@ A layout cannot delete or create new nodes, only override properties. If you nee
5256

5357
## Dynamic profile selection
5458

55-
The dynamic layout matching scores each display profile qualifier according to the following rules:
59+
When Auto Layout Selection is enabled, the engine automatically selects the best matching layout. The dynamic layout matching scores each display profile qualifier according to the following rules:
5660

5761
1. If there is no device model set, or the device model matches, a score (S) is calculated for the qualifier.
5862

@@ -70,7 +74,7 @@ Since the *Default* layout is used as fallback in runtime if there are no better
7074

7175
## Layout change messages
7276

73-
When the engine switches layout as a result of device rotation, a `layout_changed` message is posted to the GUI components' scripts that are affected by the change. The message contains the hashed id of the layout so the script can perform logic depending on which layout is selected:
77+
When the layout changes, a `layout_changed` message is posted to the GUI component’s script. This happens when the engine changes layout automatically (Auto Layout Selection ON) or when your script calls `gui.set_layout()` and the layout actually changes. The message contains the hashed id of the layout so the script can perform logic depending on which layout is selected:
7478

7579
```lua
7680
function on_message(self, message_id, message, sender)
@@ -94,3 +98,42 @@ end
9498
```
9599

96100
When orientation is switched, the GUI layout manager will automatically scale and reposition GUI nodes according to your layout and node properties. In-game content, however, is rendered in a separate pass (by default) with a stretch-fit projection into the current window. To change this behavior, either supply your own modified render script, or use a camera [library](/assets/).
101+
102+
## Manual layout selection (Lua)
103+
104+
When Auto Layout Selection is OFF for the Display Profiles in use, the engine won’t switch layouts automatically. Use these functions from a GUI script to manage layouts manually:
105+
106+
### gui.set_layout(layout)
107+
108+
- Accepts a string or hash (layout id).
109+
- Returns boolean: `true` if the layout exists in the scene and was applied; `false` otherwise.
110+
- If the layout exists in Display Profiles, updates the scene resolution to the profile’s width/height.
111+
- Emits `layout_changed` when the layout actually changes.
112+
113+
Example:
114+
115+
```lua
116+
function init(self)
117+
-- Manually apply the "Portrait" layout
118+
local ok = gui.set_layout("Portrait")
119+
if not ok then
120+
print("Portrait layout not found in this scene")
121+
end
122+
end
123+
```
124+
125+
### gui.get_layouts()
126+
127+
- Returns a table mapping each layout id hash to `vmath.vector3(width, height, 0)`.
128+
- For the default layout, returns the current scene resolution.
129+
130+
Example:
131+
132+
```lua
133+
local layouts = gui.get_layouts()
134+
for id, size in pairs(layouts) do
135+
print(id, size.x, size.y)
136+
end
137+
```
138+
139+
Note: If a GUI layout exists in the scene but is not present in Display Profiles, `gui.set_layout()` still applies the per-layout node overrides but does not change the scene resolution.
-575 Bytes
Loading
-4.39 KB
Loading
-7.02 KB
Loading
4.5 KB
Loading
242 Bytes
Loading
-6.59 KB
Loading
-175 Bytes
Loading
-2.13 KB
Loading

docs/ru/manuals/gui-layouts.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ Device Models
3232

3333
Если вы хотите, чтобы движок автоматически переключался между книжной и альбомной раскладками при повороте устройства, установите флажок *Dynamic Orientation*. Движок будет динамически выбирать подходящую компоновку, а также менять ее при смене ориентации устройства.
3434

35+
### Автоматический выбор компоновки (Display Profiles)
36+
37+
У ресурса Display Profiles есть опция «Автоматический выбор компоновки» (по умолчанию ВКЛ). При включении движок автоматически выбирает наиболее подходящую компоновку как при создании сцены, так и при изменении размеров окна/экрана. При отключении движок не меняет компоновку автоматически — используйте `gui.set_layout()` из GUI‑скрипта для ручного переключения. Эта настройка сохраняется в файле Display Profiles и влияет на все GUI‑сцены.
38+
3539
## GUI-компоновки
3640

3741
Текущий набор профилей отображения может быть использован для создания вариантов компоновки конфигурации GUI-нод. Чтобы добавить новую компоновку в GUI-сцену, кликните ПКМ по иконке *Layouts* в представлении *Outline* и выберите <kbd>Add ▸ Layout ▸ ...</kbd>:
@@ -70,7 +74,7 @@ Device Models
7074

7175
## Сообщения о смене компоновки
7276

73-
Когда движок переключает раскладку в результате поворота устройства, сообщение `layout_changed` отправляется в скрипты компонентов GUI, на которые влияет изменение. Сообщение содержит хэшированный идентификатор компоновки, чтобы скрипт мог выполнять логику в зависимости от того, какая компоновка выбрана:
77+
Когда компановка меняется, сообщение `layout_changed` отправляется в скрипты компонентов GUI, на которые влияет изменение. Это происходит, когда движок автоматически меняет компановку (Auto Layout Selection включён) или когда ваш скрипт вызывает `gui.set_layout()`, и раскладка действительно изменяется. Сообщение содержит хэшированный идентификатор компоновки, чтобы скрипт мог выполнять логику в зависимости от того, какая компоновка выбрана:
7478

7579
```lua
7680
function on_message(self, message_id, message, sender)
@@ -94,3 +98,41 @@ end
9498
```
9599

96100
При смене ориентации менеджер GUI-компоновок автоматически изменяет масштаб и расположение GUI-нод в соответствии с компоновкой и свойствами нод. Однако внутриигровое содержимое отображается в отдельном проходе (по умолчанию) с проекцией в текущее окно. Чтобы изменить это поведение, либо предоставьте свой собственный модифицированный рендер-скрипт, либо используйте [библиотеку камеры](/assets/).
101+
## Ручной выбор компоновки (Lua)
102+
103+
Когда для используемого Display Profiles отключён *Автоматический выбор компоновки*, движок не будет переключать компоновки автоматически. Используйте следующие функции в GUI‑скрипте для ручного управления компоновками:
104+
105+
### gui.set_layout(layout)
106+
107+
- Принимает строку или хэш (идентификатор компоновки).
108+
- Возвращает boolean: `true`, если компоновка существует в сцене и была применена; `false` в противном случае.
109+
- Если компоновка присутствует в Display Profiles, обновляет разрешение сцены до ширины/высоты профиля.
110+
- Посылает `layout_changed`, если компоновка действительно изменилась.
111+
112+
Пример:
113+
114+
```lua
115+
function init(self)
116+
-- Ручное применение компоновки "Portrait"
117+
local ok = gui.set_layout("Portrait")
118+
if not ok then
119+
print("Компоновка 'Portrait' не найдена в этой сцене")
120+
end
121+
end
122+
```
123+
124+
### gui.get_layouts()
125+
126+
- Возвращает таблицу, отображающую хэш идентификатора компоновки в `vmath.vector3(width, height, 0)`.
127+
- Для компоновки по умолчанию возвращается текущее разрешение сцены.
128+
129+
Пример:
130+
131+
```lua
132+
local layouts = gui.get_layouts()
133+
for id, size in pairs(layouts) do
134+
print(id, size.x, size.y)
135+
end
136+
```
137+
138+
Примечание: Если компоновка существует в сцене, но отсутствует в Display Profiles, `gui.set_layout()` всё равно применит переопределения свойств нод для этой компоновки, но не изменит разрешение сцены.

0 commit comments

Comments
 (0)