diff options
author | Aki <please@ignore.pl> | 2022-05-21 16:56:51 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-05-21 16:56:51 +0200 |
commit | ecf2f58b9d50c8cc6f29e76076888843e4fa4228 (patch) | |
tree | ce3114fd9bc9d5a8335f88634c3392eefb16328e | |
parent | 15ba7976d44eefb5db43db95c99c868b1f119636 (diff) | |
download | derelict-ecf2f58b9d50c8cc6f29e76076888843e4fa4228.zip derelict-ecf2f58b9d50c8cc6f29e76076888843e4fa4228.tar.gz derelict-ecf2f58b9d50c8cc6f29e76076888843e4fa4228.tar.bz2 |
Simplified active label detection
-rw-r--r-- | View.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
@@ -66,19 +66,14 @@ View::update(const float dt) } std::sort(m_labels.begin(), m_labels.end(), [](auto& a, auto& b){ return a.depth > b.depth; }); m_active = nullptr; - for (auto& label : m_labels) { + std::for_each(m_labels.rbegin(), m_labels.rend(), [this](auto& label) { if (label.hover) { - if (m_active) { - if (label.depth < m_active->depth) - m_active = &label; - } + if (m_active) + label.hover = false; else m_active = &label; - label.hover = false; } - } - if (m_active) - m_active->hover = true; + }); } |