From 6d4f62703558fdf53edfcf26656f44699bb6df90 Mon Sep 17 00:00:00 2001 From: dankan1890 Date: Thu, 3 Mar 2016 01:52:34 +0100 Subject: menu: fixed top line computation. (nw) --- src/emu/ui/menu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/emu/ui/menu.cpp') diff --git a/src/emu/ui/menu.cpp b/src/emu/ui/menu.cpp index f6154c41638..56c41062afd 100644 --- a/src/emu/ui/menu.cpp +++ b/src/emu/ui/menu.cpp @@ -544,7 +544,7 @@ void ui_menu::draw(bool customonly, bool noimage, bool noinput) machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR); // determine the first visible line based on the current selection - if (selected > top_line + visible_lines) + if (selected > top_line + visible_lines || selected < top_line - visible_lines) top_line = selected - (visible_lines / 2); if (top_line < 0 || selected == 0) top_line = 0; -- cgit v1.2.3-70-g09d2 From 02d24565dc183f3d2f7ff364e8ce9472cbaf2baf Mon Sep 17 00:00:00 2001 From: dankan1890 Date: Sat, 5 Mar 2016 15:38:22 +0100 Subject: menu: added handling of mouse button held down on arrows in the machine list. (nw) --- src/emu/mame.cpp | 2 +- src/emu/ui/menu.cpp | 23 +++++++++++++++++++++++ src/emu/ui/menu.h | 9 ++++++++- src/emu/ui/selgame.cpp | 20 +++++++++++--------- 4 files changed, 43 insertions(+), 11 deletions(-) (limited to 'src/emu/ui/menu.cpp') diff --git a/src/emu/mame.cpp b/src/emu/mame.cpp index 513300553d6..5e93623498d 100644 --- a/src/emu/mame.cpp +++ b/src/emu/mame.cpp @@ -259,7 +259,7 @@ int machine_manager::execute() sw_instance = sw_load.substr(right + 1); sw_load.assign(sw_load.substr(0, right)); - char arg[] = "ume"; + char arg[] = "mame"; char *argv = &arg[0]; m_options.set_value(OPTION_SOFTWARENAME, sw_name.c_str(), OPTION_PRIORITY_CMDLINE, error_string); m_options.parse_slot_devices(1, &argv, option_errors, sw_instance.c_str(), sw_load.c_str()); diff --git a/src/emu/ui/menu.cpp b/src/emu/ui/menu.cpp index 56c41062afd..ccc73f55002 100644 --- a/src/emu/ui/menu.cpp +++ b/src/emu/ui/menu.cpp @@ -1891,6 +1891,21 @@ void ui_menu::handle_main_events(UINT32 flags) bool stop = false; ui_event local_menu_event; + if (m_pressed) + { + bool pressed = mouse_pressed(); + INT32 m_target_x, m_target_y; + bool m_button; + render_target *mouse_target = machine().ui_input().find_mouse(&m_target_x, &m_target_y, &m_button); + if (mouse_target != nullptr && m_button && (hover == HOVER_ARROW_DOWN || hover == HOVER_ARROW_UP)) + { + if (pressed) + machine().ui_input().push_mouse_down_event(mouse_target, m_target_x, m_target_y); + } + else + reset_pressed(); + } + // loop while we have interesting events while (!stop && machine().ui_input().pop_event(&local_menu_event)) { @@ -1919,6 +1934,7 @@ void ui_menu::handle_main_events(UINT32 flags) if (selected < 0) selected = 0; top_line -= visitems - (top_line + visible_lines == visible_items); + set_pressed(); } else if (hover == HOVER_ARROW_DOWN) { @@ -1926,6 +1942,7 @@ void ui_menu::handle_main_events(UINT32 flags) if (selected >= visible_items) selected = visible_items - 1; top_line += visible_lines - 2; + set_pressed(); } else if (hover == HOVER_UI_RIGHT) menu_event.iptkey = IPT_UI_RIGHT; @@ -2820,3 +2837,9 @@ void ui_menu::draw_dats_menu() // return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow visitems = visible_lines - (top_line != 0) - (top_line + visible_lines != visible_items); } + +void ui_menu::set_pressed() +{ + (m_repeat == 0) ? m_repeat = osd_ticks() + osd_ticks_per_second() / 2 : m_repeat = osd_ticks() + osd_ticks_per_second() / 4; + m_pressed = true; +} \ No newline at end of file diff --git a/src/emu/ui/menu.h b/src/emu/ui/menu.h index 562650d0e51..4a788c612c7 100644 --- a/src/emu/ui/menu.h +++ b/src/emu/ui/menu.h @@ -266,8 +266,15 @@ protected: static std::unique_ptr hilight_main_bitmap; static render_texture *hilight_main_texture; private: + + // mouse button held down + bool m_pressed = false; + osd_ticks_t m_repeat = 0; + void reset_pressed() { m_pressed = false; m_repeat = 0; } + bool mouse_pressed() { return (osd_ticks() >= m_repeat); } + void set_pressed(); + static std::unique_ptr no_avail_bitmap, bgrnd_bitmap, star_bitmap; -// static std::unique_ptr hilight_main_bitmap; static render_texture *bgrnd_texture, *star_texture; static bitmap_argb32 *icons_bitmap[]; static render_texture *icons_texture[]; diff --git a/src/emu/ui/selgame.cpp b/src/emu/ui/selgame.cpp index 34fdab6d64e..c3c724b900c 100644 --- a/src/emu/ui/selgame.cpp +++ b/src/emu/ui/selgame.cpp @@ -358,13 +358,13 @@ void ui_menu_select_game::handle() if (!isfavorite()) { const game_driver *driver = (const game_driver *)m_event->itemref; - if ((FPTR)driver > 3 && machine().datfile().has_data(driver)) + if ((FPTR)driver > skip_main_items && machine().datfile().has_data(driver)) ui_menu::stack_push(global_alloc_clear(machine(), container, driver)); } else { ui_software_info *swinfo = (ui_software_info *)m_event->itemref; - if ((FPTR)swinfo > 3 && machine().datfile().has_data(swinfo->driver)) + if ((FPTR)swinfo > skip_main_items && machine().datfile().has_data(swinfo->driver)) { if (swinfo->startempty == 1) ui_menu::stack_push(global_alloc_clear(machine(), container, swinfo->driver)); @@ -380,7 +380,7 @@ void ui_menu_select_game::handle() if (!isfavorite()) { const game_driver *driver = (const game_driver *)m_event->itemref; - if ((FPTR)driver > 3) + if ((FPTR)driver > skip_main_items) { if (!machine().favorite().isgame_favorite(driver)) { @@ -398,7 +398,7 @@ void ui_menu_select_game::handle() else { ui_software_info *swinfo = (ui_software_info *)m_event->itemref; - if ((FPTR)swinfo > 3) + if ((FPTR)swinfo > skip_main_items) { machine().popmessage(_("%s\n removed from favorites list."), swinfo->longname.c_str()); machine().favorite().remove_favorite_game(*swinfo); @@ -534,24 +534,26 @@ void ui_menu_select_game::populate() } // iterate over entries - for (size_t curitem = 0; curitem < m_displaylist.size(); ++curitem) + int curitem = 0; + for (auto & elem : m_displaylist) { UINT32 flags_ui = MENU_FLAG_UI | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW; - if (old_item_selected == -1 && m_displaylist[curitem]->name == reselect_last::driver) + if (old_item_selected == -1 && elem->name == reselect_last::driver) old_item_selected = curitem; - bool cloneof = strcmp(m_displaylist[curitem]->parent, "0"); + bool cloneof = strcmp(elem->parent, "0"); if (cloneof) { - int cx = driver_list::find(m_displaylist[curitem]->parent); + int cx = driver_list::find(elem->parent); if (cx != -1 && ((driver_list::driver(cx).flags & MACHINE_IS_BIOS_ROOT) != 0)) cloneof = false; } if (cloneof) flags_ui |= MENU_FLAG_INVERT; - item_append(m_displaylist[curitem]->description, nullptr, flags_ui, (void *)m_displaylist[curitem]); + item_append(elem->description, nullptr, flags_ui, (void *)elem); + curitem++; } } } -- cgit v1.2.3-70-g09d2