1 /***************************************************************************
2                           menu_list_epiphany.cpp  -  description
3                              -------------------
4     begin                : Jun 13 2007
5     copyright            : (C) 2007 by Giuseppe D'Aqui'
6     email                : kumber@tiscalinet.it
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License, Version 2,      *
13  *   as published by the Free Software Foundation.                         *
14  *                                                                         *
15  ***************************************************************************/
16 
17 #include "dephine.h"
18 #include "menu_list_epiphany.h"
19 #include "menu_entry.h"
20 #include "menu_entry_simple.h"
21 #include "menu_entry_ranged.h"
22 #include "menu_list_options.h"
23 #include <vector>
24 #include <cassert>
25 
26 
Menu_List_Epiphany(Uint32 unsolved_level)27 Menu_List_Epiphany::Menu_List_Epiphany(Uint32 unsolved_level)
28 {
29 	m_return_action = Menu_List_Epiphany::MENU_NONE;
30 
31 	m_selected = 0;
32 
33 	m_entries_list.push_back(new Menu_Entry_Simple("Start"));
34 
35 	m_entries_list.push_back(new Menu_Entry_Ranged(0, unsolved_level, "Level: ", unsolved_level));
36 
37 	m_entries_list.push_back(new Menu_Entry_Simple("Options"));
38 
39 	//m_entries_list.push_back(new Menu_Entry_Simple("Credits"));
40 
41 	m_entries_list.push_back(new Menu_Entry_Simple("Quit"));
42 
43 }
44 
~Menu_List_Epiphany()45 Menu_List_Epiphany::~Menu_List_Epiphany()
46 {
47 	for(Uint32 i=0; i<m_entries_list.size(); i++)
48 	{
49 		delete m_entries_list[i];
50 	}
51 }
52 
action_press()53 void Menu_List_Epiphany::action_press()
54 {
55 	m_entries_list[m_selected]->action_press();
56 
57 	switch(m_selected)
58 	{
59 		case 0:
60 			m_return_action = MENU_START;
61 			break;
62 		case 2:
63 			m_return_action = MENU_OPTIONS;
64 			break;
65 		case 3:
66 			m_return_action = MENU_QUIT;
67 			break;
68 		default:
69 			m_return_action = MENU_NONE;
70 	}
71 
72 }
73 
action_down()74 void Menu_List_Epiphany::action_down()
75 {
76 
77 	if(m_selected<m_entries_list.size()-1)
78 	{
79 
80 		m_selected++;
81 
82 	}
83 
84 }
85 
86 
87 
88 
action_up()89 void Menu_List_Epiphany::action_up()
90 {
91 
92 	if(m_selected>0)
93 	{
94 
95 		m_selected--;
96 
97 	}
98 
99 }
100 
101 
action_right()102 void Menu_List_Epiphany::action_right()
103 {
104 	m_entries_list[m_selected]->action_right();
105 }
106 
107 
108 
109 
action_left()110 void Menu_List_Epiphany::action_left()
111 {
112 	m_entries_list[m_selected]->action_left();
113 }
114 
115 
116 
117 
get_menu_entry_string(Uint32 entry)118 const char* Menu_List_Epiphany::get_menu_entry_string(Uint32 entry)
119 {
120 	assert(entry<m_entries_list.size() && "Fatal: Accessing menu_entry outside limits");
121 
122 	return m_entries_list[entry]->get_string();
123 }
124 
125 
get_list_size()126 Uint32 Menu_List_Epiphany::get_list_size()
127 {
128 	return m_entries_list.size();
129 
130 }
131 
132 
get_return_action()133 Uint32 Menu_List_Epiphany::get_return_action()
134 {
135 	return m_return_action;
136 }
137 
get_selected_level()138 Uint32 Menu_List_Epiphany::get_selected_level()
139 {
140 	return m_entries_list[1]->get_value();
141 
142 }
143 
144 
145