update pack.get_info

This commit is contained in:
MihailRis 2025-01-02 11:45:28 +03:00
parent e976b2078e
commit e2f6c263e7
3 changed files with 8 additions and 15 deletions

View File

@ -76,14 +76,14 @@ pack.get_base_packs() -> strings array
Returns the id of all base packages (non-removeable) Returns the id of all base packages (non-removeable)
```python ```lua
pack.get_info(packid: str) -> { pack.get_info(packid: str) -> {
id: str, id: str,
title: str, title: str,
creator: str, creator: str,
description: str, description: str,
version: str, version: str,
icon: str, icon: str, -- not available in headless mode
dependencies: optional strings array dependencies: optional strings array
} }
``` ```

View File

@ -70,7 +70,7 @@ pack.get_info(packid: str) -> {
creator: str, creator: str,
description: str, description: str,
version: str, version: str,
icon: str, icon: str, -- отсутствует в headless режиме
dependencies: опциональный массив строк dependencies: опциональный массив строк
} }
``` ```

View File

@ -81,24 +81,17 @@ static int l_pack_get_info(
lua::pushstring(L, pack.version); lua::pushstring(L, pack.version);
lua::setfield(L, "version"); lua::setfield(L, "version");
if (!engine->isHeadless()) {
auto assets = engine->getAssets(); auto assets = engine->getAssets();
std::string icon = pack.id + ".icon"; std::string icon = pack.id + ".icon";
if (engine->isHeadless()) {
if (fs::exists(pack.folder / fs::path("icon.png"))) {
icon = pack.folder.u8string() + "/icon.png";
} else {
icon = "gui/no_icon";
}
} else {
if (!AssetsLoader::loadExternalTexture( if (!AssetsLoader::loadExternalTexture(
assets, icon, {pack.folder / fs::path("icon.png")} assets, icon, {pack.folder / fs::path("icon.png")}
)) { )) {
icon = "gui/no_icon"; icon = "gui/no_icon";
} }
}
lua::pushstring(L, icon); lua::pushstring(L, icon);
lua::setfield(L, "icon"); lua::setfield(L, "icon");
}
if (!pack.dependencies.empty()) { if (!pack.dependencies.empty()) {
lua::createtable(L, pack.dependencies.size(), 0); lua::createtable(L, pack.dependencies.size(), 0);