mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
impr: Improved types used in provider functions
This commit is contained in:
@@ -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) },
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)},
|
||||
};
|
||||
|
||||
@@ -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" },
|
||||
|
||||
@@ -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" },
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user