Added scrolling to the menu (a little crude, but working)
authorIngo Ruhnke <grumbel@gmx.de>
Mon, 5 May 2008 20:08:41 +0000 (20:08 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Mon, 5 May 2008 20:08:41 +0000 (20:08 +0000)
SVN-Revision: 5420

data/images/engine/menu/frame.png
src/gui/menu.cpp

index 9eede6f..0bf5113 100644 (file)
Binary files a/data/images/engine/menu/frame.png and b/data/images/engine/menu/frame.png differ
index ce8ff63..7768934 100644 (file)
@@ -342,6 +342,13 @@ Menu::clear()
 void
 Menu::update()
 {
+  int menu_height = get_height();
+  if (menu_height > SCREEN_HEIGHT)
+    { // Scrolling
+      int scroll_offset = (menu_height - SCREEN_HEIGHT) / 2 + 32;
+      pos_y = SCREEN_HEIGHT/2 - scroll_offset * ((float(active_item) / (items.size()-1)) - 0.5f) * 2.0f;
+    }
+
   effect_progress = (real_time - effect_start_time) * 6.0f;
 
   if(effect_progress >= 1.0f) {