1
0
mirror of synced 2025-02-16 10:32:35 +01:00

impr: Better UI/UX for interactive help

This commit is contained in:
WerWolv 2024-06-24 23:01:46 +02:00
parent 1f27530241
commit 91a0be2d78

View File

@ -142,20 +142,28 @@ namespace hex {
} }
void TutorialManager::drawHighlights() { void TutorialManager::drawHighlights() {
if (s_helpHoverActive && s_hoveredId != 0) { if (s_helpHoverActive) {
ImGui::GetForegroundDrawList()->AddRectFilled(s_hoveredRect.Min, s_hoveredRect.Max, 0x30FFFFFF); const auto &drawList = ImGui::GetForegroundDrawList();
drawList->AddText(ImGui::GetMousePos() + scaled({ 10, -5, }), ImGui::GetColorU32(ImGuiCol_Text), "?");
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) { const bool mouseClicked = ImGui::IsMouseClicked(ImGuiMouseButton_Left);
s_helpHoverActive = false; if (s_hoveredId != 0) {
drawList->AddRectFilled(s_hoveredRect.Min, s_hoveredRect.Max, 0x30FFFFFF);
auto it = s_interactiveHelpItems->find(s_hoveredId); if (mouseClicked) {
if (it != s_interactiveHelpItems->end()) { auto it = s_interactiveHelpItems->find(s_hoveredId);
it->second(); if (it != s_interactiveHelpItems->end()) {
it->second();
}
} }
s_hoveredId = 0;
s_hoveredRect = {};
} }
s_hoveredId = 0; if (mouseClicked || ImGui::IsKeyPressed(ImGuiKey_Escape)) {
s_hoveredRect = {}; s_helpHoverActive = false;
}
} }
for (const auto &[rect, unlocalizedText] : *s_highlightDisplays) { for (const auto &[rect, unlocalizedText] : *s_highlightDisplays) {