content panel xml (WIP)
This commit is contained in:
parent
fbc2cc5ce9
commit
1b5a1a5ae6
6
res/layouts/pages/content.xml
Normal file
6
res/layouts/pages/content.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<panel size='550' color='0' padding='8' interval='5'>
|
||||
<panel id='packs_panel' size='540,10' color='0,0,0,50' max-length='400'>
|
||||
<!-- content is generated in script -->
|
||||
</panel>
|
||||
<button onclick='menu:back()' padding='10'>@Back</button>
|
||||
</panel>
|
||||
17
res/layouts/pages/content.xml.lua
Normal file
17
res/layouts/pages/content.xml.lua
Normal file
@ -0,0 +1,17 @@
|
||||
function add_pack(packid, packinfo)
|
||||
document.packs_panel:add(gui.template("pack", {
|
||||
id=packid,
|
||||
title=packinfo.title,
|
||||
description=packinfo.description,
|
||||
icon="gui/no_icon",
|
||||
creator=packinfo.creator,
|
||||
remover='0'
|
||||
}))
|
||||
end
|
||||
|
||||
function on_open()
|
||||
local packs = pack.get_installed()
|
||||
for i,id in ipairs(packs) do
|
||||
add_pack(id, pack.get_info(id))
|
||||
end
|
||||
end
|
||||
@ -1,15 +1,18 @@
|
||||
<container onclick='%{callback}' size='540,80' color='#0F1E2DB2'>
|
||||
<label pos='215,2' color='#FFFFFF80' size='300,25' align='right'>
|
||||
<label color='#FFFFFF80' size='300,25' align='right' gravity='top-right'>
|
||||
[%{id}]
|
||||
</label>
|
||||
<label pos='78,6'>%{title}</label>
|
||||
<label if='%{creator}' color='#CCFFE5B2' size='300,20' align='right' pos='215,60'>
|
||||
<label if='%{creator}' color='#CCFFE5B2' size='300,20' align='right'
|
||||
gravity='bottom-right'>
|
||||
%{creator}
|
||||
</label>
|
||||
<label pos='80,28' color='#FFFFFFB2'>
|
||||
%{description}
|
||||
</label>
|
||||
<button if='%{remover}' onclick='%{remover}' color='0' hover-color='#FFFFFF2B'>
|
||||
<button if='%{remover}' onclick='%{remover}' color='0' hover-color='#FFFFFF2B'
|
||||
gravity='center-right' margin='10'>
|
||||
<image src='gui/cross' size='32,32'/>
|
||||
</button>
|
||||
<image pos='8,8' src='%{icon}' size='64'></image>
|
||||
</container>
|
||||
|
||||
@ -239,6 +239,7 @@ void menus::create_menus(Engine* engine) {
|
||||
create_world_generators_panel(engine);
|
||||
add_page_loader(engine, "main");
|
||||
add_page_loader(engine, "404");
|
||||
add_page_loader(engine, "content");
|
||||
}
|
||||
|
||||
void menus::refresh_menus(Engine* engine) {
|
||||
|
||||
@ -27,8 +27,7 @@ std::shared_ptr<Container> create_pack_panel(
|
||||
) {
|
||||
auto assets = engine->getAssets();
|
||||
auto packpanel = std::dynamic_pointer_cast<Container>(guiutil::create(
|
||||
"<container size='540,80' color='#0F1E2DB2'>"
|
||||
"</container>"
|
||||
"<container size='540,80' color='#0F1E2DB2'></container>"
|
||||
));
|
||||
if (callback) {
|
||||
packpanel->listenAction([=](GUI*) {
|
||||
@ -41,25 +40,14 @@ std::shared_ptr<Container> create_pack_panel(
|
||||
: "["+pack.id+"]";
|
||||
|
||||
packpanel->add(guiutil::create(
|
||||
"<label pos='215,2' color='#FFFFFF80' size='300,25' align='right'>" +
|
||||
idtext +
|
||||
"<label pos='215,2' color='#FFFFFF80' size='300,25' align='right'>"
|
||||
+idtext+
|
||||
"</label>"
|
||||
));
|
||||
packpanel->add(guiutil::create(
|
||||
"<label pos='78,6'>"+pack.title+"</label>"
|
||||
));
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
if (!pack.creator.empty()) {
|
||||
packpanel->add(guiutil::create(
|
||||
"<label color='#CCFFE5B2' size='300,20' align='right' pos='215,60'>"
|
||||
@ -74,6 +62,16 @@ std::shared_ptr<Container> create_pack_panel(
|
||||
"</label>"
|
||||
));
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
packpanel->add(std::make_shared<Image>(icon, glm::vec2(64)), glm::vec2(8));
|
||||
|
||||
if (remover && pack.id != "base") {
|
||||
@ -238,7 +236,7 @@ void menus::create_pause_panel(Engine* engine, LevelController* controller) {
|
||||
menu->reset();
|
||||
}));
|
||||
panel->add(create_button(L"Content", glm::vec4(10.0f), glm::vec4(1), [=](GUI*) {
|
||||
create_content_panel(engine, controller);
|
||||
//create_content_panel(engine, controller);
|
||||
menu->setPage("content");
|
||||
}));
|
||||
panel->add(guiutil::gotoButton(L"Settings", "settings", menu));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user