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) {
|
void Hud::add(HudElement element) {
|
||||||
|
using dynamic::Value;
|
||||||
|
|
||||||
gui->add(element.getNode());
|
gui->add(element.getNode());
|
||||||
auto invview = std::dynamic_pointer_cast<InventoryView>(element.getNode());
|
auto invview = std::dynamic_pointer_cast<InventoryView>(element.getNode());
|
||||||
auto document = element.getDocument();
|
auto document = element.getDocument();
|
||||||
if (document) {
|
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) {
|
if (invview) {
|
||||||
auto inventory = invview->getInventory();
|
|
||||||
scripting::on_ui_open(
|
scripting::on_ui_open(
|
||||||
element.getDocument(),
|
element.getDocument(),
|
||||||
inventory.get(),
|
std::move(args)
|
||||||
blockPos
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
scripting::on_ui_open(
|
scripting::on_ui_open(
|
||||||
element.getDocument(),
|
element.getDocument(),
|
||||||
nullptr,
|
std::move(args)
|
||||||
blockPos
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "../delegates.h"
|
#include "../delegates.h"
|
||||||
#include "../engine.h"
|
#include "../engine.h"
|
||||||
|
#include "../data/dynamic.h"
|
||||||
#include "../interfaces/Task.h"
|
#include "../interfaces/Task.h"
|
||||||
#include "../files/engine_paths.h"
|
#include "../files/engine_paths.h"
|
||||||
#include "../graphics/ui/elements/Label.hpp"
|
#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();
|
auto document = UiDocument::read(scripting::get_root_environment(), fullname, file).release();
|
||||||
engine->getAssets()->store(document, fullname);
|
engine->getAssets()->store(document, fullname);
|
||||||
scripting::on_ui_open(document, nullptr, glm::ivec3());
|
scripting::on_ui_open(document, {});
|
||||||
return document->getRoot();
|
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) {
|
void menus::show_process_panel(Engine* engine, std::shared_ptr<Task> task, std::wstring text) {
|
||||||
auto menu = engine->getGUI()->getMenu();
|
auto menu = engine->getGUI()->getMenu();
|
||||||
auto panel = std::dynamic_pointer_cast<gui::Panel>(guiutil::create(
|
auto panel = std::dynamic_pointer_cast<gui::Panel>(guiutil::create(
|
||||||
|
|||||||
@ -2,15 +2,21 @@
|
|||||||
#define FRONTEND_MENU_MENU_HPP_
|
#define FRONTEND_MENU_MENU_HPP_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class Task;
|
class Task;
|
||||||
class Engine;
|
class Engine;
|
||||||
|
|
||||||
|
namespace dynamic {
|
||||||
|
class Value;
|
||||||
|
}
|
||||||
|
|
||||||
namespace menus {
|
namespace menus {
|
||||||
/// @brief Create development version label at the top-right screen corner
|
/// @brief Create development version label at the top-right screen corner
|
||||||
void create_version_label(Engine* engine);
|
void create_version_label(Engine* engine);
|
||||||
void create_menus(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"");
|
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,
|
const Content* content,
|
||||||
std::shared_ptr<ContentLUT> lut
|
std::shared_ptr<ContentLUT> lut
|
||||||
) {
|
) {
|
||||||
auto* gui = engine->getGUI();
|
using namespace dynamic;
|
||||||
auto menu = gui->getMenu();
|
auto root = std::make_unique<Map>();
|
||||||
auto panel = std::dynamic_pointer_cast<gui::Panel>(guiutil::create(
|
auto& contentEntries = root->putList("content");
|
||||||
"<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);
|
|
||||||
|
|
||||||
for (auto& entry : lut->getMissingContent()) {
|
for (auto& entry : lut->getMissingContent()) {
|
||||||
std::string contentname = contenttype_name(entry.type);
|
std::string contentName = contenttype_name(entry.type);
|
||||||
subpanel->add(guiutil::create(
|
auto& contentEntry = contentEntries.putMap();
|
||||||
"<panel size='500,20' color='0' orientation='horizontal' padding='2'>"
|
contentEntry.put("type", contentName);
|
||||||
"<label color='#80808080'>["+contentname+"]</label>"
|
contentEntry.put("name", entry.name);
|
||||||
"<label color='#FF333380'>"+entry.name+"</label>"
|
|
||||||
"</panel>"
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
std::vector<std::unique_ptr<dynamic::Value>> args;
|
||||||
panel->add(std::make_shared<gui::Button>(
|
args.emplace_back(std::make_unique<Value>(valtype::map, root.release()));
|
||||||
langs::get(L"Back to Main Menu", L"menu"), glm::vec4(8.0f), [=](auto){
|
menus::show(engine, "reports/missing_content", std::move(args));
|
||||||
menu->back();
|
|
||||||
}
|
|
||||||
));
|
|
||||||
menu->addPage("missing-content", panel);
|
|
||||||
menu->setPage("missing-content");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EngineController::openWorld(std::string name, bool confirmConvert) {
|
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";
|
std::string name = layout->getId() + ".open";
|
||||||
emit_event(name, [inventory, blockcoord] (lua::LuaState* state) {
|
emit_event(name, [=] (lua::LuaState* state) {
|
||||||
state->pushinteger(inventory == nullptr ? 0 : inventory->getId());
|
for (const auto& value : *argsptr) {
|
||||||
state->pushivec3(blockcoord.x, blockcoord.y, blockcoord.z);
|
state->pushvalue(*value);
|
||||||
return 4;
|
}
|
||||||
|
return argsptr->size();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
#include <string>
|
#include "../../data/dynamic.h"
|
||||||
#include <filesystem>
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
|
|
||||||
#include "../../typedefs.h"
|
#include "../../typedefs.h"
|
||||||
#include "../../delegates.h"
|
#include "../../delegates.h"
|
||||||
|
|
||||||
#include "lua/LuaState.h"
|
#include "lua/LuaState.h"
|
||||||
#include "scripting_functional.h"
|
#include "scripting_functional.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
@ -71,7 +74,10 @@ namespace scripting {
|
|||||||
bool on_item_break_block(Player* player, const ItemDef* item, int x, int y, int z);
|
bool on_item_break_block(Player* player, const ItemDef* item, int x, int y, int z);
|
||||||
|
|
||||||
/// @brief Called on UI view show
|
/// @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
|
/// @brief Called on UI view close
|
||||||
void on_ui_close(UiDocument* layout, Inventory* inventory);
|
void on_ui_close(UiDocument* layout, Inventory* inventory);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user