ux: Fixed MIME-based pattern loading popup not working properly
Fixed issues addressed in #225
This commit is contained in:
parent
0d11f4460f
commit
b6f76ad8ed
@ -143,6 +143,7 @@ namespace hex {
|
|||||||
});
|
});
|
||||||
preprocessor.addDefaultPragmaHandlers();
|
preprocessor.addDefaultPragmaHandlers();
|
||||||
|
|
||||||
|
this->m_possiblePatternFiles.clear();
|
||||||
|
|
||||||
std::error_code errorCode;
|
std::error_code errorCode;
|
||||||
for (const auto &dir : hex::getPath(ImHexPath::Patterns)) {
|
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)) {
|
if (ImGui::BeginPopupModal("hex.view.pattern.accept_pattern"_lang, nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
ImGui::TextWrapped("hex.view.pattern.accept_pattern.desc"_lang);
|
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++) {
|
for (u32 i = 0; i < entries.size(); i++) {
|
||||||
entries[i] = this->m_possiblePatternFiles[i].data();
|
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::NewLine();
|
||||||
ImGui::Text("hex.view.pattern.accept_pattern.question"_lang);
|
ImGui::Text("hex.view.pattern.accept_pattern.question"_lang);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user