Implemented mirroring in Sprite, so that now it's possible to adjust left offsets.
[supertux.git] / lib / gui / menu.cpp
index 28e6eff..fcd60a4 100644 (file)
@@ -462,10 +462,9 @@ Menu::action()
     // FIXME: wtf?! having a hack to avoid horizontal lines...
     // Elegant solution would be to check for horizontal lines, right
     // when it was asked to move menu up and down
-    MenuItem& new_item = item[active_item];
-    if(new_item.kind == MN_DEACTIVE ||
-       new_item.kind == MN_LABEL ||
-       new_item.kind == MN_HL)
+    if(item[active_item].kind == MN_DEACTIVE ||
+       item[active_item].kind == MN_LABEL ||
+       item[active_item].kind == MN_HL)
       {
       // Skip the horzontal line item
       if (menuaction != MENU_ACTION_UP && menuaction != MENU_ACTION_DOWN)
@@ -770,7 +769,7 @@ Menu::event(SDL_Event& event)
             /* An International Character. */
           }
 
-        if(item[active_item].kind == MN_CONTROLFIELD_KB)
+        if(item.size() > 0 && item[active_item].kind == MN_CONTROLFIELD_KB)
           {
             if(key == SDLK_ESCAPE)
               {
@@ -798,7 +797,7 @@ Menu::event(SDL_Event& event)
             menuaction = MENU_ACTION_RIGHT;
             break;
           case SDLK_SPACE:
-            if(item[active_item].kind == MN_TEXTFIELD)
+            if(item.size() > 0 && item[active_item].kind == MN_TEXTFIELD)
               {
                 menuaction = MENU_ACTION_INPUT;
                 mn_input_char = ' ';
@@ -847,8 +846,15 @@ Menu::event(SDL_Event& event)
             joystick_timer.stop();
         }
       break;
+    case SDL_JOYHATMOTION:
+      if(event.jhat.value & SDL_HAT_UP) {
+          menuaction = MENU_ACTION_UP;
+      } else if(event.jhat.value & SDL_HAT_DOWN) {
+          menuaction = MENU_ACTION_DOWN;
+      }
+      break;
     case  SDL_JOYBUTTONDOWN:
-      if (item[active_item].kind == MN_CONTROLFIELD_JS)
+      if (item.size() > 0 && item[active_item].kind == MN_CONTROLFIELD_JS)
         {
           // FIXME: This next line does nothing useable, right?
           // *item[active_item].int_p = key;