From eec83198b5dfdfe9a0db71b410383697eb58930c Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Wed, 24 Jul 2024 19:47:52 +0200 Subject: app: add progress bar for turn order --- core/src/turn_order.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'core/src') diff --git a/core/src/turn_order.cpp b/core/src/turn_order.cpp index 234f394..835baab 100644 --- a/core/src/turn_order.cpp +++ b/core/src/turn_order.cpp @@ -56,6 +56,11 @@ namespace turns::core return m_is_running.get_proxy(); } + auto turn_order::progress() const -> Glib::PropertyProxy_ReadOnly + { + return m_progress.get_proxy(); + } + auto turn_order::round_number() const -> Glib::PropertyProxy_ReadOnly { return m_round_number.get_proxy(); @@ -85,6 +90,7 @@ namespace turns::core m_has_previous = false; m_active.reset(); m_round_number = invalid_round_number; + m_progress = 0; auto old_size = get_n_items(); m_data.clear(); @@ -100,6 +106,8 @@ namespace turns::core m_data[old_active]->is_active() = false; m_data[*m_active]->is_active() = true; + m_progress = (static_cast(*m_active) + 1) / get_n_items(); + if (m_active == 0) { m_round_number = m_round_number + 1; @@ -120,6 +128,8 @@ namespace turns::core m_data[old_active]->is_active() = false; m_data[*m_active]->is_active() = true; + m_progress = (static_cast(*m_active) + 1) / get_n_items(); + if (m_active == 0 && m_round_number > 0) { m_round_number = m_round_number - 1; @@ -156,11 +166,14 @@ namespace turns::core m_round_number = 0; } m_is_running = true; + + m_progress = (static_cast(*m_active) + 1) / get_n_items(); } auto turn_order::stop() -> void { m_is_running = false; + m_progress = 0; } /** ListModel implementation */ -- cgit v1.2.3