diff --git a/plugins/builtin/source/content/data_processor_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes.cpp index de9e4732f..ee6d433e5 100644 --- a/plugins/builtin/source/content/data_processor_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes.cpp @@ -360,6 +360,97 @@ namespace hex::plugin::builtin { } }; + class NodeArithmeticAdd : public dp::Node { + public: + NodeArithmeticAdd() : Node("hex.builtin.nodes.arithmetic.add.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.add.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.add.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.add.output") }) {} + + void process() override { + auto inputA = this->getIntegerOnInput(0); + auto inputB = this->getIntegerOnInput(1); + + auto output = inputA + inputB; + + this->setIntegerOnOutput(2, output); + } + }; + + class NodeArithmeticSubtract : public dp::Node { + public: + NodeArithmeticSubtract() : Node("hex.builtin.nodes.arithmetic.sub.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.sub.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.sub.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.sub.output") }) {} + + void process() override { + auto inputA = this->getIntegerOnInput(0); + auto inputB = this->getIntegerOnInput(1); + + auto output = inputA - inputB; + + this->setIntegerOnOutput(2, output); + } + }; + + class NodeArithmeticMultiply : public dp::Node { + public: + NodeArithmeticMultiply() : Node("hex.builtin.nodes.arithmetic.mul.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.mul.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.mul.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.mul.output") }) {} + + void process() override { + auto inputA = this->getIntegerOnInput(0); + auto inputB = this->getIntegerOnInput(1); + + auto output = inputA * inputB; + + this->setIntegerOnOutput(2, output); + } + }; + + class NodeArithmeticDivide : public dp::Node { + public: + NodeArithmeticDivide() : Node("hex.builtin.nodes.arithmetic.div.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.div.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.div.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.div.output") }) {} + + void process() override { + auto inputA = this->getIntegerOnInput(0); + auto inputB = this->getIntegerOnInput(1); + + if (inputB == 0) + throwNodeError("Division by zero"); + + auto output = inputA / inputB; + + this->setIntegerOnOutput(2, output); + } + }; + + class NodeArithmeticModulus : public dp::Node { + public: + NodeArithmeticModulus() : Node("hex.builtin.nodes.arithmetic.mod.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.mod.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.mod.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Integer, "hex.builtin.nodes.arithmetic.mod.output") }) {} + + void process() override { + auto inputA = this->getIntegerOnInput(0); + auto inputB = this->getIntegerOnInput(1); + + if (inputB == 0) + throwNodeError("Division by zero"); + + auto output = inputA % inputB; + + this->setIntegerOnOutput(2, output); + } + }; + class NodeIf : public dp::Node { public: NodeIf() : Node("ex.builtin.nodes.control_flow.if.header", @@ -583,6 +674,12 @@ namespace hex::plugin::builtin { 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.arithmetic", "hex.builtin.nodes.arithmetic.add"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.sub"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.mul"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.div"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.arithmetic", "hex.builtin.nodes.arithmetic.mod"); + 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"); diff --git a/plugins/builtin/source/lang/de_DE.cpp b/plugins/builtin/source/lang/de_DE.cpp index 9e2b8da40..7e6a5992f 100644 --- a/plugins/builtin/source/lang/de_DE.cpp +++ b/plugins/builtin/source/lang/de_DE.cpp @@ -347,6 +347,33 @@ namespace hex::plugin::builtin { { "hex.builtin.nodes.casting.buffer_to_int.input", "In" }, { "hex.builtin.nodes.casting.buffer_to_int.output", "Out" }, + { "hex.builtin.nodes.arithmetic", "Arithmetisch" }, + { "hex.builtin.nodes.arithmetic.add", "Addition" }, + { "hex.builtin.nodes.arithmetic.add.header", "Plus" }, + { "hex.builtin.nodes.arithmetic.add.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.add.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.add.output", "Output" }, + { "hex.builtin.nodes.arithmetic.sub", "Subtraktion" }, + { "hex.builtin.nodes.arithmetic.sub.header", "Minus" }, + { "hex.builtin.nodes.arithmetic.sub.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.sub.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.sub.output", "Output" }, + { "hex.builtin.nodes.arithmetic.mul", "Multiplikation" }, + { "hex.builtin.nodes.arithmetic.mul.header", "Mal" }, + { "hex.builtin.nodes.arithmetic.mul.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.mul.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.mul.output", "Output" }, + { "hex.builtin.nodes.arithmetic.div", "Division" }, + { "hex.builtin.nodes.arithmetic.div.header", "Durch" }, + { "hex.builtin.nodes.arithmetic.div.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.div.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.div.output", "Output" }, + { "hex.builtin.nodes.arithmetic.mod", "Modulus" }, + { "hex.builtin.nodes.arithmetic.mod.header", "Modulo" }, + { "hex.builtin.nodes.arithmetic.mod.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.mod.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.mod.output", "Output" }, + { "hex.builtin.nodes.control_flow", "Kontrollfluss" }, { "hex.builtin.nodes.control_flow.if", "If" }, { "hex.builtin.nodes.control_flow.if.header", "If" }, diff --git a/plugins/builtin/source/lang/en_US.cpp b/plugins/builtin/source/lang/en_US.cpp index 5bc6ec5cc..a6b96e53b 100644 --- a/plugins/builtin/source/lang/en_US.cpp +++ b/plugins/builtin/source/lang/en_US.cpp @@ -347,6 +347,33 @@ namespace hex::plugin::builtin { { "hex.builtin.nodes.casting.buffer_to_int.input", "In" }, { "hex.builtin.nodes.casting.buffer_to_int.output", "Out" }, + { "hex.builtin.nodes.arithmetic", "Arithmetic" }, + { "hex.builtin.nodes.arithmetic.add", "Addition" }, + { "hex.builtin.nodes.arithmetic.add.header", "Add" }, + { "hex.builtin.nodes.arithmetic.add.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.add.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.add.output", "Output" }, + { "hex.builtin.nodes.arithmetic.sub", "Subtraction" }, + { "hex.builtin.nodes.arithmetic.sub.header", "Subtract" }, + { "hex.builtin.nodes.arithmetic.sub.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.sub.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.sub.output", "Output" }, + { "hex.builtin.nodes.arithmetic.mul", "Multiplication" }, + { "hex.builtin.nodes.arithmetic.mul.header", "Multiply" }, + { "hex.builtin.nodes.arithmetic.mul.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.mul.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.mul.output", "Output" }, + { "hex.builtin.nodes.arithmetic.div", "Division" }, + { "hex.builtin.nodes.arithmetic.div.header", "Divide" }, + { "hex.builtin.nodes.arithmetic.div.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.div.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.div.output", "Output" }, + { "hex.builtin.nodes.arithmetic.mod", "Modulus" }, + { "hex.builtin.nodes.arithmetic.mod.header", "Modulo" }, + { "hex.builtin.nodes.arithmetic.mod.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.mod.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.mod.output", "Output" }, + { "hex.builtin.nodes.control_flow", "Control flow" }, { "hex.builtin.nodes.control_flow.if", "If" }, { "hex.builtin.nodes.control_flow.if.header", "If" }, diff --git a/plugins/builtin/source/lang/it_IT.cpp b/plugins/builtin/source/lang/it_IT.cpp index d540f6eca..ad2bc509c 100644 --- a/plugins/builtin/source/lang/it_IT.cpp +++ b/plugins/builtin/source/lang/it_IT.cpp @@ -347,6 +347,33 @@ namespace hex::plugin::builtin { { "hex.builtin.nodes.casting.buffer_to_int.input", "Entrata" }, { "hex.builtin.nodes.casting.buffer_to_int.output", "Uscita" }, + { "hex.builtin.nodes.arithmetic", "Aritmetica" }, + { "hex.builtin.nodes.arithmetic.add", "Aggiunta" }, + { "hex.builtin.nodes.arithmetic.add.header", "Aggiungere" }, + { "hex.builtin.nodes.arithmetic.add.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.add.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.add.output", "Output" }, + { "hex.builtin.nodes.arithmetic.sub", "Sottrazione" }, + { "hex.builtin.nodes.arithmetic.sub.header", "Sottrarre" }, + { "hex.builtin.nodes.arithmetic.sub.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.sub.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.sub.output", "Output" }, + { "hex.builtin.nodes.arithmetic.mul", "Moltiplicazione" }, + { "hex.builtin.nodes.arithmetic.mul.header", "Moltiplicare" }, + { "hex.builtin.nodes.arithmetic.mul.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.mul.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.mul.output", "Output" }, + { "hex.builtin.nodes.arithmetic.div", "Divisione" }, + { "hex.builtin.nodes.arithmetic.div.header", "Dividere" }, + { "hex.builtin.nodes.arithmetic.div.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.div.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.div.output", "Output" }, + { "hex.builtin.nodes.arithmetic.mod", "Modulo" }, + { "hex.builtin.nodes.arithmetic.mod.header", "Modulo" }, + { "hex.builtin.nodes.arithmetic.mod.input.a", "Input A" }, + { "hex.builtin.nodes.arithmetic.mod.input.b", "Input B" }, + { "hex.builtin.nodes.arithmetic.mod.output", "Output" }, + { "hex.builtin.nodes.control_flow", "Controlla Flusso" }, { "hex.builtin.nodes.control_flow.if", "Se" }, { "hex.builtin.nodes.control_flow.if.header", "Se" }, diff --git a/source/views/view_data_processor.cpp b/source/views/view_data_processor.cpp index c860190f0..b44fd8cd7 100644 --- a/source/views/view_data_processor.cpp +++ b/source/views/view_data_processor.cpp @@ -165,16 +165,16 @@ namespace hex { } } - for (const auto &[category, name, function] : ContentRegistry::DataProcessorNode::getEntries()) { - if (category.empty() && name.empty()) { + for (const auto &[unlocalizedCategory, unlocalizedName, function] : ContentRegistry::DataProcessorNode::getEntries()) { + if (unlocalizedCategory.empty() && unlocalizedName.empty()) { ImGui::Separator(); - } else if (category.empty()) { - if (ImGui::MenuItem(name.c_str())) { + } else if (unlocalizedCategory.empty()) { + if (ImGui::MenuItem(LangEntry(unlocalizedName))) { node = function(); } } else { - if (ImGui::BeginMenu(category.c_str())) { - if (ImGui::MenuItem(name.c_str())) { + if (ImGui::BeginMenu(LangEntry(unlocalizedCategory))) { + if (ImGui::MenuItem(LangEntry(unlocalizedName))) { node = function(); } ImGui::EndMenu();