mirror of
https://github.com/holub/mame
synced 2025-06-09 06:13:04 +03:00
menu: added handling of mouse button held down on arrows in the machine list. (nw)
This commit is contained in:
parent
424ea5d9d8
commit
02d24565dc
@ -259,7 +259,7 @@ int machine_manager::execute()
|
|||||||
sw_instance = sw_load.substr(right + 1);
|
sw_instance = sw_load.substr(right + 1);
|
||||||
sw_load.assign(sw_load.substr(0, right));
|
sw_load.assign(sw_load.substr(0, right));
|
||||||
|
|
||||||
char arg[] = "ume";
|
char arg[] = "mame";
|
||||||
char *argv = &arg[0];
|
char *argv = &arg[0];
|
||||||
m_options.set_value(OPTION_SOFTWARENAME, sw_name.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
|
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());
|
m_options.parse_slot_devices(1, &argv, option_errors, sw_instance.c_str(), sw_load.c_str());
|
||||||
|
@ -1891,6 +1891,21 @@ void ui_menu::handle_main_events(UINT32 flags)
|
|||||||
bool stop = false;
|
bool stop = false;
|
||||||
ui_event local_menu_event;
|
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
|
// loop while we have interesting events
|
||||||
while (!stop && machine().ui_input().pop_event(&local_menu_event))
|
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)
|
if (selected < 0)
|
||||||
selected = 0;
|
selected = 0;
|
||||||
top_line -= visitems - (top_line + visible_lines == visible_items);
|
top_line -= visitems - (top_line + visible_lines == visible_items);
|
||||||
|
set_pressed();
|
||||||
}
|
}
|
||||||
else if (hover == HOVER_ARROW_DOWN)
|
else if (hover == HOVER_ARROW_DOWN)
|
||||||
{
|
{
|
||||||
@ -1926,6 +1942,7 @@ void ui_menu::handle_main_events(UINT32 flags)
|
|||||||
if (selected >= visible_items)
|
if (selected >= visible_items)
|
||||||
selected = visible_items - 1;
|
selected = visible_items - 1;
|
||||||
top_line += visible_lines - 2;
|
top_line += visible_lines - 2;
|
||||||
|
set_pressed();
|
||||||
}
|
}
|
||||||
else if (hover == HOVER_UI_RIGHT)
|
else if (hover == HOVER_UI_RIGHT)
|
||||||
menu_event.iptkey = IPT_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
|
// 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);
|
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;
|
||||||
|
}
|
@ -266,8 +266,15 @@ protected:
|
|||||||
static std::unique_ptr<bitmap_rgb32> hilight_main_bitmap;
|
static std::unique_ptr<bitmap_rgb32> hilight_main_bitmap;
|
||||||
static render_texture *hilight_main_texture;
|
static render_texture *hilight_main_texture;
|
||||||
private:
|
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<bitmap_argb32> no_avail_bitmap, bgrnd_bitmap, star_bitmap;
|
static std::unique_ptr<bitmap_argb32> no_avail_bitmap, bgrnd_bitmap, star_bitmap;
|
||||||
// static std::unique_ptr<bitmap_rgb32> hilight_main_bitmap;
|
|
||||||
static render_texture *bgrnd_texture, *star_texture;
|
static render_texture *bgrnd_texture, *star_texture;
|
||||||
static bitmap_argb32 *icons_bitmap[];
|
static bitmap_argb32 *icons_bitmap[];
|
||||||
static render_texture *icons_texture[];
|
static render_texture *icons_texture[];
|
||||||
|
@ -358,13 +358,13 @@ void ui_menu_select_game::handle()
|
|||||||
if (!isfavorite())
|
if (!isfavorite())
|
||||||
{
|
{
|
||||||
const game_driver *driver = (const game_driver *)m_event->itemref;
|
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<ui_menu_dats_view>(machine(), container, driver));
|
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, driver));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui_software_info *swinfo = (ui_software_info *)m_event->itemref;
|
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)
|
if (swinfo->startempty == 1)
|
||||||
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, swinfo->driver));
|
ui_menu::stack_push(global_alloc_clear<ui_menu_dats_view>(machine(), container, swinfo->driver));
|
||||||
@ -380,7 +380,7 @@ void ui_menu_select_game::handle()
|
|||||||
if (!isfavorite())
|
if (!isfavorite())
|
||||||
{
|
{
|
||||||
const game_driver *driver = (const game_driver *)m_event->itemref;
|
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))
|
if (!machine().favorite().isgame_favorite(driver))
|
||||||
{
|
{
|
||||||
@ -398,7 +398,7 @@ void ui_menu_select_game::handle()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui_software_info *swinfo = (ui_software_info *)m_event->itemref;
|
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().popmessage(_("%s\n removed from favorites list."), swinfo->longname.c_str());
|
||||||
machine().favorite().remove_favorite_game(*swinfo);
|
machine().favorite().remove_favorite_game(*swinfo);
|
||||||
@ -534,24 +534,26 @@ void ui_menu_select_game::populate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// iterate over entries
|
// 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;
|
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;
|
old_item_selected = curitem;
|
||||||
|
|
||||||
bool cloneof = strcmp(m_displaylist[curitem]->parent, "0");
|
bool cloneof = strcmp(elem->parent, "0");
|
||||||
if (cloneof)
|
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))
|
if (cx != -1 && ((driver_list::driver(cx).flags & MACHINE_IS_BIOS_ROOT) != 0))
|
||||||
cloneof = false;
|
cloneof = false;
|
||||||
}
|
}
|
||||||
if (cloneof)
|
if (cloneof)
|
||||||
flags_ui |= MENU_FLAG_INVERT;
|
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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user