migrate from dynamic::Value to dv::value & total erase namespace 'dynamic'
This commit is contained in:
@@ -403,14 +403,12 @@ void Hud::closeInventory() {
|
||||
}
|
||||
|
||||
void Hud::add(const HudElement& element) {
|
||||
using namespace dynamic;
|
||||
|
||||
gui->add(element.getNode());
|
||||
auto document = element.getDocument();
|
||||
if (document) {
|
||||
auto invview = std::dynamic_pointer_cast<InventoryView>(element.getNode());
|
||||
auto inventory = invview ? invview->getInventory() : nullptr;
|
||||
std::vector<Value> args;
|
||||
std::vector<dv::value> args;
|
||||
args.emplace_back(inventory ? inventory.get()->getId() : 0);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
args.emplace_back(static_cast<integer_t>(blockPos[i]));
|
||||
|
||||
+9
-11
@@ -7,7 +7,7 @@
|
||||
#include "content/ContentPack.hpp"
|
||||
#include "files/files.hpp"
|
||||
#include "util/stringutil.hpp"
|
||||
#include "data/dynamic.hpp"
|
||||
#include "data/dv.hpp"
|
||||
#include "debug/Logger.hpp"
|
||||
|
||||
static debug::Logger logger("locale");
|
||||
@@ -72,23 +72,21 @@ void langs::loadLocalesInfo(const fs::path& resdir, std::string& fallback) {
|
||||
auto root = files::read_json(file);
|
||||
|
||||
langs::locales_info.clear();
|
||||
root->str("fallback", fallback);
|
||||
root.at("fallback").get(fallback);
|
||||
|
||||
auto langs = root->map("langs");
|
||||
if (langs) {
|
||||
if (auto found = root.at("langs")) {
|
||||
auto& langs = *found;
|
||||
auto logline = logger.info();
|
||||
logline << "locales ";
|
||||
for (auto& entry : langs->values) {
|
||||
auto langInfo = entry.second;
|
||||
|
||||
for (const auto& [key, langInfo] : langs.asObject()) {
|
||||
std::string name;
|
||||
if (auto mapptr = std::get_if<dynamic::Map_sptr>(&langInfo)) {
|
||||
name = (*mapptr)->get("name", "none"s);
|
||||
if (langInfo.isObject()) {
|
||||
name = langInfo["name"].asString("none");
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
logline << "[" << entry.first << " (" << name << ")] ";
|
||||
langs::locales_info[entry.first] = LocaleInfo {entry.first, name};
|
||||
logline << "[" << key << " (" << name << ")] ";
|
||||
langs::locales_info[key] = LocaleInfo {key, name};
|
||||
}
|
||||
logline << "added";
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "delegates.hpp"
|
||||
#include "engine.hpp"
|
||||
#include "data/dynamic.hpp"
|
||||
#include "data/dv.hpp"
|
||||
#include "interfaces/Task.hpp"
|
||||
#include "files/engine_paths.hpp"
|
||||
#include "graphics/ui/elements/Menu.hpp"
|
||||
@@ -36,9 +36,7 @@ void menus::create_version_label(Engine* engine) {
|
||||
|
||||
gui::page_loader_func menus::create_page_loader(Engine* engine) {
|
||||
return [=](const std::string& query) {
|
||||
using namespace dynamic;
|
||||
|
||||
std::vector<Value> args;
|
||||
std::vector<dv::value> args;
|
||||
|
||||
std::string name;
|
||||
size_t index = query.find('?');
|
||||
@@ -46,14 +44,14 @@ gui::page_loader_func menus::create_page_loader(Engine* engine) {
|
||||
auto argstr = query.substr(index+1);
|
||||
name = query.substr(0, index);
|
||||
|
||||
auto map = create_map();
|
||||
auto map = dv::object();
|
||||
auto filename = "query for "+name;
|
||||
BasicParser parser(filename, argstr);
|
||||
while (parser.hasNext()) {
|
||||
auto key = std::string(parser.readUntil('='));
|
||||
parser.nextChar();
|
||||
auto value = std::string(parser.readUntil('&'));
|
||||
map->put(key, value);
|
||||
map[key] = value;
|
||||
}
|
||||
args.emplace_back(map);
|
||||
} else {
|
||||
@@ -106,7 +104,7 @@ bool menus::call(Engine* engine, runnable func) {
|
||||
}
|
||||
}
|
||||
|
||||
UiDocument* menus::show(Engine* engine, const std::string& name, std::vector<dynamic::Value> args) {
|
||||
UiDocument* menus::show(Engine* engine, const std::string& name, std::vector<dv::value> args) {
|
||||
auto menu = engine->getGUI()->getMenu();
|
||||
auto file = engine->getResPaths()->find("layouts/"+name+".xml");
|
||||
auto fullname = "core:layouts/"+name;
|
||||
@@ -123,8 +121,6 @@ UiDocument* menus::show(Engine* engine, const std::string& name, std::vector<dyn
|
||||
}
|
||||
|
||||
void menus::show_process_panel(Engine* engine, const std::shared_ptr<Task>& task, const std::wstring& text) {
|
||||
using namespace dynamic;
|
||||
|
||||
uint initialWork = task->getWorkTotal();
|
||||
|
||||
auto menu = engine->getGUI()->getMenu();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "data/dynamic.hpp"
|
||||
#include "data/dv.hpp"
|
||||
#include "graphics/ui/elements/Menu.hpp"
|
||||
|
||||
#include <string>
|
||||
@@ -21,7 +21,7 @@ namespace menus {
|
||||
UiDocument* show(
|
||||
Engine* engine,
|
||||
const std::string& name,
|
||||
std::vector<dynamic::Value> args
|
||||
std::vector<dv::value> args
|
||||
);
|
||||
|
||||
void show_process_panel(Engine* engine, const std::shared_ptr<Task>& task, const std::wstring& text=L"");
|
||||
|
||||
Reference in New Issue
Block a user