move menu pages loader to Lua & add gui.load_document, file.ext(), file.prefix() & add core:gui_util module

This commit is contained in:
MihailRis
2025-01-06 16:07:16 +03:00
parent da471bd4eb
commit 0a1a16299e
16 changed files with 156 additions and 55 deletions
+14 -2
View File
@@ -125,10 +125,22 @@ Combines objects from JSON files of different packs.
file.name(path: str) --> str
```
Extracts the file name from the path.
Extracts the file name from the path. Example: `world:data/base/config.toml` -> `config.toml`.
``lua
file.stem(path: str) --> str
```
Extracts the file name from the path, removing the extension.
Extracts the file name from the path, removing the extension. Example: `world:data/base/config.toml` -> `config`.
```lua
file.ext(path: str) --> str
```
Extracts the extension from the path. Example: `world:data/base/config.toml` -> `toml`.
```lua
file.prefix(path: str) --> str
```
Extracts the entry point (prefix) from the path. Example: `world:data/base/config.toml` -> `world`.
+13
View File
@@ -79,3 +79,16 @@ gui.confirm(
```
Requests confirmation from the user for an action. **Does not** stop code execution.
```lua
gui.load_document(
-- Path to the xml file of the page. Example: `core:layouts/pages/main.xml`
path: str,
-- Name (id) of the document. Example: `core:pages/main`
name: str
-- Table of parameters passed to the on_open event
args: table
) --> str
```
Loads a UI document with its script, returns the name of the document if successfully loaded.
+14 -2
View File
@@ -125,10 +125,22 @@ file.read_combined_object(путь: str) -> массив
file.name(путь: str) --> str
```
Извлекает имя файла из пути.
Извлекает имя файла из пути. Пример: `world:data/base/config.toml` -> `config.toml`.
```lua
file.stem(путь: str) --> str
```
Извлекает имя файла из пути, удаляя расширение.
Извлекает имя файла из пути, удаляя расширение. Пример: `world:data/base/config.toml` -> `config`.
```lua
file.ext(путь: str) --> str
```
Извлекает расширение из пути. Пример: `world:data/base/config.toml` -> `toml`.
```lua
file.prefix(путь: str) --> str
```
Извлекает точку входа (префикс) из пути. Пример: `world:data/base/config.toml` -> `world`.
+13
View File
@@ -76,3 +76,16 @@ gui.confirm(
```
Запрашивает у пользователя подтверждение действия. **Не** останавливает выполнение кода.
```lua
gui.load_document(
-- Путь к xml файлу страницы. Пример: `core:layouts/pages/main.xml`
path: str,
-- Имя (id) документа. Пример: `core:pages/main`
name: str
-- Таблица параметров, передаваемых в событие on_open
args: table
) --> str
```
Загружает UI документ с его скриптом, возвращает имя документа, если успешно загружен.