File: menu_list_options.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 (149 lines) | stat: -rw-r--r-- 2,954 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
145
146
147
148
149
/***************************************************************************
                          menu_list_options.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_options.h"
#include "menu_entry.h"
#include "menu_entry_simple.h"
#include "menu_entry_ranged.h"
#include "sfx.h"
#include "music_manager.h"
#include <vector>
#include <cassert>




Menu_List_Options::Menu_List_Options()
{
	m_return_action = Menu_List_Options::MENU_NONE;
	
	m_selected = 0;
	
	m_entries_list.push_back(new Menu_Entry_Ranged(0, Sample_Manager::instance()->get_max_volume(), "Sound Volume: ", Sample_Manager::instance()->get_volume()));
	
	//TODO insert music volume control
	m_entries_list.push_back(new Menu_Entry_Ranged(0, Music_Manager::instance()->get_max_volume(), "Music Volume: ", Music_Manager::instance()->get_volume()));
	
	m_entries_list.push_back(new Menu_Entry_Simple("Back"));
	
}




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




void Menu_List_Options::action_press()
{
	m_entries_list[m_selected]->action_press();
	
	switch(m_selected)
	{
		case 2:
			m_return_action = MENU_OK;
			Sample_Manager::instance()->set_volume(m_entries_list[0]->get_value());
			Music_Manager::instance()->set_volume(m_entries_list[1]->get_value());
			break;
		default:
			m_return_action = MENU_NONE;
	}
	
}




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

		m_selected++;

	}

}




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

		m_selected--;

	}

}




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




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




const char* Menu_List_Options::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_Options::get_list_size()
{
	return m_entries_list.size();
		
}




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