1
0
mirror of synced 2024-11-28 09:30:51 +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,12 +142,15 @@ namespace hex {
}
void TutorialManager::drawHighlights() {
if (s_helpHoverActive && s_hoveredId != 0) {
ImGui::GetForegroundDrawList()->AddRectFilled(s_hoveredRect.Min, s_hoveredRect.Max, 0x30FFFFFF);
if (s_helpHoverActive) {
const auto &drawList = ImGui::GetForegroundDrawList();
drawList->AddText(ImGui::GetMousePos() + scaled({ 10, -5, }), ImGui::GetColorU32(ImGuiCol_Text), "?");
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
s_helpHoverActive = false;
const bool mouseClicked = ImGui::IsMouseClicked(ImGuiMouseButton_Left);
if (s_hoveredId != 0) {
drawList->AddRectFilled(s_hoveredRect.Min, s_hoveredRect.Max, 0x30FFFFFF);
if (mouseClicked) {
auto it = s_interactiveHelpItems->find(s_hoveredId);
if (it != s_interactiveHelpItems->end()) {
it->second();
@ -158,6 +161,11 @@ namespace hex {
s_hoveredRect = {};
}
if (mouseClicked || ImGui::IsKeyPressed(ImGuiKey_Escape)) {
s_helpHoverActive = false;
}
}
for (const auto &[rect, unlocalizedText] : *s_highlightDisplays) {
const auto drawList = ImGui::GetForegroundDrawList();