Previous 199869 Revisions Next

r34506 Tuesday 20th January, 2015 at 09:31:02 UTC by Fabio Priuli
ui: split a few more menu entries from miscmenu.c to separate files,
so to avoid having too much assorted stuff in miscmenu.c (now it is
down to a reasonable size). nw.
[src/emu]emu.mak
[src/emu/ui]cheatopt.c* cheatopt.h* filemngr.c mainmenu.c mainmenu.h menu.c miscmenu.c miscmenu.h sliders.c* sliders.h* ui.c videoopt.c* videoopt.h*

trunk/src/emu/emu.mak
r243017r243018
120120   $(EMUOBJ)/ui/mainmenu.o \
121121   $(EMUOBJ)/ui/miscmenu.o \
122122   $(EMUOBJ)/ui/barcode.o \
123   $(EMUOBJ)/ui/cheatopt.o \
123124   $(EMUOBJ)/ui/devopt.o \
124125   $(EMUOBJ)/ui/filemngr.o \
125126   $(EMUOBJ)/ui/filesel.o \
r243017r243018
127128   $(EMUOBJ)/ui/info.o \
128129   $(EMUOBJ)/ui/inputmap.o \
129130   $(EMUOBJ)/ui/selgame.o \
131   $(EMUOBJ)/ui/sliders.o \
130132   $(EMUOBJ)/ui/slotopt.o \
131133   $(EMUOBJ)/ui/swlist.o \
132134   $(EMUOBJ)/ui/tapectrl.o \
135   $(EMUOBJ)/ui/videoopt.o \
133136   $(EMUOBJ)/ui/viewgfx.o \
134137   $(EMUOBJ)/validity.o \
135138   $(EMUOBJ)/video.o \
trunk/src/emu/ui/cheatopt.c
r0r243018
1/*********************************************************************
2
3    ui/cheatopt.c
4
5    Internal menu for the cheat 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#include "cheat.h"
14
15#include "uiinput.h"
16#include "ui/ui.h"
17#include "ui/cheatopt.h"
18
19/*-------------------------------------------------
20    menu_cheat - handle the cheat menu
21-------------------------------------------------*/
22
23void ui_menu_cheat::handle()
24{
25   /* process the menu */
26   const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT);
27
28   /* handle events */
29   if (menu_event != NULL && menu_event->itemref != NULL)
30   {
31      bool changed = false;
32
33      /* clear cheat comment on any movement or keypress */
34      popmessage(NULL);
35
36      /* handle reset all + reset all cheats for reload all option */
37      if ((FPTR)menu_event->itemref < 3 && menu_event->iptkey == IPT_UI_SELECT)
38      {
39         for (cheat_entry *curcheat = machine().cheat().first(); curcheat != NULL; curcheat = curcheat->next())
40            if (curcheat->select_default_state())
41               changed = true;
42      }
43
44
45      /* handle individual cheats */
46      else if ((FPTR)menu_event->itemref > 2)
47      {
48         cheat_entry *curcheat = reinterpret_cast<cheat_entry *>(menu_event->itemref);
49         const char *string;
50         switch (menu_event->iptkey)
51         {
52            /* if selected, activate a oneshot */
53            case IPT_UI_SELECT:
54               changed = curcheat->activate();
55               break;
56
57            /* if cleared, reset to default value */
58            case IPT_UI_CLEAR:
59               changed = curcheat->select_default_state();
60               break;
61
62            /* left decrements */
63            case IPT_UI_LEFT:
64               changed = curcheat->select_previous_state();
65               break;
66
67            /* right increments */
68            case IPT_UI_RIGHT:
69               changed = curcheat->select_next_state();
70               break;
71
72            /* bring up display comment if one exists */
73            case IPT_UI_DISPLAY_COMMENT:
74            case IPT_UI_UP:
75            case IPT_UI_DOWN:
76               string = curcheat->comment();
77               if (string != NULL && string[0] != 0)
78                  popmessage("Cheat Comment:\n%s", string);
79               break;
80         }
81      }
82
83      /* handle reload all  */
84      if ((FPTR)menu_event->itemref == 2 && menu_event->iptkey == IPT_UI_SELECT)
85      {
86         /* re-init cheat engine and thus reload cheats/cheats have already been turned off by here */
87         machine().cheat().reload();
88
89         /* display the reloaded cheats */
90         reset(UI_MENU_RESET_REMEMBER_REF);
91         popmessage("All cheats reloaded");
92      }
93
94      /* if things changed, update */
95      if (changed)
96         reset(UI_MENU_RESET_REMEMBER_REF);
97   }
98}
99
100
101/*-------------------------------------------------
102    menu_cheat_populate - populate the cheat menu
103-------------------------------------------------*/
104
105ui_menu_cheat::ui_menu_cheat(running_machine &machine, render_container *container) : ui_menu(machine, container)
106{
107}
108
109void ui_menu_cheat::populate()
110{
111   /* iterate over cheats */
112   astring text;
113   astring subtext;
114   for (cheat_entry *curcheat = machine().cheat().first(); curcheat != NULL; curcheat = curcheat->next())
115   {
116      UINT32 flags;
117      curcheat->menu_text(text, subtext, flags);
118      item_append(text, subtext, flags, curcheat);
119   }
120
121   /* add a separator */
122   item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
123
124   /* add a reset all option */
125   item_append("Reset All", NULL, 0, (void *)1);
126
127   /* add a reload all cheats option */
128   item_append("Reload All", NULL, 0, (void *)2);
129}
130
131ui_menu_cheat::~ui_menu_cheat()
132{
133}
trunk/src/emu/ui/cheatopt.h
r0r243018
1/***************************************************************************
2
3    ui/cheatopt.h
4
5    Internal menu for the cheat interface.
6
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10***************************************************************************/
11
12#pragma once
13
14#ifndef __UI_CHEATOPT_H__
15#define __UI_CHEATOPT_H__
16
17class ui_menu_cheat : public ui_menu {
18public:
19   ui_menu_cheat(running_machine &machine, render_container *container);
20   virtual ~ui_menu_cheat();
21   virtual void populate();
22   virtual void handle();
23};
24
25#endif  /* __UI_CHEATOPT_H__ */
trunk/src/emu/ui/filemngr.c
r243017r243018
66
77    TODO
88        - Restrict directory listing by file extension
9        - Support file manager invocation from the main menu for
10          required images
119
1210*********************************************************************/
1311
14#include <stdio.h>
15#include <ctype.h>
16#include <stdlib.h>
17
1812#include "emu.h"
1913#include "ui/ui.h"
2014#include "ui/swlist.h"
trunk/src/emu/ui/mainmenu.c
r243017r243018
1010*********************************************************************/
1111
1212#include "emu.h"
13#include "audit.h"
14#include "crsshair.h"
1315#include "osdnet.h"
1416#include "emuopts.h"
15#include "ui/ui.h"
1617#include "rendutil.h"
1718#include "cheat.h"
1819#include "uiinput.h"
20#include "ui/ui.h"
1921#include "ui/filemngr.h"
2022#include "ui/filesel.h"
2123#include "ui/barcode.h"
24#include "ui/cheatopt.h"
2225#include "ui/info.h"
2326#include "ui/inputmap.h"
2427#include "ui/mainmenu.h"
2528#include "ui/miscmenu.h"
2629#include "ui/selgame.h"
30#include "ui/sliders.h"
2731#include "ui/slotopt.h"
2832#include "ui/tapectrl.h"
29#include "audit.h"
30#include "crsshair.h"
31#include <ctype.h>
33#include "ui/videoopt.h"
3234#include "imagedev/cassette.h"
3335#include "imagedev/bitbngr.h"
3436#include "machine/bcreader.h"
trunk/src/emu/ui/mainmenu.h
r243017r243018
1414#ifndef __UI_MAINMENU_H__
1515#define __UI_MAINMENU_H__
1616
17#include "crsshair.h"
1817#include "drivenum.h"
1918
2019class ui_menu_main : public ui_menu {
trunk/src/emu/ui/menu.c
r243017r243018
1111
1212#include "emu.h"
1313#include "emuopts.h"
14#include "ui/ui.h"
1514#include "rendutil.h"
16#include "uiinput.h"
1715#include "cheat.h"
16#include "uiinput.h"
17#include "ui/ui.h"
1818#include "ui/mainmenu.h"
19#include "ui/miscmenu.h"
20#include <ctype.h>
19#include "ui/cheatopt.h"
2120
2221
2322
trunk/src/emu/ui/miscmenu.c
r243017r243018
99
1010*********************************************************************/
1111
12#include <ctype.h>
13
1412#include "emu.h"
15#include "emuopts.h"
16
17#include "cheat.h"
1813#include "osdnet.h"
19#include "rendutil.h"
2014
2115#include "uiinput.h"
16#include "ui/ui.h"
2217#include "ui/miscmenu.h"
2318#include "ui/filemngr.h"
2419
25#include "osdepend.h"
2620
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
33UINT32 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
5321/***************************************************************************
5422    MENU HANDLERS
5523***************************************************************************/
r243017r243018
302270   item_append(tempstring, NULL, MENU_FLAG_MULTILINE, NULL);
303271}
304272
305
306273/*-------------------------------------------------
307    menu_cheat - handle the cheat menu
308-------------------------------------------------*/
309
310void 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
392ui_menu_cheat::ui_menu_cheat(running_machine &machine, render_container *container) : ui_menu(machine, container)
393{
394}
395
396void 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
418ui_menu_cheat::~ui_menu_cheat()
419{
420}
421
422/*-------------------------------------------------
423    menu_sliders - handle the sliders menu
424-------------------------------------------------*/
425
426void 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
524ui_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
529void 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
564ui_menu_sliders::~ui_menu_sliders()
565{
566}
567
568/*-------------------------------------------------
569    menu_sliders_custom_render - perform our special
570    rendering
571-------------------------------------------------*/
572
573void 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
644void 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
658ui_menu_video_targets::ui_menu_video_targets(running_machine &machine, render_container *container) : ui_menu(machine, container)
659{
660}
661
662void 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
682ui_menu_video_targets::~ui_menu_video_targets()
683{
684}
685
686/*-------------------------------------------------
687    menu_video_options - handle the video options
688    menu
689-------------------------------------------------*/
690
691void 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
789ui_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
794void 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
851ui_menu_video_options::~ui_menu_video_options()
852{
853}
854
855/*-------------------------------------------------
856274    menu_crosshair - handle the crosshair settings
857275    menu
858276-------------------------------------------------*/
trunk/src/emu/ui/miscmenu.h
r243017r243018
1414#ifndef __UI_MISCMENU_H__
1515#define __UI_MISCMENU_H__
1616
17#include "crsshair.h"
1817#include "drivenum.h"
18#include "crsshair.h"
1919
2020class ui_menu_keyboard_mode : public ui_menu {
2121public:
r243017r243018
4444   attotime prevtime;
4545};
4646
47class ui_menu_cheat : public ui_menu {
48public:
49   ui_menu_cheat(running_machine &machine, render_container *container);
50   virtual ~ui_menu_cheat();
51   virtual void populate();
52   virtual void handle();
53};
54
55class ui_menu_sliders : public ui_menu {
56public:
57   ui_menu_sliders(running_machine &machine, render_container *container, bool menuless_mode = false);
58   virtual ~ui_menu_sliders();
59   virtual void populate();
60   virtual void handle();
61
62   virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
63
64   static UINT32 ui_handler(running_machine &machine, render_container *container, UINT32 state);
65
66private:
67   bool menuless_mode, hidden;
68};
69
70class ui_menu_video_targets : public ui_menu {
71public:
72   ui_menu_video_targets(running_machine &machine, render_container *container);
73   virtual ~ui_menu_video_targets();
74   virtual void populate();
75   virtual void handle();
76};
77
78class ui_menu_video_options : public ui_menu {
79public:
80   ui_menu_video_options(running_machine &machine, render_container *container, render_target *target);
81   virtual ~ui_menu_video_options();
82   virtual void populate();
83   virtual void handle();
84
85private:
86   enum {
87      VIDEO_ITEM_ROTATE = 0x80000000,
88      VIDEO_ITEM_BACKDROPS,
89      VIDEO_ITEM_OVERLAYS,
90      VIDEO_ITEM_BEZELS,
91      VIDEO_ITEM_CPANELS,
92      VIDEO_ITEM_MARQUEES,
93      VIDEO_ITEM_ZOOM,
94      VIDEO_ITEM_VIEW
95   };
96
97   render_target *target;
98};
99
10047class ui_menu_crosshair : public ui_menu {
10148public:
10249   ui_menu_crosshair(running_machine &machine, render_container *container);
trunk/src/emu/ui/sliders.c
r0r243018
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
20ui_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
25ui_menu_sliders::~ui_menu_sliders()
26{
27}
28
29/*-------------------------------------------------
30    menu_sliders - handle the sliders menu
31-------------------------------------------------*/
32
33void 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
131void 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
171void 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
243UINT32 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/sliders.h
r0r243018
1/***************************************************************************
2
3    ui/miscmenu.h
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#pragma once
13
14#ifndef __UI_SLIDERS_H__
15#define __UI_SLIDERS_H__
16
17class ui_menu_sliders : public ui_menu {
18public:
19   ui_menu_sliders(running_machine &machine, render_container *container, bool menuless_mode = false);
20   virtual ~ui_menu_sliders();
21   virtual void populate();
22   virtual void handle();
23
24   virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
25
26   static UINT32 ui_handler(running_machine &machine, render_container *container, UINT32 state);
27
28private:
29   bool menuless_mode, hidden;
30};
31
32
33#endif  /* __UI_SLIDERS_H__ */
trunk/src/emu/ui/ui.c
r243017r243018
1616#include "render.h"
1717#include "cheat.h"
1818#include "rendfont.h"
19#include "uiinput.h"
1920#include "ui/ui.h"
20#include "uiinput.h"
21#include "ui/cheatopt.h"
2122#include "ui/mainmenu.h"
2223#include "ui/miscmenu.h"
2324#include "ui/filemngr.h"
25#include "ui/sliders.h"
2426#include "ui/viewgfx.h"
2527#include "imagedev/cassette.h"
26#include <ctype.h>
2728
2829
2930/***************************************************************************
trunk/src/emu/ui/videoopt.c
r0r243018
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
24void 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
38ui_menu_video_targets::ui_menu_video_targets(running_machine &machine, render_container *container) : ui_menu(machine, container)
39{
40}
41
42void 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
62ui_menu_video_targets::~ui_menu_video_targets()
63{
64}
65
66/*-------------------------------------------------
67    menu_video_options - handle the video options
68    menu
69-------------------------------------------------*/
70
71void 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
169ui_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
174void 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
231ui_menu_video_options::~ui_menu_video_options()
232{
233}
trunk/src/emu/ui/videoopt.h
r0r243018
1/***************************************************************************
2
3    ui/videoopt.h
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#pragma once
13
14#ifndef __UI_VIDEOOPT_H__
15#define __UI_VIDEOOPT_H__
16
17
18class ui_menu_video_targets : public ui_menu {
19public:
20   ui_menu_video_targets(running_machine &machine, render_container *container);
21   virtual ~ui_menu_video_targets();
22   virtual void populate();
23   virtual void handle();
24};
25
26class ui_menu_video_options : public ui_menu {
27public:
28   ui_menu_video_options(running_machine &machine, render_container *container, render_target *target);
29   virtual ~ui_menu_video_options();
30   virtual void populate();
31   virtual void handle();
32
33private:
34   enum {
35      VIDEO_ITEM_ROTATE = 0x80000000,
36      VIDEO_ITEM_BACKDROPS,
37      VIDEO_ITEM_OVERLAYS,
38      VIDEO_ITEM_BEZELS,
39      VIDEO_ITEM_CPANELS,
40      VIDEO_ITEM_MARQUEES,
41      VIDEO_ITEM_ZOOM,
42      VIDEO_ITEM_VIEW
43   };
44
45   render_target *target;
46};
47
48
49#endif  /* __UI_VIDEOOPT_H__ */


Previous 199869 Revisions Next


© 1997-2024 The MAME Team