content packs icons fix
This commit is contained in:
parent
01f41715d7
commit
bedcc438f4
@ -8,7 +8,6 @@ function add_pack(packid, packinfo)
|
||||
end
|
||||
packinfo.id = packid
|
||||
packinfo.remover = remover
|
||||
packinfo.icon = "gui/no_icon"
|
||||
document.packs_panel:add(gui.template("pack", packinfo))
|
||||
end
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
</textbox>
|
||||
<label>@Seed</label>
|
||||
<textbox id='seed_box' placeholder='-' padding='4'></textbox>
|
||||
<button onclick='menu.page="world_generators"' id='generator_btn' padding='10'>
|
||||
<button onclick='menu.page="generators"' id='generator_btn' padding='10'>
|
||||
@World generator
|
||||
</button>
|
||||
<button onclick='create_world()' padding='10' margin='1,20,1,1'>
|
||||
|
||||
@ -2,10 +2,12 @@
|
||||
#include "lua_commons.h"
|
||||
#include "../scripting.h"
|
||||
#include "../../../engine.h"
|
||||
#include "../../../coders/imageio.h"
|
||||
#include "../../../files/engine_paths.h"
|
||||
#include "../../../files/WorldFiles.h"
|
||||
#include "../../../world/Level.h"
|
||||
#include "../../../world/World.h"
|
||||
#include "../../../graphics/core/Texture.h"
|
||||
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
@ -73,6 +75,21 @@ static int l_pack_get_info(lua_State* L, const ContentPack& pack, const Content*
|
||||
lua_pushstring(L, pack.version.c_str());
|
||||
lua_setfield(L, -2, "version");
|
||||
|
||||
// hmm
|
||||
auto assets = scripting::engine->getAssets();
|
||||
std::string icon = pack.id+".icon";
|
||||
if (assets->getTexture(icon) == nullptr) {
|
||||
auto iconfile = pack.folder/fs::path("icon.png");
|
||||
if (fs::is_regular_file(iconfile)) {
|
||||
auto image = imageio::read(iconfile.string());
|
||||
assets->store(Texture::from(image.get()), icon);
|
||||
} else {
|
||||
icon = "gui/no_icon";
|
||||
}
|
||||
}
|
||||
lua_pushstring(L, icon.c_str());
|
||||
lua_setfield(L, -2, "icon");
|
||||
|
||||
auto runtime = content ? content->getPackRuntime(pack.id) : nullptr;
|
||||
if (runtime) {
|
||||
lua_pushboolean(L, runtime->getStats().hasSavingContent());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user