From: Ricardo Cruz Date: Thu, 29 Apr 2004 10:34:45 +0000 (+0000) Subject: Added removing of slots when Delete is pressed. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=37a466fe88fc69672ca73779bc64694cc47225c6;p=supertux.git Added removing of slots when Delete is pressed. SVN-Revision: 833 --- diff --git a/src/menu.cpp b/src/menu.cpp index d8382693e..43083feee 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -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) { diff --git a/src/menu.h b/src/menu.h index 60d6205cc..52aa6e14a 100644 --- a/src/menu.h +++ b/src/menu.h @@ -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); diff --git a/src/title.cpp b/src/title.cpp index d3416c5ec..26d23dc61 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -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