dynamic::Value simplified
This commit is contained in:
@@ -387,10 +387,10 @@ void Hud::add(HudElement element) {
|
||||
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));
|
||||
std::vector<Value> args;
|
||||
args.push_back(inventory ? inventory.get()->getId() : 0);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
args.push_back(value_of(static_cast<integer_t>(blockPos[i])));
|
||||
args.push_back(static_cast<integer_t>(blockPos[i]));
|
||||
}
|
||||
scripting::on_ui_open(
|
||||
element.getDocument(),
|
||||
|
||||
@@ -76,10 +76,10 @@ void langs::loadLocalesInfo(const fs::path& resdir, std::string& fallback) {
|
||||
if (langs) {
|
||||
std::cout << "locales ";
|
||||
for (auto& entry : langs->values) {
|
||||
auto langInfo = entry.second.get();
|
||||
auto langInfo = entry.second;
|
||||
|
||||
std::string name;
|
||||
if (auto mapptr = std::get_if<dynamic::Map*>(&langInfo->value)) {
|
||||
if (auto mapptr = std::get_if<dynamic::Map_sptr>(&langInfo)) {
|
||||
name = (*mapptr)->get("name", "none"s);
|
||||
} else {
|
||||
continue;
|
||||
|
||||
@@ -37,7 +37,7 @@ gui::page_loader_func menus::create_page_loader(Engine* engine) {
|
||||
return [=](const std::string& query) {
|
||||
using namespace dynamic;
|
||||
|
||||
std::vector<std::unique_ptr<Value>> args;
|
||||
std::vector<Value> args;
|
||||
|
||||
std::string name;
|
||||
size_t index = query.find('?');
|
||||
@@ -45,7 +45,7 @@ gui::page_loader_func menus::create_page_loader(Engine* engine) {
|
||||
auto argstr = query.substr(index+1);
|
||||
name = query.substr(0, index);
|
||||
|
||||
auto map = std::make_unique<Map>();
|
||||
auto map = std::make_shared<Map>();
|
||||
BasicParser parser("query for "+name, argstr);
|
||||
while (parser.hasNext()) {
|
||||
auto key = parser.readUntil('=');
|
||||
@@ -53,7 +53,7 @@ gui::page_loader_func menus::create_page_loader(Engine* engine) {
|
||||
auto value = parser.readUntil('&');
|
||||
map->put(key, value);
|
||||
}
|
||||
args.push_back(value_of(std::move(map)));
|
||||
args.push_back(map);
|
||||
} else {
|
||||
name = query;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ gui::page_loader_func menus::create_page_loader(Engine* engine) {
|
||||
};
|
||||
}
|
||||
|
||||
UiDocument* menus::show(Engine* engine, const std::string& name, std::vector<std::unique_ptr<dynamic::Value>> args) {
|
||||
UiDocument* menus::show(Engine* engine, const std::string& name, std::vector<dynamic::Value> args) {
|
||||
auto menu = engine->getGUI()->getMenu();
|
||||
auto file = engine->getResPaths()->find("layouts/"+name+".xml");
|
||||
auto fullname = "core:layouts/"+name;
|
||||
@@ -89,9 +89,9 @@ void menus::show_process_panel(Engine* engine, std::shared_ptr<Task> task, std::
|
||||
|
||||
auto menu = engine->getGUI()->getMenu();
|
||||
menu->reset();
|
||||
std::vector<std::unique_ptr<Value>> args;
|
||||
args.emplace_back(value_of(util::wstr2str_utf8(langs::get(text))));
|
||||
auto doc = menus::show(engine, "process", std::move(args));
|
||||
auto doc = menus::show(engine, "process", {
|
||||
util::wstr2str_utf8(langs::get(text))
|
||||
});
|
||||
std::dynamic_pointer_cast<Container>(doc->getRoot())->listenInterval(0.01f, [=]() {
|
||||
task->update();
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef FRONTEND_MENU_MENU_HPP_
|
||||
#define FRONTEND_MENU_MENU_HPP_
|
||||
|
||||
#include "../data/dynamic.hpp"
|
||||
#include "../graphics/ui/elements/Menu.hpp"
|
||||
|
||||
#include <string>
|
||||
@@ -12,10 +13,6 @@ class Engine;
|
||||
|
||||
class UiDocument;
|
||||
|
||||
namespace dynamic {
|
||||
class Value;
|
||||
}
|
||||
|
||||
namespace menus {
|
||||
/// @brief Create development version label at the top-right screen corner
|
||||
void create_version_label(Engine* engine);
|
||||
@@ -25,7 +22,7 @@ namespace menus {
|
||||
UiDocument* show(
|
||||
Engine* engine,
|
||||
const std::string& name,
|
||||
std::vector<std::unique_ptr<dynamic::Value>> args
|
||||
std::vector<dynamic::Value> args
|
||||
);
|
||||
|
||||
void show_process_panel(Engine* engine, std::shared_ptr<Task> task, std::wstring text=L"");
|
||||
|
||||
Reference in New Issue
Block a user