]> git.sesse.net Git - ccbs/commitdiff
Implement a simple priority system.
authorSteinar H. Gunderson <sesse@samfundet.no>
Tue, 1 Mar 2005 01:12:51 +0000 (01:12 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Tue, 1 Mar 2005 01:12:51 +0000 (01:12 +0000)
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
bigscreen/groupscreen.h
bigscreen/rotatescreen.cpp
bigscreen/screen.cpp
bigscreen/screen.h
bigscreen/top10scorescreen.cpp
bigscreen/top10scorescreen.h

index 83a70820ce176b4c1f2ba2383d50e0a7b446b8d3..8d408ec50358b56db1f560f425ebbbd938f9da21 100644 (file)
@@ -501,3 +501,7 @@ void GroupScreen::draw(unsigned char *buf)
        last_text = td;
 }
 
        last_text = td;
 }
 
+int GroupScreen::get_priority()
+{
+       return 10;
+}
index 21ab17248e2bb4ab54056e9778d12a63f3d422a2..1bff23fdb57607009fe3e3def8a1a0083ceb08ad 100644 (file)
@@ -27,6 +27,7 @@ public:
 
        bool check_invalidated();
        void draw(unsigned char *buf);
 
        bool check_invalidated();
        void draw(unsigned char *buf);
+       int get_priority();
 };
 
 #endif /* !defined(_GROUPSCREEN_H) */
 };
 
 #endif /* !defined(_GROUPSCREEN_H) */
index 275b73ed0820c8806b9b8999ca0688528b929c47..fcc975cbc1ba54a86fa15972a6a5064fe655253c 100644 (file)
@@ -103,12 +103,14 @@ void RotateScreen::draw(unsigned char *buf)
                // determine if we want to switch screens
        
                unsigned old_current_screen = current_screen;
                // 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) {
                
                // 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;
                                current_screen = i;
                                force = true;
+                               priority = subscreens[i].screen->get_priority();
                        }
                }
 
                        }
                }
 
index 850ca949a10d7b2c212c4fff992952e587cc2784..279d21d5d979cd11685ff25c9b41c2dda410ed6b 100644 (file)
@@ -3,3 +3,7 @@
 GenericScreen::GenericScreen() {}
 GenericScreen::~GenericScreen() {}
 
 GenericScreen::GenericScreen() {}
 GenericScreen::~GenericScreen() {}
 
+int GenericScreen::get_priority()
+{
+       return 0;
+}
index 37edb563bab6bc4a7c0537ded8cc16c1e4bf9433..b35e3af06379e0bd46594ee2d45b86c228eb57df 100644 (file)
@@ -10,6 +10,7 @@ public:
        virtual ~GenericScreen();
        virtual bool check_invalidated() = 0;
        virtual void draw(unsigned char *buf) = 0;
        virtual ~GenericScreen();
        virtual bool check_invalidated() = 0;
        virtual void draw(unsigned char *buf) = 0;
+       virtual int get_priority();
 };
 
 #endif /* !defined(_SCREEN_H) */
 };
 
 #endif /* !defined(_SCREEN_H) */
index 2db7bfd4ecc3c167e309d9c42a20c82db235446a..6ae58fd1d9d5c7b970253e9dc20be79a29434678 100644 (file)
@@ -87,3 +87,7 @@ void Top10ScoreScreen::draw(unsigned char *buf)
        std::copy(scores.begin(), scores.end(), std::inserter(seen_topscore, seen_topscore.end()));
 }
 
        std::copy(scores.begin(), scores.end(), std::inserter(seen_topscore, seen_topscore.end()));
 }
 
+int Top10ScoreScreen::get_priority()
+{
+       return 5;
+}
index 143c291a97da62303f66cc7c2c01f38d017fcb14..2a32901b285abb12f84df1a922b28c0b5bf4dede 100644 (file)
@@ -23,6 +23,7 @@ public:
 
        bool check_invalidated();
        void draw(unsigned char *buf);
 
        bool check_invalidated();
        void draw(unsigned char *buf);
+       int get_priority();
 };
 
 #endif /* !defined(_TOP10SCORESCREEN_H) */
 };
 
 #endif /* !defined(_TOP10SCORESCREEN_H) */