impr: Improved types used in provider functions

This commit is contained in:
WerWolv
2023-06-04 10:42:11 +02:00
parent 25476d4e1e
commit 07aabe8efa
18 changed files with 50 additions and 21 deletions

View File

@@ -270,7 +270,7 @@ namespace hex::plugin::builtin {
return wolv::util::toUTF8String(this->m_path);
}
std::vector<std::pair<std::string, std::string>> DiskProvider::getDataDescription() const {
std::vector<DiskProvider::Description> DiskProvider::getDataDescription() const {
return {
{ "hex.builtin.provider.disk.selected_disk"_lang, wolv::util::toUTF8String(this->m_path) },
{ "hex.builtin.provider.disk.disk_size"_lang, hex::toByteString(this->m_diskSize) },

View File

@@ -144,8 +144,8 @@ namespace hex::plugin::builtin {
return wolv::util::toUTF8String(this->m_path.filename());
}
std::vector<std::pair<std::string, std::string>> FileProvider::getDataDescription() const {
std::vector<std::pair<std::string, std::string>> result;
std::vector<FileProvider::Description> FileProvider::getDataDescription() const {
std::vector<Description> result;
result.emplace_back("hex.builtin.provider.file.path"_lang, wolv::util::toUTF8String(this->m_path));
result.emplace_back("hex.builtin.provider.file.size"_lang, hex::toByteString(this->getActualSize()));
@@ -184,7 +184,7 @@ namespace hex::plugin::builtin {
});
}
std::vector<std::pair<std::string, std::function<void()>>> FileProvider::getMenuEntries(){
std::vector<FileProvider::MenuEntry> FileProvider::getMenuEntries(){
return {
{"hex.builtin.provider.file.menu.open_folder"_lang, [path = this->m_path] {
fs::openFolderWithSelectionExternal(path);

View File

@@ -238,7 +238,7 @@ namespace hex::plugin::builtin {
return hex::format("hex.builtin.provider.gdb.name"_lang, address, port);
}
std::vector<std::pair<std::string, std::string>> GDBProvider::getDataDescription() const {
std::vector<GDBProvider::Description> GDBProvider::getDataDescription() const {
return {
{"hex.builtin.provider.gdb.server"_lang, hex::format("{}:{}", this->m_ipAddress, this->m_port)},
};

View File

@@ -224,6 +224,15 @@ namespace hex::plugin::builtin {
return hex::format("hex.builtin.provider.intel_hex.name"_lang, wolv::util::toUTF8String(this->m_sourceFilePath.filename()));
}
[[nodiscard]] std::vector<IntelHexProvider::Description> IntelHexProvider::getDataDescription() const {
std::vector<Description> result;
result.emplace_back("hex.builtin.provider.file.path"_lang, wolv::util::toUTF8String(this->m_sourceFilePath));
result.emplace_back("hex.builtin.provider.file.size"_lang, hex::toByteString(this->getActualSize()));
return result;
}
bool IntelHexProvider::handleFilePicker() {
auto picked = fs::openFileBrowser(fs::DialogMode::Open, {
{ "Intel Hex File", "hex" },

View File

@@ -202,6 +202,16 @@ namespace hex::plugin::builtin {
return hex::format("hex.builtin.provider.motorola_srec.name"_lang, wolv::util::toUTF8String(this->m_sourceFilePath.filename()));
}
[[nodiscard]] std::vector<MotorolaSRECProvider::Description> MotorolaSRECProvider::getDataDescription() const {
std::vector<Description> result;
result.emplace_back("hex.builtin.provider.file.path"_lang, wolv::util::toUTF8String(this->m_sourceFilePath));
result.emplace_back("hex.builtin.provider.file.size"_lang, hex::toByteString(this->getActualSize()));
return result;
}
bool MotorolaSRECProvider::handleFilePicker() {
auto picked = fs::openFileBrowser(fs::DialogMode::Open, {
{ "Motorola SREC File", "s19" },

View File

@@ -286,9 +286,9 @@ namespace hex::plugin::builtin {
}
if (ImGui::BeginPopup(popupID.c_str())) {
for (auto p : tabProvider->getMenuEntries()) {
if (ImGui::MenuItem(p.first.c_str())) {
p.second();
for (const auto &menuEntry : tabProvider->getMenuEntries()) {
if (ImGui::MenuItem(menuEntry.name.c_str())) {
menuEntry.callback();
}
}
ImGui::EndPopup();

View File

@@ -50,7 +50,6 @@ namespace hex::plugin::builtin {
// Attach the newly created window to the cursor, so it gets dragged around
GImGui->MovingWindow = ImGui::GetCurrentWindow();
GImGui->ActiveId = GImGui->MovingWindow->MoveId;
ImGui::DockContextQueueUndockWindow(GImGui, GImGui->MovingWindow);
}
}
ImGui::End();