ui: Unify snapshot filter and title name search box

This commit is contained in:
Matt Borgerson 2023-06-03 22:22:24 -07:00 committed by mborgerson
parent 4104b3d540
commit 458de1758a
2 changed files with 5 additions and 8 deletions

View File

@ -930,14 +930,12 @@ void MainMenuSnapshotsView::Draw()
Load();
SectionTitle("Snapshots");
ImGui::Checkbox("Filter by current title", &g_config.general.snapshots.filter_current_game);
ImGui::InputTextWithHint("##search", "Filter by name...", &m_search_buf, ImGuiInputTextFlags_CallbackEdit,
ImGui::InputTextWithHint("##search", "Search...", &m_search_buf, ImGuiInputTextFlags_CallbackEdit,
&MainMenuSnapshotsViewUpdateSearchBox, this);
ImGui::InputTextWithHint("##create", "Create new snapshot", &m_create_buf);
bool snapshot_with_create_name_exists = false;
for (int i = 0; i < m_snapshots_len; ++i) {
if (g_strcmp0(m_create_buf.c_str(), m_snapshots[i].name) == 0) {
if (g_strcmp0(m_search_buf.c_str(), m_snapshots[i].name) == 0) {
snapshot_with_create_name_exists = true;
break;
}
@ -945,12 +943,12 @@ void MainMenuSnapshotsView::Draw()
ImGui::SameLine();
if (ImGui::Button(snapshot_with_create_name_exists ? "Replace" : "Create")) {
xemu_snapshots_save(m_create_buf.empty() ? NULL : m_create_buf.c_str(), NULL);
m_create_buf.clear();
xemu_snapshots_save(m_search_buf.empty() ? NULL : m_search_buf.c_str(), NULL);
m_search_buf.clear();
}
if (snapshot_with_create_name_exists && ImGui::IsItemHovered()) {
ImGui::SetTooltip("A snapshot with the name \"%s\" already exists. This button will overwrite the existing snapshot.", m_create_buf.c_str());
ImGui::SetTooltip("A snapshot with the name \"%s\" already exists. This button will overwrite the existing snapshot.", m_search_buf.c_str());
}
for (int i = m_snapshots_len - 1; i >= 0; i--) {

View File

@ -110,7 +110,6 @@ protected:
uint32_t m_current_title_id;
char *m_current_title_name;
std::string m_search_buf;
std::string m_create_buf;
bool m_load_failed;
private: