Re-issue ui hint if hint string changed

This commit is contained in:
Nikita Lisitsa 2022-03-30 09:52:33 +03:00
parent b6ddd70989
commit 02dbdccf0d

View file

@ -61,7 +61,7 @@ namespace psemek::ui
float hint_timer = 0.f;
util::function<void(element *)> on_hint;
element * hinted_element = nullptr;
bool hint_called = false;
std::optional<std::string> hint_called = std::nullopt;
impl(async::event_loop * loop);
@ -201,7 +201,7 @@ namespace psemek::ui
if (impl().hint_called && impl().on_hint)
impl().on_hint(nullptr);
impl().hint_timer = 0.f;
impl().hint_called = false;
impl().hint_called = std::nullopt;
}
impl().hinted_element = new_hinted_element;
@ -227,14 +227,14 @@ namespace psemek::ui
{
impl().update(dt);
if (impl().hinted_element && !impl().hint_called)
if (impl().hinted_element && (!impl().hint_called || *impl().hint_called != *impl().hinted_element->hint()))
{
impl().hint_timer += dt;
if (impl().hint_timer >= impl().hint_delay)
{
if (impl().on_hint)
impl().on_hint(impl().hinted_element);
impl().hint_called = true;
impl().hint_called = *impl().hinted_element->hint();
}
}
}