From 0b3bb271ac40b5f8bcfc5a417d4423e92c4483b1 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 1 Mar 2005 01:12:51 +0000 Subject: [PATCH 1/1] Implement a simple priority system. The priority system is used to determine which screen is shown first if two or more screens have updated information (ie. a group screen is more important than a "today's high scores" screen, which is in turn more important than "today's most chosen songs", as the latter is mainly a curiosity). - Add a get_priority() to GenericScreen, default 0. - Implement get_priority() for GroupScreen and Top10ScoreScreen, set to 10 and 5 resp. - Make RotateScreen automatically pick the screen with the highest priority if two or more have forced updates. --- bigscreen/groupscreen.cpp | 4 ++++ bigscreen/groupscreen.h | 1 + bigscreen/rotatescreen.cpp | 4 +++- bigscreen/screen.cpp | 4 ++++ bigscreen/screen.h | 1 + bigscreen/top10scorescreen.cpp | 4 ++++ bigscreen/top10scorescreen.h | 1 + 7 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bigscreen/groupscreen.cpp b/bigscreen/groupscreen.cpp index 83a7082..8d408ec 100644 --- a/bigscreen/groupscreen.cpp +++ b/bigscreen/groupscreen.cpp @@ -501,3 +501,7 @@ void GroupScreen::draw(unsigned char *buf) last_text = td; } +int GroupScreen::get_priority() +{ + return 10; +} diff --git a/bigscreen/groupscreen.h b/bigscreen/groupscreen.h index 21ab172..1bff23f 100644 --- a/bigscreen/groupscreen.h +++ b/bigscreen/groupscreen.h @@ -27,6 +27,7 @@ public: bool check_invalidated(); void draw(unsigned char *buf); + int get_priority(); }; #endif /* !defined(_GROUPSCREEN_H) */ diff --git a/bigscreen/rotatescreen.cpp b/bigscreen/rotatescreen.cpp index 275b73e..fcc975c 100644 --- a/bigscreen/rotatescreen.cpp +++ b/bigscreen/rotatescreen.cpp @@ -103,12 +103,14 @@ void RotateScreen::draw(unsigned char *buf) // determine if we want to switch screens unsigned old_current_screen = current_screen; + int priority = -9999; // bah :-P // push any invalidated screen first (for now) for (unsigned i = 0; i < subscreens.size(); ++i) { - if (subscreens[i].screen->check_invalidated()) { + if (subscreens[i].screen->check_invalidated() && subscreens[i].screen->get_priority() > priority) { current_screen = i; force = true; + priority = subscreens[i].screen->get_priority(); } } diff --git a/bigscreen/screen.cpp b/bigscreen/screen.cpp index 850ca94..279d21d 100644 --- a/bigscreen/screen.cpp +++ b/bigscreen/screen.cpp @@ -3,3 +3,7 @@ GenericScreen::GenericScreen() {} GenericScreen::~GenericScreen() {} +int GenericScreen::get_priority() +{ + return 0; +} diff --git a/bigscreen/screen.h b/bigscreen/screen.h index 37edb56..b35e3af 100644 --- a/bigscreen/screen.h +++ b/bigscreen/screen.h @@ -10,6 +10,7 @@ public: virtual ~GenericScreen(); virtual bool check_invalidated() = 0; virtual void draw(unsigned char *buf) = 0; + virtual int get_priority(); }; #endif /* !defined(_SCREEN_H) */ diff --git a/bigscreen/top10scorescreen.cpp b/bigscreen/top10scorescreen.cpp index 2db7bfd..6ae58fd 100644 --- a/bigscreen/top10scorescreen.cpp +++ b/bigscreen/top10scorescreen.cpp @@ -87,3 +87,7 @@ void Top10ScoreScreen::draw(unsigned char *buf) std::copy(scores.begin(), scores.end(), std::inserter(seen_topscore, seen_topscore.end())); } +int Top10ScoreScreen::get_priority() +{ + return 5; +} diff --git a/bigscreen/top10scorescreen.h b/bigscreen/top10scorescreen.h index 143c291..2a32901 100644 --- a/bigscreen/top10scorescreen.h +++ b/bigscreen/top10scorescreen.h @@ -23,6 +23,7 @@ public: bool check_invalidated(); void draw(unsigned char *buf); + int get_priority(); }; #endif /* !defined(_TOP10SCORESCREEN_H) */ -- 2.39.2