| 1 |
// NS_Menu_Play.cpp: implementation of the NS_Menu_Play class. |
| 2 |
// |
| 3 |
////////////////////////////////////////////////////////////////////// |
| 4 |
|
| 5 |
#include "NS_Menu_Play.h" |
| 6 |
#include <ClanLib/display.h> |
| 7 |
#include <ClanLib/display.h> |
| 8 |
|
| 9 |
#include <iostream> |
| 10 |
#include "NS_MenuManager.h" |
| 11 |
|
| 12 |
////////////////////////////////////////////////////////////////////// |
| 13 |
// Construction/Destruction |
| 14 |
////////////////////////////////////////////////////////////////////// |
| 15 |
|
| 16 |
NS_Menu_Play::NS_Menu_Play(NS_MenuManager & menu_manager, |
| 17 |
CL_StyleManager & style_manager, |
| 18 |
std::string const & path_to_resource) |
| 19 |
: NS_MenuGeneric(menu_manager, style_manager, path_to_resource), |
| 20 |
level_number(0), |
| 21 |
state(NS_Menu_Play::game_running) |
| 22 |
{ |
| 23 |
slots.connect(CL_Keyboard::sig_key_down(), this, &NS_Menu_Play::on_key_down); |
| 24 |
} |
| 25 |
|
| 26 |
NS_Menu_Play::~NS_Menu_Play() |
| 27 |
{ |
| 28 |
|
| 29 |
} |
| 30 |
|
| 31 |
void NS_Menu_Play::on_key_down(CL_InputEvent const & key) |
| 32 |
{ |
| 33 |
if (!is_input_enabled()) |
| 34 |
return; |
| 35 |
|
| 36 |
if (key.id == CL_KEY_ESCAPE) |
| 37 |
{ |
| 38 |
// Do cleanup |
| 39 |
on_switch_to_main_menu(); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
void NS_Menu_Play::run_task() |
| 44 |
{ |
| 45 |
NS_MenuGeneric::run_task(); |
| 46 |
} |
| 47 |
|
| 48 |
void NS_Menu_Play::on_timer() |
| 49 |
{ |
| 50 |
on_switch_to_main_menu(); |
| 51 |
} |
| 52 |
|
| 53 |
void NS_Menu_Play::on_quit() |
| 54 |
{ |
| 55 |
NS_MenuGeneric::quit(); |
| 56 |
} |
| 57 |
|
| 58 |
void NS_Menu_Play::on_switch_to_main_menu() |
| 59 |
{ |
| 60 |
switch_to("menu_main"); |
| 61 |
} |
| 62 |
|
| 63 |
void NS_Menu_Play::switch_to(std::string const & menu_name) |
| 64 |
{ |
| 65 |
NS_MenuGeneric::switch_to(menu_name); |
| 66 |
} |