diff --git a/.gitattributes b/.gitattributes index 8cae5688fb2..e1a5cd091d3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3075,18 +3075,18 @@ src/emu/timer.h svneol=native#text/plain src/emu/ui/barcode.c svneol=native#text/plain src/emu/ui/barcode.h svneol=native#text/plain src/emu/ui/devctrl.h svneol=native#text/plain -src/emu/ui/emenubar.c svneol=native#text/plain -src/emu/ui/emenubar.h svneol=native#text/plain +src/emu/ui/filemngr.c svneol=native#text/plain +src/emu/ui/filemngr.h svneol=native#text/plain src/emu/ui/filesel.c svneol=native#text/plain src/emu/ui/filesel.h svneol=native#text/plain src/emu/ui/imgcntrl.c svneol=native#text/plain src/emu/ui/imgcntrl.h svneol=native#text/plain src/emu/ui/imginfo.c svneol=native#text/plain src/emu/ui/imginfo.h svneol=native#text/plain +src/emu/ui/mainmenu.c svneol=native#text/plain +src/emu/ui/mainmenu.h svneol=native#text/plain src/emu/ui/menu.c svneol=native#text/plain src/emu/ui/menu.h svneol=native#text/plain -src/emu/ui/menubar.c svneol=native#text/plain -src/emu/ui/menubar.h svneol=native#text/plain src/emu/ui/miscmenu.c svneol=native#text/plain src/emu/ui/miscmenu.h svneol=native#text/plain src/emu/ui/selgame.c svneol=native#text/plain diff --git a/src/emu/emu.mak b/src/emu/emu.mak index a410655665e..777644d5ff0 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -116,10 +116,10 @@ EMUOBJS = \ $(EMUOBJ)/ui/ui.o \ $(EMUOBJ)/ui/swlist.o \ $(EMUOBJ)/ui/menu.o \ - $(EMUOBJ)/ui/menubar.o \ - $(EMUOBJ)/ui/emenubar.o \ + $(EMUOBJ)/ui/mainmenu.o \ $(EMUOBJ)/ui/miscmenu.o \ $(EMUOBJ)/ui/selgame.o \ + $(EMUOBJ)/ui/filemngr.o \ $(EMUOBJ)/ui/filesel.o \ $(EMUOBJ)/ui/imgcntrl.o \ $(EMUOBJ)/ui/imginfo.o \ diff --git a/src/emu/emuopts.c b/src/emu/emuopts.c index 68a60331b58..f4c8db2c892 100644 --- a/src/emu/emuopts.c +++ b/src/emu/emuopts.c @@ -167,7 +167,7 @@ const options_entry emu_options::s_option_entries[] = { OPTION_SKIP_GAMEINFO, "0", OPTION_BOOLEAN, "skip displaying the information screen at startup" }, { OPTION_UI_FONT, "default", OPTION_STRING, "specify a font to use" }, { OPTION_RAMSIZE ";ram", NULL, OPTION_STRING, "size of RAM (if supported by driver)" }, - { OPTION_CONFIRM_QUIT, "1", OPTION_BOOLEAN, "display confirm quit screen on exit" }, + { OPTION_CONFIRM_QUIT, "0", OPTION_BOOLEAN, "display confirm quit screen on exit" }, { OPTION_UI_MOUSE, "0", OPTION_BOOLEAN, "display ui mouse cursor" }, { OPTION_AUTOBOOT_COMMAND ";ab", NULL, OPTION_STRING, "command to execute after machine boot" }, { OPTION_AUTOBOOT_DELAY, "2", OPTION_INTEGER, "timer delay in sec to trigger command execution on autoboot" }, diff --git a/src/emu/inpttype.h b/src/emu/inpttype.h index c96e48176fd..56aab02fa32 100644 --- a/src/emu/inpttype.h +++ b/src/emu/inpttype.h @@ -709,72 +709,66 @@ void construct_core_types_keypad(simple_list &typelist) INPUT_PORT_DIGITAL_TYPE( 0, OTHER, KEYBOARD, "Keyboard", input_seq() ) } -void construct_core_types_ui_general(simple_list &typelist) +void construct_core_types_UI(simple_list &typelist) { - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_CONFIGURE, "Config Menu", input_seq(KEYCODE_TAB) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_UP, "UI Up", input_seq(KEYCODE_UP, input_seq::or_code, JOYCODE_Y_UP_SWITCH_INDEXED(0)) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_DOWN, "UI Down", input_seq(KEYCODE_DOWN, input_seq::or_code, JOYCODE_Y_DOWN_SWITCH_INDEXED(0)) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_LEFT, "UI Left", input_seq(KEYCODE_LEFT, input_seq::or_code, JOYCODE_X_LEFT_SWITCH_INDEXED(0)) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_RIGHT, "UI Right", input_seq(KEYCODE_RIGHT, input_seq::or_code, JOYCODE_X_RIGHT_SWITCH_INDEXED(0)) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_HOME, "UI Home", input_seq(KEYCODE_HOME) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_END, "UI End", input_seq(KEYCODE_END) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_PAGE_UP, "UI Page Up", input_seq(KEYCODE_PGUP) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_PAGE_DOWN, "UI Page Down", input_seq(KEYCODE_PGDN) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_SELECT, "UI Select", input_seq(KEYCODE_ENTER, input_seq::or_code, JOYCODE_BUTTON1_INDEXED(0)) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_CANCEL, "UI Cancel", input_seq(KEYCODE_ESC) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_DISPLAY_COMMENT, "UI Display Comment", input_seq(KEYCODE_SPACE) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_CLEAR, "UI Clear", input_seq(KEYCODE_DEL) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_ZOOM_IN, "UI Zoom In", input_seq(KEYCODE_EQUALS) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_ZOOM_OUT, "UI Zoom Out", input_seq(KEYCODE_MINUS) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_PREV_GROUP, "UI Previous Group", input_seq(KEYCODE_OPENBRACE) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, UI_NEXT_GROUP, "UI Next Group", input_seq(KEYCODE_CLOSEBRACE) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ON_SCREEN_DISPLAY,"On Screen Display", input_seq(KEYCODE_TILDE) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_DEBUG_BREAK, "Break in Debugger", input_seq(KEYCODE_TILDE) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_CONFIGURE, "Config Menu", input_seq(KEYCODE_TAB) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PAUSE, "Pause", input_seq(KEYCODE_P) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RESET_MACHINE, "Reset Game", input_seq(KEYCODE_F3, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SOFT_RESET, "Soft Reset", input_seq(KEYCODE_F3, input_seq::not_code, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SHOW_GFX, "Show Gfx", input_seq(KEYCODE_F4) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_FRAMESKIP_DEC, "Frameskip Dec", input_seq(KEYCODE_F8) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_FRAMESKIP_INC, "Frameskip Inc", input_seq(KEYCODE_F9) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_THROTTLE, "Throttle", input_seq(KEYCODE_F10) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_FAST_FORWARD, "Fast Forward", input_seq(KEYCODE_INSERT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SHOW_FPS, "Show FPS", input_seq(KEYCODE_F11, input_seq::not_code, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SNAPSHOT, "Save Snapshot", input_seq(KEYCODE_F12, input_seq::not_code, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RECORD_MOVIE, "Record Movie", input_seq(KEYCODE_F12, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_CHEAT, "Toggle Cheat", input_seq(KEYCODE_F6) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_UP, "UI Up", input_seq(KEYCODE_UP, input_seq::or_code, JOYCODE_Y_UP_SWITCH_INDEXED(0)) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_DOWN, "UI Down", input_seq(KEYCODE_DOWN, input_seq::or_code, JOYCODE_Y_DOWN_SWITCH_INDEXED(0)) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_LEFT, "UI Left", input_seq(KEYCODE_LEFT, input_seq::or_code, JOYCODE_X_LEFT_SWITCH_INDEXED(0)) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RIGHT, "UI Right", input_seq(KEYCODE_RIGHT, input_seq::or_code, JOYCODE_X_RIGHT_SWITCH_INDEXED(0)) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_HOME, "UI Home", input_seq(KEYCODE_HOME) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_END, "UI End", input_seq(KEYCODE_END) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PAGE_UP, "UI Page Up", input_seq(KEYCODE_PGUP) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PAGE_DOWN, "UI Page Down", input_seq(KEYCODE_PGDN) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SELECT, "UI Select", input_seq(KEYCODE_ENTER, input_seq::or_code, JOYCODE_BUTTON1_INDEXED(0)) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_CANCEL, "UI Cancel", input_seq(KEYCODE_ESC) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_DISPLAY_COMMENT, "UI Display Comment", input_seq(KEYCODE_SPACE) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_CLEAR, "UI Clear", input_seq(KEYCODE_DEL) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ZOOM_IN, "UI Zoom In", input_seq(KEYCODE_EQUALS) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ZOOM_OUT, "UI Zoom Out", input_seq(KEYCODE_MINUS) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PREV_GROUP, "UI Previous Group", input_seq(KEYCODE_OPENBRACE) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_NEXT_GROUP, "UI Next Group", input_seq(KEYCODE_CLOSEBRACE) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ROTATE, "UI Rotate", input_seq(KEYCODE_R) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SHOW_PROFILER, "Show Profiler", input_seq(KEYCODE_F11, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_UI, "UI Toggle", input_seq(KEYCODE_SCRLOCK, input_seq::not_code, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PASTE, "UI Paste Text", input_seq(KEYCODE_SCRLOCK, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_DEBUG, "Toggle Debugger", input_seq(KEYCODE_F5) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SAVE_STATE, "Save State", input_seq(KEYCODE_F7, KEYCODE_LSHIFT) ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_LOAD_STATE, "Load State", input_seq(KEYCODE_F7, input_seq::not_code, KEYCODE_LSHIFT) ) } -void construct_core_types_ui_shortcuts(simple_list &typelist) -{ - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_ON_SCREEN_DISPLAY,"On Screen Display", input_seq(KEYCODE_TILDE) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_DEBUG_BREAK, "Break in Debugger", input_seq(KEYCODE_TILDE) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_PAUSE, "Pause", input_seq(KEYCODE_P, input_seq::not_code, KEYCODE_LSHIFT, input_seq::not_code, KEYCODE_RSHIFT ) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_SINGLE_STEP, "Single Step", input_seq(KEYCODE_P, KEYCODE_LSHIFT, input_seq::or_code, KEYCODE_P, KEYCODE_RSHIFT ) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_RESET_MACHINE, "Reset Game", input_seq(KEYCODE_F3, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_SOFT_RESET, "Soft Reset", input_seq(KEYCODE_F3, input_seq::not_code, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_EXIT, "Exit", input_seq(KEYCODE_ESC) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_SHOW_GFX, "Show Gfx", input_seq(KEYCODE_F4) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_FRAMESKIP_DEC, "Frameskip Dec", input_seq(KEYCODE_F8) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_FRAMESKIP_INC, "Frameskip Inc", input_seq(KEYCODE_F9) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_THROTTLE, "Throttle", input_seq(KEYCODE_F10) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_FAST_FORWARD, "Fast Forward", input_seq(KEYCODE_INSERT) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_SHOW_FPS, "Show FPS", input_seq(KEYCODE_F11, input_seq::not_code, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_SNAPSHOT, "Save Snapshot", input_seq(KEYCODE_F12, input_seq::not_code, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_RECORD_MOVIE, "Record Movie", input_seq(KEYCODE_F12, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_TOGGLE_CHEAT, "Toggle Cheat", input_seq(KEYCODE_F6) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_ROTATE, "UI Rotate", input_seq(KEYCODE_R) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_SHOW_PROFILER, "Show Profiler", input_seq(KEYCODE_F11, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_PASTE, "UI Paste Text", input_seq(KEYCODE_SCRLOCK, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_TOGGLE_DEBUG, "Toggle Debugger", input_seq(KEYCODE_F5) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_SAVE_STATE, "Save State", input_seq(KEYCODE_F7, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_LOAD_STATE, "Load State", input_seq(KEYCODE_F7, input_seq::not_code, KEYCODE_LSHIFT) ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_SHORTCUT, UI_SHORTCUTS_ENABLED,"Enable Shortcuts", input_seq(KEYCODE_SCRLOCK) ) - } - void construct_core_types_OSD(simple_list &typelist) { - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_1, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_2, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_3, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_4, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_5, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_6, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_7, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_8, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_9, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_10, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_11, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_12, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_13, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_14, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_15, NULL, input_seq() ) - INPUT_PORT_DIGITAL_TYPE( 0, UI_GENERAL, OSD_16, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_1, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_2, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_3, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_4, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_5, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_6, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_7, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_8, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_9, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_10, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_11, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_12, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_13, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_14, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_15, NULL, input_seq() ) + INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_16, NULL, input_seq() ) } void construct_core_types_invalid(simple_list &typelist) @@ -829,8 +823,7 @@ void construct_core_types(simple_list &typelist) construct_core_types_mouse_X(typelist); construct_core_types_mouse_Y(typelist); construct_core_types_keypad(typelist); - construct_core_types_ui_general(typelist); - construct_core_types_ui_shortcuts(typelist); + construct_core_types_UI(typelist); construct_core_types_OSD(typelist); construct_core_types_invalid(typelist); } diff --git a/src/emu/ioport.c b/src/emu/ioport.c index a1231308043..952945f6e37 100644 --- a/src/emu/ioport.c +++ b/src/emu/ioport.c @@ -123,7 +123,6 @@ const int SPACE_COUNT = 3; const int KEY_BUFFER_SIZE = 4096; const unicode_char INVALID_CHAR = '?'; -const bool KEYBOARD_TRUMPS_UI_SHORTCUTS = false; @@ -2478,10 +2477,6 @@ time_t ioport_manager::initialize() osd_printf_error("Input port errors:\n%s", errors.cstr()); } - // do we have a keyboard? if so, we may need to change default UI keys in response - if (KEYBOARD_TRUMPS_UI_SHORTCUTS && has_keyboard()) - adjust_ui_seqs_for_keyboard(); - // renumber player numbers for controller ports int player_offset = 0; for (device_t *device = iter.first(); device != NULL; device = iter.next()) @@ -2642,87 +2637,6 @@ void ioport_manager::init_autoselect_devices(int type1, int type2, int type3, co } -//------------------------------------------------- -// adjust_ui_seqs_for_keyboard - make adjustments -// to UI seqs in response to the existence of a -// keyboard -//------------------------------------------------- - -void ioport_manager::adjust_ui_seqs_for_keyboard() -{ - // track used keys in a bool array - bool used_keys[ITEM_ID_MAXIMUM]; - memset(used_keys, 0, sizeof(used_keys)); - - // iterate over ports and fields - for (ioport_port *port = first_port(); port != NULL; port = port->next()) - { - for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) - { - // if we are at init, check IPT_KEYBOARD - if (field->type() == IPT_KEYBOARD && (!m_safe_to_read || field->enabled())) - { - const input_seq &defseq = field->defseq(); - for (int codenum = 0; defseq[codenum] != input_seq::end_code; codenum++) - { - input_code code = defseq[codenum]; - if (!code.internal() && !is_modifier_item_id(code.item_id())) - used_keys[code.item_id()] = true; - } - } - } - } - - // now that we know which keys are used by keyboards, lets take a look at the UI - // shortcuts - for (input_type_entry *curtype = first_type(); curtype != NULL; curtype = curtype->next()) - { - // we're only interested in "shortcut" UI keys - if (curtype->group() == IPG_UI_SHORTCUT) - { - const input_seq &defseq = curtype->defseq(); - for (int codenum = 0; defseq[codenum] != input_seq::end_code; codenum++) - { - input_code code = defseq[codenum]; - if (!code.internal() && !is_modifier_item_id(code.item_id()) && used_keys[code.item_id()]) - { - // this shortcut is used by the keyboard; clear it - curtype->defseq().set(); - curtype->restore_default_seq(); - break; - } - } - } - - // special case - change UI_CONFIGURE to be ScrLk on computers - if (curtype->type() == IPT_UI_CONFIGURE) - { - curtype->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_SCRLOCK); - curtype->restore_default_seq(); - } - } -} - - -//------------------------------------------------- -// is_modifier_item_id - do we consider this input -// item id a modifier? -//------------------------------------------------- - -bool ioport_manager::is_modifier_item_id(input_item_id item_id) -{ - return (item_id == ITEM_ID_LSHIFT) - || (item_id == ITEM_ID_LSHIFT) - || (item_id == ITEM_ID_RSHIFT) - || (item_id == ITEM_ID_LCONTROL) - || (item_id == ITEM_ID_RCONTROL) - || (item_id == ITEM_ID_LALT) - || (item_id == ITEM_ID_RALT) - || (item_id == ITEM_ID_LWIN) - || (item_id == ITEM_ID_RWIN); -} - - //------------------------------------------------- // exit - exit callback to ensure we clean up // and close our files diff --git a/src/emu/ioport.h b/src/emu/ioport.h index 769a7693274..620f1b513ec 100644 --- a/src/emu/ioport.h +++ b/src/emu/ioport.h @@ -72,8 +72,7 @@ enum crosshair_axis_t // groups for input ports enum ioport_group { - IPG_UI_GENERAL = 0, - IPG_UI_SHORTCUT, + IPG_UI = 0, IPG_PLAYER1, IPG_PLAYER2, IPG_PLAYER3, @@ -334,7 +333,6 @@ enum ioport_type IPT_UI_ON_SCREEN_DISPLAY, IPT_UI_DEBUG_BREAK, IPT_UI_PAUSE, - IPT_UI_SINGLE_STEP, IPT_UI_RESET_MACHINE, IPT_UI_SOFT_RESET, IPT_UI_SHOW_GFX, @@ -364,18 +362,11 @@ enum ioport_type IPT_UI_NEXT_GROUP, IPT_UI_ROTATE, IPT_UI_SHOW_PROFILER, - IPT_UI_EXIT, + IPT_UI_TOGGLE_UI, IPT_UI_TOGGLE_DEBUG, IPT_UI_PASTE, IPT_UI_SAVE_STATE, IPT_UI_LOAD_STATE, - IPT_UI_SHORTCUTS_ENABLED, - - // dummy slots that will likely be filled soon (putting these in as a temporary convenience) - IPT_UI_DUMMY1, - IPT_UI_DUMMY2, - IPT_UI_DUMMY3, - IPT_UI_DUMMY4, // additional OSD-specified UI port types (up to 16) IPT_OSD_1, @@ -1400,8 +1391,6 @@ public: private: // internal helpers void init_port_types(); - void adjust_ui_seqs_for_keyboard(); - static bool is_modifier_item_id(input_item_id item_id); void init_autoselect_devices(int type1, int type2, int type3, const char *option, const char *ananame); void frame_update_callback(); diff --git a/src/emu/machine.c b/src/emu/machine.c index 37ae528576f..481625eb410 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -80,7 +80,6 @@ #include "crsshair.h" #include "validity.h" #include "unzip.h" -#include "ui/selgame.h" #include "debug/debugcon.h" #include "debug/debugvw.h" diff --git a/src/emu/ui/emenubar.c b/src/emu/ui/emenubar.c deleted file mode 100644 index fe30a69796d..00000000000 --- a/src/emu/ui/emenubar.c +++ /dev/null @@ -1,659 +0,0 @@ -/*************************************************************************** - - emenubar.c - - Internal MAME menu bar for the user interface. - - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. - -***************************************************************************/ - -#include "emu.h" -#include "ui/emenubar.h" -#include "ui/selgame.h" -#include "ui/miscmenu.h" -#include "ui/filesel.h" -#include "ui/imginfo.h" -#include "ui/tapectrl.h" -#include "ui/swlist.h" -#include "ui/viewgfx.h" -#include "ui/barcode.h" -#include "softlist.h" -#include "cheat.h" -#include "debugger.h" - - -//************************************************************************** -// CONSTANTS -//************************************************************************** - -#ifdef MAME_PROFILER -#define HAS_PROFILER 1 -#else // !MAME_PROFILER -#define HAS_PROFILER 0 -#endif // MAME_PROFILER - - -//************************************************************************** -// MENUBAR IMPLEMENTATION -//************************************************************************** - -astring ui_emu_menubar::s_softlist_result; -device_image_interface *ui_emu_menubar::s_softlist_image; - - -//------------------------------------------------- -// ctor -//------------------------------------------------- - -ui_emu_menubar::ui_emu_menubar(running_machine &machine) - : ui_menubar(machine) -{ -} - - -//------------------------------------------------- -// handle -//------------------------------------------------- - -void ui_emu_menubar::handle(render_container *container) -{ - // check to see if we have a softlist selection - if (s_softlist_result.len() > 0) - { - // do the load - s_softlist_image->load(s_softlist_result); - - // clear out state - s_softlist_image = NULL; - s_softlist_result.reset(); - } - - // call inherited method - ui_menubar::handle(container); -} - - -//------------------------------------------------- -// start_menu -//------------------------------------------------- - -void ui_emu_menubar::start_menu(ui_menu *menu) -{ - machine().ui().set_handler(ui_menu::ui_handler, 0); - ui_menu::stack_push(menu); -} - - -//------------------------------------------------- -// start_menu -//------------------------------------------------- - -template -void ui_emu_menubar::start_menu() -{ - start_menu(auto_alloc_clear(machine(), _Menu(machine(), container()))); -} - - -//------------------------------------------------- -// menubar_draw_ui_elements -//------------------------------------------------- - -void ui_emu_menubar::menubar_draw_ui_elements() -{ - // first draw the FPS counter - if (machine().ui().show_fps_counter()) - { - astring tempstring; - machine().ui().draw_text_full(container(), machine().video().speed_text(tempstring), 0.0f, 0.0f, 1.0f, - JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL); - } - - // draw the profiler if visible - if (machine().ui().show_profiler()) - { - const char *text = g_profiler.text(machine()); - machine().ui().draw_text_full(container(), text, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL); - } - - // if we're single-stepping, pause now - if (machine().ui().single_step()) - { - machine().pause(); - machine().ui().set_single_step(false); - } - - // check for fast forward - if (machine().ioport().type_pressed(IPT_UI_FAST_FORWARD)) - { - machine().video().set_fastforward(true); - machine().ui().show_fps_temp(0.5); - } - else - machine().video().set_fastforward(false); - -} - - -//------------------------------------------------- -// menubar_build_menus -//------------------------------------------------- - -void ui_emu_menubar::menubar_build_menus() -{ - // build normal menus - build_file_menu(); - if (has_images()) - build_images_menu(); - build_options_menu(); - build_settings_menu(); - build_help_menu(); - - // and customize them - machine().osd().customize_menubar(*this); -} - - -//------------------------------------------------- -// build_file_menu -//------------------------------------------------- - -void ui_emu_menubar::build_file_menu() -{ - astring menu_text; - menu_item &file_menu = root_menu().append("File"); - - // show gfx - if (ui_gfx_is_relevant(machine())) - file_menu.append("Show Graphics/Palette...", &ui_emu_menubar::set_ui_handler, *this, ui_gfx_ui_handler, (UINT32) machine().paused(), IPT_UI_SHOW_GFX); - - // save screen snapshot - file_menu.append("Save Screen Snapshot(s)", &video_manager::save_active_screen_snapshots, machine().video(), IPT_UI_SNAPSHOT); - - // record movie - menu_item &record_movie_menu = file_menu.append("Record Movie", &video_manager::toggle_record_movie, machine().video(), IPT_UI_RECORD_MOVIE); - record_movie_menu.set_checked(machine().video().is_recording()); - - // save state - file_menu.append("Save State...", &ui_emu_menubar::set_ui_handler, *this, ui_manager::ui_handler_load_save, (UINT32) LOADSAVE_SAVE, IPT_UI_SAVE_STATE); - - // load state - file_menu.append("Load State...", &ui_emu_menubar::set_ui_handler, *this, ui_manager::ui_handler_load_save, (UINT32) LOADSAVE_LOAD, IPT_UI_LOAD_STATE); - - // separator - file_menu.append_separator(); - - // paste - if (machine().ioport().has_keyboard() && machine().ioport().natkeyboard().can_post()) - { - menu_item &paste_menu = file_menu.append("Paste", &ui_manager::paste, machine().ui(), IPT_UI_PASTE); - paste_menu.set_enabled(machine().ui().can_paste()); - } - - // debug - if (machine().debug_flags & DEBUG_FLAG_ENABLED) - file_menu.append("Break into debugger", &ui_emu_menubar::debugger_break, *this, IPT_UI_TOGGLE_DEBUG); - - // pause - menu_item &pause_menu = file_menu.append("Pause", &running_machine::toggle_pause, machine(), IPT_UI_PAUSE); - pause_menu.set_checked(machine().paused()); - - // single step - file_menu.append("Single Step", &ui_manager::do_single_step, machine().ui(), IPT_UI_SINGLE_STEP); - - // reset - menu_item &reset_menu = file_menu.append("Reset"); - reset_menu.append("Hard", &running_machine::schedule_hard_reset, machine(), IPT_UI_RESET_MACHINE); - reset_menu.append("Soft", &running_machine::schedule_soft_reset, machine(), IPT_UI_SOFT_RESET); - - // separator - file_menu.append_separator(); - - // select new game - menu_text.printf("Select New %s...", emulator_info::get_capstartgamenoun()); - file_menu.append(menu_text, &ui_emu_menubar::select_new_game, *this); - - // exit - file_menu.append("Exit", &ui_manager::request_quit, machine().ui(), IPT_UI_EXIT); -} - - -//------------------------------------------------- -// build_images_menu -//------------------------------------------------- - -void ui_emu_menubar::build_images_menu() -{ - // add the root "Images" menu - menu_item &images_menu = root_menu().append("Images"); - - // loop through all devices - image_interface_iterator iter(machine().root_device()); - for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) - { - bool is_loaded = image->basename() != NULL; - - astring buffer; - buffer.printf("%s (%s): \t%s", - image->device().name(), - image->brief_instance_name(), - is_loaded ? image->basename() : "[empty]"); - - // append the menu item for this device - menu_item &menu = images_menu.append(buffer); - - // software list - if (image->image_interface() != NULL) - { - if (build_software_list_menus(menu, image)) - menu.append_separator(); - } - - // load - menu.append("Load...", &ui_emu_menubar::load, *this, image); - - // unload - menu_item &unload_menu = menu.append("Unload", &device_image_interface::unload, *image); - unload_menu.set_enabled(is_loaded); - - // tape control - cassette_image_device *cassette = dynamic_cast(image); - if (cassette != NULL) - { - menu_item &control_menu = menu.append("Tape Control...", &ui_emu_menubar::tape_control, *this, cassette); - control_menu.set_enabled(is_loaded); - } - } -} - - -//------------------------------------------------- -// build_software_list_menus -//------------------------------------------------- - -bool ui_emu_menubar::build_software_list_menus(menu_item &menu, device_image_interface *image) -{ - int item_count = 0; - menu_item *last_menu_item = NULL; - astring description; - softlist_type types[] = { SOFTWARE_LIST_ORIGINAL_SYSTEM, SOFTWARE_LIST_COMPATIBLE_SYSTEM }; - software_list_device_iterator softlist_iter(machine().config().root_device()); - - // first do "original system" softlists, then do compatible ones - for (int typenum = 0; typenum < ARRAY_LENGTH(types); typenum++) - { - for (software_list_device *swlist = softlist_iter.first(); swlist != NULL; swlist = softlist_iter.next()) - { - if ((swlist->list_type() == types[typenum]) && is_softlist_relevant(swlist, image->image_interface(), description)) - { - // we've found a softlist; append the menu item - last_menu_item = &menu.append(description, &ui_emu_menubar::select_from_software_list, *this, image, swlist); - item_count++; - } - } - } - - // if we only had one list, lets use a generic name - if (last_menu_item != NULL && (item_count == 1)) - last_menu_item->set_text("Software list..."); - - return item_count > 0; -} - - -//------------------------------------------------- -// build_options_menu -//------------------------------------------------- - -void ui_emu_menubar::build_options_menu() -{ - astring menu_text; - menu_item &options_menu = root_menu().append("Options"); - - // throttle - float throttle_rates[] = { 10.0f, 5.0f, 2.0f, 1.0f, 0.5f, 0.2f, 0.1f, 0.0f }; - float current_throttle_rate = machine().video().throttled() - ? machine().video().throttle_rate() - : 0.0f; - menu_item &throttle_menu = options_menu.append("Throttle"); - for (int i = 0; i < ARRAY_LENGTH(throttle_rates); i++) - { - const char *item = "Unthrottled"; - if (throttle_rates[i] != 0) - { - menu_text.printf("%d%%", (int) (throttle_rates[i] * 100)); - item = menu_text; - } - - menu_item &menu = throttle_menu.append(item, &ui_emu_menubar::set_throttle_rate, *this, throttle_rates[i]); - menu.set_checked(current_throttle_rate == throttle_rates[i]); - } - - // frame skip - menu_item &frameskip_menu = options_menu.append("Frame Skip"); - for (int i = -1; i <= MAX_FRAMESKIP; i++) - { - const char *item = "Auto"; - if (i >= 0) - { - menu_text.printf("%d", i); - item = menu_text; - } - - menu_item &menu = frameskip_menu.append(item, &video_manager::set_frameskip, machine().video(), i); - menu.set_checked(machine().video().frameskip() == i); - } - - // separator - frameskip_menu.append_separator(); - - // increase - frameskip_menu.append("Increase", &ui_manager::increase_frameskip, machine().ui(), IPT_UI_FRAMESKIP_INC); - - // decrease - frameskip_menu.append("Decrease", &ui_manager::decrease_frameskip, machine().ui(), IPT_UI_FRAMESKIP_DEC); - - // show fps - options_menu.append("Show Frames Per Second", &ui_manager::set_show_fps, &ui_manager::show_fps, machine().ui(), IPT_UI_SHOW_FPS); - - // show profiler - if (HAS_PROFILER) - options_menu.append("Show Profiler", &ui_manager::set_show_profiler, &ui_manager::show_profiler, machine().ui(), IPT_UI_SHOW_PROFILER); - - // video - // do different things if we actually have multiple render targets - menu_item &video_menu = options_menu.append("Video"); - if (machine().render().target_by_index(1) != NULL) - { - // multiple targets - int targetnum = 0; - render_target *target; - while((target = machine().render().target_by_index(targetnum)) != NULL) - { - astring buffer; - buffer.printf("Screen #%d", targetnum++); - menu_item &target_menu = options_menu.append(buffer); - build_video_target_menu(target_menu, *target); - } - } - else - { - // single target - build_video_target_menu(video_menu, *machine().render().first_target()); - } - - // separator - options_menu.append_separator(); - - // slot devices - slot_interface_iterator slotiter(machine().root_device()); - if (slotiter.first() != NULL) - options_menu.append("Slot Devices...", &ui_emu_menubar::start_menu, *this); - - // barcode reader - barcode_reader_device_iterator bcriter(machine().root_device()); - if (bcriter.first() != NULL) - options_menu.append("Barcode Reader...", &ui_emu_menubar::start_menu, *this); - - // network devices - network_interface_iterator netiter(machine().root_device()); - if (netiter.first() != NULL) - options_menu.append("Network Devices...", &ui_emu_menubar::start_menu, *this); - - // keyboard - if (machine().ioport().has_keyboard() && machine().ioport().natkeyboard().can_post()) - { - menu_item &keyboard_menu = options_menu.append("Keyboard"); - keyboard_menu.append("Emulated", &ui_manager::set_use_natural_keyboard, &ui_manager::use_natural_keyboard, machine().ui(), false); - keyboard_menu.append("Natural", &ui_manager::set_use_natural_keyboard, &ui_manager::use_natural_keyboard, machine().ui(), true); - } - - // crosshair options - if (crosshair_get_usage(machine())) - options_menu.append("Crosshair Options...", &ui_emu_menubar::start_menu, *this); - - // memory card - if (machine().config().m_memcard_handler != NULL) - options_menu.append("Memory Card...", &ui_emu_menubar::start_menu, *this); - - // shortcuts enabled - menu_item &shortcuts_enabled_item = options_menu.append("Menu Shorcuts Enabled", &ui_manager::set_shortcuts_enabled, &ui_manager::shortcuts_enabled, machine().ui(), IPT_UI_SHORTCUTS_ENABLED); - shortcuts_enabled_item.set_shortcut_always_enabled(true); - - // cheat - if (machine().options().cheat() && machine().cheat().first() != NULL) - { - options_menu.append_separator(); - options_menu.append("Cheats enabled", &cheat_manager::set_enable, &cheat_manager::enabled, machine().cheat(), IPT_UI_TOGGLE_CHEAT); - options_menu.append("Cheat...", &ui_emu_menubar::start_menu, *this); - } -} - - -//------------------------------------------------- -// build_video_target_menu -//------------------------------------------------- - -void ui_emu_menubar::build_video_target_menu(menu_item &target_menu, render_target &target) -{ - astring tempstring; - const char *view_name; - - // add the menu items for each view - for(int viewnum = 0; (view_name = target.view_name(viewnum)) != NULL; viewnum++) - { - // replace spaces with underscores - tempstring.cpy(view_name).replace(0, "_", " "); - - // append the menu - target_menu.append(tempstring, &render_target::set_view, &render_target::view, target, viewnum); - } - - // separator - target_menu.append_separator(); - - // rotation - menu_item &rotation_menu = target_menu.append("Rotation"); - rotation_menu.append("None", &render_target::set_orientation, &render_target::orientation, target, ROT0); - rotation_menu.append("Clockwise 90", &render_target::set_orientation, &render_target::orientation, target, ROT90); - rotation_menu.append("180", &render_target::set_orientation, &render_target::orientation, target, ROT180); - rotation_menu.append("Counterclockwise 90", &render_target::set_orientation, &render_target::orientation, target, ROT270); - - // show backdrops - target_menu.append("Show Backdrops", &render_target::set_backdrops_enabled, &render_target::backdrops_enabled, target); - - // show overlay - target_menu.append("Show Overlays", &render_target::set_overlays_enabled, &render_target::overlays_enabled, target); - - // show bezel - target_menu.append("Show Bezels", &render_target::set_bezels_enabled, &render_target::bezels_enabled, target); - - // show cpanel - target_menu.append("Show CPanels", &render_target::set_cpanels_enabled, &render_target::cpanels_enabled, target); - - // show marquee - target_menu.append("Show Marquees", &render_target::set_marquees_enabled, &render_target::marquees_enabled, target); - - // view - menu_item &view_menu = target_menu.append("View"); - view_menu.append("Cropped", &render_target::set_zoom_to_screen, &render_target::zoom_to_screen, target, true); - view_menu.append("Full", &render_target::set_zoom_to_screen, &render_target::zoom_to_screen, target, false); -} - - -//------------------------------------------------- -// build_settings_menu -//------------------------------------------------- - -void ui_emu_menubar::build_settings_menu() -{ - astring menu_text; - menu_item &settings_menu = root_menu().append("Settings"); - - // general input - // TODO - BREAK THIS APART? - settings_menu.append("General Input...", &ui_emu_menubar::start_menu, *this); - - // game input - menu_text.printf("%s Input...", emulator_info::get_capstartgamenoun()); - settings_menu.append(menu_text, &ui_emu_menubar::start_menu, *this); - - // analog controls - if (machine().ioport().has_analog()) - settings_menu.append("Analog Controls...", &ui_emu_menubar::start_menu, *this); - - // dip switches - if (machine().ioport().has_dips()) - settings_menu.append("Dip Switches...", &ui_emu_menubar::start_menu, *this); - - // driver configuration - if (machine().ioport().has_configs()) - { - menu_text.printf("%s Configuration...", emulator_info::get_capstartgamenoun()); - settings_menu.append(menu_text, &ui_emu_menubar::start_menu, *this); - } - - // bios selection - if (machine().ioport().has_bioses()) - settings_menu.append("Bios Selection...", &ui_emu_menubar::start_menu, *this); - - // sliders - settings_menu.append("Sliders...", &ui_emu_menubar::start_menu, *this, IPT_UI_ON_SCREEN_DISPLAY); -} - - -//------------------------------------------------- -// build_help_menu -//------------------------------------------------- - -void ui_emu_menubar::build_help_menu() -{ - astring menu_text; - menu_item &help_menu = root_menu().append("Help"); - - // bookkeeping info - help_menu.append("Bookkeeping info...", &ui_emu_menubar::start_menu, *this); - - // game info - menu_text.printf("%s Information...", emulator_info::get_capstartgamenoun()); - help_menu.append(menu_text, &ui_emu_menubar::start_menu, *this); - - // image information - image_interface_iterator imgiter(machine().root_device()); - if (imgiter.first() != NULL) - help_menu.append("Image Information...", &ui_emu_menubar::start_menu, *this); -} - - -//------------------------------------------------- -// is_softlist_relevant -//------------------------------------------------- - -bool ui_emu_menubar::is_softlist_relevant(software_list_device *swlist, const char *interface, astring &list_description) -{ - bool result = false; - - for (software_info *swinfo = swlist->first_software_info(); swinfo != NULL; swinfo = swinfo->next()) - { - software_part *part = swinfo->find_part(NULL, NULL); - if (part->matches_interface(interface)) - { - list_description.printf("%s...", swlist->description()); - result = true; - break; - } - } - - return result; -} - - -//------------------------------------------------- -// set_ui_handler -//------------------------------------------------- - -void ui_emu_menubar::set_ui_handler(ui_callback callback, UINT32 param) -{ - // first pause - machine().pause(); - - // and transfer control - machine().ui().set_handler(callback, param); -} - - -//------------------------------------------------- -// select_new_game -//------------------------------------------------- - -void ui_emu_menubar::select_new_game() -{ - start_menu(auto_alloc_clear(machine(), ui_menu_select_game(machine(), container(), machine().system().name))); -} - - -//------------------------------------------------- -// select_from_software_list -//------------------------------------------------- - -void ui_emu_menubar::select_from_software_list(device_image_interface *image, software_list_device *swlist) -{ - s_softlist_image = image; - start_menu(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container(), swlist, image->image_interface(), s_softlist_result))); -} - - -//------------------------------------------------- -// tape_control -//------------------------------------------------- - -void ui_emu_menubar::tape_control(cassette_image_device *image) -{ - start_menu(auto_alloc_clear(machine(), ui_menu_mess_tape_control(machine(), container(), image))); -} - - -//------------------------------------------------- -// load -//------------------------------------------------- - -void ui_emu_menubar::load(device_image_interface *image) -{ - start_menu(image->get_selection_menu(machine(), container())); -} - - -//------------------------------------------------- -// has_images -//------------------------------------------------- - -bool ui_emu_menubar::has_images() -{ - image_interface_iterator iter(machine().root_device()); - return iter.first() != NULL; -} - - -//------------------------------------------------- -// set_throttle_rate -//------------------------------------------------- - -void ui_emu_menubar::set_throttle_rate(float throttle_rate) -{ - machine().video().set_throttled(throttle_rate != 0.0); - if (throttle_rate != 0.0) - machine().video().set_throttle_rate(throttle_rate); -} - - -//------------------------------------------------- -// debugger_break -//------------------------------------------------- - -void ui_emu_menubar::debugger_break() -{ - ::debugger_break(machine()); -} - diff --git a/src/emu/ui/emenubar.h b/src/emu/ui/emenubar.h deleted file mode 100644 index c2274db16c5..00000000000 --- a/src/emu/ui/emenubar.h +++ /dev/null @@ -1,64 +0,0 @@ -/*************************************************************************** - - emenubar.h - - Internal MAME menu bar for the user interface. - - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. - -***************************************************************************/ - -#pragma once - -#ifndef __UI_EMENUBAR_H__ -#define __UI_EMENUBAR_H__ - -#include "ui/menubar.h" -#include "imagedev/cassette.h" -#include "imagedev/bitbngr.h" - -class ui_emu_menubar : public ui_menubar -{ -public: - ui_emu_menubar(running_machine &machine); - - virtual void handle(render_container *container); - -protected: - virtual void menubar_build_menus(); - virtual void menubar_draw_ui_elements(); - -private: - // variables - static device_image_interface *s_softlist_image; - static astring s_softlist_result; - - // menubar building - void build_file_menu(); - void build_images_menu(); - bool build_software_list_menus(menu_item &menu, device_image_interface *image); - void build_options_menu(); - void build_video_target_menu(menu_item &target_menu, render_target &target); - void build_settings_menu(); - void build_help_menu(); - - // miscellaneous - bool is_softlist_relevant(software_list_device *swlist, const char *interface, astring &list_description); - void set_ui_handler(UINT32 (*callback)(running_machine &, render_container *, UINT32), UINT32 param); - void select_new_game(); - void select_from_software_list(device_image_interface *image, software_list_device *swlist); - void tape_control(cassette_image_device *image); - void load(device_image_interface *image); - bool has_images(); - void set_throttle_rate(float throttle_rate); - void start_menu(ui_menu *menu); - void debugger_break(); - - // template methods - template - void start_menu(); -}; - - -#endif // __UI_EMENUBAR_H__ diff --git a/src/emu/ui/filemngr.c b/src/emu/ui/filemngr.c new file mode 100644 index 00000000000..ef7bb0838e1 --- /dev/null +++ b/src/emu/ui/filemngr.c @@ -0,0 +1,136 @@ +/********************************************************************* + + ui/filemngr.c + + MESS's clunky built-in file manager + + TODO + - Restrict directory listing by file extension + - Support file manager invocation from the main menu for + required images + +*********************************************************************/ + +#include +#include +#include + +#include "emu.h" +#include "ui/ui.h" +#include "ui/swlist.h" +#include "ui/filemngr.h" +#include "ui/filesel.h" + + +/*************************************************************************** + FILE MANAGER +***************************************************************************/ + +//------------------------------------------------- +// ctor +//------------------------------------------------- + +ui_menu_file_manager::ui_menu_file_manager(running_machine &machine, render_container *container) : ui_menu(machine, container) +{ +} + + +//------------------------------------------------- +// dtor +//------------------------------------------------- + +ui_menu_file_manager::~ui_menu_file_manager() +{ +} + + +//------------------------------------------------- +// custom_render - perform our special rendering +//------------------------------------------------- + +void ui_menu_file_manager::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) +{ + const char *path; + + // access the path + path = selected_device ? selected_device->filename() : NULL; + extra_text_render(container, top, bottom, + origx1, origy1, origx2, origy2, NULL, path); +} + + +//------------------------------------------------- +// populate +//------------------------------------------------- + +void ui_menu_file_manager::populate() +{ + astring buffer; + astring tmp_name; + + // cycle through all devices for this system + image_interface_iterator iter(machine().root_device()); + for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) + { + // get the image type/id + buffer.printf( + "%s (%s)", + image->device().name(), image->brief_instance_name()); + + // get the base name + if (image->basename() != NULL) + { + tmp_name.cpy(image->basename()); + + // if the image has been loaded through softlist, also show the loaded part + if (image->part_entry() != NULL) + { + const software_part *tmp = image->part_entry(); + if (tmp->name() != NULL) + { + tmp_name.cat(" ("); + tmp_name.cat(tmp->name()); + // also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it + if (image->get_feature("part_id") != NULL) + { + tmp_name.cat(": "); + tmp_name.cat(image->get_feature("part_id")); + } + tmp_name.cat(")"); + } + } + } + else + tmp_name.cpy("---"); + + // record the menu item + item_append(buffer, tmp_name.cstr(), 0, (void *) image); + } + + custombottom = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER; +} + + +//------------------------------------------------- +// handle +//------------------------------------------------- + +void ui_menu_file_manager::handle() +{ + // update the selected device + selected_device = (device_image_interface *) get_selection(); + + // process the menu + const ui_menu_event *event = process(0); + if (event != NULL && event->iptkey == IPT_UI_SELECT) + { + selected_device = (device_image_interface *) event->itemref; + if (selected_device != NULL) + { + ui_menu::stack_push(selected_device->get_selection_menu(machine(), container)); + + // reset the existing menu + reset(UI_MENU_RESET_REMEMBER_POSITION); + } + } +} diff --git a/src/emu/ui/filemngr.h b/src/emu/ui/filemngr.h new file mode 100644 index 00000000000..c515aaeff2e --- /dev/null +++ b/src/emu/ui/filemngr.h @@ -0,0 +1,30 @@ +/*************************************************************************** + + ui/filemngr.h + + MESS's clunky built-in file manager + + Copyright Nicola Salmoria and the MAME Team. + Visit http://mamedev.org for licensing and usage restrictions. + +***************************************************************************/ + +#pragma once + +#ifndef __UI_FILEMNGR_H__ +#define __UI_FILEMNGR_H__ + +class ui_menu_file_manager : public ui_menu { +public: + astring current_directory; + astring current_file; + device_image_interface *selected_device; + + ui_menu_file_manager(running_machine &machine, render_container *container); + virtual ~ui_menu_file_manager(); + virtual void populate(); + virtual void handle(); + virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2); +}; + +#endif /* __UI_FILEMNGR_H__ */ diff --git a/src/emu/ui/filesel.c b/src/emu/ui/filesel.c index a42a4038367..403ccb4268e 100644 --- a/src/emu/ui/filesel.c +++ b/src/emu/ui/filesel.c @@ -342,13 +342,14 @@ void ui_menu_file_create::handle() // ctor //------------------------------------------------- -ui_menu_file_selector::ui_menu_file_selector(running_machine &machine, render_container *container, device_image_interface *image, astring ¤t_directory, astring ¤t_file, bool has_empty, bool has_create, int *result) - : ui_menu(machine, container), - m_current_directory(current_directory), - m_current_file(current_file) +ui_menu_file_selector::ui_menu_file_selector(running_machine &machine, render_container *container, device_image_interface *image, astring ¤t_directory, astring ¤t_file, bool has_empty, bool has_softlist, bool has_create, int *result) + : ui_menu(machine, container), + m_current_directory(current_directory), + m_current_file(current_file) { m_image = image; m_has_empty = has_empty; + m_has_softlist = has_softlist; m_has_create = has_create; m_result = result; } @@ -505,6 +506,10 @@ void ui_menu_file_selector::append_entry_menu_item(const file_selector_entry *en text = "[create]"; break; + case SELECTOR_ENTRY_TYPE_SOFTWARE_LIST: + text = "[software list]"; + break; + case SELECTOR_ENTRY_TYPE_DRIVE: text = entry->basename; subtext = "[DRIVE]"; @@ -559,6 +564,12 @@ void ui_menu_file_selector::populate() append_entry(SELECTOR_ENTRY_TYPE_CREATE, NULL, NULL); } + if (m_has_softlist) + { + // add the "[software list]" entry + append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, NULL, NULL); + } + // add the drives i = 0; while((volume_name = osd_get_volume_name(i))!=NULL) @@ -636,6 +647,11 @@ void ui_menu_file_selector::handle() ui_menu::stack_pop(machine()); break; + case SELECTOR_ENTRY_TYPE_SOFTWARE_LIST: + *m_result = R_SOFTLIST; + ui_menu::stack_pop(machine()); + break; + case SELECTOR_ENTRY_TYPE_DRIVE: case SELECTOR_ENTRY_TYPE_DIRECTORY: // drive/directory - first check the path diff --git a/src/emu/ui/filesel.h b/src/emu/ui/filesel.h index 6e7e34cdc59..f32e87cf7b7 100644 --- a/src/emu/ui/filesel.h +++ b/src/emu/ui/filesel.h @@ -54,8 +54,8 @@ private: class ui_menu_file_selector : public ui_menu { public: - enum { R_EMPTY, R_CREATE, R_FILE }; - ui_menu_file_selector(running_machine &machine, render_container *container, device_image_interface *image, astring ¤t_directory, astring ¤t_file, bool has_empty, bool has_create, int *result); + enum { R_EMPTY, R_SOFTLIST, R_CREATE, R_FILE }; + ui_menu_file_selector(running_machine &machine, render_container *container, device_image_interface *image, astring ¤t_directory, astring ¤t_file, bool has_empty, bool has_softlist, bool has_create, int *result); virtual ~ui_menu_file_selector(); virtual void populate(); virtual void handle(); @@ -66,6 +66,7 @@ private: { SELECTOR_ENTRY_TYPE_EMPTY, SELECTOR_ENTRY_TYPE_CREATE, + SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, SELECTOR_ENTRY_TYPE_DRIVE, SELECTOR_ENTRY_TYPE_DIRECTORY, SELECTOR_ENTRY_TYPE_FILE @@ -85,7 +86,7 @@ private: astring & m_current_directory; astring & m_current_file; bool m_has_empty; -// bool m_has_softlist; + bool m_has_softlist; bool m_has_create; int * m_result; file_selector_entry * m_entrylist; diff --git a/src/emu/ui/imgcntrl.c b/src/emu/ui/imgcntrl.c index a2bd3d36ae9..7d451863d5f 100644 --- a/src/emu/ui/imgcntrl.c +++ b/src/emu/ui/imgcntrl.c @@ -173,11 +173,48 @@ void ui_menu_control_device_image::handle() zippath_closedir(directory); } submenu_result = -1; - ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_selector(machine(), container, image, current_directory, current_file, true, can_create, &submenu_result))); + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_selector(machine(), container, image, current_directory, current_file, true, image->image_interface()!=NULL, can_create, &submenu_result))); state = SELECT_FILE; break; } + case START_SOFTLIST: + sld = 0; + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software(machine(), container, image->image_interface(), &sld))); + state = SELECT_SOFTLIST; + break; + + case START_OTHER_PART: { + submenu_result = -1; + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, swi, swp->interface(), &swp, true, &submenu_result))); + state = SELECT_OTHER_PART; + break; + } + + case SELECT_SOFTLIST: + if(!sld) { + ui_menu::stack_pop(machine()); + break; + } + software_info_name = ""; + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container, sld, image->image_interface(), software_info_name))); + state = SELECT_PARTLIST; + break; + + case SELECT_PARTLIST: + swi = sld->find(software_info_name); + if(swi->has_multiple_parts(image->image_interface())) { + submenu_result = -1; + swp = 0; + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, swi, image->image_interface(), &swp, false, &submenu_result))); + state = SELECT_ONE_PART; + } else { + swp = swi->first_part(); + load_software_part(); + ui_menu::stack_pop(machine()); + } + break; + case SELECT_ONE_PART: switch(submenu_result) { case ui_menu_software_parts::T_ENTRY: { @@ -228,6 +265,11 @@ void ui_menu_control_device_image::handle() state = CREATE_FILE; break; + case ui_menu_file_selector::R_SOFTLIST: + state = START_SOFTLIST; + handle(); + break; + case -1: // return to system ui_menu::stack_pop(machine()); break; diff --git a/src/emu/ui/mainmenu.c b/src/emu/ui/mainmenu.c new file mode 100644 index 00000000000..06a3d0e54b5 --- /dev/null +++ b/src/emu/ui/mainmenu.c @@ -0,0 +1,248 @@ +/********************************************************************* + + ui/mainmenu.c + + Internal MAME menus for the user interface. + + Copyright Nicola Salmoria and the MAME Team. + Visit http://mamedev.org for licensing and usage restrictions. + +*********************************************************************/ + +#include "emu.h" +#include "osdnet.h" +#include "emuopts.h" +#include "ui/ui.h" +#include "rendutil.h" +#include "cheat.h" +#include "uiinput.h" +#include "ui/filemngr.h" +#include "ui/filesel.h" +#include "ui/barcode.h" +#include "ui/tapectrl.h" +#include "ui/mainmenu.h" +#include "ui/miscmenu.h" +#include "ui/imginfo.h" +#include "ui/selgame.h" +#include "audit.h" +#include "crsshair.h" +#include +#include "imagedev/cassette.h" +#include "imagedev/bitbngr.h" +#include "machine/bcreader.h" + + + +/*************************************************************************** + MENU HANDLERS +***************************************************************************/ + +/*------------------------------------------------- + ui_menu_main constructor - populate the main menu +-------------------------------------------------*/ + +ui_menu_main::ui_menu_main(running_machine &machine, render_container *container) : ui_menu(machine, container) +{ +} + +void ui_menu_main::populate() +{ + astring menu_text; + + /* add input menu items */ + item_append("Input (general)", NULL, 0, (void *)INPUT_GROUPS); + + menu_text.printf("Input (this %s)",emulator_info::get_capstartgamenoun()); + item_append(menu_text.cstr(), NULL, 0, (void *)INPUT_SPECIFIC); + + /* add optional input-related menus */ + if (machine().ioport().has_analog()) + item_append("Analog Controls", NULL, 0, (void *)ANALOG); + if (machine().ioport().has_dips()) + item_append("Dip Switches", NULL, 0, (void *)SETTINGS_DIP_SWITCHES); + if (machine().ioport().has_configs()) + { + menu_text.printf("%s Configuration",emulator_info::get_capstartgamenoun()); + item_append(menu_text.cstr(), NULL, 0, (void *)SETTINGS_DRIVER_CONFIG); + } + + /* add bookkeeping menu */ + item_append("Bookkeeping Info", NULL, 0, (void *)BOOKKEEPING); + + /* add game info menu */ + menu_text.printf("%s Information",emulator_info::get_capstartgamenoun()); + item_append(menu_text.cstr(), NULL, 0, (void *)GAME_INFO); + + image_interface_iterator imgiter(machine().root_device()); + if (imgiter.first() != NULL) + { + /* add image info menu */ + item_append("Image Information", NULL, 0, (void *)IMAGE_MENU_IMAGE_INFO); + + /* add file manager menu */ + item_append("File Manager", NULL, 0, (void *)IMAGE_MENU_FILE_MANAGER); + + /* 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); + } + + if (machine().ioport().has_bioses()) + item_append("Bios Selection", NULL, 0, (void *)BIOS_SELECTION); + + slot_interface_iterator slotiter(machine().root_device()); + if (slotiter.first() != NULL) + { + /* add slot info menu */ + item_append("Slot Devices", NULL, 0, (void *)SLOT_DEVICES); + } + + barcode_reader_device_iterator bcriter(machine().root_device()); + if (bcriter.first() != NULL) + { + /* add slot info menu */ + item_append("Barcode Reader", NULL, 0, (void *)BARCODE_READ); + } + + network_interface_iterator netiter(machine().root_device()); + if (netiter.first() != NULL) + { + /* add image info menu */ + item_append("Network Devices", NULL, 0, (void*)NETWORK_DEVICES); + } + + /* add keyboard mode menu */ + if (machine().ioport().has_keyboard() && machine().ioport().natkeyboard().can_post()) + item_append("Keyboard Mode", NULL, 0, (void *)KEYBOARD_MODE); + + /* add sliders menu */ + item_append("Slider Controls", NULL, 0, (void *)SLIDERS); + + /* add video options menu */ + item_append("Video Options", NULL, 0, (machine().render().target_by_index(1) != NULL) ? (void *)VIDEO_TARGETS : (void *)VIDEO_OPTIONS); + + /* add crosshair options menu */ + if (crosshair_get_usage(machine())) + item_append("Crosshair Options", NULL, 0, (void *)CROSSHAIR); + + /* add cheat menu */ + if (machine().options().cheat() && machine().cheat().first() != NULL) + item_append("Cheat", NULL, 0, (void *)CHEAT); + + /* add memory card menu */ + if (machine().config().m_memcard_handler != NULL) + item_append("Memory Card", NULL, 0, (void *)MEMORY_CARD); + + /* add reset and exit menus */ + menu_text.printf("Select New %s",emulator_info::get_capstartgamenoun()); + item_append(menu_text.cstr(), NULL, 0, (void *)SELECT_GAME); +} + +ui_menu_main::~ui_menu_main() +{ +} + +/*------------------------------------------------- + menu_main - handle the main menu +-------------------------------------------------*/ + +void ui_menu_main::handle() +{ + /* process the menu */ + const ui_menu_event *menu_event = process(0); + if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT) { + switch((long long)(menu_event->itemref)) { + case INPUT_GROUPS: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_groups(machine(), container))); + break; + + case INPUT_SPECIFIC: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_input_specific(machine(), container))); + break; + + case SETTINGS_DIP_SWITCHES: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_settings_dip_switches(machine(), container))); + break; + + case SETTINGS_DRIVER_CONFIG: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_settings_driver_config(machine(), container))); + break; + + case ANALOG: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_analog(machine(), container))); + break; + + case BOOKKEEPING: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_bookkeeping(machine(), container))); + break; + + case GAME_INFO: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_game_info(machine(), container))); + break; + + case IMAGE_MENU_IMAGE_INFO: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_image_info(machine(), container))); + break; + + case IMAGE_MENU_FILE_MANAGER: + 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))); + break; + + case SLOT_DEVICES: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_slot_devices(machine(), container))); + break; + + case NETWORK_DEVICES: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_network_devices(machine(), container))); + break; + + case KEYBOARD_MODE: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_keyboard_mode(machine(), container))); + break; + + case SLIDERS: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_sliders(machine(), container, false))); + break; + + case VIDEO_TARGETS: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_video_targets(machine(), container))); + break; + + case VIDEO_OPTIONS: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_video_options(machine(), container, machine().render().first_target()))); + break; + + case CROSSHAIR: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_crosshair(machine(), container))); + break; + + case CHEAT: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_cheat(machine(), container))); + break; + + case MEMORY_CARD: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_memory_card(machine(), container))); + break; + + case SELECT_GAME: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_select_game(machine(), container, 0))); + break; + + case BIOS_SELECTION: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_bios_selection(machine(), container))); + break; + + case BARCODE_READ: + ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_barcode_reader(machine(), container))); + break; + + default: + fatalerror("ui_menu_main::handle - unknown reference\n"); + } + } +} diff --git a/src/emu/ui/mainmenu.h b/src/emu/ui/mainmenu.h new file mode 100644 index 00000000000..c585062d632 --- /dev/null +++ b/src/emu/ui/mainmenu.h @@ -0,0 +1,54 @@ +/*************************************************************************** + + ui/mainmenu.h + + Internal MAME menus for the user interface. + + Copyright Nicola Salmoria and the MAME Team. + Visit http://mamedev.org for licensing and usage restrictions. + +***************************************************************************/ + +#pragma once + +#ifndef __UI_MAINMENU_H__ +#define __UI_MAINMENU_H__ + +#include "crsshair.h" +#include "drivenum.h" + +class ui_menu_main : public ui_menu { +public: + ui_menu_main(running_machine &machine, render_container *container); + virtual ~ui_menu_main(); + virtual void populate(); + virtual void handle(); + +private: + enum { + INPUT_GROUPS, + INPUT_SPECIFIC, + SETTINGS_DIP_SWITCHES, + SETTINGS_DRIVER_CONFIG, + ANALOG, + BOOKKEEPING, + GAME_INFO, + IMAGE_MENU_IMAGE_INFO, + IMAGE_MENU_FILE_MANAGER, + MESS_MENU_TAPE_CONTROL, + SLOT_DEVICES, + NETWORK_DEVICES, + KEYBOARD_MODE, + SLIDERS, + VIDEO_TARGETS, + VIDEO_OPTIONS, + CROSSHAIR, + CHEAT, + MEMORY_CARD, + SELECT_GAME, + BIOS_SELECTION, + BARCODE_READ, + }; +}; + +#endif /* __UI_MAINMENU_H__ */ diff --git a/src/emu/ui/menu.c b/src/emu/ui/menu.c index babb2aa04e6..6e5c8f09297 100644 --- a/src/emu/ui/menu.c +++ b/src/emu/ui/menu.c @@ -15,7 +15,7 @@ #include "rendutil.h" #include "uiinput.h" #include "cheat.h" -#include "ui/emenubar.h" +#include "ui/mainmenu.h" #include "ui/miscmenu.h" #include @@ -1038,8 +1038,9 @@ void ui_menu::do_handle() UINT32 ui_menu::ui_handler(running_machine &machine, render_container *container, UINT32 state) { - // if we have no menus stacked up, we have to have something - assert(menu_stack != NULL); + // if we have no menus stacked up, start with the main menu + if (menu_stack == NULL) + stack_push(auto_alloc_clear(machine, ui_menu_main(machine, container))); // update the menu state if (menu_stack != NULL) diff --git a/src/emu/ui/menubar.c b/src/emu/ui/menubar.c deleted file mode 100644 index ba4b6fd80d5..00000000000 --- a/src/emu/ui/menubar.c +++ /dev/null @@ -1,1125 +0,0 @@ -/*************************************************************************** - - menubar.c - - Internal MAME menu bar for the user interface. - - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. - -***************************************************************************/ - -#include "emu.h" -#include "ui/menubar.h" -#include "ui/ui.h" -#include "uiinput.h" - - -//************************************************************************** -// CONSTANTS -//************************************************************************** - -#define CHECKMARK "x " -#define SEPARATOR_HEIGHT 0.25 - - -//************************************************************************** -// CLASSES -//************************************************************************** - -class tabbed_text_iterator -{ -public: - tabbed_text_iterator(const char *text); - bool next(); - int index() const { return m_index; } - const char *current() { return m_current; } - -private: - astring m_buffer; - const char * m_text; - const char * m_current; - int m_position; - int m_index; -}; - - -//************************************************************************** -// MENUBAR IMPLEMENTATION -//************************************************************************** - -//------------------------------------------------- -// ctor -//------------------------------------------------- - -ui_menubar::ui_menubar(running_machine &machine) - : m_machine(machine), m_menus(*this) -{ - m_container = NULL; - m_shortcuted_menu_items = NULL; - m_selected_item = NULL; - m_active_item = NULL; - m_dragged = false; - m_checkmark_width = -1; - m_mouse_x = -1; - m_mouse_y = -1; - m_mouse_button = false; - m_last_mouse_move = 0; - m_first_time = true; -} - - -//------------------------------------------------- -// dtor -//------------------------------------------------- - -ui_menubar::~ui_menubar() -{ -} - - -//------------------------------------------------- -// reset -//------------------------------------------------- - -void ui_menubar::reset() -{ -} - - -//------------------------------------------------- -// input_pressed_safe -//------------------------------------------------- - -bool ui_menubar::input_pressed_safe(int key) -{ - return (key != IPT_INVALID) && ui_input_pressed(machine(), key); -} - - -//------------------------------------------------- -// handle -//------------------------------------------------- - -void ui_menubar::handle(render_container *current_container) -{ - m_container = current_container; - - // do we need to initialize the menus? - if (m_menus.is_empty()) - menubar_build_menus(); - - // measure standard string widths (if necessary) - if (m_checkmark_width <= 0) - m_checkmark_width = machine().ui().get_string_width(CHECKMARK); - - // reset screen locations of all menu items - m_menus.clear_area_recursive(); - - // calculate visibility of the menubar - m_menubar_visibility = get_menubar_visibility(); - - // draw conventional UI elements (e.g. - frameskip) - menubar_draw_ui_elements(); - - float text_height = machine().ui().get_line_height(); - float spacing = text_height / 10; - float x = spacing; - float y = spacing; - - for(menu_item *mi = m_menus.child(); mi != NULL; mi = mi->next()) - { - float width = machine().ui().get_string_width(mi->text()); - - machine().ui().draw_outlined_box( - container(), - x, - y, - x + width + (spacing * 2), - y + text_height + (spacing * 2), - adjust_color(UI_BORDER_COLOR), - adjust_color(UI_BACKGROUND_COLOR)); - - draw_menu_item_text( - mi, - x + spacing, - y + spacing, - x + spacing + width, - y + spacing + text_height, - false); - - // child menu open? - if (is_child_menu_visible(mi)) - draw_child_menu(mi, x, y + text_height + (spacing * 3)); - - x += width + spacing * 4; - } - - // loop while we have interesting events - while(!event_loop()) - { - } -} - - -//------------------------------------------------- -// event_loop -//------------------------------------------------- - -bool ui_menubar::event_loop() -{ - bool done = false; - - ui_event local_menu_event; - if (ui_input_pop_event(machine(), &local_menu_event)) - { - // find the menu item we're pointing at - find_mouse(m_mouse_x, m_mouse_y, m_mouse_button); - menu_item *mi = m_menus.find_point(m_mouse_x, m_mouse_y); - - switch (local_menu_event.event_type) - { - case UI_EVENT_MOUSE_DOWN: - if (mi != NULL) - { - m_selected_item = mi; - m_active_item = mi; - m_dragged = false; - } - break; - - case UI_EVENT_MOUSE_MOVE: - // record the move - m_last_mouse_move = osd_ticks(); - - // moving is only interesting if we have an active menu selection - if (m_mouse_button && m_active_item != NULL) - { - // are we changing the active menu item? - if (m_active_item != mi) - { - if (mi != NULL) - m_active_item = mi->has_children() ? mi->child() : mi; - m_dragged = true; - done = true; - } - - // are we changing the selection? - if (m_selected_item != mi) - { - m_selected_item = mi; - done = true; - } - } - break; - - case UI_EVENT_MOUSE_UP: - m_active_item = NULL; - if (m_selected_item && m_selected_item == mi) - { - // looks like we did a mouse up on the current selection; we - // should invoke or expand the current selection (whichever - // may be appropriate) - if (m_selected_item->is_invokable()) - invoke(m_selected_item); - else if (m_selected_item->has_children()) - m_active_item = m_selected_item->child(); - } - else if (m_dragged) - { - m_selected_item = NULL; - } - done = true; - break; - - default: - break; - } - } - - if (!done) - { - bool navigation_input_pressed = poll_navigation_keys(); - poll_shortcut_keys(navigation_input_pressed || m_first_time); - m_first_time = false; - done = true; - } - return done; -} - - -//------------------------------------------------- -// poll_navigation_keys -//------------------------------------------------- - -bool ui_menubar::poll_navigation_keys() -{ - int code_previous_menu = IPT_INVALID; - int code_next_menu = IPT_INVALID; - int code_child_menu1 = IPT_INVALID; - int code_child_menu2 = IPT_INVALID; - int code_parent_menu = IPT_INVALID; - int code_previous_sub_menu = IPT_INVALID; - int code_next_sub_menu = IPT_INVALID; - int code_selected = (m_selected_item && m_selected_item->is_invokable()) - ? IPT_UI_SELECT - : IPT_INVALID; - - // are we navigating the menu? - if (m_selected_item != NULL) - { - // if so, are we in a pull down menu? - if (!m_selected_item->is_sub_menu()) - { - // no pull down menu selected - code_previous_menu = IPT_UI_LEFT; - code_next_menu = IPT_UI_RIGHT; - code_child_menu1 = IPT_UI_SELECT; - code_child_menu2 = IPT_UI_DOWN; - } - else - { - // pull down menu selected - code_previous_menu = IPT_UI_UP; - code_next_menu = IPT_UI_DOWN; - if (m_selected_item->child()) - { - code_child_menu1 = IPT_UI_SELECT; - code_child_menu2 = IPT_UI_RIGHT; - } - code_previous_sub_menu = IPT_UI_LEFT; - code_next_sub_menu = IPT_UI_RIGHT; - if (m_selected_item->parent()->is_sub_menu()) - code_parent_menu = IPT_UI_LEFT; - } - } - - bool result = true; - if (input_pressed_safe(code_previous_menu)) - result = walk_selection_previous(); - else if (input_pressed_safe(code_next_menu)) - result = walk_selection_next(); - else if (input_pressed_safe(code_child_menu1) || input_pressed_safe(code_child_menu2)) - result = walk_selection_child(); - else if (input_pressed_safe(IPT_UI_CANCEL)) - result = walk_selection_escape(); - else if (input_pressed_safe(code_parent_menu)) - result = walk_selection_parent(); - else if (input_pressed_safe(code_previous_sub_menu)) - result = walk_selection_previous_sub_menu(); - else if (input_pressed_safe(code_next_sub_menu)) - result = walk_selection_next_sub_menu(); - else if (machine().ui().shortcuts_enabled() && input_pressed_safe(IPT_UI_CONFIGURE)) - toggle_selection(); - else if (input_pressed_safe(code_selected)) - invoke(m_selected_item); - else - result = false; // didn't do anything - - // if we changed something, set the active item accordingly - if (result) - m_active_item = m_selected_item; - - return result; -} - - -//------------------------------------------------- -// poll_shortcut_keys -//------------------------------------------------- - -bool ui_menubar::poll_shortcut_keys(bool swallow) -{ - // loop through all shortcut items - for (menu_item *item = m_shortcuted_menu_items; item != NULL; item = item->next_with_shortcut()) - { - // sanity check - assert(item->is_invokable()); - - // should we check the shortcut? - if (machine().ui().shortcuts_enabled() || item->is_shortcut_always_enabled()) - { - // did we press this shortcut? - if (input_pressed_safe(item->shortcut()) && !swallow) - { - // this shortcut was pressed and we're not swallowing them; invoke it - invoke(item); - return true; - } - } - } - return false; -} - - -//------------------------------------------------- -// toggle_selection -//------------------------------------------------- - -void ui_menubar::toggle_selection() -{ - m_selected_item = m_selected_item != NULL - ? NULL - : m_menus.child(); -} - - -//------------------------------------------------- -// invoke -//------------------------------------------------- - -void ui_menubar::invoke(menu_item *menu) -{ - // first, we're ending the menu; pop us off first - machine().ui().set_handler(NULL, 0); - - // and invoke the selection - menu->invoke(); -} - - -//------------------------------------------------- -// walk_selection_previous -//------------------------------------------------- - -bool ui_menubar::walk_selection_previous() -{ - if (m_selected_item) - { - do - { - m_selected_item = m_selected_item->previous() - ? m_selected_item->previous() - : m_selected_item->parent()->last_child(); - } - while(!m_selected_item->is_enabled()); - } - else - { - m_selected_item = m_menus.last_child(); - } - return true; -} - - -//------------------------------------------------- -// walk_selection_next -//------------------------------------------------- - -bool ui_menubar::walk_selection_next() -{ - if (m_selected_item) - { - do - { - m_selected_item = m_selected_item->next() - ? m_selected_item->next() - : m_selected_item->parent()->child(); - } - while(!m_selected_item->is_enabled()); - } - else - { - m_selected_item = m_menus.child(); - } - return true; -} - - -//------------------------------------------------- -// walk_selection_child -//------------------------------------------------- - -bool ui_menubar::walk_selection_child() -{ - bool result = false; - if (m_selected_item && m_selected_item->child()) - { - m_selected_item = m_selected_item->child(); - result = true; - } - return result; -} - - -//------------------------------------------------- -// walk_selection_parent -//------------------------------------------------- - -bool ui_menubar::walk_selection_parent() -{ - bool result = false; - if (m_selected_item && m_selected_item->parent() && m_selected_item->parent() != &m_menus) - { - m_selected_item = m_selected_item->parent(); - result = true; - } - return result; -} - - -//------------------------------------------------- -// walk_selection_escape -//------------------------------------------------- - -bool ui_menubar::walk_selection_escape() -{ - bool result = walk_selection_parent(); - - if (!result && m_selected_item != NULL) - { - m_selected_item = NULL; - result = true; - } - - return result; -} - - -//------------------------------------------------- -// walk_selection_previous_sub_menu -//------------------------------------------------- - -bool ui_menubar::walk_selection_previous_sub_menu() -{ - while(walk_selection_parent()) - ; - bool result = walk_selection_previous(); - if (result) - walk_selection_child(); - return result; -} - - -//------------------------------------------------- -// walk_selection_next_sub_menu -//------------------------------------------------- - -bool ui_menubar::walk_selection_next_sub_menu() -{ - while(walk_selection_parent()) - ; - bool result = walk_selection_next(); - if (result) - walk_selection_child(); - return result; -} - - -//------------------------------------------------- -// draw_child_menu -//------------------------------------------------- - -void ui_menubar::draw_child_menu(menu_item *menu, float x, float y) -{ - float text_height = machine().ui().get_line_height(); - float separator_height = text_height * SEPARATOR_HEIGHT; - float spacing = text_height / 10; - - // calculate the maximum width and menu item count - float max_widths[4] = {0, }; - float total_height = (spacing * 2); - float max_shortcuts_width = 0; - for(menu_item *mi = menu->child(); mi != NULL; mi = mi->next()) - { - // aggregate the maximum width for each column - tabbed_text_iterator iter(mi->text()); - while(iter.next()) - { - float width = machine().ui().get_string_width(iter.current()); - assert(iter.index() < ARRAY_LENGTH(max_widths)); - max_widths[iter.index()] = MAX(max_widths[iter.index()], width); - } - - // measure the shortcut - float shortcut_width = mi->shortcut_text_width(); - if (shortcut_width > 0) - max_shortcuts_width = MAX(max_shortcuts_width, shortcut_width + spacing); - - // increase the height - total_height += (mi->is_separator() ? separator_height : text_height); - } - - // get the aggregate maximum widths across all columns - float max_width = m_checkmark_width * 2 + max_shortcuts_width; - for (int i = 0; i < ARRAY_LENGTH(max_widths); i++) - max_width += max_widths[i]; - - // are we going to go over the right of the screen? - float right = x + max_width + (spacing * 3); - if (right > 1.0f) - x = MAX(0.0f, x - (right - 1.0f)); - - // draw the menu outline - machine().ui().draw_outlined_box( - container(), - x, - y, - x + max_width + (spacing * 2), - y + total_height, - adjust_color(UI_BACKGROUND_COLOR)); - - // draw the individual items - float my = y; - for(menu_item *mi = menu->child(); mi != NULL; mi = mi->next()) - { - if (mi->is_separator()) - { - // draw separator - container()->add_line( - x, - my + spacing + separator_height / 2, - x + max_width + (spacing * 2), - my + spacing + separator_height / 2, - separator_height / 8, - adjust_color(UI_BORDER_COLOR), - 0); - } - else - { - // draw normal text - draw_menu_item_text( - mi, - x + spacing, - my + spacing, - x + spacing + max_width, - my + spacing + text_height, - true, - max_widths); - } - - // move down... - my += (mi->is_separator() ? separator_height : text_height); - } - - // draw child menus - my = y; - for(menu_item *mi = menu->child(); mi != NULL; mi = mi->next()) - { - // child menu open? - if (!mi->is_separator() && is_child_menu_visible(mi)) - { - draw_child_menu( - mi, - x + max_width + (spacing * 2), - my); - } - - // move down... - my += (mi->is_separator() ? separator_height : text_height); - } -} - - -//------------------------------------------------- -// is_child_menu_visible -//------------------------------------------------- - -bool ui_menubar::is_child_menu_visible(menu_item *menu) const -{ - menu_item *current_menu = m_active_item ? m_active_item : m_selected_item; - return current_menu && current_menu->is_child_of(menu); -} - - -//------------------------------------------------- -// draw_menu_item_text -//------------------------------------------------- - -void ui_menubar::draw_menu_item_text(menu_item *mi, float x0, float y0, float x1, float y1, bool decorations, const float *column_widths) -{ - // set our area - mi->set_area(x0, y0, x1, y1); - - // choose the color - rgb_t fgcolor, bgcolor; - if (!mi->is_enabled()) - { - // disabled - fgcolor = UI_UNAVAILABLE_COLOR; - bgcolor = UI_TEXT_BG_COLOR; - } - else if (is_highlighted_selection(mi)) - { - // selected - fgcolor = UI_SELECTED_COLOR; - bgcolor = UI_SELECTED_BG_COLOR; - } - else if ((m_mouse_x >= x0) && (m_mouse_x < x1) && (m_mouse_y >= y0) && (m_mouse_y < y1)) - { - // hover - fgcolor = UI_MOUSEOVER_COLOR; - bgcolor = UI_MOUSEOVER_BG_COLOR; - } - else - { - // normal - fgcolor = UI_TEXT_COLOR; - bgcolor = UI_TEXT_BG_COLOR; - } - - // highlight? - if (bgcolor != UI_TEXT_BG_COLOR) - ui_menu::highlight(container(), x0, y0, x1, y1, adjust_color(bgcolor)); - - // do we have to draw additional decorations? - if (decorations) - { - // account for the checkbox - if (mi->is_checked()) - machine().ui().draw_text_full(container(), CHECKMARK, x0, y0, 1.0f - x0, JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, adjust_color(fgcolor), adjust_color(bgcolor)); - x0 += m_checkmark_width; - - // expanders? - if (mi->child()) - { - float lr_arrow_width = 0.4f * (y1 - y0) * machine().render().ui_aspect(); - ui_menu::draw_arrow( - container(), - x1 - lr_arrow_width, - y0 + (0.1f * (y1 - y0)), - x1, - y0 + (0.9f * (y1 - y0)), - adjust_color(fgcolor), - ROT90); - } - - // shortcut? - machine().ui().draw_text_full( - container(), - mi->shortcut_text(), - x0, - y0, - x1 - x0, - JUSTIFY_RIGHT, - WRAP_WORD, - DRAW_NORMAL, - adjust_color(fgcolor), - adjust_color(bgcolor)); - } - - tabbed_text_iterator iter(mi->text()); - while(iter.next()) - { - machine().ui().draw_text_full(container(), iter.current(), x0, y0, 1.0f - x0, JUSTIFY_LEFT, WRAP_WORD, DRAW_NORMAL, adjust_color(fgcolor), adjust_color(bgcolor)); - if (column_widths != NULL) - x0 += column_widths[iter.index()]; - } -} - - -//------------------------------------------------- -// is_highlighted_selection -//------------------------------------------------- - -bool ui_menubar::is_highlighted_selection(menu_item *mi) -{ - bool result = false; - - if (mi == m_selected_item) - { - // this item _is_ the selection - result = true; - } - else if (m_selected_item != NULL) - { - // walk up the menu hierarchy; we want to also highlight ancestor sub menus - menu_item *selected_item_ancestor = m_selected_item; - do - { - selected_item_ancestor = selected_item_ancestor->parent(); - result = mi == selected_item_ancestor; - } - while(!result && selected_item_ancestor != &root_menu()); - } - return result; -} - - -//------------------------------------------------- -// find_mouse -//------------------------------------------------- - -bool ui_menubar::find_mouse(float &mouse_x, float &mouse_y, bool &mouse_button) -{ - bool result = false; - mouse_x = -1; - mouse_y = -1; - - INT32 mouse_target_x, mouse_target_y; - render_target *mouse_target = ui_input_find_mouse(machine(), &mouse_target_x, &mouse_target_y, &mouse_button); - if (mouse_target != NULL) - { - if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, *container(), mouse_x, mouse_y)) - result = true; - } - - return result; -} - - -//------------------------------------------------- -// get_menubar_visibility -//------------------------------------------------- - -ui_menubar::menubar_visibility_t ui_menubar::get_menubar_visibility() -{ - menubar_visibility_t result; - - // is the mouse in the menu bar? - bool in_menu_bar = (m_mouse_y >= 0) && (m_mouse_y <= machine().ui().get_line_height()); - - // did we recently move the mouse? - bool recently_moved = (m_last_mouse_move != 0) - && ((osd_ticks() - m_last_mouse_move) * 5 / osd_ticks_per_second() < 1); - - // make the choice - if ((m_selected_item != NULL) || (m_active_item != NULL)) - result = MENUBAR_VISIBILITY_VISIBLE; - else if (in_menu_bar || recently_moved) - result = MENUBAR_VISIBILITY_TRANSLUCENT; - else - result = MENUBAR_VISIBILITY_INVISIBLE; - - return result; -} - - -//------------------------------------------------- -// adjust_color -//------------------------------------------------- - -rgb_t ui_menubar::adjust_color(rgb_t color) -{ - switch(m_menubar_visibility) - { - case MENUBAR_VISIBILITY_INVISIBLE: - color = rgb_t(0, 0, 0, 0); - break; - - case MENUBAR_VISIBILITY_TRANSLUCENT: - color = rgb_t( - color.a() / 4, - color.r(), - color.g(), - color.b()); - break; - - case MENUBAR_VISIBILITY_VISIBLE: - default: - // do nothing - break; - } - return color; -} - - -//************************************************************************** -// MENU ITEMS -//************************************************************************** - -//------------------------------------------------- -// menu_item::ctor -//------------------------------------------------- - -ui_menubar::menu_item::menu_item(ui_menubar &menubar, const char *text, ui_menubar::menu_item *parent, bool is_invokable, int shortcut) - : m_menubar(menubar) -{ - if (text != NULL) - m_text.cpy(text); - m_is_invokable = is_invokable; - m_parent = parent; - m_first_child = NULL; - m_last_child = NULL; - m_previous = NULL; - m_next = NULL; - m_is_checked = false; - m_is_enabled = true; - m_is_separator = false; - m_is_shortcut_always_enabled = false; - m_shortcut = shortcut; - m_shortcut_text_width = -1; - clear_area(); -} - - -//------------------------------------------------- -// menu_item::dtor -//------------------------------------------------- - -ui_menubar::menu_item::~menu_item() -{ - menu_item *mi = m_first_child; - while (mi) - { - menu_item *next = mi->m_next; - delete mi; - mi = next; - } -} - - -//------------------------------------------------- -// menu_item::set_area -//------------------------------------------------- - -void ui_menubar::menu_item::set_area(float x0, float y0, float x1, float y1) -{ - m_x0 = x0; - m_y0 = y0; - m_x1 = x1; - m_y1 = y1; -} - - -//------------------------------------------------- -// menu_item::clear_area_recursive -//------------------------------------------------- - -void ui_menubar::menu_item::clear_area_recursive() -{ - clear_area(); - if (m_first_child) - m_first_child->clear_area_recursive(); - if (m_next) - m_next->clear_area_recursive(); -} - - -//------------------------------------------------- -// menu_item::initialize -//------------------------------------------------- - -void ui_menubar::menu_item::initialize(ui_menubar::menu_item &child) -{ - // link this back to the previous item - child.m_previous = m_last_child; - - // link the end of the chain to this new item - if (m_last_child) - m_last_child->m_next = &child; - else - m_first_child = &child; - - // this new child is now last in the chain - m_last_child = &child; - - // link this up into the shortcut list, if appropriate - if (child.shortcut() != 0) - { - child.set_next_with_shortcut(m_menubar.m_shortcuted_menu_items); - m_menubar.m_shortcuted_menu_items = &child; - } -} - - -//------------------------------------------------- -// menu_item::append -//------------------------------------------------- - -ui_menubar::menu_item &ui_menubar::menu_item::append(const char *text) -{ - menu_item *child = new menu_item(m_menubar, text, this); - initialize(*child); - return *child; -} - - -//------------------------------------------------- -// menu_item::append_separator -//------------------------------------------------- - -void ui_menubar::menu_item::append_separator() -{ - menu_item &separator = append("-"); - separator.set_enabled(false); - separator.m_is_separator = true; -} - - -//------------------------------------------------- -// menu_item::find_point -//------------------------------------------------- - -ui_menubar::menu_item *ui_menubar::menu_item::find_point(float x, float y) -{ - menu_item *result = NULL; - - if (m_is_enabled && (x >= m_x0) && (y >= m_y0) && (x <= m_x1) && (y <= m_y1)) - result = this; - - if (!result && m_first_child) - result = m_first_child->find_point(x, y); - if (!result && m_next) - result = m_next->find_point(x, y); - return result; -} - - -//------------------------------------------------- -// menu_item::find_child -//------------------------------------------------- - -ui_menubar::menu_item &ui_menubar::menu_item::find_child(const char *target) -{ - menu_item *item = find_child_internal(target); - assert(item != NULL); - return *item; -} - - -//------------------------------------------------- -// menu_item::find_child_internal -//------------------------------------------------- - -ui_menubar::menu_item *ui_menubar::menu_item::find_child_internal(const char *target) -{ - if (!strcmp(target, text())) - return this; - - for(menu_item *item = child(); item != NULL; item = item->next()) - { - menu_item *result = item->find_child_internal(target); - if (result != NULL) - return result; - } - return NULL; -} - - -//------------------------------------------------- -// menu_item::shortcut_text -//------------------------------------------------- - -const char *ui_menubar::menu_item::shortcut_text() -{ - // do we have to calculate this stuff? - if (m_shortcut_text_width < 0) - { - // clear the text - m_shortcut_text.cpy(""); - - // first, do we even have a shortcut? - if (shortcut() != 0) - { - // iterate over the input ports and add menu items - for (input_type_entry *entry = m_menubar.machine().ioport().first_type(); entry != NULL; entry = entry->next()) - { - // add if we match the group and we have a valid name */ - if (entry->group() == IPG_UI_SHORTCUT && entry->name() != NULL && entry->name()[0] != 0 && entry->type() == shortcut()) - { - const input_seq &seq = m_menubar.machine().ioport().type_seq(entry->type(), entry->player(), SEQ_TYPE_STANDARD); - sensible_seq_name(m_shortcut_text, seq); - break; - } - } - } - - // finally calculate the text width - m_shortcut_text_width = m_menubar.machine().ui().get_string_width(m_shortcut_text); - } - - // return the text - return m_shortcut_text; -} - - -//------------------------------------------------- -// menu_item::shortcut_text_width -//------------------------------------------------- - -float ui_menubar::menu_item::shortcut_text_width() -{ - // force a calculation, if we didn't have one - shortcut_text(); - - // and return the text width - return m_shortcut_text_width; -} - - -//------------------------------------------------- -// menu_item::sensible_seq_name -//------------------------------------------------- - -void ui_menubar::menu_item::sensible_seq_name(astring &text, const input_seq &seq) -{ - // special case; we don't want 'None' - if (seq[0] == input_seq::end_code) - text.cpy(""); - else - m_menubar.machine().input().seq_name(text, seq); -} - - -//------------------------------------------------- -// menu_item::is_child_of -//------------------------------------------------- - -bool ui_menubar::menu_item::is_child_of(ui_menubar::menu_item *that) const -{ - for(menu_item *mi = m_parent; mi != NULL; mi = mi->m_parent) - { - if (mi == that) - return true; - } - return false; -} - - -//------------------------------------------------- -// menu_item::invoke -//------------------------------------------------- - -void ui_menubar::menu_item::invoke() -{ - // do nothing -} - - -//************************************************************************** -// TABBED TEXT ITERATOR -//************************************************************************** - -//------------------------------------------------- -// tabbed_text_iterator::ctor -//------------------------------------------------- - -tabbed_text_iterator::tabbed_text_iterator(const char *text) -{ - m_text = text; - m_current = NULL; - m_position = 0; - m_index = -1; -} - - -//------------------------------------------------- -// tabbed_text_iterator::next -//------------------------------------------------- - -bool tabbed_text_iterator::next() -{ - const char *current_text = &m_text[m_position]; - const char *tabpos = strchr(current_text, '\t'); - - if (tabpos != NULL) - { - int count = tabpos - current_text; - m_buffer.cpy(current_text, count); - m_position += count + 1; - m_current = m_buffer; - m_index++; - } - else if (*current_text != '\0') - { - m_current = current_text; - m_position += strlen(m_current); - m_index++; - } - else - { - m_current = NULL; - } - return m_current != NULL; -} diff --git a/src/emu/ui/menubar.h b/src/emu/ui/menubar.h deleted file mode 100644 index 646289de669..00000000000 --- a/src/emu/ui/menubar.h +++ /dev/null @@ -1,261 +0,0 @@ -/*************************************************************************** - - menubar.h - - Internal MAME menu bar for the user interface. - - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. - -***************************************************************************/ - -#pragma once - -#ifndef __UI_MENUBAR_H__ -#define __UI_MENUBAR_H__ - -#include "render.h" - - -//************************************************************************** -// MENU BAR -//************************************************************************** - -class ui_menubar -{ -public: - ui_menubar(running_machine &machine); - virtual ~ui_menubar(); - - // menu item - class menu_item - { - public: - menu_item(ui_menubar &menubar, const char *text = NULL, menu_item *parent = NULL, bool is_invokable = false, int shortcut = 0); - virtual ~menu_item(); - - // methods - menu_item &append(const char *text); - void append_separator(); - bool is_child_of(menu_item *that) const; - virtual void invoke(); - void clear_area_recursive(); - menu_item *find_point(float x, float y); - menu_item &find_child(const char *target); - const char *shortcut_text(); - float shortcut_text_width(); - void sensible_seq_name(astring &text, const input_seq &seq); - - // template methods; look I tried to use delegate.h but I got humbled... - template menu_item &append(const char *text, void (_Target::*callback)(), _Target &obj, int shortcut = 0) - { - menu_item *child = new invokable_menu_item<_Target>(m_menubar, text, this, callback, obj, shortcut); - initialize(*child); - return *child; - } - template menu_item &append(const char *text, void (_Target::*callback)(_Arg), _Target &obj, _Arg arg, int shortcut = 0) - { - menu_item *child = new arg_invokable_menu_item<_Target, _Arg>(m_menubar, text, this, callback, obj, arg, shortcut); - initialize(*child); - return *child; - } - template menu_item &append(const char *text, void (_Target::*callback)(_Arg1, _Arg2), _Target &obj, _Arg1 arg1, _Arg2 arg2, int shortcut = 0) - { - menu_item *child = new arg2_invokable_menu_item<_Target, _Arg1, _Arg2>(m_menubar, text, this, callback, obj, arg1, arg2, shortcut); - initialize(*child); - return *child; - } - template menu_item &append(const char *text, void (_Target::*set_callback)(bool), bool (_Target::*get_callback)() const, _Target &obj, int shortcut = 0) - { - // tailored for a toggle - bool current_value = ((obj).*(get_callback))(); - menu_item &menu = append(text, set_callback, obj, !current_value, shortcut); - menu.set_checked(current_value); - return menu; - } - template menu_item &append(const char *text, void (_Target::*set_callback)(_Arg), _Arg (_Target::*get_callback)() const, _Target &obj, _Arg arg, int shortcut = 0) - { - // tailored for a set operation - _Arg current_value = ((obj).*(get_callback))(); - menu_item &menu = append(text, set_callback, obj, arg, shortcut); - menu.set_checked(current_value == arg); - return menu; - } - - // getters - bool is_empty() const { return !m_first_child; } - bool is_invokable() const { return m_is_invokable; } - bool is_checked() const { return m_is_checked; } - bool is_enabled() const { return m_is_enabled; } - bool is_separator() const { return m_is_separator; } - bool has_children() const { return m_first_child ? true : false; } - bool is_shortcut_always_enabled() const { return m_is_shortcut_always_enabled; } - int shortcut() const { return m_shortcut; } - const astring &text() const { return m_text; } - menu_item *parent() { return m_parent; } - menu_item *child() { return m_first_child; } - menu_item *last_child() { return m_last_child; } - menu_item *previous() { return m_previous; } - menu_item *next() { return m_next; } - menu_item *next_with_shortcut() { return m_next_with_shortcut; } - bool is_sub_menu() const { return m_parent && m_parent->m_parent; } - - // setters - void set_area(float x0, float y0, float x1, float y1); - void clear_area() { set_area(-1, -1, -1, -1); } - void set_checked(bool checked) { m_is_checked = checked; } - void set_enabled(bool enabled) { m_is_enabled = enabled; } - void set_text(const char *text) { m_text.cpy(text); } - void set_next_with_shortcut(menu_item *item) { m_next_with_shortcut = item; } - void set_shortcut_always_enabled(bool shortcut_always_enabled) { m_is_shortcut_always_enabled = shortcut_always_enabled; } - - private: - // private variables - ui_menubar & m_menubar; - astring m_text; - int m_shortcut; - astring m_shortcut_text; - float m_shortcut_text_width; - bool m_is_invokable; - bool m_is_checked; - bool m_is_enabled; - bool m_is_separator; - bool m_is_shortcut_always_enabled; - menu_item * m_parent; - menu_item * m_first_child; - menu_item * m_last_child; - menu_item * m_previous; - menu_item * m_next; - menu_item * m_next_with_shortcut; - float m_x0; - float m_y0; - float m_x1; - float m_y1; - - // private methods - void initialize(menu_item &child); - menu_item *find_child_internal(const char *target); - }; - - // methods - virtual void reset(); - virtual void handle(render_container *container); - - // getters - bool is_visible() const { return m_menubar_visibility != MENUBAR_VISIBILITY_INVISIBLE; } - bool has_selection() const { return m_selected_item != NULL; } - menu_item &root_menu() { return m_menus; } - -protected: - // implemented by child classes - virtual void menubar_build_menus() = 0; - virtual void menubar_draw_ui_elements() = 0; - - // accessors - running_machine &machine() { return m_machine; } - render_container *container() { return m_container; } - -private: - // classes - template - class invokable_menu_item : public menu_item - { - public: - invokable_menu_item(ui_menubar &menubar, const char *name, menu_item *parent, void (_Target::*callback)(), _Target &obj, int shortcut) - : menu_item(menubar, name, parent, true, shortcut), m_callback(callback), m_obj(obj) - { - } - - virtual void invoke() { ((m_obj).*(m_callback))(); } - - private: - void (_Target::*m_callback)(); - _Target &m_obj; - }; - - template - class arg_invokable_menu_item : public menu_item - { - public: - arg_invokable_menu_item(ui_menubar &menubar, const char *name, menu_item *parent, void (_Target::*callback)(_Arg), _Target &obj, _Arg arg, int shortcut) - : menu_item(menubar, name, parent, true, shortcut), m_callback(callback), m_obj(obj), m_arg(arg) - { - } - - virtual void invoke() { ((m_obj).*(m_callback))(m_arg); } - - private: - void (_Target::*m_callback)(_Arg); - _Target &m_obj; - _Arg m_arg; - }; - - template - class arg2_invokable_menu_item : public menu_item - { - public: - arg2_invokable_menu_item(ui_menubar &menubar, const char *name, menu_item *parent, void (_Target::*callback)(_Arg1, _Arg2), _Target &obj, _Arg1 arg1, _Arg2 arg2, int shortcut) - : menu_item(menubar, name, parent, true, shortcut), m_callback(callback), m_obj(obj), m_arg1(arg1), m_arg2(arg2) - { - } - - virtual void invoke() { ((m_obj).*(m_callback))(m_arg1, m_arg2); } - - private: - void (_Target::*m_callback)(_Arg1, _Arg2); - _Target &m_obj; - _Arg1 m_arg1; - _Arg2 m_arg2; - }; - - // menubar visibility - enum menubar_visibility_t - { - MENUBAR_VISIBILITY_INVISIBLE, - MENUBAR_VISIBILITY_TRANSLUCENT, - MENUBAR_VISIBILITY_VISIBLE - }; - - // instance variables - running_machine & m_machine; - render_container * m_container; - menu_item m_menus; // the root menu item - menu_item * m_shortcuted_menu_items; // list of menu items with shortcuts - menu_item * m_selected_item; // current selection - menu_item * m_active_item; // active menu item - bool m_dragged; // have we dragged over at least one item? - float m_mouse_x, m_mouse_y; - bool m_mouse_button; - float m_checkmark_width; - osd_ticks_t m_last_mouse_move; - menubar_visibility_t m_menubar_visibility; - bool m_first_time; - //bool m_shortcuts_enabled; - - // selection walking - bool walk_selection_previous(); - bool walk_selection_next(); - bool walk_selection_child(); - bool walk_selection_parent(); - bool walk_selection_escape(); - bool walk_selection_previous_sub_menu(); - bool walk_selection_next_sub_menu(); - - // miscellaneous - void draw_child_menu(menu_item *menu, float x, float y); - bool is_child_menu_visible(menu_item *menu) const; - void draw_menu_item_text(menu_item *mi, float x0, float y0, float x1, float y1, bool decorations, const float *column_widths = NULL); - bool is_highlighted_selection(menu_item *mi); - bool event_loop(); - bool poll_navigation_keys(); - bool poll_shortcut_keys(bool swallow); - bool input_pressed_safe(int key); - void toggle_selection(); - void invoke(menu_item *menu); - bool find_mouse(float &mouse_x, float &mouse_y, bool &mouse_button); - menubar_visibility_t get_menubar_visibility(); - rgb_t adjust_color(rgb_t color); -}; - - -#endif /* __UI_MENUBAR_H__ */ diff --git a/src/emu/ui/miscmenu.c b/src/emu/ui/miscmenu.c index 9bf975a351e..f9cdb7a4d77 100644 --- a/src/emu/ui/miscmenu.c +++ b/src/emu/ui/miscmenu.c @@ -16,11 +16,11 @@ #include "rendutil.h" #include "cheat.h" #include "uiinput.h" +#include "ui/filemngr.h" #include "ui/miscmenu.h" #include "audit.h" #include "crsshair.h" #include -#include "ui/selgame.h" #include "imagedev/cassette.h" #include "imagedev/bitbngr.h" @@ -73,6 +73,42 @@ UINT32 ui_menu_sliders::ui_handler(running_machine &machine, render_container *c MENU HANDLERS ***************************************************************************/ +/*------------------------------------------------- + ui_menu_keyboard_mode - menu that +-------------------------------------------------*/ + +ui_menu_keyboard_mode::ui_menu_keyboard_mode(running_machine &machine, render_container *container) : ui_menu(machine, container) +{ +} + +void ui_menu_keyboard_mode::populate() +{ + bool natural = machine().ui().use_natural_keyboard(); + item_append("Keyboard Mode:", natural ? "Natural" : "Emulated", natural ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, NULL); +} + +ui_menu_keyboard_mode::~ui_menu_keyboard_mode() +{ +} + +void ui_menu_keyboard_mode::handle() +{ + bool natural = machine().ui().use_natural_keyboard(); + + /* process the menu */ + const ui_menu_event *menu_event = process(0); + + if (menu_event != NULL) + { + if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) + { + machine().ui().set_use_natural_keyboard(natural ^ true); + reset(UI_MENU_RESET_REMEMBER_REF); + } + } +} + + /*------------------------------------------------- ui_slot_get_current_option - returns -------------------------------------------------*/ @@ -397,8 +433,7 @@ void ui_menu_input_groups::populate() int player; /* build up the menu */ - item_append("User Interface", NULL, 0, (void *)(IPG_UI_GENERAL + 1)); - item_append("Shortcuts", NULL, 0, (void *)(IPG_UI_SHORTCUT + 1)); + item_append("User Interface", NULL, 0, (void *)(IPG_UI + 1)); for (player = 0; player < MAX_PLAYERS; player++) { char buffer[40]; diff --git a/src/emu/ui/miscmenu.h b/src/emu/ui/miscmenu.h index 8a5985ea8b6..7605baa88b5 100644 --- a/src/emu/ui/miscmenu.h +++ b/src/emu/ui/miscmenu.h @@ -17,6 +17,14 @@ #include "crsshair.h" #include "drivenum.h" +class ui_menu_keyboard_mode : public ui_menu { +public: + ui_menu_keyboard_mode(running_machine &machine, render_container *container); + virtual ~ui_menu_keyboard_mode(); + virtual void populate(); + virtual void handle(); +}; + class ui_menu_slot_devices : public ui_menu { public: ui_menu_slot_devices(running_machine &machine, render_container *container); diff --git a/src/emu/ui/swlist.c b/src/emu/ui/swlist.c index b955055a631..c864ff560e5 100644 --- a/src/emu/ui/swlist.c +++ b/src/emu/ui/swlist.c @@ -357,3 +357,87 @@ void ui_menu_software_list::handle() } } + +/*************************************************************************** + SOFTWARE MENU - list of available software lists - i.e. cartridges, + floppies +***************************************************************************/ + +//------------------------------------------------- +// ctor +//------------------------------------------------- + +ui_menu_software::ui_menu_software(running_machine &machine, render_container *container, const char *interface, software_list_device **result) + : ui_menu(machine, container) +{ + m_interface = interface; + m_result = result; +} + + +//------------------------------------------------- +// dtor +//------------------------------------------------- + +ui_menu_software::~ui_menu_software() +{ +} + + +//------------------------------------------------- +// populate +//------------------------------------------------- + +void ui_menu_software::populate() +{ + bool have_compatible = false; + + // Add original software lists for this system + software_list_device_iterator iter(machine().config().root_device()); + for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next()) + if (swlistdev->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM) + if (swlistdev->first_software_info() != NULL && m_interface != NULL) + { + bool found = false; + for (const software_info *swinfo = swlistdev->first_software_info(); swinfo != NULL; swinfo = swinfo->next()) + if (swinfo->first_part()->matches_interface(m_interface)) + found = true; + if (found) + item_append(swlistdev->description(), NULL, 0, (void *)swlistdev); + } + + // add compatible software lists for this system + for (software_list_device *swlistdev = iter.first(); swlistdev != NULL; swlistdev = iter.next()) + if (swlistdev->list_type() == SOFTWARE_LIST_COMPATIBLE_SYSTEM) + if (swlistdev->first_software_info() != NULL && m_interface != NULL) + { + bool found = false; + for (const software_info *swinfo = swlistdev->first_software_info(); swinfo != NULL; swinfo = swinfo->next()) + if (swinfo->first_part()->matches_interface(m_interface)) + found = true; + if (found) + { + if (!have_compatible) + item_append("[compatible lists]", NULL, MENU_FLAG_DISABLE, NULL); + item_append(swlistdev->description(), NULL, 0, (void *)swlistdev); + } + have_compatible = true; + } +} + + +//------------------------------------------------- +// handle +//------------------------------------------------- + +void ui_menu_software::handle() +{ + // process the menu + const ui_menu_event *event = process(0); + + if (event != NULL && event->iptkey == IPT_UI_SELECT) { + // ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container, (software_list_config *)event->itemref, image))); + *m_result = (software_list_device *)event->itemref; + ui_menu::stack_pop(machine()); + } +} diff --git a/src/emu/ui/swlist.h b/src/emu/ui/swlist.h index 12863153119..1d0edc80d1e 100644 --- a/src/emu/ui/swlist.h +++ b/src/emu/ui/swlist.h @@ -68,5 +68,18 @@ private: }; +// ======================> ui_menu_software + +class ui_menu_software : public ui_menu { +public: + ui_menu_software(running_machine &machine, render_container *container, const char *interface, software_list_device **result); + virtual ~ui_menu_software(); + virtual void populate(); + virtual void handle(); + +private: + const char * m_interface; + software_list_device ** m_result; +}; #endif /* __UI_SWLIST_H__ */ diff --git a/src/emu/ui/ui.c b/src/emu/ui/ui.c index f8c29d5f05b..00634f12f2d 100644 --- a/src/emu/ui/ui.c +++ b/src/emu/ui/ui.c @@ -18,11 +18,24 @@ #include "rendfont.h" #include "ui/ui.h" #include "uiinput.h" +#include "ui/mainmenu.h" #include "ui/miscmenu.h" #include "ui/viewgfx.h" #include +/*************************************************************************** + CONSTANTS +***************************************************************************/ + +enum +{ + LOADSAVE_NONE, + LOADSAVE_LOAD, + LOADSAVE_SAVE +}; + + /*************************************************************************** LOCAL VARIABLES ***************************************************************************/ @@ -213,7 +226,6 @@ ui_manager::ui_manager(running_machine &machine) ui_gfx_init(machine); // reset instance variables - m_menubar = NULL; m_font = NULL; m_handler_callback = NULL; m_handler_param = 0; @@ -224,7 +236,6 @@ ui_manager::ui_manager(running_machine &machine) m_popup_text_end = 0; m_use_natural_keyboard = false; m_mouse_arrow_texture = NULL; - m_shortcuts_enabled = true; // more initialization set_handler(handler_messagebox, 0); @@ -349,6 +360,10 @@ void ui_manager::display_startup_screens(bool first_time, bool show_disclaimer) // loop while we have a handler while (m_handler_callback != handler_ingame && !machine().scheduled_event_pending() && !ui_menu::stack_has_special_main_menu()) machine().video().frame_update(); + + // clear the handler and force an update + set_handler(handler_ingame, 0); + machine().video().frame_update(); } // if we're the empty driver, force the menus on @@ -459,17 +474,15 @@ float ui_manager::get_line_height() { INT32 raw_font_pixel_height = get_font()->pixel_height(); render_target &ui_target = machine().render().ui_target(); - INT32 target_pixel_width = ui_target.width(); INT32 target_pixel_height = ui_target.height(); + float one_to_one_line_height; + float scale_factor; - // compute the font pixel width/height at the nominal size - float one_to_one_line_width = (float)raw_font_pixel_height / (float)target_pixel_width; - float one_to_one_line_height = (float)raw_font_pixel_height / (float)target_pixel_height; + // compute the font pixel height at the nominal size + one_to_one_line_height = (float)raw_font_pixel_height / (float)target_pixel_height; // determine the scale factor - float scale_factor = MIN( - UI_TARGET_FONT_WIDTH / one_to_one_line_width, - UI_TARGET_FONT_HEIGHT / one_to_one_line_height); + scale_factor = UI_TARGET_FONT_HEIGHT / one_to_one_line_height; // if our font is small-ish, do integral scaling if (raw_font_pixel_height < 24) @@ -940,17 +953,6 @@ void ui_manager::show_mouse(bool status) } -//------------------------------------------------- -// set_shortcuts_enabled -//------------------------------------------------- - -void ui_manager::set_shortcuts_enabled(bool shortcuts_enabled) -{ - m_shortcuts_enabled = shortcuts_enabled; - popmessage("Menu shortcuts %s", shortcuts_enabled ? "enabled" : "disabled"); -} - - //------------------------------------------------- // is_menu_active - return true if the menu // UI handler is active @@ -958,8 +960,7 @@ void ui_manager::set_shortcuts_enabled(bool shortcuts_enabled) bool ui_manager::is_menu_active(void) { - return (m_handler_callback == ui_menu::ui_handler) - || (m_handler_callback == handler_ingame && m_menubar != NULL && m_menubar->has_selection()); + return (m_handler_callback == ui_menu::ui_handler); } @@ -1447,46 +1448,187 @@ void ui_manager::image_handler_ingame() UINT32 ui_manager::handler_ingame(running_machine &machine, render_container *container, UINT32 state) { - return machine.ui().handler_ingame_method(container, state); + bool is_paused = machine.paused(); + + // first draw the FPS counter + if (machine.ui().show_fps_counter()) + { + astring tempstring; + machine.ui().draw_text_full(container, machine.video().speed_text(tempstring), 0.0f, 0.0f, 1.0f, + JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL); + } + + // draw the profiler if visible + if (machine.ui().show_profiler()) + { + const char *text = g_profiler.text(machine); + machine.ui().draw_text_full(container, text, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL); + } + + // if we're single-stepping, pause now + if (machine.ui().single_step()) + { + machine.pause(); + machine.ui().set_single_step(false); + } + + // determine if we should disable the rest of the UI + bool ui_disabled = (machine.ioport().has_keyboard() && !machine.ui_active()); + + // is ScrLk UI toggling applicable here? + if (machine.ioport().has_keyboard()) + { + // are we toggling the UI with ScrLk? + if (ui_input_pressed(machine, IPT_UI_TOGGLE_UI)) + { + // toggle the UI + machine.set_ui_active(!machine.ui_active()); + + // display a popup indicating the new status + if (machine.ui_active()) + { + machine.ui().popup_time(2, "%s\n%s\n%s\n%s\n%s\n%s\n", + "Keyboard Emulation Status", + "-------------------------", + "Mode: PARTIAL Emulation", + "UI: Enabled", + "-------------------------", + "**Use ScrLock to toggle**"); + } + else + { + machine.ui().popup_time(2, "%s\n%s\n%s\n%s\n%s\n%s\n", + "Keyboard Emulation Status", + "-------------------------", + "Mode: FULL Emulation", + "UI: Disabled", + "-------------------------", + "**Use ScrLock to toggle**"); + } + } + } + + // is the natural keyboard enabled? + if (machine.ui().use_natural_keyboard() && (machine.phase() == MACHINE_PHASE_RUNNING)) + machine.ui().process_natural_keyboard(); + + if (!ui_disabled) + { + // paste command + if (ui_input_pressed(machine, IPT_UI_PASTE)) + machine.ui().paste(); + } + + machine.ui().image_handler_ingame(); + + if (ui_disabled) return ui_disabled; + + if (ui_input_pressed(machine, IPT_UI_CANCEL)) + { + machine.ui().request_quit(); + return 0; + } + + // turn on menus if requested + if (ui_input_pressed(machine, IPT_UI_CONFIGURE)) + return machine.ui().set_handler(ui_menu::ui_handler, 0); + + // if the on-screen display isn't up and the user has toggled it, turn it on + if ((machine.debug_flags & DEBUG_FLAG_ENABLED) == 0 && ui_input_pressed(machine, IPT_UI_ON_SCREEN_DISPLAY)) + return machine.ui().set_handler(ui_menu_sliders::ui_handler, 1); + + // handle a reset request + if (ui_input_pressed(machine, IPT_UI_RESET_MACHINE)) + machine.schedule_hard_reset(); + if (ui_input_pressed(machine, IPT_UI_SOFT_RESET)) + machine.schedule_soft_reset(); + + // handle a request to display graphics/palette + if (ui_input_pressed(machine, IPT_UI_SHOW_GFX)) + { + if (!is_paused) + machine.pause(); + return machine.ui().set_handler(ui_gfx_ui_handler, is_paused); + } + + // handle a save state request + if (ui_input_pressed(machine, IPT_UI_SAVE_STATE)) + { + machine.pause(); + return machine.ui().set_handler(handler_load_save, LOADSAVE_SAVE); + } + + // handle a load state request + if (ui_input_pressed(machine, IPT_UI_LOAD_STATE)) + { + machine.pause(); + return machine.ui().set_handler(handler_load_save, LOADSAVE_LOAD); + } + + // handle a save snapshot request + if (ui_input_pressed(machine, IPT_UI_SNAPSHOT)) + machine.video().save_active_screen_snapshots(); + + // toggle pause + if (ui_input_pressed(machine, IPT_UI_PAUSE)) + { + // with a shift key, it is single step + if (is_paused && (machine.input().code_pressed(KEYCODE_LSHIFT) || machine.input().code_pressed(KEYCODE_RSHIFT))) + { + machine.ui().set_single_step(true); + machine.resume(); + } + else + machine.toggle_pause(); + } + + // handle a toggle cheats request + if (ui_input_pressed(machine, IPT_UI_TOGGLE_CHEAT)) + machine.cheat().set_enable(!machine.cheat().enabled()); + + // toggle movie recording + if (ui_input_pressed(machine, IPT_UI_RECORD_MOVIE)) + machine.video().toggle_record_movie(); + + // toggle profiler display + if (ui_input_pressed(machine, IPT_UI_SHOW_PROFILER)) + machine.ui().set_show_profiler(!machine.ui().show_profiler()); + + // toggle FPS display + if (ui_input_pressed(machine, IPT_UI_SHOW_FPS)) + machine.ui().set_show_fps(!machine.ui().show_fps()); + + // increment frameskip? + if (ui_input_pressed(machine, IPT_UI_FRAMESKIP_INC)) + machine.ui().increase_frameskip(); + + // decrement frameskip? + if (ui_input_pressed(machine, IPT_UI_FRAMESKIP_DEC)) + machine.ui().decrease_frameskip(); + + // toggle throttle? + if (ui_input_pressed(machine, IPT_UI_THROTTLE)) + machine.video().toggle_throttle(); + + // check for fast forward + if (machine.ioport().type_pressed(IPT_UI_FAST_FORWARD)) + { + machine.video().set_fastforward(true); + machine.ui().show_fps_temp(0.5); + } + else + machine.video().set_fastforward(false); + + return 0; } //------------------------------------------------- -// handler_ingame_method - in-game handler takes -// care of the standard keypresses -//------------------------------------------------- - -UINT32 ui_manager::handler_ingame_method(render_container *container, UINT32 state) -{ - // no menubar? create it - if (m_menubar == NULL) - m_menubar = auto_alloc(machine(), ui_emu_menubar(machine())); - - // handle! - m_menubar->handle(container); - - // did we change out the handler? - if (m_handler_callback != handler_ingame) - { - // if so, flush the menubar... - auto_free(machine(), m_menubar); - m_menubar = NULL; - - // ...and then check to see if this is just a "refresh" - if (m_handler_callback == NULL) - m_handler_callback = handler_ingame; - } - - return m_handler_param; -} - - -//------------------------------------------------- -// ui_handler_load_save - leads the user through +// handler_load_save - leads the user through // specifying a game to save or load //------------------------------------------------- -UINT32 ui_manager::ui_handler_load_save(running_machine &machine, render_container *container, UINT32 state) +UINT32 ui_manager::handler_load_save(running_machine &machine, render_container *container, UINT32 state) { char filename[20]; input_code code; @@ -1563,17 +1705,6 @@ void ui_manager::request_quit() } -//------------------------------------------------- -// do_single_step -//------------------------------------------------- - -void ui_manager::do_single_step() -{ - set_single_step(true); - machine().resume(); -} - - //------------------------------------------------- // handler_confirm_quit - leads the user through // confirming quit emulation diff --git a/src/emu/ui/ui.h b/src/emu/ui/ui.h index 668875137f7..fa6c4824d1a 100644 --- a/src/emu/ui/ui.h +++ b/src/emu/ui/ui.h @@ -15,7 +15,6 @@ #define __USRINTRF_H__ #include "render.h" -#include "emenubar.h" /*************************************************************************** @@ -23,9 +22,7 @@ ***************************************************************************/ /* preferred font height; use ui_get_line_height() to get actual height */ -#define UI_TARGET_FONT_COLUMNS (25) #define UI_TARGET_FONT_ROWS (25) -#define UI_TARGET_FONT_WIDTH (1.0f / (float)UI_TARGET_FONT_COLUMNS) #define UI_TARGET_FONT_HEIGHT (1.0f / (float)UI_TARGET_FONT_ROWS) #define UI_MAX_FONT_HEIGHT (1.0f / 15.0f) @@ -86,14 +83,6 @@ enum DRAW_OPAQUE }; -enum -{ - LOADSAVE_NONE, - LOADSAVE_LOAD, - LOADSAVE_SAVE -}; - - #define SLIDER_NOCHANGE 0x12345678 @@ -130,7 +119,6 @@ public: // getters running_machine &machine() const { return m_machine; } bool single_step() const { return m_single_step; } - bool menubar_visible() { return m_menubar && m_menubar->is_visible(); } // setters void set_single_step(bool single_step) { m_single_step = single_step; } @@ -170,13 +158,6 @@ public: void increase_frameskip(); void decrease_frameskip(); void request_quit(); - void do_single_step(); - bool shortcuts_enabled() const { return m_shortcuts_enabled; } - void set_shortcuts_enabled(bool shortcuts_enabled); - - // UI handlers - static UINT32 ui_handler_load_save(running_machine &machine, render_container *container, UINT32 state); - UINT32 handler_ingame_method(render_container *container, UINT32 state); // print the game info string into a buffer astring &game_info_astring(astring &string); @@ -202,8 +183,6 @@ private: UINT8 * m_non_char_keys_down; render_texture * m_mouse_arrow_texture; bool m_mouse_show; - ui_menubar * m_menubar; - bool m_shortcuts_enabled; // text generators astring &disclaimer_string(astring &buffer); @@ -214,6 +193,7 @@ private: static UINT32 handler_messagebox_ok(running_machine &machine, render_container *container, UINT32 state); static UINT32 handler_messagebox_anykey(running_machine &machine, render_container *container, UINT32 state); static UINT32 handler_ingame(running_machine &machine, render_container *container, UINT32 state); + static UINT32 handler_load_save(running_machine &machine, render_container *container, UINT32 state); static UINT32 handler_confirm_quit(running_machine &machine, render_container *container, UINT32 state); // private methods diff --git a/src/emu/uiinput.h b/src/emu/uiinput.h index 13e35da2d5d..3cf30ccfed4 100644 --- a/src/emu/uiinput.h +++ b/src/emu/uiinput.h @@ -110,6 +110,7 @@ INLINE void ui_input_push_mouse_move_event(running_machine &machine, render_targ ui_input_push_mouse_leave_event - pushes a mouse leave event to the specified render_target -------------------------------------------------*/ + INLINE void ui_input_push_mouse_leave_event(running_machine &machine, render_target *target) { ui_event event = { UI_EVENT_NONE }; diff --git a/src/osd/osdepend.c b/src/osd/osdepend.c index 6ddc93dd5e6..7eb47c70549 100644 --- a/src/osd/osdepend.c +++ b/src/osd/osdepend.c @@ -179,15 +179,6 @@ void osd_interface::customize_input_type_list(simple_list &typ } -//============================================================ -// customize_menubar -//============================================================ - -void osd_interface::customize_menubar(ui_menubar &menu_bar) -{ -} - - //------------------------------------------------- // font_open - attempt to "open" a handle to the // font with the given name diff --git a/src/osd/osdepend.h b/src/osd/osdepend.h index b15e91f2155..7949079a523 100644 --- a/src/osd/osdepend.h +++ b/src/osd/osdepend.h @@ -25,7 +25,6 @@ // forward references class input_type_entry; class device_t; -class ui_menubar; typedef void *osd_font; @@ -56,7 +55,6 @@ public: // input overridables virtual void customize_input_type_list(simple_list &typelist); - virtual void customize_menubar(ui_menubar &menubar); // font overridables virtual osd_font font_open(const char *name, int &height); diff --git a/src/osd/sdl/input.c b/src/osd/sdl/input.c index d6a93f1e0aa..39dee7ccae5 100644 --- a/src/osd/sdl/input.c +++ b/src/osd/sdl/input.c @@ -2083,6 +2083,25 @@ void sdl_osd_interface::customize_input_type_list(simple_list { switch (entry->type()) { + // configurable UI mode switch + case IPT_UI_TOGGLE_UI: + uimode = downcast(machine().options()).ui_mode_key(); + if(!strcmp(uimode,"auto")) + { + #if defined(__APPLE__) && defined(__MACH__) + mameid_code = lookup_mame_code("ITEM_ID_INSERT"); + #else + mameid_code = lookup_mame_code("ITEM_ID_SCRLOCK"); + #endif + } + else + { + snprintf(fullmode, 63, "ITEM_ID_%s", uimode); + mameid_code = lookup_mame_code(fullmode); + } + ui_code = input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, input_item_id(mameid_code)); + entry->defseq(SEQ_TYPE_STANDARD).set(ui_code); + break; // alt-enter for fullscreen case IPT_OSD_1: entry->configure_osd("TOGGLE_FULLSCREEN", "Toggle Fullscreen"); @@ -2163,23 +2182,7 @@ void sdl_osd_interface::customize_input_type_list(simple_list // disable the config menu if the ALT key is down // (allows ALT-TAB to switch between apps) case IPT_UI_CONFIGURE: - // configurable UI mode switch - uimode = downcast(machine().options()).ui_mode_key(); - if(!strcmp(uimode,"auto")) - { - #if defined(__APPLE__) && defined(__MACH__) - mameid_code = lookup_mame_code("ITEM_ID_INSERT"); - #else - mameid_code = lookup_mame_code("ITEM_ID_SCRLOCK"); - #endif - } - else - { - snprintf(fullmode, 63, "ITEM_ID_%s", uimode); - mameid_code = lookup_mame_code(fullmode); - } - ui_code = input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, input_item_id(mameid_code)); - entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_TAB, input_seq::not_code, KEYCODE_LALT, input_seq::not_code, KEYCODE_RALT, input_seq::or_code, ui_code); + entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_TAB, input_seq::not_code, KEYCODE_LALT, input_seq::not_code, KEYCODE_RALT); break; // leave everything else alone diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c index 468fe3ef2bd..fddc23f94d8 100644 --- a/src/osd/windows/drawd3d.c +++ b/src/osd/windows/drawd3d.c @@ -185,7 +185,6 @@ static render_primitive_list *drawd3d_window_get_primitives(win_window_info *win static void drawd3d_window_save(win_window_info *window); static void drawd3d_window_record(win_window_info *window); static void drawd3d_window_toggle_fsfx(win_window_info *window); -static bool drawd3d_window_fsfx_enabled(win_window_info *window); static int drawd3d_window_draw(win_window_info *window, HDC dc, int update); @@ -225,12 +224,6 @@ static void drawd3d_window_toggle_fsfx(win_window_info *window) d3d->set_restarting(true); } -static bool drawd3d_window_fsfx_enabled(win_window_info *window) -{ - d3d::renderer *d3d = (d3d::renderer *)window->drawdata; - return d3d->get_shaders() != NULL && d3d->get_shaders()->enabled(); -} - static void drawd3d_window_record(win_window_info *window) { d3d::renderer *d3d = (d3d::renderer *)window->drawdata; @@ -308,7 +301,6 @@ int drawd3d_init(running_machine &machine, win_draw_callbacks *callbacks) callbacks->window_save = drawd3d_window_save; callbacks->window_record = drawd3d_window_record; callbacks->window_toggle_fsfx = drawd3d_window_toggle_fsfx; - callbacks->window_fsfx_enabled = drawd3d_window_fsfx_enabled; callbacks->window_destroy = drawd3d_window_destroy; return 0; } diff --git a/src/osd/windows/input.c b/src/osd/windows/input.c index 3a8a7e2f109..05563f7abce 100644 --- a/src/osd/windows/input.c +++ b/src/osd/windows/input.c @@ -173,7 +173,6 @@ static bool input_enabled; static osd_lock * input_lock; static bool input_paused; static DWORD last_poll; -static bool menubar_visible; // DirectInput variables static LPDIRECTINPUT dinput; @@ -533,9 +532,6 @@ void wininput_poll(running_machine &machine) { bool hasfocus = winwindow_has_focus() && input_enabled; - // check menubar - menubar_visible = (machine.phase() > MACHINE_PHASE_INIT) && machine.ui().menubar_visible(); - // ignore if not enabled if (input_enabled) { @@ -576,7 +572,7 @@ void wininput_poll(running_machine &machine) bool wininput_should_hide_mouse(void) { // if we are paused or disabled, no - if (input_paused || !input_enabled || menubar_visible) + if (input_paused || !input_enabled) return false; // if neither mice nor lightguns enabled in the core, then no @@ -752,7 +748,6 @@ void windows_osd_interface::customize_input_type_list(simple_listconfigure_osd("RENDER_SNAP", "Take Rendered Snapshot"); entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_F12, KEYCODE_LALT, input_seq::not_code, KEYCODE_LSHIFT); break; - // add a NOT-lalt to our default F12 case IPT_UI_SNAPSHOT: // emu/input.c: input_seq(KEYCODE_F12, input_seq::not_code, KEYCODE_LSHIFT) entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_F12, input_seq::not_code, KEYCODE_LSHIFT, input_seq::not_code, KEYCODE_LALT); @@ -763,7 +758,6 @@ void windows_osd_interface::customize_input_type_list(simple_listconfigure_osd("RENDER_AVI", "Record Rendered Video"); entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_F12, KEYCODE_LSHIFT, KEYCODE_LALT); break; - // add a NOT-lalt to our default shift-F12 case IPT_UI_RECORD_MOVIE: // emu/input.c: input_seq(KEYCODE_F12, KEYCODE_LSHIFT) entry->defseq(SEQ_TYPE_STANDARD).set(KEYCODE_F12, KEYCODE_LSHIFT, input_seq::not_code, KEYCODE_LALT); @@ -786,36 +780,6 @@ void windows_osd_interface::customize_input_type_list(simple_listmachine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); + ui_input_push_mouse_move_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); break; case WM_MOUSELEAVE: - if (!wininput_should_hide_mouse()) - ui_input_push_mouse_leave_event(window->machine(), window->target); + ui_input_push_mouse_leave_event(window->machine(), window->target); break; case WM_LBUTTONDOWN: - if (!wininput_should_hide_mouse()) - { - DWORD ticks = GetTickCount(); - ui_input_push_mouse_down_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); + { + DWORD ticks = GetTickCount(); + ui_input_push_mouse_down_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); - // check for a double-click - if (ticks - window->lastclicktime < GetDoubleClickTime() && - GET_X_LPARAM(lparam) >= window->lastclickx - 4 && GET_X_LPARAM(lparam) <= window->lastclickx + 4 && - GET_Y_LPARAM(lparam) >= window->lastclicky - 4 && GET_Y_LPARAM(lparam) <= window->lastclicky + 4) - { - window->lastclicktime = 0; - ui_input_push_mouse_double_click_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); - } - else - { - window->lastclicktime = ticks; - window->lastclickx = GET_X_LPARAM(lparam); - window->lastclicky = GET_Y_LPARAM(lparam); - } + // check for a double-click + if (ticks - window->lastclicktime < GetDoubleClickTime() && + GET_X_LPARAM(lparam) >= window->lastclickx - 4 && GET_X_LPARAM(lparam) <= window->lastclickx + 4 && + GET_Y_LPARAM(lparam) >= window->lastclicky - 4 && GET_Y_LPARAM(lparam) <= window->lastclicky + 4) + { + window->lastclicktime = 0; + ui_input_push_mouse_double_click_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); + } + else + { + window->lastclicktime = ticks; + window->lastclickx = GET_X_LPARAM(lparam); + window->lastclicky = GET_Y_LPARAM(lparam); } break; + } case WM_LBUTTONUP: - if (!wininput_should_hide_mouse()) - ui_input_push_mouse_up_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); + ui_input_push_mouse_up_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); break; case WM_CHAR: diff --git a/src/osd/windows/window.h b/src/osd/windows/window.h index fcdea00cf21..b5bf3f3e52a 100644 --- a/src/osd/windows/window.h +++ b/src/osd/windows/window.h @@ -92,7 +92,6 @@ struct win_draw_callbacks void (*window_save)(win_window_info *window); void (*window_record)(win_window_info *window); void (*window_toggle_fsfx)(win_window_info *window); - bool (*window_fsfx_enabled)(win_window_info *window); void (*window_destroy)(win_window_info *window); }; @@ -126,14 +125,8 @@ LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wpar extern LRESULT CALLBACK winwindow_video_window_proc_ui(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam); void winwindow_toggle_full_screen(void); - -// HLSL -bool winwindow_can_take_snap(void); void winwindow_take_snap(void); -bool winwindow_can_take_video(void); void winwindow_take_video(void); -bool winwindow_can_toggle_fsfx(void); -bool winwindow_is_fsfx_enabled(void); void winwindow_toggle_fsfx(void); void winwindow_process_events_periodic(running_machine &machine); diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index 601d3a02c7e..0305dcf3157 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -965,46 +965,6 @@ bool windows_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, b } -//------------------------------------------------- -// toggle_full_screen -//------------------------------------------------- - -void windows_osd_interface::toggle_full_screen() -{ - winwindow_toggle_full_screen(); -} - - -//------------------------------------------------- -// take_snap -//------------------------------------------------- - -void windows_osd_interface::take_snap() -{ - winwindow_take_snap(); -} - - -//------------------------------------------------- -// take_video -//------------------------------------------------- - -void windows_osd_interface::take_video() -{ - winwindow_take_video(); -} - - -//------------------------------------------------- -// toggle_fsfx -//------------------------------------------------- - -void windows_osd_interface::toggle_fsfx() -{ - winwindow_toggle_fsfx(); -} - - //============================================================ // winmain_dump_stack //============================================================ diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index e7ea875c610..2e1a0c6b5b7 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -308,7 +308,6 @@ public: // input overridables virtual void customize_input_type_list(simple_list &typelist); - virtual void customize_menubar(ui_menubar &menubar); // font overridables virtual osd_font font_open(const char *name, int &height); @@ -319,12 +318,6 @@ private: static void osd_exit(running_machine &machine); static const int DEFAULT_FONT_HEIGHT = 200; - - // trampolines to support menu bar - void toggle_full_screen(); - void take_snap(); - void take_video(); - void toggle_fsfx(); };