mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-24 19:27:27 +00:00
VideoCommon: add graphics mod editor control for displaying a selection of tags to choose from
This commit is contained in:
parent
6853292fd3
commit
ccfccaada8
2 changed files with 95 additions and 0 deletions
|
@ -0,0 +1,77 @@
|
|||
// Copyright 2024 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "VideoCommon/GraphicsModEditor/Controls/TagSelectionWindow.h"
|
||||
|
||||
#include "VideoCommon/GraphicsModEditor/Controls/MiscControls.h"
|
||||
|
||||
namespace GraphicsModEditor::Controls
|
||||
{
|
||||
bool TagSelectionWindow(std::string_view popup_name, EditorState* state, std::string* chosen_tag)
|
||||
{
|
||||
if (!state) [[unlikely]]
|
||||
return false;
|
||||
if (!chosen_tag) [[unlikely]]
|
||||
return false;
|
||||
|
||||
if (!ImGui::IsPopupOpen(popup_name.data()))
|
||||
{
|
||||
ImGui::OpenPopup(popup_name.data());
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
const ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
||||
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||
if (ImGui::BeginPopupModal(popup_name.data(), nullptr))
|
||||
{
|
||||
const u32 column_count = 5;
|
||||
u32 current_columns = 0;
|
||||
u32 tags_displayed = 0;
|
||||
|
||||
if (ImGui::BeginTable("TagSelectionPopup", column_count))
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
for (const auto& [tag_name, tag] : state->m_editor_data.m_tags)
|
||||
{
|
||||
tags_displayed++;
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
const bool tag_clicked = ColorButton(
|
||||
tag.m_name.c_str(), tag_size, ImVec4{tag.m_color.x, tag.m_color.y, tag.m_color.z, 1});
|
||||
if (!tag.m_description.empty())
|
||||
ImGui::SetItemTooltip("%s", tag.m_description.c_str());
|
||||
if (tag_clicked)
|
||||
{
|
||||
*chosen_tag = tag.m_name;
|
||||
changed = true;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
current_columns++;
|
||||
if (current_columns == column_count)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
current_columns = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::Button("Cancel", ImVec2(120, 0)))
|
||||
{
|
||||
changed = true;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
if (tags_displayed == 0)
|
||||
{
|
||||
ImGui::Text("No tags found");
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
} // namespace GraphicsModEditor::Controls
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright 2024 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "imgui.h"
|
||||
|
||||
#include "VideoCommon/GraphicsModEditor/EditorState.h"
|
||||
|
||||
namespace GraphicsModEditor::Controls
|
||||
{
|
||||
static inline ImVec2 tag_size = ImVec2(175, 35);
|
||||
|
||||
bool TagSelectionWindow(std::string_view popup_name, EditorState* state, std::string* chosen_tag);
|
||||
} // namespace GraphicsModEditor::Controls
|
Loading…
Add table
Add a link
Reference in a new issue