Added removing of slots when Delete is pressed.
authorRicardo Cruz <rick2@aeiou.pt>
Thu, 29 Apr 2004 10:34:45 +0000 (10:34 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Thu, 29 Apr 2004 10:34:45 +0000 (10:34 +0000)
SVN-Revision: 833

src/menu.cpp
src/menu.h
src/title.cpp

index d838269..43083fe 100644 (file)
@@ -644,6 +644,11 @@ Menu::get_item_by_id(int id)
   return dummyitem;
 }
 
+int Menu::get_active_item_id()
+{
+return item[active_item].id;
+}
+
 bool
 Menu::isToggled(int id)
 {
index 60d6205..52aa6e1 100644 (file)
@@ -173,6 +173,8 @@ public:
   MenuItem& get_item(int index) { return item[index]; }
   MenuItem& get_item_by_id(int id);
 
+  int get_active_item_id();
+
   bool isToggled(int id);
 
   void Menu::get_controlfield_key_into_input(MenuItem *item);
index d3416c5..26d23dc 100644 (file)
@@ -337,7 +337,26 @@ void title(void)
             }
           else if(menu == load_game_menu)
             {
-              if (process_load_game_menu())
+              if(event.key.keysym.sym == SDLK_DELETE)
+                {
+                int slot = menu->get_active_item_id();
+                char str[1024];
+                sprintf(str,"Are you sure you want to delete slot %d?", slot);
+                
+                Menu::set_current(0);
+                draw_background();
+
+                if(confirm_dialog(str))
+                  {
+                  sprintf(str,"%s/slot%d.stsg", st_save_dir, slot);
+                  printf("Removing: %s\n",str);
+                  remove(str);
+                  }
+
+                update_time = st_get_ticks();
+                Menu::set_current(main_menu);
+                }
+              else if (process_load_game_menu())
                 {
                   // FIXME: shouldn't be needed if GameSession doesn't relay on global variables
                   // reset tux