Share settings page helpers, add GUI cursor/scale API

- move create_trackbar_setting/update_trackbar_label/create_checkbox from
  settings_audio/display/graphics pages to core:settings_common module
- GUI scale trackbar shows the really applied scale, e.g. '3 (effective 2)'
- add gui.get_scale(), gui.get_max_scale(), gui.get_cursor_pos() (UI units);
  document that input.get_mouse_pos() returns window pixels
- InventoryView default color is defined once (InventoryView::DEFAULT_COLOR)
  instead of duplicated literals; 'color' attribute still overrides it
This commit is contained in:
loki5512344 2026-10-03 13:12:30 +00:00
parent 851c1a0e27
commit 33e132a231
15 changed files with 173 additions and 123 deletions

View file

@ -16,6 +16,17 @@ gui.str(text: str, context: str) -> str
-- Returns size of the main container (window).
gui.get_viewport() -> {int, int}
-- Returns current GUI scale: window pixels per one UI unit (1..4).
-- Set by the display.gui-scale setting and limited by window size.
gui.get_scale() -> int
-- Returns maximal GUI scale that fits the current window size.
gui.get_max_scale() -> int
-- Returns cursor position in UI units (unlike input.get_mouse_pos,
-- which returns window pixels). Use it to position UI elements.
gui.get_cursor_pos() -> {number, number}
-- Returns environment (global variables table) of the specified document.
gui.get_env(document: str) -> table
```

View file

@ -55,7 +55,8 @@ end, document.root)
input.get_mouse_pos() --> {int, int}
```
Returns cursor screen position.
Returns cursor screen position in window pixels.
To get position in UI units (affected by GUI scale) use `gui.get_cursor_pos()`.
```lua
input.get_mouse_delta() --> {int, int}