ui various changes:

* extended keyboard navigation in the UI on the right side.
* added the skeleton for a configuration menu for single machine.
* fixed bug in building the search path for images.
This commit is contained in:
dankan1890 2016-02-27 03:31:08 +01:00
parent 42921c5e54
commit 04d1948ee8
9 changed files with 475 additions and 133 deletions

View File

@ -761,7 +761,7 @@ void construct_core_types_UI(simple_list<input_type_entry> &typelist)
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_UP_FILTER, nullptr, input_seq() )
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_DOWN_FILTER, nullptr, input_seq() )
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_LEFT_PANEL, nullptr, input_seq() )
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RIGHT_PANEL, "UI Right switch image/info",input_seq(KEYCODE_RIGHT, KEYCODE_LCONTROL) )
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RIGHT_PANEL, nullptr, input_seq() )
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_UP_PANEL, nullptr, input_seq() )
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_DOWN_PANEL, nullptr, input_seq() )
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_EXPORT, "UI Export list to xml", input_seq(KEYCODE_LALT, KEYCODE_E) )

View File

@ -1657,14 +1657,17 @@ void ui_menu::get_title_search(std::string &snaptext, std::string &searchstr)
else
searchstr = machine().ui().options().value(arts_info[ui_globals::curimage_view].path);
path_iterator path(searchstr.c_str());
std::string tmp(searchstr);
path_iterator path(tmp.c_str());
std::string curpath;
path_iterator path_iter(arts_info[ui_globals::curimage_view].addpath);
std::string c_path;
// iterate over path and add path for zipped formats
while (path.next(curpath))
{
path_iterator path_iter(arts_info[ui_globals::curimage_view].addpath);
std::string c_path;
path_iter.reset();
while (path_iter.next(c_path))
searchstr.append(";").append(curpath).append(PATH_SEPARATOR).append(c_path);
}
@ -1707,22 +1710,27 @@ void ui_menu::handle_main_keys(UINT32 flags)
validate_selection(1);
// swallow left/right keys if they are not appropriate
bool ignoreleft = ((item[selected].flags & MENU_FLAG_LEFT_ARROW) == 0 || ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_RIGHT_PANEL);
bool ignoreright = ((item[selected].flags & MENU_FLAG_RIGHT_ARROW) == 0 || ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_RIGHT_PANEL);
bool ignoreleft = ((item[selected].flags & MENU_FLAG_LEFT_ARROW) == 0);
bool ignoreright = ((item[selected].flags & MENU_FLAG_RIGHT_ARROW) == 0);
bool leftclose = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_LEFT_PANEL);
bool rightclose = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_RIGHT_PANEL);
input_manager &minput = machine().input();
// accept left/right keys as-is with repeat
if (!ignoreleft && exclusive_input_pressed(IPT_UI_LEFT, (flags & UI_MENU_PROCESS_LR_REPEAT) ? 6 : 0))
{
// Swap the right panel
if (minput.code_pressed(KEYCODE_LCONTROL) || minput.code_pressed(JOYCODE_BUTTON1))
if (m_focus == focused_menu::righttop)
menu_event.iptkey = IPT_UI_LEFT_PANEL;
return;
}
if (!ignoreright && exclusive_input_pressed(IPT_UI_RIGHT, (flags & UI_MENU_PROCESS_LR_REPEAT) ? 6 : 0))
{
// Swap the right panel
if (m_focus == focused_menu::righttop)
menu_event.iptkey = IPT_UI_RIGHT_PANEL;
return;
}
// up backs up by one item
if (exclusive_input_pressed(IPT_UI_UP, 6))
@ -1735,7 +1743,7 @@ void ui_menu::handle_main_keys(UINT32 flags)
}
// Infos
if (!ignoreleft && (minput.code_pressed(KEYCODE_LCONTROL) || minput.code_pressed(JOYCODE_BUTTON1)))
if (!rightclose && m_focus == focused_menu::rightbottom)
{
menu_event.iptkey = IPT_UI_UP_PANEL;
topline_datsview--;
@ -1762,7 +1770,7 @@ void ui_menu::handle_main_keys(UINT32 flags)
}
// Infos
if (!ignoreright && (minput.code_pressed(KEYCODE_LCONTROL) || minput.code_pressed(JOYCODE_BUTTON1)))
if (!rightclose && m_focus == focused_menu::rightbottom)
{
menu_event.iptkey = IPT_UI_DOWN_PANEL;
topline_datsview++;
@ -1782,7 +1790,7 @@ void ui_menu::handle_main_keys(UINT32 flags)
if (exclusive_input_pressed(IPT_UI_PAGE_UP, 6))
{
// Infos
if (!ignoreleft && (minput.code_pressed(KEYCODE_LCONTROL) || minput.code_pressed(JOYCODE_BUTTON1)))
if (!rightclose && m_focus == focused_menu::rightbottom)
{
menu_event.iptkey = IPT_UI_DOWN_PANEL;
topline_datsview -= right_visible_lines - 1;
@ -1804,7 +1812,7 @@ void ui_menu::handle_main_keys(UINT32 flags)
if (exclusive_input_pressed(IPT_UI_PAGE_DOWN, 6))
{
// Infos
if (!ignoreleft && (minput.code_pressed(KEYCODE_LCONTROL) || minput.code_pressed(JOYCODE_BUTTON1)))
if (!rightclose && m_focus == focused_menu::rightbottom)
{
menu_event.iptkey = IPT_UI_DOWN_PANEL;
topline_datsview += right_visible_lines - 1;
@ -1826,7 +1834,7 @@ void ui_menu::handle_main_keys(UINT32 flags)
if (exclusive_input_pressed(IPT_UI_HOME, 0))
{
// Infos
if (!ignoreleft && (minput.code_pressed(KEYCODE_LCONTROL) || minput.code_pressed(JOYCODE_BUTTON1)))
if (!rightclose && m_focus == focused_menu::rightbottom)
{
menu_event.iptkey = IPT_UI_DOWN_PANEL;
topline_datsview = 0;
@ -1844,7 +1852,7 @@ void ui_menu::handle_main_keys(UINT32 flags)
if (exclusive_input_pressed(IPT_UI_END, 0))
{
// Infos
if (!ignoreleft && (minput.code_pressed(KEYCODE_LCONTROL) || minput.code_pressed(JOYCODE_BUTTON1)))
if (!rightclose && m_focus == focused_menu::rightbottom)
{
menu_event.iptkey = IPT_UI_DOWN_PANEL;
topline_datsview = totallines;
@ -1906,6 +1914,8 @@ void ui_menu::handle_main_events(UINT32 flags)
{
if (hover >= 0 && hover < item.size())
{
if (hover >= visible_items - 1 && selected < visible_items)
m_prev_selected = item[selected].ref;
selected = hover;
m_focus = focused_menu::main;
}
@ -2104,9 +2114,17 @@ float ui_menu::draw_right_box_title(float x1, float y1, float x2, float y2)
fgcolor = UI_CLONE_COLOR;
}
if (bgcolor != UI_TEXT_BG_COLOR)
if (m_focus == focused_menu::righttop && ui_globals::rpanel == cells)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
mui.draw_textured_box(container, x1 + UI_LINE_WIDTH, y1 + UI_LINE_WIDTH, x1 + midl - UI_LINE_WIDTH, y1 + line_height,
bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
}
if (bgcolor == UI_MOUSEOVER_BG_COLOR)
container->add_rect(x1 + UI_LINE_WIDTH, y1 + UI_LINE_WIDTH, x1 + midl - UI_LINE_WIDTH, y1 + line_height,
bgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
bgcolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
mui.draw_text_full(container, buffer[cells].c_str(), x1 + UI_LINE_WIDTH, y1, midl - UI_LINE_WIDTH,
JUSTIFY_CENTER, WRAP_NEVER, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
@ -2122,6 +2140,8 @@ float ui_menu::draw_right_box_title(float x1, float y1, float x2, float y2)
std::string ui_menu::arts_render_common(float origx1, float origy1, float origx2, float origy2)
{
ui_manager &mui = machine().ui();
float line_height = mui.get_line_height();
std::string snaptext, searchstr;
get_title_search(snaptext, searchstr);
@ -2131,7 +2151,7 @@ std::string ui_menu::arts_render_common(float origx1, float origy1, float origx2
for (int x = FIRST_VIEW; x < LAST_VIEW; x++)
{
machine().ui().draw_text_full(container, arts_info[x].title, origx1, origy1, origx2 - origx1, JUSTIFY_CENTER,
mui.draw_text_full(container, arts_info[x].title, origx1, origy1, origx2 - origx1, JUSTIFY_CENTER,
WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &txt_lenght, nullptr);
txt_lenght += 0.01f;
title_size = MAX(txt_lenght, title_size);
@ -2145,7 +2165,13 @@ std::string ui_menu::arts_render_common(float origx1, float origy1, float origx2
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
}
machine().ui().draw_text_full(container, snaptext.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
float middle = origx2 - origx1;
if (bgcolor != UI_TEXT_BG_COLOR)
mui.draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
origy1 + line_height, bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
mui.draw_text_full(container, snaptext.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
draw_common_arrow(origx1, origy1, origx2, origy2, ui_globals::curimage_view, FIRST_VIEW, LAST_VIEW, title_size);

View File

@ -193,7 +193,7 @@ private:
public:
// tab navigation
enum focused_menu
enum class focused_menu
{
main,
left,

View File

@ -701,91 +701,90 @@ void ui_menu_export::handle()
{
switch ((FPTR)m_event->itemref)
{
case 1:
{
if (m_event->iptkey == IPT_UI_SELECT)
case 1:
{
std::string filename("exported");
emu_file infile(machine().ui().options().ui_path(), OPEN_FLAG_READ);
if (infile.open(filename.c_str(), ".xml") == FILERR_NONE)
for (int seq = 0; ; ++seq)
{
std::string seqtext;
strprintf(seqtext, "%s_%04d", filename.c_str(), seq);
if (infile.open(seqtext.c_str(), ".xml") != FILERR_NONE)
{
filename = seqtext;
break;
}
}
// attempt to open the output file
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
if (file.open(filename.c_str(), ".xml") == FILERR_NONE)
if (m_event->iptkey == IPT_UI_SELECT)
{
FILE *pfile;
std::string fullpath(file.fullpath());
file.close();
pfile = fopen(fullpath.c_str(), "w");
std::string filename("exported");
emu_file infile(machine().ui().options().ui_path(), OPEN_FLAG_READ);
if (infile.open(filename.c_str(), ".xml") == FILERR_NONE)
for (int seq = 0; ; ++seq)
{
std::string seqtext;
strprintf(seqtext, "%s_%04d", filename.c_str(), seq);
if (infile.open(seqtext.c_str(), ".xml") != FILERR_NONE)
{
filename = seqtext;
break;
}
}
// create the XML and save to file
driver_enumerator drvlist(machine().options());
drvlist.exclude_all();
for (auto & elem : m_list)
drvlist.include(driver_list::find(*elem));
// attempt to open the output file
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
if (file.open(filename.c_str(), ".xml") == FILERR_NONE)
{
FILE *pfile;
std::string fullpath(file.fullpath());
file.close();
pfile = fopen(fullpath.c_str(), "w");
info_xml_creator creator(drvlist);
creator.output(pfile, false);
fclose(pfile);
machine().popmessage(_("%s.xml saved under ui folder."), filename.c_str());
// create the XML and save to file
driver_enumerator drvlist(machine().options());
drvlist.exclude_all();
for (auto & elem : m_list)
drvlist.include(driver_list::find(*elem));
info_xml_creator creator(drvlist);
creator.output(pfile, false);
fclose(pfile);
machine().popmessage(_("%s.xml saved under ui folder."), filename.c_str());
}
}
break;
}
break;
}
case 2:
{
if (m_event->iptkey == IPT_UI_SELECT)
case 2:
{
std::string filename("exported");
std::string buffer;
emu_file infile(machine().ui().options().ui_path(), OPEN_FLAG_READ);
if (infile.open(filename.c_str(), ".txt") == FILERR_NONE)
for (int seq = 0; ; ++seq)
{
std::string seqtext;
strprintf(seqtext, "%s_%04d", filename.c_str(), seq);
if (infile.open(seqtext.c_str(), ".txt") != FILERR_NONE)
{
filename = seqtext;
break;
}
}
// attempt to open the output file
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
if (file.open(filename.c_str(), ".txt") == FILERR_NONE)
if (m_event->iptkey == IPT_UI_SELECT)
{
// print the header
buffer.assign(_("Name: Description:\n"));
driver_enumerator drvlist(machine().options());
drvlist.exclude_all();
for (auto & elem : m_list)
drvlist.include(driver_list::find(*elem));
std::string filename("exported");
std::string buffer;
emu_file infile(machine().ui().options().ui_path(), OPEN_FLAG_READ);
if (infile.open(filename.c_str(), ".txt") == FILERR_NONE)
for (int seq = 0; ; ++seq)
{
std::string seqtext;
strprintf(seqtext, "%s_%04d", filename.c_str(), seq);
if (infile.open(seqtext.c_str(), ".txt") != FILERR_NONE)
{
filename = seqtext;
break;
}
}
// iterate through drivers and output the info
while (drvlist.next())
if ((drvlist.driver().flags & MACHINE_NO_STANDALONE) == 0)
strcatprintf(buffer, "%-18s\"%s\"\n", drvlist.driver().name, drvlist.driver().description);
file.puts(buffer.c_str());
file.close();
machine().popmessage(_("%s.txt saved under ui folder."), filename.c_str());
// attempt to open the output file
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
if (file.open(filename.c_str(), ".txt") == FILERR_NONE)
{
// print the header
buffer.assign(_("Name: Description:\n"));
driver_enumerator drvlist(machine().options());
drvlist.exclude_all();
for (auto & elem : m_list)
drvlist.include(driver_list::find(*elem));
// iterate through drivers and output the info
while (drvlist.next())
if ((drvlist.driver().flags & MACHINE_NO_STANDALONE) == 0)
strcatprintf(buffer, "%-18s\"%s\"\n", drvlist.driver().name, drvlist.driver().description);
file.puts(buffer.c_str());
file.close();
machine().popmessage(_("%s.txt saved under ui folder."), filename.c_str());
}
}
break;
}
break;
}
default:
break;
default:
break;
}
}
}
@ -796,9 +795,102 @@ void ui_menu_export::handle()
void ui_menu_export::populate()
{
// add options items
item_append(_("Export XML format"), nullptr, 0, (void *)(FPTR)1);
item_append(_("Export TXT format"), nullptr, 0, (void *)(FPTR)2);
item_append(_("Export XML format (like -listxml)"), nullptr, 0, (void *)(FPTR)1);
item_append(_("Export TXT format (like -listfull)"), nullptr, 0, (void *)(FPTR)2);
item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
}
//-------------------------------------------------
// ctor / dtor
//-------------------------------------------------
ui_menu_machine_configure::ui_menu_machine_configure(running_machine &machine, render_container *container, const game_driver *prev)
: ui_menu(machine, container), m_drv(prev)
{
}
ui_menu_machine_configure::~ui_menu_machine_configure()
{
}
//-------------------------------------------------
// handlethe options menu
//-------------------------------------------------
void ui_menu_machine_configure::handle()
{
// process the menu
ui_menu::menu_stack->parent->process(UI_MENU_PROCESS_NOINPUT);
const ui_menu_event *m_event = process(UI_MENU_PROCESS_NOIMAGE);
if (m_event != nullptr && m_event->itemref != nullptr)
{
switch ((FPTR)m_event->itemref)
{
case 1:
{
if (m_event->iptkey == IPT_UI_SELECT)
{
std::string filename(m_drv->name);
emu_file file(machine().options().ini_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
file_error filerr = file.open(filename.c_str(), ".ini");
if (filerr == FILERR_NONE)
{
std::string inistring = machine().options().output_ini();
file.puts(inistring.c_str());
}
}
break;
}
default:
break;
}
}
}
//-------------------------------------------------
// populate
//-------------------------------------------------
void ui_menu_machine_configure::populate()
{
// add options items
item_append(_("Dummy"), nullptr, 0, (void *)(FPTR)10);
item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
item_append(_("Save machine configuration"), nullptr, 0, (void *)(FPTR)1);
item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
customtop = machine().ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
}
//-------------------------------------------------
// perform our special rendering
//-------------------------------------------------
void ui_menu_machine_configure::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
float width;
ui_manager &mui = machine().ui();
mui.draw_text_full(container, m_drv->description, 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
float maxwidth = MAX(origx2 - origx1, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
float x2 = x1 + maxwidth;
float y1 = origy1 - top;
float y2 = origy1 - UI_BOX_TB_BORDER;
// draw a box
mui.draw_outlined_box(container, x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
x1 += UI_BOX_LR_BORDER;
x2 -= UI_BOX_LR_BORDER;
y1 += UI_BOX_TB_BORDER;
// draw the text within it
mui.draw_text_full(container, m_drv->description, x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
}

View File

@ -1,5 +1,5 @@
// license:BSD-3-Clause
// copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods,Dankan1890
// copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods, Maurizio Petrarota
/***************************************************************************
ui/miscmenu.h
@ -108,6 +108,10 @@ private:
static misc_option m_options[];
};
//-------------------------------------------------
// export menu
//-------------------------------------------------
class ui_menu_export : public ui_menu
{
public:
@ -119,4 +123,23 @@ public:
private:
std::vector<const game_driver*> m_list;
};
//-------------------------------------------------
// machine configure menu
//-------------------------------------------------
class ui_menu_machine_configure : public ui_menu
{
public:
ui_menu_machine_configure(running_machine &machine, render_container *container, const game_driver *prev);
virtual ~ui_menu_machine_configure();
virtual void populate() override;
virtual void handle() override;
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
private:
const game_driver *m_drv;
};
#endif /* __UI_MISCMENU_H__ */

View File

@ -1,5 +1,5 @@
// license:BSD-3-Clause
// copyright-holders:Dankan1890
// copyright-holders:Maurizio Petrarota
/*********************************************************************
ui/selgame.cpp
@ -263,10 +263,10 @@ ui_menu_select_game::~ui_menu_select_game()
else
driver = (selected >= 0 && selected < item.size()) ? (const game_driver *)item[selected].ref : nullptr;
if ((FPTR)driver > 3)
if ((FPTR)driver > skip_main_items)
last_driver = driver->name;
if ((FPTR)swinfo > 3)
if ((FPTR)swinfo > skip_main_items)
last_driver = swinfo->shortname;
std::string filter(main_filters::text[main_filters::actual]);
@ -650,10 +650,11 @@ void ui_menu_select_game::populate()
if (ui_menu::stack_has_special_main_menu())
{
UINT32 flags_ui = MENU_FLAG_UI | MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW;
item_append(_("Configure Options"), nullptr, flags_ui, (void *)(FPTR)1);
item_append(_("Configure Directories"), nullptr, flags_ui, (void *)(FPTR)2);
item_append(_("Save Configuration"), nullptr, flags_ui, (void *)(FPTR)3);
skip_main_items = 3;
item_append(_("Configure Options"), nullptr, flags_ui, (void *)(FPTR)CONF_OPTS);
item_append(_("Configure Directories"), nullptr, flags_ui, (void *)(FPTR)CONF_DIR);
item_append(_("Configure Machine"), nullptr, flags_ui, (void *)(FPTR)CONF_MACHINE);
item_append(_("Save Configuration"), nullptr, flags_ui, (void *)(FPTR)SAVE_CONFIG);
skip_main_items = 4;
}
else
skip_main_items = 0;
@ -999,14 +1000,21 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *m_event)
const game_driver *driver = (const game_driver *)m_event->itemref;
// special case for configure options
if ((FPTR)driver == 1)
if ((FPTR)driver == CONF_OPTS)
ui_menu::stack_push(global_alloc_clear<ui_menu_game_options>(machine(), container));
// special case for configure directory
else if ((FPTR)driver == 2)
else if ((FPTR)driver == CONF_DIR)
ui_menu::stack_push(global_alloc_clear<ui_menu_directory>(machine(), container));
// anything else is a driver
else if ((FPTR)driver == 3) {
// special case for save configuration
else if ((FPTR)driver == SAVE_CONFIG)
save_main_option(machine());
// special case for save configuration
else if ((FPTR)driver == CONF_MACHINE)
{
if (m_prev_selected != nullptr)
ui_menu::stack_push(global_alloc_clear<ui_menu_machine_configure>(machine(), container, (const game_driver *)m_prev_selected));
else
return;
}
// anything else is a driver
else
@ -1063,15 +1071,23 @@ void ui_menu_select_game::inkey_select_favorite(const ui_menu_event *m_event)
ui_options &mopt = machine().ui().options();
// special case for configure options
if ((FPTR)ui_swinfo == 1)
if ((FPTR)ui_swinfo == CONF_OPTS)
ui_menu::stack_push(global_alloc_clear<ui_menu_game_options>(machine(), container));
// special case for configure directory
else if ((FPTR)ui_swinfo == 2)
else if ((FPTR)ui_swinfo == CONF_DIR)
ui_menu::stack_push(global_alloc_clear<ui_menu_directory>(machine(), container));
else if ((FPTR)ui_swinfo == 3)
{
else if ((FPTR)ui_swinfo == SAVE_CONFIG)
save_main_option(machine());
else if ((FPTR)ui_swinfo == CONF_MACHINE)
{
if (m_prev_selected != nullptr)
{
ui_software_info *swinfo = (ui_software_info *)m_prev_selected;
if (swinfo->startempty == 1)
ui_menu::stack_push(global_alloc_clear<ui_menu_machine_configure>(machine(), container, swinfo->driver));
}
else
return;
}
else if (ui_swinfo->startempty == 1)
{
@ -1202,8 +1218,40 @@ void ui_menu_select_game::inkey_configure(const ui_menu_event *m_event)
selected = visible_items + 1;
}
else if (selected > visible_items && m_focus == focused_menu::main)
m_focus = focused_menu::left;
{
if (ui_globals::panels_status != HIDE_LEFT_PANEL)
m_focus = focused_menu::left;
else if (ui_globals::panels_status == HIDE_BOTH)
{
for (int x = 0; x < item.size(); ++x)
if (item[x].ref == m_prev_selected)
selected = x;
}
else
m_focus = focused_menu::righttop;
}
else if (m_focus == focused_menu::left)
{
if (ui_globals::panels_status != HIDE_RIGHT_PANEL)
m_focus = focused_menu::righttop;
else
{
m_focus = focused_menu::main;
if (m_prev_selected == nullptr)
{
selected = 0;
return;
}
for (int x = 0; x < item.size(); ++x)
if (item[x].ref == m_prev_selected)
selected = x;
}
}
else if (m_focus == focused_menu::righttop)
m_focus = focused_menu::rightbottom;
else if (m_focus == focused_menu::rightbottom)
{
m_focus = focused_menu::main;
if (m_prev_selected == nullptr)
@ -1216,8 +1264,6 @@ void ui_menu_select_game::inkey_configure(const ui_menu_event *m_event)
if (item[x].ref == m_prev_selected)
selected = x;
}
else if (m_focus == focused_menu::rightbottom)
m_focus = focused_menu::main;
}
//-------------------------------------------------
@ -1926,8 +1972,22 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
title_size = MAX(txt_lenght, title_size);
}
mui.draw_text_full(container, snaptext.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER,
WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
rgb_t fgcolor = UI_TEXT_COLOR;
rgb_t bgcolor = UI_TEXT_BG_COLOR;
if (m_focus == focused_menu::rightbottom)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
}
float middle = origx2 - origx1;
if (bgcolor != UI_TEXT_BG_COLOR)
mui.draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
origy1 + line_height, bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
mui.draw_text_full(container, snaptext.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER,
WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
draw_common_arrow(origx1, origy1, origx2, origy2, ui_globals::curdats_view, UI_FIRST_LOAD, UI_LAST_LOAD, title_size);
@ -2086,8 +2146,22 @@ void ui_menu_select_game::infos_render(void *selectedref, float origx1, float or
title_size = MAX(txt_lenght, title_size);
}
mui.draw_text_full(container, t_text[ui_globals::cur_sw_dats_view].c_str(), origx1, origy1, origx2 - origx1,
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
rgb_t fgcolor = UI_TEXT_COLOR;
rgb_t bgcolor = UI_TEXT_BG_COLOR;
if (m_focus == focused_menu::rightbottom)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
}
float middle = origx2 - origx1;
if (bgcolor != UI_TEXT_BG_COLOR)
mui.draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
origy1 + line_height, bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
mui.draw_text_full(container, t_text[ui_globals::cur_sw_dats_view].c_str(), origx1, origy1, origx2 - origx1,
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
draw_common_arrow(origx1, origy1, origx2, origy2, ui_globals::cur_sw_dats_view, 0, 1, title_size);
}

View File

@ -37,6 +37,14 @@ public:
virtual void draw_right_panel(void *selectedref, float origx1, float origy1, float origx2, float origy2) override;
private:
enum
{
CONF_OPTS = 1,
CONF_DIR,
CONF_MACHINE,
SAVE_CONFIG
};
enum { VISIBLE_GAMES_IN_SEARCH = 200 };
char m_search[40];
static int m_isabios;

View File

@ -226,6 +226,18 @@ void ui_menu_select_software::handle()
}
}
// handle UI_UP_FILTER
else if (m_event->iptkey == IPT_UI_UP_FILTER && highlight > UI_SW_FIRST)
{
highlight--;
}
// handle UI_DOWN_FILTER
else if (m_event->iptkey == IPT_UI_DOWN_FILTER && highlight < UI_SW_LAST)
{
highlight++;
}
// handle UI_DATS
else if (m_event->iptkey == IPT_UI_DATS && machine().ui().options().enabled_dats())
{
@ -297,6 +309,52 @@ void ui_menu_select_software::handle()
if (m_event->iptkey == IPT_UI_CONFIGURE)
inkey_configure(m_event);
// handle UI_LEFT
else if (m_event->iptkey == IPT_UI_LEFT)
{
// Images
if (ui_globals::rpanel == RP_IMAGES && ui_globals::curimage_view > FIRST_VIEW)
{
ui_globals::curimage_view--;
ui_globals::switch_image = true;
ui_globals::default_image = false;
}
// Infos
else if (ui_globals::rpanel == RP_INFOS && ui_globals::cur_sw_dats_view > 0)
{
ui_globals::cur_sw_dats_view--;
topline_datsview = 0;
}
}
// handle UI_RIGHT
else if (m_event->iptkey == IPT_UI_RIGHT)
{
// Images
if (ui_globals::rpanel == RP_IMAGES && ui_globals::curimage_view < LAST_VIEW)
{
ui_globals::curimage_view++;
ui_globals::switch_image = true;
ui_globals::default_image = false;
}
// Infos
else if (ui_globals::rpanel == RP_INFOS && ui_globals::cur_sw_dats_view < 1)
{
ui_globals::cur_sw_dats_view++;
topline_datsview = 0;
}
}
// handle UI_LEFT_PANEL
else if (m_event->iptkey == IPT_UI_LEFT_PANEL)
ui_globals::rpanel = RP_IMAGES;
// handle UI_RIGHT_PANEL
else if (m_event->iptkey == IPT_UI_RIGHT_PANEL)
ui_globals::rpanel = RP_INFOS;
// handle UI_UP_FILTER
else if (m_event->iptkey == IPT_UI_UP_FILTER && highlight > UI_SW_FIRST)
{
@ -939,8 +997,40 @@ void ui_menu_select_software::inkey_configure(const ui_menu_event *m_event)
selected = visible_items + 1;
}
else if (selected > visible_items && m_focus == focused_menu::main)
m_focus = focused_menu::left;
{
if (ui_globals::panels_status != HIDE_LEFT_PANEL)
m_focus = focused_menu::left;
else if (ui_globals::panels_status == HIDE_BOTH)
{
for (int x = 0; x < item.size(); ++x)
if (item[x].ref == m_prev_selected)
selected = x;
}
else
m_focus = focused_menu::righttop;
}
else if (m_focus == focused_menu::left)
{
if (ui_globals::panels_status != HIDE_RIGHT_PANEL)
m_focus = focused_menu::righttop;
else
{
m_focus = focused_menu::main;
if (m_prev_selected == nullptr)
{
selected = 0;
return;
}
for (int x = 0; x < item.size(); ++x)
if (item[x].ref == m_prev_selected)
selected = x;
}
}
else if (m_focus == focused_menu::righttop)
m_focus = focused_menu::rightbottom;
else if (m_focus == focused_menu::rightbottom)
{
m_focus = focused_menu::main;
if (m_prev_selected == nullptr)
@ -953,8 +1043,6 @@ void ui_menu_select_software::inkey_configure(const ui_menu_event *m_event)
if (item[x].ref == m_prev_selected)
selected = x;
}
else if (m_focus == focused_menu::rightbottom)
m_focus = focused_menu::main;
}
//-------------------------------------------------
@ -1463,7 +1551,6 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
std::vector<int> xstart;
std::vector<int> xend;
float text_size = machine().ui().options().infos_size();
// ui_software_info *soft = (ui_software_info *)selectedref;
ui_software_info *soft = (selectedref != nullptr) ? (ui_software_info *)selectedref : ((m_prev_selected != nullptr) ? (ui_software_info *)m_prev_selected : nullptr);
static ui_software_info *oldsoft = nullptr;
static int old_sw_view = -1;
@ -1475,8 +1562,28 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
// apply title to right panel
if (soft != nullptr && soft->usage.empty())
{
float title_size = 0.0f;
mui.draw_text_full(container, _("History"), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
DRAW_NONE, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, &title_size, nullptr);
title_size += 0.01f;
rgb_t fgcolor = UI_TEXT_COLOR;
rgb_t bgcolor = UI_TEXT_BG_COLOR;
if (m_focus == focused_menu::rightbottom)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
}
float middle = origx2 - origx1;
if (bgcolor != UI_TEXT_BG_COLOR)
mui.draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
origy1 + line_height, bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
mui.draw_text_full(container, _("History"), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
ui_globals::cur_sw_dats_view = 0;
}
else
@ -1490,14 +1597,27 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
for (auto & elem : t_text)
{
mui.draw_text_full(container, elem.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_TRUNCATE,
DRAW_NONE, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, &txt_lenght, nullptr);
DRAW_NONE, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, &txt_lenght, nullptr);
txt_lenght += 0.01f;
title_size = MAX(txt_lenght, title_size);
}
rgb_t fgcolor = UI_TEXT_COLOR;
rgb_t bgcolor = UI_TEXT_BG_COLOR;
if (m_focus == focused_menu::rightbottom)
{
fgcolor = rgb_t(0xff, 0xff, 0xff, 0x00);
bgcolor = rgb_t(0xff, 0xff, 0xff, 0xff);
}
float middle = origx2 - origx1;
if (bgcolor != UI_TEXT_BG_COLOR)
mui.draw_textured_box(container, origx1 + ((middle - title_size) * 0.5f), origy1, origx1 + ((middle + title_size) * 0.5f),
origy1 + line_height, bgcolor, rgb_t(255, 43, 43, 43), hilight_main_texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(TRUE));
mui.draw_text_full(container, t_text[ui_globals::cur_sw_dats_view].c_str(), origx1, origy1, origx2 - origx1,
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR,
nullptr, nullptr);
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
draw_common_arrow(origx1, origy1, origx2, origy2, ui_globals::cur_sw_dats_view, 0, 1, title_size);
}
@ -1521,7 +1641,7 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
if (buffer.empty())
{
mui.draw_text_full(container, _("No Infos Available"), origx1, (origy2 + origy1) * 0.5f, origx2 - origx1, JUSTIFY_CENTER,
WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
return;
}
else
@ -1549,8 +1669,8 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
info_arrow(1, origx1, origx2, oy1, line_height, text_size, ud_arrow_width);
else
mui.draw_text_full(container, tempbuf.c_str(), origx1 + gutter_width, oy1, origx2 - origx1,
JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR,
nullptr, nullptr, text_size);
JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR,
nullptr, nullptr, text_size);
oy1 += (line_height * text_size);
}
@ -1570,7 +1690,6 @@ void ui_menu_select_software::arts_render(void *selectedref, float origx1, float
static const game_driver *olddriver = nullptr;
const game_driver *driver = nullptr;
ui_software_info *soft = (selectedref != nullptr) ? (ui_software_info *)selectedref : ((m_prev_selected != nullptr) ? (ui_software_info *)m_prev_selected : nullptr);
// ui_software_info *soft = (ui_software_info *)selectedref;
if (soft != nullptr && soft->startempty == 1)
{

View File

@ -1,5 +1,5 @@
// license:BSD-3-Clause
// copyright-holders:Dankan1890
// copyright-holders:Maurizio Petrarota
/***************************************************************************
ui/selsoft.h