diff --git a/plugins/builtin/source/content/command_palette_commands.cpp b/plugins/builtin/source/content/command_palette_commands.cpp index 4ca04fba8..bb264cc8c 100644 --- a/plugins/builtin/source/content/command_palette_commands.cpp +++ b/plugins/builtin/source/content/command_palette_commands.cpp @@ -8,7 +8,7 @@ namespace hex::plugin::builtin { hex::ContentRegistry::CommandPaletteCommands::add( hex::ContentRegistry::CommandPaletteCommands::Type::SymbolCommand, - "#", "hex.builtin.command.calc.desc"_lang, + "#", "hex.builtin.command.calc.desc", [](auto input) { hex::MathEvaluator evaluator; evaluator.registerStandardVariables(); @@ -29,7 +29,7 @@ namespace hex::plugin::builtin { hex::ContentRegistry::CommandPaletteCommands::add( hex::ContentRegistry::CommandPaletteCommands::Type::KeywordCommand, - "/web", "hex.builtin.command.web.desc"_lang, + "/web", "hex.builtin.command.web.desc", [](auto input) { return hex::format("hex.builtin.command.web.result"_lang, input.data()); }, diff --git a/plugins/builtin/source/content/data_inspector.cpp b/plugins/builtin/source/content/data_inspector.cpp index 03bc1789c..69555f835 100644 --- a/plugins/builtin/source/content/data_inspector.cpp +++ b/plugins/builtin/source/content/data_inspector.cpp @@ -20,7 +20,7 @@ namespace hex::plugin::builtin { using Style = hex::ContentRegistry::DataInspector::NumberDisplayStyle; - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.binary"_lang, sizeof(u8), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.binary", sizeof(u8), [](auto buffer, auto endian, auto style) { std::string binary; for (u8 i = 0; i < 8; i++) binary += ((buffer[0] << i) & 0x80) == 0 ? '0' : '1'; @@ -28,76 +28,76 @@ namespace hex::plugin::builtin { return [binary] { ImGui::TextUnformatted(binary.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u8"_lang, sizeof(u8), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u8", sizeof(u8), [](auto buffer, auto endian, auto style) { auto format = (style == Style::Decimal) ? "%u" : ((style == Style::Hexadecimal) ? "0x%X" : "0o%o"); auto value = hex::format(format, *reinterpret_cast(buffer.data())); return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s8"_lang, sizeof(s8), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s8", sizeof(s8), [](auto buffer, auto endian, auto style) { auto format = (style == Style::Decimal) ? "%d" : ((style == Style::Hexadecimal) ? "0x%X" : "0o%o"); auto value = hex::format(format, *reinterpret_cast(buffer.data())); return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u16"_lang, sizeof(u16), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u16", sizeof(u16), [](auto buffer, auto endian, auto style) { auto format = (style == Style::Decimal) ? "%u" : ((style == Style::Hexadecimal) ? "0x%X" : "0o%o"); auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast(buffer.data()), endian)); return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s16"_lang, sizeof(s16), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s16", sizeof(s16), [](auto buffer, auto endian, auto style) { auto format = (style == Style::Decimal) ? "%d" : ((style == Style::Hexadecimal) ? "0x%X" : "0o%o"); auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast(buffer.data()), endian)); return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u32"_lang, sizeof(u32), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u32", sizeof(u32), [](auto buffer, auto endian, auto style) { auto format = (style == Style::Decimal) ? "%u" : ((style == Style::Hexadecimal) ? "0x%X" : "0o%o"); auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast(buffer.data()), endian)); return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s32"_lang, sizeof(s32), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s32", sizeof(s32), [](auto buffer, auto endian, auto style) { auto format = (style == Style::Decimal) ? "%d" : ((style == Style::Hexadecimal) ? "0x%X" : "0o%o"); auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast(buffer.data()), endian)); return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u64"_lang, sizeof(u64), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.u64", sizeof(u64), [](auto buffer, auto endian, auto style) { auto format = (style == Style::Decimal) ? "%llu" : ((style == Style::Hexadecimal) ? "0x%llX" : "0o%llo"); auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast(buffer.data()), endian)); return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s64"_lang, sizeof(s64), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.s64", sizeof(s64), [](auto buffer, auto endian, auto style) { auto format = (style == Style::Decimal) ? "%lld" : ((style == Style::Hexadecimal) ? "0x%llX" : "0o%llo"); auto value = hex::format(format, hex::changeEndianess(*reinterpret_cast(buffer.data()), endian)); return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.float"_lang, sizeof(float), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.float", sizeof(float), [](auto buffer, auto endian, auto style) { auto value = hex::format("%e", hex::changeEndianess(*reinterpret_cast(buffer.data()), endian)); return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.double"_lang, sizeof(double), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.double", sizeof(double), [](auto buffer, auto endian, auto style) { auto value = hex::format("%e", hex::changeEndianess(*reinterpret_cast(buffer.data()), endian)); return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.ascii"_lang, sizeof(char8_t), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.ascii", sizeof(char8_t), [](auto buffer, auto endian, auto style) { auto value = hex::format("'%s'", makePrintable(*reinterpret_cast(buffer.data())).c_str()); return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.wide"_lang, sizeof(char16_t), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.wide", sizeof(char16_t), [](auto buffer, auto endian, auto style) { auto c = *reinterpret_cast(buffer.data()); auto value = hex::format("'%lc'", c == 0 ? '\x01' : hex::changeEndianess(c, endian)); return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.utf8"_lang, sizeof(char8_t) * 4, [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.utf8", sizeof(char8_t) * 4, [](auto buffer, auto endian, auto style) { char utf8Buffer[5] = { 0 }; char codepointString[5] = { 0 }; u32 codepoint = 0; @@ -116,7 +116,7 @@ namespace hex::plugin::builtin { #if defined(OS_WINDOWS) && defined(ARCH_64_BIT) - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time32"_lang, sizeof(__time32_t), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time32", sizeof(__time32_t), [](auto buffer, auto endian, auto style) { auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<__time32_t*>(buffer.data()), endian); std::tm * ptm = _localtime32(&endianAdjustedTime); char timeBuffer[32]; @@ -129,7 +129,7 @@ namespace hex::plugin::builtin { return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time64"_lang, sizeof(__time64_t), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time64", sizeof(__time64_t), [](auto buffer, auto endian, auto style) { auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast<__time64_t*>(buffer.data()), endian); std::tm * ptm = _localtime64(&endianAdjustedTime); char timeBuffer[64]; @@ -144,7 +144,7 @@ namespace hex::plugin::builtin { #else - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time"_lang, sizeof(time_t), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.time", sizeof(time_t), [](auto buffer, auto endian, auto style) { auto endianAdjustedTime = hex::changeEndianess(*reinterpret_cast(buffer.data()), endian); std::tm * ptm = localtime(&endianAdjustedTime); char timeBuffer[64]; @@ -159,7 +159,7 @@ namespace hex::plugin::builtin { #endif - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.guid"_lang, sizeof(GUID), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.guid", sizeof(GUID), [](auto buffer, auto endian, auto style) { GUID guid; std::memcpy(&guid, buffer.data(), sizeof(GUID)); auto value = hex::format("%s{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}", @@ -173,7 +173,7 @@ namespace hex::plugin::builtin { return [value] { ImGui::TextUnformatted(value.c_str()); }; }); - hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.rgba8"_lang, sizeof(u32), [](auto buffer, auto endian, auto style) { + hex::ContentRegistry::DataInspector::add("hex.builtin.inspector.rgba8", sizeof(u32), [](auto buffer, auto endian, auto style) { ImColor value(hex::changeEndianess(*reinterpret_cast(buffer.data()), endian)); return [value] { diff --git a/plugins/builtin/source/content/data_processor_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes.cpp index 0d86d5d91..de9e4732f 100644 --- a/plugins/builtin/source/content/data_processor_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes.cpp @@ -8,8 +8,8 @@ namespace hex::plugin::builtin { class NodeNullptr : public dp::Node { public: - NodeNullptr() : Node("hex.builtin.nodes.constants.nullptr.header"_lang, { - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.constants.nullptr.output"_lang) + NodeNullptr() : Node("hex.builtin.nodes.constants.nullptr.header", { + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.constants.nullptr.output") }) {} void process() override { @@ -19,8 +19,8 @@ namespace hex::plugin::builtin { class NodeBuffer : public dp::Node { public: - NodeBuffer() : Node("hex.builtin.nodes.constants.buffer.header"_lang, { - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.constants.buffer.output"_lang) + NodeBuffer() : Node("hex.builtin.nodes.constants.buffer.header", { + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.constants.buffer.output") }) {} void drawNode() override { @@ -45,8 +45,8 @@ namespace hex::plugin::builtin { class NodeString : public dp::Node { public: - NodeString() : Node("hex.builtin.nodes.constants.string.header"_lang, { - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.constants.string.output"_lang) + NodeString() : Node("hex.builtin.nodes.constants.string.header", { + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.constants.string.output") }) { this->m_value.resize(0xFFF, 0x00); } @@ -72,8 +72,8 @@ namespace hex::plugin::builtin { class NodeInteger : public dp::Node { public: - NodeInteger() : Node("hex.builtin.nodes.constants.int.header"_lang, { - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.int.output"_lang) + NodeInteger() : Node("hex.builtin.nodes.constants.int.header", { + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.int.output") }) {} void drawNode() override { @@ -96,8 +96,8 @@ namespace hex::plugin::builtin { class NodeFloat : public dp::Node { public: - NodeFloat() : Node("hex.builtin.nodes.constants.float.header"_lang, { - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Float, "hex.builtin.nodes.constants.float.output"_lang) + NodeFloat() : Node("hex.builtin.nodes.constants.float.header", { + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Float, "hex.builtin.nodes.constants.float.output") }) {} void drawNode() override { @@ -120,11 +120,11 @@ namespace hex::plugin::builtin { class NodeRGBA8 : public dp::Node { public: - NodeRGBA8() : Node("hex.builtin.nodes.constants.rgba8.header"_lang, - { dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.r"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.g"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.b"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.a"_lang)}) {} + NodeRGBA8() : Node("hex.builtin.nodes.constants.rgba8.header", + { dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.r"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.g"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.constants.rgba8.output.a")}) {} void drawNode() override { ImGui::PushItemWidth(200); @@ -146,7 +146,7 @@ namespace hex::plugin::builtin { class NodeComment : public dp::Node { public: - NodeComment() : Node("hex.builtin.nodes.constants.comment.header"_lang, { }) { + NodeComment() : Node("hex.builtin.nodes.constants.comment.header", { }) { this->m_comment.resize(0xFFF, 0x00); } @@ -165,8 +165,8 @@ namespace hex::plugin::builtin { class NodeDisplayInteger : public dp::Node { public: - NodeDisplayInteger() : Node("hex.builtin.nodes.display.int.header"_lang, { - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.display.int.input"_lang) + NodeDisplayInteger() : Node("hex.builtin.nodes.display.int.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.display.int.input") }) {} void drawNode() override { @@ -191,8 +191,8 @@ namespace hex::plugin::builtin { class NodeDisplayFloat : public dp::Node { public: - NodeDisplayFloat() : Node("hex.builtin.nodes.display.float.header"_lang, { - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Float, "hex.builtin.nodes.display.float.input"_lang) + NodeDisplayFloat() : Node("hex.builtin.nodes.display.float.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Float, "hex.builtin.nodes.display.float.input") }) {} void drawNode() override { @@ -218,9 +218,9 @@ namespace hex::plugin::builtin { class NodeBitwiseNOT : public dp::Node { public: - NodeBitwiseNOT() : Node("hex.builtin.nodes.bitwise.not.header"_lang, { - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.not.input"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.not.output"_lang) }) {} + NodeBitwiseNOT() : Node("hex.builtin.nodes.bitwise.not.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.not.input"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.not.output") }) {} void process() override { auto input = this->getBufferOnInput(0); @@ -235,10 +235,10 @@ namespace hex::plugin::builtin { class NodeBitwiseAND : public dp::Node { public: - NodeBitwiseAND() : Node("hex.builtin.nodes.bitwise.and.header"_lang, { - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.and.input.a"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.and.input.b"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.and.output"_lang) }) {} + NodeBitwiseAND() : Node("hex.builtin.nodes.bitwise.and.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.and.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.and.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.and.output") }) {} void process() override { auto inputA = this->getBufferOnInput(0); @@ -255,10 +255,10 @@ namespace hex::plugin::builtin { class NodeBitwiseOR : public dp::Node { public: - NodeBitwiseOR() : Node("hex.builtin.nodes.bitwise.or.header"_lang, { - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.or.input.a"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.or.input.b"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.or.output"_lang) }) {} + NodeBitwiseOR() : Node("hex.builtin.nodes.bitwise.or.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.or.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.or.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.or.output") }) {} void process() override { auto inputA = this->getBufferOnInput(0); @@ -275,10 +275,10 @@ namespace hex::plugin::builtin { class NodeBitwiseXOR : public dp::Node { public: - NodeBitwiseXOR() : Node("hex.builtin.nodes.bitwise.xor.header"_lang, { - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.xor.input.a"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.xor.input.b"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.xor.output"_lang) }) {} + NodeBitwiseXOR() : Node("hex.builtin.nodes.bitwise.xor.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.xor.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.xor.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.bitwise.xor.output") }) {} void process() override { auto inputA = this->getBufferOnInput(0); @@ -295,10 +295,10 @@ namespace hex::plugin::builtin { class NodeReadData : public dp::Node { public: - NodeReadData() : Node("hex.builtin.nodes.data_access.read.header"_lang, { - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.data_access.read.address"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.data_access.read.size"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.data_access.read.data"_lang) + NodeReadData() : Node("hex.builtin.nodes.data_access.read.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.data_access.read.address"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.data_access.read.size"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.data_access.read.data") }) { } void process() override { @@ -316,9 +316,9 @@ namespace hex::plugin::builtin { class NodeWriteData : public dp::Node { public: - NodeWriteData() : Node("hex.builtin.nodes.data_access.write.header"_lang, { - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.data_access.write.address"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.data_access.write.data"_lang) }) {} + NodeWriteData() : Node("hex.builtin.nodes.data_access.write.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.data_access.write.address"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.data_access.write.data") }) {} void process() override { auto address = this->getIntegerOnInput(0); @@ -330,9 +330,9 @@ namespace hex::plugin::builtin { class NodeCastIntegerToBuffer : public dp::Node { public: - NodeCastIntegerToBuffer() : Node("hex.builtin.nodes.casting.int_to_buffer.header"_lang, { - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.casting.int_to_buffer.input"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.casting.int_to_buffer.output"_lang) }) {} + NodeCastIntegerToBuffer() : Node("hex.builtin.nodes.casting.int_to_buffer.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.casting.int_to_buffer.input"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.casting.int_to_buffer.output") }) {} void process() override { auto input = this->getIntegerOnInput(0); @@ -346,9 +346,9 @@ namespace hex::plugin::builtin { class NodeCastBufferToInteger : public dp::Node { public: - NodeCastBufferToInteger() : Node("hex.builtin.nodes.casting.buffer_to_int.header"_lang, { - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.casting.buffer_to_int.input"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.casting.buffer_to_int.output"_lang) }) {} + NodeCastBufferToInteger() : Node("hex.builtin.nodes.casting.buffer_to_int.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.casting.buffer_to_int.input"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.casting.buffer_to_int.output") }) {} void process() override { auto input = this->getBufferOnInput(0); @@ -362,11 +362,11 @@ namespace hex::plugin::builtin { class NodeIf : public dp::Node { public: - NodeIf() : Node("ex.builtin.nodes.control_flow.if.header"_lang, - { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.if.condition"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.control_flow.if.true"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.control_flow.if.false"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.control_flow.if.output"_lang) }) {} + NodeIf() : Node("ex.builtin.nodes.control_flow.if.header", + { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.if.condition"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.control_flow.if.true"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.control_flow.if.false"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.control_flow.if.output") }) {} void process() override { auto cond = this->getIntegerOnInput(0); @@ -383,10 +383,10 @@ namespace hex::plugin::builtin { class NodeEquals : public dp::Node { public: - NodeEquals() : Node("hex.builtin.nodes.control_flow.equals.header"_lang, - { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.equals.input.a"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.equals.input.b"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.equals.output"_lang) }) {} + NodeEquals() : Node("hex.builtin.nodes.control_flow.equals.header", + { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.equals.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.equals.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.equals.output") }) {} void process() override { auto inputA = this->getIntegerOnInput(0); @@ -398,9 +398,9 @@ namespace hex::plugin::builtin { class NodeNot : public dp::Node { public: - NodeNot() : Node("hex.builtin.nodes.control_flow.not.header"_lang, - { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.not.input"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.not.output"_lang) }) {} + NodeNot() : Node("hex.builtin.nodes.control_flow.not.header", + { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.not.input"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.not.output") }) {} void process() override { auto input = this->getIntegerOnInput(0); @@ -411,10 +411,10 @@ namespace hex::plugin::builtin { class NodeGreaterThan : public dp::Node { public: - NodeGreaterThan() : Node("hex.builtin.nodes.control_flow.gt.header"_lang, - { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.gt.input.a"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.gt.input.b"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.gt.output"_lang) }) {} + NodeGreaterThan() : Node("hex.builtin.nodes.control_flow.gt.header", + { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.gt.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.gt.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.gt.output") }) {} void process() override { auto inputA = this->getIntegerOnInput(0); @@ -426,10 +426,10 @@ namespace hex::plugin::builtin { class NodeLessThan : public dp::Node { public: - NodeLessThan() : Node("hex.builtin.nodes.control_flow.lt.header"_lang, - { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.lt.input.a"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.lt.input.b"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.lt.output"_lang) }) {} + NodeLessThan() : Node("hex.builtin.nodes.control_flow.lt.header", + { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.lt.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.lt.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.lt.output") }) {} void process() override { auto inputA = this->getIntegerOnInput(0); @@ -441,10 +441,10 @@ namespace hex::plugin::builtin { class NodeBoolAND : public dp::Node { public: - NodeBoolAND() : Node("hex.builtin.nodes.control_flow.and.header"_lang, - { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.and.input.a"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.and.input.b"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.and.output"_lang) }) {} + NodeBoolAND() : Node("hex.builtin.nodes.control_flow.and.header", + { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.and.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.and.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.and.output") }) {} void process() override { auto inputA = this->getIntegerOnInput(0); @@ -456,10 +456,10 @@ namespace hex::plugin::builtin { class NodeBoolOR : public dp::Node { public: - NodeBoolOR() : Node("hex.builtin.nodes.control_flow.or.header"_lang, - { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.or.input.a"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.or.input.b"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.or.output"_lang) }) {} + NodeBoolOR() : Node("hex.builtin.nodes.control_flow.or.header", + { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.or.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.or.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.control_flow.or.output") }) {} void process() override { auto inputA = this->getIntegerOnInput(0); @@ -471,12 +471,12 @@ namespace hex::plugin::builtin { class NodeCryptoAESDecrypt : public dp::Node { public: - NodeCryptoAESDecrypt() : Node("hex.builtin.nodes.crypto.aes.header"_lang, - { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.key"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.iv"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.nonce"_lang), - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.input"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.output"_lang) }) {} + NodeCryptoAESDecrypt() : Node("hex.builtin.nodes.crypto.aes.header", + { dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.key"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.iv"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.nonce"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.input"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.crypto.aes.output") }) {} void drawNode() override { ImGui::PushItemWidth(100); @@ -514,9 +514,9 @@ namespace hex::plugin::builtin { class NodeDecodingBase64 : public dp::Node { public: - NodeDecodingBase64() : Node("hex.builtin.nodes.decoding.base64.header"_lang, { - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.decoding.base64.input"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.decoding.base64.output"_lang) }) {} + NodeDecodingBase64() : Node("hex.builtin.nodes.decoding.base64.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.decoding.base64.input"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.decoding.base64.output") }) {} void process() override { auto input = this->getBufferOnInput(0); @@ -529,9 +529,9 @@ namespace hex::plugin::builtin { class NodeDecodingHex : public dp::Node { public: - NodeDecodingHex() : Node("hex.builtin.nodes.decoding.hex.header"_lang, { - dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.decoding.hex.input"_lang), - dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.decoding.hex.output"_lang) }) {} + NodeDecodingHex() : Node("hex.builtin.nodes.decoding.hex.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.decoding.hex.input"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.decoding.hex.output") }) {} void process() override { auto input = this->getBufferOnInput(0); @@ -566,40 +566,40 @@ namespace hex::plugin::builtin { }; void registerDataProcessorNodes() { - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants"_lang, "hex.builtin.nodes.constants.int"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants"_lang, "hex.builtin.nodes.constants.float"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants"_lang, "hex.builtin.nodes.constants.nullptr"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants"_lang, "hex.builtin.nodes.constants.buffer"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants"_lang, "hex.builtin.nodes.constants.string"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants"_lang, "hex.builtin.nodes.constants.rgba8"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants"_lang, "hex.builtin.nodes.constants.comment"_lang); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.int"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.float"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.nullptr"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.buffer"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.string"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.rgba8"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.constants", "hex.builtin.nodes.constants.comment"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.display"_lang, "hex.builtin.nodes.display.int"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.display"_lang, "hex.builtin.nodes.display.float"_lang); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.display", "hex.builtin.nodes.display.int"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.display", "hex.builtin.nodes.display.float"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.data_access"_lang, "hex.builtin.nodes.data_access.read"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.data_access"_lang, "hex.builtin.nodes.data_access.write"_lang); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.read"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.data_access", "hex.builtin.nodes.data_access.write"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.casting"_lang, "hex.builtin.nodes.casting.int_to_buffer"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.casting"_lang, "hex.builtin.nodes.casting.buffer_to_int"_lang); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.int_to_buffer"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.casting", "hex.builtin.nodes.casting.buffer_to_int"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow"_lang, "hex.builtin.nodes.control_flow.if"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow"_lang, "hex.builtin.nodes.control_flow.equals"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow"_lang, "hex.builtin.nodes.control_flow.not"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow"_lang, "hex.builtin.nodes.control_flow.gt"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow"_lang, "hex.builtin.nodes.control_flow.lt"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow"_lang, "hex.builtin.nodes.control_flow.and"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow"_lang, "hex.builtin.nodes.control_flow.or"_lang); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.if"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.equals"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.not"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.gt"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.lt"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.and"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.control_flow", "hex.builtin.nodes.control_flow.or"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise"_lang, "hex.builtin.nodes.bitwise.and"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise"_lang, "hex.builtin.nodes.bitwise.or"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise"_lang, "hex.builtin.nodes.bitwise.xor"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise"_lang, "hex.builtin.nodes.bitwise.not"_lang); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.and"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.or"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.xor"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.bitwise", "hex.builtin.nodes.bitwise.not"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.decoding"_lang, "hex.builtin.nodes.decoding.base64"_lang); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.decoding"_lang, "hex.builtin.nodes.decoding.hex"_lang); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.decoding", "hex.builtin.nodes.decoding.base64"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.decoding", "hex.builtin.nodes.decoding.hex"); - ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.crypto"_lang, "hex.builtin.nodes.crypto.aes"_lang); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.crypto", "hex.builtin.nodes.crypto.aes"); } } \ No newline at end of file diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index cd4c7dacb..2dc60f8db 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -4,9 +4,16 @@ namespace hex::plugin::builtin { void registerSettings() { - ContentRegistry::Settings::add("Interface", "Color theme", 0, [](nlohmann::json &setting) { + ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.color", 0, [](auto name, nlohmann::json &setting) { static int selection = setting; - if (ImGui::Combo("Color theme", &selection, "Dark\0Light\0Classic\0")) { + + const char* themes[] = { + "hex.builtin.setting.interface.color.dark"_lang, + "hex.builtin.setting.interface.color.light"_lang, + "hex.builtin.setting.interface.color.classic"_lang + }; + + if (ImGui::Combo(name.data(), &selection, themes, IM_ARRAYSIZE(themes))) { setting = selection; return true; } @@ -14,7 +21,7 @@ namespace hex::plugin::builtin { return false; }); - ContentRegistry::Settings::add("Interface", "Language", "en-US", [](nlohmann::json &setting) { + ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.language", "en-US", [](auto name, nlohmann::json &setting) { auto &languages = LangEntry::getSupportedLanguages(); static int selection = [&]() -> int { @@ -37,7 +44,7 @@ namespace hex::plugin::builtin { }(); - if (ImGui::Combo("Language", &selection, languageNames.data(), languageNames.size())) { + if (ImGui::Combo(name.data(), &selection, languageNames.data(), languageNames.size())) { u16 index = 0; for (auto &[languageCode, languageName] : languages){ diff --git a/plugins/builtin/source/content/tools_entries.cpp b/plugins/builtin/source/content/tools_entries.cpp index d481948a8..8bcd8fc2b 100644 --- a/plugins/builtin/source/content/tools_entries.cpp +++ b/plugins/builtin/source/content/tools_entries.cpp @@ -341,12 +341,12 @@ namespace hex::plugin::builtin { } void registerToolEntries() { - ContentRegistry::Tools::add("hex.builtin.tools.demangler"_lang, drawDemangler); - ContentRegistry::Tools::add("hex.builtin.tools.ascii_table"_lang, drawASCIITable); - ContentRegistry::Tools::add("hex.builtin.tools.regex_replacer"_lang, drawRegexReplacer); - ContentRegistry::Tools::add("hex.builtin.tools.color"_lang, drawColorPicker); - ContentRegistry::Tools::add("hex.builtin.tools.calc"_lang, drawMathEvaluator); - ContentRegistry::Tools::add("hex.builtin.tools.base_converter"_lang, drawBaseConverter); + ContentRegistry::Tools::add("hex.builtin.tools.demangler", drawDemangler); + ContentRegistry::Tools::add("hex.builtin.tools.ascii_table", drawASCIITable); + ContentRegistry::Tools::add("hex.builtin.tools.regex_replacer", drawRegexReplacer); + ContentRegistry::Tools::add("hex.builtin.tools.color", drawColorPicker); + ContentRegistry::Tools::add("hex.builtin.tools.calc", drawMathEvaluator); + ContentRegistry::Tools::add("hex.builtin.tools.base_converter", drawBaseConverter); } } \ No newline at end of file diff --git a/plugins/builtin/source/lang/en_US.cpp b/plugins/builtin/source/lang/en_US.cpp index a52511da9..a64813da0 100644 --- a/plugins/builtin/source/lang/en_US.cpp +++ b/plugins/builtin/source/lang/en_US.cpp @@ -425,6 +425,14 @@ namespace hex::plugin::builtin { { "hex.builtin.tools.base_converter.oct", "OCT" }, { "hex.builtin.tools.base_converter.bin", "BIN" }, + { "hex.builtin.setting.imhex", "ImHex" }, + { "hex.builtin.setting.imhex.recent_files", "Recent Files" }, + { "hex.builtin.setting.interface", "Interface" }, + { "hex.builtin.setting.interface.color", "Color theme" }, + { "hex.builtin.setting.interface.color.dark", "Dark" }, + { "hex.builtin.setting.interface.color.light", "Light" }, + { "hex.builtin.setting.interface.color.classic", "Classic" }, + { "hex.builtin.setting.interface.language", "Language" } }); } diff --git a/plugins/builtin/source/plugin_builtin.cpp b/plugins/builtin/source/plugin_builtin.cpp index 23deaeeb6..eab411f4b 100644 --- a/plugins/builtin/source/plugin_builtin.cpp +++ b/plugins/builtin/source/plugin_builtin.cpp @@ -2,8 +2,6 @@ namespace hex::plugin::builtin { - void registerLanguageEnUS(); - void registerDataInspectorEntries(); void registerToolEntries(); void registerPatternLanguageFunctions(); @@ -11,20 +9,22 @@ namespace hex::plugin::builtin { void registerSettings(); void registerDataProcessorNodes(); + void registerLanguageEnUS(); + } IMHEX_PLUGIN_SETUP { using namespace hex::plugin::builtin; - registerLanguageEnUS(); - registerDataInspectorEntries(); registerToolEntries(); registerPatternLanguageFunctions(); registerCommandPaletteCommands(); registerSettings(); registerDataProcessorNodes(); + + registerLanguageEnUS(); } diff --git a/plugins/libimhex/include/hex/api/content_registry.hpp b/plugins/libimhex/include/hex/api/content_registry.hpp index 86ec1592c..887b7362c 100644 --- a/plugins/libimhex/include/hex/api/content_registry.hpp +++ b/plugins/libimhex/include/hex/api/content_registry.hpp @@ -33,22 +33,22 @@ namespace hex { struct Entry { std::string name; - std::function callback; + std::function callback; }; static void load(); static void store(); - static void add(std::string_view category, std::string_view name, s64 defaultValue, const std::function &callback); - static void add(std::string_view category, std::string_view name, std::string_view defaultValue, const std::function &callback); + static void add(std::string_view unlocalizedCategory, std::string_view unlocalizedName, s64 defaultValue, const std::function &callback); + static void add(std::string_view unlocalizedCategory, std::string_view unlocalizedName, std::string_view defaultValue, const std::function &callback); - static void write(std::string_view category, std::string_view name, s64 value); - static void write(std::string_view category, std::string_view name, std::string_view value); - static void write(std::string_view category, std::string_view name, const std::vector& value); + static void write(std::string_view unlocalizedCategory, std::string_view unlocalizedName, s64 value); + static void write(std::string_view unlocalizedCategory, std::string_view unlocalizedName, std::string_view value); + static void write(std::string_view unlocalizedCategory, std::string_view unlocalizedName, const std::vector& value); - static s64 read(std::string_view category, std::string_view name, s64 defaultValue); - static std::string read(std::string_view category, std::string_view name, std::string_view defaultValue); - static std::vector read(std::string_view category, std::string_view name, const std::vector& defaultValue = { }); + static s64 read(std::string_view unlocalizedCategory, std::string_view unlocalizedName, s64 defaultValue); + static std::string read(std::string_view unlocalizedCategory, std::string_view unlocalizedName, std::string_view defaultValue); + static std::vector read(std::string_view unlocalizedCategory, std::string_view unlocalizedName, const std::vector& defaultValue = { }); static std::map>& getEntries(); static nlohmann::json& getSettingsData(); @@ -73,12 +73,12 @@ namespace hex { struct Entry { Type type; std::string command; - std::string description; + std::string unlocalizedDescription; std::function displayCallback; std::function executeCallback; }; - static void add(Type type, std::string_view command, std::string_view description, const std::function &displayCallback, const std::function &executeCallback = [](auto){}); + static void add(Type type, std::string_view command, std::string_view unlocalizedDescription, const std::function &displayCallback, const std::function &executeCallback = [](auto){}); static std::vector& getEntries(); }; @@ -126,7 +126,7 @@ namespace hex { std::function function; }; - static void add(std::string_view name, const std::function &function); + static void add(std::string_view unlocalizedName, const std::function &function); static std::vector& getEntries(); }; @@ -145,12 +145,12 @@ namespace hex { using GeneratorFunction = std::function&, std::endian, NumberDisplayStyle)>; struct Entry { - std::string name; + std::string unlocalizedName; size_t requiredSize; GeneratorFunction generatorFunction; }; - static void add(std::string_view name, size_t requiredSize, GeneratorFunction function); + static void add(std::string_view unlocalizedName, size_t requiredSize, GeneratorFunction function); static std::vector& getEntries(); }; @@ -164,8 +164,8 @@ namespace hex { }; template T, typename ... Args> - static void add(std::string_view category, std::string_view name, Args&& ... args) { - add(Entry{ category.data(), name.data(), [args...]{ return new T(std::forward(args)...); } }); + static void add(std::string_view unlocalizedCategory, std::string_view unlocalizedName, Args&& ... args) { + add(Entry{ unlocalizedCategory.data(), unlocalizedName.data(), [args...]{ return new T(std::forward(args)...); } }); } static void addSeparator(); diff --git a/plugins/libimhex/include/hex/data_processor/attribute.hpp b/plugins/libimhex/include/hex/data_processor/attribute.hpp index b38fee1af..564d76461 100644 --- a/plugins/libimhex/include/hex/data_processor/attribute.hpp +++ b/plugins/libimhex/include/hex/data_processor/attribute.hpp @@ -16,7 +16,7 @@ namespace hex::dp { In, Out }; - Attribute(IOType ioType, Type type, std::string_view name) : m_id(SharedData::dataProcessorNodeIdCounter++), m_ioType(ioType), m_type(type), m_name(name) { + Attribute(IOType ioType, Type type, std::string_view unlocalizedName) : m_id(SharedData::dataProcessorNodeIdCounter++), m_ioType(ioType), m_type(type), m_unlocalizedName(unlocalizedName) { } @@ -28,7 +28,7 @@ namespace hex::dp { [[nodiscard]] u32 getID() const { return this->m_id; } [[nodiscard]] IOType getIOType() const { return this->m_ioType; } [[nodiscard]] Type getType() const { return this->m_type; } - [[nodiscard]] std::string_view getName() const { return this->m_name; } + [[nodiscard]] std::string_view getUnlocalizedName() const { return this->m_unlocalizedName; } void addConnectedAttribute(u32 linkId, Attribute *to) { this->m_connectedAttributes.insert({ linkId, to }); } void removeConnectedAttribute(u32 linkId) { this->m_connectedAttributes.erase(linkId); } @@ -41,7 +41,7 @@ namespace hex::dp { u32 m_id; IOType m_ioType; Type m_type; - std::string m_name; + std::string m_unlocalizedName; std::map m_connectedAttributes; Node *m_parentNode; diff --git a/plugins/libimhex/include/hex/data_processor/node.hpp b/plugins/libimhex/include/hex/data_processor/node.hpp index 1b5ba7e1e..ad688861f 100644 --- a/plugins/libimhex/include/hex/data_processor/node.hpp +++ b/plugins/libimhex/include/hex/data_processor/node.hpp @@ -6,7 +6,7 @@ namespace hex::dp { class Node { public: - Node(std::string_view title, std::vector attributes) : m_id(SharedData::dataProcessorNodeIdCounter++), m_title(title), m_attributes(std::move(attributes)) { + Node(std::string_view unlocalizedName, std::vector attributes) : m_id(SharedData::dataProcessorNodeIdCounter++), m_unlocalizedName(unlocalizedName), m_attributes(std::move(attributes)) { for (auto &attr : this->m_attributes) attr.setParentNode(this); } @@ -14,7 +14,7 @@ namespace hex::dp { virtual ~Node() = default; [[nodiscard]] u32 getID() const { return this->m_id; } - [[nodiscard]] std::string_view getTitle() const { return this->m_title; } + [[nodiscard]] std::string_view getUnlocalizedName() const { return this->m_unlocalizedName; } [[nodiscard]] std::vector& getAttributes() { return this->m_attributes; } void setCurrentOverlay(prv::Overlay *overlay) { @@ -33,7 +33,7 @@ namespace hex::dp { private: u32 m_id; - std::string m_title; + std::string m_unlocalizedName; std::vector m_attributes; prv::Overlay *m_overlay = nullptr; @@ -59,7 +59,7 @@ namespace hex::dp { auto attribute = this->getConnectedInputAttribute(index); if (attribute == nullptr) - throwNodeError(hex::format("Nothing connected to input '%s'", this->m_attributes[index].getName().data())); + throwNodeError(hex::format("Nothing connected to input '%s'", static_cast(LangEntry(this->m_attributes[index].getUnlocalizedName())))); if (attribute->getType() != Attribute::Type::Buffer) throwNodeError("Tried to read buffer from non-buffer attribute"); @@ -78,7 +78,7 @@ namespace hex::dp { auto attribute = this->getConnectedInputAttribute(index); if (attribute == nullptr) - throwNodeError(hex::format("Nothing connected to input '%s'", this->m_attributes[index].getName().data())); + throwNodeError(hex::format("Nothing connected to input '%s'", static_cast(LangEntry(this->m_attributes[index].getUnlocalizedName())))); if (attribute->getType() != Attribute::Type::Integer) throwNodeError("Tried to read integer from non-integer attribute"); @@ -100,7 +100,7 @@ namespace hex::dp { auto attribute = this->getConnectedInputAttribute(index); if (attribute == nullptr) - throwNodeError(hex::format("Nothing connected to input '%s'", this->m_attributes[index].getName().data())); + throwNodeError(hex::format("Nothing connected to input '%s'", static_cast(LangEntry(this->m_attributes[index].getUnlocalizedName())))); if (attribute->getType() != Attribute::Type::Float) throwNodeError("Tried to read float from non-float attribute"); diff --git a/plugins/libimhex/include/hex/helpers/lang.hpp b/plugins/libimhex/include/hex/helpers/lang.hpp index 36312acdb..36048467d 100644 --- a/plugins/libimhex/include/hex/helpers/lang.hpp +++ b/plugins/libimhex/include/hex/helpers/lang.hpp @@ -19,13 +19,15 @@ namespace hex { class LangEntry { public: - LangEntry(const char *unlocalizedString); + explicit LangEntry(const char *unlocalizedString); + explicit LangEntry(const std::string &unlocalizedString); + explicit LangEntry(std::string_view unlocalizedString); operator std::string() const; operator std::string_view() const; operator const char*() const; - std::string_view get() const; + [[nodiscard]] std::string_view get() const; static void loadLanguage(std::string_view language); static const std::map& getSupportedLanguages(); diff --git a/plugins/libimhex/source/api/content_registry.cpp b/plugins/libimhex/source/api/content_registry.cpp index cbb86186e..2d217c7a2 100644 --- a/plugins/libimhex/source/api/content_registry.cpp +++ b/plugins/libimhex/source/api/content_registry.cpp @@ -21,83 +21,91 @@ namespace hex { settingsFile << getSettingsData(); } - void ContentRegistry::Settings::add(std::string_view category, std::string_view name, s64 defaultValue, const std::function &callback) { - ContentRegistry::Settings::getEntries()[category.data()].emplace_back(Entry{ name.data(), callback }); + void ContentRegistry::Settings::add(std::string_view unlocalizedCategory, std::string_view unlocalizedName, s64 defaultValue, const std::function &callback) { + ContentRegistry::Settings::getEntries()[unlocalizedCategory.data()].emplace_back(Entry{ unlocalizedName.data(), callback }); auto &json = getSettingsData(); - if (!json.contains(category.data())) - json[category.data()] = nlohmann::json::object(); - if (!json[category.data()].contains(name.data())) - json[category.data()][name.data()] = defaultValue; + if (!json.contains(unlocalizedCategory.data())) + json[unlocalizedCategory.data()] = nlohmann::json::object(); + if (!json[unlocalizedCategory.data()].contains(unlocalizedName.data())) + json[unlocalizedCategory.data()][unlocalizedName.data()] = defaultValue; + + Settings::store(); } - void ContentRegistry::Settings::add(std::string_view category, std::string_view name, std::string_view defaultValue, const std::function &callback) { - ContentRegistry::Settings::getEntries()[category.data()].emplace_back(Entry{ name.data(), callback }); + void ContentRegistry::Settings::add(std::string_view unlocalizedCategory, std::string_view unlocalizedName, std::string_view defaultValue, const std::function &callback) { + ContentRegistry::Settings::getEntries()[unlocalizedCategory.data()].emplace_back(Entry{ unlocalizedName.data(), callback }); - getSettingsData()[category.data()] = nlohmann::json::object(); - getSettingsData()[category.data()][name.data()] = defaultValue; - } - - void ContentRegistry::Settings::write(std::string_view category, std::string_view name, s64 value) { auto &json = getSettingsData(); - if (!json.contains(category.data())) - json[category.data()] = nlohmann::json::object(); + if (!json.contains(unlocalizedCategory.data())) + json[unlocalizedCategory.data()] = nlohmann::json::object(); + if (!json[unlocalizedCategory.data()].contains(unlocalizedName.data())) + json[unlocalizedCategory.data()][unlocalizedName.data()] = defaultValue; - json[category.data()][name.data()] = value; + Settings::store(); } - void ContentRegistry::Settings::write(std::string_view category, std::string_view name, std::string_view value) { + void ContentRegistry::Settings::write(std::string_view unlocalizedCategory, std::string_view unlocalizedName, s64 value) { auto &json = getSettingsData(); - if (!json.contains(category.data())) - json[category.data()] = nlohmann::json::object(); + if (!json.contains(unlocalizedCategory.data())) + json[unlocalizedCategory.data()] = nlohmann::json::object(); - json[category.data()][name.data()] = value; + json[unlocalizedCategory.data()][unlocalizedName.data()] = value; } - void ContentRegistry::Settings::write(std::string_view category, std::string_view name, const std::vector& value) { + void ContentRegistry::Settings::write(std::string_view unlocalizedCategory, std::string_view unlocalizedName, std::string_view value) { auto &json = getSettingsData(); - if (!json.contains(category.data())) - json[category.data()] = nlohmann::json::object(); + if (!json.contains(unlocalizedCategory.data())) + json[unlocalizedCategory.data()] = nlohmann::json::object(); - json[category.data()][name.data()] = value; + json[unlocalizedCategory.data()][unlocalizedName.data()] = value; + } + + void ContentRegistry::Settings::write(std::string_view unlocalizedCategory, std::string_view unlocalizedName, const std::vector& value) { + auto &json = getSettingsData(); + + if (!json.contains(unlocalizedCategory.data())) + json[unlocalizedCategory.data()] = nlohmann::json::object(); + + json[unlocalizedCategory.data()][unlocalizedName.data()] = value; } - s64 ContentRegistry::Settings::read(std::string_view category, std::string_view name, s64 defaultValue) { + s64 ContentRegistry::Settings::read(std::string_view unlocalizedCategory, std::string_view unlocalizedName, s64 defaultValue) { auto &json = getSettingsData(); - if (!json.contains(category.data())) + if (!json.contains(unlocalizedCategory.data())) return defaultValue; - if (!json[category.data()].contains(name.data())) + if (!json[unlocalizedCategory.data()].contains(unlocalizedName.data())) return defaultValue; - return json[category.data()][name.data()].get(); + return json[unlocalizedCategory.data()][unlocalizedName.data()].get(); } - std::string ContentRegistry::Settings::read(std::string_view category, std::string_view name, std::string_view defaultValue) { + std::string ContentRegistry::Settings::read(std::string_view unlocalizedCategory, std::string_view unlocalizedName, std::string_view defaultValue) { auto &json = getSettingsData(); - if (!json.contains(category.data())) + if (!json.contains(unlocalizedCategory.data())) return defaultValue.data(); - if (!json[category.data()].contains(name.data())) + if (!json[unlocalizedCategory.data()].contains(unlocalizedName.data())) return defaultValue.data(); - return json[category.data()][name.data()].get(); + return json[unlocalizedCategory.data()][unlocalizedName.data()].get(); } - std::vector ContentRegistry::Settings::read(std::string_view category, std::string_view name, const std::vector& defaultValue) { + std::vector ContentRegistry::Settings::read(std::string_view unlocalizedCategory, std::string_view unlocalizedName, const std::vector& defaultValue) { auto &json = getSettingsData(); - if (!json.contains(category.data())) + if (!json.contains(unlocalizedCategory.data())) return defaultValue; - if (!json[category.data()].contains(name.data())) + if (!json[unlocalizedCategory.data()].contains(unlocalizedName.data())) return defaultValue; - return json[category.data()][name.data()].get>(); + return json[unlocalizedCategory.data()][unlocalizedName.data()].get>(); } @@ -127,8 +135,8 @@ namespace hex { /* Command Palette Commands */ - void ContentRegistry::CommandPaletteCommands::add(ContentRegistry::CommandPaletteCommands::Type type, std::string_view command, std::string_view description, const std::function &displayCallback, const std::function &executeCallback) { - getEntries().push_back(ContentRegistry::CommandPaletteCommands::Entry{ type, command.data(), description.data(), displayCallback, executeCallback }); + void ContentRegistry::CommandPaletteCommands::add(ContentRegistry::CommandPaletteCommands::Type type, std::string_view command, std::string_view unlocalizedDescription, const std::function &displayCallback, const std::function &executeCallback) { + getEntries().push_back(ContentRegistry::CommandPaletteCommands::Entry{ type, command.data(), unlocalizedDescription.data(), displayCallback, executeCallback }); } std::vector& ContentRegistry::CommandPaletteCommands::getEntries() { @@ -160,8 +168,8 @@ namespace hex { /* Tools */ - void ContentRegistry::Tools::add(std::string_view name, const std::function &function) { - getEntries().emplace_back(Entry{ name.data(), function }); + void ContentRegistry::Tools:: add(std::string_view unlocalizedName, const std::function &function) { + getEntries().emplace_back(Entry{ unlocalizedName.data(), function }); } std::vector& ContentRegistry::Tools::getEntries() { @@ -171,8 +179,8 @@ namespace hex { /* Data Inspector */ - void ContentRegistry::DataInspector::add(std::string_view name, size_t requiredSize, ContentRegistry::DataInspector::GeneratorFunction function) { - getEntries().push_back({ name.data(), requiredSize, std::move(function) }); + void ContentRegistry::DataInspector::add(std::string_view unlocalizedName, size_t requiredSize, ContentRegistry::DataInspector::GeneratorFunction function) { + getEntries().push_back({ unlocalizedName.data(), requiredSize, std::move(function) }); } std::vector& ContentRegistry::DataInspector::getEntries() { diff --git a/plugins/libimhex/source/helpers/lang.cpp b/plugins/libimhex/source/helpers/lang.cpp index d0703cc12..62acd74a7 100644 --- a/plugins/libimhex/source/helpers/lang.cpp +++ b/plugins/libimhex/source/helpers/lang.cpp @@ -14,6 +14,8 @@ namespace hex { } LangEntry::LangEntry(const char *unlocalizedString) : m_unlocalizedString(unlocalizedString) { } + LangEntry::LangEntry(const std::string &unlocalizedString) : m_unlocalizedString(unlocalizedString) { } + LangEntry::LangEntry(std::string_view unlocalizedString) : m_unlocalizedString(unlocalizedString) { } LangEntry::operator std::string() const { return std::string(get()); diff --git a/source/views/view_command_palette.cpp b/source/views/view_command_palette.cpp index 476ba36bd..f5cf9a459 100644 --- a/source/views/view_command_palette.cpp +++ b/source/views/view_command_palette.cpp @@ -101,7 +101,7 @@ namespace hex { std::vector results; - for (const auto &[type, command, description, displayCallback, executeCallback] : ContentRegistry::CommandPaletteCommands::getEntries()) { + for (const auto &[type, command, unlocalizedDescription, displayCallback, executeCallback] : ContentRegistry::CommandPaletteCommands::getEntries()) { auto AutoComplete = [this, &currCommand = command](auto) { focusInputTextBox(); @@ -112,7 +112,7 @@ namespace hex { if (type == ContentRegistry::CommandPaletteCommands::Type::SymbolCommand) { if (auto [match, value] = MatchCommand(input, command); match != MatchType::NoMatch) { if (match != MatchType::PerfectMatch) - results.push_back({ command + " (" + description + ")", "", AutoComplete }); + results.push_back({ command + " (" + LangEntry(unlocalizedDescription) + ")", "", AutoComplete }); else { auto matchedCommand = input.substr(command.length()).data(); results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback }); @@ -121,7 +121,7 @@ namespace hex { } else if (type == ContentRegistry::CommandPaletteCommands::Type::KeywordCommand) { if (auto [match, value] = MatchCommand(input, command + " "); match != MatchType::NoMatch) { if (match != MatchType::PerfectMatch) - results.push_back({ command + " (" + description + ")", "", AutoComplete }); + results.push_back({ command + " (" + LangEntry(unlocalizedDescription) + ")", "", AutoComplete }); else { auto matchedCommand = input.substr(command.length() + 1).data(); results.push_back({ displayCallback(matchedCommand), matchedCommand, executeCallback }); diff --git a/source/views/view_data_inspector.cpp b/source/views/view_data_inspector.cpp index f8e89f068..42c874149 100644 --- a/source/views/view_data_inspector.cpp +++ b/source/views/view_data_inspector.cpp @@ -49,7 +49,7 @@ namespace hex { std::vector buffer(entry.requiredSize); provider->read(this->m_startAddress, buffer.data(), buffer.size()); - this->m_cachedData.emplace_back(entry.name, entry.generatorFunction(buffer, this->m_endian, this->m_numberDisplayStyle)); + this->m_cachedData.emplace_back(entry.unlocalizedName, entry.generatorFunction(buffer, this->m_endian, this->m_numberDisplayStyle)); } } @@ -67,10 +67,10 @@ namespace hex { ImGui::TableHeadersRow(); - for (const auto &[name, function] : this->m_cachedData) { + for (const auto &[unlocalizedName, function] : this->m_cachedData) { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::TextUnformatted(name.c_str()); + ImGui::TextUnformatted(LangEntry(unlocalizedName)); ImGui::TableNextColumn(); function(); } diff --git a/source/views/view_data_processor.cpp b/source/views/view_data_processor.cpp index 5e24db2df..1c19d0b57 100644 --- a/source/views/view_data_processor.cpp +++ b/source/views/view_data_processor.cpp @@ -18,7 +18,7 @@ namespace hex { } View::subscribeEvent(Events::SettingsChanged, [](auto) { - int theme = ContentRegistry::Settings::getSettingsData()["Interface"]["Color theme"]; + int theme = ContentRegistry::Settings::getSettingsData()["hex.builtin.setting.interface"]["hex.builtin.setting.interface.color"]; switch (theme) { default: @@ -238,7 +238,7 @@ namespace hex { imnodes::BeginNode(node->getID()); imnodes::BeginNodeTitleBar(); - ImGui::TextUnformatted(node->getTitle().data()); + ImGui::TextUnformatted(LangEntry(node->getUnlocalizedName())); imnodes::EndNodeTitleBar(); node->drawNode(); @@ -254,11 +254,11 @@ namespace hex { if (attribute.getIOType() == dp::Attribute::IOType::In) { imnodes::BeginInputAttribute(attribute.getID(), pinShape); - ImGui::TextUnformatted(attribute.getName().data()); + ImGui::TextUnformatted(LangEntry(attribute.getUnlocalizedName())); imnodes::EndInputAttribute(); } else if (attribute.getIOType() == dp::Attribute::IOType::Out) { imnodes::BeginOutputAttribute(attribute.getID(), imnodes::PinShape(pinShape + 1)); - ImGui::TextUnformatted(attribute.getName().data()); + ImGui::TextUnformatted(LangEntry(attribute.getUnlocalizedName())); imnodes::EndOutputAttribute(); } } diff --git a/source/views/view_pattern.cpp b/source/views/view_pattern.cpp index c6b18e74f..f918b2980 100644 --- a/source/views/view_pattern.cpp +++ b/source/views/view_pattern.cpp @@ -173,7 +173,7 @@ namespace hex { { View::subscribeEvent(Events::SettingsChanged, [this](auto) { - int theme = ContentRegistry::Settings::getSettingsData()["Interface"]["Color theme"]; + int theme = ContentRegistry::Settings::getSettingsData()["hex.builtin.setting.interface"]["hex.builtin.setting.interface.color"]; switch (theme) { default: diff --git a/source/views/view_settings.cpp b/source/views/view_settings.cpp index 3389d6db6..2a5ba9a22 100644 --- a/source/views/view_settings.cpp +++ b/source/views/view_settings.cpp @@ -6,7 +6,7 @@ namespace hex { ViewSettings::ViewSettings() : View("hex.view.settings.title"_lang) { View::subscribeEvent(Events::OpenWindow, [this](auto name) { - if (std::any_cast(name) == std::string("hex.view.settings.title"_lang)) { + if (std::any_cast(name) == std::string("hex.view.settings.title")) { View::doLater([]{ ImGui::OpenPopup("hex.view.settings.title"_lang); }); this->getWindowOpenState() = true; } @@ -23,10 +23,10 @@ namespace hex { if (ImGui::BeginPopupModal("hex.view.settings.title"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_AlwaysAutoResize)) { for (auto &[category, entries] : ContentRegistry::Settings::getEntries()) { - ImGui::TextUnformatted(category.c_str()); + ImGui::TextUnformatted(LangEntry(category)); ImGui::Separator(); for (auto &[name, callback] : entries) { - if (callback(ContentRegistry::Settings::getSettingsData()[category][name])) + if (callback(LangEntry(name), ContentRegistry::Settings::getSettingsData()[category][name])) View::postEvent(Events::SettingsChanged); } ImGui::NewLine(); diff --git a/source/views/view_tools.cpp b/source/views/view_tools.cpp index fc515b83f..df8afd985 100644 --- a/source/views/view_tools.cpp +++ b/source/views/view_tools.cpp @@ -11,7 +11,7 @@ namespace hex { void ViewTools::drawContent() { if (ImGui::Begin("hex.view.tools.title"_lang, &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) { for (const auto& [name, function] : ContentRegistry::Tools::getEntries()) { - if (ImGui::CollapsingHeader(name.c_str())) { + if (ImGui::CollapsingHeader(LangEntry(name))) { function(); } } diff --git a/source/window.cpp b/source/window.cpp index d139ac8ba..20b1fcbe1 100644 --- a/source/window.cpp +++ b/source/window.cpp @@ -55,7 +55,7 @@ namespace hex { EventManager::subscribe(Events::SettingsChanged, this, [](auto) -> std::any { { - int theme = ContentRegistry::Settings::getSettingsData()["Interface"]["Color theme"]; + int theme = ContentRegistry::Settings::getSettingsData()["hex.builtin.setting.interface"]["hex.builtin.setting.interface.color"]; switch (theme) { default: case 0: /* Dark theme */ @@ -72,7 +72,7 @@ namespace hex { } { - std::string language = ContentRegistry::Settings::getSettingsData()["Interface"]["Language"]; + std::string language = ContentRegistry::Settings::getSettingsData()["hex.builtin.setting.interface"]["hex.builtin.setting.interface.language"]; LangEntry::loadLanguage(language); } @@ -107,7 +107,7 @@ namespace hex { std::vector recentFilesVector; std::copy(this->m_recentFiles.begin(), this->m_recentFiles.end(), std::back_inserter(recentFilesVector)); - ContentRegistry::Settings::write("ImHex", "RecentFiles", recentFilesVector); + ContentRegistry::Settings::write("hex.builtin.setting.imhex", "hex.builtin.setting.imhex.recent_files", recentFilesVector); } return { }; @@ -119,13 +119,13 @@ namespace hex { return { }; }); + this->initPlugins(); + ContentRegistry::Settings::load(); View::postEvent(Events::SettingsChanged); - for (const auto &path : ContentRegistry::Settings::read("ImHex", "RecentFiles")) + for (const auto &path : ContentRegistry::Settings::read("hex.builtin.setting.imhex", "hex.builtin.setting.imhex.recent_files")) this->m_recentFiles.push_back(path); - - this->initPlugins(); } Window::~Window() { @@ -362,7 +362,7 @@ namespace hex { ImGui::Text("hex.welcome.header.customize"_lang); { if (ImGui::DescriptionButton("hex.welcome.customize.settings.title"_lang, "hex.welcome.customize.settings.desc"_lang, ImVec2(ImGui::GetContentRegionAvail().x * 0.8f, 0))) - EventManager::post(Events::OpenWindow, "Preferences"); + EventManager::post(Events::OpenWindow, "hex.view.settings.title"); } ImGui::TableNextRow(ImGuiTableRowFlags_None, 100); ImGui::TableNextColumn();