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

impr: Added path tooltips to accept pattern popup

This commit is contained in:
WerWolv 2023-04-10 01:46:55 +02:00
parent dc77d81e1b
commit 391c8acfe4
2 changed files with 14 additions and 3 deletions

View File

@ -37,7 +37,9 @@ namespace hex::plugin::builtin {
else
ImGui::TextFormattedCentered("{}", "hex.builtin.popup.docs_question.prompt"_lang);
} else {
int id = 1;
for (auto &[type, text] : this->m_answer) {
ImGui::PushID(id);
switch (type) {
case TextBlockType::Text:
ImGui::TextFormattedWrapped("{}", text);
@ -54,6 +56,9 @@ namespace hex::plugin::builtin {
break;
}
ImGui::PopID();
id += 1;
}
}
} else {

View File

@ -47,6 +47,8 @@ namespace hex::plugin::builtin {
PopupAcceptPattern(ViewPatternEditor *view) : Popup("hex.builtin.view.pattern_editor.accept_pattern"), m_view(view) {}
void drawContent() override {
auto provider = ImHexApi::Provider::get();
ImGui::TextFormattedWrapped("{}", static_cast<const char *>("hex.builtin.view.pattern_editor.accept_pattern.desc"_lang));
std::vector<std::string> entries;
@ -59,8 +61,14 @@ namespace hex::plugin::builtin {
if (ImGui::BeginListBox("##patterns_accept", ImVec2(-FLT_MIN, 0))) {
u32 index = 0;
for (auto &path : this->m_view->m_possiblePatternFiles) {
if (ImGui::Selectable(wolv::util::toUTF8String(path.filename()).c_str(), index == this->m_view->m_selectedPatternFile))
if (ImGui::Selectable(wolv::util::toUTF8String(path.filename()).c_str(), index == this->m_view->m_selectedPatternFile, ImGuiSelectableFlags_DontClosePopups))
this->m_view->m_selectedPatternFile = index;
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0))
this->m_view->loadPatternFile(this->m_view->m_possiblePatternFiles[this->m_view->m_selectedPatternFile], provider);
ImGui::InfoTooltip(wolv::util::toUTF8String(path).c_str());
index++;
}
@ -70,8 +78,6 @@ namespace hex::plugin::builtin {
ImGui::NewLine();
ImGui::TextUnformatted("hex.builtin.view.pattern_editor.accept_pattern.question"_lang);
auto provider = ImHexApi::Provider::get();
confirmButtons(
"hex.builtin.common.yes"_lang, "hex.builtin.common.no"_lang, [this, provider] {
this->m_view->loadPatternFile(this->m_view->m_possiblePatternFiles[this->m_view->m_selectedPatternFile], provider);