trunk/src/emu/ui/miscmenu.c
| r243017 | r243018 | |
| 9 | 9 | |
| 10 | 10 | *********************************************************************/ |
| 11 | 11 | |
| 12 | | #include <ctype.h> |
| 13 | | |
| 14 | 12 | #include "emu.h" |
| 15 | | #include "emuopts.h" |
| 16 | | |
| 17 | | #include "cheat.h" |
| 18 | 13 | #include "osdnet.h" |
| 19 | | #include "rendutil.h" |
| 20 | 14 | |
| 21 | 15 | #include "uiinput.h" |
| 16 | #include "ui/ui.h" |
| 22 | 17 | #include "ui/miscmenu.h" |
| 23 | 18 | #include "ui/filemngr.h" |
| 24 | 19 | |
| 25 | | #include "osdepend.h" |
| 26 | 20 | |
| 27 | | /*------------------------------------------------- |
| 28 | | ui_slider_ui_handler - pushes the slider |
| 29 | | menu on the stack and hands off to the |
| 30 | | standard menu handler |
| 31 | | -------------------------------------------------*/ |
| 32 | | |
| 33 | | UINT32 ui_menu_sliders::ui_handler(running_machine &machine, render_container *container, UINT32 state) |
| 34 | | { |
| 35 | | UINT32 result; |
| 36 | | |
| 37 | | /* if this is the first call, push the sliders menu */ |
| 38 | | if (state) |
| 39 | | ui_menu::stack_push(auto_alloc_clear(machine, ui_menu_sliders(machine, container, true))); |
| 40 | | |
| 41 | | /* handle standard menus */ |
| 42 | | result = ui_menu::ui_handler(machine, container, state); |
| 43 | | |
| 44 | | /* if we are cancelled, pop the sliders menu */ |
| 45 | | if (result == UI_HANDLER_CANCEL) |
| 46 | | ui_menu::stack_pop(machine); |
| 47 | | |
| 48 | | ui_menu_sliders *uim = dynamic_cast<ui_menu_sliders *>(menu_stack); |
| 49 | | return uim && uim->menuless_mode ? 0 : UI_HANDLER_CANCEL; |
| 50 | | } |
| 51 | | |
| 52 | | |
| 53 | 21 | /*************************************************************************** |
| 54 | 22 | MENU HANDLERS |
| 55 | 23 | ***************************************************************************/ |
| r243017 | r243018 | |
| 302 | 270 | item_append(tempstring, NULL, MENU_FLAG_MULTILINE, NULL); |
| 303 | 271 | } |
| 304 | 272 | |
| 305 | | |
| 306 | 273 | /*------------------------------------------------- |
| 307 | | menu_cheat - handle the cheat menu |
| 308 | | -------------------------------------------------*/ |
| 309 | | |
| 310 | | void ui_menu_cheat::handle() |
| 311 | | { |
| 312 | | /* process the menu */ |
| 313 | | const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT); |
| 314 | | |
| 315 | | /* handle events */ |
| 316 | | if (menu_event != NULL && menu_event->itemref != NULL) |
| 317 | | { |
| 318 | | bool changed = false; |
| 319 | | |
| 320 | | /* clear cheat comment on any movement or keypress */ |
| 321 | | popmessage(NULL); |
| 322 | | |
| 323 | | /* handle reset all + reset all cheats for reload all option */ |
| 324 | | if ((FPTR)menu_event->itemref < 3 && menu_event->iptkey == IPT_UI_SELECT) |
| 325 | | { |
| 326 | | for (cheat_entry *curcheat = machine().cheat().first(); curcheat != NULL; curcheat = curcheat->next()) |
| 327 | | if (curcheat->select_default_state()) |
| 328 | | changed = true; |
| 329 | | } |
| 330 | | |
| 331 | | |
| 332 | | /* handle individual cheats */ |
| 333 | | else if ((FPTR)menu_event->itemref > 2) |
| 334 | | { |
| 335 | | cheat_entry *curcheat = reinterpret_cast<cheat_entry *>(menu_event->itemref); |
| 336 | | const char *string; |
| 337 | | switch (menu_event->iptkey) |
| 338 | | { |
| 339 | | /* if selected, activate a oneshot */ |
| 340 | | case IPT_UI_SELECT: |
| 341 | | changed = curcheat->activate(); |
| 342 | | break; |
| 343 | | |
| 344 | | /* if cleared, reset to default value */ |
| 345 | | case IPT_UI_CLEAR: |
| 346 | | changed = curcheat->select_default_state(); |
| 347 | | break; |
| 348 | | |
| 349 | | /* left decrements */ |
| 350 | | case IPT_UI_LEFT: |
| 351 | | changed = curcheat->select_previous_state(); |
| 352 | | break; |
| 353 | | |
| 354 | | /* right increments */ |
| 355 | | case IPT_UI_RIGHT: |
| 356 | | changed = curcheat->select_next_state(); |
| 357 | | break; |
| 358 | | |
| 359 | | /* bring up display comment if one exists */ |
| 360 | | case IPT_UI_DISPLAY_COMMENT: |
| 361 | | case IPT_UI_UP: |
| 362 | | case IPT_UI_DOWN: |
| 363 | | string = curcheat->comment(); |
| 364 | | if (string != NULL && string[0] != 0) |
| 365 | | popmessage("Cheat Comment:\n%s", string); |
| 366 | | break; |
| 367 | | } |
| 368 | | } |
| 369 | | |
| 370 | | /* handle reload all */ |
| 371 | | if ((FPTR)menu_event->itemref == 2 && menu_event->iptkey == IPT_UI_SELECT) |
| 372 | | { |
| 373 | | /* re-init cheat engine and thus reload cheats/cheats have already been turned off by here */ |
| 374 | | machine().cheat().reload(); |
| 375 | | |
| 376 | | /* display the reloaded cheats */ |
| 377 | | reset(UI_MENU_RESET_REMEMBER_REF); |
| 378 | | popmessage("All cheats reloaded"); |
| 379 | | } |
| 380 | | |
| 381 | | /* if things changed, update */ |
| 382 | | if (changed) |
| 383 | | reset(UI_MENU_RESET_REMEMBER_REF); |
| 384 | | } |
| 385 | | } |
| 386 | | |
| 387 | | |
| 388 | | /*------------------------------------------------- |
| 389 | | menu_cheat_populate - populate the cheat menu |
| 390 | | -------------------------------------------------*/ |
| 391 | | |
| 392 | | ui_menu_cheat::ui_menu_cheat(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 393 | | { |
| 394 | | } |
| 395 | | |
| 396 | | void ui_menu_cheat::populate() |
| 397 | | { |
| 398 | | /* iterate over cheats */ |
| 399 | | astring text; |
| 400 | | astring subtext; |
| 401 | | for (cheat_entry *curcheat = machine().cheat().first(); curcheat != NULL; curcheat = curcheat->next()) |
| 402 | | { |
| 403 | | UINT32 flags; |
| 404 | | curcheat->menu_text(text, subtext, flags); |
| 405 | | item_append(text, subtext, flags, curcheat); |
| 406 | | } |
| 407 | | |
| 408 | | /* add a separator */ |
| 409 | | item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 410 | | |
| 411 | | /* add a reset all option */ |
| 412 | | item_append("Reset All", NULL, 0, (void *)1); |
| 413 | | |
| 414 | | /* add a reload all cheats option */ |
| 415 | | item_append("Reload All", NULL, 0, (void *)2); |
| 416 | | } |
| 417 | | |
| 418 | | ui_menu_cheat::~ui_menu_cheat() |
| 419 | | { |
| 420 | | } |
| 421 | | |
| 422 | | /*------------------------------------------------- |
| 423 | | menu_sliders - handle the sliders menu |
| 424 | | -------------------------------------------------*/ |
| 425 | | |
| 426 | | void ui_menu_sliders::handle() |
| 427 | | { |
| 428 | | const ui_menu_event *menu_event; |
| 429 | | |
| 430 | | /* process the menu */ |
| 431 | | menu_event = process(UI_MENU_PROCESS_LR_REPEAT | (hidden ? UI_MENU_PROCESS_CUSTOM_ONLY : 0)); |
| 432 | | if (menu_event != NULL) |
| 433 | | { |
| 434 | | /* handle keys if there is a valid item selected */ |
| 435 | | if (menu_event->itemref != NULL) |
| 436 | | { |
| 437 | | const slider_state *slider = (const slider_state *)menu_event->itemref; |
| 438 | | INT32 curvalue = (*slider->update)(machine(), slider->arg, NULL, SLIDER_NOCHANGE); |
| 439 | | INT32 increment = 0; |
| 440 | | |
| 441 | | switch (menu_event->iptkey) |
| 442 | | { |
| 443 | | /* toggle visibility */ |
| 444 | | case IPT_UI_ON_SCREEN_DISPLAY: |
| 445 | | if (menuless_mode) |
| 446 | | ui_menu::stack_pop(machine()); |
| 447 | | else |
| 448 | | hidden = !hidden; |
| 449 | | break; |
| 450 | | |
| 451 | | /* decrease value */ |
| 452 | | case IPT_UI_LEFT: |
| 453 | | if (machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT)) |
| 454 | | increment = -1; |
| 455 | | else if (machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT)) |
| 456 | | increment = (slider->incval > 10) ? -(slider->incval / 10) : -1; |
| 457 | | else if (machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL)) |
| 458 | | increment = -slider->incval * 10; |
| 459 | | else |
| 460 | | increment = -slider->incval; |
| 461 | | break; |
| 462 | | |
| 463 | | /* increase value */ |
| 464 | | case IPT_UI_RIGHT: |
| 465 | | if (machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT)) |
| 466 | | increment = 1; |
| 467 | | else if (machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT)) |
| 468 | | increment = (slider->incval > 10) ? (slider->incval / 10) : 1; |
| 469 | | else if (machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL)) |
| 470 | | increment = slider->incval * 10; |
| 471 | | else |
| 472 | | increment = slider->incval; |
| 473 | | break; |
| 474 | | |
| 475 | | /* restore default */ |
| 476 | | case IPT_UI_SELECT: |
| 477 | | increment = slider->defval - curvalue; |
| 478 | | break; |
| 479 | | } |
| 480 | | |
| 481 | | /* handle any changes */ |
| 482 | | if (increment != 0) |
| 483 | | { |
| 484 | | INT32 newvalue = curvalue + increment; |
| 485 | | |
| 486 | | /* clamp within bounds */ |
| 487 | | if (newvalue < slider->minval) |
| 488 | | newvalue = slider->minval; |
| 489 | | if (newvalue > slider->maxval) |
| 490 | | newvalue = slider->maxval; |
| 491 | | |
| 492 | | /* update the slider and recompute the menu */ |
| 493 | | (*slider->update)(machine(), slider->arg, NULL, newvalue); |
| 494 | | reset(UI_MENU_RESET_REMEMBER_REF); |
| 495 | | } |
| 496 | | } |
| 497 | | |
| 498 | | /* if we are selecting an invalid item and we are hidden, skip to the next one */ |
| 499 | | else if (hidden) |
| 500 | | { |
| 501 | | /* if we got here via up or page up, select the previous item */ |
| 502 | | if (menu_event->iptkey == IPT_UI_UP || menu_event->iptkey == IPT_UI_PAGE_UP) |
| 503 | | { |
| 504 | | selected = (selected + numitems - 1) % numitems; |
| 505 | | validate_selection(-1); |
| 506 | | } |
| 507 | | |
| 508 | | /* otherwise select the next item */ |
| 509 | | else if (menu_event->iptkey == IPT_UI_DOWN || menu_event->iptkey == IPT_UI_PAGE_DOWN) |
| 510 | | { |
| 511 | | selected = (selected + 1) % numitems; |
| 512 | | validate_selection(1); |
| 513 | | } |
| 514 | | } |
| 515 | | } |
| 516 | | } |
| 517 | | |
| 518 | | |
| 519 | | /*------------------------------------------------- |
| 520 | | menu_sliders_populate - populate the sliders |
| 521 | | menu |
| 522 | | -------------------------------------------------*/ |
| 523 | | |
| 524 | | ui_menu_sliders::ui_menu_sliders(running_machine &machine, render_container *container, bool _menuless_mode) : ui_menu(machine, container) |
| 525 | | { |
| 526 | | menuless_mode = hidden = _menuless_mode; |
| 527 | | } |
| 528 | | |
| 529 | | void ui_menu_sliders::populate() |
| 530 | | { |
| 531 | | const slider_state *curslider; |
| 532 | | astring tempstring; |
| 533 | | |
| 534 | | /* add all sliders */ |
| 535 | | for (curslider = machine().ui().get_slider_list(); curslider != NULL; curslider = curslider->next) |
| 536 | | { |
| 537 | | INT32 curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE); |
| 538 | | UINT32 flags = 0; |
| 539 | | if (curval > curslider->minval) |
| 540 | | flags |= MENU_FLAG_LEFT_ARROW; |
| 541 | | if (curval < curslider->maxval) |
| 542 | | flags |= MENU_FLAG_RIGHT_ARROW; |
| 543 | | item_append(curslider->description, tempstring, flags, (void *)curslider); |
| 544 | | |
| 545 | | if (menuless_mode) |
| 546 | | break; |
| 547 | | } |
| 548 | | |
| 549 | | /* add all sliders */ |
| 550 | | for (curslider = (slider_state*)machine().osd().get_slider_list(); curslider != NULL; curslider = curslider->next) |
| 551 | | { |
| 552 | | INT32 curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE); |
| 553 | | UINT32 flags = 0; |
| 554 | | if (curval > curslider->minval) |
| 555 | | flags |= MENU_FLAG_LEFT_ARROW; |
| 556 | | if (curval < curslider->maxval) |
| 557 | | flags |= MENU_FLAG_RIGHT_ARROW; |
| 558 | | item_append(curslider->description, tempstring, flags, (void *)curslider); |
| 559 | | } |
| 560 | | |
| 561 | | custombottom = 2.0f * machine().ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER; |
| 562 | | } |
| 563 | | |
| 564 | | ui_menu_sliders::~ui_menu_sliders() |
| 565 | | { |
| 566 | | } |
| 567 | | |
| 568 | | /*------------------------------------------------- |
| 569 | | menu_sliders_custom_render - perform our special |
| 570 | | rendering |
| 571 | | -------------------------------------------------*/ |
| 572 | | |
| 573 | | void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) |
| 574 | | { |
| 575 | | const slider_state *curslider = (const slider_state *)selectedref; |
| 576 | | if (curslider != NULL) |
| 577 | | { |
| 578 | | float bar_left, bar_area_top, bar_width, bar_area_height, bar_top, bar_bottom, default_x, current_x; |
| 579 | | float line_height = machine().ui().get_line_height(); |
| 580 | | float percentage, default_percentage; |
| 581 | | astring tempstring; |
| 582 | | float text_height; |
| 583 | | INT32 curval; |
| 584 | | |
| 585 | | /* determine the current value and text */ |
| 586 | | curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE); |
| 587 | | |
| 588 | | /* compute the current and default percentages */ |
| 589 | | percentage = (float)(curval - curslider->minval) / (float)(curslider->maxval - curslider->minval); |
| 590 | | default_percentage = (float)(curslider->defval - curslider->minval) / (float)(curslider->maxval - curslider->minval); |
| 591 | | |
| 592 | | /* assemble the text */ |
| 593 | | tempstring.ins(0, " ").ins(0, curslider->description); |
| 594 | | |
| 595 | | /* move us to the bottom of the screen, and expand to full width */ |
| 596 | | y2 = 1.0f - UI_BOX_TB_BORDER; |
| 597 | | y1 = y2 - bottom; |
| 598 | | x1 = UI_BOX_LR_BORDER; |
| 599 | | x2 = 1.0f - UI_BOX_LR_BORDER; |
| 600 | | |
| 601 | | /* draw extra menu area */ |
| 602 | | machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR); |
| 603 | | y1 += UI_BOX_TB_BORDER; |
| 604 | | |
| 605 | | /* determine the text height */ |
| 606 | | machine().ui().draw_text_full(container, tempstring, 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, |
| 607 | | JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, NULL, &text_height); |
| 608 | | |
| 609 | | /* draw the thermometer */ |
| 610 | | bar_left = x1 + UI_BOX_LR_BORDER; |
| 611 | | bar_area_top = y1; |
| 612 | | bar_width = x2 - x1 - 2.0f * UI_BOX_LR_BORDER; |
| 613 | | bar_area_height = line_height; |
| 614 | | |
| 615 | | /* compute positions */ |
| 616 | | bar_top = bar_area_top + 0.125f * bar_area_height; |
| 617 | | bar_bottom = bar_area_top + 0.875f * bar_area_height; |
| 618 | | default_x = bar_left + bar_width * default_percentage; |
| 619 | | current_x = bar_left + bar_width * percentage; |
| 620 | | |
| 621 | | /* fill in the percentage */ |
| 622 | | container->add_rect(bar_left, bar_top, current_x, bar_bottom, UI_SLIDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 623 | | |
| 624 | | /* draw the top and bottom lines */ |
| 625 | | container->add_line(bar_left, bar_top, bar_left + bar_width, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 626 | | container->add_line(bar_left, bar_bottom, bar_left + bar_width, bar_bottom, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 627 | | |
| 628 | | /* draw default marker */ |
| 629 | | container->add_line(default_x, bar_area_top, default_x, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 630 | | 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)); |
| 631 | | |
| 632 | | /* draw the actual text */ |
| 633 | | machine().ui().draw_text_full(container, tempstring, x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, |
| 634 | | JUSTIFY_CENTER, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, &text_height); |
| 635 | | } |
| 636 | | } |
| 637 | | |
| 638 | | |
| 639 | | /*------------------------------------------------- |
| 640 | | menu_video_targets - handle the video targets |
| 641 | | menu |
| 642 | | -------------------------------------------------*/ |
| 643 | | |
| 644 | | void ui_menu_video_targets::handle() |
| 645 | | { |
| 646 | | /* process the menu */ |
| 647 | | const ui_menu_event *menu_event = process(0); |
| 648 | | if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) |
| 649 | | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_video_options(machine(), container, static_cast<render_target *>(menu_event->itemref)))); |
| 650 | | } |
| 651 | | |
| 652 | | |
| 653 | | /*------------------------------------------------- |
| 654 | | menu_video_targets_populate - populate the |
| 655 | | video targets menu |
| 656 | | -------------------------------------------------*/ |
| 657 | | |
| 658 | | ui_menu_video_targets::ui_menu_video_targets(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 659 | | { |
| 660 | | } |
| 661 | | |
| 662 | | void ui_menu_video_targets::populate() |
| 663 | | { |
| 664 | | int targetnum; |
| 665 | | |
| 666 | | /* find the targets */ |
| 667 | | for (targetnum = 0; ; targetnum++) |
| 668 | | { |
| 669 | | render_target *target = machine().render().target_by_index(targetnum); |
| 670 | | char buffer[40]; |
| 671 | | |
| 672 | | /* stop when we run out */ |
| 673 | | if (target == NULL) |
| 674 | | break; |
| 675 | | |
| 676 | | /* add a menu item */ |
| 677 | | sprintf(buffer, "Screen #%d", targetnum); |
| 678 | | item_append(buffer, NULL, 0, target); |
| 679 | | } |
| 680 | | } |
| 681 | | |
| 682 | | ui_menu_video_targets::~ui_menu_video_targets() |
| 683 | | { |
| 684 | | } |
| 685 | | |
| 686 | | /*------------------------------------------------- |
| 687 | | menu_video_options - handle the video options |
| 688 | | menu |
| 689 | | -------------------------------------------------*/ |
| 690 | | |
| 691 | | void ui_menu_video_options::handle() |
| 692 | | { |
| 693 | | bool changed = false; |
| 694 | | |
| 695 | | /* process the menu */ |
| 696 | | const ui_menu_event *menu_event = process(0); |
| 697 | | if (menu_event != NULL && menu_event->itemref != NULL) |
| 698 | | { |
| 699 | | switch ((FPTR)menu_event->itemref) |
| 700 | | { |
| 701 | | /* rotate adds rotation depending on the direction */ |
| 702 | | case VIDEO_ITEM_ROTATE: |
| 703 | | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 704 | | { |
| 705 | | int delta = (menu_event->iptkey == IPT_UI_LEFT) ? ROT270 : ROT90; |
| 706 | | target->set_orientation(orientation_add(delta, target->orientation())); |
| 707 | | if (target->is_ui_target()) |
| 708 | | { |
| 709 | | render_container::user_settings settings; |
| 710 | | container->get_user_settings(settings); |
| 711 | | settings.m_orientation = orientation_add(delta ^ ROT180, settings.m_orientation); |
| 712 | | container->set_user_settings(settings); |
| 713 | | } |
| 714 | | changed = true; |
| 715 | | } |
| 716 | | break; |
| 717 | | |
| 718 | | /* layer config bitmasks handle left/right keys the same (toggle) */ |
| 719 | | case VIDEO_ITEM_BACKDROPS: |
| 720 | | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 721 | | { |
| 722 | | target->set_backdrops_enabled(!target->backdrops_enabled()); |
| 723 | | changed = true; |
| 724 | | } |
| 725 | | break; |
| 726 | | |
| 727 | | case VIDEO_ITEM_OVERLAYS: |
| 728 | | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 729 | | { |
| 730 | | target->set_overlays_enabled(!target->overlays_enabled()); |
| 731 | | changed = true; |
| 732 | | } |
| 733 | | break; |
| 734 | | |
| 735 | | case VIDEO_ITEM_BEZELS: |
| 736 | | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 737 | | { |
| 738 | | target->set_bezels_enabled(!target->bezels_enabled()); |
| 739 | | changed = true; |
| 740 | | } |
| 741 | | break; |
| 742 | | |
| 743 | | case VIDEO_ITEM_CPANELS: |
| 744 | | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 745 | | { |
| 746 | | target->set_cpanels_enabled(!target->cpanels_enabled()); |
| 747 | | changed = true; |
| 748 | | } |
| 749 | | break; |
| 750 | | |
| 751 | | case VIDEO_ITEM_MARQUEES: |
| 752 | | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 753 | | { |
| 754 | | target->set_marquees_enabled(!target->marquees_enabled()); |
| 755 | | changed = true; |
| 756 | | } |
| 757 | | break; |
| 758 | | |
| 759 | | case VIDEO_ITEM_ZOOM: |
| 760 | | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 761 | | { |
| 762 | | target->set_zoom_to_screen(!target->zoom_to_screen()); |
| 763 | | changed = true; |
| 764 | | } |
| 765 | | break; |
| 766 | | |
| 767 | | /* anything else is a view item */ |
| 768 | | default: |
| 769 | | if (menu_event->iptkey == IPT_UI_SELECT && (int)(FPTR)menu_event->itemref >= VIDEO_ITEM_VIEW) |
| 770 | | { |
| 771 | | target->set_view((FPTR)menu_event->itemref - VIDEO_ITEM_VIEW); |
| 772 | | changed = true; |
| 773 | | } |
| 774 | | break; |
| 775 | | } |
| 776 | | } |
| 777 | | |
| 778 | | /* if something changed, rebuild the menu */ |
| 779 | | if (changed) |
| 780 | | reset(UI_MENU_RESET_REMEMBER_REF); |
| 781 | | } |
| 782 | | |
| 783 | | |
| 784 | | /*------------------------------------------------- |
| 785 | | menu_video_options_populate - populate the |
| 786 | | video options menu |
| 787 | | -------------------------------------------------*/ |
| 788 | | |
| 789 | | ui_menu_video_options::ui_menu_video_options(running_machine &machine, render_container *container, render_target *_target) : ui_menu(machine, container) |
| 790 | | { |
| 791 | | target = _target; |
| 792 | | } |
| 793 | | |
| 794 | | void ui_menu_video_options::populate() |
| 795 | | { |
| 796 | | const char *subtext = ""; |
| 797 | | astring tempstring; |
| 798 | | int viewnum; |
| 799 | | int enabled; |
| 800 | | |
| 801 | | /* add items for each view */ |
| 802 | | for (viewnum = 0; ; viewnum++) |
| 803 | | { |
| 804 | | const char *name = target->view_name(viewnum); |
| 805 | | if (name == NULL) |
| 806 | | break; |
| 807 | | |
| 808 | | /* create a string for the item, replacing underscores with spaces */ |
| 809 | | tempstring.cpy(name).replace(0, "_", " "); |
| 810 | | item_append(tempstring, NULL, 0, (void *)(FPTR)(VIDEO_ITEM_VIEW + viewnum)); |
| 811 | | } |
| 812 | | |
| 813 | | /* add a separator */ |
| 814 | | item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 815 | | |
| 816 | | /* add a rotate item */ |
| 817 | | switch (target->orientation()) |
| 818 | | { |
| 819 | | case ROT0: subtext = "None"; break; |
| 820 | | case ROT90: subtext = "CW 90" UTF8_DEGREES; break; |
| 821 | | case ROT180: subtext = "180" UTF8_DEGREES; break; |
| 822 | | case ROT270: subtext = "CCW 90" UTF8_DEGREES; break; |
| 823 | | } |
| 824 | | item_append("Rotate", subtext, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_ROTATE); |
| 825 | | |
| 826 | | /* backdrop item */ |
| 827 | | enabled = target->backdrops_enabled(); |
| 828 | | item_append("Backdrops", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BACKDROPS); |
| 829 | | |
| 830 | | /* overlay item */ |
| 831 | | enabled = target->overlays_enabled(); |
| 832 | | item_append("Overlays", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_OVERLAYS); |
| 833 | | |
| 834 | | /* bezel item */ |
| 835 | | enabled = target->bezels_enabled(); |
| 836 | | item_append("Bezels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BEZELS); |
| 837 | | |
| 838 | | /* cpanel item */ |
| 839 | | enabled = target->cpanels_enabled(); |
| 840 | | item_append("CPanels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_CPANELS); |
| 841 | | |
| 842 | | /* marquee item */ |
| 843 | | enabled = target->marquees_enabled(); |
| 844 | | item_append("Marquees", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_MARQUEES); |
| 845 | | |
| 846 | | /* cropping */ |
| 847 | | enabled = target->zoom_to_screen(); |
| 848 | | item_append("View", enabled ? "Cropped" : "Full", enabled ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)VIDEO_ITEM_ZOOM); |
| 849 | | } |
| 850 | | |
| 851 | | ui_menu_video_options::~ui_menu_video_options() |
| 852 | | { |
| 853 | | } |
| 854 | | |
| 855 | | /*------------------------------------------------- |
| 856 | 274 | menu_crosshair - handle the crosshair settings |
| 857 | 275 | menu |
| 858 | 276 | -------------------------------------------------*/ |
trunk/src/emu/ui/sliders.c
| r0 | r243018 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | miscmenu.c |
| 4 | |
| 5 | Internal MAME menus for the user interface. |
| 6 | |
| 7 | Copyright Nicola Salmoria and the MAME Team. |
| 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | |
| 10 | *********************************************************************/ |
| 11 | |
| 12 | #include "emu.h" |
| 13 | |
| 14 | #include "osdepend.h" |
| 15 | #include "uiinput.h" |
| 16 | #include "ui/ui.h" |
| 17 | #include "ui/sliders.h" |
| 18 | |
| 19 | |
| 20 | ui_menu_sliders::ui_menu_sliders(running_machine &machine, render_container *container, bool _menuless_mode) : ui_menu(machine, container) |
| 21 | { |
| 22 | menuless_mode = hidden = _menuless_mode; |
| 23 | } |
| 24 | |
| 25 | ui_menu_sliders::~ui_menu_sliders() |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | /*------------------------------------------------- |
| 30 | menu_sliders - handle the sliders menu |
| 31 | -------------------------------------------------*/ |
| 32 | |
| 33 | void ui_menu_sliders::handle() |
| 34 | { |
| 35 | const ui_menu_event *menu_event; |
| 36 | |
| 37 | /* process the menu */ |
| 38 | menu_event = process(UI_MENU_PROCESS_LR_REPEAT | (hidden ? UI_MENU_PROCESS_CUSTOM_ONLY : 0)); |
| 39 | if (menu_event != NULL) |
| 40 | { |
| 41 | /* handle keys if there is a valid item selected */ |
| 42 | if (menu_event->itemref != NULL) |
| 43 | { |
| 44 | const slider_state *slider = (const slider_state *)menu_event->itemref; |
| 45 | INT32 curvalue = (*slider->update)(machine(), slider->arg, NULL, SLIDER_NOCHANGE); |
| 46 | INT32 increment = 0; |
| 47 | |
| 48 | switch (menu_event->iptkey) |
| 49 | { |
| 50 | /* toggle visibility */ |
| 51 | case IPT_UI_ON_SCREEN_DISPLAY: |
| 52 | if (menuless_mode) |
| 53 | ui_menu::stack_pop(machine()); |
| 54 | else |
| 55 | hidden = !hidden; |
| 56 | break; |
| 57 | |
| 58 | /* decrease value */ |
| 59 | case IPT_UI_LEFT: |
| 60 | if (machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT)) |
| 61 | increment = -1; |
| 62 | else if (machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT)) |
| 63 | increment = (slider->incval > 10) ? -(slider->incval / 10) : -1; |
| 64 | else if (machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL)) |
| 65 | increment = -slider->incval * 10; |
| 66 | else |
| 67 | increment = -slider->incval; |
| 68 | break; |
| 69 | |
| 70 | /* increase value */ |
| 71 | case IPT_UI_RIGHT: |
| 72 | if (machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT)) |
| 73 | increment = 1; |
| 74 | else if (machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT)) |
| 75 | increment = (slider->incval > 10) ? (slider->incval / 10) : 1; |
| 76 | else if (machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL)) |
| 77 | increment = slider->incval * 10; |
| 78 | else |
| 79 | increment = slider->incval; |
| 80 | break; |
| 81 | |
| 82 | /* restore default */ |
| 83 | case IPT_UI_SELECT: |
| 84 | increment = slider->defval - curvalue; |
| 85 | break; |
| 86 | } |
| 87 | |
| 88 | /* handle any changes */ |
| 89 | if (increment != 0) |
| 90 | { |
| 91 | INT32 newvalue = curvalue + increment; |
| 92 | |
| 93 | /* clamp within bounds */ |
| 94 | if (newvalue < slider->minval) |
| 95 | newvalue = slider->minval; |
| 96 | if (newvalue > slider->maxval) |
| 97 | newvalue = slider->maxval; |
| 98 | |
| 99 | /* update the slider and recompute the menu */ |
| 100 | (*slider->update)(machine(), slider->arg, NULL, newvalue); |
| 101 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | /* if we are selecting an invalid item and we are hidden, skip to the next one */ |
| 106 | else if (hidden) |
| 107 | { |
| 108 | /* if we got here via up or page up, select the previous item */ |
| 109 | if (menu_event->iptkey == IPT_UI_UP || menu_event->iptkey == IPT_UI_PAGE_UP) |
| 110 | { |
| 111 | selected = (selected + numitems - 1) % numitems; |
| 112 | validate_selection(-1); |
| 113 | } |
| 114 | |
| 115 | /* otherwise select the next item */ |
| 116 | else if (menu_event->iptkey == IPT_UI_DOWN || menu_event->iptkey == IPT_UI_PAGE_DOWN) |
| 117 | { |
| 118 | selected = (selected + 1) % numitems; |
| 119 | validate_selection(1); |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | |
| 126 | /*------------------------------------------------- |
| 127 | menu_sliders_populate - populate the sliders |
| 128 | menu |
| 129 | -------------------------------------------------*/ |
| 130 | |
| 131 | void ui_menu_sliders::populate() |
| 132 | { |
| 133 | const slider_state *curslider; |
| 134 | astring tempstring; |
| 135 | |
| 136 | /* add all sliders */ |
| 137 | for (curslider = machine().ui().get_slider_list(); curslider != NULL; curslider = curslider->next) |
| 138 | { |
| 139 | INT32 curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE); |
| 140 | UINT32 flags = 0; |
| 141 | if (curval > curslider->minval) |
| 142 | flags |= MENU_FLAG_LEFT_ARROW; |
| 143 | if (curval < curslider->maxval) |
| 144 | flags |= MENU_FLAG_RIGHT_ARROW; |
| 145 | item_append(curslider->description, tempstring, flags, (void *)curslider); |
| 146 | |
| 147 | if (menuless_mode) |
| 148 | break; |
| 149 | } |
| 150 | |
| 151 | /* add all sliders */ |
| 152 | for (curslider = (slider_state*)machine().osd().get_slider_list(); curslider != NULL; curslider = curslider->next) |
| 153 | { |
| 154 | INT32 curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE); |
| 155 | UINT32 flags = 0; |
| 156 | if (curval > curslider->minval) |
| 157 | flags |= MENU_FLAG_LEFT_ARROW; |
| 158 | if (curval < curslider->maxval) |
| 159 | flags |= MENU_FLAG_RIGHT_ARROW; |
| 160 | item_append(curslider->description, tempstring, flags, (void *)curslider); |
| 161 | } |
| 162 | |
| 163 | custombottom = 2.0f * machine().ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER; |
| 164 | } |
| 165 | |
| 166 | /*------------------------------------------------- |
| 167 | menu_sliders_custom_render - perform our special |
| 168 | rendering |
| 169 | -------------------------------------------------*/ |
| 170 | |
| 171 | void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) |
| 172 | { |
| 173 | const slider_state *curslider = (const slider_state *)selectedref; |
| 174 | if (curslider != NULL) |
| 175 | { |
| 176 | float bar_left, bar_area_top, bar_width, bar_area_height, bar_top, bar_bottom, default_x, current_x; |
| 177 | float line_height = machine().ui().get_line_height(); |
| 178 | float percentage, default_percentage; |
| 179 | astring tempstring; |
| 180 | float text_height; |
| 181 | INT32 curval; |
| 182 | |
| 183 | /* determine the current value and text */ |
| 184 | curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE); |
| 185 | |
| 186 | /* compute the current and default percentages */ |
| 187 | percentage = (float)(curval - curslider->minval) / (float)(curslider->maxval - curslider->minval); |
| 188 | default_percentage = (float)(curslider->defval - curslider->minval) / (float)(curslider->maxval - curslider->minval); |
| 189 | |
| 190 | /* assemble the text */ |
| 191 | tempstring.ins(0, " ").ins(0, curslider->description); |
| 192 | |
| 193 | /* move us to the bottom of the screen, and expand to full width */ |
| 194 | y2 = 1.0f - UI_BOX_TB_BORDER; |
| 195 | y1 = y2 - bottom; |
| 196 | x1 = UI_BOX_LR_BORDER; |
| 197 | x2 = 1.0f - UI_BOX_LR_BORDER; |
| 198 | |
| 199 | /* draw extra menu area */ |
| 200 | machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR); |
| 201 | y1 += UI_BOX_TB_BORDER; |
| 202 | |
| 203 | /* determine the text height */ |
| 204 | machine().ui().draw_text_full(container, tempstring, 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, |
| 205 | JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, NULL, &text_height); |
| 206 | |
| 207 | /* draw the thermometer */ |
| 208 | bar_left = x1 + UI_BOX_LR_BORDER; |
| 209 | bar_area_top = y1; |
| 210 | bar_width = x2 - x1 - 2.0f * UI_BOX_LR_BORDER; |
| 211 | bar_area_height = line_height; |
| 212 | |
| 213 | /* compute positions */ |
| 214 | bar_top = bar_area_top + 0.125f * bar_area_height; |
| 215 | bar_bottom = bar_area_top + 0.875f * bar_area_height; |
| 216 | default_x = bar_left + bar_width * default_percentage; |
| 217 | current_x = bar_left + bar_width * percentage; |
| 218 | |
| 219 | /* fill in the percentage */ |
| 220 | container->add_rect(bar_left, bar_top, current_x, bar_bottom, UI_SLIDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 221 | |
| 222 | /* draw the top and bottom lines */ |
| 223 | container->add_line(bar_left, bar_top, bar_left + bar_width, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 224 | container->add_line(bar_left, bar_bottom, bar_left + bar_width, bar_bottom, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 225 | |
| 226 | /* draw default marker */ |
| 227 | container->add_line(default_x, bar_area_top, default_x, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 228 | 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)); |
| 229 | |
| 230 | /* draw the actual text */ |
| 231 | machine().ui().draw_text_full(container, tempstring, x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER, |
| 232 | JUSTIFY_CENTER, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, &text_height); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | |
| 237 | /*------------------------------------------------- |
| 238 | ui_slider_ui_handler - pushes the slider |
| 239 | menu on the stack and hands off to the |
| 240 | standard menu handler |
| 241 | -------------------------------------------------*/ |
| 242 | |
| 243 | UINT32 ui_menu_sliders::ui_handler(running_machine &machine, render_container *container, UINT32 state) |
| 244 | { |
| 245 | UINT32 result; |
| 246 | |
| 247 | /* if this is the first call, push the sliders menu */ |
| 248 | if (state) |
| 249 | ui_menu::stack_push(auto_alloc_clear(machine, ui_menu_sliders(machine, container, true))); |
| 250 | |
| 251 | /* handle standard menus */ |
| 252 | result = ui_menu::ui_handler(machine, container, state); |
| 253 | |
| 254 | /* if we are cancelled, pop the sliders menu */ |
| 255 | if (result == UI_HANDLER_CANCEL) |
| 256 | ui_menu::stack_pop(machine); |
| 257 | |
| 258 | ui_menu_sliders *uim = dynamic_cast<ui_menu_sliders *>(menu_stack); |
| 259 | return uim && uim->menuless_mode ? 0 : UI_HANDLER_CANCEL; |
| 260 | } |
trunk/src/emu/ui/videoopt.c
| r0 | r243018 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | ui/videoopt.c |
| 4 | |
| 5 | Internal menus for video options |
| 6 | |
| 7 | Copyright Nicola Salmoria and the MAME Team. |
| 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | |
| 10 | *********************************************************************/ |
| 11 | |
| 12 | #include "emu.h" |
| 13 | #include "rendutil.h" |
| 14 | |
| 15 | #include "uiinput.h" |
| 16 | #include "ui/ui.h" |
| 17 | #include "ui/videoopt.h" |
| 18 | |
| 19 | /*------------------------------------------------- |
| 20 | menu_video_targets - handle the video targets |
| 21 | menu |
| 22 | -------------------------------------------------*/ |
| 23 | |
| 24 | void ui_menu_video_targets::handle() |
| 25 | { |
| 26 | /* process the menu */ |
| 27 | const ui_menu_event *menu_event = process(0); |
| 28 | if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) |
| 29 | ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_video_options(machine(), container, static_cast<render_target *>(menu_event->itemref)))); |
| 30 | } |
| 31 | |
| 32 | |
| 33 | /*------------------------------------------------- |
| 34 | menu_video_targets_populate - populate the |
| 35 | video targets menu |
| 36 | -------------------------------------------------*/ |
| 37 | |
| 38 | ui_menu_video_targets::ui_menu_video_targets(running_machine &machine, render_container *container) : ui_menu(machine, container) |
| 39 | { |
| 40 | } |
| 41 | |
| 42 | void ui_menu_video_targets::populate() |
| 43 | { |
| 44 | int targetnum; |
| 45 | |
| 46 | /* find the targets */ |
| 47 | for (targetnum = 0; ; targetnum++) |
| 48 | { |
| 49 | render_target *target = machine().render().target_by_index(targetnum); |
| 50 | char buffer[40]; |
| 51 | |
| 52 | /* stop when we run out */ |
| 53 | if (target == NULL) |
| 54 | break; |
| 55 | |
| 56 | /* add a menu item */ |
| 57 | sprintf(buffer, "Screen #%d", targetnum); |
| 58 | item_append(buffer, NULL, 0, target); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | ui_menu_video_targets::~ui_menu_video_targets() |
| 63 | { |
| 64 | } |
| 65 | |
| 66 | /*------------------------------------------------- |
| 67 | menu_video_options - handle the video options |
| 68 | menu |
| 69 | -------------------------------------------------*/ |
| 70 | |
| 71 | void ui_menu_video_options::handle() |
| 72 | { |
| 73 | bool changed = false; |
| 74 | |
| 75 | /* process the menu */ |
| 76 | const ui_menu_event *menu_event = process(0); |
| 77 | if (menu_event != NULL && menu_event->itemref != NULL) |
| 78 | { |
| 79 | switch ((FPTR)menu_event->itemref) |
| 80 | { |
| 81 | /* rotate adds rotation depending on the direction */ |
| 82 | case VIDEO_ITEM_ROTATE: |
| 83 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 84 | { |
| 85 | int delta = (menu_event->iptkey == IPT_UI_LEFT) ? ROT270 : ROT90; |
| 86 | target->set_orientation(orientation_add(delta, target->orientation())); |
| 87 | if (target->is_ui_target()) |
| 88 | { |
| 89 | render_container::user_settings settings; |
| 90 | container->get_user_settings(settings); |
| 91 | settings.m_orientation = orientation_add(delta ^ ROT180, settings.m_orientation); |
| 92 | container->set_user_settings(settings); |
| 93 | } |
| 94 | changed = true; |
| 95 | } |
| 96 | break; |
| 97 | |
| 98 | /* layer config bitmasks handle left/right keys the same (toggle) */ |
| 99 | case VIDEO_ITEM_BACKDROPS: |
| 100 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 101 | { |
| 102 | target->set_backdrops_enabled(!target->backdrops_enabled()); |
| 103 | changed = true; |
| 104 | } |
| 105 | break; |
| 106 | |
| 107 | case VIDEO_ITEM_OVERLAYS: |
| 108 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 109 | { |
| 110 | target->set_overlays_enabled(!target->overlays_enabled()); |
| 111 | changed = true; |
| 112 | } |
| 113 | break; |
| 114 | |
| 115 | case VIDEO_ITEM_BEZELS: |
| 116 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 117 | { |
| 118 | target->set_bezels_enabled(!target->bezels_enabled()); |
| 119 | changed = true; |
| 120 | } |
| 121 | break; |
| 122 | |
| 123 | case VIDEO_ITEM_CPANELS: |
| 124 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 125 | { |
| 126 | target->set_cpanels_enabled(!target->cpanels_enabled()); |
| 127 | changed = true; |
| 128 | } |
| 129 | break; |
| 130 | |
| 131 | case VIDEO_ITEM_MARQUEES: |
| 132 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 133 | { |
| 134 | target->set_marquees_enabled(!target->marquees_enabled()); |
| 135 | changed = true; |
| 136 | } |
| 137 | break; |
| 138 | |
| 139 | case VIDEO_ITEM_ZOOM: |
| 140 | if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) |
| 141 | { |
| 142 | target->set_zoom_to_screen(!target->zoom_to_screen()); |
| 143 | changed = true; |
| 144 | } |
| 145 | break; |
| 146 | |
| 147 | /* anything else is a view item */ |
| 148 | default: |
| 149 | if (menu_event->iptkey == IPT_UI_SELECT && (int)(FPTR)menu_event->itemref >= VIDEO_ITEM_VIEW) |
| 150 | { |
| 151 | target->set_view((FPTR)menu_event->itemref - VIDEO_ITEM_VIEW); |
| 152 | changed = true; |
| 153 | } |
| 154 | break; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | /* if something changed, rebuild the menu */ |
| 159 | if (changed) |
| 160 | reset(UI_MENU_RESET_REMEMBER_REF); |
| 161 | } |
| 162 | |
| 163 | |
| 164 | /*------------------------------------------------- |
| 165 | menu_video_options_populate - populate the |
| 166 | video options menu |
| 167 | -------------------------------------------------*/ |
| 168 | |
| 169 | ui_menu_video_options::ui_menu_video_options(running_machine &machine, render_container *container, render_target *_target) : ui_menu(machine, container) |
| 170 | { |
| 171 | target = _target; |
| 172 | } |
| 173 | |
| 174 | void ui_menu_video_options::populate() |
| 175 | { |
| 176 | const char *subtext = ""; |
| 177 | astring tempstring; |
| 178 | int viewnum; |
| 179 | int enabled; |
| 180 | |
| 181 | /* add items for each view */ |
| 182 | for (viewnum = 0; ; viewnum++) |
| 183 | { |
| 184 | const char *name = target->view_name(viewnum); |
| 185 | if (name == NULL) |
| 186 | break; |
| 187 | |
| 188 | /* create a string for the item, replacing underscores with spaces */ |
| 189 | tempstring.cpy(name).replace(0, "_", " "); |
| 190 | item_append(tempstring, NULL, 0, (void *)(FPTR)(VIDEO_ITEM_VIEW + viewnum)); |
| 191 | } |
| 192 | |
| 193 | /* add a separator */ |
| 194 | item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 195 | |
| 196 | /* add a rotate item */ |
| 197 | switch (target->orientation()) |
| 198 | { |
| 199 | case ROT0: subtext = "None"; break; |
| 200 | case ROT90: subtext = "CW 90" UTF8_DEGREES; break; |
| 201 | case ROT180: subtext = "180" UTF8_DEGREES; break; |
| 202 | case ROT270: subtext = "CCW 90" UTF8_DEGREES; break; |
| 203 | } |
| 204 | item_append("Rotate", subtext, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_ROTATE); |
| 205 | |
| 206 | /* backdrop item */ |
| 207 | enabled = target->backdrops_enabled(); |
| 208 | item_append("Backdrops", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BACKDROPS); |
| 209 | |
| 210 | /* overlay item */ |
| 211 | enabled = target->overlays_enabled(); |
| 212 | item_append("Overlays", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_OVERLAYS); |
| 213 | |
| 214 | /* bezel item */ |
| 215 | enabled = target->bezels_enabled(); |
| 216 | item_append("Bezels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BEZELS); |
| 217 | |
| 218 | /* cpanel item */ |
| 219 | enabled = target->cpanels_enabled(); |
| 220 | item_append("CPanels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_CPANELS); |
| 221 | |
| 222 | /* marquee item */ |
| 223 | enabled = target->marquees_enabled(); |
| 224 | item_append("Marquees", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_MARQUEES); |
| 225 | |
| 226 | /* cropping */ |
| 227 | enabled = target->zoom_to_screen(); |
| 228 | item_append("View", enabled ? "Cropped" : "Full", enabled ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)VIDEO_ITEM_ZOOM); |
| 229 | } |
| 230 | |
| 231 | ui_menu_video_options::~ui_menu_video_options() |
| 232 | { |
| 233 | } |