missing content report moved to xml
This commit is contained in:
parent
61ca91b525
commit
132016d33f
7
res/layouts/reports/missing_content.xml
Normal file
7
res/layouts/reports/missing_content.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<panel size='500' color='#00000080' padding='8' context='menu'>
|
||||
<label>@missing-content</label>
|
||||
<panel id='content_panel' size='480,100' color='#00000080' scrollable='true' max-length='400'>
|
||||
<!-- content is generated in script -->
|
||||
</panel>
|
||||
<button onclick='menu:back()'>@Back to Main Menu</button>
|
||||
</panel>
|
||||
5
res/layouts/reports/missing_content.xml.lua
Normal file
5
res/layouts/reports/missing_content.xml.lua
Normal file
@ -0,0 +1,5 @@
|
||||
function on_open(report)
|
||||
for i, entry in ipairs(report.content) do
|
||||
document.content_panel:add(gui.template("content_entry", entry))
|
||||
end
|
||||
end
|
||||
4
res/layouts/templates/content_entry.xml
Normal file
4
res/layouts/templates/content_entry.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<panel size='500,20' color='0' orientation='horizontal' padding='2'>
|
||||
<label color='#80808080'>[%{type}]</label>
|
||||
<label color='#FF333380'>"%{name}</label>
|
||||
</panel>
|
||||
@ -377,22 +377,28 @@ void Hud::closeInventory() {
|
||||
}
|
||||
|
||||
void Hud::add(HudElement element) {
|
||||
using dynamic::Value;
|
||||
|
||||
gui->add(element.getNode());
|
||||
auto invview = std::dynamic_pointer_cast<InventoryView>(element.getNode());
|
||||
auto document = element.getDocument();
|
||||
if (document) {
|
||||
auto inventory = invview ? invview->getInventory() : nullptr;
|
||||
std::vector<std::unique_ptr<Value>> args;
|
||||
args.push_back(Value::of(inventory ? inventory.get()->getId() : 0));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
args.push_back(Value::of(blockPos[i]));
|
||||
}
|
||||
|
||||
if (invview) {
|
||||
auto inventory = invview->getInventory();
|
||||
scripting::on_ui_open(
|
||||
element.getDocument(),
|
||||
inventory.get(),
|
||||
blockPos
|
||||
std::move(args)
|
||||
);
|
||||
} else {
|
||||
scripting::on_ui_open(
|
||||
element.getDocument(),
|
||||
nullptr,
|
||||
blockPos
|
||||
std::move(args)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
|
||||
#include "../delegates.h"
|
||||
#include "../engine.h"
|
||||
#include "../data/dynamic.h"
|
||||
#include "../interfaces/Task.h"
|
||||
#include "../files/engine_paths.h"
|
||||
#include "../graphics/ui/elements/Label.hpp"
|
||||
@ -43,11 +44,23 @@ void menus::create_menus(Engine* engine) {
|
||||
|
||||
auto document = UiDocument::read(scripting::get_root_environment(), fullname, file).release();
|
||||
engine->getAssets()->store(document, fullname);
|
||||
scripting::on_ui_open(document, nullptr, glm::ivec3());
|
||||
scripting::on_ui_open(document, {});
|
||||
return document->getRoot();
|
||||
});
|
||||
}
|
||||
|
||||
void menus::show(Engine* engine, const std::string& name, std::vector<std::unique_ptr<dynamic::Value>> args) {
|
||||
auto menu = engine->getGUI()->getMenu();
|
||||
auto file = engine->getResPaths()->find("layouts/"+name+".xml");
|
||||
auto fullname = "core:layouts/"+name;
|
||||
|
||||
auto document = UiDocument::read(scripting::get_root_environment(), fullname, file).release();
|
||||
engine->getAssets()->store(document, fullname);
|
||||
scripting::on_ui_open(document, std::move(args));
|
||||
menu->addPage(name, document->getRoot());
|
||||
menu->setPage(name);
|
||||
}
|
||||
|
||||
void menus::show_process_panel(Engine* engine, std::shared_ptr<Task> task, std::wstring text) {
|
||||
auto menu = engine->getGUI()->getMenu();
|
||||
auto panel = std::dynamic_pointer_cast<gui::Panel>(guiutil::create(
|
||||
|
||||
@ -2,15 +2,21 @@
|
||||
#define FRONTEND_MENU_MENU_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
class Task;
|
||||
class Engine;
|
||||
|
||||
namespace dynamic {
|
||||
class Value;
|
||||
}
|
||||
|
||||
namespace menus {
|
||||
/// @brief Create development version label at the top-right screen corner
|
||||
void create_version_label(Engine* engine);
|
||||
void create_menus(Engine* engine);
|
||||
void show(Engine* engine, const std::string& name, std::vector<std::unique_ptr<dynamic::Value>> args);
|
||||
void show_process_panel(Engine* engine, std::shared_ptr<Task> task, std::wstring text=L"");
|
||||
}
|
||||
|
||||
|
||||
@ -74,36 +74,18 @@ static void show_content_missing(
|
||||
const Content* content,
|
||||
std::shared_ptr<ContentLUT> lut
|
||||
) {
|
||||
auto* gui = engine->getGUI();
|
||||
auto menu = gui->getMenu();
|
||||
auto panel = std::dynamic_pointer_cast<gui::Panel>(guiutil::create(
|
||||
"<panel size='500' color='#00000080' padding='8'>"
|
||||
"<label>@menu.missing-content</label>"
|
||||
"</panel>"
|
||||
));
|
||||
auto subpanel = std::dynamic_pointer_cast<gui::Panel>(guiutil::create(
|
||||
"<panel size='480,100' color='#00000080' scrollable='true' max-length='400'>"
|
||||
"</panel>"
|
||||
));
|
||||
panel->add(subpanel);
|
||||
|
||||
using namespace dynamic;
|
||||
auto root = std::make_unique<Map>();
|
||||
auto& contentEntries = root->putList("content");
|
||||
for (auto& entry : lut->getMissingContent()) {
|
||||
std::string contentname = contenttype_name(entry.type);
|
||||
subpanel->add(guiutil::create(
|
||||
"<panel size='500,20' color='0' orientation='horizontal' padding='2'>"
|
||||
"<label color='#80808080'>["+contentname+"]</label>"
|
||||
"<label color='#FF333380'>"+entry.name+"</label>"
|
||||
"</panel>"
|
||||
));
|
||||
std::string contentName = contenttype_name(entry.type);
|
||||
auto& contentEntry = contentEntries.putMap();
|
||||
contentEntry.put("type", contentName);
|
||||
contentEntry.put("name", entry.name);
|
||||
}
|
||||
|
||||
panel->add(std::make_shared<gui::Button>(
|
||||
langs::get(L"Back to Main Menu", L"menu"), glm::vec4(8.0f), [=](auto){
|
||||
menu->back();
|
||||
}
|
||||
));
|
||||
menu->addPage("missing-content", panel);
|
||||
menu->setPage("missing-content");
|
||||
std::vector<std::unique_ptr<dynamic::Value>> args;
|
||||
args.emplace_back(std::make_unique<Value>(valtype::map, root.release()));
|
||||
menus::show(engine, "reports/missing_content", std::move(args));
|
||||
}
|
||||
|
||||
void EngineController::openWorld(std::string name, bool confirmConvert) {
|
||||
|
||||
@ -226,12 +226,17 @@ bool scripting::on_item_break_block(Player* player, const ItemDef* item, int x,
|
||||
});
|
||||
}
|
||||
|
||||
void scripting::on_ui_open(UiDocument* layout, Inventory* inventory, glm::ivec3 blockcoord) {
|
||||
void scripting::on_ui_open(
|
||||
UiDocument* layout,
|
||||
std::vector<std::unique_ptr<dynamic::Value>> args
|
||||
) {
|
||||
auto argsptr = std::make_shared<std::vector<std::unique_ptr<dynamic::Value>>>(std::move(args));
|
||||
std::string name = layout->getId() + ".open";
|
||||
emit_event(name, [inventory, blockcoord] (lua::LuaState* state) {
|
||||
state->pushinteger(inventory == nullptr ? 0 : inventory->getId());
|
||||
state->pushivec3(blockcoord.x, blockcoord.y, blockcoord.z);
|
||||
return 4;
|
||||
emit_event(name, [=] (lua::LuaState* state) {
|
||||
for (const auto& value : *argsptr) {
|
||||
state->pushvalue(*value);
|
||||
}
|
||||
return argsptr->size();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "../../data/dynamic.h"
|
||||
#include "../../typedefs.h"
|
||||
#include "../../delegates.h"
|
||||
|
||||
#include "lua/LuaState.h"
|
||||
#include "scripting_functional.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <filesystem>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class Engine;
|
||||
@ -71,7 +74,10 @@ namespace scripting {
|
||||
bool on_item_break_block(Player* player, const ItemDef* item, int x, int y, int z);
|
||||
|
||||
/// @brief Called on UI view show
|
||||
void on_ui_open(UiDocument* layout, Inventory* inventory, glm::ivec3 blockcoord);
|
||||
void on_ui_open(
|
||||
UiDocument* layout,
|
||||
std::vector<std::unique_ptr<dynamic::Value>> args
|
||||
);
|
||||
|
||||
/// @brief Called on UI view close
|
||||
void on_ui_close(UiDocument* layout, Inventory* inventory);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user