From d6a24cd32a523eed6f69ff1b0a534fc6fffe43bb Mon Sep 17 00:00:00 2001 From: June Date: Sat, 15 Jul 2023 16:23:52 -0700 Subject: [PATCH] add chip description tooltip for systems in new song dialog (#1242) * add chip description tooltip for systems in new song dialog * give BeginTooltip() for chip descriptions its own line in code --- src/gui/newSong.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/gui/newSong.cpp b/src/gui/newSong.cpp index fd7eace75..1b8e57def 100644 --- a/src/gui/newSong.cpp +++ b/src/gui/newSong.cpp @@ -113,7 +113,35 @@ void FurnaceGUI::drawNewSong() { nextDescName=i.name; accepted=true; } + if (ImGui::IsItemHovered()) { + if (ImGui::BeginTooltip()) { + std::map chipCounts; + std::vector chips; + for (FurnaceGUISysDefChip chip: i.orig) { + if (chipCounts.find(chip.sys) == chipCounts.end()) { + chipCounts[chip.sys] = 1; + chips.push_back(chip.sys); + } + else { + chipCounts[chip.sys] += 1; + } + } + int num_chips = chips.size(); + for (int chipIndex = 0; chipIndex < num_chips; chipIndex++) { + DivSystem chip = chips[chipIndex]; + const DivSysDef* sysDef = e->getSystemDef(chip); + ImGui::Text("%s (x%d): ", sysDef->name, chipCounts[chip]); + ImGui::TextWrapped("%s", sysDef->description); + if (chipIndex + 1 < num_chips) { + ImGui::Separator(); + } + } + + ImGui::EndTooltip(); + } + } } + ImGui::EndTable(); }