File: menu_list_epiphany.cpp

package info (click to toggle)
epiphany 0.7.0+0-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 7,532 kB
  • sloc: cpp: 6,404; ansic: 141; makefile: 78; sh: 7
file content (144 lines) | stat: -rw-r--r-- 2,946 bytes parent folder | download | duplicates (6)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/***************************************************************************
                          menu_list_epiphany.cpp  -  description
                             -------------------
    begin                : Jun 13 2007
    copyright            : (C) 2007 by Giuseppe D'Aqui'
    email                : kumber@tiscalinet.it
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License, Version 2,      *
 *   as published by the Free Software Foundation.                         *
 *                                                                         *
 ***************************************************************************/

#include "dephine.h"
#include "menu_list_epiphany.h"
#include "menu_entry.h"
#include "menu_entry_simple.h"
#include "menu_entry_ranged.h"
#include "menu_list_options.h"
#include <vector>
#include <cassert>


Menu_List_Epiphany::Menu_List_Epiphany(Uint32 unsolved_level)
{
	m_return_action = Menu_List_Epiphany::MENU_NONE;
	
	m_selected = 0;
	
	m_entries_list.push_back(new Menu_Entry_Simple("Start"));
	
	m_entries_list.push_back(new Menu_Entry_Ranged(0, unsolved_level, "Level: ", unsolved_level));
	
	m_entries_list.push_back(new Menu_Entry_Simple("Options"));
	
	//m_entries_list.push_back(new Menu_Entry_Simple("Credits"));
	
	m_entries_list.push_back(new Menu_Entry_Simple("Quit"));
	
}

Menu_List_Epiphany::~Menu_List_Epiphany()
{
	for(Uint32 i=0; i<m_entries_list.size(); i++)
	{
		delete m_entries_list[i];
	}
}

void Menu_List_Epiphany::action_press()
{
	m_entries_list[m_selected]->action_press();
	
	switch(m_selected)
	{
		case 0:
			m_return_action = MENU_START;
			break;
		case 2:
			m_return_action = MENU_OPTIONS;
			break;
		case 3:
			m_return_action = MENU_QUIT;
			break;
		default:
			m_return_action = MENU_NONE;
	}

}

void Menu_List_Epiphany::action_down()
{
	
	if(m_selected<m_entries_list.size()-1)
	{

		m_selected++;

	}

}




void Menu_List_Epiphany::action_up()
{
	
	if(m_selected>0)
	{

		m_selected--;

	}

}


void Menu_List_Epiphany::action_right()
{
	m_entries_list[m_selected]->action_right();
}




void Menu_List_Epiphany::action_left()
{
	m_entries_list[m_selected]->action_left();
}




const char* Menu_List_Epiphany::get_menu_entry_string(Uint32 entry)
{
	assert(entry<m_entries_list.size() && "Fatal: Accessing menu_entry outside limits");

	return m_entries_list[entry]->get_string();
}


Uint32 Menu_List_Epiphany::get_list_size()
{
	return m_entries_list.size();
		
}


Uint32 Menu_List_Epiphany::get_return_action()
{
	return m_return_action;
}

Uint32 Menu_List_Epiphany::get_selected_level()
{
	return m_entries_list[1]->get_value();
	
}