Debian Codegraph @

Examples/GUIStyle/MenuSystem/NS_MenuGeneric.cpp

raw
1 // NS_MenuGeneric.cpp: implementation of the NS_MenuGeneric class.
2 //
3 //////////////////////////////////////////////////////////////////////
4
5 #include "NS_MenuGeneric.h"
6 #include "NS_MenuManager.h"
7
8 #include <ClanLib/display.h>
9 #include <ClanLib/display.h>
10 #include <ClanLib/core.h>
11 #include <ClanLib/core.h>
12
13 //////////////////////////////////////////////////////////////////////
14 // Construction/Destruction
15 //////////////////////////////////////////////////////////////////////
16
17 NS_MenuGeneric::NS_MenuGeneric(NS_MenuManager & menu_manager,
18 CL_StyleManager & style_manager,
19 std::string const & path_to_resource)
20 : CL_GUIManager(&style_manager),
21 menu_manager(menu_manager),
22 comp_manager(0)
23 {
24 comp_manager = new CL_ComponentManager(path_to_resource, this);
25 slots.connect(sig_begin_paint(), this, &NS_MenuGeneric::on_begin_paint);
26 slots.connect(sig_focus_changed(), this, &NS_MenuGeneric::on_focus_changed);
27 }
28
29 NS_MenuGeneric::~NS_MenuGeneric()
30 {
31 delete comp_manager;
32 }
33
34 NS_MenuManager & NS_MenuGeneric::get_menu_manager() const
35 {
36 return menu_manager;
37 }
38
39 void NS_MenuGeneric::on_exit()
40 {
41 quit();
42 menu_manager.quit();
43 }
44
45 void NS_MenuGeneric::run()
46 {
47 quit_run = false;
48 while (!quit_run)
49 {
50 run_task();
51 }
52 }
53
54 void NS_MenuGeneric::show()
55 {
56 CL_GUIManager::show();
57 }
58
59 void NS_MenuGeneric::quit()
60 {
61 quit_run = true;
62 }
63
64 void NS_MenuGeneric::on_begin_paint()
65 {
66 CL_Display::clear(CL_Color::black);
67 }
68
69 // Menu manager loops a current menu, and so here should be
70 // a things which usualy doing in main loop in games
71 // Do a whatever calculations you need in this method.
72 // Standard implementation just clears the screen
73 void NS_MenuGeneric::run_task()
74 {
75 show();
76 CL_Display::flip();
77 CL_System::keep_alive(10);
78 }
79
80 void NS_MenuGeneric::switch_to(std::string const & menu_name)
81 {
82 quit();
83 menu_manager.switch_to(menu_name);
84 }
85
86 void NS_MenuGeneric::on_focus_changed(CL_Component * new_comp_focus)
87 {
88 }