197 if (cards_in_category.empty()) {
198 ImGui::MenuItem(
"(No cards registered)",
nullptr,
false,
false);
202 for (
const auto& info : cards_in_category) {
203 if (!info.visibility_flag)
continue;
205 std::string label = info.icon.empty()
207 : info.icon +
" " + info.display_name;
209 bool visible = *info.visibility_flag;
211 if (ImGui::MenuItem(label.c_str(),
212 info.shortcut_hint.empty() ?
nullptr : info.shortcut_hint.c_str(),
267 if (cards_in_category.empty()) {
272 ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyleColorVec4(ImGuiCol_Button));
273 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyleColorVec4(ImGuiCol_ButtonHovered));
274 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGui::GetStyleColorVec4(ImGuiCol_ButtonActive));
277 ImGui::OpenPopup(
"CardControlPopup");
280 ImGui::PopStyleColor(3);
282 if (ImGui::IsItemHovered()) {
283 ImGui::SetTooltip(
"%s Card Controls", category.c_str());
287 if (ImGui::BeginPopup(
"CardControlPopup")) {
288 ImGui::TextColored(ImVec4(0.7f, 0.9f, 1.0f, 1.0f),
"%s %s Cards",
292 for (
const auto& info : cards_in_category) {
293 if (!info.visibility_flag)
continue;
295 std::string label = info.icon.empty()
297 : info.icon +
" " + info.display_name;
299 bool visible = *info.visibility_flag;
300 if (ImGui::Checkbox(label.c_str(), &visible)) {
301 *info.visibility_flag = visible;
302 if (visible && info.on_show) {
304 }
else if (!visible && info.on_hide) {
310 if (!info.shortcut_hint.empty()) {
312 ImGui::TextDisabled(
"(%s)", info.shortcut_hint.c_str());
333 if (cards_in_category.empty()) {
338 size_t visible_count = 0;
339 for (
const auto& info : cards_in_category) {
340 if (info.visibility_flag && *info.visibility_flag) {
345 ImGui::TextDisabled(
"%s %zu/%zu",
ICON_MD_DASHBOARD, visible_count, cards_in_category.size());
347 if (ImGui::IsItemHovered()) {
348 ImGui::SetTooltip(
"%s cards: %zu visible, %zu hidden",
349 category.c_str(), visible_count,
350 cards_in_category.size() - visible_count);
355 if (!p_open || !*p_open)
return;
357 ImGui::SetNextWindowSize(ImVec2(800, 600), ImGuiCond_FirstUseEver);
358 ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(),
359 ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
368 static char search_filter[256] =
"";
369 ImGui::SetNextItemWidth(-100);
370 ImGui::InputTextWithHint(
"##CardSearch",
372 search_filter,
sizeof(search_filter));
375 if (ImGui::Button(absl::StrFormat(
"%s Clear",
ICON_MD_CLEAR).c_str())) {
376 search_filter[0] =
'\0';
382 ImGui::Text(
"%s Total Cards: %zu | Visible: %zu",
388 if (ImGui::BeginTabBar(
"CardBrowserTabs")) {
391 if (ImGui::BeginTabItem(absl::StrFormat(
"%s All",
ICON_MD_APPS).c_str())) {
398 std::string tab_label = category;
399 if (ImGui::BeginTabItem(tab_label.c_str())) {
406 if (ImGui::BeginTabItem(absl::StrFormat(
"%s Presets",
ICON_MD_BOOKMARK).c_str())) {
418 const std::string& category_filter) {
419 if (ImGui::BeginTable(
"CardBrowserTable", 4,
420 ImGuiTableFlags_Borders |
421 ImGuiTableFlags_RowBg |
422 ImGuiTableFlags_Resizable |
423 ImGuiTableFlags_ScrollY)) {
425 ImGui::TableSetupColumn(
"Card", ImGuiTableColumnFlags_WidthStretch, 0.4f);
426 ImGui::TableSetupColumn(
"Category", ImGuiTableColumnFlags_WidthStretch, 0.2f);
427 ImGui::TableSetupColumn(
"Shortcut", ImGuiTableColumnFlags_WidthStretch, 0.2f);
428 ImGui::TableSetupColumn(
"Visible", ImGuiTableColumnFlags_WidthFixed, 80.0f);
429 ImGui::TableHeadersRow();
432 std::vector<CardInfo> display_cards;
433 for (
const auto& [
id, info] :
cards_) {
435 if (!category_filter.empty() && info.category != category_filter) {
439 if (search_filter && search_filter[0] !=
'\0') {
440 std::string search_lower = search_filter;
441 std::transform(search_lower.begin(), search_lower.end(),
442 search_lower.begin(), ::tolower);
444 std::string name_lower = info.display_name;
445 std::transform(name_lower.begin(), name_lower.end(),
446 name_lower.begin(), ::tolower);
448 if (name_lower.find(search_lower) == std::string::npos) {
453 display_cards.push_back(info);
457 std::sort(display_cards.begin(), display_cards.end(),
459 if (a.category != b.category) return a.category < b.category;
460 return a.priority < b.priority;
464 for (
const auto& info : display_cards) {
465 ImGui::PushID(info.card_id.c_str());
467 ImGui::TableNextRow();
468 ImGui::TableNextColumn();
471 std::string label = info.icon.empty()
473 : info.icon +
" " + info.display_name;
474 ImGui::Text(
"%s", label.c_str());
476 ImGui::TableNextColumn();
477 ImGui::TextDisabled(
"%s", info.category.c_str());
479 ImGui::TableNextColumn();
480 if (!info.shortcut_hint.empty()) {
481 ImGui::TextDisabled(
"%s", info.shortcut_hint.c_str());
484 ImGui::TableNextColumn();
485 if (info.visibility_flag) {
486 bool visible = *info.visibility_flag;
487 if (ImGui::Checkbox(
"##Visible", &visible)) {
488 *info.visibility_flag = visible;
489 if (visible && info.on_show) {
491 }
else if (!visible && info.on_hide) {
509 static char preset_name[256] =
"";
510 static char preset_desc[512] =
"";
512 ImGui::Text(
"Save Current Layout:");
513 ImGui::InputText(
"Name", preset_name,
sizeof(preset_name));
514 ImGui::InputText(
"Description", preset_desc,
sizeof(preset_desc));
516 if (ImGui::Button(absl::StrFormat(
"%s Save Preset",
ICON_MD_SAVE).c_str())) {
517 if (preset_name[0] !=
'\0') {
519 preset_name[0] =
'\0';
520 preset_desc[0] =
'\0';
525 ImGui::Text(
"Saved Presets:");
529 if (presets.empty()) {
530 ImGui::TextDisabled(
"No presets saved");
532 for (
const auto& preset : presets) {
533 ImGui::PushID(preset.name.c_str());
540 if (ImGui::Button(absl::StrFormat(
"%s Delete",
ICON_MD_DELETE).c_str())) {
547 if (!preset.description.empty()) {
549 ImGui::TextDisabled(
"- %s", preset.description.c_str());
553 ImGui::TextDisabled(
"(%zu cards)", preset.visible_cards.size());