Previous 199869 Revisions Next

r34234 Wednesday 7th January, 2015 at 14:02:14 UTC by Fabio Priuli
ui: Added "Reset" option to DipSwitch and ConfSettings menu, as well
as to the File Manager, for consistency with other menus where an hard
reset is of help [Fabio Priuli]
ui: Fixed DipLocation drawing so that it remains on screen also when
highlighting switches without locations [Fabio Priuli]

out of whatsnew: while at it, I have also cleaned up a bit the handling of
"Reset" in the slot and bios menus...
[src/emu/ui]filemngr.c miscmenu.c

trunk/src/emu/ui/filemngr.c
r242745r242746
106106      // record the menu item
107107      item_append(buffer, tmp_name.cstr(), 0, (void *) image);
108108   }
109   item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
110   item_append("Reset",  NULL, 0, (void *)1);
109111
110112   custombottom = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
111113}
r242745r242746
117119
118120void ui_menu_file_manager::handle()
119121{
120   // update the selected device
121   selected_device = (device_image_interface *) get_selection();
122
123122   // process the menu
124123   const ui_menu_event *event = process(0);
125   if (event != NULL && event->iptkey == IPT_UI_SELECT)
124   if (event != NULL && event->itemref != NULL && event->iptkey == IPT_UI_SELECT)
126125   {
127      selected_device = (device_image_interface *) event->itemref;
128      if (selected_device != NULL)
126      if ((FPTR)event->itemref == 1)
127         machine().schedule_hard_reset();
128      else
129129      {
130         ui_menu::stack_push(selected_device->get_selection_menu(machine(), container));
131
132         // reset the existing menu
133         reset(UI_MENU_RESET_REMEMBER_POSITION);
130         selected_device = (device_image_interface *) event->itemref;
131         if (selected_device != NULL)
132         {
133            ui_menu::stack_push(selected_device->get_selection_menu(machine(), container));
134           
135            // reset the existing menu
136            reset(UI_MENU_RESET_REMEMBER_POSITION);
137         }
134138      }
135139   }
136140}
trunk/src/emu/ui/miscmenu.c
r242745r242746
99
1010*********************************************************************/
1111
12#include <ctype.h>
13
1214#include "emu.h"
15#include "emuopts.h"
16
17#include "cheat.h"
1318#include "osdnet.h"
14#include "emuopts.h"
15#include "ui/ui.h"
1619#include "rendutil.h"
17#include "cheat.h"
20
1821#include "uiinput.h"
22#include "ui/ui.h"
23#include "ui/miscmenu.h"
1924#include "ui/filemngr.h"
20#include "ui/miscmenu.h"
21#include "audit.h"
22#include "crsshair.h"
23#include <ctype.h>
24#include "imagedev/cassette.h"
25#include "imagedev/bitbngr.h"
2625
2726
28
2927/***************************************************************************
3028    CONSTANTS
3129***************************************************************************/
r242745r242746
257255      item_append(slot->device().tag()+1, option == NULL ? "------" : option->name(), (slot->fixed() || slot_get_length(slot) == 0) ? 0 : (MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW), (void *)slot);
258256   }
259257   item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
260   item_append("Reset",  NULL, 0, NULL);
258   item_append("Reset",  NULL, 0, (void *)1);
261259}
262260
263261ui_menu_slot_devices::~ui_menu_slot_devices()
r242745r242746
275273
276274   if (menu_event != NULL && menu_event->itemref != NULL)
277275   {
278      if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) {
276      if ((FPTR)menu_event->itemref == 1 && menu_event->iptkey == IPT_UI_SELECT)
277         machine().schedule_hard_reset();
278      else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
279      {
279280         device_slot_interface *slot = (device_slot_interface *)menu_event->itemref;
280281         const char *val = (menu_event->iptkey == IPT_UI_LEFT) ? slot_get_prev(slot) : slot_get_next(slot);
281         set_slot_device(slot,val);
282         set_slot_device(slot, val);
282283         reset(UI_MENU_RESET_REMEMBER_REF);
283284      }
284   } else if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) {
285      machine().schedule_hard_reset();
286285   }
287286}
288287
r242745r242746
315314   }
316315
317316   item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
318   item_append("Reset",  NULL, 0, NULL);
317   item_append("Reset",  NULL, 0, (void *)1);
319318}
320319
321320ui_menu_bios_selection::~ui_menu_bios_selection()
r242745r242746
333332
334333   if (menu_event != NULL && menu_event->itemref != NULL)
335334   {
336      if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) {
335      if ((FPTR)menu_event->itemref == 1 && menu_event->iptkey == IPT_UI_SELECT)
336         machine().schedule_hard_reset();
337      else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
338      {
337339         device_t *dev = (device_t *)menu_event->itemref;
338340         int cnt = 0;
339341         for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++)
r242745r242746
358360         }
359361         reset(UI_MENU_RESET_REMEMBER_REF);
360362      }
361   } else if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) {
362      machine().schedule_hard_reset();
363363   }
364364}
365365
366
367
366368ui_menu_network_devices::ui_menu_network_devices(running_machine &machine, render_container *container) : ui_menu(machine, container)
367369{
368370}
r242745r242746
842844
843845void ui_menu_settings::handle()
844846{
845   /* process the menu */
847   // process the menu
846848   const ui_menu_event *menu_event = process(0);
847849
848   /* handle events */
850   // handle events
849851   if (menu_event != NULL && menu_event->itemref != NULL)
850852   {
851      ioport_field *field = (ioport_field *)menu_event->itemref;
852      ioport_field::user_settings settings;
853      int changed = false;
854
855      switch (menu_event->iptkey)
853      // reset
854      if ((FPTR)menu_event->itemref == 1)
856855      {
857         /* if selected, reset to default value */
858         case IPT_UI_SELECT:
859            field->get_user_settings(settings);
860            settings.value = field->defvalue();
861            field->set_user_settings(settings);
862            changed = true;
863            break;
864
865         /* left goes to previous setting */
866         case IPT_UI_LEFT:
867            field->select_previous_setting();
868            changed = true;
869            break;
870
871         /* right goes to next setting */
872         case IPT_UI_RIGHT:
873            field->select_next_setting();
874            changed = true;
875            break;
856         if (menu_event->iptkey == IPT_UI_SELECT)
857            machine().schedule_hard_reset();
876858      }
877
878      /* if anything changed, rebuild the menu, trying to stay on the same field */
879      if (changed)
880         reset(UI_MENU_RESET_REMEMBER_REF);
859      // actual settings
860      else
861      {
862         ioport_field *field = (ioport_field *)menu_event->itemref;
863         ioport_field::user_settings settings;
864         int changed = false;
865         
866         switch (menu_event->iptkey)
867         {
868            /* if selected, reset to default value */
869            case IPT_UI_SELECT:
870               field->get_user_settings(settings);
871               settings.value = field->defvalue();
872               field->set_user_settings(settings);
873               changed = true;
874               break;
875               
876            /* left goes to previous setting */
877            case IPT_UI_LEFT:
878               field->select_previous_setting();
879               changed = true;
880               break;
881               
882            /* right goes to next setting */
883            case IPT_UI_RIGHT:
884               field->select_next_setting();
885               changed = true;
886               break;
887         }
888         
889         /* if anything changed, rebuild the menu, trying to stay on the same field */
890         if (changed)
891            reset(UI_MENU_RESET_REMEMBER_REF);
892      }
881893   }
882894}
883895
r242745r242746
949961                     dip->mask = dip->state = 0;
950962                     *diplist_tailptr = dip;
951963                     diplist_tailptr = &dip->next;
952                     if (core_stricmp(dip->name, "FAKE") != 0)
953                        dipcount++;
964                     dipcount++;
954965                  }
955966
956967                  /* apply the bits */
r242745r242746
964975            }
965976         }
966977   if (type == IPT_DIPSWITCH)
967      custombottom = dipcount * (DIP_SWITCH_HEIGHT + DIP_SWITCH_SPACING) + DIP_SWITCH_SPACING;
978      custombottom = dipcount ? dipcount * (DIP_SWITCH_HEIGHT + DIP_SWITCH_SPACING) + DIP_SWITCH_SPACING : 0;
979   
980   item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
981   item_append("Reset",  NULL, 0, (void *)1);
968982}
969983
970984ui_menu_settings::~ui_menu_settings()
r242745r242746
978992
979993void ui_menu_settings_dip_switches::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2)
980994{
981   ioport_field *field = (ioport_field *)selectedref;
982   dip_descriptor *dip;
983
984   if (field==NULL || field->first_diplocation() == NULL)
995   // catch if no diploc has to be drawn
996   if (bottom == 0)
985997      return;
986998
987   /* add borders */
999   // add borders
9881000   y1 = y2 + UI_BOX_TB_BORDER;
9891001   y2 = y1 + bottom;
9901002
991   /* draw extra menu area */
1003   // draw extra menu area
9921004   machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
9931005   y1 += (float)DIP_SWITCH_SPACING;
9941006
995   /* iterate over DIP switches */
996   for (dip = diplist; dip != NULL; dip = dip->next)
1007   // iterate over DIP switches
1008   for (dip_descriptor *dip = diplist; dip != NULL; dip = dip->next)
9971009   {
998      if (core_stricmp(dip->name, "FAKE") != 0)
1010      const ioport_diplocation *diploc;
1011      UINT32 selectedmask = 0;
1012     
1013      // determine the mask of selected bits
1014      if ((FPTR)selectedref != 1)
9991015      {
1000         const ioport_diplocation *diploc;
1001         UINT32 selectedmask = 0;
1002
1003         /* determine the mask of selected bits */
1004         if (field != NULL)
1016         ioport_field *field = (ioport_field *)selectedref;
1017         
1018         if (field != NULL && field->first_diplocation() != NULL)
10051019            for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next())
10061020               if (strcmp(dip->name, diploc->name()) == 0)
10071021                  selectedmask |= 1 << (diploc->number() - 1);
1008
1009         /* draw one switch */
1010         custom_render_one(x1, y1, x2, y1 + DIP_SWITCH_HEIGHT, dip, selectedmask);
1011         y1 += (float)(DIP_SWITCH_SPACING + DIP_SWITCH_HEIGHT);
10121022      }
1023     
1024      // draw one switch
1025      custom_render_one(x1, y1, x2, y1 + DIP_SWITCH_HEIGHT, dip, selectedmask);
1026      y1 += (float)(DIP_SWITCH_SPACING + DIP_SWITCH_HEIGHT);
10131027   }
10141028}
10151029


Previous 199869 Revisions Next


© 1997-2024 The MAME Team