1
0
mirror of synced 2024-11-28 17:40:51 +01:00

feat: Allow custom data inspector rows to be edited

This commit is contained in:
WerWolv 2023-03-20 08:30:34 +01:00
parent c9342d90fb
commit 677c989664

View File

@ -119,20 +119,28 @@ namespace hex::plugin::builtin {
if (pattern->getVisibility() == pl::ptrn::Visibility::Hidden)
continue;
auto formatWriteFunction = pattern->getWriteFormatterFunction();
std::optional<ContentRegistry::DataInspector::impl::EditingFunction> editingFunction;
if (!formatWriteFunction.empty()) {
editingFunction = [formatWriteFunction, &pattern](const std::string &value, std::endian) -> std::vector<u8> {
pattern->setValue(value);
};
}
this->m_workData.push_back({
pattern->getDisplayName(),
[value = pattern->getFormattedValue()]() {
ImGui::TextUnformatted(value.c_str());
return value;
},
std::nullopt,
editingFunction,
false
});
}
} else {
const auto& error = runtime.getError();
log::error("Failed to execute inspectors.hexpat!");
log::error("Failed to execute custom inspector file '{}'!", wolv::util::toUTF8String(filePath.path()));
if (error.has_value())
log::error("{}", error.value().what());
}