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