src/emu/uiimage.c
| r13553 | r13554 | |
| 22 | 22 | #include "ui.h" |
| 23 | 23 | #include "uimenu.h" |
| 24 | 24 | #include "uiswlist.h" |
| 25 | #include "uiimage.h" |
| 25 | 26 | #include "zippath.h" |
| 26 | 27 | #include "unicode.h" |
| 27 | 28 | #include "imagedev/cassette.h" |
| r13553 | r13554 | |
| 47 | 48 | #define ITEMREF_NO ((void *) 0x0004) |
| 48 | 49 | #define ITEMREF_YES ((void *) 0x0005) |
| 49 | 50 | |
| 50 | | |
| 51 | | |
| 52 | 51 | /*************************************************************************** |
| 53 | | TYPE DEFINITIONS |
| 54 | | ***************************************************************************/ |
| 55 | | |
| 56 | | /* menu item type in the file selector */ |
| 57 | | enum _file_selector_entry_type |
| 58 | | { |
| 59 | | SELECTOR_ENTRY_TYPE_EMPTY, |
| 60 | | SELECTOR_ENTRY_TYPE_CREATE, |
| 61 | | SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, |
| 62 | | SELECTOR_ENTRY_TYPE_DRIVE, |
| 63 | | SELECTOR_ENTRY_TYPE_DIRECTORY, |
| 64 | | SELECTOR_ENTRY_TYPE_FILE |
| 65 | | }; |
| 66 | | typedef enum _file_selector_entry_type file_selector_entry_type; |
| 67 | | |
| 68 | | |
| 69 | | |
| 70 | | /* an entry within the file manager */ |
| 71 | | typedef struct _file_selector_entry file_selector_entry; |
| 72 | | struct _file_selector_entry |
| 73 | | { |
| 74 | | file_selector_entry *next; |
| 75 | | |
| 76 | | file_selector_entry_type type; |
| 77 | | const char *basename; |
| 78 | | const char *fullpath; |
| 79 | | }; |
| 80 | | |
| 81 | | |
| 82 | | |
| 83 | | /* state of the file manager */ |
| 84 | | typedef struct _file_manager_menu_state file_manager_menu_state; |
| 85 | | struct _file_manager_menu_state |
| 86 | | { |
| 87 | | device_image_interface *selected_device; |
| 88 | | astring *current_directory; |
| 89 | | astring *current_file; |
| 90 | | }; |
| 91 | | |
| 92 | | |
| 93 | | |
| 94 | | /* state of the file selector menu */ |
| 95 | | typedef struct _file_selector_menu_state file_selector_menu_state; |
| 96 | | struct _file_selector_menu_state |
| 97 | | { |
| 98 | | file_manager_menu_state *manager_menustate; |
| 99 | | file_selector_entry *entrylist; |
| 100 | | char filename_buffer[1024]; |
| 101 | | }; |
| 102 | | |
| 103 | | |
| 104 | | |
| 105 | | /* state of the file creator menu */ |
| 106 | | typedef struct _file_create_menu_state file_create_menu_state; |
| 107 | | struct _file_create_menu_state |
| 108 | | { |
| 109 | | file_manager_menu_state *manager_menustate; |
| 110 | | const image_device_format *current_format; |
| 111 | | int confirm_save_as_yes; |
| 112 | | char filename_buffer[1024]; |
| 113 | | }; |
| 114 | | |
| 115 | | |
| 116 | | /* state of the confirm save as menu */ |
| 117 | | typedef struct _confirm_save_as_menu_state confirm_save_as_menu_state; |
| 118 | | struct _confirm_save_as_menu_state |
| 119 | | { |
| 120 | | int *yes; |
| 121 | | }; |
| 122 | | |
| 123 | | /*************************************************************************** |
| 124 | 52 | MENU HELPERS |
| 125 | 53 | ***************************************************************************/ |
| 126 | 54 | |
| r13553 | r13554 | |
| 151 | 79 | or footer text |
| 152 | 80 | -------------------------------------------------*/ |
| 153 | 81 | |
| 154 | | static void extra_text_draw_box(render_container &ui_container, float origx1, float origx2, float origy, float yspan, const char *text, int direction) |
| 82 | static void extra_text_draw_box(render_container *container, float origx1, float origx2, float origy, float yspan, const char *text, int direction) |
| 155 | 83 | { |
| 156 | 84 | float text_width, text_height; |
| 157 | 85 | float width, maxwidth; |
| 158 | 86 | float x1, y1, x2, y2, temp; |
| 159 | 87 | |
| 160 | 88 | /* get the size of the text */ |
| 161 | | ui_draw_text_full(&ui_container,text, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, |
| 89 | ui_draw_text_full(container,text, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, |
| 162 | 90 | DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &text_width, &text_height); |
| 163 | 91 | width = text_width + (2 * UI_BOX_LR_BORDER); |
| 164 | 92 | maxwidth = MAX(width, origx2 - origx1); |
| r13553 | r13554 | |
| 177 | 105 | } |
| 178 | 106 | |
| 179 | 107 | /* draw a box */ |
| 180 | | ui_draw_outlined_box(&ui_container,x1, y1, x2, y2, UI_BACKGROUND_COLOR); |
| 108 | ui_draw_outlined_box(container,x1, y1, x2, y2, UI_BACKGROUND_COLOR); |
| 181 | 109 | |
| 182 | 110 | /* take off the borders */ |
| 183 | 111 | x1 += UI_BOX_LR_BORDER; |
| r13553 | r13554 | |
| 186 | 114 | y2 -= UI_BOX_TB_BORDER; |
| 187 | 115 | |
| 188 | 116 | /* draw the text within it */ |
| 189 | | ui_draw_text_full(&ui_container,text, x1, y1, text_width, JUSTIFY_LEFT, WRAP_WORD, |
| 117 | ui_draw_text_full(container,text, x1, y1, text_width, JUSTIFY_LEFT, WRAP_WORD, |
| 190 | 118 | DRAW_NORMAL, ARGB_WHITE, ARGB_BLACK, NULL, NULL); |
| 191 | 119 | } |
| 192 | 120 | |
| r13553 | r13554 | |
| 197 | 125 | and footer text |
| 198 | 126 | -------------------------------------------------*/ |
| 199 | 127 | |
| 200 | | static void extra_text_render(running_machine &machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, |
| 128 | static void extra_text_render(render_container *container, float top, float bottom, |
| 201 | 129 | float origx1, float origy1, float origx2, float origy2, |
| 202 | 130 | const char *header, const char *footer) |
| 203 | 131 | { |
| r13553 | r13554 | |
| 205 | 133 | footer = ((footer != NULL) && (footer[0] != '\0')) ? footer : NULL; |
| 206 | 134 | |
| 207 | 135 | if (header != NULL) |
| 208 | | extra_text_draw_box(machine.render().ui_container(), origx1, origx2, origy1, top, header, -1); |
| 136 | extra_text_draw_box(container, origx1, origx2, origy1, top, header, -1); |
| 209 | 137 | if (footer != NULL) |
| 210 | | extra_text_draw_box(machine.render().ui_container(), origx1, origx2, origy2, bottom, footer, +1); |
| 138 | extra_text_draw_box(container, origx1, origx2, origy2, bottom, footer, +1); |
| 211 | 139 | } |
| 212 | 140 | |
| 213 | 141 | |
| r13553 | r13554 | |
| 221 | 149 | confirm save as menu |
| 222 | 150 | -------------------------------------------------*/ |
| 223 | 151 | |
| 224 | | static void menu_confirm_save_as_populate(running_machine &machine, ui_menu *menu, void *state) |
| 152 | ui_menu_confirm_save_as::ui_menu_confirm_save_as(running_machine &machine, render_container *container, int *_yes) : ui_menu(machine, container) |
| 225 | 153 | { |
| 226 | | menu->item_append("File Already Exists - Overide?", NULL, MENU_FLAG_DISABLE, NULL); |
| 227 | | menu->item_append(MENU_SEPARATOR_ITEM, NULL, MENU_FLAG_DISABLE, NULL); |
| 228 | | menu->item_append("No", NULL, 0, ITEMREF_NO); |
| 229 | | menu->item_append("Yes", NULL, 0, ITEMREF_YES); |
| 154 | yes = _yes; |
| 230 | 155 | } |
| 231 | 156 | |
| 157 | ui_menu_confirm_save_as::~ui_menu_confirm_save_as() |
| 158 | { |
| 159 | } |
| 232 | 160 | |
| 161 | void ui_menu_confirm_save_as::populate() |
| 162 | { |
| 163 | item_append("File Already Exists - Overide?", NULL, MENU_FLAG_DISABLE, NULL); |
| 164 | item_append(MENU_SEPARATOR_ITEM, NULL, MENU_FLAG_DISABLE, NULL); |
| 165 | item_append("No", NULL, 0, ITEMREF_NO); |
| 166 | item_append("Yes", NULL, 0, ITEMREF_YES); |
| 167 | } |
| 233 | 168 | |
| 234 | 169 | /*------------------------------------------------- |
| 235 | 170 | menu_confirm_save_as - confirm save as menu |
| 236 | 171 | -------------------------------------------------*/ |
| 237 | 172 | |
| 238 | | static void menu_confirm_save_as(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 173 | void ui_menu_confirm_save_as::handle() |
| 239 | 174 | { |
| 240 | | const ui_menu_event *event; |
| 241 | | confirm_save_as_menu_state *menustate = (confirm_save_as_menu_state *) state; |
| 242 | | |
| 243 | | /* if the menu isn't built, populate now */ |
| 244 | | if (!menu->populated()) |
| 245 | | menu_confirm_save_as_populate(machine, menu, state); |
| 246 | | |
| 247 | 175 | /* process the menu */ |
| 248 | | event = menu->process(0); |
| 176 | const ui_menu_event *event = process(0); |
| 249 | 177 | |
| 250 | 178 | /* process the event */ |
| 251 | 179 | if ((event != NULL) && (event->iptkey == IPT_UI_SELECT)) |
| 252 | 180 | { |
| 253 | 181 | if (event->itemref == ITEMREF_YES) |
| 254 | | *menustate->yes = TRUE; |
| 182 | *yes = TRUE; |
| 255 | 183 | |
| 256 | 184 | /* no matter what, pop out */ |
| 257 | | ui_menu::stack_pop(machine); |
| 185 | ui_menu::stack_pop(machine()); |
| 258 | 186 | } |
| 259 | 187 | } |
| 260 | 188 | |
| r13553 | r13554 | |
| 293 | 221 | special rendering |
| 294 | 222 | -------------------------------------------------*/ |
| 295 | 223 | |
| 296 | | static void file_create_render_extra(running_machine &machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) |
| 224 | void ui_menu_file_create::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) |
| 297 | 225 | { |
| 298 | | file_create_menu_state *menustate = (file_create_menu_state *) state; |
| 299 | | |
| 300 | | extra_text_render(machine, menu, state, selectedref, top, bottom, origx1, origy1, origx2, origy2, |
| 301 | | astring_c(menustate->manager_menustate->current_directory), |
| 226 | extra_text_render(container, top, bottom, origx1, origy1, origx2, origy2, |
| 227 | astring_c(manager->current_directory), |
| 302 | 228 | NULL); |
| 303 | 229 | } |
| 304 | 230 | |
| r13553 | r13554 | |
| 309 | 235 | creator menu |
| 310 | 236 | -------------------------------------------------*/ |
| 311 | 237 | |
| 312 | | static void menu_file_create_populate(running_machine &machine, ui_menu *menu, void *state, void *selection) |
| 238 | ui_menu_file_create::ui_menu_file_create(running_machine &machine, render_container *container, ui_menu_file_manager *parent) : ui_menu(machine, container) |
| 313 | 239 | { |
| 240 | manager = parent; |
| 241 | } |
| 242 | |
| 243 | ui_menu_file_create::~ui_menu_file_create() |
| 244 | { |
| 245 | } |
| 246 | |
| 247 | void ui_menu_file_create::populate() |
| 248 | { |
| 314 | 249 | astring buffer; |
| 315 | | file_create_menu_state *menustate = (file_create_menu_state *) state; |
| 316 | | device_image_interface *device = menustate->manager_menustate->selected_device; |
| 250 | device_image_interface *device = manager->selected_device; |
| 317 | 251 | const image_device_format *format; |
| 318 | 252 | const char *new_image_name; |
| 319 | 253 | |
| 320 | 254 | /* append the "New Image Name" item */ |
| 321 | | if (selection == ITEMREF_NEW_IMAGE_NAME) |
| 255 | if (get_selection() == ITEMREF_NEW_IMAGE_NAME) |
| 322 | 256 | { |
| 323 | | astring_assemble_2(&buffer, menustate->filename_buffer, "_"); |
| 257 | astring_assemble_2(&buffer, filename_buffer, "_"); |
| 324 | 258 | new_image_name = astring_c(&buffer); |
| 325 | 259 | } |
| 326 | 260 | else |
| 327 | 261 | { |
| 328 | | new_image_name = menustate->filename_buffer; |
| 262 | new_image_name = filename_buffer; |
| 329 | 263 | } |
| 330 | | menu->item_append("New Image Name:", new_image_name, 0, ITEMREF_NEW_IMAGE_NAME); |
| 264 | item_append("New Image Name:", new_image_name, 0, ITEMREF_NEW_IMAGE_NAME); |
| 331 | 265 | |
| 332 | 266 | /* do we support multiple formats? */ |
| 333 | 267 | format = device->device_get_creatable_formats(); |
| 334 | 268 | if (ENABLE_FORMATS && (format != NULL)) |
| 335 | 269 | { |
| 336 | | menu->item_append("Image Format:", menustate->current_format->m_description, 0, ITEMREF_FORMAT); |
| 337 | | menustate->current_format = format; |
| 270 | item_append("Image Format:", current_format->m_description, 0, ITEMREF_FORMAT); |
| 271 | current_format = format; |
| 338 | 272 | } |
| 339 | 273 | |
| 340 | 274 | /* finish up the menu */ |
| 341 | | menu->item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 342 | | menu->item_append("Create", NULL, 0, ITEMREF_CREATE); |
| 275 | item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 276 | item_append("Create", NULL, 0, ITEMREF_CREATE); |
| 343 | 277 | |
| 344 | | /* set up custom render proc */ |
| 345 | | menu->set_custom_render(file_create_render_extra, ui_get_line_height(machine) + 3.0f * UI_BOX_TB_BORDER, 0); |
| 278 | customtop = ui_get_line_height(machine()) + 3.0f * UI_BOX_TB_BORDER; |
| 346 | 279 | } |
| 347 | 280 | |
| 348 | 281 | |
| r13553 | r13554 | |
| 351 | 284 | create_new_image - creates a new disk image |
| 352 | 285 | -------------------------------------------------*/ |
| 353 | 286 | |
| 354 | | static int create_new_image(device_image_interface *image, const char *directory, const char *filename, int *yes) |
| 287 | int ui_menu_file_create::create_new_image(device_image_interface *image, const char *directory, const char *filename, int *yes) |
| 355 | 288 | { |
| 356 | 289 | astring *path; |
| 357 | 290 | osd_directory_entry *entry; |
| 358 | 291 | osd_dir_entry_type file_type; |
| 359 | 292 | int do_create, err; |
| 360 | 293 | int result = FALSE; |
| 361 | | ui_menu *child_menu; |
| 362 | | confirm_save_as_menu_state *child_menustate; |
| 363 | 294 | |
| 364 | 295 | /* assemble the full path */ |
| 365 | 296 | path = zippath_combine(astring_alloc(), directory, filename); |
| r13553 | r13554 | |
| 383 | 314 | |
| 384 | 315 | case ENTTYPE_FILE: |
| 385 | 316 | /* a file exists here - ask for permission from the user */ |
| 386 | | child_menu = ui_menu_alloc(image->device().machine(), &image->device().machine().render().ui_container(), menu_confirm_save_as, NULL); |
| 387 | | child_menustate = (confirm_save_as_menu_state*)child_menu->alloc_state(sizeof(*child_menustate), NULL); |
| 388 | | child_menustate->yes = yes; |
| 389 | | ui_menu::stack_push(child_menu); |
| 317 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_confirm_save_as(machine(), container, yes))); |
| 390 | 318 | do_create = FALSE; |
| 391 | 319 | break; |
| 392 | 320 | |
| r13553 | r13554 | |
| 424 | 352 | menu_file_create - file creator menu |
| 425 | 353 | -------------------------------------------------*/ |
| 426 | 354 | |
| 427 | | static void menu_file_create(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 355 | void ui_menu_file_create::handle() |
| 428 | 356 | { |
| 429 | | void *selection; |
| 430 | 357 | const ui_menu_event *event; |
| 431 | 358 | ui_menu_event fake_event; |
| 432 | | file_create_menu_state *menustate = (file_create_menu_state *) state; |
| 433 | 359 | |
| 434 | | /* identify the selection */ |
| 435 | | selection = menu->get_selection(); |
| 436 | | |
| 437 | | /* rebuild the menu */ |
| 438 | | menu->reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 439 | | menu_file_create_populate(machine, menu, state, selection); |
| 440 | | |
| 441 | | if (menustate->confirm_save_as_yes) |
| 360 | if (confirm_save_as_yes) |
| 442 | 361 | { |
| 443 | 362 | /* we just returned from a "confirm save as" dialog and the user said "yes" - fake an event */ |
| 444 | 363 | memset(&fake_event, 0, sizeof(fake_event)); |
| r13553 | r13554 | |
| 449 | 368 | else |
| 450 | 369 | { |
| 451 | 370 | /* process the menu */ |
| 452 | | event = menu->process(0); |
| 371 | event = process(0); |
| 453 | 372 | } |
| 454 | 373 | |
| 455 | 374 | /* process the event */ |
| r13553 | r13554 | |
| 462 | 381 | if ((event->itemref == ITEMREF_CREATE) || (event->itemref == ITEMREF_NEW_IMAGE_NAME)) |
| 463 | 382 | { |
| 464 | 383 | if (create_new_image( |
| 465 | | menustate->manager_menustate->selected_device, |
| 466 | | astring_c(menustate->manager_menustate->current_directory), |
| 467 | | menustate->filename_buffer, |
| 468 | | &menustate->confirm_save_as_yes)) |
| 384 | manager->selected_device, |
| 385 | astring_c(manager->current_directory), |
| 386 | filename_buffer, |
| 387 | &confirm_save_as_yes)) |
| 469 | 388 | { |
| 470 | 389 | /* success - pop out twice to device view */ |
| 471 | | ui_menu::stack_pop(machine); |
| 472 | | ui_menu::stack_pop(machine); |
| 390 | ui_menu::stack_pop(machine()); |
| 391 | ui_menu::stack_pop(machine()); |
| 473 | 392 | } |
| 474 | 393 | } |
| 475 | 394 | break; |
| 476 | 395 | |
| 477 | 396 | case IPT_SPECIAL: |
| 478 | | if (menu->get_selection() == ITEMREF_NEW_IMAGE_NAME) |
| 397 | if (get_selection() == ITEMREF_NEW_IMAGE_NAME) |
| 479 | 398 | { |
| 480 | 399 | input_character( |
| 481 | | menustate->filename_buffer, |
| 482 | | ARRAY_LENGTH(menustate->filename_buffer), |
| 400 | filename_buffer, |
| 401 | ARRAY_LENGTH(filename_buffer), |
| 483 | 402 | event->unichar, |
| 484 | 403 | is_valid_filename_char); |
| 485 | 404 | } |
| r13553 | r13554 | |
| 499 | 418 | special rendering |
| 500 | 419 | -------------------------------------------------*/ |
| 501 | 420 | |
| 502 | | static void file_selector_render_extra(running_machine &machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) |
| 421 | void ui_menu_file_selector::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) |
| 503 | 422 | { |
| 504 | | file_selector_menu_state *menustate = (file_selector_menu_state *) state; |
| 505 | | |
| 506 | | extra_text_render(machine, menu, state, selectedref, top, bottom, |
| 423 | extra_text_render(container, top, bottom, |
| 507 | 424 | origx1, origy1, origx2, origy2, |
| 508 | | astring_c(menustate->manager_menustate->current_directory), |
| 425 | astring_c(manager->current_directory), |
| 509 | 426 | NULL); |
| 510 | 427 | } |
| 511 | 428 | |
| r13553 | r13554 | |
| 516 | 433 | for file selector entries |
| 517 | 434 | -------------------------------------------------*/ |
| 518 | 435 | |
| 519 | | static int compare_file_selector_entries(const file_selector_entry *e1, const file_selector_entry *e2) |
| 436 | int ui_menu_file_selector::compare_entries(const file_selector_entry *e1, const file_selector_entry *e2) |
| 520 | 437 | { |
| 521 | 438 | int result; |
| 522 | 439 | const char *e1_basename = (e1->basename != NULL) ? e1->basename : ""; |
| r13553 | r13554 | |
| 552 | 469 | |
| 553 | 470 | |
| 554 | 471 | /*------------------------------------------------- |
| 555 | | append_file_selector_entry - appends a new |
| 472 | append_entry - appends a new |
| 556 | 473 | file selector entry to an entry list |
| 557 | 474 | -------------------------------------------------*/ |
| 558 | 475 | |
| 559 | | static file_selector_entry *append_file_selector_entry(ui_menu *menu, file_selector_menu_state *menustate, |
| 476 | ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_entry( |
| 560 | 477 | file_selector_entry_type entry_type, const char *entry_basename, const char *entry_fullpath) |
| 561 | 478 | { |
| 562 | 479 | file_selector_entry *entry; |
| 563 | 480 | file_selector_entry **entryptr; |
| 564 | 481 | |
| 565 | 482 | /* allocate a new entry */ |
| 566 | | entry = (file_selector_entry *) menu->m_pool_alloc(sizeof(*entry)); |
| 483 | entry = (file_selector_entry *) m_pool_alloc(sizeof(*entry)); |
| 567 | 484 | memset(entry, 0, sizeof(*entry)); |
| 568 | 485 | entry->type = entry_type; |
| 569 | | entry->basename = (entry_basename != NULL) ? menu->pool_strdup(entry_basename) : entry_basename; |
| 570 | | entry->fullpath = (entry_fullpath != NULL) ? menu->pool_strdup(entry_fullpath) : entry_fullpath; |
| 486 | entry->basename = (entry_basename != NULL) ? pool_strdup(entry_basename) : entry_basename; |
| 487 | entry->fullpath = (entry_fullpath != NULL) ? pool_strdup(entry_fullpath) : entry_fullpath; |
| 571 | 488 | |
| 572 | 489 | /* find the end of the list */ |
| 573 | | entryptr = &menustate->entrylist; |
| 574 | | while ((*entryptr != NULL) && (compare_file_selector_entries(entry, *entryptr) >= 0)) |
| 490 | entryptr = &entrylist; |
| 491 | while ((*entryptr != NULL) && (compare_entries(entry, *entryptr) >= 0)) |
| 575 | 492 | entryptr = &(*entryptr)->next; |
| 576 | 493 | |
| 577 | 494 | /* insert the entry */ |
| r13553 | r13554 | |
| 583 | 500 | |
| 584 | 501 | |
| 585 | 502 | /*------------------------------------------------- |
| 586 | | append_file_selector_entry_menu_item - appends |
| 503 | append_entry_menu_item - appends |
| 587 | 504 | a menu item for a file selector entry |
| 588 | 505 | -------------------------------------------------*/ |
| 589 | 506 | |
| 590 | | static file_selector_entry *append_dirent_file_selector_entry(ui_menu *menu, file_selector_menu_state *menustate, |
| 591 | | const osd_directory_entry *dirent) |
| 507 | ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_dirent_entry(const osd_directory_entry *dirent) |
| 592 | 508 | { |
| 593 | 509 | astring *buffer; |
| 594 | 510 | file_selector_entry_type entry_type; |
| r13553 | r13554 | |
| 612 | 528 | /* determine the full path */ |
| 613 | 529 | buffer = zippath_combine( |
| 614 | 530 | astring_alloc(), |
| 615 | | astring_c(menustate->manager_menustate->current_directory), |
| 531 | astring_c(manager->current_directory), |
| 616 | 532 | dirent->name); |
| 617 | 533 | |
| 618 | 534 | /* create the file selector entry */ |
| 619 | | entry = append_file_selector_entry( |
| 620 | | menu, |
| 621 | | menustate, |
| 535 | entry = append_entry( |
| 622 | 536 | entry_type, |
| 623 | 537 | dirent->name, |
| 624 | 538 | astring_c(buffer)); |
| r13553 | r13554 | |
| 630 | 544 | |
| 631 | 545 | |
| 632 | 546 | /*------------------------------------------------- |
| 633 | | append_file_selector_entry_menu_item - appends |
| 547 | append_entry_menu_item - appends |
| 634 | 548 | a menu item for a file selector entry |
| 635 | 549 | -------------------------------------------------*/ |
| 636 | 550 | |
| 637 | | static void append_file_selector_entry_menu_item(ui_menu *menu, const file_selector_entry *entry) |
| 551 | void ui_menu_file_selector::append_entry_menu_item(const file_selector_entry *entry) |
| 638 | 552 | { |
| 639 | 553 | const char *text = NULL; |
| 640 | 554 | const char *subtext = NULL; |
| r13553 | r13554 | |
| 668 | 582 | subtext = "[FILE]"; |
| 669 | 583 | break; |
| 670 | 584 | } |
| 671 | | menu->item_append(text, subtext, 0, (void *) entry); |
| 585 | item_append(text, subtext, 0, (void *) entry); |
| 672 | 586 | } |
| 673 | 587 | |
| 674 | 588 | |
| r13553 | r13554 | |
| 677 | 591 | allocates all menu items for a directory |
| 678 | 592 | -------------------------------------------------*/ |
| 679 | 593 | |
| 680 | | static file_error menu_file_selector_populate(running_machine &machine, ui_menu *menu, file_selector_menu_state *menustate) |
| 594 | ui_menu_file_selector::ui_menu_file_selector(running_machine &machine, render_container *container, ui_menu_file_manager *parent) : ui_menu(machine, container) |
| 681 | 595 | { |
| 596 | manager = parent; |
| 597 | } |
| 598 | |
| 599 | ui_menu_file_selector::~ui_menu_file_selector() |
| 600 | { |
| 601 | } |
| 602 | |
| 603 | void ui_menu_file_selector::populate() |
| 604 | { |
| 682 | 605 | zippath_directory *directory = NULL; |
| 683 | 606 | file_error err = FILERR_NONE; |
| 684 | 607 | const osd_directory_entry *dirent; |
| r13553 | r13554 | |
| 686 | 609 | const file_selector_entry *selected_entry = NULL; |
| 687 | 610 | int i; |
| 688 | 611 | const char *volume_name; |
| 689 | | device_image_interface *device = menustate->manager_menustate->selected_device; |
| 690 | | const char *path = astring_c(menustate->manager_menustate->current_directory); |
| 612 | device_image_interface *device = manager->selected_device; |
| 613 | const char *path = astring_c(manager->current_directory); |
| 691 | 614 | |
| 692 | 615 | /* open the directory */ |
| 693 | 616 | err = zippath_opendir(path, &directory); |
| r13553 | r13554 | |
| 695 | 618 | goto done; |
| 696 | 619 | |
| 697 | 620 | /* clear out the menu entries */ |
| 698 | | menustate->entrylist = NULL; |
| 621 | entrylist = NULL; |
| 699 | 622 | |
| 700 | 623 | /* add the "[empty slot]" entry */ |
| 701 | | append_file_selector_entry(menu, menustate, SELECTOR_ENTRY_TYPE_EMPTY, NULL, NULL); |
| 624 | append_entry(SELECTOR_ENTRY_TYPE_EMPTY, NULL, NULL); |
| 702 | 625 | |
| 703 | 626 | if (device->is_creatable() && !zippath_is_zip(directory)) |
| 704 | 627 | { |
| 705 | 628 | /* add the "[create]" entry */ |
| 706 | | append_file_selector_entry(menu, menustate, SELECTOR_ENTRY_TYPE_CREATE, NULL, NULL); |
| 629 | append_entry(SELECTOR_ENTRY_TYPE_CREATE, NULL, NULL); |
| 707 | 630 | } |
| 708 | 631 | |
| 709 | 632 | /* add the "[software list]" entry */ |
| 710 | | append_file_selector_entry(menu, menustate, SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, NULL, NULL); |
| 633 | append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, NULL, NULL); |
| 711 | 634 | |
| 712 | 635 | /* add the drives */ |
| 713 | 636 | i = 0; |
| 714 | 637 | while((volume_name = osd_get_volume_name(i))!=NULL) |
| 715 | 638 | { |
| 716 | | append_file_selector_entry(menu, menustate, SELECTOR_ENTRY_TYPE_DRIVE, |
| 639 | append_entry(SELECTOR_ENTRY_TYPE_DRIVE, |
| 717 | 640 | volume_name, volume_name); |
| 718 | 641 | i++; |
| 719 | 642 | } |
| r13553 | r13554 | |
| 722 | 645 | while((dirent = zippath_readdir(directory)) != NULL) |
| 723 | 646 | { |
| 724 | 647 | /* append a dirent entry */ |
| 725 | | entry = append_dirent_file_selector_entry(menu, menustate, dirent); |
| 648 | entry = append_dirent_entry(dirent); |
| 726 | 649 | |
| 727 | 650 | if (entry != NULL) |
| 728 | 651 | { |
| r13553 | r13554 | |
| 731 | 654 | selected_entry = entry; |
| 732 | 655 | |
| 733 | 656 | /* do we have to select this file? */ |
| 734 | | if (!mame_stricmp(astring_c(menustate->manager_menustate->current_file), dirent->name)) |
| 657 | if (!mame_stricmp(astring_c(manager->current_file), dirent->name)) |
| 735 | 658 | selected_entry = entry; |
| 736 | 659 | } |
| 737 | 660 | } |
| 738 | 661 | |
| 739 | 662 | /* append all of the menu entries */ |
| 740 | | for (entry = menustate->entrylist; entry != NULL; entry = entry->next) |
| 741 | | append_file_selector_entry_menu_item(menu, entry); |
| 663 | for (entry = entrylist; entry != NULL; entry = entry->next) |
| 664 | append_entry_menu_item(entry); |
| 742 | 665 | |
| 743 | 666 | /* set the selection (if we have one) */ |
| 744 | 667 | if (selected_entry != NULL) |
| 745 | | menu->set_selection((void *) selected_entry); |
| 668 | set_selection((void *) selected_entry); |
| 746 | 669 | |
| 747 | 670 | /* set up custom render proc */ |
| 748 | | menu->set_custom_render(file_selector_render_extra, ui_get_line_height(machine) + 3.0f * UI_BOX_TB_BORDER, 0); |
| 671 | customtop = ui_get_line_height(machine()) + 3.0f * UI_BOX_TB_BORDER; |
| 749 | 672 | |
| 750 | 673 | done: |
| 751 | 674 | if (directory != NULL) |
| 752 | 675 | zippath_closedir(directory); |
| 753 | | return err; |
| 754 | 676 | } |
| 755 | 677 | |
| 756 | | |
| 757 | | |
| 758 | 678 | /*------------------------------------------------- |
| 759 | 679 | check_path - performs a quick check to see if |
| 760 | 680 | a path exists |
| r13553 | r13554 | |
| 771 | 691 | menu_file_selector - file selector menu |
| 772 | 692 | -------------------------------------------------*/ |
| 773 | 693 | |
| 774 | | static void menu_file_selector(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 694 | void ui_menu_file_selector::handle() |
| 775 | 695 | { |
| 776 | 696 | file_error err; |
| 777 | | const ui_menu_event *event; |
| 778 | | ui_menu *child_menu; |
| 779 | | file_selector_menu_state *menustate; |
| 780 | | file_create_menu_state *child_menustate; |
| 781 | 697 | const file_selector_entry *entry; |
| 782 | 698 | const file_selector_entry *selected_entry = NULL; |
| 783 | 699 | int bestmatch = 0; |
| 784 | 700 | |
| 785 | | /* get menu state */ |
| 786 | | menustate = (file_selector_menu_state *) state; |
| 787 | | |
| 788 | | /* if the menu isn't built, populate now */ |
| 789 | | if (!menu->populated()) |
| 790 | | { |
| 791 | | err = menu_file_selector_populate(machine, menu, menustate); |
| 792 | | |
| 793 | | /* pop out if there was an error */ |
| 794 | | if (err != FILERR_NONE) |
| 795 | | { |
| 796 | | ui_menu::stack_pop(machine); |
| 797 | | return; |
| 798 | | } |
| 799 | | } |
| 800 | | |
| 801 | 701 | /* process the menu */ |
| 802 | | event = menu->process(0); |
| 702 | const ui_menu_event *event = process(0); |
| 803 | 703 | if (event != NULL && event->itemref != NULL) |
| 804 | 704 | { |
| 805 | 705 | /* handle selections */ |
| r13553 | r13554 | |
| 810 | 710 | { |
| 811 | 711 | case SELECTOR_ENTRY_TYPE_EMPTY: |
| 812 | 712 | /* empty slot - unload */ |
| 813 | | menustate->manager_menustate->selected_device->unload(); |
| 814 | | ui_menu::stack_pop(machine); |
| 713 | manager->selected_device->unload(); |
| 714 | ui_menu::stack_pop(machine()); |
| 815 | 715 | break; |
| 816 | 716 | |
| 817 | 717 | case SELECTOR_ENTRY_TYPE_CREATE: |
| 818 | 718 | /* create */ |
| 819 | | child_menu = ui_menu_alloc(machine, &machine.render().ui_container(), menu_file_create, NULL); |
| 820 | | child_menustate = (file_create_menu_state*)child_menu->alloc_state(sizeof(*child_menustate), NULL); |
| 821 | | child_menustate->manager_menustate = menustate->manager_menustate; |
| 822 | | ui_menu::stack_push(child_menu); |
| 719 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_create(machine(), container, manager))); |
| 823 | 720 | break; |
| 824 | 721 | case SELECTOR_ENTRY_TYPE_SOFTWARE_LIST: |
| 825 | | child_menu = ui_menu_alloc(machine, &machine.render().ui_container(), ui_image_menu_software, menustate->manager_menustate->selected_device); |
| 826 | | ui_menu::stack_push(child_menu); |
| 722 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software(machine(), container, manager->selected_device))); |
| 827 | 723 | break; |
| 828 | 724 | case SELECTOR_ENTRY_TYPE_DRIVE: |
| 829 | 725 | case SELECTOR_ENTRY_TYPE_DIRECTORY: |
| r13553 | r13554 | |
| 835 | 731 | ui_popup_time(1, "Error accessing %s", entry->fullpath); |
| 836 | 732 | break; |
| 837 | 733 | } |
| 838 | | astring_cpyc(menustate->manager_menustate->current_directory, entry->fullpath); |
| 839 | | menu->reset((ui_menu_reset_options)0); |
| 734 | astring_cpyc(manager->current_directory, entry->fullpath); |
| 735 | reset((ui_menu_reset_options)0); |
| 840 | 736 | break; |
| 841 | 737 | |
| 842 | 738 | case SELECTOR_ENTRY_TYPE_FILE: |
| 843 | 739 | /* file */ |
| 844 | | menustate->manager_menustate->selected_device->load(entry->fullpath); |
| 845 | | ui_menu::stack_pop(machine); |
| 740 | manager->selected_device->load(entry->fullpath); |
| 741 | ui_menu::stack_pop(machine()); |
| 846 | 742 | break; |
| 847 | 743 | } |
| 848 | 744 | |
| 849 | 745 | // reset the char buffer when pressing IPT_UI_SELECT |
| 850 | | if (menustate->filename_buffer[0] != '\0') |
| 851 | | memset(menustate->filename_buffer, '\0', ARRAY_LENGTH(menustate->filename_buffer)); |
| 746 | if (filename_buffer[0] != '\0') |
| 747 | memset(filename_buffer, '\0', ARRAY_LENGTH(filename_buffer)); |
| 852 | 748 | } |
| 853 | 749 | else if (event->iptkey == IPT_SPECIAL) |
| 854 | 750 | { |
| 855 | | int buflen = strlen(menustate->filename_buffer); |
| 751 | int buflen = strlen(filename_buffer); |
| 856 | 752 | bool update_selected = FALSE; |
| 857 | 753 | |
| 858 | 754 | /* if it's a backspace and we can handle it, do so */ |
| 859 | 755 | if ((event->unichar == 8 || event->unichar == 0x7f) && buflen > 0) |
| 860 | 756 | { |
| 861 | | *(char *)utf8_previous_char(&menustate->filename_buffer[buflen]) = 0; |
| 757 | *(char *)utf8_previous_char(&filename_buffer[buflen]) = 0; |
| 862 | 758 | update_selected = TRUE; |
| 863 | 759 | |
| 864 | | if (ARRAY_LENGTH(menustate->filename_buffer) > 0) |
| 865 | | ui_popup_time(ERROR_MESSAGE_TIME, "%s", menustate->filename_buffer); |
| 760 | if (ARRAY_LENGTH(filename_buffer) > 0) |
| 761 | ui_popup_time(ERROR_MESSAGE_TIME, "%s", filename_buffer); |
| 866 | 762 | } |
| 867 | 763 | /* if it's any other key and we're not maxed out, update */ |
| 868 | 764 | else if (event->unichar >= ' ' && event->unichar < 0x7f) |
| 869 | 765 | { |
| 870 | | buflen += utf8_from_uchar(&menustate->filename_buffer[buflen], ARRAY_LENGTH(menustate->filename_buffer) - buflen, event->unichar); |
| 871 | | menustate->filename_buffer[buflen] = 0; |
| 766 | buflen += utf8_from_uchar(&filename_buffer[buflen], ARRAY_LENGTH(filename_buffer) - buflen, event->unichar); |
| 767 | filename_buffer[buflen] = 0; |
| 872 | 768 | update_selected = TRUE; |
| 873 | 769 | |
| 874 | | if (ARRAY_LENGTH(menustate->filename_buffer) > 0) |
| 875 | | ui_popup_time(ERROR_MESSAGE_TIME, "%s", menustate->filename_buffer); |
| 770 | if (ARRAY_LENGTH(filename_buffer) > 0) |
| 771 | ui_popup_time(ERROR_MESSAGE_TIME, "%s", filename_buffer); |
| 876 | 772 | } |
| 877 | 773 | |
| 878 | 774 | if (update_selected) |
| 879 | 775 | { |
| 880 | | const file_selector_entry *cur_selected = (const file_selector_entry *)menu->get_selection(); |
| 776 | const file_selector_entry *cur_selected = (const file_selector_entry *)get_selection(); |
| 881 | 777 | |
| 882 | 778 | // check for entries which matches our filename_buffer: |
| 883 | 779 | // from current entry to the end |
| 884 | 780 | for (entry = cur_selected; entry != NULL; entry = entry->next) |
| 885 | 781 | { |
| 886 | | if (entry->basename != NULL && menustate->filename_buffer != NULL) |
| 782 | if (entry->basename != NULL && filename_buffer != NULL) |
| 887 | 783 | { |
| 888 | 784 | int match = 0; |
| 889 | | for (int i = 0; i < ARRAY_LENGTH(menustate->filename_buffer); i++) |
| 785 | for (int i = 0; i < ARRAY_LENGTH(filename_buffer); i++) |
| 890 | 786 | { |
| 891 | | if (mame_strnicmp(entry->basename, menustate->filename_buffer, i) == 0) |
| 787 | if (mame_strnicmp(entry->basename, filename_buffer, i) == 0) |
| 892 | 788 | match = i; |
| 893 | 789 | } |
| 894 | 790 | |
| r13553 | r13554 | |
| 900 | 796 | } |
| 901 | 797 | } |
| 902 | 798 | // and from the first entry to current one |
| 903 | | for (entry = menustate->entrylist; entry != cur_selected; entry = entry->next) |
| 799 | for (entry = entrylist; entry != cur_selected; entry = entry->next) |
| 904 | 800 | { |
| 905 | | if (entry->basename != NULL && menustate->filename_buffer != NULL) |
| 801 | if (entry->basename != NULL && filename_buffer != NULL) |
| 906 | 802 | { |
| 907 | 803 | int match = 0; |
| 908 | | for (int i = 0; i < ARRAY_LENGTH(menustate->filename_buffer); i++) |
| 804 | for (int i = 0; i < ARRAY_LENGTH(filename_buffer); i++) |
| 909 | 805 | { |
| 910 | | if (mame_strnicmp(entry->basename, menustate->filename_buffer, i) == 0) |
| 806 | if (mame_strnicmp(entry->basename, filename_buffer, i) == 0) |
| 911 | 807 | match = i; |
| 912 | 808 | } |
| 913 | 809 | |
| r13553 | r13554 | |
| 920 | 816 | } |
| 921 | 817 | |
| 922 | 818 | if (selected_entry != NULL && selected_entry != cur_selected) |
| 923 | | menu->set_selection((void *) selected_entry); |
| 819 | set_selection((void *) selected_entry); |
| 924 | 820 | } |
| 925 | 821 | } |
| 926 | 822 | else if (event->iptkey == IPT_UI_CANCEL) |
| 927 | 823 | { |
| 928 | 824 | // reset the char buffer also in this case |
| 929 | | if (menustate->filename_buffer[0] != '\0') |
| 930 | | memset(menustate->filename_buffer, '\0', ARRAY_LENGTH(menustate->filename_buffer)); |
| 825 | if (filename_buffer[0] != '\0') |
| 826 | memset(filename_buffer, '\0', ARRAY_LENGTH(filename_buffer)); |
| 931 | 827 | } |
| 932 | 828 | } |
| 933 | 829 | } |
| r13553 | r13554 | |
| 944 | 840 | "makes sense" |
| 945 | 841 | -------------------------------------------------*/ |
| 946 | 842 | |
| 947 | | static void fix_working_directory(device_image_interface *image) |
| 843 | void ui_menu_file_manager::fix_working_directory(device_image_interface *image) |
| 948 | 844 | { |
| 949 | 845 | /* if the image exists, set the working directory to the parent directory */ |
| 950 | 846 | if (image->exists()) |
| r13553 | r13554 | |
| 967 | 863 | special rendering |
| 968 | 864 | -------------------------------------------------*/ |
| 969 | 865 | |
| 970 | | static void file_manager_render_extra(running_machine &machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) |
| 866 | void ui_menu_file_manager::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) |
| 971 | 867 | { |
| 972 | | file_manager_menu_state *menustate = (file_manager_menu_state *) state; |
| 973 | 868 | const char *path; |
| 974 | 869 | |
| 975 | 870 | /* access the path */ |
| 976 | | path = (menustate->selected_device != NULL) ? menustate->selected_device->filename() : NULL; |
| 977 | | extra_text_render(machine, menu, state, selectedref, top, bottom, |
| 978 | | origx1, origy1, origx2, origy2, NULL, path); |
| 871 | path = selected_device ? selected_device->filename() : NULL; |
| 872 | extra_text_render(container, top, bottom, |
| 873 | origx1, origy1, origx2, origy2, NULL, path); |
| 979 | 874 | } |
| 980 | 875 | |
| 981 | 876 | |
| r13553 | r13554 | |
| 985 | 880 | file manager menu |
| 986 | 881 | -------------------------------------------------*/ |
| 987 | 882 | |
| 988 | | static void menu_file_manager_populate(running_machine &machine, ui_menu *menu, void *state) |
| 883 | ui_menu_file_manager::ui_menu_file_manager(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 989 | 884 | { |
| 885 | current_directory = astring_alloc(); |
| 886 | current_file = astring_alloc(); |
| 887 | } |
| 888 | |
| 889 | void ui_menu_file_manager::populate() |
| 890 | { |
| 990 | 891 | char buffer[2048]; |
| 991 | 892 | device_image_interface *image = NULL; |
| 992 | 893 | astring tmp_name; |
| 993 | 894 | |
| 994 | 895 | /* cycle through all devices for this system */ |
| 995 | | for (bool gotone = machine.devicelist().first(image); gotone; gotone = image->next(image)) |
| 896 | for (bool gotone = machine().devicelist().first(image); gotone; gotone = image->next(image)) |
| 996 | 897 | { |
| 997 | 898 | /* get the image type/id */ |
| 998 | 899 | snprintf(buffer, ARRAY_LENGTH(buffer), |
| r13553 | r13554 | |
| 1026 | 927 | tmp_name.cpy("---"); |
| 1027 | 928 | |
| 1028 | 929 | /* record the menu item */ |
| 1029 | | menu->item_append(buffer, tmp_name.cstr(), 0, (void *) image); |
| 930 | item_append(buffer, tmp_name.cstr(), 0, (void *) image); |
| 1030 | 931 | } |
| 1031 | 932 | |
| 1032 | | /* set up custom render proc */ |
| 1033 | | menu->set_custom_render(file_manager_render_extra, 0, ui_get_line_height(machine) + 3.0f * UI_BOX_TB_BORDER); |
| 933 | custombottom = ui_get_line_height(machine()) + 3.0f * UI_BOX_TB_BORDER; |
| 1034 | 934 | } |
| 1035 | 935 | |
| 1036 | 936 | |
| r13553 | r13554 | |
| 1039 | 939 | file_manager_destroy_state - state destructor |
| 1040 | 940 | -------------------------------------------------*/ |
| 1041 | 941 | |
| 1042 | | static void file_manager_destroy_state(ui_menu *menu, void *state) |
| 942 | ui_menu_file_manager::~ui_menu_file_manager() |
| 1043 | 943 | { |
| 1044 | | file_manager_menu_state *menustate = (file_manager_menu_state *) state; |
| 1045 | | |
| 1046 | | if (menustate->current_directory != NULL) |
| 1047 | | astring_free(menustate->current_directory); |
| 1048 | | |
| 1049 | | if (menustate->current_file != NULL) |
| 1050 | | astring_free(menustate->current_file); |
| 944 | astring_free(current_directory); |
| 945 | astring_free(current_file); |
| 1051 | 946 | } |
| 1052 | 947 | |
| 1053 | 948 | |
| r13553 | r13554 | |
| 1056 | 951 | menu_file_manager - main file manager menu |
| 1057 | 952 | -------------------------------------------------*/ |
| 1058 | 953 | |
| 1059 | | void ui_image_menu_file_manager(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 954 | void ui_menu_file_manager::handle() |
| 1060 | 955 | { |
| 1061 | | const ui_menu_event *event; |
| 1062 | | file_manager_menu_state *menustate; |
| 1063 | | ui_menu *child_menu; |
| 1064 | | file_selector_menu_state *child_menustate; |
| 1065 | | |
| 1066 | | /* if no state, allocate now */ |
| 1067 | | if (state == NULL) |
| 1068 | | { |
| 1069 | | state = menu->alloc_state(sizeof(*menustate), file_manager_destroy_state); |
| 1070 | | menustate = (file_manager_menu_state *) state; |
| 1071 | | |
| 1072 | | menustate->current_directory = astring_alloc(); |
| 1073 | | menustate->current_file = astring_alloc(); |
| 1074 | | } |
| 1075 | | menustate = (file_manager_menu_state *) state; |
| 1076 | | |
| 1077 | | /* if the menu isn't built, populate now */ |
| 1078 | | if (!menu->populated()) |
| 1079 | | menu_file_manager_populate(machine, menu, state); |
| 1080 | | |
| 1081 | 956 | /* update the selected device */ |
| 1082 | | menustate->selected_device = (device_image_interface *) menu->get_selection(); |
| 957 | selected_device = (device_image_interface *) get_selection(); |
| 1083 | 958 | |
| 1084 | 959 | /* process the menu */ |
| 1085 | | event = menu->process(0); |
| 960 | const ui_menu_event *event = process(0); |
| 1086 | 961 | if (event != NULL && event->iptkey == IPT_UI_SELECT) |
| 1087 | 962 | { |
| 1088 | | menustate->selected_device = (device_image_interface *) event->itemref; |
| 1089 | | if (menustate->selected_device != NULL) |
| 963 | selected_device = (device_image_interface *) event->itemref; |
| 964 | if (selected_device != NULL) |
| 1090 | 965 | { |
| 1091 | 966 | /* ensure that the working directory for this device exists */ |
| 1092 | | fix_working_directory(menustate->selected_device); |
| 967 | fix_working_directory(selected_device); |
| 1093 | 968 | |
| 1094 | 969 | /* set up current_directory and current_file - depends on whether we have an image */ |
| 1095 | | astring_cpyc(menustate->current_directory, menustate->selected_device->working_directory()); |
| 1096 | | astring_cpyc(menustate->current_file, menustate->selected_device->exists() ? menustate->selected_device->basename() : ""); |
| 970 | astring_cpyc(current_directory, selected_device->working_directory()); |
| 971 | astring_cpyc(current_file, selected_device->exists() ? selected_device->basename() : ""); |
| 1097 | 972 | |
| 1098 | 973 | /* reset the existing menu */ |
| 1099 | | menu->reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 974 | reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 1100 | 975 | |
| 1101 | 976 | /* push the menu */ |
| 1102 | | child_menu = ui_menu_alloc(machine, &machine.render().ui_container(), menu_file_selector, NULL); |
| 1103 | | child_menustate = (file_selector_menu_state *)child_menu->alloc_state(sizeof(*child_menustate), NULL); |
| 1104 | | child_menustate->manager_menustate = menustate; |
| 1105 | | ui_menu::stack_push(child_menu); |
| 977 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_selector(machine(), container, this))); |
| 1106 | 978 | } |
| 1107 | 979 | } |
| 1108 | 980 | } |
| 1109 | 981 | |
| 1110 | 982 | /*------------------------------------------------- |
| 1111 | | ui_image_menu_image_info - menu that shows info |
| 983 | ui_menu_image_info - menu that shows info |
| 1112 | 984 | on all loaded images |
| 1113 | 985 | -------------------------------------------------*/ |
| 1114 | 986 | |
| 1115 | | void ui_image_menu_image_info(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 987 | ui_menu_image_info::ui_menu_image_info(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 1116 | 988 | { |
| 1117 | | /* if the menu isn't built, populate now */ |
| 1118 | | if (!menu->populated()) |
| 1119 | | { |
| 1120 | | astring *tempstring = image_info_astring(machine, astring_alloc()); |
| 1121 | | menu->item_append(astring_c(tempstring), NULL, MENU_FLAG_MULTILINE, NULL); |
| 1122 | | astring_free(tempstring); |
| 1123 | | } |
| 989 | } |
| 1124 | 990 | |
| 991 | void ui_menu_image_info::populate() |
| 992 | { |
| 993 | astring *tempstring = image_info_astring(machine(), astring_alloc()); |
| 994 | item_append(astring_c(tempstring), NULL, MENU_FLAG_MULTILINE, NULL); |
| 995 | astring_free(tempstring); |
| 996 | } |
| 997 | |
| 998 | ui_menu_image_info::~ui_menu_image_info() |
| 999 | { |
| 1000 | } |
| 1001 | |
| 1002 | void ui_menu_image_info::handle() |
| 1003 | { |
| 1125 | 1004 | /* process the menu */ |
| 1126 | | menu->process(0); |
| 1005 | process(0); |
| 1127 | 1006 | } |
| 1128 | 1007 | |
| 1129 | 1008 | /*************************************************************************** |
| r13553 | r13554 | |
| 1144 | 1023 | #define BITBANGERCMD_TUNE ((void *) 0x0003) |
| 1145 | 1024 | |
| 1146 | 1025 | |
| 1147 | | typedef struct _tape_control_menu_state tape_control_menu_state; |
| 1148 | | struct _tape_control_menu_state |
| 1026 | /*************************************************************************** |
| 1027 | IMPLEMENTATION |
| 1028 | ***************************************************************************/ |
| 1029 | |
| 1030 | ui_menu_mess_tape_control::ui_menu_mess_tape_control(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 1149 | 1031 | { |
| 1150 | | int index; |
| 1151 | | device_image_interface *device; |
| 1152 | | }; |
| 1032 | } |
| 1153 | 1033 | |
| 1034 | ui_menu_mess_tape_control::~ui_menu_mess_tape_control() |
| 1035 | { |
| 1036 | } |
| 1154 | 1037 | |
| 1038 | ui_menu_mess_bitbanger_control::ui_menu_mess_bitbanger_control(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 1039 | { |
| 1040 | } |
| 1155 | 1041 | |
| 1156 | | typedef struct _bitbanger_control_menu_state bitbanger_control_menu_state; |
| 1157 | | struct _bitbanger_control_menu_state |
| 1042 | ui_menu_mess_bitbanger_control::~ui_menu_mess_bitbanger_control() |
| 1158 | 1043 | { |
| 1159 | | int index; |
| 1160 | | device_image_interface *device; |
| 1161 | | }; |
| 1044 | } |
| 1162 | 1045 | |
| 1163 | | |
| 1164 | | |
| 1165 | | /*************************************************************************** |
| 1166 | | IMPLEMENTATION |
| 1167 | | ***************************************************************************/ |
| 1168 | | |
| 1169 | 1046 | /*------------------------------------------------- |
| 1170 | 1047 | cassette_count - returns the number of cassette |
| 1171 | 1048 | devices in the machine |
| 1172 | 1049 | -------------------------------------------------*/ |
| 1173 | 1050 | |
| 1174 | | INLINE int cassette_count( running_machine &machine ) |
| 1051 | int ui_menu_mess_tape_control::cassette_count() |
| 1175 | 1052 | { |
| 1176 | 1053 | int count = 0; |
| 1177 | | device_t *device = machine.devicelist().first(CASSETTE); |
| 1054 | device_t *device = machine().devicelist().first(CASSETTE); |
| 1178 | 1055 | |
| 1179 | 1056 | while ( device ) |
| 1180 | 1057 | { |
| r13553 | r13554 | |
| 1189 | 1066 | devices in the machine |
| 1190 | 1067 | -------------------------------------------------*/ |
| 1191 | 1068 | |
| 1192 | | INLINE int bitbanger_count( running_machine &machine ) |
| 1069 | int ui_menu_mess_bitbanger_control::bitbanger_count() |
| 1193 | 1070 | { |
| 1194 | 1071 | int count = 0; |
| 1195 | | device_t *device = machine.devicelist().first(BITBANGER); |
| 1072 | device_t *device = machine().devicelist().first(BITBANGER); |
| 1196 | 1073 | |
| 1197 | 1074 | while ( device ) |
| 1198 | 1075 | { |
| r13553 | r13554 | |
| 1234 | 1111 | main tape control menu |
| 1235 | 1112 | -------------------------------------------------*/ |
| 1236 | 1113 | |
| 1237 | | static void menu_tape_control_populate(running_machine &machine, ui_menu *menu, tape_control_menu_state *menustate) |
| 1114 | void ui_menu_mess_tape_control::populate() |
| 1238 | 1115 | { |
| 1239 | 1116 | astring timepos; |
| 1240 | 1117 | cassette_state state; |
| 1241 | | int count = cassette_count(machine); |
| 1118 | int count = cassette_count(); |
| 1242 | 1119 | UINT32 flags = 0; |
| 1243 | 1120 | |
| 1244 | 1121 | if( count > 0 ) |
| 1245 | 1122 | { |
| 1246 | | if( menustate->index == (count-1) ) |
| 1123 | if( index == (count-1) ) |
| 1247 | 1124 | flags |= MENU_FLAG_LEFT_ARROW; |
| 1248 | 1125 | else |
| 1249 | 1126 | flags |= MENU_FLAG_RIGHT_ARROW; |
| 1250 | 1127 | } |
| 1251 | 1128 | |
| 1252 | | if (menustate->device->exists()) |
| 1129 | if (device->exists()) |
| 1253 | 1130 | { |
| 1254 | 1131 | double t0, t1; |
| 1255 | 1132 | UINT32 tapeflags = 0; |
| 1256 | | cassette_image_device* cassette = dynamic_cast<cassette_image_device*>(&menustate->device->device()); |
| 1133 | cassette_image_device* cassette = dynamic_cast<cassette_image_device*>(&device->device()); |
| 1257 | 1134 | |
| 1258 | 1135 | t0 = cassette->get_position(); |
| 1259 | 1136 | t1 = cassette->get_length(); |
| r13553 | r13554 | |
| 1267 | 1144 | } |
| 1268 | 1145 | |
| 1269 | 1146 | /* name of tape */ |
| 1270 | | menu->item_append(menustate->device->device().name(), menustate->device->filename(), flags, TAPECMD_SELECT); |
| 1147 | item_append(device->device().name(), device->filename(), flags, TAPECMD_SELECT); |
| 1271 | 1148 | |
| 1272 | 1149 | /* state */ |
| 1273 | 1150 | tapecontrol_gettime(&timepos, cassette, NULL, NULL); |
| 1274 | 1151 | state = cassette->get_state(); |
| 1275 | | menu->item_append( |
| 1152 | item_append( |
| 1276 | 1153 | (state & CASSETTE_MASK_UISTATE) == CASSETTE_STOPPED |
| 1277 | 1154 | ? "stopped" |
| 1278 | 1155 | : ((state & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY |
| r13553 | r13554 | |
| 1284 | 1161 | TAPECMD_SLIDER); |
| 1285 | 1162 | |
| 1286 | 1163 | /* pause or stop */ |
| 1287 | | menu->item_append("Pause/Stop", NULL, 0, TAPECMD_STOP); |
| 1164 | item_append("Pause/Stop", NULL, 0, TAPECMD_STOP); |
| 1288 | 1165 | |
| 1289 | 1166 | /* play */ |
| 1290 | | menu->item_append("Play", NULL, 0, TAPECMD_PLAY); |
| 1167 | item_append("Play", NULL, 0, TAPECMD_PLAY); |
| 1291 | 1168 | |
| 1292 | 1169 | /* record */ |
| 1293 | | menu->item_append("Record", NULL, 0, TAPECMD_RECORD); |
| 1170 | item_append("Record", NULL, 0, TAPECMD_RECORD); |
| 1294 | 1171 | |
| 1295 | 1172 | /* rewind */ |
| 1296 | | menu->item_append("Rewind", NULL, 0, TAPECMD_REWIND); |
| 1173 | item_append("Rewind", NULL, 0, TAPECMD_REWIND); |
| 1297 | 1174 | |
| 1298 | 1175 | /* fast forward */ |
| 1299 | | menu->item_append("Fast Forward", NULL, 0, TAPECMD_FAST_FORWARD); |
| 1176 | item_append("Fast Forward", NULL, 0, TAPECMD_FAST_FORWARD); |
| 1300 | 1177 | } |
| 1301 | 1178 | else |
| 1302 | 1179 | { |
| 1303 | 1180 | /* no tape loaded */ |
| 1304 | | menu->item_append("No Tape Image loaded", NULL, flags, NULL); |
| 1181 | item_append("No Tape Image loaded", NULL, flags, NULL); |
| 1305 | 1182 | } |
| 1306 | 1183 | } |
| 1307 | 1184 | |
| r13553 | r13554 | |
| 1311 | 1188 | main bitbanger control menu |
| 1312 | 1189 | -------------------------------------------------*/ |
| 1313 | 1190 | |
| 1314 | | static void menu_bitbanger_control_populate(running_machine &machine, ui_menu *menu, bitbanger_control_menu_state *menustate) |
| 1191 | void ui_menu_mess_bitbanger_control::populate() |
| 1315 | 1192 | { |
| 1316 | | bitbanger_device *bitbanger = downcast<bitbanger_device *>(&menustate->device->device()); |
| 1317 | | int count = bitbanger_count(machine); |
| 1193 | bitbanger_device *bitbanger = downcast<bitbanger_device *>(&device->device()); |
| 1194 | int count = bitbanger_count(); |
| 1318 | 1195 | UINT32 flags = 0, mode_flags = 0, baud_flags = 0, tune_flags = 0; |
| 1319 | 1196 | |
| 1320 | 1197 | if( count > 0 ) |
| 1321 | 1198 | { |
| 1322 | | if( menustate->index == (count-1) ) |
| 1199 | if( index == (count-1) ) |
| 1323 | 1200 | flags |= MENU_FLAG_LEFT_ARROW; |
| 1324 | 1201 | else |
| 1325 | 1202 | flags |= MENU_FLAG_RIGHT_ARROW; |
| r13553 | r13554 | |
| 1344 | 1221 | tune_flags |= MENU_FLAG_LEFT_ARROW; |
| 1345 | 1222 | |
| 1346 | 1223 | |
| 1347 | | if (menustate->device->exists()) |
| 1224 | if (device->exists()) |
| 1348 | 1225 | { |
| 1349 | 1226 | /* name of bitbanger file */ |
| 1350 | | menu->item_append(menustate->device->device().name(), menustate->device->filename(), flags, BITBANGERCMD_SELECT); |
| 1351 | | menu->item_append("Device Mode:", bitbanger->mode_string(), mode_flags, BITBANGERCMD_MODE); |
| 1352 | | menu->item_append("Baud:", bitbanger->baud_string(), baud_flags, BITBANGERCMD_BAUD); |
| 1353 | | menu->item_append("Baud Tune:", bitbanger->tune_string(), tune_flags, BITBANGERCMD_TUNE); |
| 1354 | | menu->item_append("Protocol:", "8-1-N", 0, NULL); |
| 1227 | item_append(device->device().name(), device->filename(), flags, BITBANGERCMD_SELECT); |
| 1228 | item_append("Device Mode:", bitbanger->mode_string(), mode_flags, BITBANGERCMD_MODE); |
| 1229 | item_append("Baud:", bitbanger->baud_string(), baud_flags, BITBANGERCMD_BAUD); |
| 1230 | item_append("Baud Tune:", bitbanger->tune_string(), tune_flags, BITBANGERCMD_TUNE); |
| 1231 | item_append("Protocol:", "8-1-N", 0, NULL); |
| 1355 | 1232 | } |
| 1356 | 1233 | else |
| 1357 | 1234 | { |
| 1358 | 1235 | /* no tape loaded */ |
| 1359 | | menu->item_append("No Bitbanger Image loaded", NULL, flags, NULL); |
| 1236 | item_append("No Bitbanger Image loaded", NULL, flags, NULL); |
| 1360 | 1237 | } |
| 1361 | 1238 | } |
| 1362 | 1239 | |
| r13553 | r13554 | |
| 1365 | 1242 | menu_tape_control - main tape control menu |
| 1366 | 1243 | -------------------------------------------------*/ |
| 1367 | 1244 | |
| 1368 | | void ui_mess_menu_tape_control(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 1245 | void ui_menu_mess_tape_control::handle() |
| 1369 | 1246 | { |
| 1370 | | tape_control_menu_state *menustate; |
| 1371 | | const ui_menu_event *event; |
| 1372 | | |
| 1373 | | /* if no state, allocate some */ |
| 1374 | | if (state == NULL) |
| 1375 | | state = menu->alloc_state(sizeof(*menustate), NULL); |
| 1376 | | menustate = (tape_control_menu_state *) state; |
| 1377 | | |
| 1378 | 1247 | /* do we have to load the device? */ |
| 1379 | | if (menustate->device == NULL) |
| 1248 | if (device == NULL) |
| 1380 | 1249 | { |
| 1381 | | int index = menustate->index; |
| 1382 | | device_image_interface *device = NULL; |
| 1383 | | for (bool gotone = machine.devicelist().first(device); gotone; gotone = device->next(device)) |
| 1250 | int cindex = index; |
| 1251 | for (bool gotone = machine().devicelist().first(device); gotone; gotone = device->next(device)) |
| 1384 | 1252 | { |
| 1385 | 1253 | if(device->device().type() == CASSETTE) { |
| 1386 | | if (index==0) break; |
| 1387 | | index--; |
| 1254 | if (cindex==0) break; |
| 1255 | cindex--; |
| 1388 | 1256 | } |
| 1389 | 1257 | } |
| 1390 | | menustate->device = device; |
| 1391 | | menu->reset((ui_menu_reset_options)0); |
| 1258 | reset((ui_menu_reset_options)0); |
| 1392 | 1259 | } |
| 1393 | 1260 | |
| 1394 | 1261 | /* rebuild the menu - we have to do this so that the counter updates */ |
| 1395 | | menu->reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 1396 | | menu_tape_control_populate(machine, menu, (tape_control_menu_state*)state); |
| 1262 | reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 1263 | populate(); |
| 1397 | 1264 | |
| 1398 | | cassette_image_device* cassette = dynamic_cast<cassette_image_device*>(&menustate->device->device()); |
| 1265 | cassette_image_device* cassette = dynamic_cast<cassette_image_device*>(&device->device()); |
| 1399 | 1266 | |
| 1400 | 1267 | /* process the menu */ |
| 1401 | | event = menu->process(UI_MENU_PROCESS_LR_REPEAT); |
| 1268 | const ui_menu_event *event = process(UI_MENU_PROCESS_LR_REPEAT); |
| 1402 | 1269 | if (event != NULL) |
| 1403 | 1270 | { |
| 1404 | 1271 | switch(event->iptkey) |
| r13553 | r13554 | |
| 1410 | 1277 | if (event->itemref==TAPECMD_SELECT) |
| 1411 | 1278 | { |
| 1412 | 1279 | /* left arrow - rotate left through cassette devices */ |
| 1413 | | if (menustate->index > 0) |
| 1414 | | menustate->index--; |
| 1280 | if (index > 0) |
| 1281 | index--; |
| 1415 | 1282 | else |
| 1416 | | menustate->index = cassette_count(machine) - 1; |
| 1417 | | menustate->device = NULL; |
| 1283 | index = cassette_count() - 1; |
| 1284 | device = NULL; |
| 1418 | 1285 | } |
| 1419 | 1286 | break; |
| 1420 | 1287 | |
| r13553 | r13554 | |
| 1425 | 1292 | if (event->itemref==TAPECMD_SELECT) |
| 1426 | 1293 | { |
| 1427 | 1294 | /* right arrow - rotate right through cassette devices */ |
| 1428 | | if (menustate->index < cassette_count(machine) - 1) |
| 1429 | | menustate->index++; |
| 1295 | if (index < cassette_count() - 1) |
| 1296 | index++; |
| 1430 | 1297 | else |
| 1431 | | menustate->index = 0; |
| 1432 | | menustate->device = NULL; |
| 1298 | index = 0; |
| 1299 | device = NULL; |
| 1433 | 1300 | } |
| 1434 | 1301 | break; |
| 1435 | 1302 | |
| r13553 | r13554 | |
| 1464 | 1331 | control menu |
| 1465 | 1332 | -------------------------------------------------*/ |
| 1466 | 1333 | |
| 1467 | | void ui_mess_menu_bitbanger_control(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 1334 | void ui_menu_mess_bitbanger_control::handle() |
| 1468 | 1335 | { |
| 1469 | | bitbanger_control_menu_state *menustate; |
| 1470 | | const ui_menu_event *event; |
| 1471 | | |
| 1472 | | /* if no state, allocate some */ |
| 1473 | | if (state == NULL) |
| 1474 | | state = menu->alloc_state(sizeof(*menustate), NULL); |
| 1475 | | menustate = (bitbanger_control_menu_state *) state; |
| 1476 | | |
| 1477 | 1336 | /* do we have to load the device? */ |
| 1478 | | if (menustate->device == NULL) |
| 1337 | if (device == NULL) |
| 1479 | 1338 | { |
| 1480 | | int index = menustate->index; |
| 1481 | | device_image_interface *device = NULL; |
| 1482 | | for (bool gotone = machine.devicelist().first(device); gotone; gotone = device->next(device)) |
| 1339 | int cindex = index; |
| 1340 | for (bool gotone = machine().devicelist().first(device); gotone; gotone = device->next(device)) |
| 1483 | 1341 | { |
| 1484 | 1342 | if(device->device().type() == BITBANGER) { |
| 1485 | | if (index==0) break; |
| 1486 | | index--; |
| 1343 | if (cindex==0) break; |
| 1344 | cindex--; |
| 1487 | 1345 | } |
| 1488 | 1346 | } |
| 1489 | | menustate->device = device; |
| 1490 | | menu->reset((ui_menu_reset_options)0); |
| 1347 | reset((ui_menu_reset_options)0); |
| 1491 | 1348 | } |
| 1492 | 1349 | |
| 1493 | 1350 | /* get the bitbanger */ |
| 1494 | | bitbanger_device *bitbanger = downcast<bitbanger_device *>(menustate->device); |
| 1351 | bitbanger_device *bitbanger = downcast<bitbanger_device *>(device); |
| 1495 | 1352 | |
| 1496 | 1353 | /* rebuild the menu */ |
| 1497 | | menu->reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 1498 | | menu_bitbanger_control_populate(machine, menu, (bitbanger_control_menu_state*)state); |
| 1354 | reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 1355 | populate(); |
| 1499 | 1356 | |
| 1500 | 1357 | /* process the menu */ |
| 1501 | | event = menu->process(UI_MENU_PROCESS_LR_REPEAT); |
| 1358 | const ui_menu_event *event = process(UI_MENU_PROCESS_LR_REPEAT); |
| 1502 | 1359 | if (event != NULL) |
| 1503 | 1360 | { |
| 1504 | 1361 | switch(event->iptkey) |
| r13553 | r13554 | |
| 1507 | 1364 | if (event->itemref==BITBANGERCMD_SELECT) |
| 1508 | 1365 | { |
| 1509 | 1366 | /* left arrow - rotate left through cassette devices */ |
| 1510 | | if (menustate->index > 0) |
| 1511 | | menustate->index--; |
| 1367 | if (index > 0) |
| 1368 | index--; |
| 1512 | 1369 | else |
| 1513 | | menustate->index = bitbanger_count(machine) - 1; |
| 1514 | | menustate->device = NULL; |
| 1370 | index = bitbanger_count() - 1; |
| 1371 | device = NULL; |
| 1515 | 1372 | } |
| 1516 | 1373 | else if (event->itemref==BITBANGERCMD_MODE) |
| 1517 | 1374 | { |
| r13553 | r13554 | |
| 1531 | 1388 | if (event->itemref==BITBANGERCMD_SELECT) |
| 1532 | 1389 | { |
| 1533 | 1390 | /* right arrow - rotate right through cassette devices */ |
| 1534 | | if (menustate->index < bitbanger_count(machine) - 1) |
| 1535 | | menustate->index++; |
| 1391 | if (index < bitbanger_count() - 1) |
| 1392 | index++; |
| 1536 | 1393 | else |
| 1537 | | menustate->index = 0; |
| 1538 | | menustate->device = NULL; |
| 1394 | index = 0; |
| 1395 | device = NULL; |
| 1539 | 1396 | } |
| 1540 | 1397 | else if (event->itemref==BITBANGERCMD_MODE) |
| 1541 | 1398 | { |
src/emu/uimain.c
| r13553 | r13554 | |
| 18 | 18 | #include "uiimage.h" |
| 19 | 19 | #include "uiinput.h" |
| 20 | 20 | #include "uimenu.h" |
| 21 | #include "uimain.h" |
| 21 | 22 | #include "audit.h" |
| 22 | 23 | #include "crsshair.h" |
| 23 | 24 | #include <ctype.h> |
| r13553 | r13554 | |
| 30 | 31 | CONSTANTS |
| 31 | 32 | ***************************************************************************/ |
| 32 | 33 | |
| 33 | | #define VISIBLE_GAMES_IN_LIST 15 |
| 34 | | |
| 35 | 34 | #define MAX_PHYSICAL_DIPS 10 |
| 36 | 35 | #define MAX_INPUT_PORTS 32 |
| 37 | 36 | #define MAX_BITS_PER_PORT 32 |
| r13553 | r13554 | |
| 45 | 44 | #define PERCENTAGE_OF_HALF_FIELD_USED 0.80f |
| 46 | 45 | #define SINGLE_TOGGLE_SWITCH_HEIGHT ((DIP_SWITCH_HEIGHT / 2) * PERCENTAGE_OF_HALF_FIELD_USED) |
| 47 | 46 | |
| 47 | /*------------------------------------------------- |
| 48 | ui_slider_ui_handler - pushes the slider |
| 49 | menu on the stack and hands off to the |
| 50 | standard menu handler |
| 51 | -------------------------------------------------*/ |
| 48 | 52 | |
| 49 | | enum |
| 53 | UINT32 ui_menu_sliders::ui_handler(running_machine &machine, render_container *container, UINT32 state) |
| 50 | 54 | { |
| 51 | | INPUT_TYPE_DIGITAL = 0, |
| 52 | | INPUT_TYPE_ANALOG = 1, |
| 53 | | INPUT_TYPE_ANALOG_DEC = INPUT_TYPE_ANALOG + SEQ_TYPE_DECREMENT, |
| 54 | | INPUT_TYPE_ANALOG_INC = INPUT_TYPE_ANALOG + SEQ_TYPE_INCREMENT, |
| 55 | | INPUT_TYPE_TOTAL = INPUT_TYPE_ANALOG + SEQ_TYPE_TOTAL |
| 56 | | }; |
| 55 | UINT32 result; |
| 57 | 56 | |
| 58 | | enum |
| 59 | | { |
| 60 | | ANALOG_ITEM_KEYSPEED = 0, |
| 61 | | ANALOG_ITEM_CENTERSPEED, |
| 62 | | ANALOG_ITEM_REVERSE, |
| 63 | | ANALOG_ITEM_SENSITIVITY, |
| 64 | | ANALOG_ITEM_COUNT |
| 65 | | }; |
| 57 | /* if this is the first call, push the sliders menu */ |
| 58 | if (state) |
| 59 | ui_menu::stack_push(auto_alloc_clear(machine, ui_menu_sliders(machine, container, true))); |
| 66 | 60 | |
| 67 | | enum |
| 68 | | { |
| 69 | | MEMCARD_ITEM_SELECT = 1, |
| 70 | | MEMCARD_ITEM_LOAD, |
| 71 | | MEMCARD_ITEM_EJECT, |
| 72 | | MEMCARD_ITEM_CREATE |
| 73 | | }; |
| 61 | /* handle standard menus */ |
| 62 | result = ui_menu::ui_handler(machine, container, state); |
| 74 | 63 | |
| 75 | | enum |
| 76 | | { |
| 77 | | VIDEO_ITEM_ROTATE = 0x80000000, |
| 78 | | VIDEO_ITEM_BACKDROPS, |
| 79 | | VIDEO_ITEM_OVERLAYS, |
| 80 | | VIDEO_ITEM_BEZELS, |
| 81 | | VIDEO_ITEM_CPANELS, |
| 82 | | VIDEO_ITEM_MARQUEES, |
| 83 | | VIDEO_ITEM_ZOOM, |
| 84 | | VIDEO_ITEM_VIEW |
| 85 | | }; |
| 64 | /* if we are cancelled, pop the sliders menu */ |
| 65 | if (result == UI_HANDLER_CANCEL) |
| 66 | ui_menu::stack_pop(machine); |
| 86 | 67 | |
| 68 | ui_menu_sliders *uim = dynamic_cast<ui_menu_sliders *>(menu_stack); |
| 69 | return uim && uim->menuless_mode ? 0 : UI_HANDLER_CANCEL; |
| 70 | } |
| 87 | 71 | |
| 88 | | enum |
| 89 | | { |
| 90 | | CROSSHAIR_ITEM_VIS = 0, |
| 91 | | CROSSHAIR_ITEM_PIC, |
| 92 | | CROSSHAIR_ITEM_AUTO_TIME |
| 93 | | }; |
| 94 | 72 | |
| 73 | /*------------------------------------------------- |
| 74 | ui_menu_force_game_select - force the game |
| 75 | select menu to be visible and inescapable |
| 76 | -------------------------------------------------*/ |
| 95 | 77 | |
| 96 | | /*************************************************************************** |
| 97 | | TYPE DEFINITIONS |
| 98 | | ***************************************************************************/ |
| 78 | void ui_menu_force_game_select(running_machine &machine, render_container *container) |
| 79 | { |
| 80 | char *gamename = (char *)machine.options().system_name(); |
| 99 | 81 | |
| 82 | /* reset the menu stack */ |
| 83 | ui_menu::stack_reset(machine); |
| 100 | 84 | |
| 85 | /* add the quit entry followed by the game select entry */ |
| 86 | ui_menu *quit = auto_alloc_clear(machine, ui_menu_quit_game(machine, container)); |
| 87 | quit->set_special_main_menu(true); |
| 88 | ui_menu::stack_push(quit); |
| 89 | ui_menu::stack_push(auto_alloc_clear(machine, ui_menu_select_game(machine, container, gamename))); |
| 101 | 90 | |
| 102 | | /* internal input menu item data */ |
| 103 | | struct input_item_data |
| 104 | | { |
| 105 | | input_item_data * next; /* pointer to next item in the list */ |
| 106 | | const void * ref; /* reference to type description for global inputs or field for game inputs */ |
| 107 | | input_seq_type seqtype; /* sequence type */ |
| 108 | | input_seq seq; /* copy of the live sequence */ |
| 109 | | const input_seq * defseq; /* pointer to the default sequence */ |
| 110 | | const char * name; /* pointer to the base name of the item */ |
| 111 | | UINT16 sortorder; /* sorting information */ |
| 112 | | UINT8 type; /* type of port */ |
| 113 | | }; |
| 91 | /* force the menus on */ |
| 92 | ui_show_menu(); |
| 114 | 93 | |
| 94 | /* make sure MAME is paused */ |
| 95 | machine.pause(); |
| 96 | } |
| 115 | 97 | |
| 116 | | /* internal analog menu item data */ |
| 117 | | struct analog_item_data |
| 118 | | { |
| 119 | | input_field_config *field; |
| 120 | | int type; |
| 121 | | int min, max; |
| 122 | | int cur; |
| 123 | | int defvalue; |
| 124 | | }; |
| 125 | 98 | |
| 99 | /*************************************************************************** |
| 100 | MENU HANDLERS |
| 101 | ***************************************************************************/ |
| 126 | 102 | |
| 127 | | /* DIP switch descriptor */ |
| 128 | | struct dip_descriptor |
| 103 | /*------------------------------------------------- |
| 104 | ui_menu_main constructor - populate the main menu |
| 105 | -------------------------------------------------*/ |
| 106 | |
| 107 | ui_menu_main::ui_menu_main(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 129 | 108 | { |
| 130 | | dip_descriptor * next; |
| 131 | | const char * name; |
| 132 | | UINT32 mask; |
| 133 | | UINT32 state; |
| 134 | | }; |
| 109 | } |
| 135 | 110 | |
| 136 | | |
| 137 | | /* extended settings menu state */ |
| 138 | | struct settings_menu_state |
| 111 | void ui_menu_main::populate() |
| 139 | 112 | { |
| 140 | | dip_descriptor * diplist; |
| 141 | | }; |
| 113 | input_field_config *field; |
| 114 | input_port_config *port; |
| 115 | int has_configs = false; |
| 116 | int has_analog = false; |
| 117 | int has_dips = false; |
| 118 | astring menu_text; |
| 119 | /* scan the input port array to see what options we need to enable */ |
| 120 | for (port = machine().m_portlist.first(); port != NULL; port = port->next()) |
| 121 | for (field = port->fieldlist().first(); field != NULL; field = field->next()) |
| 122 | { |
| 123 | if (field->type == IPT_DIPSWITCH) |
| 124 | has_dips = true; |
| 125 | if (field->type == IPT_CONFIG) |
| 126 | has_configs = true; |
| 127 | if (input_type_is_analog(field->type)) |
| 128 | has_analog = true; |
| 129 | } |
| 142 | 130 | |
| 131 | /* add input menu items */ |
| 132 | item_append("Input (general)", NULL, 0, (void *)INPUT_GROUPS); |
| 133 | |
| 134 | menu_text.printf("Input (this %s)",emulator_info::get_capstartgamenoun()); |
| 135 | item_append(menu_text.cstr(), NULL, 0, (void *)INPUT_SPECIFIC); |
| 143 | 136 | |
| 144 | | /* extended input menu state */ |
| 145 | | struct input_menu_state |
| 146 | | { |
| 147 | | UINT16 last_sortorder; |
| 148 | | const void * pollingref; |
| 149 | | input_item_data * pollingitem; |
| 150 | | UINT8 record_next; |
| 151 | | input_seq starting_seq; |
| 152 | | }; |
| 137 | /* add optional input-related menus */ |
| 138 | if (has_dips) |
| 139 | item_append("Dip Switches", NULL, 0, (void *)SETTINGS_DIP_SWITCHES); |
| 140 | if (has_configs) |
| 141 | item_append("Driver Configuration", NULL, 0, (void *)SETTINGS_DRIVER_CONFIG); |
| 142 | if (has_analog) |
| 143 | item_append("Analog Controls", NULL, 0, (void *)ANALOG); |
| 153 | 144 | |
| 145 | /* add bookkeeping menu */ |
| 146 | item_append("Bookkeeping Info", NULL, 0, (void *)BOOKKEEPING); |
| 154 | 147 | |
| 155 | | /* extended select game menu state */ |
| 156 | | struct select_game_state |
| 157 | | { |
| 158 | | UINT8 error; |
| 159 | | UINT8 rerandomize; |
| 160 | | char search[40]; |
| 161 | | int matchlist[VISIBLE_GAMES_IN_LIST]; |
| 162 | | const game_driver * driverlist[1]; |
| 163 | | }; |
| 148 | /* add game info menu */ |
| 149 | menu_text.printf("%s Information",emulator_info::get_capstartgamenoun()); |
| 150 | item_append(menu_text.cstr(), NULL, 0, (void *)GAME_INFO); |
| 164 | 151 | |
| 152 | device_image_interface *image = NULL; |
| 153 | if (machine().devicelist().first(image)) |
| 154 | { |
| 155 | /* add image info menu */ |
| 156 | item_append("Image Information", NULL, 0, (void *)IMAGE_MENU_IMAGE_INFO); |
| 165 | 157 | |
| 166 | | /* internal crosshair menu item data */ |
| 167 | | struct crosshair_item_data |
| 168 | | { |
| 169 | | UINT8 type; |
| 170 | | UINT8 player; |
| 171 | | UINT8 min, max; |
| 172 | | UINT8 cur; |
| 173 | | UINT8 defvalue; |
| 174 | | char last_name[CROSSHAIR_PIC_NAME_LENGTH + 1]; |
| 175 | | char next_name[CROSSHAIR_PIC_NAME_LENGTH + 1]; |
| 176 | | }; |
| 158 | /* add file manager menu */ |
| 159 | item_append("File Manager", NULL, 0, (void *)IMAGE_MENU_FILE_MANAGER); |
| 177 | 160 | |
| 161 | /* add tape control menu */ |
| 162 | if (machine().devicelist().first(CASSETTE)) |
| 163 | item_append("Tape Control", NULL, 0, (void *)MESS_MENU_TAPE_CONTROL); |
| 178 | 164 | |
| 165 | /* add bitbanger control menu */ |
| 166 | if (machine().devicelist().first(BITBANGER)) |
| 167 | item_append("Bitbanger Control", NULL, 0, (void *)MESS_MENU_BITBANGER_CONTROL); |
| 168 | } |
| 179 | 169 | |
| 180 | | /*************************************************************************** |
| 181 | | GLOBAL VARIABLES |
| 182 | | ***************************************************************************/ |
| 170 | device_slot_interface *slot = NULL; |
| 171 | if (machine().devicelist().first(slot)) |
| 172 | { |
| 173 | /* add image info menu */ |
| 174 | item_append("Slot Devices", NULL, 0, (void *)SLOT_DEVICES); |
| 175 | } |
| 183 | 176 | |
| 184 | | // temporary hack until this is C++-ified |
| 185 | | static driver_enumerator *drivlist; |
| 177 | device_network_interface *network = NULL; |
| 178 | if (machine().devicelist().first(network)) |
| 179 | { |
| 180 | /* add image info menu */ |
| 181 | item_append("Network Devices", NULL, 0, (void*)NETWORK_DEVICES); |
| 182 | } |
| 186 | 183 | |
| 187 | | /*************************************************************************** |
| 188 | | FUNCTION PROTOTYPES |
| 189 | | ***************************************************************************/ |
| 184 | /* add keyboard mode menu */ |
| 185 | if (input_machine_has_keyboard(machine()) && inputx_can_post(machine())) |
| 186 | item_append("Keyboard Mode", NULL, 0, (void *)KEYBOARD_MODE); |
| 190 | 187 | |
| 191 | | /* menu handlers */ |
| 192 | | static void menu_main_populate(running_machine &machine, ui_menu *menu, void *state); |
| 193 | | static void menu_input_groups(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 194 | | static void menu_input_groups_populate(running_machine &machine, ui_menu *menu, void *state); |
| 195 | | static void menu_input_general(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 196 | | static void menu_input_general_populate(running_machine &machine, ui_menu *menu, input_menu_state *menustate, int group); |
| 197 | | static void menu_input_specific(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 198 | | static void menu_input_specific_populate(running_machine &machine, ui_menu *menu, input_menu_state *menustate); |
| 199 | | static void menu_input_common(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 200 | | static int CLIB_DECL menu_input_compare_items(const void *i1, const void *i2); |
| 201 | | static void menu_input_populate_and_sort(running_machine &machine, ui_menu *menu, input_item_data *itemlist, input_menu_state *menustate); |
| 202 | | static void menu_settings_dip_switches(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 203 | | static void menu_settings_driver_config(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 204 | | static void menu_settings_common(running_machine &machine, ui_menu *menu, void *state, UINT32 type); |
| 205 | | static void menu_settings_populate(running_machine &machine, ui_menu *menu, settings_menu_state *menustate, UINT32 type); |
| 206 | | static void menu_analog(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 207 | | static void menu_analog_populate(running_machine &machine, ui_menu *menu); |
| 208 | | static void menu_bookkeeping(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 209 | | static void menu_bookkeeping_populate(running_machine &machine, ui_menu *menu, attotime *curtime); |
| 210 | | static void menu_game_info(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 211 | | static void menu_cheat(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 212 | | static void menu_cheat_populate(running_machine &machine, ui_menu *menu); |
| 213 | | static void menu_memory_card(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 214 | | static void menu_memory_card_populate(running_machine &machine, ui_menu *menu, int cardnum); |
| 215 | | static void menu_sliders(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 216 | | static void menu_sliders_populate(running_machine &machine, ui_menu *menu, int menuless_mode); |
| 217 | | static void menu_sliders_custom_render(running_machine &machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2); |
| 218 | | static void menu_video_targets(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 219 | | static void menu_video_targets_populate(running_machine &machine, ui_menu *menu); |
| 220 | | static void menu_video_options(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 221 | | static void menu_video_options_populate(running_machine &machine, ui_menu *menu, render_target *target); |
| 222 | | static void menu_crosshair(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 223 | | static void menu_crosshair_populate(running_machine &machine, ui_menu *menu); |
| 224 | | static void menu_quit_game(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 225 | | static void menu_select_game(running_machine &machine, ui_menu *menu, void *parameter, void *state); |
| 226 | | static void menu_select_game_populate(running_machine &machine, ui_menu *menu, select_game_state *menustate); |
| 227 | | static void menu_select_game_build_driver_list(ui_menu *menu, select_game_state *menustate); |
| 228 | | static void menu_select_game_custom_render(running_machine &machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float x, float y, float x2, float y2); |
| 188 | /* add sliders menu */ |
| 189 | item_append("Slider Controls", NULL, 0, (void *)SLIDERS); |
| 229 | 190 | |
| 230 | | /* menu helpers */ |
| 231 | | static void menu_settings_custom_render_one(render_container *container, float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask); |
| 232 | | static void menu_settings_custom_render(running_machine &machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float x, float y, float x2, float y2); |
| 191 | /* add video options menu */ |
| 192 | item_append("Video Options", NULL, 0, (machine().render().target_by_index(1) != NULL) ? (void *)VIDEO_TARGETS : (void *)VIDEO_OPTIONS); |
| 233 | 193 | |
| 194 | /* add crosshair options menu */ |
| 195 | if (crosshair_get_usage(machine())) |
| 196 | item_append("Crosshair Options", NULL, 0, (void *)CROSSHAIR); |
| 234 | 197 | |
| 198 | /* add cheat menu */ |
| 199 | if (machine().options().cheat() && machine().cheat().first() != NULL) |
| 200 | item_append("Cheat", NULL, 0, (void *)CHEAT); |
| 235 | 201 | |
| 236 | | /*************************************************************************** |
| 237 | | INLINE FUNCTIONS |
| 238 | | ***************************************************************************/ |
| 202 | /* add memory card menu */ |
| 203 | if (machine().config().m_memcard_handler != NULL) |
| 204 | item_append("Memory Card", NULL, 0, (void *)MEMORY_CARD); |
| 239 | 205 | |
| 240 | | /*------------------------------------------------- |
| 241 | | get_field_default_seq - return a pointer |
| 242 | | to the default sequence for the given field |
| 243 | | -------------------------------------------------*/ |
| 206 | /* add reset and exit menus */ |
| 207 | menu_text.printf("Select New %s",emulator_info::get_capstartgamenoun()); |
| 208 | item_append(menu_text.cstr(), NULL, 0, (void *)SELECT_GAME); |
| 209 | } |
| 244 | 210 | |
| 245 | | INLINE const input_seq &get_field_default_seq(input_field_config *field, input_seq_type seqtype) |
| 211 | ui_menu_main::~ui_menu_main() |
| 246 | 212 | { |
| 247 | | if (field->seq[seqtype].is_default()) |
| 248 | | return input_type_seq(field->machine(), field->type, field->player, seqtype); |
| 249 | | else |
| 250 | | return field->seq[seqtype]; |
| 251 | 213 | } |
| 252 | 214 | |
| 253 | | |
| 254 | 215 | /*------------------------------------------------- |
| 255 | | toggle_none_default - toggle between "NONE" |
| 256 | | and the default item |
| 216 | menu_main - handle the main menu |
| 257 | 217 | -------------------------------------------------*/ |
| 258 | 218 | |
| 259 | | INLINE void toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq) |
| 219 | void ui_menu_main::handle() |
| 260 | 220 | { |
| 261 | | /* if we used to be "none", toggle to the default value */ |
| 262 | | if (original_seq.length() == 0) |
| 263 | | selected_seq = selected_defseq; |
| 221 | /* process the menu */ |
| 222 | const ui_menu_event *menu_event = process(0); |
| 223 | if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) { |
| 224 | switch((long long)(menu_event->itemref)) { |
| 225 | case INPUT_GROUPS: |
| 226 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_groups(machine(), container))); |
| 227 | break; |
| 264 | 228 | |
| 265 | | /* otherwise, toggle to "none" */ |
| 266 | | else |
| 267 | | selected_seq.reset(); |
| 268 | | } |
| 229 | case INPUT_SPECIFIC: |
| 230 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_specific(machine(), container))); |
| 231 | break; |
| 269 | 232 | |
| 233 | case SETTINGS_DIP_SWITCHES: |
| 234 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_settings_dip_switches(machine(), container))); |
| 235 | break; |
| 270 | 236 | |
| 271 | | /*------------------------------------------------- |
| 272 | | ui_slider_ui_handler - pushes the slider |
| 273 | | menu on the stack and hands off to the |
| 274 | | standard menu handler |
| 275 | | -------------------------------------------------*/ |
| 237 | case SETTINGS_DRIVER_CONFIG: |
| 238 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_settings_driver_config(machine(), container))); |
| 239 | break; |
| 276 | 240 | |
| 277 | | UINT32 ui_slider_ui_handler(running_machine &machine, render_container *container, UINT32 state) |
| 278 | | { |
| 279 | | UINT32 result; |
| 241 | case ANALOG: |
| 242 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_analog(machine(), container))); |
| 243 | break; |
| 280 | 244 | |
| 281 | | /* if this is the first call, push the sliders menu */ |
| 282 | | if (state) |
| 283 | | ui_menu::stack_push(ui_menu_alloc(machine, container, menu_sliders, (void *)1)); |
| 245 | case BOOKKEEPING: |
| 246 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_bookkeeping(machine(), container))); |
| 247 | break; |
| 284 | 248 | |
| 285 | | /* handle standard menus */ |
| 286 | | result = ui_menu::ui_handler(machine, container, state); |
| 249 | case GAME_INFO: |
| 250 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_game_info(machine(), container))); |
| 251 | break; |
| 287 | 252 | |
| 288 | | /* if we are cancelled, pop the sliders menu */ |
| 289 | | if (result == UI_HANDLER_CANCEL) |
| 290 | | ui_menu::stack_pop(machine); |
| 253 | case IMAGE_MENU_IMAGE_INFO: |
| 254 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_image_info(machine(), container))); |
| 255 | break; |
| 291 | 256 | |
| 292 | | return (ui_menu::menu_stack != NULL && ui_menu::menu_stack->handler == menu_sliders && ui_menu::menu_stack->parameter != NULL) ? 0 : UI_HANDLER_CANCEL; |
| 293 | | } |
| 257 | case IMAGE_MENU_FILE_MANAGER: |
| 258 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_manager(machine(), container))); |
| 259 | break; |
| 294 | 260 | |
| 261 | case MESS_MENU_TAPE_CONTROL: |
| 262 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_mess_tape_control(machine(), container))); |
| 263 | break; |
| 295 | 264 | |
| 296 | | /*------------------------------------------------- |
| 297 | | ui_menu_force_game_select - force the game |
| 298 | | select menu to be visible and inescapable |
| 299 | | -------------------------------------------------*/ |
| 265 | case MESS_MENU_BITBANGER_CONTROL: |
| 266 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_mess_bitbanger_control(machine(), container))); |
| 267 | break; |
| 300 | 268 | |
| 301 | | void ui_menu_force_game_select(running_machine &machine, render_container *container) |
| 302 | | { |
| 303 | | char *gamename = (char *)machine.options().system_name(); |
| 269 | case SLOT_DEVICES: |
| 270 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_slot_devices(machine(), container))); |
| 271 | break; |
| 304 | 272 | |
| 305 | | /* reset the menu stack */ |
| 306 | | ui_menu::stack_reset(machine); |
| 273 | case NETWORK_DEVICES: |
| 274 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_network_devices(machine(), container))); |
| 275 | break; |
| 307 | 276 | |
| 308 | | /* add the quit entry followed by the game select entry */ |
| 309 | | ui_menu *quit = ui_menu_alloc(machine, container, menu_quit_game, NULL); |
| 310 | | quit->set_special_main_menu(true); |
| 311 | | ui_menu::stack_push(quit); |
| 312 | | ui_menu::stack_push(ui_menu_alloc(machine, container, menu_select_game, gamename)); |
| 277 | case KEYBOARD_MODE: |
| 278 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_keyboard_mode(machine(), container))); |
| 279 | break; |
| 313 | 280 | |
| 314 | | /* force the menus on */ |
| 315 | | ui_show_menu(); |
| 281 | case SLIDERS: |
| 282 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_sliders(machine(), container, false))); |
| 283 | break; |
| 316 | 284 | |
| 317 | | /* make sure MAME is paused */ |
| 318 | | machine.pause(); |
| 319 | | } |
| 285 | case VIDEO_TARGETS: |
| 286 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_video_targets(machine(), container))); |
| 287 | break; |
| 320 | 288 | |
| 289 | case VIDEO_OPTIONS: |
| 290 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_video_options(machine(), container, machine().render().first_target()))); |
| 291 | break; |
| 321 | 292 | |
| 322 | | /*************************************************************************** |
| 323 | | MENU HANDLERS |
| 324 | | ***************************************************************************/ |
| 293 | case CROSSHAIR: |
| 294 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_crosshair(machine(), container))); |
| 295 | break; |
| 325 | 296 | |
| 326 | | /*------------------------------------------------- |
| 327 | | menu_main - handle the main menu |
| 328 | | -------------------------------------------------*/ |
| 297 | case CHEAT: |
| 298 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_cheat(machine(), container))); |
| 299 | break; |
| 329 | 300 | |
| 330 | | void menu_main(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 331 | | { |
| 332 | | const ui_menu_event *menu_event; |
| 301 | case MEMORY_CARD: |
| 302 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_memory_card(machine(), container))); |
| 303 | break; |
| 333 | 304 | |
| 334 | | /* if the menu isn't built, populate now */ |
| 335 | | if (!menu->populated()) |
| 336 | | menu_main_populate(machine, menu, state); |
| 305 | case SELECT_GAME: |
| 306 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_select_game(machine(), container, 0))); |
| 307 | break; |
| 337 | 308 | |
| 338 | | /* process the menu */ |
| 339 | | menu_event = menu->process(0); |
| 340 | | if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) |
| 341 | | ui_menu::stack_push(ui_menu_alloc(machine, menu->container, (ui_menu_handler_func)menu_event->itemref, NULL)); |
| 309 | default: |
| 310 | abort(); |
| 311 | } |
| 312 | } |
| 342 | 313 | } |
| 343 | 314 | |
| 344 | 315 | |
| r13553 | r13554 | |
| 346 | 317 | ui_menu_keyboard_mode - menu that |
| 347 | 318 | -------------------------------------------------*/ |
| 348 | 319 | |
| 349 | | static void ui_menu_keyboard_mode(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 320 | ui_menu_keyboard_mode::ui_menu_keyboard_mode(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 350 | 321 | { |
| 351 | | const ui_menu_event *menu_event; |
| 352 | | int natural = ui_get_use_natural_keyboard(machine); |
| 322 | } |
| 353 | 323 | |
| 354 | | /* if the menu isn't built, populate now */ |
| 355 | | if (!menu->populated()) |
| 356 | | { |
| 357 | | menu->item_append("Keyboard Mode:", natural ? "Natural" : "Emulated", natural ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, NULL); |
| 358 | | } |
| 324 | void ui_menu_keyboard_mode::populate() |
| 325 | { |
| 326 | int natural = ui_get_use_natural_keyboard(machine()); |
| 327 | item_append("Keyboard Mode:", natural ? "Natural" : "Emulated", natural ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, NULL); |
| 328 | } |
| 359 | 329 | |
| 330 | ui_menu_keyboard_mode::~ui_menu_keyboard_mode() |
| 331 | { |
| 332 | } |
| 333 | |
| 334 | void ui_menu_keyboard_mode::handle() |
| 335 | { |
| 336 | int natural = ui_get_use_natural_keyboard(machine()); |
| 337 | |
| 360 | 338 | /* process the menu */ |
| 361 | | menu_event = menu->process(0); |
| 339 | const ui_menu_event *menu_event = process(0); |
| 362 | 340 | |
| 363 | 341 | if (menu_event != NULL) |
| 364 | 342 | { |
| 365 | 343 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { |
| 366 | | ui_set_use_natural_keyboard(machine, natural ^ TRUE); |
| 367 | | menu->reset(UI_MENU_RESET_REMEMBER_REF); |
| 344 | ui_set_use_natural_keyboard(machine(), natural ^ true); |
| 345 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 368 | 346 | } |
| 369 | 347 | } |
| 370 | 348 | } |
| r13553 | r13554 | |
| 373 | 351 | /*------------------------------------------------- |
| 374 | 352 | ui_slot_get_current_index - returns |
| 375 | 353 | -------------------------------------------------*/ |
| 376 | | int ui_slot_get_current_index(running_machine &machine, device_slot_interface *slot) |
| 354 | int ui_menu_slot_devices::slot_get_current_index(device_slot_interface *slot) |
| 377 | 355 | { |
| 378 | | const char *current = machine.options().value(slot->device().tag()); |
| 356 | const char *current = machine().options().value(slot->device().tag()); |
| 379 | 357 | const slot_interface* intf = slot->get_slot_interfaces(); |
| 380 | 358 | int val = -1; |
| 381 | 359 | for (int i = 0; intf[i].name != NULL; i++) { |
| r13553 | r13554 | |
| 387 | 365 | /*------------------------------------------------- |
| 388 | 366 | ui_slot_get_length - returns |
| 389 | 367 | -------------------------------------------------*/ |
| 390 | | int ui_slot_get_length(running_machine &machine, device_slot_interface *slot) |
| 368 | int ui_menu_slot_devices::slot_get_length(device_slot_interface *slot) |
| 391 | 369 | { |
| 392 | 370 | const slot_interface* intf = slot->get_slot_interfaces(); |
| 393 | 371 | int val = 0; |
| r13553 | r13554 | |
| 398 | 376 | /*------------------------------------------------- |
| 399 | 377 | ui_slot_get_next - returns |
| 400 | 378 | -------------------------------------------------*/ |
| 401 | | const char *ui_slot_get_next(running_machine &machine, device_slot_interface *slot) |
| 379 | const char *ui_menu_slot_devices::slot_get_next(device_slot_interface *slot) |
| 402 | 380 | { |
| 403 | | int idx = ui_slot_get_current_index(machine, slot) + 1; |
| 404 | | if (idx==ui_slot_get_length(machine,slot)) return ""; |
| 381 | int idx = slot_get_current_index(slot) + 1; |
| 382 | if (idx==slot_get_length(slot)) return ""; |
| 405 | 383 | return slot->get_slot_interfaces()[idx].name; |
| 406 | 384 | } |
| 407 | 385 | |
| 408 | 386 | /*------------------------------------------------- |
| 409 | 387 | ui_slot_get_prev - returns |
| 410 | 388 | -------------------------------------------------*/ |
| 411 | | const char *ui_slot_get_prev(running_machine &machine, device_slot_interface *slot) |
| 389 | const char *ui_menu_slot_devices::slot_get_prev(device_slot_interface *slot) |
| 412 | 390 | { |
| 413 | | int idx = ui_slot_get_current_index(machine, slot) - 1; |
| 391 | int idx = slot_get_current_index(slot) - 1; |
| 414 | 392 | if (idx==-1) return ""; |
| 415 | | if (idx==-2) idx = ui_slot_get_length(machine,slot) -1; |
| 393 | if (idx==-2) idx = slot_get_length(slot) -1; |
| 416 | 394 | if (idx==-1) return ""; |
| 417 | 395 | return slot->get_slot_interfaces()[idx].name; |
| 418 | 396 | } |
| r13553 | r13554 | |
| 420 | 398 | /*------------------------------------------------- |
| 421 | 399 | ui_get_slot_device - returns |
| 422 | 400 | -------------------------------------------------*/ |
| 423 | | const char *ui_get_slot_device(running_machine &machine, device_slot_interface *slot) |
| 401 | const char *ui_menu_slot_devices::get_slot_device(device_slot_interface *slot) |
| 424 | 402 | { |
| 425 | | return machine.options().value(slot->device().tag()); |
| 403 | return machine().options().value(slot->device().tag()); |
| 426 | 404 | } |
| 427 | 405 | |
| 428 | 406 | |
| r13553 | r13554 | |
| 431 | 409 | whether the natural keyboard is active |
| 432 | 410 | -------------------------------------------------*/ |
| 433 | 411 | |
| 434 | | void ui_set_slot_device(running_machine &machine, device_slot_interface *slot, const char *val) |
| 412 | void ui_menu_slot_devices::set_slot_device(device_slot_interface *slot, const char *val) |
| 435 | 413 | { |
| 436 | 414 | astring error; |
| 437 | | machine.options().set_value(slot->device().tag(), val, OPTION_PRIORITY_CMDLINE, error); |
| 415 | machine().options().set_value(slot->device().tag(), val, OPTION_PRIORITY_CMDLINE, error); |
| 438 | 416 | assert(!error); |
| 439 | 417 | } |
| 440 | 418 | |
| r13553 | r13554 | |
| 443 | 421 | slot device menu |
| 444 | 422 | -------------------------------------------------*/ |
| 445 | 423 | |
| 446 | | static void menu_slot_devices_populate(running_machine &machine, ui_menu *menu, void *state) |
| 424 | ui_menu_slot_devices::ui_menu_slot_devices(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 447 | 425 | { |
| 426 | } |
| 427 | |
| 428 | void ui_menu_slot_devices::populate() |
| 429 | { |
| 448 | 430 | device_slot_interface *slot = NULL; |
| 449 | 431 | |
| 450 | 432 | /* cycle through all devices for this system */ |
| 451 | | for (bool gotone = machine.devicelist().first(slot); gotone; gotone = slot->next(slot)) |
| 433 | for (bool gotone = machine().devicelist().first(slot); gotone; gotone = slot->next(slot)) |
| 452 | 434 | { |
| 453 | 435 | /* record the menu item */ |
| 454 | | const char *title = ui_get_slot_device(machine,slot); |
| 455 | | menu->item_append(slot->device().tag(), strcmp(title,"")==0 ? "------" : title, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)slot); |
| 436 | const char *title = get_slot_device(slot); |
| 437 | item_append(slot->device().tag(), strcmp(title,"")==0 ? "------" : title, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)slot); |
| 456 | 438 | } |
| 457 | | menu->item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 458 | | menu->item_append("Reset", NULL, 0, NULL); |
| 439 | item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 440 | item_append("Reset", NULL, 0, NULL); |
| 459 | 441 | } |
| 460 | 442 | |
| 443 | ui_menu_slot_devices::~ui_menu_slot_devices() |
| 444 | { |
| 445 | } |
| 446 | |
| 461 | 447 | /*------------------------------------------------- |
| 462 | 448 | ui_menu_slot_devices - menu that |
| 463 | 449 | -------------------------------------------------*/ |
| 464 | 450 | |
| 465 | | static void ui_menu_slot_devices(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 451 | void ui_menu_slot_devices::handle() |
| 466 | 452 | { |
| 467 | | const ui_menu_event *menu_event; |
| 468 | | |
| 469 | | /* if the menu isn't built, populate now */ |
| 470 | | if (!menu->populated()) |
| 471 | | { |
| 472 | | menu_slot_devices_populate(machine, menu, state); |
| 473 | | } |
| 474 | | |
| 475 | 453 | /* process the menu */ |
| 476 | | menu_event = menu->process(0); |
| 454 | const ui_menu_event *menu_event = process(0); |
| 477 | 455 | |
| 478 | 456 | if (menu_event != NULL && menu_event->itemref != NULL) |
| 479 | 457 | { |
| 480 | 458 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { |
| 481 | 459 | device_slot_interface *slot = (device_slot_interface *)menu_event->itemref; |
| 482 | | const char *val = (menu_event->iptkey == IPT_UI_LEFT) ? ui_slot_get_prev(machine,slot) : ui_slot_get_next(machine,slot); |
| 483 | | ui_set_slot_device(machine,slot,val); |
| 484 | | menu->reset(UI_MENU_RESET_REMEMBER_REF); |
| 460 | const char *val = (menu_event->iptkey == IPT_UI_LEFT) ? slot_get_prev(slot) : slot_get_next(slot); |
| 461 | set_slot_device(slot,val); |
| 462 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 485 | 463 | } |
| 486 | 464 | } else if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) { |
| 487 | | machine.schedule_hard_reset(); |
| 465 | machine().schedule_hard_reset(); |
| 488 | 466 | } |
| 489 | 467 | } |
| 490 | 468 | |
| 469 | ui_menu_network_devices::ui_menu_network_devices(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 470 | { |
| 471 | } |
| 491 | 472 | |
| 473 | ui_menu_network_devices::~ui_menu_network_devices() |
| 474 | { |
| 475 | } |
| 476 | |
| 492 | 477 | /*------------------------------------------------- |
| 493 | 478 | menu_network_devices_populate - populates the main |
| 494 | 479 | network device menu |
| 495 | 480 | -------------------------------------------------*/ |
| 496 | 481 | |
| 497 | | static void menu_network_devices_populate(running_machine &machine, ui_menu *menu, void *state) |
| 482 | void ui_menu_network_devices::populate() |
| 498 | 483 | { |
| 499 | 484 | device_network_interface *network = NULL; |
| 500 | 485 | |
| 501 | 486 | /* cycle through all devices for this system */ |
| 502 | | for (bool gotone = machine.devicelist().first(network); gotone; gotone = network->next(network)) |
| 487 | for (bool gotone = machine().devicelist().first(network); gotone; gotone = network->next(network)) |
| 503 | 488 | { |
| 504 | 489 | int curr = network->get_interface(); |
| 505 | 490 | const char *title = NULL; |
| r13553 | r13554 | |
| 512 | 497 | entry = entry->m_next; |
| 513 | 498 | } |
| 514 | 499 | |
| 515 | | menu->item_append(network->device().tag(), (title) ? title : "------", MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)network); |
| 500 | item_append(network->device().tag(), (title) ? title : "------", MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)network); |
| 516 | 501 | } |
| 517 | 502 | } |
| 518 | 503 | |
| r13553 | r13554 | |
| 520 | 505 | ui_menu_network_devices - menu that |
| 521 | 506 | -------------------------------------------------*/ |
| 522 | 507 | |
| 523 | | static void ui_menu_network_devices(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 508 | void ui_menu_network_devices::handle() |
| 524 | 509 | { |
| 525 | | const ui_menu_event *menu_event; |
| 526 | | |
| 527 | | /* if the menu isn't built, populate now */ |
| 528 | | if (!menu->populated()) |
| 529 | | { |
| 530 | | menu_network_devices_populate(machine, menu, state); |
| 531 | | } |
| 532 | | |
| 533 | 510 | /* process the menu */ |
| 534 | | menu_event = menu->process(0); |
| 511 | const ui_menu_event *menu_event = process(0); |
| 535 | 512 | |
| 536 | 513 | if (menu_event != NULL && menu_event->itemref != NULL) |
| 537 | 514 | { |
| r13553 | r13554 | |
| 541 | 518 | if (menu_event->iptkey == IPT_UI_LEFT) curr--; else curr++; |
| 542 | 519 | if (curr==-2) curr = netdev_count() - 1; |
| 543 | 520 | network->set_interface(curr); |
| 544 | | menu->reset(UI_MENU_RESET_REMEMBER_REF); |
| 521 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 545 | 522 | } |
| 546 | 523 | } |
| 547 | 524 | } |
| 548 | 525 | |
| 549 | 526 | /*------------------------------------------------- |
| 550 | | menu_main_populate - populate the main menu |
| 527 | menu_input_groups_populate - populate the |
| 528 | input groups menu |
| 551 | 529 | -------------------------------------------------*/ |
| 552 | 530 | |
| 553 | | static void menu_main_populate(running_machine &machine, ui_menu *menu, void *state) |
| 531 | ui_menu_input_groups::ui_menu_input_groups(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 554 | 532 | { |
| 555 | | input_field_config *field; |
| 556 | | input_port_config *port; |
| 557 | | int has_configs = FALSE; |
| 558 | | int has_analog = FALSE; |
| 559 | | int has_dips = FALSE; |
| 560 | | astring menu_text; |
| 561 | | /* scan the input port array to see what options we need to enable */ |
| 562 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 563 | | for (field = port->fieldlist().first(); field != NULL; field = field->next()) |
| 564 | | { |
| 565 | | if (field->type == IPT_DIPSWITCH) |
| 566 | | has_dips = TRUE; |
| 567 | | if (field->type == IPT_CONFIG) |
| 568 | | has_configs = TRUE; |
| 569 | | if (input_type_is_analog(field->type)) |
| 570 | | has_analog = TRUE; |
| 571 | | } |
| 533 | } |
| 572 | 534 | |
| 573 | | /* add input menu items */ |
| 574 | | menu->item_append("Input (general)", NULL, 0, (void *)menu_input_groups); |
| 535 | void ui_menu_input_groups::populate() |
| 536 | { |
| 537 | int player; |
| 575 | 538 | |
| 576 | | menu_text.printf("Input (this %s)",emulator_info::get_capstartgamenoun()); |
| 577 | | menu->item_append(menu_text.cstr(), NULL, 0, (void *)menu_input_specific); |
| 578 | | |
| 579 | | /* add optional input-related menus */ |
| 580 | | if (has_dips) |
| 581 | | menu->item_append("Dip Switches", NULL, 0, (void *)menu_settings_dip_switches); |
| 582 | | if (has_configs) |
| 583 | | menu->item_append("Driver Configuration", NULL, 0, (void *)menu_settings_driver_config); |
| 584 | | if (has_analog) |
| 585 | | menu->item_append("Analog Controls", NULL, 0, (void *)menu_analog); |
| 586 | | |
| 587 | | /* add bookkeeping menu */ |
| 588 | | menu->item_append("Bookkeeping Info", NULL, 0, (void *)menu_bookkeeping); |
| 589 | | |
| 590 | | /* add game info menu */ |
| 591 | | menu_text.printf("%s Information",emulator_info::get_capstartgamenoun()); |
| 592 | | menu->item_append(menu_text.cstr(), NULL, 0, (void *)menu_game_info); |
| 593 | | |
| 594 | | device_image_interface *image = NULL; |
| 595 | | if (machine.devicelist().first(image)) |
| 539 | /* build up the menu */ |
| 540 | item_append("User Interface", NULL, 0, (void *)(IPG_UI + 1)); |
| 541 | for (player = 0; player < MAX_PLAYERS; player++) |
| 596 | 542 | { |
| 597 | | /* add image info menu */ |
| 598 | | menu->item_append("Image Information", NULL, 0, (void*)ui_image_menu_image_info); |
| 599 | | |
| 600 | | /* add file manager menu */ |
| 601 | | menu->item_append("File Manager", NULL, 0, (void*)ui_image_menu_file_manager); |
| 602 | | |
| 603 | | /* add tape control menu */ |
| 604 | | if (machine.devicelist().first(CASSETTE)) |
| 605 | | menu->item_append("Tape Control", NULL, 0, (void*)ui_mess_menu_tape_control); |
| 606 | | |
| 607 | | /* add bitbanger control menu */ |
| 608 | | if (machine.devicelist().first(BITBANGER)) |
| 609 | | menu->item_append("Bitbanger Control", NULL, 0, (void*)ui_mess_menu_bitbanger_control); |
| 543 | char buffer[40]; |
| 544 | sprintf(buffer, "Player %d Controls", player + 1); |
| 545 | item_append(buffer, NULL, 0, (void *)(FPTR)(IPG_PLAYER1 + player + 1)); |
| 610 | 546 | } |
| 547 | item_append("Other Controls", NULL, 0, (void *)(FPTR)(IPG_OTHER + 1)); |
| 548 | } |
| 611 | 549 | |
| 612 | | device_slot_interface *slot = NULL; |
| 613 | | if (machine.devicelist().first(slot)) |
| 614 | | { |
| 615 | | /* add image info menu */ |
| 616 | | menu->item_append("Slot Devices", NULL, 0, (void*)ui_menu_slot_devices); |
| 617 | | } |
| 618 | | |
| 619 | | device_network_interface *network = NULL; |
| 620 | | if (machine.devicelist().first(network)) |
| 621 | | { |
| 622 | | /* add image info menu */ |
| 623 | | menu->item_append("Network Devices", NULL, 0, (void*)ui_menu_network_devices); |
| 624 | | } |
| 625 | | |
| 626 | | /* add keyboard mode menu */ |
| 627 | | if (input_machine_has_keyboard(machine) && inputx_can_post(machine)) |
| 628 | | menu->item_append("Keyboard Mode", NULL, 0, (void *)ui_menu_keyboard_mode); |
| 629 | | |
| 630 | | /* add sliders menu */ |
| 631 | | menu->item_append("Slider Controls", NULL, 0, (void *)menu_sliders); |
| 632 | | |
| 633 | | /* add video options menu */ |
| 634 | | menu->item_append("Video Options", NULL, 0, (machine.render().target_by_index(1) != NULL) ? (void *)menu_video_targets : (void *)menu_video_options); |
| 635 | | |
| 636 | | /* add crosshair options menu */ |
| 637 | | if (crosshair_get_usage(machine)) |
| 638 | | menu->item_append("Crosshair Options", NULL, 0, (void *)menu_crosshair); |
| 639 | | |
| 640 | | /* add cheat menu */ |
| 641 | | if (machine.options().cheat() && machine.cheat().first() != NULL) |
| 642 | | menu->item_append("Cheat", NULL, 0, (void *)menu_cheat); |
| 643 | | |
| 644 | | /* add memory card menu */ |
| 645 | | if (machine.config().m_memcard_handler != NULL) |
| 646 | | menu->item_append("Memory Card", NULL, 0, (void *)menu_memory_card); |
| 647 | | |
| 648 | | /* add reset and exit menus */ |
| 649 | | menu_text.printf("Select New %s",emulator_info::get_capstartgamenoun()); |
| 650 | | menu->item_append(menu_text.cstr(), NULL, 0, (void *)menu_select_game); |
| 550 | ui_menu_input_groups::~ui_menu_input_groups() |
| 551 | { |
| 651 | 552 | } |
| 652 | 553 | |
| 653 | | |
| 654 | 554 | /*------------------------------------------------- |
| 655 | 555 | menu_input_groups - handle the input groups |
| 656 | 556 | menu |
| 657 | 557 | -------------------------------------------------*/ |
| 658 | 558 | |
| 659 | | static void menu_input_groups(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 559 | void ui_menu_input_groups::handle() |
| 660 | 560 | { |
| 661 | | const ui_menu_event *menu_event; |
| 662 | | |
| 663 | | /* if the menu isn't built, populate now */ |
| 664 | | if (!menu->populated()) |
| 665 | | menu_input_groups_populate(machine, menu, state); |
| 666 | | |
| 667 | 561 | /* process the menu */ |
| 668 | | menu_event = menu->process(0); |
| 562 | const ui_menu_event *menu_event = process(0); |
| 669 | 563 | if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) |
| 670 | | ui_menu::stack_push(ui_menu_alloc(machine, menu->container, menu_input_general, menu_event->itemref)); |
| 564 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_general(machine(), container, int((long long)(menu_event->itemref)-1)))); |
| 671 | 565 | } |
| 672 | 566 | |
| 673 | 567 | |
| 674 | | /*------------------------------------------------- |
| 675 | | menu_input_groups_populate - populate the |
| 676 | | input groups menu |
| 677 | | -------------------------------------------------*/ |
| 678 | 568 | |
| 679 | | static void menu_input_groups_populate(running_machine &machine, ui_menu *menu, void *state) |
| 680 | | { |
| 681 | | int player; |
| 682 | | |
| 683 | | /* build up the menu */ |
| 684 | | menu->item_append("User Interface", NULL, 0, (void *)(IPG_UI + 1)); |
| 685 | | for (player = 0; player < MAX_PLAYERS; player++) |
| 686 | | { |
| 687 | | char buffer[40]; |
| 688 | | sprintf(buffer, "Player %d Controls", player + 1); |
| 689 | | menu->item_append(buffer, NULL, 0, (void *)(FPTR)(IPG_PLAYER1 + player + 1)); |
| 690 | | } |
| 691 | | menu->item_append("Other Controls", NULL, 0, (void *)(FPTR)(IPG_OTHER + 1)); |
| 692 | | } |
| 693 | | |
| 694 | | |
| 695 | | |
| 696 | 569 | /*------------------------------------------------- |
| 697 | 570 | menu_input_general - handle the general |
| 698 | 571 | input menu |
| 699 | 572 | -------------------------------------------------*/ |
| 700 | 573 | |
| 701 | | static void menu_input_general(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 574 | ui_menu_input_general::ui_menu_input_general(running_machine &machine, render_container *container, int _group) : ui_menu_input(machine, container) |
| 702 | 575 | { |
| 703 | | menu_input_common(machine, menu, parameter, state); |
| 576 | group = _group; |
| 704 | 577 | } |
| 705 | 578 | |
| 706 | | |
| 707 | | /*------------------------------------------------- |
| 708 | | menu_input_general_populate - populate the |
| 709 | | general input menu |
| 710 | | -------------------------------------------------*/ |
| 711 | | |
| 712 | | static void menu_input_general_populate(running_machine &machine, ui_menu *menu, input_menu_state *menustate, int group) |
| 579 | void ui_menu_input_general::populate() |
| 713 | 580 | { |
| 714 | 581 | input_item_data *itemlist = NULL; |
| 715 | 582 | int suborder[SEQ_TYPE_TOTAL]; |
| r13553 | r13554 | |
| 722 | 589 | suborder[SEQ_TYPE_INCREMENT] = 2; |
| 723 | 590 | |
| 724 | 591 | /* iterate over the input ports and add menu items */ |
| 725 | | for (input_type_entry *entry = input_type_list(machine).first(); entry != NULL; entry = entry->next()) |
| 592 | for (input_type_entry *entry = input_type_list(machine()).first(); entry != NULL; entry = entry->next()) |
| 726 | 593 | |
| 727 | 594 | /* add if we match the group and we have a valid name */ |
| 728 | 595 | if (entry->group == group && entry->name != NULL && entry->name[0] != 0) |
| r13553 | r13554 | |
| 734 | 601 | for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++) |
| 735 | 602 | { |
| 736 | 603 | /* build an entry for the standard sequence */ |
| 737 | | input_item_data *item = (input_item_data *)menu->m_pool_alloc(sizeof(*item)); |
| 604 | input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item)); |
| 738 | 605 | memset(item, 0, sizeof(*item)); |
| 739 | 606 | item->ref = entry; |
| 740 | 607 | item->seqtype = seqtype; |
| 741 | | item->seq = input_type_seq(machine, entry->type, entry->player, seqtype); |
| 608 | item->seq = input_type_seq(machine(), entry->type, entry->player, seqtype); |
| 742 | 609 | item->defseq = &entry->defseq[seqtype]; |
| 743 | 610 | item->sortorder = sortorder * 4 + suborder[seqtype]; |
| 744 | 611 | item->type = input_type_is_analog(entry->type) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; |
| r13553 | r13554 | |
| 753 | 620 | } |
| 754 | 621 | |
| 755 | 622 | /* sort and populate the menu in a standard fashion */ |
| 756 | | menu_input_populate_and_sort(machine, menu, itemlist, menustate); |
| 623 | populate_and_sort(itemlist); |
| 757 | 624 | } |
| 758 | 625 | |
| 626 | ui_menu_input_general::~ui_menu_input_general() |
| 627 | { |
| 628 | } |
| 759 | 629 | |
| 760 | 630 | /*------------------------------------------------- |
| 761 | 631 | menu_input_specific - handle the game-specific |
| 762 | 632 | input menu |
| 763 | 633 | -------------------------------------------------*/ |
| 764 | 634 | |
| 765 | | static void menu_input_specific(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 635 | ui_menu_input_specific::ui_menu_input_specific(running_machine &machine, render_container *container) : ui_menu_input(machine, container) |
| 766 | 636 | { |
| 767 | | menu_input_common(machine, menu, NULL, state); |
| 768 | 637 | } |
| 769 | 638 | |
| 770 | | |
| 771 | | /*------------------------------------------------- |
| 772 | | menu_input_specific_populate - populate |
| 773 | | the input menu with game-specific items |
| 774 | | -------------------------------------------------*/ |
| 775 | | |
| 776 | | static void menu_input_specific_populate(running_machine &machine, ui_menu *menu, input_menu_state *menustate) |
| 639 | void ui_menu_input_specific::populate() |
| 777 | 640 | { |
| 778 | 641 | input_item_data *itemlist = NULL; |
| 779 | 642 | input_field_config *field; |
| r13553 | r13554 | |
| 787 | 650 | suborder[SEQ_TYPE_INCREMENT] = 2; |
| 788 | 651 | |
| 789 | 652 | /* iterate over the input ports and add menu items */ |
| 790 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 653 | for (port = machine().m_portlist.first(); port != NULL; port = port->next()) |
| 791 | 654 | for (field = port->fieldlist().first(); field != NULL; field = field->next()) |
| 792 | 655 | { |
| 793 | 656 | const char *name = input_field_name(field); |
| 794 | 657 | |
| 795 | 658 | /* add if we match the group and we have a valid name */ |
| 796 | | if (name != NULL && input_condition_true(machine, &field->condition, port->owner()) && |
| 797 | | ((field->type == IPT_OTHER && field->name != NULL) || input_type_group(machine, field->type, field->player) != IPG_INVALID)) |
| 659 | if (name != NULL && input_condition_true(machine(), &field->condition, port->owner()) && |
| 660 | ((field->type == IPT_OTHER && field->name != NULL) || input_type_group(machine(), field->type, field->player) != IPG_INVALID)) |
| 798 | 661 | { |
| 799 | 662 | input_seq_type seqtype; |
| 800 | 663 | UINT16 sortorder; |
| r13553 | r13554 | |
| 809 | 672 | for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++) |
| 810 | 673 | { |
| 811 | 674 | /* build an entry for the standard sequence */ |
| 812 | | input_item_data *item = (input_item_data *)menu->m_pool_alloc(sizeof(*item)); |
| 675 | input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item)); |
| 813 | 676 | memset(item, 0, sizeof(*item)); |
| 814 | 677 | item->ref = field; |
| 815 | 678 | item->seqtype = seqtype; |
| r13553 | r13554 | |
| 829 | 692 | } |
| 830 | 693 | |
| 831 | 694 | /* sort and populate the menu in a standard fashion */ |
| 832 | | menu_input_populate_and_sort(machine, menu, itemlist, menustate); |
| 695 | populate_and_sort(itemlist); |
| 833 | 696 | } |
| 834 | 697 | |
| 698 | ui_menu_input_specific::~ui_menu_input_specific() |
| 699 | { |
| 700 | } |
| 835 | 701 | |
| 836 | 702 | /*------------------------------------------------- |
| 837 | 703 | menu_input - display a menu for inputs |
| 838 | 704 | -------------------------------------------------*/ |
| 705 | ui_menu_input::ui_menu_input(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 706 | { |
| 707 | } |
| 839 | 708 | |
| 840 | | static void menu_input_common(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 709 | ui_menu_input::~ui_menu_input() |
| 841 | 710 | { |
| 842 | | input_item_data *seqchangeditem = NULL; |
| 843 | | input_menu_state *menustate; |
| 844 | | const ui_menu_event *menu_event; |
| 845 | | int invalidate = FALSE; |
| 711 | } |
| 846 | 712 | |
| 847 | | /* if no state, allocate now */ |
| 848 | | if (state == NULL) |
| 849 | | state = menu->alloc_state(sizeof(*menustate), NULL); |
| 850 | | menustate = (input_menu_state *)state; |
| 713 | /*------------------------------------------------- |
| 714 | toggle_none_default - toggle between "NONE" |
| 715 | and the default item |
| 716 | -------------------------------------------------*/ |
| 851 | 717 | |
| 852 | | /* if the menu isn't built, populate now */ |
| 853 | | if (!menu->populated()) |
| 854 | | { |
| 855 | | if (parameter != NULL) |
| 856 | | menu_input_general_populate(machine, menu, menustate, (FPTR)parameter - 1); |
| 857 | | else |
| 858 | | menu_input_specific_populate(machine, menu, menustate); |
| 859 | | } |
| 718 | void ui_menu_input::toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq) |
| 719 | { |
| 720 | /* if we used to be "none", toggle to the default value */ |
| 721 | if (original_seq.length() == 0) |
| 722 | selected_seq = selected_defseq; |
| 860 | 723 | |
| 724 | /* otherwise, toggle to "none" */ |
| 725 | else |
| 726 | selected_seq.reset(); |
| 727 | } |
| 728 | |
| 729 | /*------------------------------------------------- |
| 730 | get_field_default_seq - return a pointer |
| 731 | to the default sequence for the given field |
| 732 | -------------------------------------------------*/ |
| 733 | |
| 734 | const input_seq &ui_menu_input::get_field_default_seq(input_field_config *field, input_seq_type seqtype) |
| 735 | { |
| 736 | if (field->seq[seqtype].is_default()) |
| 737 | return input_type_seq(field->machine(), field->type, field->player, seqtype); |
| 738 | else |
| 739 | return field->seq[seqtype]; |
| 740 | } |
| 741 | |
| 742 | void ui_menu_input::handle() |
| 743 | { |
| 744 | input_item_data *seqchangeditem = NULL; |
| 745 | const ui_menu_event *menu_event; |
| 746 | int invalidate = false; |
| 747 | |
| 861 | 748 | /* process the menu */ |
| 862 | | menu_event = menu->process((menustate->pollingitem != NULL) ? UI_MENU_PROCESS_NOKEYS : 0); |
| 749 | menu_event = process((pollingitem != NULL) ? UI_MENU_PROCESS_NOKEYS : 0); |
| 863 | 750 | |
| 864 | 751 | /* if we are polling, handle as a special case */ |
| 865 | | if (menustate->pollingitem != NULL) |
| 752 | if (pollingitem != NULL) |
| 866 | 753 | { |
| 867 | | input_item_data *item = menustate->pollingitem; |
| 754 | input_item_data *item = pollingitem; |
| 868 | 755 | input_seq newseq; |
| 869 | 756 | |
| 870 | 757 | /* if UI_CANCEL is pressed, abort */ |
| 871 | | if (ui_input_pressed(machine, IPT_UI_CANCEL)) |
| 758 | if (ui_input_pressed(machine(), IPT_UI_CANCEL)) |
| 872 | 759 | { |
| 873 | | menustate->pollingitem = NULL; |
| 874 | | menustate->record_next = FALSE; |
| 875 | | toggle_none_default(item->seq, menustate->starting_seq, *item->defseq); |
| 760 | pollingitem = NULL; |
| 761 | record_next = false; |
| 762 | toggle_none_default(item->seq, starting_seq, *item->defseq); |
| 876 | 763 | seqchangeditem = item; |
| 877 | 764 | } |
| 878 | 765 | |
| 879 | 766 | /* poll again; if finished, update the sequence */ |
| 880 | | if (machine.input().seq_poll()) |
| 767 | if (machine().input().seq_poll()) |
| 881 | 768 | { |
| 882 | | menustate->pollingitem = NULL; |
| 883 | | menustate->record_next = TRUE; |
| 884 | | item->seq = machine.input().seq_poll_final(); |
| 769 | pollingitem = NULL; |
| 770 | record_next = true; |
| 771 | item->seq = machine().input().seq_poll_final(); |
| 885 | 772 | seqchangeditem = item; |
| 886 | 773 | } |
| 887 | 774 | } |
| r13553 | r13554 | |
| 894 | 781 | { |
| 895 | 782 | /* an item was selected: begin polling */ |
| 896 | 783 | case IPT_UI_SELECT: |
| 897 | | menustate->pollingitem = item; |
| 898 | | menustate->last_sortorder = item->sortorder; |
| 899 | | menustate->starting_seq = item->seq; |
| 900 | | machine.input().seq_poll_start((item->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, menustate->record_next ? &item->seq : NULL); |
| 901 | | invalidate = TRUE; |
| 784 | pollingitem = item; |
| 785 | last_sortorder = item->sortorder; |
| 786 | starting_seq = item->seq; |
| 787 | machine().input().seq_poll_start((item->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? &item->seq : NULL); |
| 788 | invalidate = true; |
| 902 | 789 | break; |
| 903 | 790 | |
| 904 | 791 | /* if the clear key was pressed, reset the selected item */ |
| 905 | 792 | case IPT_UI_CLEAR: |
| 906 | 793 | toggle_none_default(item->seq, item->seq, *item->defseq); |
| 907 | | menustate->record_next = FALSE; |
| 794 | record_next = false; |
| 908 | 795 | seqchangeditem = item; |
| 909 | 796 | break; |
| 910 | 797 | } |
| 911 | 798 | |
| 912 | 799 | /* if the selection changed, reset the "record next" flag */ |
| 913 | | if (item->sortorder != menustate->last_sortorder) |
| 914 | | menustate->record_next = FALSE; |
| 915 | | menustate->last_sortorder = item->sortorder; |
| 800 | if (item->sortorder != last_sortorder) |
| 801 | record_next = false; |
| 802 | last_sortorder = item->sortorder; |
| 916 | 803 | } |
| 917 | 804 | |
| 918 | 805 | /* if the sequence changed, update it */ |
| 919 | 806 | if (seqchangeditem != NULL) |
| 920 | 807 | { |
| 921 | | /* update a general input */ |
| 922 | | if (parameter != NULL) |
| 923 | | { |
| 924 | | const input_type_entry *entry = (const input_type_entry *)seqchangeditem->ref; |
| 925 | | input_type_set_seq(machine, entry->type, entry->player, seqchangeditem->seqtype, &seqchangeditem->seq); |
| 926 | | } |
| 808 | update_input(seqchangeditem); |
| 927 | 809 | |
| 928 | | /* update a game-specific input */ |
| 929 | | else |
| 930 | | { |
| 931 | | input_field_user_settings settings; |
| 932 | | |
| 933 | | input_field_get_user_settings((input_field_config *)seqchangeditem->ref, &settings); |
| 934 | | settings.seq[seqchangeditem->seqtype] = seqchangeditem->seq; |
| 935 | | input_field_set_user_settings((input_field_config *)seqchangeditem->ref, &settings); |
| 936 | | } |
| 937 | | |
| 938 | 810 | /* invalidate the menu to force an update */ |
| 939 | | invalidate = TRUE; |
| 811 | invalidate = true; |
| 940 | 812 | } |
| 941 | 813 | |
| 942 | 814 | /* if the menu is invalidated, clear it now */ |
| 943 | 815 | if (invalidate) |
| 944 | 816 | { |
| 945 | | menustate->pollingref = NULL; |
| 946 | | if (menustate->pollingitem != NULL) |
| 947 | | menustate->pollingref = menustate->pollingitem->ref; |
| 948 | | menu->reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 817 | pollingref = NULL; |
| 818 | if (pollingitem != NULL) |
| 819 | pollingref = pollingitem->ref; |
| 820 | reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 949 | 821 | } |
| 950 | 822 | } |
| 951 | 823 | |
| 824 | void ui_menu_input_general::update_input(struct input_item_data *seqchangeditem) |
| 825 | { |
| 826 | const input_type_entry *entry = (const input_type_entry *)seqchangeditem->ref; |
| 827 | input_type_set_seq(machine(), entry->type, entry->player, seqchangeditem->seqtype, &seqchangeditem->seq); |
| 828 | } |
| 952 | 829 | |
| 830 | void ui_menu_input_specific::update_input(struct input_item_data *seqchangeditem) |
| 831 | { |
| 832 | input_field_user_settings settings; |
| 833 | |
| 834 | input_field_get_user_settings((input_field_config *)seqchangeditem->ref, &settings); |
| 835 | settings.seq[seqchangeditem->seqtype] = seqchangeditem->seq; |
| 836 | input_field_set_user_settings((input_field_config *)seqchangeditem->ref, &settings); |
| 837 | } |
| 838 | |
| 839 | |
| 953 | 840 | /*------------------------------------------------- |
| 954 | 841 | menu_input_compare_items - compare two |
| 955 | 842 | items for quicksort |
| 956 | 843 | -------------------------------------------------*/ |
| 957 | 844 | |
| 958 | | static int menu_input_compare_items(const void *i1, const void *i2) |
| 845 | int ui_menu_input::compare_items(const void *i1, const void *i2) |
| 959 | 846 | { |
| 960 | 847 | const input_item_data * const *data1 = (const input_item_data * const *)i1; |
| 961 | 848 | const input_item_data * const *data2 = (const input_item_data * const *)i2; |
| r13553 | r13554 | |
| 973 | 860 | menu from them |
| 974 | 861 | -------------------------------------------------*/ |
| 975 | 862 | |
| 976 | | static void menu_input_populate_and_sort(running_machine &machine, ui_menu *menu, input_item_data *itemlist, input_menu_state *menustate) |
| 863 | void ui_menu_input::populate_and_sort(input_item_data *itemlist) |
| 977 | 864 | { |
| 978 | 865 | const char *nameformat[INPUT_TYPE_TOTAL] = { 0 }; |
| 979 | 866 | input_item_data **itemarray, *item; |
| r13553 | r13554 | |
| 992 | 879 | numitems++; |
| 993 | 880 | |
| 994 | 881 | /* now allocate an array of items and fill it up */ |
| 995 | | itemarray = (input_item_data **)menu->m_pool_alloc(sizeof(*itemarray) * numitems); |
| 882 | itemarray = (input_item_data **)m_pool_alloc(sizeof(*itemarray) * numitems); |
| 996 | 883 | for (item = itemlist, curitem = 0; item != NULL; item = item->next) |
| 997 | 884 | itemarray[curitem++] = item; |
| 998 | 885 | |
| 999 | 886 | /* sort it */ |
| 1000 | | qsort(itemarray, numitems, sizeof(*itemarray), menu_input_compare_items); |
| 887 | qsort(itemarray, numitems, sizeof(*itemarray), compare_items); |
| 1001 | 888 | |
| 1002 | 889 | /* build the menu */ |
| 1003 | 890 | for (curitem = 0; curitem < numitems; curitem++) |
| r13553 | r13554 | |
| 1010 | 897 | text.printf(nameformat[item->type], item->name); |
| 1011 | 898 | |
| 1012 | 899 | /* if we're polling this item, use some spaces with left/right arrows */ |
| 1013 | | if (menustate->pollingref == item->ref) |
| 900 | if (pollingref == item->ref) |
| 1014 | 901 | { |
| 1015 | 902 | subtext.cpy(" "); |
| 1016 | 903 | flags |= MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW; |
| r13553 | r13554 | |
| 1019 | 906 | /* otherwise, generate the sequence name and invert it if different from the default */ |
| 1020 | 907 | else |
| 1021 | 908 | { |
| 1022 | | machine.input().seq_name(subtext, item->seq); |
| 909 | machine().input().seq_name(subtext, item->seq); |
| 1023 | 910 | flags |= (item->seq != *item->defseq) ? MENU_FLAG_INVERT : 0; |
| 1024 | 911 | } |
| 1025 | 912 | |
| 1026 | 913 | /* add the item */ |
| 1027 | | menu->item_append(text, subtext, flags, item); |
| 914 | item_append(text, subtext, flags, item); |
| 1028 | 915 | } |
| 1029 | 916 | } |
| 1030 | 917 | |
| r13553 | r13554 | |
| 1034 | 921 | switches menu |
| 1035 | 922 | -------------------------------------------------*/ |
| 1036 | 923 | |
| 1037 | | static void menu_settings_dip_switches(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 924 | ui_menu_settings_dip_switches::ui_menu_settings_dip_switches(running_machine &machine, render_container *container) : ui_menu_settings(machine, container, IPT_DIPSWITCH) |
| 1038 | 925 | { |
| 1039 | | menu_settings_common(machine, menu, state, IPT_DIPSWITCH); |
| 926 | custombottom = dipcount * (DIP_SWITCH_HEIGHT + DIP_SWITCH_SPACING) + DIP_SWITCH_SPACING; |
| 1040 | 927 | } |
| 1041 | 928 | |
| 929 | ui_menu_settings_dip_switches::~ui_menu_settings_dip_switches() |
| 930 | { |
| 931 | } |
| 1042 | 932 | |
| 1043 | 933 | /*------------------------------------------------- |
| 1044 | 934 | menu_settings_driver_config - handle the |
| 1045 | 935 | driver config menu |
| 1046 | 936 | -------------------------------------------------*/ |
| 1047 | 937 | |
| 1048 | | static void menu_settings_driver_config(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 938 | ui_menu_settings_driver_config::ui_menu_settings_driver_config(running_machine &machine, render_container *container) : ui_menu_settings(machine, container, IPT_CONFIG) |
| 1049 | 939 | { |
| 1050 | | menu_settings_common(machine, menu, state, IPT_CONFIG); |
| 1051 | 940 | } |
| 1052 | 941 | |
| 942 | ui_menu_settings_driver_config::~ui_menu_settings_driver_config() |
| 943 | { |
| 944 | } |
| 1053 | 945 | |
| 1054 | 946 | /*------------------------------------------------- |
| 1055 | 947 | menu_settings_common - handle one of the |
| 1056 | 948 | switches menus |
| 1057 | 949 | -------------------------------------------------*/ |
| 1058 | 950 | |
| 1059 | | static void menu_settings_common(running_machine &machine, ui_menu *menu, void *state, UINT32 type) |
| 951 | void ui_menu_settings::handle() |
| 1060 | 952 | { |
| 1061 | | settings_menu_state *menustate; |
| 1062 | | const ui_menu_event *menu_event; |
| 1063 | | |
| 1064 | | /* if no state, allocate now */ |
| 1065 | | if (state == NULL) |
| 1066 | | state = menu->alloc_state(sizeof(*menustate), NULL); |
| 1067 | | menustate = (settings_menu_state *)state; |
| 1068 | | |
| 1069 | | /* if the menu isn't built, populate now */ |
| 1070 | | if (!menu->populated()) |
| 1071 | | menu_settings_populate(machine, menu, menustate, type); |
| 1072 | | |
| 1073 | 953 | /* process the menu */ |
| 1074 | | menu_event = menu->process(0); |
| 954 | const ui_menu_event *menu_event = process(0); |
| 1075 | 955 | |
| 1076 | 956 | /* handle events */ |
| 1077 | 957 | if (menu_event != NULL && menu_event->itemref != NULL) |
| 1078 | 958 | { |
| 1079 | 959 | input_field_config *field = (input_field_config *)menu_event->itemref; |
| 1080 | 960 | input_field_user_settings settings; |
| 1081 | | int changed = FALSE; |
| 961 | int changed = false; |
| 1082 | 962 | |
| 1083 | 963 | switch (menu_event->iptkey) |
| 1084 | 964 | { |
| r13553 | r13554 | |
| 1087 | 967 | input_field_get_user_settings(field, &settings); |
| 1088 | 968 | settings.value = field->defvalue; |
| 1089 | 969 | input_field_set_user_settings(field, &settings); |
| 1090 | | changed = TRUE; |
| 970 | changed = true; |
| 1091 | 971 | break; |
| 1092 | 972 | |
| 1093 | 973 | /* left goes to previous setting */ |
| 1094 | 974 | case IPT_UI_LEFT: |
| 1095 | 975 | input_field_select_previous_setting(field); |
| 1096 | | changed = TRUE; |
| 976 | changed = true; |
| 1097 | 977 | break; |
| 1098 | 978 | |
| 1099 | 979 | /* right goes to next setting */ |
| 1100 | 980 | case IPT_UI_RIGHT: |
| 1101 | 981 | input_field_select_next_setting(field); |
| 1102 | | changed = TRUE; |
| 982 | changed = true; |
| 1103 | 983 | break; |
| 1104 | 984 | } |
| 1105 | 985 | |
| 1106 | 986 | /* if anything changed, rebuild the menu, trying to stay on the same field */ |
| 1107 | 987 | if (changed) |
| 1108 | | menu->reset(UI_MENU_RESET_REMEMBER_REF); |
| 988 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 1109 | 989 | } |
| 1110 | 990 | } |
| 1111 | 991 | |
| r13553 | r13554 | |
| 1115 | 995 | switches menus |
| 1116 | 996 | -------------------------------------------------*/ |
| 1117 | 997 | |
| 1118 | | static void menu_settings_populate(running_machine &machine, ui_menu *menu, settings_menu_state *menustate, UINT32 type) |
| 998 | ui_menu_settings::ui_menu_settings(running_machine &machine, render_container *container, UINT32 _type) : ui_menu(machine, container) |
| 1119 | 999 | { |
| 1000 | type = _type; |
| 1001 | } |
| 1002 | |
| 1003 | void ui_menu_settings::populate() |
| 1004 | { |
| 1120 | 1005 | input_field_config *field; |
| 1121 | 1006 | input_port_config *port; |
| 1122 | 1007 | dip_descriptor **diplist_tailptr; |
| 1123 | | int dipcount = 0; |
| 1124 | 1008 | |
| 1125 | 1009 | /* reset the dip switch tracking */ |
| 1126 | | menustate->diplist = NULL; |
| 1127 | | diplist_tailptr = &menustate->diplist; |
| 1010 | dipcount = 0; |
| 1011 | diplist = NULL; |
| 1012 | diplist_tailptr = &diplist; |
| 1128 | 1013 | |
| 1129 | 1014 | /* loop over input ports and set up the current values */ |
| 1130 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 1015 | for (port = machine().m_portlist.first(); port != NULL; port = port->next()) |
| 1131 | 1016 | for (field = port->fieldlist().first(); field != NULL; field = field->next()) |
| 1132 | | if (field->type == type && input_condition_true(machine, &field->condition, port->owner())) |
| 1017 | if (field->type == type && input_condition_true(machine(), &field->condition, port->owner())) |
| 1133 | 1018 | { |
| 1134 | 1019 | UINT32 flags = 0; |
| 1135 | 1020 | |
| r13553 | r13554 | |
| 1140 | 1025 | flags |= MENU_FLAG_RIGHT_ARROW; |
| 1141 | 1026 | |
| 1142 | 1027 | /* add the menu item */ |
| 1143 | | menu->item_append(input_field_name(field), input_field_setting_name(field), flags, (void *)field); |
| 1028 | item_append(input_field_name(field), input_field_setting_name(field), flags, (void *)field); |
| 1144 | 1029 | |
| 1145 | 1030 | /* for DIP switches, build up the model */ |
| 1146 | 1031 | if (type == IPT_DIPSWITCH && field->diploclist().count() != 0) |
| r13553 | r13554 | |
| 1159 | 1044 | dip_descriptor *dip; |
| 1160 | 1045 | |
| 1161 | 1046 | /* find the matching switch name */ |
| 1162 | | for (dip = menustate->diplist; dip != NULL; dip = dip->next) |
| 1047 | for (dip = diplist; dip != NULL; dip = dip->next) |
| 1163 | 1048 | if (strcmp(dip->name, diploc->swname) == 0) |
| 1164 | 1049 | break; |
| 1165 | 1050 | |
| 1166 | 1051 | /* allocate new if none */ |
| 1167 | 1052 | if (dip == NULL) |
| 1168 | 1053 | { |
| 1169 | | dip = (dip_descriptor *)menu->m_pool_alloc(sizeof(*dip)); |
| 1054 | dip = (dip_descriptor *)m_pool_alloc(sizeof(*dip)); |
| 1170 | 1055 | dip->next = NULL; |
| 1171 | 1056 | dip->name = diploc->swname; |
| 1172 | 1057 | dip->mask = dip->state = 0; |
| r13553 | r13554 | |
| 1186 | 1071 | } |
| 1187 | 1072 | } |
| 1188 | 1073 | } |
| 1074 | } |
| 1189 | 1075 | |
| 1190 | | /* configure the extra menu */ |
| 1191 | | if (type == IPT_DIPSWITCH && menustate->diplist != NULL) |
| 1192 | | menu->set_custom_render(menu_settings_custom_render, 0.0f, dipcount * (DIP_SWITCH_HEIGHT + DIP_SWITCH_SPACING) + DIP_SWITCH_SPACING); |
| 1076 | ui_menu_settings::~ui_menu_settings() |
| 1077 | { |
| 1193 | 1078 | } |
| 1194 | 1079 | |
| 1195 | | |
| 1196 | 1080 | /*------------------------------------------------- |
| 1197 | 1081 | menu_settings_custom_render - perform our special |
| 1198 | 1082 | rendering |
| 1199 | 1083 | -------------------------------------------------*/ |
| 1200 | 1084 | |
| 1201 | | static void menu_settings_custom_render(running_machine &machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) |
| 1085 | void ui_menu_settings_dip_switches::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) |
| 1202 | 1086 | { |
| 1203 | 1087 | input_field_config *field = (input_field_config *)selectedref; |
| 1204 | | settings_menu_state *menustate = (settings_menu_state *)state; |
| 1205 | 1088 | dip_descriptor *dip; |
| 1206 | 1089 | |
| 1207 | 1090 | /* add borders */ |
| r13553 | r13554 | |
| 1209 | 1092 | y2 = y1 + bottom; |
| 1210 | 1093 | |
| 1211 | 1094 | /* draw extra menu area */ |
| 1212 | | ui_draw_outlined_box(&machine.render().ui_container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); |
| 1095 | ui_draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR); |
| 1213 | 1096 | y1 += (float)DIP_SWITCH_SPACING; |
| 1214 | 1097 | |
| 1215 | 1098 | /* iterate over DIP switches */ |
| 1216 | | for (dip = menustate->diplist; dip != NULL; dip = dip->next) |
| 1099 | for (dip = diplist; dip != NULL; dip = dip->next) |
| 1217 | 1100 | { |
| 1218 | 1101 | if (mame_stricmp(dip->name, "FAKE") != 0) |
| 1219 | 1102 | { |
| r13553 | r13554 | |
| 1227 | 1110 | selectedmask |= 1 << (diploc->swnum - 1); |
| 1228 | 1111 | |
| 1229 | 1112 | /* draw one switch */ |
| 1230 | | menu_settings_custom_render_one(&machine.render().ui_container(), x1, y1, x2, y1 + DIP_SWITCH_HEIGHT, dip, selectedmask); |
| 1113 | custom_render_one(x1, y1, x2, y1 + DIP_SWITCH_HEIGHT, dip, selectedmask); |
| 1231 | 1114 | y1 += (float)(DIP_SWITCH_SPACING + DIP_SWITCH_HEIGHT); |
| 1232 | 1115 | } |
| 1233 | 1116 | } |
| r13553 | r13554 | |
| 1239 | 1122 | DIP switch |
| 1240 | 1123 | -------------------------------------------------*/ |
| 1241 | 1124 | |
| 1242 | | static void menu_settings_custom_render_one(render_container *container, float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask) |
| 1125 | void ui_menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2, float y2, const dip_descriptor *dip, UINT32 selectedmask) |
| 1243 | 1126 | { |
| 1244 | 1127 | float switch_field_width = SINGLE_TOGGLE_SWITCH_FIELD_WIDTH * container->manager().ui_aspect(); |
| 1245 | 1128 | float switch_width = SINGLE_TOGGLE_SWITCH_WIDTH * container->manager().ui_aspect(); |
| r13553 | r13554 | |
| 1308 | 1191 | menu_analog - handle the analog settings menu |
| 1309 | 1192 | -------------------------------------------------*/ |
| 1310 | 1193 | |
| 1311 | | static void menu_analog(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 1194 | void ui_menu_analog::handle() |
| 1312 | 1195 | { |
| 1313 | | const ui_menu_event *menu_event; |
| 1314 | | |
| 1315 | | /* if the menu isn't built, populate now */ |
| 1316 | | if (!menu->populated()) |
| 1317 | | menu_analog_populate(machine, menu); |
| 1318 | | |
| 1319 | 1196 | /* process the menu */ |
| 1320 | | menu_event = menu->process(UI_MENU_PROCESS_LR_REPEAT); |
| 1197 | const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT); |
| 1321 | 1198 | |
| 1322 | 1199 | /* handle events */ |
| 1323 | 1200 | if (menu_event != NULL && menu_event->itemref != NULL) |
| r13553 | r13554 | |
| 1334 | 1211 | |
| 1335 | 1212 | /* left decrements */ |
| 1336 | 1213 | case IPT_UI_LEFT: |
| 1337 | | newval -= machine.input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; |
| 1214 | newval -= machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; |
| 1338 | 1215 | break; |
| 1339 | 1216 | |
| 1340 | 1217 | /* right increments */ |
| 1341 | 1218 | case IPT_UI_RIGHT: |
| 1342 | | newval += machine.input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; |
| 1219 | newval += machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; |
| 1343 | 1220 | break; |
| 1344 | 1221 | } |
| 1345 | 1222 | |
| r13553 | r13554 | |
| 1366 | 1243 | input_field_set_user_settings(data->field, &settings); |
| 1367 | 1244 | |
| 1368 | 1245 | /* rebuild the menu */ |
| 1369 | | menu->reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 1246 | reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 1370 | 1247 | } |
| 1371 | 1248 | } |
| 1372 | 1249 | } |
| r13553 | r13554 | |
| 1377 | 1254 | settings menu |
| 1378 | 1255 | -------------------------------------------------*/ |
| 1379 | 1256 | |
| 1380 | | static void menu_analog_populate(running_machine &machine, ui_menu *menu) |
| 1257 | ui_menu_analog::ui_menu_analog(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 1381 | 1258 | { |
| 1259 | } |
| 1260 | |
| 1261 | void ui_menu_analog::populate() |
| 1262 | { |
| 1382 | 1263 | input_field_config *field; |
| 1383 | 1264 | input_port_config *port; |
| 1384 | 1265 | astring subtext; |
| 1385 | 1266 | astring text; |
| 1386 | 1267 | |
| 1387 | 1268 | /* loop over input ports and add the items */ |
| 1388 | | for (port = machine.m_portlist.first(); port != NULL; port = port->next()) |
| 1269 | for (port = machine().m_portlist.first(); port != NULL; port = port->next()) |
| 1389 | 1270 | for (field = port->fieldlist().first(); field != NULL; field = field->next()) |
| 1390 | | if (input_type_is_analog(field->type) && input_condition_true(machine, &field->condition, port->owner())) |
| 1271 | if (input_type_is_analog(field->type) && input_condition_true(machine(), &field->condition, port->owner())) |
| 1391 | 1272 | { |
| 1392 | 1273 | input_field_user_settings settings; |
| 1393 | | int use_autocenter = FALSE; |
| 1274 | int use_autocenter = false; |
| 1394 | 1275 | int type; |
| 1395 | 1276 | |
| 1396 | 1277 | /* based on the type, determine if we enable autocenter */ |
| r13553 | r13554 | |
| 1409 | 1290 | case IPT_PEDAL: |
| 1410 | 1291 | case IPT_PEDAL2: |
| 1411 | 1292 | case IPT_PEDAL3: |
| 1412 | | use_autocenter = TRUE; |
| 1293 | use_autocenter = true; |
| 1413 | 1294 | break; |
| 1414 | 1295 | } |
| 1415 | 1296 | |
| r13553 | r13554 | |
| 1424 | 1305 | UINT32 flags = 0; |
| 1425 | 1306 | |
| 1426 | 1307 | /* allocate a data item for tracking what this menu item refers to */ |
| 1427 | | data = (analog_item_data *)menu->m_pool_alloc(sizeof(*data)); |
| 1308 | data = (analog_item_data *)m_pool_alloc(sizeof(*data)); |
| 1428 | 1309 | data->field = field; |
| 1429 | 1310 | data->type = type; |
| 1430 | 1311 | |
| r13553 | r13554 | |
| 1476 | 1357 | flags |= MENU_FLAG_RIGHT_ARROW; |
| 1477 | 1358 | |
| 1478 | 1359 | /* append a menu item */ |
| 1479 | | menu->item_append(text, subtext, flags, data); |
| 1360 | item_append(text, subtext, flags, data); |
| 1480 | 1361 | } |
| 1481 | 1362 | } |
| 1482 | 1363 | } |
| 1483 | 1364 | |
| 1365 | ui_menu_analog::~ui_menu_analog() |
| 1366 | { |
| 1367 | } |
| 1484 | 1368 | |
| 1485 | 1369 | /*------------------------------------------------- |
| 1486 | 1370 | menu_bookkeeping - handle the bookkeeping |
| 1487 | 1371 | information menu |
| 1488 | 1372 | -------------------------------------------------*/ |
| 1489 | 1373 | |
| 1490 | | static void menu_bookkeeping(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 1374 | void ui_menu_bookkeeping::handle() |
| 1491 | 1375 | { |
| 1492 | | attotime *prevtime; |
| 1493 | 1376 | attotime curtime; |
| 1494 | 1377 | |
| 1495 | | /* if no state, allocate some */ |
| 1496 | | if (state == NULL) |
| 1497 | | state = menu->alloc_state(sizeof(*prevtime), NULL); |
| 1498 | | prevtime = (attotime *)state; |
| 1499 | | |
| 1500 | 1378 | /* if the time has rolled over another second, regenerate */ |
| 1501 | | curtime = machine.time(); |
| 1502 | | if (prevtime->seconds != curtime.seconds) |
| 1379 | curtime = machine().time(); |
| 1380 | if (prevtime.seconds != curtime.seconds) |
| 1503 | 1381 | { |
| 1504 | | menu->reset(UI_MENU_RESET_SELECT_FIRST); |
| 1505 | | *prevtime = curtime; |
| 1506 | | menu_bookkeeping_populate(machine, menu, prevtime); |
| 1382 | reset(UI_MENU_RESET_SELECT_FIRST); |
| 1383 | prevtime = curtime; |
| 1384 | populate(); |
| 1507 | 1385 | } |
| 1508 | 1386 | |
| 1509 | 1387 | /* process the menu */ |
| 1510 | | menu->process(0); |
| 1388 | process(0); |
| 1511 | 1389 | } |
| 1512 | 1390 | |
| 1513 | 1391 | |
| r13553 | r13554 | |
| 1515 | 1393 | menu_bookkeeping - handle the bookkeeping |
| 1516 | 1394 | information menu |
| 1517 | 1395 | -------------------------------------------------*/ |
| 1396 | ui_menu_bookkeeping::ui_menu_bookkeeping(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 1397 | { |
| 1398 | } |
| 1518 | 1399 | |
| 1519 | | static void menu_bookkeeping_populate(running_machine &machine, ui_menu *menu, attotime *curtime) |
| 1400 | ui_menu_bookkeeping::~ui_menu_bookkeeping() |
| 1520 | 1401 | { |
| 1521 | | int tickets = get_dispensed_tickets(machine); |
| 1402 | } |
| 1403 | |
| 1404 | void ui_menu_bookkeeping::populate() |
| 1405 | { |
| 1406 | int tickets = get_dispensed_tickets(machine()); |
| 1522 | 1407 | astring tempstring; |
| 1523 | 1408 | int ctrnum; |
| 1524 | 1409 | |
| 1525 | 1410 | /* show total time first */ |
| 1526 | | if (curtime->seconds >= 60 * 60) |
| 1527 | | tempstring.catprintf("Uptime: %d:%02d:%02d\n\n", curtime->seconds / (60*60), (curtime->seconds / 60) % 60, curtime->seconds % 60); |
| 1411 | if (prevtime.seconds >= 60 * 60) |
| 1412 | tempstring.catprintf("Uptime: %d:%02d:%02d\n\n", prevtime.seconds / (60*60), (prevtime.seconds / 60) % 60, prevtime.seconds % 60); |
| 1528 | 1413 | else |
| 1529 | | tempstring.catprintf("Uptime: %d:%02d\n\n", (curtime->seconds / 60) % 60, curtime->seconds % 60); |
| 1414 | tempstring.catprintf("Uptime: %d:%02d\n\n", (prevtime.seconds / 60) % 60, prevtime.seconds % 60); |
| 1530 | 1415 | |
| 1531 | 1416 | /* show tickets at the top */ |
| 1532 | 1417 | if (tickets > 0) |
| r13553 | r13554 | |
| 1535 | 1420 | /* loop over coin counters */ |
| 1536 | 1421 | for (ctrnum = 0; ctrnum < COIN_COUNTERS; ctrnum++) |
| 1537 | 1422 | { |
| 1538 | | int count = coin_counter_get_count(machine, ctrnum); |
| 1423 | int count = coin_counter_get_count(machine(), ctrnum); |
| 1539 | 1424 | |
| 1540 | 1425 | /* display the coin counter number */ |
| 1541 | 1426 | tempstring.catprintf("Coin %c: ", ctrnum + 'A'); |
| r13553 | r13554 | |
| 1547 | 1432 | tempstring.catprintf("%d", count); |
| 1548 | 1433 | |
| 1549 | 1434 | /* display whether or not we are locked out */ |
| 1550 | | if (coin_lockout_get_state(machine, ctrnum)) |
| 1435 | if (coin_lockout_get_state(machine(), ctrnum)) |
| 1551 | 1436 | tempstring.cat(" (locked)"); |
| 1552 | 1437 | tempstring.cat("\n"); |
| 1553 | 1438 | } |
| 1554 | 1439 | |
| 1555 | 1440 | /* append the single item */ |
| 1556 | | menu->item_append(tempstring, NULL, MENU_FLAG_MULTILINE, NULL); |
| 1441 | item_append(tempstring, NULL, MENU_FLAG_MULTILINE, NULL); |
| 1557 | 1442 | } |
| 1558 | 1443 | |
| 1559 | 1444 | |
| r13553 | r13554 | |
| 1562 | 1447 | menu |
| 1563 | 1448 | -------------------------------------------------*/ |
| 1564 | 1449 | |
| 1565 | | static void menu_game_info(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 1450 | ui_menu_game_info::ui_menu_game_info(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 1566 | 1451 | { |
| 1567 | | /* if the menu isn't built, populate now */ |
| 1568 | | if (!menu->populated()) |
| 1569 | | { |
| 1570 | | astring tempstring; |
| 1571 | | menu->item_append(game_info_astring(machine, tempstring), NULL, MENU_FLAG_MULTILINE, NULL); |
| 1572 | | } |
| 1452 | } |
| 1573 | 1453 | |
| 1454 | void ui_menu_game_info::populate() |
| 1455 | { |
| 1456 | astring tempstring; |
| 1457 | item_append(game_info_astring(machine(), tempstring), NULL, MENU_FLAG_MULTILINE, NULL); |
| 1458 | } |
| 1459 | |
| 1460 | void ui_menu_game_info::handle() |
| 1461 | { |
| 1574 | 1462 | /* process the menu */ |
| 1575 | | menu->process(0); |
| 1463 | process(0); |
| 1576 | 1464 | } |
| 1577 | 1465 | |
| 1466 | ui_menu_game_info::~ui_menu_game_info() |
| 1467 | { |
| 1468 | } |
| 1578 | 1469 | |
| 1579 | 1470 | /*------------------------------------------------- |
| 1580 | 1471 | menu_cheat - handle the cheat menu |
| 1581 | 1472 | -------------------------------------------------*/ |
| 1582 | 1473 | |
| 1583 | | static void menu_cheat(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 1474 | void ui_menu_cheat::handle() |
| 1584 | 1475 | { |
| 1585 | | const ui_menu_event *menu_event; |
| 1586 | | |
| 1587 | | /* if the menu isn't built, populate now */ |
| 1588 | | if (!menu->populated()) |
| 1589 | | menu_cheat_populate(machine, menu); |
| 1590 | | |
| 1591 | 1476 | /* process the menu */ |
| 1592 | | menu_event = menu->process(UI_MENU_PROCESS_LR_REPEAT); |
| 1477 | const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT); |
| 1593 | 1478 | |
| 1594 | 1479 | /* handle events */ |
| 1595 | 1480 | if (menu_event != NULL && menu_event->itemref != NULL) |
| r13553 | r13554 | |
| 1602 | 1487 | /* handle reset all + reset all cheats for reload all option */ |
| 1603 | 1488 | if ((FPTR)menu_event->itemref < 3 && menu_event->iptkey == IPT_UI_SELECT) |
| 1604 | 1489 | { |
| 1605 | | for (cheat_entry *curcheat = machine.cheat().first(); curcheat != NULL; curcheat = curcheat->next()) |
| 1490 | for (cheat_entry *curcheat = machine().cheat().first(); curcheat != NULL; curcheat = curcheat->next()) |
| 1606 | 1491 | if (curcheat->select_default_state()) |
| 1607 | 1492 | changed = true; |
| 1608 | 1493 | } |
| r13553 | r13554 | |
| 1650 | 1535 | if ((FPTR)menu_event->itemref == 2 && menu_event->iptkey == IPT_UI_SELECT) |
| 1651 | 1536 | { |
| 1652 | 1537 | /* re-init cheat engine and thus reload cheats/cheats have already been turned off by here */ |
| 1653 | | machine.cheat().reload(); |
| 1538 | machine().cheat().reload(); |
| 1654 | 1539 | |
| 1655 | 1540 | /* display the reloaded cheats */ |
| 1656 | | menu->reset(UI_MENU_RESET_REMEMBER_REF); |
| 1541 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 1657 | 1542 | popmessage("All cheats reloaded"); |
| 1658 | 1543 | } |
| 1659 | 1544 | |
| 1660 | 1545 | /* if things changed, update */ |
| 1661 | 1546 | if (changed) |
| 1662 | | menu->reset(UI_MENU_RESET_REMEMBER_REF); |
| 1547 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 1663 | 1548 | } |
| 1664 | 1549 | } |
| 1665 | 1550 | |
| r13553 | r13554 | |
| 1668 | 1553 | menu_cheat_populate - populate the cheat menu |
| 1669 | 1554 | -------------------------------------------------*/ |
| 1670 | 1555 | |
| 1671 | | static void menu_cheat_populate(running_machine &machine, ui_menu *menu) |
| 1556 | ui_menu_cheat::ui_menu_cheat(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 1672 | 1557 | { |
| 1558 | } |
| 1559 | |
| 1560 | void ui_menu_cheat::populate() |
| 1561 | { |
| 1673 | 1562 | /* iterate over cheats */ |
| 1674 | 1563 | astring text; |
| 1675 | 1564 | astring subtext; |
| 1676 | | for (cheat_entry *curcheat = machine.cheat().first(); curcheat != NULL; curcheat = curcheat->next()) |
| 1565 | for (cheat_entry *curcheat = machine().cheat().first(); curcheat != NULL; curcheat = curcheat->next()) |
| 1677 | 1566 | { |
| 1678 | 1567 | UINT32 flags; |
| 1679 | 1568 | curcheat->menu_text(text, subtext, flags); |
| 1680 | | menu->item_append(text, subtext, flags, curcheat); |
| 1569 | item_append(text, subtext, flags, curcheat); |
| 1681 | 1570 | } |
| 1682 | 1571 | |
| 1683 | 1572 | /* add a separator */ |
| 1684 | | menu->item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 1573 | item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 1685 | 1574 | |
| 1686 | 1575 | /* add a reset all option */ |
| 1687 | | menu->item_append("Reset All", NULL, 0, (void *)1); |
| 1576 | item_append("Reset All", NULL, 0, (void *)1); |
| 1688 | 1577 | |
| 1689 | 1578 | /* add a reload all cheats option */ |
| 1690 | | menu->item_append("Reload All", NULL, 0, (void *)2); |
| 1579 | item_append("Reload All", NULL, 0, (void *)2); |
| 1691 | 1580 | } |
| 1692 | 1581 | |
| 1582 | ui_menu_cheat::~ui_menu_cheat() |
| 1583 | { |
| 1584 | } |
| 1693 | 1585 | |
| 1694 | 1586 | /*------------------------------------------------- |
| 1695 | 1587 | menu_memory_card - handle the memory card |
| 1696 | 1588 | menu |
| 1697 | 1589 | -------------------------------------------------*/ |
| 1698 | 1590 | |
| 1699 | | static void menu_memory_card(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 1591 | void ui_menu_memory_card::handle() |
| 1700 | 1592 | { |
| 1701 | | const ui_menu_event *menu_event; |
| 1702 | | int *cardnum; |
| 1703 | | |
| 1704 | | /* if no state, allocate some */ |
| 1705 | | if (state == NULL) |
| 1706 | | state = menu->alloc_state(sizeof(*cardnum), NULL); |
| 1707 | | cardnum = (int *)state; |
| 1708 | | |
| 1709 | | /* if the menu isn't built, populate now */ |
| 1710 | | if (!menu->populated()) |
| 1711 | | menu_memory_card_populate(machine, menu, *cardnum); |
| 1712 | | |
| 1713 | 1593 | /* process the menu */ |
| 1714 | | menu_event = menu->process(UI_MENU_PROCESS_LR_REPEAT); |
| 1594 | const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT); |
| 1715 | 1595 | |
| 1716 | 1596 | /* if something was selected, act on it */ |
| 1717 | 1597 | if (menu_event != NULL && menu_event->itemref != NULL) |
| r13553 | r13554 | |
| 1725 | 1605 | { |
| 1726 | 1606 | /* handle card loading; if we succeed, clear the menus */ |
| 1727 | 1607 | case MEMCARD_ITEM_LOAD: |
| 1728 | | if (memcard_insert(menu->machine(), *cardnum) == 0) |
| 1608 | if (memcard_insert(machine(), cardnum) == 0) |
| 1729 | 1609 | { |
| 1730 | 1610 | popmessage("Memory card loaded"); |
| 1731 | | ui_menu::stack_reset(menu->machine()); |
| 1611 | ui_menu::stack_reset(machine()); |
| 1732 | 1612 | } |
| 1733 | 1613 | else |
| 1734 | 1614 | popmessage("Error loading memory card"); |
| r13553 | r13554 | |
| 1736 | 1616 | |
| 1737 | 1617 | /* handle card ejecting */ |
| 1738 | 1618 | case MEMCARD_ITEM_EJECT: |
| 1739 | | memcard_eject(menu->machine()); |
| 1619 | memcard_eject(machine()); |
| 1740 | 1620 | popmessage("Memory card ejected"); |
| 1741 | 1621 | break; |
| 1742 | 1622 | |
| 1743 | 1623 | /* handle card creating */ |
| 1744 | 1624 | case MEMCARD_ITEM_CREATE: |
| 1745 | | if (memcard_create(menu->machine(), *cardnum, FALSE) == 0) |
| 1625 | if (memcard_create(machine(), cardnum, false) == 0) |
| 1746 | 1626 | popmessage("Memory card created"); |
| 1747 | 1627 | else |
| 1748 | 1628 | popmessage("Error creating memory card\n(Card may already exist)"); |
| r13553 | r13554 | |
| 1757 | 1637 | { |
| 1758 | 1638 | /* left decrements the card number */ |
| 1759 | 1639 | case IPT_UI_LEFT: |
| 1760 | | *cardnum -= 1; |
| 1761 | | menu->reset(UI_MENU_RESET_REMEMBER_REF); |
| 1640 | cardnum -= 1; |
| 1641 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 1762 | 1642 | break; |
| 1763 | 1643 | |
| 1764 | 1644 | /* right decrements the card number */ |
| 1765 | 1645 | case IPT_UI_RIGHT: |
| 1766 | | *cardnum += 1; |
| 1767 | | menu->reset(UI_MENU_RESET_REMEMBER_REF); |
| 1646 | cardnum += 1; |
| 1647 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 1768 | 1648 | break; |
| 1769 | 1649 | } |
| 1770 | 1650 | } |
| r13553 | r13554 | |
| 1777 | 1657 | memory card menu |
| 1778 | 1658 | -------------------------------------------------*/ |
| 1779 | 1659 | |
| 1780 | | static void menu_memory_card_populate(running_machine &machine, ui_menu *menu, int cardnum) |
| 1660 | ui_menu_memory_card::ui_menu_memory_card(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 1781 | 1661 | { |
| 1662 | } |
| 1663 | |
| 1664 | void ui_menu_memory_card::populate() |
| 1665 | { |
| 1782 | 1666 | char tempstring[20]; |
| 1783 | 1667 | UINT32 flags = 0; |
| 1784 | 1668 | |
| r13553 | r13554 | |
| 1788 | 1672 | flags |= MENU_FLAG_LEFT_ARROW; |
| 1789 | 1673 | if (cardnum < 1000) |
| 1790 | 1674 | flags |= MENU_FLAG_RIGHT_ARROW; |
| 1791 | | menu->item_append("Card Number:", tempstring, flags, (void *)MEMCARD_ITEM_SELECT); |
| 1675 | item_append("Card Number:", tempstring, flags, (void *)MEMCARD_ITEM_SELECT); |
| 1792 | 1676 | |
| 1793 | 1677 | /* add the remaining items */ |
| 1794 | | menu->item_append("Load Selected Card", NULL, 0, (void *)MEMCARD_ITEM_LOAD); |
| 1795 | | if (memcard_present(machine) != -1) |
| 1796 | | menu->item_append("Eject Current Card", NULL, 0, (void *)MEMCARD_ITEM_EJECT); |
| 1797 | | menu->item_append("Create New Card", NULL, 0, (void *)MEMCARD_ITEM_CREATE); |
| 1678 | item_append("Load Selected Card", NULL, 0, (void *)MEMCARD_ITEM_LOAD); |
| 1679 | if (memcard_present(machine()) != -1) |
| 1680 | item_append("Eject Current Card", NULL, 0, (void *)MEMCARD_ITEM_EJECT); |
| 1681 | item_append("Create New Card", NULL, 0, (void *)MEMCARD_ITEM_CREATE); |
| 1798 | 1682 | } |
| 1799 | 1683 | |
| 1684 | ui_menu_memory_card::~ui_menu_memory_card() |
| 1685 | { |
| 1686 | } |
| 1800 | 1687 | |
| 1801 | 1688 | /*------------------------------------------------- |
| 1802 | 1689 | menu_sliders - handle the sliders menu |
| 1803 | 1690 | -------------------------------------------------*/ |
| 1804 | 1691 | |
| 1805 | | static void menu_sliders(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 1692 | void ui_menu_sliders::handle() |
| 1806 | 1693 | { |
| 1807 | | int menuless_mode = (parameter != NULL); |
| 1808 | 1694 | const ui_menu_event *menu_event; |
| 1809 | | UINT8 *hidden = (UINT8 *)state; |
| 1810 | 1695 | |
| 1811 | | /* if no state, allocate some */ |
| 1812 | | if (hidden == NULL) |
| 1813 | | hidden = (UINT8 *)menu->alloc_state(sizeof(*hidden), NULL); |
| 1814 | | if (menuless_mode) |
| 1815 | | *hidden = TRUE; |
| 1816 | | |
| 1817 | | /* if the menu isn't built, populate now */ |
| 1818 | | if (!menu->populated()) |
| 1819 | | menu_sliders_populate(machine, menu, menuless_mode); |
| 1820 | | |
| 1821 | 1696 | /* process the menu */ |
| 1822 | | menu_event = menu->process(UI_MENU_PROCESS_LR_REPEAT | (*hidden ? UI_MENU_PROCESS_CUSTOM_ONLY : 0)); |
| 1697 | menu_event = process(UI_MENU_PROCESS_LR_REPEAT | (hidden ? UI_MENU_PROCESS_CUSTOM_ONLY : 0)); |
| 1823 | 1698 | if (menu_event != NULL) |
| 1824 | 1699 | { |
| 1825 | 1700 | /* handle keys if there is a valid item selected */ |
| 1826 | 1701 | if (menu_event->itemref != NULL) |
| 1827 | 1702 | { |
| 1828 | 1703 | const slider_state *slider = (const slider_state *)menu_event->itemref; |
| 1829 | | INT32 curvalue = (*slider->update)(machine, slider->arg, NULL, SLIDER_NOCHANGE); |
| 1704 | INT32 curvalue = (*slider->update)(machine(), slider->arg, NULL, SLIDER_NOCHANGE); |
| 1830 | 1705 | INT32 increment = 0; |
| 1831 | 1706 | |
| 1832 | 1707 | switch (menu_event->iptkey) |
| r13553 | r13554 | |
| 1834 | 1709 | /* toggle visibility */ |
| 1835 | 1710 | case IPT_UI_ON_SCREEN_DISPLAY: |
| 1836 | 1711 | if (menuless_mode) |
| 1837 | | ui_menu::stack_pop(machine); |
| 1712 | ui_menu::stack_pop(machine()); |
| 1838 | 1713 | else |
| 1839 | | *hidden = !*hidden; |
| 1714 | hidden = !hidden; |
| 1840 | 1715 | break; |
| 1841 | 1716 | |
| 1842 | 1717 | /* decrease value */ |
| 1843 | 1718 | case IPT_UI_LEFT: |
| 1844 | | if (machine.input().code_pressed(KEYCODE_LALT) || machine.input().code_pressed(KEYCODE_RALT)) |
| 1719 | if (machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT)) |
| 1845 | 1720 | increment = -1; |
| 1846 | | else if (machine.input().code_pressed(KEYCODE_LSHIFT) || machine.input().code_pressed(KEYCODE_RSHIFT)) |
| 1721 | else if (machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT)) |
| 1847 | 1722 | increment = (slider->incval > 10) ? -(slider->incval / 10) : -1; |
| 1848 | | else if (machine.input().code_pressed(KEYCODE_LCONTROL) || machine.input().code_pressed(KEYCODE_RCONTROL)) |
| 1723 | else if (machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL)) |
| 1849 | 1724 | increment = -slider->incval * 10; |
| 1850 | 1725 | else |
| 1851 | 1726 | increment = -slider->incval; |
| r13553 | r13554 | |
| 1853 | 1728 | |
| 1854 | 1729 | /* increase value */ |
| 1855 | 1730 | case IPT_UI_RIGHT: |
| 1856 | | if (machine.input().code_pressed(KEYCODE_LALT) || machine.input().code_pressed(KEYCODE_RALT)) |
| 1731 | if (machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT)) |
| 1857 | 1732 | increment = 1; |
| 1858 | | else if (machine.input().code_pressed(KEYCODE_LSHIFT) || machine.input().code_pressed(KEYCODE_RSHIFT)) |
| 1733 | else if (machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT)) |
| 1859 | 1734 | increment = (slider->incval > 10) ? (slider->incval / 10) : 1; |
| 1860 | | else if (machine.input().code_pressed(KEYCODE_LCONTROL) || machine.input().code_pressed(KEYCODE_RCONTROL)) |
| 1735 | else if (machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL)) |
| 1861 | 1736 | increment = slider->incval * 10; |
| 1862 | 1737 | else |
| 1863 | 1738 | increment = slider->incval; |
| r13553 | r13554 | |
| 1881 | 1756 | newvalue = slider->maxval; |
| 1882 | 1757 | |
| 1883 | 1758 | /* update the slider and recompute the menu */ |
| 1884 | | (*slider->update)(machine, slider->arg, NULL, newvalue); |
| 1885 | | menu->reset(UI_MENU_RESET_REMEMBER_REF); |
| 1759 | (*slider->update)(machine(), slider->arg, NULL, newvalue); |
| 1760 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 1886 | 1761 | } |
| 1887 | 1762 | } |
| 1888 | 1763 | |
| 1889 | 1764 | /* if we are selecting an invalid item and we are hidden, skip to the next one */ |
| 1890 | | else if (*hidden) |
| 1765 | else if (hidden) |
| 1891 | 1766 | { |
| 1892 | 1767 | /* if we got here via up or page up, select the previous item */ |
| 1893 | 1768 | if (menu_event->iptkey == IPT_UI_UP || menu_event->iptkey == IPT_UI_PAGE_UP) |
| 1894 | 1769 | { |
| 1895 | | menu->selected = (menu->selected + menu->numitems - 1) % menu->numitems; |
| 1896 | | menu->validate_selection(-1); |
| 1770 | selected = (selected + numitems - 1) % numitems; |
| 1771 | validate_selection(-1); |
| 1897 | 1772 | } |
| 1898 | 1773 | |
| 1899 | 1774 | /* otherwise select the next item */ |
| 1900 | 1775 | else if (menu_event->iptkey == IPT_UI_DOWN || menu_event->iptkey == IPT_UI_PAGE_DOWN) |
| 1901 | 1776 | { |
| 1902 | | menu->selected = (menu->selected + 1) % menu->numitems; |
| 1903 | | menu->validate_selection(1); |
| 1777 | selected = (selected + 1) % numitems; |
| 1778 | validate_selection(1); |
| 1904 | 1779 | } |
| 1905 | 1780 | } |
| 1906 | 1781 | } |
| r13553 | r13554 | |
| 1912 | 1787 | menu |
| 1913 | 1788 | -------------------------------------------------*/ |
| 1914 | 1789 | |
| 1915 | | static void menu_sliders_populate(running_machine &machine, ui_menu *menu, int menuless_mode) |
| 1790 | ui_menu_sliders::ui_menu_sliders(running_machine &machine, render_container *container, bool _menuless_mode) : ui_menu(machine, container) |
| 1916 | 1791 | { |
| 1792 | menuless_mode = hidden = _menuless_mode; |
| 1793 | } |
| 1794 | |
| 1795 | void ui_menu_sliders::populate() |
| 1796 | { |
| 1917 | 1797 | const slider_state *curslider; |
| 1918 | 1798 | astring tempstring; |
| 1919 | 1799 | |
| 1920 | 1800 | /* add all sliders */ |
| 1921 | 1801 | for (curslider = ui_get_slider_list(); curslider != NULL; curslider = curslider->next) |
| 1922 | 1802 | { |
| 1923 | | INT32 curval = (*curslider->update)(machine, curslider->arg, &tempstring, SLIDER_NOCHANGE); |
| 1803 | INT32 curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE); |
| 1924 | 1804 | UINT32 flags = 0; |
| 1925 | 1805 | if (curval > curslider->minval) |
| 1926 | 1806 | flags |= MENU_FLAG_LEFT_ARROW; |
| 1927 | 1807 | if (curval < curslider->maxval) |
| 1928 | 1808 | flags |= MENU_FLAG_RIGHT_ARROW; |
| 1929 | | menu->item_append(curslider->description, tempstring, flags, (void *)curslider); |
| 1809 | item_append(curslider->description, tempstring, flags, (void *)curslider); |
| 1930 | 1810 | |
| 1931 | 1811 | if (menuless_mode) |
| 1932 | 1812 | break; |
| 1933 | 1813 | } |
| 1934 | 1814 | |
| 1935 | 1815 | /* add all sliders */ |
| 1936 | | for (curslider = (slider_state*)machine.osd().get_slider_list(); curslider != NULL; curslider = curslider->next) |
| 1816 | for (curslider = (slider_state*)machine().osd().get_slider_list(); curslider != NULL; curslider = curslider->next) |
| 1937 | 1817 | { |
| 1938 | | INT32 curval = (*curslider->update)(machine, curslider->arg, &tempstring, SLIDER_NOCHANGE); |
| 1818 | INT32 curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE); |
| 1939 | 1819 | UINT32 flags = 0; |
| 1940 | 1820 | if (curval > curslider->minval) |
| 1941 | 1821 | flags |= MENU_FLAG_LEFT_ARROW; |
| 1942 | 1822 | if (curval < curslider->maxval) |
| 1943 | 1823 | flags |= MENU_FLAG_RIGHT_ARROW; |
| 1944 | | menu->item_append(curslider->description, tempstring, flags, (void *)curslider); |
| 1824 | item_append(curslider->description, tempstring, flags, (void *)curslider); |
| 1945 | 1825 | } |
| 1946 | 1826 | |
| 1947 | | menu->set_custom_render(menu_sliders_custom_render, 0.0f, 2.0f * ui_get_line_height(machine) + 2.0f * UI_BOX_TB_BORDER); |
| 1827 | custombottom = 2.0f * ui_get_line_height(machine()) + 2.0f * UI_BOX_TB_BORDER; |
| 1948 | 1828 | } |
| 1949 | 1829 | |
| 1830 | ui_menu_sliders::~ui_menu_sliders() |
| 1831 | { |
| 1832 | } |
| 1950 | 1833 | |
| 1951 | 1834 | /*------------------------------------------------- |
| 1952 | 1835 | menu_sliders_custom_render - perform our special |
| 1953 | 1836 | rendering |
| 1954 | 1837 | -------------------------------------------------*/ |
| 1955 | 1838 | |
| 1956 | | static void menu_sliders_custom_render(running_machine &machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) |
| 1839 | void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) |
| 1957 | 1840 | { |
| 1958 | 1841 | const slider_state *curslider = (const slider_state *)selectedref; |
| 1959 | 1842 | if (curslider != NULL) |
| 1960 | 1843 | { |
| 1961 | 1844 | float bar_left, bar_area_top, bar_width, bar_area_height, bar_top, bar_bottom, default_x, current_x; |
| 1962 | | float line_height = ui_get_line_height(machine); |
| 1845 | float line_height = ui_get_line_height(machine()); |
| 1963 | 1846 | float percentage, default_percentage; |
| 1964 | 1847 | astring tempstring; |
| 1965 | 1848 | float text_height; |
| 1966 | 1849 | INT32 curval; |
| 1967 | 1850 | |
| 1968 | 1851 | /* determine the current value and text */ |
| 1969 | | curval = (*curslider->update)(machine, curslider->arg, &tempstring, SLIDER_NOCHANGE); |
| 1852 | curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE); |
| 1970 | 1853 | |
| 1971 | 1854 | /* compute the current and default percentages */ |
| 1972 | 1855 | percentage = (float)(curval - curslider->minval) / (float)(curslider->maxval - curslider->minval); |
| r13553 | r13554 | |
| 1982 | 1865 | x2 = 1.0f - UI_BOX_LR_BORDER; |
| 1983 | 1866 | |
| 1984 | 1867 | /* draw extra menu area */ |
| 1985 | | ui_draw_outlined_box(&machine.render().ui_container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); |
| 1868 | ui_draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR); |
| 1986 | 1869 | y1 += UI_BOX_TB_BORDER; |
| 1987 | 1870 | |
| 1988 | 1871 | /* determine the text height */ |
| 1989 | | ui_draw_text_full(&machine.render().ui_container(), tempstring, 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, |
| 1872 | ui_draw_text_full(container, tempstring, 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, |
| 1990 | 1873 | JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, NULL, &text_height); |
| 1991 | 1874 | |
| 1992 | 1875 | /* draw the thermometer */ |
| r13553 | r13554 | |
| 2002 | 1885 | current_x = bar_left + bar_width * percentage; |
| 2003 | 1886 | |
| 2004 | 1887 | /* fill in the percentage */ |
| 2005 | | machine.render().ui_container().add_rect(bar_left, bar_top, current_x, bar_bottom, UI_SLIDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 1888 | container->add_rect(bar_left, bar_top, current_x, bar_bottom, UI_SLIDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 2006 | 1889 | |
| 2007 | 1890 | /* draw the top and bottom lines */ |
| 2008 | | machine.render().ui_container().add_line(bar_left, bar_top, bar_left + bar_width, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 2009 | | machine.render().ui_container().add_line(bar_left, bar_bottom, bar_left + bar_width, bar_bottom, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 1891 | container->add_line(bar_left, bar_top, bar_left + bar_width, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 1892 | container->add_line(bar_left, bar_bottom, bar_left + bar_width, bar_bottom, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 2010 | 1893 | |
| 2011 | 1894 | /* draw default marker */ |
| 2012 | | machine.render().ui_container().add_line(default_x, bar_area_top, default_x, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 2013 | | machine.render().ui_container().add_line(default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 1895 | container->add_line(default_x, bar_area_top, default_x, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 1896 | container->add_line(default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 2014 | 1897 | |
| 2015 | 1898 | /* draw the actual text */ |
| 2016 | | ui_draw_text_full(&machine.render().ui_container(), tempstring, x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, |
| 1899 | ui_draw_text_full(container, tempstring, x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, |
| 2017 | 1900 | JUSTIFY_CENTER, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, &text_height); |
| 2018 | 1901 | } |
| 2019 | 1902 | } |
| r13553 | r13554 | |
| 2024 | 1907 | menu |
| 2025 | 1908 | -------------------------------------------------*/ |
| 2026 | 1909 | |
| 2027 | | static void menu_video_targets(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 1910 | void ui_menu_video_targets::handle() |
| 2028 | 1911 | { |
| 2029 | | const ui_menu_event *menu_event; |
| 2030 | | |
| 2031 | | /* if the menu isn't built, populate now */ |
| 2032 | | if (!menu->populated()) |
| 2033 | | menu_video_targets_populate(machine, menu); |
| 2034 | | |
| 2035 | 1912 | /* process the menu */ |
| 2036 | | menu_event = menu->process(0); |
| 1913 | const ui_menu_event *menu_event = process(0); |
| 2037 | 1914 | if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) |
| 2038 | | ui_menu::stack_push(ui_menu_alloc(machine, menu->container, menu_video_options, menu_event->itemref)); |
| 1915 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_video_options(machine(), container, static_cast<render_target *>(menu_event->itemref)))); |
| 2039 | 1916 | } |
| 2040 | 1917 | |
| 2041 | 1918 | |
| r13553 | r13554 | |
| 2044 | 1921 | video targets menu |
| 2045 | 1922 | -------------------------------------------------*/ |
| 2046 | 1923 | |
| 2047 | | static void menu_video_targets_populate(running_machine &machine, ui_menu *menu) |
| 1924 | ui_menu_video_targets::ui_menu_video_targets(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 2048 | 1925 | { |
| 1926 | } |
| 1927 | |
| 1928 | void ui_menu_video_targets::populate() |
| 1929 | { |
| 2049 | 1930 | int targetnum; |
| 2050 | 1931 | |
| 2051 | 1932 | /* find the targets */ |
| 2052 | 1933 | for (targetnum = 0; ; targetnum++) |
| 2053 | 1934 | { |
| 2054 | | render_target *target = machine.render().target_by_index(targetnum); |
| 1935 | render_target *target = machine().render().target_by_index(targetnum); |
| 2055 | 1936 | char buffer[40]; |
| 2056 | 1937 | |
| 2057 | 1938 | /* stop when we run out */ |
| r13553 | r13554 | |
| 2060 | 1941 | |
| 2061 | 1942 | /* add a menu item */ |
| 2062 | 1943 | sprintf(buffer, "Screen #%d", targetnum); |
| 2063 | | menu->item_append(buffer, NULL, 0, target); |
| 1944 | item_append(buffer, NULL, 0, target); |
| 2064 | 1945 | } |
| 2065 | 1946 | } |
| 2066 | 1947 | |
| 1948 | ui_menu_video_targets::~ui_menu_video_targets() |
| 1949 | { |
| 1950 | } |
| 2067 | 1951 | |
| 2068 | 1952 | /*------------------------------------------------- |
| 2069 | 1953 | menu_video_options - handle the video options |
| 2070 | 1954 | menu |
| 2071 | 1955 | -------------------------------------------------*/ |
| 2072 | 1956 | |
| 2073 | | static void menu_video_options(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 1957 | void ui_menu_video_options::handle() |
| 2074 | 1958 | { |
| 2075 | | render_target *target = (parameter != NULL) ? (render_target *)parameter : machine.render().first_target(); |
| 2076 | | const ui_menu_event *menu_event; |
| 2077 | | int changed = FALSE; |
| 1959 | bool changed = false; |
| 2078 | 1960 | |
| 2079 | | /* if the menu isn't built, populate now */ |
| 2080 | | if (!menu->populated()) |
| 2081 | | menu_video_options_populate(machine, menu, target); |
| 2082 | | |
| 2083 | 1961 | /* process the menu */ |
| 2084 | | menu_event = menu->process(0); |
| 1962 | const ui_menu_event *menu_event = process(0); |
| 2085 | 1963 | if (menu_event != NULL && menu_event->itemref != NULL) |
| 2086 | 1964 | { |
| 2087 | 1965 | switch ((FPTR)menu_event->itemref) |
| r13553 | r13554 | |
| 2095 | 1973 | if (target->is_ui_target()) |
| 2096 | 1974 | { |
| 2097 | 1975 | render_container::user_settings settings; |
| 2098 | | machine.render().ui_container().get_user_settings(settings); |
| 1976 | container->get_user_settings(settings); |
| 2099 | 1977 | settings.m_orientation = orientation_add(delta ^ ROT180, settings.m_orientation); |
| 2100 | | machine.render().ui_container().set_user_settings(settings); |
| 1978 | container->set_user_settings(settings); |
| 2101 | 1979 | } |
| 2102 | | changed = TRUE; |
| 1980 | changed = true; |
| 2103 | 1981 | } |
| 2104 | 1982 | break; |
| 2105 | 1983 | |
| r13553 | r13554 | |
| 2108 | 1986 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 2109 | 1987 | { |
| 2110 | 1988 | target->set_backdrops_enabled(!target->backdrops_enabled()); |
| 2111 | | changed = TRUE; |
| 1989 | changed = true; |
| 2112 | 1990 | } |
| 2113 | 1991 | break; |
| 2114 | 1992 | |
| r13553 | r13554 | |
| 2116 | 1994 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 2117 | 1995 | { |
| 2118 | 1996 | target->set_overlays_enabled(!target->overlays_enabled()); |
| 2119 | | changed = TRUE; |
| 1997 | changed = true; |
| 2120 | 1998 | } |
| 2121 | 1999 | break; |
| 2122 | 2000 | |
| r13553 | r13554 | |
| 2124 | 2002 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 2125 | 2003 | { |
| 2126 | 2004 | target->set_bezels_enabled(!target->bezels_enabled()); |
| 2127 | | changed = TRUE; |
| 2005 | changed = true; |
| 2128 | 2006 | } |
| 2129 | 2007 | break; |
| 2130 | 2008 | |
| r13553 | r13554 | |
| 2132 | 2010 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 2133 | 2011 | { |
| 2134 | 2012 | target->set_cpanels_enabled(!target->cpanels_enabled()); |
| 2135 | | changed = TRUE; |
| 2013 | changed = true; |
| 2136 | 2014 | } |
| 2137 | 2015 | break; |
| 2138 | 2016 | |
| r13553 | r13554 | |
| 2140 | 2018 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 2141 | 2019 | { |
| 2142 | 2020 | target->set_marquees_enabled(!target->marquees_enabled()); |
| 2143 | | changed = TRUE; |
| 2021 | changed = true; |
| 2144 | 2022 | } |
| 2145 | 2023 | break; |
| 2146 | 2024 | |
| r13553 | r13554 | |
| 2148 | 2026 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 2149 | 2027 | { |
| 2150 | 2028 | target->set_zoom_to_screen(!target->zoom_to_screen()); |
| 2151 | | changed = TRUE; |
| 2029 | changed = true; |
| 2152 | 2030 | } |
| 2153 | 2031 | break; |
| 2154 | 2032 | |
| r13553 | r13554 | |
| 2157 | 2035 | if (menu_event->iptkey == IPT_UI_SELECT && (int)(FPTR)menu_event->itemref >= VIDEO_ITEM_VIEW) |
| 2158 | 2036 | { |
| 2159 | 2037 | target->set_view((FPTR)menu_event->itemref - VIDEO_ITEM_VIEW); |
| 2160 | | changed = TRUE; |
| 2038 | changed = true; |
| 2161 | 2039 | } |
| 2162 | 2040 | break; |
| 2163 | 2041 | } |
| r13553 | r13554 | |
| 2165 | 2043 | |
| 2166 | 2044 | /* if something changed, rebuild the menu */ |
| 2167 | 2045 | if (changed) |
| 2168 | | menu->reset(UI_MENU_RESET_REMEMBER_REF); |
| 2046 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 2169 | 2047 | } |
| 2170 | 2048 | |
| 2171 | 2049 | |
| r13553 | r13554 | |
| 2174 | 2052 | video options menu |
| 2175 | 2053 | -------------------------------------------------*/ |
| 2176 | 2054 | |
| 2177 | | static void menu_video_options_populate(running_machine &machine, ui_menu *menu, render_target *target) |
| 2055 | ui_menu_video_options::ui_menu_video_options(running_machine &machine, render_container *container, render_target *_target) : ui_menu(machine, container) |
| 2178 | 2056 | { |
| 2179 | | const char *subtext = ""; |
| 2057 | target = _target; |
| 2058 | } |
| 2059 | |
| 2060 | void ui_menu_video_options::populate() |
| 2061 | { |
| 2062 | const char *subtext = ""; |
| 2180 | 2063 | astring tempstring; |
| 2181 | 2064 | int viewnum; |
| 2182 | 2065 | int enabled; |
| r13553 | r13554 | |
| 2190 | 2073 | |
| 2191 | 2074 | /* create a string for the item, replacing underscores with spaces */ |
| 2192 | 2075 | tempstring.cpy(name).replace(0, "_", " "); |
| 2193 | | menu->item_append(tempstring, NULL, 0, (void *)(FPTR)(VIDEO_ITEM_VIEW + viewnum)); |
| 2076 | item_append(tempstring, NULL, 0, (void *)(FPTR)(VIDEO_ITEM_VIEW + viewnum)); |
| 2194 | 2077 | } |
| 2195 | 2078 | |
| 2196 | 2079 | /* add a separator */ |
| 2197 | | menu->item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 2080 | item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 2198 | 2081 | |
| 2199 | 2082 | /* add a rotate item */ |
| 2200 | 2083 | switch (target->orientation()) |
| r13553 | r13554 | |
| 2204 | 2087 | case ROT180: subtext = "180" UTF8_DEGREES; break; |
| 2205 | 2088 | case ROT270: subtext = "CCW 90" UTF8_DEGREES; break; |
| 2206 | 2089 | } |
| 2207 | | menu->item_append("Rotate", subtext, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_ROTATE); |
| 2090 | item_append("Rotate", subtext, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_ROTATE); |
| 2208 | 2091 | |
| 2209 | 2092 | /* backdrop item */ |
| 2210 | 2093 | enabled = target->backdrops_enabled(); |
| 2211 | | menu->item_append("Backdrops", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BACKDROPS); |
| 2094 | item_append("Backdrops", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BACKDROPS); |
| 2212 | 2095 | |
| 2213 | 2096 | /* overlay item */ |
| 2214 | 2097 | enabled = target->overlays_enabled(); |
| 2215 | | menu->item_append("Overlays", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_OVERLAYS); |
| 2098 | item_append("Overlays", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_OVERLAYS); |
| 2216 | 2099 | |
| 2217 | 2100 | /* bezel item */ |
| 2218 | 2101 | enabled = target->bezels_enabled(); |
| 2219 | | menu->item_append("Bezels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BEZELS); |
| 2102 | item_append("Bezels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BEZELS); |
| 2220 | 2103 | |
| 2221 | 2104 | /* cpanel item */ |
| 2222 | 2105 | enabled = target->cpanels_enabled(); |
| 2223 | | menu->item_append("CPanels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_CPANELS); |
| 2106 | item_append("CPanels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_CPANELS); |
| 2224 | 2107 | |
| 2225 | 2108 | /* marquee item */ |
| 2226 | 2109 | enabled = target->marquees_enabled(); |
| 2227 | | menu->item_append("Marquees", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_MARQUEES); |
| 2110 | item_append("Marquees", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_MARQUEES); |
| 2228 | 2111 | |
| 2229 | 2112 | /* cropping */ |
| 2230 | 2113 | enabled = target->zoom_to_screen(); |
| 2231 | | menu->item_append("View", enabled ? "Cropped" : "Full", enabled ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)VIDEO_ITEM_ZOOM); |
| 2114 | item_append("View", enabled ? "Cropped" : "Full", enabled ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)VIDEO_ITEM_ZOOM); |
| 2232 | 2115 | } |
| 2233 | 2116 | |
| 2117 | ui_menu_video_options::~ui_menu_video_options() |
| 2118 | { |
| 2119 | } |
| 2234 | 2120 | |
| 2235 | 2121 | /*------------------------------------------------- |
| 2236 | 2122 | menu_crosshair - handle the crosshair settings |
| 2237 | 2123 | menu |
| 2238 | 2124 | -------------------------------------------------*/ |
| 2239 | 2125 | |
| 2240 | | static void menu_crosshair(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 2126 | void ui_menu_crosshair::handle() |
| 2241 | 2127 | { |
| 2242 | | const ui_menu_event *menu_event; |
| 2243 | | |
| 2244 | | /* if the menu isn't built, populate now */ |
| 2245 | | if (!menu->populated()) |
| 2246 | | menu_crosshair_populate(machine, menu); |
| 2247 | | |
| 2248 | 2128 | /* process the menu */ |
| 2249 | | menu_event = menu->process(UI_MENU_PROCESS_LR_REPEAT); |
| 2129 | const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT); |
| 2250 | 2130 | |
| 2251 | 2131 | /* handle events */ |
| 2252 | 2132 | if (menu_event != NULL && menu_event->itemref != NULL) |
| 2253 | 2133 | { |
| 2254 | 2134 | crosshair_user_settings settings; |
| 2255 | 2135 | crosshair_item_data *data = (crosshair_item_data *)menu_event->itemref; |
| 2256 | | int changed = FALSE; |
| 2257 | | //int set_def = FALSE; |
| 2136 | int changed = false; |
| 2137 | //int set_def = false; |
| 2258 | 2138 | int newval = data->cur; |
| 2259 | 2139 | |
| 2260 | 2140 | /* retreive the user settings */ |
| 2261 | | crosshair_get_user_settings(machine, data->player, &settings); |
| 2141 | crosshair_get_user_settings(machine(), data->player, &settings); |
| 2262 | 2142 | |
| 2263 | 2143 | switch (menu_event->iptkey) |
| 2264 | 2144 | { |
| 2265 | 2145 | /* if selected, reset to default value */ |
| 2266 | 2146 | case IPT_UI_SELECT: |
| 2267 | 2147 | newval = data->defvalue; |
| 2268 | | //set_def = TRUE; |
| 2148 | //set_def = true; |
| 2269 | 2149 | break; |
| 2270 | 2150 | |
| 2271 | 2151 | /* left decrements */ |
| 2272 | 2152 | case IPT_UI_LEFT: |
| 2273 | | newval -= machine.input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; |
| 2153 | newval -= machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; |
| 2274 | 2154 | break; |
| 2275 | 2155 | |
| 2276 | 2156 | /* right increments */ |
| 2277 | 2157 | case IPT_UI_RIGHT: |
| 2278 | | newval += machine.input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; |
| 2158 | newval += machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1; |
| 2279 | 2159 | break; |
| 2280 | 2160 | } |
| 2281 | 2161 | |
| r13553 | r13554 | |
| 2293 | 2173 | /* visibility state */ |
| 2294 | 2174 | case CROSSHAIR_ITEM_VIS: |
| 2295 | 2175 | settings.mode = newval; |
| 2296 | | changed = TRUE; |
| 2176 | changed = true; |
| 2297 | 2177 | break; |
| 2298 | 2178 | |
| 2299 | 2179 | /* auto time */ |
| 2300 | 2180 | case CROSSHAIR_ITEM_AUTO_TIME: |
| 2301 | 2181 | settings.auto_time = newval; |
| 2302 | | changed = TRUE; |
| 2182 | changed = true; |
| 2303 | 2183 | break; |
| 2304 | 2184 | } |
| 2305 | 2185 | } |
| r13553 | r13554 | |
| 2311 | 2191 | { |
| 2312 | 2192 | /* clear the name string to reset to default crosshair */ |
| 2313 | 2193 | settings.name[0] = 0; |
| 2314 | | changed = TRUE; |
| 2194 | changed = true; |
| 2315 | 2195 | } |
| 2316 | 2196 | else if (menu_event->iptkey == IPT_UI_LEFT) |
| 2317 | 2197 | { |
| 2318 | 2198 | strcpy(settings.name, data->last_name); |
| 2319 | | changed = TRUE; |
| 2199 | changed = true; |
| 2320 | 2200 | } |
| 2321 | 2201 | else if (menu_event->iptkey == IPT_UI_RIGHT) |
| 2322 | 2202 | { |
| 2323 | 2203 | strcpy(settings.name, data->next_name); |
| 2324 | | changed = TRUE; |
| 2204 | changed = true; |
| 2325 | 2205 | } |
| 2326 | 2206 | } |
| 2327 | 2207 | |
| 2328 | 2208 | if (changed) |
| 2329 | 2209 | { |
| 2330 | 2210 | /* save the user settings */ |
| 2331 | | crosshair_set_user_settings(machine, data->player, &settings); |
| 2211 | crosshair_set_user_settings(machine(), data->player, &settings); |
| 2332 | 2212 | |
| 2333 | 2213 | /* rebuild the menu */ |
| 2334 | | menu->reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 2214 | reset(UI_MENU_RESET_REMEMBER_POSITION); |
| 2335 | 2215 | } |
| 2336 | 2216 | } |
| 2337 | 2217 | } |
| r13553 | r13554 | |
| 2342 | 2222 | crosshair settings menu |
| 2343 | 2223 | -------------------------------------------------*/ |
| 2344 | 2224 | |
| 2345 | | static void menu_crosshair_populate(running_machine &machine, ui_menu *menu) |
| 2225 | ui_menu_crosshair::ui_menu_crosshair(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 2346 | 2226 | { |
| 2227 | } |
| 2228 | |
| 2229 | void ui_menu_crosshair::populate() |
| 2230 | { |
| 2347 | 2231 | crosshair_user_settings settings; |
| 2348 | 2232 | crosshair_item_data *data; |
| 2349 | 2233 | char temp_text[16]; |
| 2350 | 2234 | int player; |
| 2351 | | UINT8 use_auto = FALSE; |
| 2235 | UINT8 use_auto = false; |
| 2352 | 2236 | UINT32 flags = 0; |
| 2353 | 2237 | |
| 2354 | 2238 | /* loop over player and add the manual items */ |
| 2355 | 2239 | for (player = 0; player < MAX_PLAYERS; player++) |
| 2356 | 2240 | { |
| 2357 | 2241 | /* get the user settings */ |
| 2358 | | crosshair_get_user_settings(machine, player, &settings); |
| 2242 | crosshair_get_user_settings(machine(), player, &settings); |
| 2359 | 2243 | |
| 2360 | 2244 | /* add menu items for usable crosshairs */ |
| 2361 | 2245 | if (settings.used) |
| r13553 | r13554 | |
| 2364 | 2248 | static const char *const vis_text[] = { "Off", "On", "Auto" }; |
| 2365 | 2249 | |
| 2366 | 2250 | /* track if we need the auto time menu */ |
| 2367 | | if (settings.mode == CROSSHAIR_VISIBILITY_AUTO) use_auto = TRUE; |
| 2251 | if (settings.mode == CROSSHAIR_VISIBILITY_AUTO) use_auto = true; |
| 2368 | 2252 | |
| 2369 | 2253 | /* CROSSHAIR_ITEM_VIS - allocate a data item and fill it */ |
| 2370 | | data = (crosshair_item_data *)menu->m_pool_alloc(sizeof(*data)); |
| 2254 | data = (crosshair_item_data *)m_pool_alloc(sizeof(*data)); |
| 2371 | 2255 | data->type = CROSSHAIR_ITEM_VIS; |
| 2372 | 2256 | data->player = player; |
| 2373 | 2257 | data->min = CROSSHAIR_VISIBILITY_OFF; |
| r13553 | r13554 | |
| 2383 | 2267 | |
| 2384 | 2268 | /* add CROSSHAIR_ITEM_VIS menu */ |
| 2385 | 2269 | sprintf(temp_text, "P%d Visibility", player + 1); |
| 2386 | | menu->item_append(temp_text, vis_text[settings.mode], flags, data); |
| 2270 | item_append(temp_text, vis_text[settings.mode], flags, data); |
| 2387 | 2271 | |
| 2388 | 2272 | /* CROSSHAIR_ITEM_PIC - allocate a data item and fill it */ |
| 2389 | | data = (crosshair_item_data *)menu->m_pool_alloc(sizeof(*data)); |
| 2273 | data = (crosshair_item_data *)m_pool_alloc(sizeof(*data)); |
| 2390 | 2274 | data->type = CROSSHAIR_ITEM_PIC; |
| 2391 | 2275 | data->player = player; |
| 2392 | 2276 | data->last_name[0] = 0; |
| r13553 | r13554 | |
| 2395 | 2279 | /* search for crosshair graphics */ |
| 2396 | 2280 | |
| 2397 | 2281 | /* open a path to the crosshairs */ |
| 2398 | | file_enumerator path(machine.options().crosshair_path()); |
| 2282 | file_enumerator path(machine().options().crosshair_path()); |
| 2399 | 2283 | const osd_directory_entry *dir; |
| 2400 | 2284 | /* reset search flags */ |
| 2401 | | int using_default = FALSE; |
| 2402 | | int finished = FALSE; |
| 2403 | | int found = FALSE; |
| 2285 | int using_default = false; |
| 2286 | int finished = false; |
| 2287 | int found = false; |
| 2404 | 2288 | |
| 2405 | 2289 | /* if we are using the default, then we just need to find the first in the list */ |
| 2406 | 2290 | if (strlen(settings.name) == 0) |
| 2407 | | using_default = TRUE; |
| 2291 | using_default = true; |
| 2408 | 2292 | |
| 2409 | 2293 | /* look for the current name, then remember the name before */ |
| 2410 | 2294 | /* and find the next name */ |
| r13553 | r13554 | |
| 2428 | 2312 | /* get the next name */ |
| 2429 | 2313 | strncpy(data->next_name, dir->name, length); |
| 2430 | 2314 | data->next_name[length] = 0; |
| 2431 | | finished = TRUE; |
| 2315 | finished = true; |
| 2432 | 2316 | } |
| 2433 | 2317 | else if (!strncmp(dir->name, settings.name, length)) |
| 2434 | 2318 | { |
| 2435 | 2319 | /* we found the current name */ |
| 2436 | 2320 | /* so loop once more to find the next name */ |
| 2437 | | found = TRUE; |
| 2321 | found = true; |
| 2438 | 2322 | } |
| 2439 | 2323 | else |
| 2440 | 2324 | /* remember last name */ |
| r13553 | r13554 | |
| 2449 | 2333 | if (!found && !using_default) |
| 2450 | 2334 | { |
| 2451 | 2335 | data->next_name[0] = 0; |
| 2452 | | finished = TRUE; |
| 2336 | finished = true; |
| 2453 | 2337 | } |
| 2454 | 2338 | /* setup the selection flags */ |
| 2455 | 2339 | flags = 0; |
| r13553 | r13554 | |
| 2460 | 2344 | |
| 2461 | 2345 | /* add CROSSHAIR_ITEM_PIC menu */ |
| 2462 | 2346 | sprintf(temp_text, "P%d Crosshair", player + 1); |
| 2463 | | menu->item_append(temp_text, using_default ? "DEFAULT" : settings.name, flags, data); |
| 2347 | item_append(temp_text, using_default ? "DEFAULT" : settings.name, flags, data); |
| 2464 | 2348 | } |
| 2465 | 2349 | } |
| 2466 | 2350 | if (use_auto) |
| 2467 | 2351 | { |
| 2468 | 2352 | /* any player can be used to get the autotime */ |
| 2469 | | crosshair_get_user_settings(machine, 0, &settings); |
| 2353 | crosshair_get_user_settings(machine(), 0, &settings); |
| 2470 | 2354 | |
| 2471 | 2355 | /* CROSSHAIR_ITEM_AUTO_TIME - allocate a data item and fill it */ |
| 2472 | | data = (crosshair_item_data *)menu->m_pool_alloc(sizeof(*data)); |
| 2356 | data = (crosshair_item_data *)m_pool_alloc(sizeof(*data)); |
| 2473 | 2357 | data->type = CROSSHAIR_ITEM_AUTO_TIME; |
| 2474 | 2358 | data->min = CROSSHAIR_VISIBILITY_AUTOTIME_MIN; |
| 2475 | 2359 | data->max = CROSSHAIR_VISIBILITY_AUTOTIME_MAX; |
| r13553 | r13554 | |
| 2484 | 2368 | |
| 2485 | 2369 | /* add CROSSHAIR_ITEM_AUTO_TIME menu */ |
| 2486 | 2370 | sprintf(temp_text, "%d", settings.auto_time); |
| 2487 | | menu->item_append("Visible Delay", temp_text, flags, data); |
| 2371 | item_append("Visible Delay", temp_text, flags, data); |
| 2488 | 2372 | } |
| 2489 | 2373 | // else |
| 2490 | 2374 | // /* leave a blank filler line when not in auto time so size does not rescale */ |
| 2491 | | // menu->item_append("", "", NULL, NULL); |
| 2375 | // item_append("", "", NULL, NULL); |
| 2492 | 2376 | } |
| 2493 | 2377 | |
| 2378 | ui_menu_crosshair::~ui_menu_crosshair() |
| 2379 | { |
| 2380 | } |
| 2494 | 2381 | |
| 2495 | 2382 | /*------------------------------------------------- |
| 2496 | 2383 | menu_quit_game - handle the "menu" for |
| 2497 | 2384 | quitting the game |
| 2498 | 2385 | -------------------------------------------------*/ |
| 2499 | 2386 | |
| 2500 | | static void menu_quit_game(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 2387 | ui_menu_quit_game::ui_menu_quit_game(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 2501 | 2388 | { |
| 2389 | } |
| 2390 | |
| 2391 | ui_menu_quit_game::~ui_menu_quit_game() |
| 2392 | { |
| 2393 | } |
| 2394 | |
| 2395 | void ui_menu_quit_game::populate() |
| 2396 | { |
| 2397 | } |
| 2398 | |
| 2399 | void ui_menu_quit_game::handle() |
| 2400 | { |
| 2502 | 2401 | /* request a reset */ |
| 2503 | | machine.schedule_exit(); |
| 2402 | machine().schedule_exit(); |
| 2504 | 2403 | |
| 2505 | 2404 | /* reset the menu stack */ |
| 2506 | | ui_menu::stack_reset(machine); |
| 2405 | ui_menu::stack_reset(machine()); |
| 2507 | 2406 | } |
| 2508 | 2407 | |
| 2509 | 2408 | |
| r13553 | r13554 | |
| 2512 | 2411 | menu |
| 2513 | 2412 | -------------------------------------------------*/ |
| 2514 | 2413 | |
| 2515 | | static void menu_select_game(running_machine &machine, ui_menu *menu, void *parameter, void *state) |
| 2414 | void ui_menu_select_game::handle() |
| 2516 | 2415 | { |
| 2517 | | select_game_state *menustate; |
| 2518 | | const ui_menu_event *menu_event; |
| 2519 | | |
| 2520 | | /* if no state, allocate some */ |
| 2521 | | if (state == NULL) |
| 2522 | | { |
| 2523 | | state = menu->alloc_state(sizeof(*menustate) + sizeof(menustate->driverlist) * driver_list::total(), NULL); |
| 2524 | | if (parameter != NULL) |
| 2525 | | strcpy(((select_game_state *)state)->search, (const char *)parameter); |
| 2526 | | ((select_game_state *)state)->matchlist[0] = -1; |
| 2527 | | } |
| 2528 | | menustate = (select_game_state *)state; |
| 2529 | | |
| 2530 | | /* if the menu isn't built, populate now */ |
| 2531 | | if (!menu->populated()) |
| 2532 | | menu_select_game_populate(machine, menu, menustate); |
| 2533 | | |
| 2534 | 2416 | /* ignore pause keys by swallowing them before we process the menu */ |
| 2535 | | ui_input_pressed(machine, IPT_UI_PAUSE); |
| 2417 | ui_input_pressed(machine(), IPT_UI_PAUSE); |
| 2536 | 2418 | |
| 2537 | 2419 | /* process the menu */ |
| 2538 | | menu_event = menu->process(0); |
| 2420 | const ui_menu_event *menu_event = process(0); |
| 2539 | 2421 | if (menu_event != NULL && menu_event->itemref != NULL) |
| 2540 | 2422 | { |
| 2541 | 2423 | /* reset the error on any future menu_event */ |
| 2542 | | if (menustate->error) |
| 2543 | | menustate->error = FALSE; |
| 2424 | if (error) |
| 2425 | error = false; |
| 2544 | 2426 | |
| 2545 | 2427 | /* handle selections */ |
| 2546 | 2428 | else if (menu_event->iptkey == IPT_UI_SELECT) |
| r13553 | r13554 | |
| 2549 | 2431 | |
| 2550 | 2432 | /* special case for configure inputs */ |
| 2551 | 2433 | if ((FPTR)driver == 1) |
| 2552 | | ui_menu::stack_push(ui_menu_alloc(menu->machine(), menu->container, menu_input_groups, NULL)); |
| 2434 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_groups(machine(), container))); |
| 2553 | 2435 | |
| 2554 | 2436 | /* anything else is a driver */ |
| 2555 | 2437 | else |
| 2556 | 2438 | { |
| 2557 | 2439 | // audit the game first to see if we're going to work |
| 2558 | | driver_enumerator enumerator(machine.options(), *driver); |
| 2440 | driver_enumerator enumerator(machine().options(), *driver); |
| 2559 | 2441 | enumerator.next(); |
| 2560 | 2442 | media_auditor auditor(enumerator); |
| 2561 | 2443 | media_auditor::summary summary = auditor.audit_media(AUDIT_VALIDATE_FAST); |
| r13553 | r13554 | |
| 2563 | 2445 | // if everything looks good, schedule the new driver |
| 2564 | 2446 | if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE) |
| 2565 | 2447 | { |
| 2566 | | machine.schedule_new_driver(*driver); |
| 2567 | | ui_menu::stack_reset(machine); |
| 2448 | machine().schedule_new_driver(*driver); |
| 2449 | ui_menu::stack_reset(machine()); |
| 2568 | 2450 | } |
| 2569 | 2451 | |
| 2570 | 2452 | // otherwise, display an error |
| 2571 | 2453 | else |
| 2572 | 2454 | { |
| 2573 | | menu->reset(UI_MENU_RESET_REMEMBER_REF); |
| 2574 | | menustate->error = TRUE; |
| 2455 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 2456 | error = true; |
| 2575 | 2457 | } |
| 2576 | 2458 | } |
| 2577 | 2459 | } |
| 2578 | 2460 | |
| 2579 | 2461 | /* escape pressed with non-empty text clears the text */ |
| 2580 | | else if (menu_event->iptkey == IPT_UI_CANCEL && menustate->search[0] != 0) |
| 2462 | else if (menu_event->iptkey == IPT_UI_CANCEL && search[0] != 0) |
| 2581 | 2463 | { |
| 2582 | 2464 | /* since we have already been popped, we must recreate ourself from scratch */ |
| 2583 | | ui_menu::stack_push(ui_menu_alloc(menu->machine(), menu->container, menu_select_game, NULL)); |
| 2465 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_select_game(machine(), container, NULL))); |
| 2584 | 2466 | } |
| 2585 | 2467 | |
| 2586 | 2468 | /* typed characters append to the buffer */ |
| 2587 | 2469 | else if (menu_event->iptkey == IPT_SPECIAL) |
| 2588 | 2470 | { |
| 2589 | | int buflen = strlen(menustate->search); |
| 2471 | int buflen = strlen(search); |
| 2590 | 2472 | |
| 2591 | 2473 | /* if it's a backspace and we can handle it, do so */ |
| 2592 | 2474 | if ((menu_event->unichar == 8 || menu_event->unichar == 0x7f) && buflen > 0) |
| 2593 | 2475 | { |
| 2594 | | *(char *)utf8_previous_char(&menustate->search[buflen]) = 0; |
| 2595 | | menustate->rerandomize = TRUE; |
| 2596 | | menu->reset(UI_MENU_RESET_SELECT_FIRST); |
| 2476 | *(char *)utf8_previous_char(&search[buflen]) = 0; |
| 2477 | rerandomize = true; |
| 2478 | reset(UI_MENU_RESET_SELECT_FIRST); |
| 2597 | 2479 | } |
| 2598 | 2480 | |
| 2599 | 2481 | /* if it's any other key and we're not maxed out, update */ |
| 2600 | 2482 | else if (menu_event->unichar >= ' ' && menu_event->unichar < 0x7f) |
| 2601 | 2483 | { |
| 2602 | | buflen += utf8_from_uchar(&menustate->search[buflen], ARRAY_LENGTH(menustate->search) - buflen, menu_event->unichar); |
| 2603 | | menustate->search[buflen] = 0; |
| 2604 | | menu->reset(UI_MENU_RESET_SELECT_FIRST); |
| 2484 | buflen += utf8_from_uchar(&search[buflen], ARRAY_LENGTH(search) - buflen, menu_event->unichar); |
| 2485 | search[buflen] = 0; |
| 2486 | reset(UI_MENU_RESET_SELECT_FIRST); |
| 2605 | 2487 | } |
| 2606 | 2488 | } |
| 2607 | 2489 | } |
| 2608 | 2490 | |
| 2609 | 2491 | /* if we're in an error state, overlay an error message */ |
| 2610 | | if (menustate->error) |
| 2611 | | ui_draw_text_box(&machine.render().ui_container(), |
| 2492 | if (error) |
| 2493 | ui_draw_text_box(container, |
| 2612 | 2494 | "The selected game is missing one or more required ROM or CHD images. " |
| 2613 | 2495 | "Please select a different game.\n\nPress any key to continue.", |
| 2614 | 2496 | JUSTIFY_CENTER, 0.5f, 0.5f, UI_RED_COLOR); |
| r13553 | r13554 | |
| 2619 | 2501 | menu_select_game_populate - populate the game |
| 2620 | 2502 | select menu |
| 2621 | 2503 | -------------------------------------------------*/ |
| 2504 | driver_enumerator *ui_menu_select_game::drivlist; |
| 2622 | 2505 | |
| 2623 | | static void menu_select_game_populate(running_machine &machine, ui_menu *menu, select_game_state *menustate) |
| 2506 | ui_menu_select_game::ui_menu_select_game(running_machine &machine, render_container *container, const char *gamename) : ui_menu(machine, container) |
| 2624 | 2507 | { |
| 2508 | driverlist = (const game_driver **)m_pool_alloc((driver_list::total()+1)*sizeof(const game_driver *)); |
| 2509 | build_driver_list(); |
| 2510 | if(gamename) |
| 2511 | strcpy(search, gamename); |
| 2512 | matchlist[0] = -1; |
| 2513 | } |
| 2514 | |
| 2515 | void ui_menu_select_game::populate() |
| 2516 | { |
| 2625 | 2517 | int matchcount; |
| 2626 | 2518 | int curitem; |
| 2627 | 2519 | |
| 2628 | | /* update our driver list if necessary */ |
| 2629 | | if (menustate->driverlist[0] == NULL) |
| 2630 | | menu_select_game_build_driver_list(menu, menustate); |
| 2631 | | for (curitem = matchcount = 0; menustate->driverlist[curitem] != NULL && matchcount < VISIBLE_GAMES_IN_LIST; curitem++) |
| 2632 | | if (!(menustate->driverlist[curitem]->flags & GAME_NO_STANDALONE)) |
| 2520 | for (curitem = matchcount = 0; driverlist[curitem] != NULL && matchcount < VISIBLE_GAMES_IN_LIST; curitem++) |
| 2521 | if (!(driverlist[curitem]->flags & GAME_NO_STANDALONE)) |
| 2633 | 2522 | matchcount++; |
| 2634 | 2523 | |
| 2635 | 2524 | /* if nothing there, add a single multiline item and return */ |
| r13553 | r13554 | |
| 2642 | 2531 | emulator_info::get_gamesnoun(), |
| 2643 | 2532 | emulator_info::get_configname(), |
| 2644 | 2533 | emulator_info::get_appname(),emulator_info::get_appname() ); |
| 2645 | | menu->item_append(txt.cstr(), NULL, MENU_FLAG_MULTILINE | MENU_FLAG_REDTEXT, NULL); |
| 2534 | item_append(txt.cstr(), NULL, MENU_FLAG_MULTILINE | MENU_FLAG_REDTEXT, NULL); |
| 2646 | 2535 | return; |
| 2647 | 2536 | } |
| 2648 | 2537 | |
| 2649 | 2538 | /* otherwise, rebuild the match list */ |
| 2650 | 2539 | assert(drivlist != NULL); |
| 2651 | | if (menustate->search[0] != 0 || menustate->matchlist[0] == -1 || menustate->rerandomize) |
| 2652 | | drivlist->find_approximate_matches(menustate->search, matchcount, menustate->matchlist); |
| 2653 | | menustate->rerandomize = FALSE; |
| 2540 | if (search[0] != 0 || matchlist[0] == -1 || rerandomize) |
| 2541 | drivlist->find_approximate_matches(search, matchcount, matchlist); |
| 2542 | rerandomize = false; |
| 2654 | 2543 | |
| 2655 | 2544 | /* iterate over entries */ |
| 2656 | 2545 | for (curitem = 0; curitem < matchcount; curitem++) |
| 2657 | 2546 | { |
| 2658 | | int curmatch = menustate->matchlist[curitem]; |
| 2547 | int curmatch = matchlist[curitem]; |
| 2659 | 2548 | if (curmatch != -1) |
| 2660 | 2549 | { |
| 2661 | 2550 | int cloneof = drivlist->non_bios_clone(curmatch); |
| 2662 | | menu->item_append(drivlist->driver(curmatch).name, drivlist->driver(curmatch).description, (cloneof == -1) ? 0 : MENU_FLAG_INVERT, (void *)&drivlist->driver(curmatch)); |
| 2551 | item_append(drivlist->driver(curmatch).name, drivlist->driver(curmatch).description, (cloneof == -1) ? 0 : MENU_FLAG_INVERT, (void *)&drivlist->driver(curmatch)); |
| 2663 | 2552 | } |
| 2664 | 2553 | } |
| 2665 | 2554 | |
| 2666 | 2555 | /* if we're forced into this, allow general input configuration as well */ |
| 2667 | 2556 | if (ui_menu::stack_has_special_main_menu()) |
| 2668 | 2557 | { |
| 2669 | | menu->item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 2670 | | menu->item_append("Configure General Inputs", NULL, 0, (void *)1); |
| 2558 | item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 2559 | item_append("Configure General Inputs", NULL, 0, (void *)1); |
| 2671 | 2560 | } |
| 2672 | 2561 | |
| 2673 | 2562 | /* configure the custom rendering */ |
| 2674 | | menu->set_custom_render(menu_select_game_custom_render, ui_get_line_height(machine) + 3.0f * UI_BOX_TB_BORDER, 4.0f * ui_get_line_height(machine) + 3.0f * UI_BOX_TB_BORDER); |
| 2563 | customtop = ui_get_line_height(machine()) + 3.0f * UI_BOX_TB_BORDER; |
| 2564 | custombottom = 4.0f * ui_get_line_height(machine()) + 3.0f * UI_BOX_TB_BORDER; |
| 2675 | 2565 | } |
| 2676 | 2566 | |
| 2567 | ui_menu_select_game::~ui_menu_select_game() |
| 2568 | { |
| 2569 | global_free(drivlist); |
| 2570 | } |
| 2677 | 2571 | |
| 2678 | 2572 | /*------------------------------------------------- |
| 2679 | 2573 | menu_select_game_build_driver_list - build a |
| 2680 | 2574 | list of available drivers |
| 2681 | 2575 | -------------------------------------------------*/ |
| 2682 | 2576 | |
| 2683 | | static void menu_select_game_build_driver_list(ui_menu *menu, select_game_state *menustate) |
| 2577 | void ui_menu_select_game::build_driver_list() |
| 2684 | 2578 | { |
| 2685 | 2579 | // start with an empty list |
| 2686 | | // hack alert: use new directly here to avoid reporting this one-time static memory as unfreed |
| 2687 | | if (drivlist == NULL) |
| 2688 | | drivlist = global_alloc(driver_enumerator(menu->machine().options())); |
| 2580 | drivlist = global_alloc(driver_enumerator(machine().options())); |
| 2689 | 2581 | drivlist->exclude_all(); |
| 2690 | 2582 | |
| 2691 | 2583 | /* open a path to the ROMs and find them in the array */ |
| 2692 | | file_enumerator path(menu->machine().options().media_path()); |
| 2584 | file_enumerator path(machine().options().media_path()); |
| 2693 | 2585 | const osd_directory_entry *dir; |
| 2694 | 2586 | |
| 2695 | 2587 | /* iterate while we get new objects */ |
| r13553 | r13554 | |
| 2713 | 2605 | drivlist->reset(); |
| 2714 | 2606 | int listnum = 0; |
| 2715 | 2607 | while (drivlist->next()) |
| 2716 | | menustate->driverlist[listnum++] = &drivlist->driver(); |
| 2608 | driverlist[listnum++] = &drivlist->driver(); |
| 2717 | 2609 | |
| 2718 | 2610 | /* NULL-terminate */ |
| 2719 | | menustate->driverlist[listnum] = NULL; |
| 2611 | driverlist[listnum] = NULL; |
| 2720 | 2612 | } |
| 2721 | 2613 | |
| 2722 | 2614 | |
| r13553 | r13554 | |
| 2725 | 2617 | special rendering |
| 2726 | 2618 | -------------------------------------------------*/ |
| 2727 | 2619 | |
| 2728 | | static void menu_select_game_custom_render(running_machine &machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) |
| 2620 | void ui_menu_select_game::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) |
| 2729 | 2621 | { |
| 2730 | | select_game_state *menustate = (select_game_state *)state; |
| 2731 | 2622 | const game_driver *driver; |
| 2732 | 2623 | float width, maxwidth; |
| 2733 | 2624 | float x1, y1, x2, y2; |
| r13553 | r13554 | |
| 2736 | 2627 | int line; |
| 2737 | 2628 | |
| 2738 | 2629 | /* display the current typeahead */ |
| 2739 | | if (menustate->search[0] != 0) |
| 2740 | | sprintf(&tempbuf[0][0], "Type name or select: %s_", menustate->search); |
| 2630 | if (search[0] != 0) |
| 2631 | sprintf(&tempbuf[0][0], "Type name or select: %s_", search); |
| 2741 | 2632 | else |
| 2742 | 2633 | sprintf(&tempbuf[0][0], "Type name or select: (random)"); |
| 2743 | 2634 | |
| 2744 | 2635 | /* get the size of the text */ |
| 2745 | | ui_draw_text_full(&machine.render().ui_container(), &tempbuf[0][0], 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, |
| 2636 | ui_draw_text_full(container, &tempbuf[0][0], 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, |
| 2746 | 2637 | DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, NULL); |
| 2747 | 2638 | width += 2 * UI_BOX_LR_BORDER; |
| 2748 | 2639 | maxwidth = MAX(width, origx2 - origx1); |
| r13553 | r13554 | |
| 2754 | 2645 | y2 = origy1 - UI_BOX_TB_BORDER; |
| 2755 | 2646 | |
| 2756 | 2647 | /* draw a box */ |
| 2757 | | ui_draw_outlined_box(&machine.render().ui_container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); |
| 2648 | ui_draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR); |
| 2758 | 2649 | |
| 2759 | 2650 | /* take off the borders */ |
| 2760 | 2651 | x1 += UI_BOX_LR_BORDER; |
| r13553 | r13554 | |
| 2763 | 2654 | y2 -= UI_BOX_TB_BORDER; |
| 2764 | 2655 | |
| 2765 | 2656 | /* draw the text within it */ |
| 2766 | | ui_draw_text_full(&machine.render().ui_container(), &tempbuf[0][0], x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, |
| 2657 | ui_draw_text_full(container, &tempbuf[0][0], x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, |
| 2767 | 2658 | DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL); |
| 2768 | 2659 | |
| 2769 | 2660 | /* determine the text to render below */ |
| r13553 | r13554 | |
| 2830 | 2721 | maxwidth = origx2 - origx1; |
| 2831 | 2722 | for (line = 0; line < 4; line++) |
| 2832 | 2723 | { |
| 2833 | | ui_draw_text_full(&machine.render().ui_container(), &tempbuf[line][0], 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, |
| 2724 | ui_draw_text_full(container, &tempbuf[line][0], 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, |
| 2834 | 2725 | DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, NULL); |
| 2835 | 2726 | width += 2 * UI_BOX_LR_BORDER; |
| 2836 | 2727 | maxwidth = MAX(maxwidth, width); |
| r13553 | r13554 | |
| 2850 | 2741 | color = UI_YELLOW_COLOR; |
| 2851 | 2742 | if (driver != NULL && (driver->flags & (GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION)) != 0) |
| 2852 | 2743 | color = UI_RED_COLOR; |
| 2853 | | ui_draw_outlined_box(&machine.render().ui_container(), x1, y1, x2, y2, color); |
| 2744 | ui_draw_outlined_box(container, x1, y1, x2, y2, color); |
| 2854 | 2745 | |
| 2855 | 2746 | /* take off the borders */ |
| 2856 | 2747 | x1 += UI_BOX_LR_BORDER; |
| r13553 | r13554 | |
| 2861 | 2752 | /* draw all lines */ |
| 2862 | 2753 | for (line = 0; line < 4; line++) |
| 2863 | 2754 | { |
| 2864 | | ui_draw_text_full(&machine.render().ui_container(), &tempbuf[line][0], x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, |
| 2755 | ui_draw_text_full(container, &tempbuf[line][0], x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, |
| 2865 | 2756 | DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL); |
| 2866 | | y1 += ui_get_line_height(machine); |
| 2757 | y1 += ui_get_line_height(machine()); |
| 2867 | 2758 | } |
| 2868 | 2759 | } |
| 2869 | 2760 | |