/** Remove all entries from the menu */
void clear();
- /** Return the index of the menu item that was 'hit' (ie. the user
- clicked on it) in the last event() call */
- int check ();
-
virtual void check_menu() =0;
MenuItem& get_item(int index)
void set_toggled(int id, bool toggled);
protected:
+ /** Return the index of the menu item that was 'hit' (ie. the user
+ clicked on it) in the last event() call */
+ int check ();
+
MenuItem* add_item(std::unique_ptr<MenuItem> menu_item);
float get_width() const;
float get_height() const;
}
void
+GameSession::abort_level()
+{
+ MenuManager::instance().set_current(0);
+ g_screen_manager->exit_screen();
+ currentsector->player->set_bonus(bonus_at_start);
+ PlayerStatus *currentStatus = get_player_status();
+ currentStatus->coins = coins_at_start;
+ currentStatus->max_fire_bullets = max_fire_bullets_at_start;
+ currentStatus->max_ice_bullets = max_ice_bullets_at_start;
+}
+
+void
GameSession::set_editmode(bool edit_mode)
{
if (this->edit_mode == edit_mode) return;
}
void
-GameSession::process_menu()
-{
- Menu* menu = MenuManager::instance().current();
- if(menu) {
- if(menu == game_menu.get()) {
- switch (game_menu->check()) {
- case MNID_CONTINUE:
- MenuManager::instance().set_current(0);
- toggle_pause();
- break;
- case MNID_ABORTLEVEL:
- MenuManager::instance().set_current(0);
- g_screen_manager->exit_screen();
- currentsector->player->set_bonus(bonus_at_start);
- PlayerStatus *currentStatus = get_player_status();
- currentStatus->coins = coins_at_start;
- currentStatus->max_fire_bullets = max_fire_bullets_at_start;
- currentStatus->max_ice_bullets = max_ice_bullets_at_start;
- }
- }
- }
-}
-
-void
GameSession::setup()
{
if (currentsector == NULL)
on_escape_press();
process_events();
- process_menu();
+ Menu* menu = MenuManager::instance().current();
+ if (menu && menu == game_menu.get())
+ {
+ menu->check_menu();
+ }
// Unpause the game if the menu has been closed
if (game_pause && !MenuManager::instance().current()) {
int restart_level();
void toggle_pause();
+ void abort_level();
/**
* Enters or leaves level editor mode
HSQUIRRELVM run_script(std::istream& in, const std::string& sourcename);
void on_escape_press();
- void process_menu();
std::unique_ptr<Level> level;
SurfacePtr statistics_backdrop;
#include "supertux/menu/game_menu.hpp"
+#include "gui/menu_manager.hpp"
+#include "supertux/game_session.hpp"
+#include "supertux/screen_manager.hpp"
#include "supertux/level.hpp"
#include "supertux/menu/menu_storage.hpp"
#include "supertux/menu/options_menu.hpp"
void
GameMenu::check_menu()
{
+ switch (check())
+ {
+ case MNID_CONTINUE:
+ MenuManager::instance().set_current(0);
+ GameSession::current()->toggle_pause();
+ break;
+
+ case MNID_ABORTLEVEL:
+ GameSession::current()->abort_level();
+ break;
+ }
}
/* EOF */
public:
GameMenu(const Level& level);
- void check_menu();
+ void check_menu() override;
private:
GameMenu(const GameMenu&);
#include "supertux/menu/worldmap_menu.hpp"
+#include "gui/menu_manager.hpp"
#include "supertux/menu/menu_storage.hpp"
#include "supertux/menu/options_menu.hpp"
+#include "supertux/screen_manager.hpp"
#include "util/gettext.hpp"
WorldmapMenu::WorldmapMenu()
void
WorldmapMenu::check_menu()
{
+ switch (check())
+ {
+ case MNID_RETURNWORLDMAP: // Return to game
+ MenuManager::instance().set_current(0);
+ break;
+
+ case MNID_QUITWORLDMAP: // Quit Worldmap
+ g_screen_manager->exit_screen();
+ break;
+ }
}
/* EOF */
public:
WorldmapMenu();
- void check_menu();
+ void check_menu() override;
private:
WorldmapMenu(const WorldmapMenu&);
{
if(!in_level) {
Menu* menu = MenuManager::instance().current();
- if(menu != NULL) {
- if(menu == worldmap_menu.get()) {
- switch (worldmap_menu->check())
- {
- case MNID_RETURNWORLDMAP: // Return to game
- MenuManager::instance().set_current(0);
- break;
- case MNID_QUITWORLDMAP: // Quit Worldmap
- g_screen_manager->exit_screen();
- break;
- }
- }
-
+ if (menu && menu == worldmap_menu.get())
+ {
+ menu->check_menu();
return;
}