1
0
mirror of synced 2025-01-18 17:14:13 +01:00

ux: Fixed MIME-based pattern loading popup not working properly

Fixed issues addressed in #225
This commit is contained in:
WerWolv 2021-05-18 18:27:36 +02:00
parent 0d11f4460f
commit b6f76ad8ed

View File

@ -143,6 +143,7 @@ namespace hex {
});
preprocessor.addDefaultPragmaHandlers();
this->m_possiblePatternFiles.clear();
std::error_code errorCode;
for (const auto &dir : hex::getPath(ImHexPath::Patterns)) {
@ -294,13 +295,20 @@ namespace hex {
if (ImGui::BeginPopupModal("hex.view.pattern.accept_pattern"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextWrapped("hex.view.pattern.accept_pattern.desc"_lang);
char *entries[this->m_possiblePatternFiles.size()];
std::vector<std::string> entries;
entries.resize(this->m_possiblePatternFiles.size());
for (u32 i = 0; i < this->m_possiblePatternFiles.size(); i++) {
entries[i] = this->m_possiblePatternFiles[i].data();
for (u32 i = 0; i < entries.size(); i++) {
entries[i] = std::filesystem::path(this->m_possiblePatternFiles[i]).filename().string();
}
ImGui::ListBox("hex.view.pattern.accept_pattern.patterns"_lang, &this->m_selectedPatternFile, entries, IM_ARRAYSIZE(entries), 4);
ImGui::ListBox("hex.view.pattern.accept_pattern.patterns"_lang, &this->m_selectedPatternFile, [](void *data, int id, const char** outText) -> bool {
auto &entries = *static_cast<std::vector<std::string>*>(data);
*outText = entries[id].c_str();
return true;
}, &entries, entries.size(), 4);
ImGui::NewLine();
ImGui::Text("hex.view.pattern.accept_pattern.question"_lang);