summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/ui/selsoft.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/ui/selsoft.cpp')
-rw-r--r--src/emu/ui/selsoft.cpp84
1 files changed, 51 insertions, 33 deletions
diff --git a/src/emu/ui/selsoft.cpp b/src/emu/ui/selsoft.cpp
index 3bf2e237553..07172c25306 100644
--- a/src/emu/ui/selsoft.cpp
+++ b/src/emu/ui/selsoft.cpp
@@ -1,5 +1,5 @@
// license:BSD-3-Clause
-// copyright-holders:Dankan1890
+// copyright-holders:Maurizio Petrarota
/***************************************************************************
ui/selsoft.cpp
@@ -86,7 +86,7 @@ bool compare_software(ui_software_info a, ui_software_info b)
// get bios count
//-------------------------------------------------
-bool has_multiple_bios(const game_driver *driver, std::vector<s_bios> &biosname)
+bool has_multiple_bios(const game_driver *driver, s_bios &biosname)
{
if (driver->rom == nullptr)
return 0;
@@ -675,6 +675,7 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
rgb_t color = UI_BACKGROUND_COLOR;
bool isstar = false;
float tbarspace = mui.get_line_height();
+ float text_size = 1.0f;
// determine the text for the header
int vis_item = (m_search[0] != 0) ? visible_items : (m_has_empty_start ? visible_items - 1 : visible_items);
@@ -700,11 +701,17 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
for (int line = 0; line < 3; ++line)
{
mui.draw_text_full(container, tempbuf[line].c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
- DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
+ DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(width, maxwidth);
}
+ if (maxwidth > origx2 - origx1)
+ {
+ text_size = (origx2 - origx1) / maxwidth;
+ maxwidth = origx2 - origx1;
+ }
+
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
float x2 = x1 + maxwidth;
@@ -723,7 +730,7 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
for (int line = 0; line < 3; ++line)
{
mui.draw_text_full(container, tempbuf[line].c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
- DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
+ DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, text_size);
y1 += mui.get_line_height();
}
@@ -773,7 +780,7 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
color = UI_GREEN_COLOR;
if ((driver->flags & (MACHINE_IMPERFECT_GRAPHICS | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_COLORS
- | MACHINE_NO_SOUND | MACHINE_IMPERFECT_SOUND)) != 0)
+ | MACHINE_NO_SOUND | MACHINE_IMPERFECT_SOUND)) != 0)
color = UI_YELLOW_COLOR;
if ((driver->flags & (MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION)) != 0)
@@ -845,11 +852,17 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
for (auto & elem : tempbuf)
{
mui.draw_text_full(container, elem.c_str(), 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_NEVER,
- DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
+ DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
maxwidth = MAX(maxwidth, width);
}
+ if (maxwidth > origx2 - origx1)
+ {
+ text_size = (origx2 - origx1) / maxwidth;
+ maxwidth = origx2 - origx1;
+ }
+
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
x2 = x1 + maxwidth;
@@ -872,7 +885,7 @@ void ui_menu_select_software::custom_render(void *selectedref, float top, float
for (auto & elem : tempbuf)
{
mui.draw_text_full(container, elem.c_str(), x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_NEVER,
- DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
+ DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr, text_size);
y1 += machine().ui().get_line_height();
}
}
@@ -888,7 +901,7 @@ void ui_menu_select_software::inkey_select(const ui_menu_event *m_event)
if (ui_swinfo->startempty == 1)
{
- std::vector<s_bios> biosname;
+ s_bios biosname;
if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname))
ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(machine(), container, biosname, (void *)ui_swinfo->driver, false, true));
else
@@ -916,7 +929,7 @@ void ui_menu_select_software::inkey_select(const ui_menu_event *m_event)
if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE || summary == media_auditor::NONE_NEEDED)
{
- std::vector<s_bios> biosname;
+ s_bios biosname;
if (!mopt.skip_bios_menu() && has_multiple_bios(ui_swinfo->driver, biosname))
{
ui_menu::stack_push(global_alloc_clear<ui_bios_selection>(machine(), container, biosname, (void *)ui_swinfo, true, false));
@@ -924,7 +937,7 @@ void ui_menu_select_software::inkey_select(const ui_menu_event *m_event)
}
else if (!mopt.skip_parts_menu() && swinfo->has_multiple_parts(ui_swinfo->interface.c_str()))
{
- std::unordered_map<std::string, std::string> parts;
+ s_parts parts;
for (const software_part *swpart = swinfo->first_part(); swpart != nullptr; swpart = swpart->next())
{
if (swpart->matches_interface(ui_swinfo->interface.c_str()))
@@ -1049,7 +1062,7 @@ void ui_menu_select_software::load_sw_custom_filters()
{
// attempt to open the output file
emu_file file(machine().ui().options().ui_path(), OPEN_FLAG_READ);
- if (file.open("custom_", m_driver->name, "_filter.ini") == FILERR_NONE)
+ if (file.open("custom_", m_driver->name, "_filter.ini") == osd_file::error::NONE)
{
char buffer[MAX_CHAR_INFO];
@@ -1487,15 +1500,15 @@ float ui_menu_select_software::draw_left_panel(float x1, float y1, float x2, flo
x2 = x1 + 2.0f * UI_BOX_LR_BORDER;
y1 = origy1;
y2 = origy2;
- line_height = mui.get_line_height();
- float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect();
+ float space = x2 - x1;
+ float lr_arrow_width = 0.4f * space * machine().render().ui_aspect();
rgb_t fgcolor = UI_TEXT_COLOR;
// set left-right arrows dimension
float ar_x0 = 0.5f * (x2 + x1) - 0.5f * lr_arrow_width;
- float ar_y0 = 0.5f * (y2 + y1) + 0.1f * line_height;
+ float ar_y0 = 0.5f * (y2 + y1) + 0.1f * space;
float ar_x1 = ar_x0 + lr_arrow_width;
- float ar_y1 = 0.5f * (y2 + y1) + 0.9f * line_height;
+ float ar_y1 = 0.5f * (y2 + y1) + 0.9f * space;
//machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
mui.draw_outlined_box(container, x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
@@ -1511,15 +1524,15 @@ float ui_menu_select_software::draw_left_panel(float x1, float y1, float x2, flo
}
else
{
- float line_height = mui.get_line_height();
- float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect();
+ float space = x2 - x1;
+ float lr_arrow_width = 0.4f * space * machine().render().ui_aspect();
rgb_t fgcolor = UI_TEXT_COLOR;
// set left-right arrows dimension
float ar_x0 = 0.5f * (x2 + x1) - 0.5f * lr_arrow_width;
- float ar_y0 = 0.5f * (y2 + y1) + 0.1f * line_height;
+ float ar_y0 = 0.5f * (y2 + y1) + 0.1f * space;
float ar_x1 = ar_x0 + lr_arrow_width;
- float ar_y1 = 0.5f * (y2 + y1) + 0.9f * line_height;
+ float ar_y1 = 0.5f * (y2 + y1) + 0.9f * space;
//machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
mui.draw_outlined_box(container, x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
@@ -1578,7 +1591,7 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
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,
+ mui.draw_text_full(container, _("History"), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);
ui_globals::cur_sw_dats_view = 0;
}
@@ -1592,7 +1605,7 @@ 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,
+ mui.draw_text_full(container, elem.c_str(), origx1, origy1, origx2 - origx1, JUSTIFY_CENTER, WRAP_NEVER,
DRAW_NONE, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, &txt_lenght, nullptr);
txt_lenght += 0.01f;
title_size = MAX(txt_lenght, title_size);
@@ -1608,12 +1621,17 @@ void ui_menu_select_software::infos_render(void *selectedref, float origx1, floa
float middle = origx2 - origx1;
+ // check size
+ float sc = title_size + 2.0f * gutter_width;
+ float tmp_size = (sc > middle) ? ((middle - 2.0f * gutter_width) / sc) : 1.0f;
+ title_size *= tmp_size;
+
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);
+ JUSTIFY_CENTER, WRAP_NEVER, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr, tmp_size);
draw_common_arrow(origx1, origy1, origx2, origy2, ui_globals::cur_sw_dats_view, 0, 1, title_size);
}
@@ -1867,17 +1885,17 @@ void ui_menu_select_software::arts_render(void *selectedref, float origx1, float
void ui_menu_select_software::draw_right_panel(void *selectedref, float origx1, float origy1, float origx2, float origy2)
{
ui_manager &mui = machine().ui();
- float line_height = mui.get_line_height();
- float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect();
rgb_t fgcolor = UI_TEXT_COLOR;
bool hide = (ui_globals::panels_status == HIDE_RIGHT_PANEL || ui_globals::panels_status == HIDE_BOTH);
float x2 = (hide) ? origx2 : origx1 + 2.0f * UI_BOX_LR_BORDER;
+ float space = x2 - origx1;
+ float lr_arrow_width = 0.4f * space * machine().render().ui_aspect();
// set left-right arrows dimension
float ar_x0 = 0.5f * (x2 + origx1) - 0.5f * lr_arrow_width;
- float ar_y0 = 0.5f * (origy2 + origy1) + 0.1f * line_height;
+ float ar_y0 = 0.5f * (origy2 + origy1) + 0.1f * space;
float ar_x1 = ar_x0 + lr_arrow_width;
- float ar_y1 = 0.5f * (origy2 + origy1) + 0.9f * line_height;
+ float ar_y1 = 0.5f * (origy2 + origy1) + 0.9f * space;
//machine().ui().draw_outlined_box(container, origx1, origy1, origx2, origy2, UI_BACKGROUND_COLOR);
mui.draw_outlined_box(container, origx1, origy1, origx2, origy2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
@@ -1908,7 +1926,7 @@ void ui_menu_select_software::draw_right_panel(void *selectedref, float origx1,
// ctor
//-------------------------------------------------
-ui_software_parts::ui_software_parts(running_machine &machine, render_container *container, std::unordered_map<std::string, std::string> parts, ui_software_info *ui_info) : ui_menu(machine, container)
+ui_software_parts::ui_software_parts(running_machine &machine, render_container *container, s_parts parts, ui_software_info *ui_info) : ui_menu(machine, container)
{
m_parts = parts;
m_uiinfo = ui_info;
@@ -2001,7 +2019,7 @@ void ui_software_parts::custom_render(void *selectedref, float top, float bottom
// ctor
//-------------------------------------------------
-ui_bios_selection::ui_bios_selection(running_machine &machine, render_container *container, std::vector<s_bios> biosname, void *_driver, bool _software, bool _inlist) : ui_menu(machine, container)
+ui_bios_selection::ui_bios_selection(running_machine &machine, render_container *container, s_bios biosname, void *_driver, bool _software, bool _inlist) : ui_menu(machine, container)
{
m_bios = biosname;
m_driver = _driver;
@@ -2024,7 +2042,7 @@ ui_bios_selection::~ui_bios_selection()
void ui_bios_selection::populate()
{
for (auto & elem : m_bios)
- item_append(elem.name.c_str(), nullptr, 0, (void *)&elem.name);
+ item_append(elem.first.c_str(), nullptr, 0, (void *)&elem.first);
item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
customtop = machine().ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
@@ -2041,7 +2059,7 @@ void ui_bios_selection::handle()
emu_options &moptions = machine().options();
if (event != nullptr && event->iptkey == IPT_UI_SELECT && event->itemref != nullptr)
for (auto & elem : m_bios)
- if ((void*)&elem.name == event->itemref)
+ if ((void*)&elem.first == event->itemref)
{
if (!m_software)
{
@@ -2057,7 +2075,7 @@ void ui_bios_selection::handle()
}
std::string error;
- moptions.set_value("bios", elem.id, OPTION_PRIORITY_CMDLINE, error);
+ moptions.set_value("bios", elem.second, OPTION_PRIORITY_CMDLINE, error);
machine().manager().schedule_new_driver(*s_driver);
machine().schedule_hard_reset();
ui_menu::stack_reset(machine());
@@ -2066,14 +2084,14 @@ void ui_bios_selection::handle()
{
ui_software_info *ui_swinfo = (ui_software_info *)m_driver;
std::string error;
- machine().options().set_value("bios", elem.id, OPTION_PRIORITY_CMDLINE, error);
+ machine().options().set_value("bios", elem.second, OPTION_PRIORITY_CMDLINE, error);
driver_enumerator drivlist(machine().options(), *ui_swinfo->driver);
drivlist.next();
software_list_device *swlist = software_list_device::find_by_name(drivlist.config(), ui_swinfo->listname.c_str());
software_info *swinfo = swlist->find(ui_swinfo->shortname.c_str());
if (!machine().ui().options().skip_parts_menu() && swinfo->has_multiple_parts(ui_swinfo->interface.c_str()))
{
- std::unordered_map<std::string, std::string> parts;
+ s_parts parts;
for (const software_part *swpart = swinfo->first_part(); swpart != nullptr; swpart = swpart->next())
{
if (swpart->matches_interface(ui_swinfo->interface.c_str()))