diff --git a/plugins/builtin/source/content/data_processor_nodes.cpp b/plugins/builtin/source/content/data_processor_nodes.cpp index ee6d433e5..6f9875a3b 100644 --- a/plugins/builtin/source/content/data_processor_nodes.cpp +++ b/plugins/builtin/source/content/data_processor_nodes.cpp @@ -451,6 +451,69 @@ namespace hex::plugin::builtin { } }; + class NodeBufferCombine : public dp::Node { + public: + NodeBufferCombine() : Node("hex.builtin.nodes.buffer.combine.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.buffer.combine.input.a"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.buffer.combine.input.b"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.buffer.combine.output") }) {} + + void process() override { + auto inputA = this->getBufferOnInput(0); + auto inputB = this->getBufferOnInput(1); + + auto &output = inputA; + std::copy(inputB.begin(), inputB.end(), std::back_inserter(output)); + + this->setBufferOnOutput(2, output); + } + }; + + class NodeBufferSlice : public dp::Node { + public: + NodeBufferSlice() : Node("hex.builtin.nodes.buffer.slice.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.buffer.slice.input.buffer"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.buffer.slice.input.from"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.buffer.slice.input.to"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.buffer.slice.output") }) {} + + void process() override { + auto input = this->getBufferOnInput(0); + auto from = this->getIntegerOnInput(1); + auto to = this->getIntegerOnInput(2); + + if (from < 0 || from >= input.size()) + throwNodeError("'from' input out of range"); + if (to < 0 || from >= input.size()) + throwNodeError("'to' input out of range"); + if (to >= from) + throwNodeError("'to' input needs to be greater than 'from' input"); + + this->setBufferOnOutput(3, std::vector(input.begin() + from, input.begin() + to)); + } + }; + + class NodeBufferRepeat : public dp::Node { + public: + NodeBufferRepeat() : Node("hex.builtin.nodes.buffer.repeat.header", { + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Buffer, "hex.builtin.nodes.buffer.repeat.input.buffer"), + dp::Attribute(dp::Attribute::IOType::In, dp::Attribute::Type::Integer, "hex.builtin.nodes.buffer.repeat.input.count"), + dp::Attribute(dp::Attribute::IOType::Out, dp::Attribute::Type::Buffer, "hex.builtin.nodes.buffer.combine.output") }) {} + + void process() override { + auto buffer = this->getBufferOnInput(0); + auto count = this->getIntegerOnInput(1); + + std::vector output; + output.resize(buffer.size() * count); + + for (u32 i = 0; i < count; i++) + std::copy(buffer.begin(), buffer.end(), output.begin() + buffer.size() * i); + + this->setBufferOnOutput(2, output); + } + }; + class NodeIf : public dp::Node { public: NodeIf() : Node("ex.builtin.nodes.control_flow.if.header", @@ -680,6 +743,10 @@ namespace hex::plugin::builtin { 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.buffer", "hex.builtin.nodes.buffer.combine"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.slice"); + ContentRegistry::DataProcessorNode::add("hex.builtin.nodes.buffer", "hex.builtin.nodes.buffer.repeat"); + 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 7e6a5992f..9f7ff3499 100644 --- a/plugins/builtin/source/lang/de_DE.cpp +++ b/plugins/builtin/source/lang/de_DE.cpp @@ -374,6 +374,24 @@ namespace hex::plugin::builtin { { "hex.builtin.nodes.arithmetic.mod.input.b", "Input B" }, { "hex.builtin.nodes.arithmetic.mod.output", "Output" }, + { "hex.builtin.nodes.buffer", "Buffer" }, + { "hex.builtin.nodes.buffer.combine", "Kombinieren" }, + { "hex.builtin.nodes.buffer.combine.header", "Buffer kombinieren" }, + { "hex.builtin.nodes.buffer.combine.input.a", "Input A" }, + { "hex.builtin.nodes.buffer.combine.input.b", "Input B" }, + { "hex.builtin.nodes.buffer.combine.output", "Output" }, + { "hex.builtin.nodes.buffer.slice", "Zerschneiden" }, + { "hex.builtin.nodes.buffer.slice.header", "Buffer zerschneiden" }, + { "hex.builtin.nodes.buffer.slice.input.buffer", "Input" }, + { "hex.builtin.nodes.buffer.slice.input.from", "Von" }, + { "hex.builtin.nodes.buffer.slice.input.to", "Bis" }, + { "hex.builtin.nodes.buffer.slice.output", "Output" }, + { "hex.builtin.nodes.buffer.repeat", "Wiederholen" }, + { "hex.builtin.nodes.buffer.repeat.header", "Buffer wiederholen" }, + { "hex.builtin.nodes.buffer.repeat.input.buffer", "Input" }, + { "hex.builtin.nodes.buffer.repeat.input.count", "Anzahl" }, + { "hex.builtin.nodes.buffer.repeat.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 a6b96e53b..c194a97d5 100644 --- a/plugins/builtin/source/lang/en_US.cpp +++ b/plugins/builtin/source/lang/en_US.cpp @@ -374,6 +374,24 @@ namespace hex::plugin::builtin { { "hex.builtin.nodes.arithmetic.mod.input.b", "Input B" }, { "hex.builtin.nodes.arithmetic.mod.output", "Output" }, + { "hex.builtin.nodes.buffer", "Buffer" }, + { "hex.builtin.nodes.buffer.combine", "Combine" }, + { "hex.builtin.nodes.buffer.combine.header", "Combine buffers" }, + { "hex.builtin.nodes.buffer.combine.input.a", "Input A" }, + { "hex.builtin.nodes.buffer.combine.input.b", "Input B" }, + { "hex.builtin.nodes.buffer.combine.output", "Output" }, + { "hex.builtin.nodes.buffer.slice", "Slice" }, + { "hex.builtin.nodes.buffer.slice.header", "Slice buffer" }, + { "hex.builtin.nodes.buffer.slice.input.buffer", "Input" }, + { "hex.builtin.nodes.buffer.slice.input.from", "From" }, + { "hex.builtin.nodes.buffer.slice.input.to", "To" }, + { "hex.builtin.nodes.buffer.slice.output", "Output" }, + { "hex.builtin.nodes.buffer.repeat", "Repeat" }, + { "hex.builtin.nodes.buffer.repeat.header", "Repeat buffer" }, + { "hex.builtin.nodes.buffer.repeat.input.buffer", "Input" }, + { "hex.builtin.nodes.buffer.repeat.input.count", "Count" }, + { "hex.builtin.nodes.buffer.repeat.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 ad2bc509c..21c4f0a8a 100644 --- a/plugins/builtin/source/lang/it_IT.cpp +++ b/plugins/builtin/source/lang/it_IT.cpp @@ -374,6 +374,24 @@ namespace hex::plugin::builtin { { "hex.builtin.nodes.arithmetic.mod.input.b", "Input B" }, { "hex.builtin.nodes.arithmetic.mod.output", "Output" }, + { "hex.builtin.nodes.buffer", "Buffer" }, + { "hex.builtin.nodes.buffer.combine", "Combinare" }, + { "hex.builtin.nodes.buffer.combine.header", "Combina buffer" }, + { "hex.builtin.nodes.buffer.combine.input.a", "Input A" }, + { "hex.builtin.nodes.buffer.combine.input.b", "Input B" }, + { "hex.builtin.nodes.buffer.combine.output", "Output" }, + { "hex.builtin.nodes.buffer.slice", "Affettare" }, + { "hex.builtin.nodes.buffer.slice.header", "Affetta buffer" }, + { "hex.builtin.nodes.buffer.slice.input.buffer", "Input" }, + { "hex.builtin.nodes.buffer.slice.input.from", "Inizio" }, + { "hex.builtin.nodes.buffer.slice.input.to", "Fine" }, + { "hex.builtin.nodes.buffer.slice.output", "Output" }, + { "hex.builtin.nodes.buffer.repeat", "Ripetere" }, + { "hex.builtin.nodes.buffer.repeat.header", "Riperti buffer" }, + { "hex.builtin.nodes.buffer.repeat.input.buffer", "Input" }, + { "hex.builtin.nodes.buffer.repeat.input.count", "Contare" }, + { "hex.builtin.nodes.buffer.repeat.output", "Output" }, + { "hex.builtin.nodes.control_flow", "Controlla Flusso" }, { "hex.builtin.nodes.control_flow.if", "Se" }, { "hex.builtin.nodes.control_flow.if.header", "Se" },