summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/ui/mainmenu.cpp
blob: 7f0147b0ecad29b7e2690f54b941e0b66ffcc9c3 (plain) (blame)
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
// license:BSD-3-Clause
// copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods
/*********************************************************************

    ui/mainmenu.cpp

    Internal MAME menus for the user interface.

*********************************************************************/

#include "emu.h"
#include "crsshair.h"
#include "emuopts.h"
#include "mame.h"
#include "ui/menu.h"
#include "ui/filemngr.h"
#include "ui/barcode.h"
#include "ui/cheatopt.h"
#include "ui/info.h"
#include "ui/info_pty.h"
#include "ui/inputmap.h"
#include "ui/mainmenu.h"
#include "ui/miscmenu.h"
#include "ui/selgame.h"
#include "ui/simpleselgame.h"
#include "ui/sliders.h"
#include "ui/slotopt.h"
#include "ui/tapectrl.h"
#include "ui/videoopt.h"
#include "imagedev/cassette.h"
#include "machine/bcreader.h"
#include "ui/datfile.h"
#include "ui/inifile.h"
#include "ui/datmenu.h"
#include "ui/pluginopt.h"


namespace ui {

/***************************************************************************
    MENU HANDLERS
***************************************************************************/

/*-------------------------------------------------
    menu_main constructor - populate the main menu
-------------------------------------------------*/

menu_main::menu_main(mame_ui_manager &mui, render_container *container) : menu(mui, container)
{
}

void menu_main::populate()
{
	/* add input menu items */
	item_append(_("Input (general)"), nullptr, 0, (void *)INPUT_GROUPS);

	item_append(_("Input (this Machine)"), nullptr, 0, (void *)INPUT_SPECIFIC);

	/* add optional input-related menus */
	if (machine().ioport().has_analog())
		item_append(_("Analog Controls"), nullptr, 0, (void *)ANALOG);
	if (machine().ioport().has_dips())
		item_append(_("Dip Switches"), nullptr, 0, (void *)SETTINGS_DIP_SWITCHES);
	if (machine().ioport().has_configs())
	{
		item_append(_("Machine Configuration"), nullptr, 0, (void *)SETTINGS_DRIVER_CONFIG);
	}

	/* add bookkeeping menu */
	item_append(_("Bookkeeping Info"), nullptr, 0, (void *)BOOKKEEPING);

	/* add game info menu */
	item_append(_("Machine Information"), nullptr, 0, (void *)GAME_INFO);

	for (device_image_interface &image : image_interface_iterator(machine().root_device()))
	{
		if (image.user_loadable())
		{
			/* add image info menu */
			item_append(_("Image Information"), nullptr, 0, (void *)IMAGE_MENU_IMAGE_INFO);

			/* add file manager menu */
			item_append(_("File Manager"), nullptr, 0, (void *)IMAGE_MENU_FILE_MANAGER);

			break;
		}
	}

	/* add tape control menu */
	if (cassette_device_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Tape Control"), nullptr, 0, (void *)TAPE_CONTROL);

	if (pty_interface_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Pseudo terminals"), nullptr, 0, (void *)PTY_INFO);

	if (machine().ioport().has_bioses())
		item_append(_("Bios Selection"), nullptr, 0, (void *)BIOS_SELECTION);

	/* add slot info menu */
	if (slot_interface_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Slot Devices"), nullptr, 0, (void *)SLOT_DEVICES);

	/* add Barcode reader menu */
	if (barcode_reader_device_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Barcode Reader"), nullptr, 0, (void *)BARCODE_READ);

	/* add network info menu */
	if (network_interface_iterator(machine().root_device()).first() != nullptr)
		item_append(_("Network Devices"), nullptr, 0, (void*)NETWORK_DEVICES);

	/* add keyboard mode menu */
	if (machine().ioport().has_keyboard() && machine().ioport().natkeyboard().can_post())
		item_append(_("Keyboard Mode"), nullptr, 0, (void *)KEYBOARD_MODE);

	/* add sliders menu */
	item_append(_("Slider Controls"), nullptr, 0, (void *)SLIDERS);

	/* add video options menu */
	item_append(_("Video Options"), nullptr, 0, (machine().render().target_by_index(1) != nullptr) ? (void *)VIDEO_TARGETS : (void *)VIDEO_OPTIONS);

	/* add crosshair options menu */
	if (machine().crosshair().get_usage())
		item_append(_("Crosshair Options"), nullptr, 0, (void *)CROSSHAIR);

	/* add cheat menu */
	if (machine().options().cheat())
		item_append(_("Cheat"), nullptr, 0, (void *)CHEAT);

	if (machine().options().plugins())
		item_append(_("Plugin Options"), nullptr, 0, (void *)PLUGINS);

	// add dats menu
	if (ui().options().enabled_dats() && mame_machine_manager::instance()->datfile().has_data())
		item_append(_("External DAT View"), nullptr, 0, (void *)EXTERNAL_DATS);

	item_append(menu_item_type::SEPARATOR);

	/* add favorite menu */
	if (!mame_machine_manager::instance()->favorite().isgame_favorite())
		item_append(_("Add To Favorites"), nullptr, 0, (void *)ADD_FAVORITE);
	else
		item_append(_("Remove From Favorites"), nullptr, 0, (void *)REMOVE_FAVORITE);

	item_append(menu_item_type::SEPARATOR);

//  item_append(_("Quit from Machine"), nullptr, 0, (void *)QUIT_GAME);

	/* add reset and exit menus */
	item_append(_("Select New Machine"), nullptr, 0, (void *)SELECT_GAME);
}

menu_main::~menu_main()
{
}

/*-------------------------------------------------
    menu_main - handle the main menu
-------------------------------------------------*/

void menu_main::handle()
{
	/* process the menu */
	const event *menu_event = process(0);
	if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT) {
		switch((long long)(menu_event->itemref)) {
		case INPUT_GROUPS:
			menu::stack_push<menu_input_groups>(ui(), container);
			break;

		case INPUT_SPECIFIC:
			menu::stack_push<menu_input_specific>(ui(), container);
			break;

		case SETTINGS_DIP_SWITCHES:
			menu::stack_push<menu_settings_dip_switches>(ui(), container);
			break;

		case SETTINGS_DRIVER_CONFIG:
			menu::stack_push<menu_settings_driver_config>(ui(), container);
			break;

		case ANALOG:
			menu::stack_push<menu_analog>(ui(), container);
			break;

		case BOOKKEEPING:
			menu::stack_push<menu_bookkeeping>(ui(), container);
			break;

		case GAME_INFO:
			menu::stack_push<menu_game_info>(ui(), container);
			break;

		case IMAGE_MENU_IMAGE_INFO:
			menu::stack_push<menu_image_info>(ui(), container);
			break;

		case IMAGE_MENU_FILE_MANAGER:
			menu::stack_push<menu_file_manager>(ui(), container, nullptr);
			break;

		case TAPE_CONTROL:
			menu::stack_push<menu_tape_control>(ui(), container, nullptr);
			break;

		case PTY_INFO:
			menu::stack_push<menu_pty_info>(ui(), container);
			break;

		case SLOT_DEVICES:
			menu::stack_push<menu_slot_devices>(ui(), container);
			break;

		case NETWORK_DEVICES:
			menu::stack_push<menu_network_devices>(ui(), container);
			break;

		case KEYBOARD_MODE:
			menu::stack_push<menu_keyboard_mode>(ui(), container);
			break;

		case SLIDERS:
			menu::stack_push<menu_sliders>(ui(), container, false);
			break;

		case VIDEO_TARGETS:
			menu::stack_push<menu_video_targets>(ui(), container);
			break;

		case VIDEO_OPTIONS:
			menu::stack_push<menu_video_options>(ui(), container, machine().render().first_target());
			break;

		case CROSSHAIR:
			menu::stack_push<menu_crosshair>(ui(), container);
			break;

		case CHEAT:
			menu::stack_push<menu_cheat>(ui(), container);
			break;

		case PLUGINS:
			menu::stack_push<menu_plugin>(ui(), container);
			break;

		case SELECT_GAME:
			if (strcmp(machine().options().ui(),"simple")==0)
				menu::stack_push<simple_menu_select_game>(ui(), container, nullptr);
			else
				menu::stack_push<menu_select_game>(ui(), container, nullptr);
			break;

		case BIOS_SELECTION:
			menu::stack_push<menu_bios_selection>(ui(), container);
			break;

		case BARCODE_READ:
			menu::stack_push<menu_barcode_reader>(ui(), container, nullptr);
			break;

		case EXTERNAL_DATS:
			menu::stack_push<menu_dats_view>(ui(), container);
			break;

		case ADD_FAVORITE:
			mame_machine_manager::instance()->favorite().add_favorite_game();
			reset(reset_options::REMEMBER_POSITION);
			break;

		case REMOVE_FAVORITE:
			mame_machine_manager::instance()->favorite().remove_favorite_game();
			reset(reset_options::REMEMBER_POSITION);
			break;

		case QUIT_GAME:
			menu::stack_pop(machine());
			ui().request_quit();
			break;

		default:
			fatalerror("ui::menu_main::handle - unknown reference\n");
		}
	}
}

} // namespace ui