From 858e1aed3b899a38fca66aca6a21e25c67a910dd Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 22 Oct 2022 23:17:18 +0200 Subject: [PATCH] nodes: Fixed a few issues with locatizations, errors and overlays --- lib/libimhex/source/data_processor/node.cpp | 24 +++++++++---------- .../content/views/view_data_processor.cpp | 10 ++++---- plugins/builtin/source/lang/en_US.cpp | 1 + plugins/builtin/source/lang/ja_JP.cpp | 1 + plugins/builtin/source/lang/ko_KR.cpp | 1 + plugins/builtin/source/lang/pt_BR.cpp | 1 + plugins/builtin/source/lang/zh_TW.cpp | 1 + 7 files changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/libimhex/source/data_processor/node.cpp b/lib/libimhex/source/data_processor/node.cpp index f80d622c0..5d9af5b3b 100644 --- a/lib/libimhex/source/data_processor/node.cpp +++ b/lib/libimhex/source/data_processor/node.cpp @@ -29,7 +29,7 @@ namespace hex::dp { auto &outputData = attribute->getOutputData(); if (!outputData.has_value()) - throw std::runtime_error("No data available at connected attribute"); + throwNodeError("No data available at connected attribute"); return outputData.value(); } @@ -49,10 +49,10 @@ namespace hex::dp { auto &outputData = attribute->getOutputData(); if (!outputData.has_value()) - throw std::runtime_error("No data available at connected attribute"); + throwNodeError("No data available at connected attribute"); if (outputData->size() < sizeof(u64)) - throw std::runtime_error("Not enough data provided for integer"); + throwNodeError("Not enough data provided for integer"); return *reinterpret_cast(outputData->data()); } @@ -72,10 +72,10 @@ namespace hex::dp { auto &outputData = attribute->getOutputData(); if (!outputData.has_value()) - throw std::runtime_error("No data available at connected attribute"); + throwNodeError("No data available at connected attribute"); if (outputData->size() < sizeof(float)) - throw std::runtime_error("Not enough data provided for float"); + throwNodeError("Not enough data provided for float"); float result = 0; std::memcpy(&result, outputData->data(), sizeof(float)); @@ -84,24 +84,24 @@ namespace hex::dp { void Node::setBufferOnOutput(u32 index, const std::vector &data) { if (index >= this->getAttributes().size()) - throw std::runtime_error("Attribute index out of bounds!"); + throwNodeError("Attribute index out of bounds!"); auto &attribute = this->getAttributes()[index]; if (attribute.getIOType() != Attribute::IOType::Out) - throw std::runtime_error("Tried to set output data of an input attribute!"); + throwNodeError("Tried to set output data of an input attribute!"); attribute.getOutputData() = data; } void Node::setIntegerOnOutput(u32 index, i64 integer) { if (index >= this->getAttributes().size()) - throw std::runtime_error("Attribute index out of bounds!"); + throwNodeError("Attribute index out of bounds!"); auto &attribute = this->getAttributes()[index]; if (attribute.getIOType() != Attribute::IOType::Out) - throw std::runtime_error("Tried to set output data of an input attribute!"); + throwNodeError("Tried to set output data of an input attribute!"); std::vector buffer(sizeof(u64), 0); std::memcpy(buffer.data(), &integer, sizeof(u64)); @@ -111,12 +111,12 @@ namespace hex::dp { void Node::setFloatOnOutput(u32 index, float floatingPoint) { if (index >= this->getAttributes().size()) - throw std::runtime_error("Attribute index out of bounds!"); + throwNodeError("Attribute index out of bounds!"); auto &attribute = this->getAttributes()[index]; if (attribute.getIOType() != Attribute::IOType::Out) - throw std::runtime_error("Tried to set output data of an input attribute!"); + throwNodeError("Tried to set output data of an input attribute!"); std::vector buffer(sizeof(float), 0); std::memcpy(buffer.data(), &floatingPoint, sizeof(float)); @@ -126,7 +126,7 @@ namespace hex::dp { void Node::setOverlayData(u64 address, const std::vector &data) { if (this->m_overlay == nullptr) - throw std::runtime_error("Tried setting overlay data on a node that's not the end of a chain!"); + throwNodeError("Tried setting overlay data on a node that's not the end of a chain!"); this->m_overlay->setAddress(address); this->m_overlay->getData() = data; diff --git a/plugins/builtin/source/content/views/view_data_processor.cpp b/plugins/builtin/source/content/views/view_data_processor.cpp index 5fa946cee..87e618b6f 100644 --- a/plugins/builtin/source/content/views/view_data_processor.cpp +++ b/plugins/builtin/source/content/views/view_data_processor.cpp @@ -162,12 +162,12 @@ namespace hex::plugin::builtin { for (u32 i = 0; i < data.endNodes.size(); i++) data.dataOverlays.push_back(ImHexApi::Provider::get()->newOverlay()); + } - u32 overlayIndex = 0; - for (auto endNode : data.endNodes) { - endNode->setCurrentOverlay(data.dataOverlays[overlayIndex]); - overlayIndex++; - } + u32 overlayIndex = 0; + for (auto endNode : data.endNodes) { + endNode->setCurrentOverlay(data.dataOverlays[overlayIndex]); + overlayIndex++; } data.currNodeError.reset(); diff --git a/plugins/builtin/source/lang/en_US.cpp b/plugins/builtin/source/lang/en_US.cpp index bb62de416..8565f568e 100644 --- a/plugins/builtin/source/lang/en_US.cpp +++ b/plugins/builtin/source/lang/en_US.cpp @@ -605,6 +605,7 @@ namespace hex::plugin::builtin { { "hex.builtin.nodes.buffer.slice.input.to", "To" }, { "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.control_flow", "Control flow" }, diff --git a/plugins/builtin/source/lang/ja_JP.cpp b/plugins/builtin/source/lang/ja_JP.cpp index 5af93020b..6b6f5823d 100644 --- a/plugins/builtin/source/lang/ja_JP.cpp +++ b/plugins/builtin/source/lang/ja_JP.cpp @@ -607,6 +607,7 @@ namespace hex::plugin::builtin { { "hex.builtin.nodes.buffer.slice.input.to", "To" }, { "hex.builtin.nodes.buffer.repeat", "繰り返し" }, { "hex.builtin.nodes.buffer.repeat.header", "バッファを繰り返し" }, + //{ "hex.builtin.nodes.buffer.repeat.input.buffer", "Input" }, { "hex.builtin.nodes.buffer.repeat.input.count", "カウント" }, { "hex.builtin.nodes.control_flow", "制御フロー" }, diff --git a/plugins/builtin/source/lang/ko_KR.cpp b/plugins/builtin/source/lang/ko_KR.cpp index 48b4da3cc..5b1ff6a81 100644 --- a/plugins/builtin/source/lang/ko_KR.cpp +++ b/plugins/builtin/source/lang/ko_KR.cpp @@ -604,6 +604,7 @@ namespace hex::plugin::builtin { { "hex.builtin.nodes.buffer.slice.input.to", "끝" }, { "hex.builtin.nodes.buffer.repeat", "출력" }, { "hex.builtin.nodes.buffer.repeat.header", "버퍼 반복" }, + //{ "hex.builtin.nodes.buffer.repeat.input.buffer", "Input" }, { "hex.builtin.nodes.buffer.repeat.input.count", "개수" }, { "hex.builtin.nodes.control_flow", "데이터 플로우" }, diff --git a/plugins/builtin/source/lang/pt_BR.cpp b/plugins/builtin/source/lang/pt_BR.cpp index a0c9a373c..26b27e5bc 100644 --- a/plugins/builtin/source/lang/pt_BR.cpp +++ b/plugins/builtin/source/lang/pt_BR.cpp @@ -603,6 +603,7 @@ namespace hex::plugin::builtin { { "hex.builtin.nodes.buffer.slice.input.to", "Para" }, { "hex.builtin.nodes.buffer.repeat", "Repetir" }, { "hex.builtin.nodes.buffer.repeat.header", "Repetir buffer" }, + //{ "hex.builtin.nodes.buffer.repeat.input.buffer", "Input" }, { "hex.builtin.nodes.buffer.repeat.input.count", "Contar" }, { "hex.builtin.nodes.control_flow", "Control flow" }, diff --git a/plugins/builtin/source/lang/zh_TW.cpp b/plugins/builtin/source/lang/zh_TW.cpp index 6fc99c6f5..24034ec2c 100644 --- a/plugins/builtin/source/lang/zh_TW.cpp +++ b/plugins/builtin/source/lang/zh_TW.cpp @@ -603,6 +603,7 @@ namespace hex::plugin::builtin { { "hex.builtin.nodes.buffer.slice.input.to", "到" }, { "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.control_flow", "Control flow" },