summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author etabeta78 <etabeta78@users.noreply.github.com>2015-01-08 08:53:48 +0100
committer etabeta78 <etabeta78@users.noreply.github.com>2015-01-08 08:53:48 +0100
commit847585ad36b482d8b0aea102d4808fa0727ac8c5 (patch)
treee79a570c0df5109e6659ba46bf835ca497613fc2
parent91cf4d319e97f4b263d0f590124e37278a797646 (diff)
(MESS) ui: minor improvement to Tape Control menu, so that when
multiple cassettes are available it is clear which drive controls are displayed (see e.g. sol20 or pet2001 with "-tape2 c2n" slot). also cleaned up some function names and better described the usage of the devctrl.h base class. nw.
-rw-r--r--src/emu/ui/devctrl.h32
-rw-r--r--src/emu/ui/mainmenu.c6
-rw-r--r--src/emu/ui/mainmenu.h2
-rw-r--r--src/emu/ui/tapectrl.c155
-rw-r--r--src/emu/ui/tapectrl.h8
5 files changed, 110 insertions, 93 deletions
diff --git a/src/emu/ui/devctrl.h b/src/emu/ui/devctrl.h
index 9be4b7f2127..1051d1a099e 100644
--- a/src/emu/ui/devctrl.h
+++ b/src/emu/ui/devctrl.h
@@ -2,7 +2,17 @@
ui/devctrl.h
- Device specific control (base class for tapectrl)
+ Device specific control menu
+ This source provides a base class for any device which need a specific
+ submenu and which can occur multiple times in the same driver (at the
+ moment, cassette tapes and barcode readers, in future possibly other like
+ printers)
+ The base class contains calls to get the total number of devices of
+ the same kind connected to the driver, and shortcuts to switch current
+ device to next one or previous one attached. This allows, for instance,
+ users to pass from a device to another one by simply pressing left/right
+ and the menu is rebuilt accordingly, without the need of a preliminary
+ submenu listing available devices of the same kind.
Copyright Nicola Salmoria and the MAME Team.
Visit http://mamedev.org for licensing and usage restrictions.
@@ -27,6 +37,7 @@ protected:
int current_index();
void previous();
void next();
+ astring current_display_name();
private:
// device iterator
@@ -104,4 +115,23 @@ void ui_menu_device_control<_DeviceType>::next()
}
}
+
+//-------------------------------------------------
+// current_display_name
+//-------------------------------------------------
+
+template<class _DeviceType>
+astring ui_menu_device_control<_DeviceType>::current_display_name()
+{
+ astring display_name;
+ display_name.cpy(current_device()->device().name());
+ if (count() > 1)
+ {
+ astring temp;
+ temp.printf(" %d", current_index() + 1);
+ display_name.cat(temp);
+ }
+ return display_name;
+}
+
#endif /* __UI_DEVCTRL_H__ */
diff --git a/src/emu/ui/mainmenu.c b/src/emu/ui/mainmenu.c
index 4681f429a62..b17692bb930 100644
--- a/src/emu/ui/mainmenu.c
+++ b/src/emu/ui/mainmenu.c
@@ -84,7 +84,7 @@ void ui_menu_main::populate()
/* add tape control menu */
cassette_device_iterator cassiter(machine().root_device());
if (cassiter.first() != NULL)
- item_append("Tape Control", NULL, 0, (void *)MESS_MENU_TAPE_CONTROL);
+ item_append("Tape Control", NULL, 0, (void *)TAPE_CONTROL);
}
if (machine().ioport().has_bioses())
@@ -184,8 +184,8 @@ void ui_menu_main::handle()
ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_manager(machine(), container)));
break;
- case MESS_MENU_TAPE_CONTROL:
- ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_mess_tape_control(machine(), container, NULL)));
+ case TAPE_CONTROL:
+ ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_tape_control(machine(), container, NULL)));
break;
case SLOT_DEVICES:
diff --git a/src/emu/ui/mainmenu.h b/src/emu/ui/mainmenu.h
index 00756c213c7..3048829bac9 100644
--- a/src/emu/ui/mainmenu.h
+++ b/src/emu/ui/mainmenu.h
@@ -35,7 +35,7 @@ private:
GAME_INFO,
IMAGE_MENU_IMAGE_INFO,
IMAGE_MENU_FILE_MANAGER,
- MESS_MENU_TAPE_CONTROL,
+ TAPE_CONTROL,
SLOT_DEVICES,
NETWORK_DEVICES,
KEYBOARD_MODE,
diff --git a/src/emu/ui/tapectrl.c b/src/emu/ui/tapectrl.c
index 568680b30d7..d3d4f94b926 100644
--- a/src/emu/ui/tapectrl.c
+++ b/src/emu/ui/tapectrl.c
@@ -2,7 +2,7 @@
ui/tapectrl.c
- MESS's tape control
+ Tape control
Copyright Nicola Salmoria and the MAME Team.
Visit http://mamedev.org for licensing and usage restrictions.
@@ -12,8 +12,6 @@
#include "emu.h"
#include "ui/tapectrl.h"
-
-
/***************************************************************************
CONSTANTS
***************************************************************************/
@@ -23,7 +21,7 @@
#define TAPECMD_PLAY ((void *) 0x0002)
#define TAPECMD_RECORD ((void *) 0x0003)
#define TAPECMD_REWIND ((void *) 0x0004)
-#define TAPECMD_FAST_FORWARD ((void *) 0x0005)
+#define TAPECMD_FAST_FORWARD ((void *) 0x0005)
#define TAPECMD_SLIDER ((void *) 0x0006)
#define TAPECMD_SELECT ((void *) 0x0007)
@@ -36,7 +34,7 @@
// ctor
//-------------------------------------------------
-ui_menu_mess_tape_control::ui_menu_mess_tape_control(running_machine &machine, render_container *container, cassette_image_device *device)
+ui_menu_tape_control::ui_menu_tape_control(running_machine &machine, render_container *container, cassette_image_device *device)
: ui_menu_device_control<cassette_image_device>(machine, container, device)
{
}
@@ -46,7 +44,7 @@ ui_menu_mess_tape_control::ui_menu_mess_tape_control(running_machine &machine, r
// dtor
//-------------------------------------------------
-ui_menu_mess_tape_control::~ui_menu_mess_tape_control()
+ui_menu_tape_control::~ui_menu_tape_control()
{
}
@@ -55,77 +53,68 @@ ui_menu_mess_tape_control::~ui_menu_mess_tape_control()
// populate - populates the main tape control menu
//-------------------------------------------------
-void ui_menu_mess_tape_control::populate()
+void ui_menu_tape_control::populate()
{
- astring timepos;
- cassette_state state;
UINT32 flags = 0;
if (count() > 1)
{
- int index = current_index();
-
- if( index == (count()-1) )
+ if (current_index() == (count() - 1))
flags |= MENU_FLAG_LEFT_ARROW;
else
flags |= MENU_FLAG_RIGHT_ARROW;
}
- if ((current_device() != NULL) && (current_device()->exists()))
- {
- double t0, t1;
- UINT32 tapeflags = 0;
-
- t0 = current_device()->get_position();
- t1 = current_device()->get_length();
+ if (current_device())
+ {
+ // name of tape
+ item_append(current_display_name().cstr(), current_device()->exists() ? current_device()->filename() : "No Tape Image loaded", flags, TAPECMD_SELECT);
- if (t1 > 0)
+ if (current_device()->exists())
{
- if (t0 > 0)
- tapeflags |= MENU_FLAG_LEFT_ARROW;
- if (t0 < t1)
- tapeflags |= MENU_FLAG_RIGHT_ARROW;
+ astring timepos;
+ cassette_state state;
+ double t0 = current_device()->get_position();
+ double t1 = current_device()->get_length();
+ UINT32 tapeflags = 0;
+
+ // state
+ if (t1 > 0)
+ {
+ if (t0 > 0)
+ tapeflags |= MENU_FLAG_LEFT_ARROW;
+ if (t0 < t1)
+ tapeflags |= MENU_FLAG_RIGHT_ARROW;
+ }
+
+ get_time_string(timepos, current_device(), NULL, NULL);
+ state = current_device()->get_state();
+ item_append(
+ (state & CASSETTE_MASK_UISTATE) == CASSETTE_STOPPED
+ ? "stopped"
+ : ((state & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY
+ ? ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "playing" : "(playing)")
+ : ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "recording" : "(recording)")
+ ),
+ timepos,
+ tapeflags,
+ TAPECMD_SLIDER);
+
+ // pause or stop
+ item_append("Pause/Stop", NULL, 0, TAPECMD_STOP);
+
+ // play
+ item_append("Play", NULL, 0, TAPECMD_PLAY);
+
+ // record
+ item_append("Record", NULL, 0, TAPECMD_RECORD);
+
+ // rewind
+ item_append("Rewind", NULL, 0, TAPECMD_REWIND);
+
+ // fast forward
+ item_append("Fast Forward", NULL, 0, TAPECMD_FAST_FORWARD);
}
-
- // name of tape
- item_append(current_device()->device().name(), current_device()->filename(), flags, TAPECMD_SELECT);
-
- // state
- get_time_string(timepos, current_device(), NULL, NULL);
- state = current_device()->get_state();
- item_append(
- (state & CASSETTE_MASK_UISTATE) == CASSETTE_STOPPED
- ? "stopped"
- : ((state & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY
- ? ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "playing" : "(playing)")
- : ((state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED ? "recording" : "(recording)")
- ),
- timepos,
- tapeflags,
- TAPECMD_SLIDER);
-
- // pause or stop
- item_append("Pause/Stop", NULL, 0, TAPECMD_STOP);
-
- // play
- item_append("Play", NULL, 0, TAPECMD_PLAY);
-
- // record
- item_append("Record", NULL, 0, TAPECMD_RECORD);
-
- // rewind
- item_append("Rewind", NULL, 0, TAPECMD_REWIND);
-
- // fast forward
- item_append("Fast Forward", NULL, 0, TAPECMD_FAST_FORWARD);
- }
- else
- {
- // no tape loaded in this cassette device (but there could be more than one!)
- if (count() > 1)
- item_append("No Tape Image loaded", "", flags, TAPECMD_SELECT);
- else
- item_append("No Tape Image loaded", NULL, 0, NULL);
}
}
@@ -134,7 +123,7 @@ void ui_menu_mess_tape_control::populate()
// handle - main tape control menu
//-------------------------------------------------
-void ui_menu_mess_tape_control::handle()
+void ui_menu_tape_control::handle()
{
// rebuild the menu - we have to do this so that the counter updates
reset(UI_MENU_RESET_REMEMBER_POSITION);
@@ -147,34 +136,32 @@ void ui_menu_mess_tape_control::handle()
switch(event->iptkey)
{
case IPT_UI_LEFT:
- if (event->itemref==TAPECMD_SLIDER)
+ if (event->itemref == TAPECMD_SLIDER)
current_device()->seek(-1, SEEK_CUR);
- else if (event->itemref==TAPECMD_SELECT)
+ else if (event->itemref == TAPECMD_SELECT)
previous();
break;
case IPT_UI_RIGHT:
- if (event->itemref==TAPECMD_SLIDER)
+ if (event->itemref == TAPECMD_SLIDER)
current_device()->seek(+1, SEEK_CUR);
- else if (event->itemref==TAPECMD_SELECT)
+ else if (event->itemref == TAPECMD_SELECT)
next();
break;
case IPT_UI_SELECT:
- {
- if (event->itemref==TAPECMD_STOP)
- current_device()->change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE);
- else if (event->itemref==TAPECMD_PLAY)
- current_device()->change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE);
- else if (event->itemref==TAPECMD_RECORD)
- current_device()->change_state(CASSETTE_RECORD, CASSETTE_MASK_UISTATE);
- else if (event->itemref==TAPECMD_REWIND)
- current_device()->seek(-30, SEEK_CUR);
- else if (event->itemref==TAPECMD_FAST_FORWARD)
- current_device()->seek(30, SEEK_CUR);
- else if (event->itemref==TAPECMD_SLIDER)
- current_device()->seek(0, SEEK_SET);
- }
+ if (event->itemref == TAPECMD_STOP)
+ current_device()->change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE);
+ else if (event->itemref == TAPECMD_PLAY)
+ current_device()->change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE);
+ else if (event->itemref == TAPECMD_RECORD)
+ current_device()->change_state(CASSETTE_RECORD, CASSETTE_MASK_UISTATE);
+ else if (event->itemref == TAPECMD_REWIND)
+ current_device()->seek(-30, SEEK_CUR);
+ else if (event->itemref == TAPECMD_FAST_FORWARD)
+ current_device()->seek(30, SEEK_CUR);
+ else if (event->itemref == TAPECMD_SLIDER)
+ current_device()->seek(0, SEEK_SET);
break;
}
}
@@ -186,7 +173,7 @@ void ui_menu_mess_tape_control::handle()
// representation of the time
//-------------------------------------------------
-void ui_menu_mess_tape_control::get_time_string(astring &dest, cassette_image_device *cassette, int *curpos, int *endpos)
+void ui_menu_tape_control::get_time_string(astring &dest, cassette_image_device *cassette, int *curpos, int *endpos)
{
double t0, t1;
diff --git a/src/emu/ui/tapectrl.h b/src/emu/ui/tapectrl.h
index 4350d35b07a..b1c36c73dcd 100644
--- a/src/emu/ui/tapectrl.h
+++ b/src/emu/ui/tapectrl.h
@@ -2,7 +2,7 @@
ui/tapectrl.h
- MESS's tape control
+ Tape control
Copyright Nicola Salmoria and the MAME Team.
Visit http://mamedev.org for licensing and usage restrictions.
@@ -17,10 +17,10 @@
#include "imagedev/cassette.h"
#include "ui/devctrl.h"
-class ui_menu_mess_tape_control : public ui_menu_device_control<cassette_image_device> {
+class ui_menu_tape_control : public ui_menu_device_control<cassette_image_device> {
public:
- ui_menu_mess_tape_control(running_machine &machine, render_container *container, cassette_image_device *device);
- virtual ~ui_menu_mess_tape_control();
+ ui_menu_tape_control(running_machine &machine, render_container *container, cassette_image_device *device);
+ virtual ~ui_menu_tape_control();
virtual void populate();
virtual void handle();