1
0
mirror of synced 2024-11-12 02:00:52 +01:00

nodes: Fixed a few issues with locatizations, errors and overlays

This commit is contained in:
WerWolv 2022-10-22 23:17:18 +02:00
parent 3b7f2fbdaa
commit 858e1aed3b
7 changed files with 22 additions and 17 deletions

View File

@ -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<i64 *>(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<u8> &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<u8> 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<u8> 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<u8> &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;

View File

@ -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();

View File

@ -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" },

View File

@ -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", "制御フロー" },

View File

@ -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", "데이터 플로우" },

View File

@ -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" },

View File

@ -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" },