Debian Codegraph @

Examples/GUIStyle/MenuSystem/NS_Menu_Main.cpp

raw
1 // NS_Menu_Main.cpp: implementation of the NS_Menu_Main class.
2 //
3 //////////////////////////////////////////////////////////////////////
4
5 #include <iostream>
6 #include "NS_Menu_Main.h"
7 #include "NS_Profile.h"
8 //#include "../Game/NS_Players.h"
9
10 #include <ClanLib/display.h>
11 //#include <ClanLib/core.h>
12
13 //////////////////////////////////////////////////////////////////////
14 // Construction/Destruction
15 //////////////////////////////////////////////////////////////////////
16
17 NS_Menu_Main::NS_Menu_Main(NS_MenuManager & menu_manager,
18 CL_StyleManager & style_manager,
19 std::string const & path_to_resource)
20 : NS_MenuGeneric(menu_manager, style_manager, path_to_resource),
21 back_ground(new CL_Sprite("menu_right_bottom", style_manager.get_resources()))
22 {
23 CL_Button * btn_to_profile = dynamic_cast<CL_Button*>(comp_manager->get_component(("btn_to_profile")));
24 if (btn_to_profile)
25 slots.connect(btn_to_profile->sig_clicked(), this, &NS_Menu_Main::on_profile);
26
27 CL_Button * btn_to_game = dynamic_cast<CL_Button*>(comp_manager->get_component(("btn_to_game")));
28 if (btn_to_game)
29 slots.connect(btn_to_game->sig_clicked(), this, &NS_Menu_Main::on_switch_to_game_menu);
30
31 CL_Button * btn_to_credits = dynamic_cast<CL_Button*>(comp_manager->get_component(("btn_to_credits")));
32 if (btn_to_credits)
33 slots.connect(btn_to_credits->sig_clicked(), this, &NS_Menu_Main::on_switch_to_credits_menu);
34
35 CL_Button * btn_quit = dynamic_cast<CL_Button*>(comp_manager->get_component(("btn_quit")));
36 if (btn_quit)
37 slots.connect(btn_quit->sig_clicked(), this, &NS_Menu_Main::on_quit);
38 }
39
40 NS_Menu_Main::~NS_Menu_Main()
41 {
42 delete back_ground;
43 }
44
45 void NS_Menu_Main::on_profile()
46 {
47 NS_Profile::open(this);
48 }
49
50 void NS_Menu_Main::on_quit()
51 {
52 NS_MenuGeneric::on_exit();
53 }
54
55 void NS_Menu_Main::on_switch_to_credits_menu()
56 {
57 switch_to("menu_credits");
58 }
59
60 void NS_Menu_Main::on_switch_to_game_menu()
61 {
62 switch_to("menu_game");
63 }
64
65 void NS_Menu_Main::switch_to(std::string const & menu_name)
66 {
67 NS_MenuGeneric::switch_to(menu_name);
68 }
69
70 void NS_Menu_Main::on_begin_paint()
71 {
72 back_ground->draw(0,0);
73 }