summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/ui/selsoft.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/mame/ui/selsoft.cpp')
-rw-r--r--src/frontend/mame/ui/selsoft.cpp184
1 files changed, 99 insertions, 85 deletions
diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp
index 051b09b4fcf..5a0a4f1eb87 100644
--- a/src/frontend/mame/ui/selsoft.cpp
+++ b/src/frontend/mame/ui/selsoft.cpp
@@ -14,9 +14,9 @@
#include "ui/ui.h"
#include "ui/icorender.h"
#include "ui/inifile.h"
+#include "ui/miscmenu.h"
#include "ui/selector.h"
-#include "corestr.h"
#include "drivenum.h"
#include "emuopts.h"
#include "fileio.h"
@@ -25,6 +25,9 @@
#include "softlist_dev.h"
#include "uiinput.h"
#include "luaengine.h"
+
+#include "corestr.h"
+#include "path.h"
#include "unicode.h"
#include <algorithm>
@@ -85,6 +88,8 @@ public:
, m_filter_type(software_filter::ALL)
, m_swinfo()
, m_searchlist()
+ , m_right_panel(menu.right_panel())
+ , m_right_image(menu.right_image())
{
// add start empty item
m_swinfo.emplace_back(*menu.m_system.driver);
@@ -219,7 +224,8 @@ public:
}
// sort array
- std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(std::locale());
+ std::locale const lcl;
+ std::collate<wchar_t> const &coll = std::use_facet<std::collate<wchar_t> >(lcl);
auto const compare_names =
[&coll] (std::string const &x, std::string const &y) -> bool
{
@@ -345,6 +351,11 @@ public:
return m_searchlist;
}
+ u8 right_panel() const { return m_right_panel; }
+ u8 right_image() const { return m_right_image; }
+ void set_right_panel(u8 index) { m_right_panel = index; }
+ void set_right_image(u8 index) { m_right_image = index; }
+
private:
icon_cache m_icons;
bool m_has_empty_start;
@@ -354,6 +365,9 @@ private:
std::vector<ui_software_info> m_swinfo;
std::vector<search_item> m_searchlist;
+ u8 m_right_panel;
+ u8 m_right_image;
+
std::unique_ptr<std::thread> m_search_thread;
};
@@ -372,8 +386,21 @@ menu_select_software::menu_select_software(mame_ui_manager &mui, render_containe
using machine_data_cache = util::lru_cache_map<game_driver const *, std::shared_ptr<machine_data> >;
auto &cached(mui.get_session_data<menu_select_software, machine_data_cache>(8)[system.driver]);
- if (!cached)
+ if (cached)
+ {
+ // restore last right panel settings for this machine
+ set_right_panel(cached->right_panel());
+ set_right_image(cached->right_image());
+ }
+ else
+ {
+ // restore last right panel settings from UI options
+ ui_options &moptions = ui().options();
+ set_right_panel(moptions.software_right_panel());
+ set_right_image(moptions.software_right_image());
+
cached = std::make_shared<machine_data>(*this);
+ }
m_data = cached;
m_filter_highlight = m_data->filter_type();
@@ -395,7 +422,7 @@ menu_select_software::~menu_select_software()
// handle
//-------------------------------------------------
-void menu_select_software::handle(event const *ev)
+bool menu_select_software::handle(event const *ev)
{
if (m_prev_selected == nullptr && item_count() > 0)
m_prev_selected = item(0).ref();
@@ -403,65 +430,19 @@ void menu_select_software::handle(event const *ev)
// FIXME: everything above here used run before events were processed
// process the menu
+ bool changed = false;
if (ev)
{
if (dismiss_error())
{
// reset the error on any subsequent menu event
+ changed = true;
}
else switch (ev->iptkey)
{
case IPT_UI_SELECT:
if ((get_focus() == focused_menu::MAIN) && ev->itemref)
- inkey_select(ev);
- break;
-
- case IPT_UI_LEFT:
- if (ui_globals::rpanel == RP_IMAGES)
- {
- // Images
- previous_image_view();
- }
- else if (ui_globals::rpanel == RP_INFOS && ui_globals::cur_sw_dats_view > 0)
- {
- // Infos
- ui_globals::cur_sw_dats_view--;
- m_topline_datsview = 0;
- }
- break;
-
- case IPT_UI_RIGHT:
- if (ui_globals::rpanel == RP_IMAGES)
- {
- // Images
- next_image_view();
- }
- else if (ui_globals::rpanel == RP_INFOS && ui_globals::cur_sw_dats_view < (ui_globals::cur_sw_dats_total - 1))
- {
- // Infos
- ui_globals::cur_sw_dats_view++;
- m_topline_datsview = 0;
- }
- break;
-
- case IPT_UI_UP:
- if ((get_focus() == focused_menu::LEFT) && (software_filter::FIRST < m_filter_highlight))
- --m_filter_highlight;
- break;
-
- case IPT_UI_DOWN:
- if ((get_focus() == focused_menu::LEFT) && (software_filter::LAST > m_filter_highlight))
- ++m_filter_highlight;
- break;
-
- case IPT_UI_HOME:
- if (get_focus() == focused_menu::LEFT)
- m_filter_highlight = software_filter::FIRST;
- break;
-
- case IPT_UI_END:
- if (get_focus() == focused_menu::LEFT)
- m_filter_highlight = software_filter::LAST;
+ changed = inkey_select(ev);
break;
case IPT_UI_DATS:
@@ -484,27 +465,54 @@ void menu_select_software::handle(event const *ev)
mfav.add_favorite_software(*swinfo);
machine().popmessage(_("%s\n added to favorites list."), swinfo->longname);
}
-
else
{
machine().popmessage(_("%s\n removed from favorites list."), swinfo->longname);
mfav.remove_favorite_software(*swinfo);
}
+ changed = true;
}
}
}
}
}
- // if we're in an error state, overlay an error message
- draw_error_text();
+ return changed;
+}
+
+//-------------------------------------------------
+// recompute_metrics
+//-------------------------------------------------
+
+void menu_select_software::recompute_metrics(uint32_t width, uint32_t height, float aspect)
+{
+ menu_select_launch::recompute_metrics(width, height, aspect);
+
+ // configure the custom rendering
+ set_custom_space(4.0F * line_height() + 5.0F * tb_border(), 4.0F * line_height() + 3.0F * tb_border());
+}
+
+//-------------------------------------------------
+// menu_deactivated
+//-------------------------------------------------
+
+void menu_select_software::menu_deactivated()
+{
+ menu_select_launch::menu_deactivated();
+
+ // save last right panel settings
+ m_data->set_right_panel(right_panel());
+ m_data->set_right_image(right_image());
+ ui_options &mopt = ui().options();
+ mopt.set_value(OPTION_SOFTWARE_RIGHT_PANEL, right_panel_config_string(), OPTION_PRIORITY_CMDLINE);
+ mopt.set_value(OPTION_SOFTWARE_RIGHT_IMAGE, right_image_config_string(), OPTION_PRIORITY_CMDLINE);
}
//-------------------------------------------------
// populate
//-------------------------------------------------
-void menu_select_software::populate(float &customtop, float &custombottom)
+void menu_select_software::populate()
{
for (auto &icon : m_data->icons()) // TODO: why is this here? maybe better on resize or setting change?
icon.second.texture.reset();
@@ -564,15 +572,12 @@ void menu_select_software::populate(float &customtop, float &custombottom)
m_displaylist[curitem].get().parentname.empty() ? 0 : FLAG_INVERT, (void *)&m_displaylist[curitem].get());
}
- // configure the custom rendering
- skip_main_items = 0;
- customtop = 4.0f * ui().get_line_height() + 5.0f * ui().box_tb_border();
- custombottom = 4.0f * ui().get_line_height() + 4.0f * ui().box_tb_border();
+ m_skip_main_items = 0;
if (old_software != -1)
{
set_selected_index(old_software);
- top_line = selected_index() - (ui_globals::visible_sw_lines / 2);
+ centre_selection();
}
reselect_last::reset();
@@ -583,7 +588,7 @@ void menu_select_software::populate(float &customtop, float &custombottom)
// handle select key event
//-------------------------------------------------
-void menu_select_software::inkey_select(const event *menu_event)
+bool menu_select_software::inkey_select(const event *menu_event)
{
ui_software_info *ui_swinfo = (ui_software_info *)menu_event->itemref;
driver_enumerator drivlist(machine().options(), *ui_swinfo->driver);
@@ -595,6 +600,7 @@ void menu_select_software::inkey_select(const event *menu_event)
if (!audit_passed(sysaudit))
{
set_error(reset_options::REMEMBER_REF, make_system_audit_fail_text(auditor, sysaudit));
+ return true;
}
else if (ui_swinfo->startempty == 1)
{
@@ -603,6 +609,7 @@ void menu_select_software::inkey_select(const event *menu_event)
reselect_last::reselect(true);
launch_system(*ui_swinfo->driver, *ui_swinfo);
}
+ return false;
}
else
{
@@ -618,11 +625,13 @@ void menu_select_software::inkey_select(const event *menu_event)
reselect_last::reselect(true);
launch_system(drivlist.driver(), *ui_swinfo);
}
+ return false;
}
else
{
// otherwise, display an error
set_error(reset_options::REMEMBER_REF, make_software_audit_fail_text(auditor, swaudit));
+ return true;
}
}
}
@@ -632,9 +641,9 @@ void menu_select_software::inkey_select(const event *menu_event)
// draw left box
//-------------------------------------------------
-float menu_select_software::draw_left_panel(float x1, float y1, float x2, float y2)
+void menu_select_software::draw_left_panel(u32 flags)
{
- return menu_select_launch::draw_left_panel<software_filter>(m_data->filter_type(), m_data->filters(), x1, y1, x2, y2);
+ return menu_select_launch::draw_left_panel<software_filter>(flags, m_data->filter_type(), m_data->filters());
}
@@ -699,12 +708,18 @@ void menu_select_software::get_selection(ui_software_info const *&software, ui_s
}
+void menu_select_software::show_config_menu(int index)
+{
+ menu::stack_push<menu_machine_configure>(ui(), container(), m_system, nullptr);
+}
+
+
void menu_select_software::make_topbox_text(std::string &line0, std::string &line1, std::string &line2) const
{
// determine the text for the header
int vis_item = !m_search.empty() ? m_available_items : (m_available_items - 1);
line0 = string_format(_("%1$s %2$s ( %3$d / %4$d software packages )"), emulator_info::get_appname(), bare_build_version, vis_item, m_data->swinfo().size() - 1);
- line1 = string_format(_("System: \"%1$s\" software list "), m_system.description);
+ line1 = string_format(_("%1$s - select software"), m_system.description);
software_filter const *const it(m_data->current_filter());
char const *const filter(it ? it->filter_text() : nullptr);
@@ -722,29 +737,28 @@ std::string menu_select_software::make_software_description(ui_software_info con
}
-void menu_select_software::filter_selected()
+void menu_select_software::filter_selected(int index)
{
- if ((software_filter::FIRST <= m_filter_highlight) && (software_filter::LAST >= m_filter_highlight))
- {
- m_data->get_filter(software_filter::type(m_filter_highlight)).show_ui(
- ui(),
- container(),
- [this] (software_filter &filter)
+ assert((software_filter::FIRST <= index) && (software_filter::LAST >= index));
+
+ m_data->get_filter(software_filter::type(index)).show_ui(
+ ui(),
+ container(),
+ [this] (software_filter &filter)
+ {
+ software_filter::type const new_type(filter.get_type());
+ if (software_filter::CUSTOM == new_type)
{
- software_filter::type const new_type(filter.get_type());
- if (software_filter::CUSTOM == new_type)
+ emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
+ if (!file.open(util::string_format("custom_%s_filter.ini", m_system.driver->name)))
{
- emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (!file.open(util::string_format("custom_%s_filter.ini", m_system.driver->name)))
- {
- filter.save_ini(file, 0);
- file.close();
- }
+ filter.save_ini(file, 0);
+ file.close();
}
- m_data->set_filter_type(new_type);
- reset(reset_options::REMEMBER_REF);
- });
- }
+ }
+ m_data->set_filter_type(new_type);
+ reset(reset_options::REMEMBER_REF);
+ });
}
} // namespace ui