1 ///////////////////////////////////////////////////////////////////////////////
2 //            Copyright (C) 2004-2010 by The Allacrost Project
3 //                         All Rights Reserved
4 //
5 // This code is licensed under the GNU GPL version 2. It is free software
6 // and you may modify it and/or redistribute it under the terms of this license.
7 // See http://www.gnu.org/copyleft/gpl.html for details.
8 ///////////////////////////////////////////////////////////////////////////////
9 
10 /*!****************************************************************************
11  * \file    boot_menu.cpp
12  * \author  Viljami Korhonen, mindflayer@allacrost.org
13  * \brief   Source file for the boot menus
14  *****************************************************************************/
15 
16 #include "boot.h"
17 #include "boot_menu.h"
18 
19 using namespace std;
20 using namespace hoa_utils;
21 using namespace hoa_video;
22 
23 namespace hoa_boot {
24 
25 namespace private_boot {
26 
AddOption(const ustring & text,void (BootMode::* confirm_function)(),void (BootMode::* up_function)(),void (BootMode::* down_function)(),void (BootMode::* left_function)(),void (BootMode::* right_function)())27 void BootMenu::AddOption(const ustring& text, void (BootMode::*confirm_function)(),
28 	void (BootMode::*up_function)(), void (BootMode::*down_function)(),
29 	void (BootMode::*left_function)(), void (BootMode::*right_function)())
30 {
31 	OptionBox::AddOption(text);
32 
33 	_confirm_handlers.push_back(confirm_function);
34 	_up_handlers.push_back(up_function);
35 	_down_handlers.push_back(down_function);
36 	_left_handlers.push_back(left_function);
37 	_right_handlers.push_back(right_function);
38 }
39 
40 
41 
InputConfirm()42 void BootMenu::InputConfirm() {
43 	OptionBox::InputConfirm();
44 
45 	int32 selection = OptionBox::GetSelection();
46 	if ((selection != -1) && (_confirm_handlers.empty() == false)) {
47 		void (BootMode::*confirm_function)() = _confirm_handlers.at(selection);
48 		if (confirm_function != NULL)
49 			(BootMode::CurrentInstance()->*confirm_function)();
50 	}
51 }
52 
53 
54 
InputUp()55 void BootMenu::InputUp() {
56 	OptionBox::InputUp();
57 
58 	int32 selection = OptionBox::GetSelection();
59 	if ((selection != -1) && (_up_handlers.empty() == false)) {
60 		void (BootMode::*up_function)() = _up_handlers.at(selection);
61 		if (up_function != NULL)
62 			(BootMode::CurrentInstance()->*up_function)();
63 	}
64 }
65 
66 
67 
InputDown()68 void BootMenu::InputDown() {
69 	OptionBox::InputDown();
70 
71 	int32 selection = OptionBox::GetSelection();
72 	if ((selection != -1) && (_down_handlers.empty() == false)) {
73 		void (BootMode::*down_function)() = _down_handlers.at(selection);
74 		if (down_function != NULL)
75 			(BootMode::CurrentInstance()->*down_function)();
76 	}
77 }
78 
79 
80 
InputLeft()81 void BootMenu::InputLeft() {
82 	OptionBox::InputLeft();
83 
84 	int32 selection = OptionBox::GetSelection();
85 	if ((selection != -1) && (_left_handlers.empty() == false)) {
86 		void (BootMode::*left_function)() = _left_handlers.at(selection);
87 		if (left_function != NULL)
88 			(BootMode::CurrentInstance()->*left_function)();
89 	}
90 }
91 
92 
93 
InputRight()94 void BootMenu::InputRight() {
95 	OptionBox::InputRight();
96 
97 	int32 selection = OptionBox::GetSelection();
98 	if ((selection != -1) && (_right_handlers.empty() == false)) {
99 		void (BootMode::*right_function)() = _right_handlers.at(selection);
100 		if (right_function != NULL)
101 			(BootMode::CurrentInstance()->*right_function)();
102 	}
103 }
104 
105 } // namespace private_boot
106 
107 } // namespace hoa_boot
108