summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-10-18 08:22:21 +1100
committer Vas Crabb <vas@vastheman.com>2021-10-18 08:22:21 +1100
commit40a30af10f05f6567f717e4d1004f7bae01b85a2 (patch)
tree13990300ff0940a5195192a6d76a55df58fa5c5a /src/frontend
parent0a82b82684115f7d5334e65cef8c4297a50c4e19 (diff)
Still more user experience improvements:
Changed the default mapping for UI select to not trigger on Alt+Enter fullscreen toggle. (Fullscreen toggle still doesn't work in menus - actually fixing that is complicated.) frontend: Made the about box wrap text properly, made the title and backtrack menu item always visible, and added a footer with the VCS revision. frontend: Don't highlight the favourites and info toolbar buttons if there's no selection (can happen if filters produce no results). Also made the info viewer appear even if no info is available - it's less confusing to see an empty menu than wonder why clicking the button does nothing. debugger: Added a register points view to the GUI debuggers, to go with the breakpoints and watchpoints views. debugger: Extended [brw]p(clear|(en|dis)able) commands to accept multiple arguments to perform the same action on multiple (break|watch|register)points at once. Also made rplist accept a CPU for showing a single CPU's register points ([bw]plist already support this). docs: Updated registerpoints debugger commands page, and updated other pages for latest extensions to syntax.
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/mame/mame.h1
-rw-r--r--src/frontend/mame/ui/about.cpp222
-rw-r--r--src/frontend/mame/ui/about.h16
-rw-r--r--src/frontend/mame/ui/datmenu.cpp78
-rw-r--r--src/frontend/mame/ui/datmenu.h4
-rw-r--r--src/frontend/mame/ui/selmenu.cpp27
6 files changed, 271 insertions, 77 deletions
diff --git a/src/frontend/mame/mame.h b/src/frontend/mame/mame.h
index 037d714b39c..5fb5a2f4a81 100644
--- a/src/frontend/mame/mame.h
+++ b/src/frontend/mame/mame.h
@@ -92,5 +92,6 @@ private:
extern const char build_version[];
extern const char bare_build_version[];
+extern const char bare_vcs_revision[];
#endif // MAME_FRONTEND_MAME_MAME_H
diff --git a/src/frontend/mame/ui/about.cpp b/src/frontend/mame/ui/about.cpp
index b55267d1b96..bac2c3b4bdc 100644
--- a/src/frontend/mame/ui/about.cpp
+++ b/src/frontend/mame/ui/about.cpp
@@ -1,21 +1,23 @@
// license:BSD-3-Clause
-// copyright-holders:Ryan Holtz
+// copyright-holders:Vas Crabb
/***************************************************************************
ui/about.cpp
- "About" modal
+ About box
***************************************************************************/
#include "emu.h"
-
#include "ui/about.h"
+
#include "ui/ui.h"
#include "ui/utils.h"
#include "mame.h"
-#include "osdcore.h"
+
+#include <string_view>
+
namespace ui {
@@ -25,10 +27,9 @@ namespace {
} // anonymous namespace
-/**************************************************
-
- ABOUT MODAL
+/**************************************************
+ ABOUT BOX
**************************************************/
@@ -38,6 +39,8 @@ namespace {
menu_about::menu_about(mame_ui_manager &mui, render_container &container)
: menu(mui, container)
+ , m_title(util::string_format(_("%1$s %2$s"), emulator_info::get_appname(), bare_build_version))
+ , m_footer(util::string_format(_("Revision: %1$s"), bare_vcs_revision))
{
}
@@ -52,19 +55,174 @@ menu_about::~menu_about()
//-------------------------------------------------
-// populate - populates the about modal
+// perform our special rendering
//-------------------------------------------------
-void menu_about::populate(float &customtop, float &custombottom)
+void menu_about::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
+{
+ std::string_view tempbuf[1];
+
+ // draw the title
+ tempbuf[0] = m_title;
+ draw_text_box(
+ std::begin(tempbuf), std::end(tempbuf),
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
+ text_layout::text_justify::CENTER, text_layout::word_wrapping::TRUNCATE, false,
+ ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
+
+ // draw the footer
+ tempbuf[0] = m_footer;
+ draw_text_box(
+ std::begin(tempbuf), std::end(tempbuf),
+ origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom,
+ text_layout::text_justify::CENTER, text_layout::word_wrapping::NEVER, false,
+ ui().colors().text_color(), ui().colors().background_color(), 1.0f);
+}
+
+
+//-------------------------------------------------
+// draw - draw about
+//-------------------------------------------------
+
+void menu_about::draw(uint32_t flags)
{
- std::string title = string_format(_("%1$s %2$s"), emulator_info::get_appname(), bare_build_version);
- item_append(title, 0, nullptr);
- item_append(menu_item_type::SEPARATOR);
+ rgb_t const color = ui().colors().text_color();
+ float const aspect = machine().render().ui_aspect(&container());
+ float const line_height = ui().get_line_height();
+ float const ud_arrow_width = line_height * aspect;
+ float const gutter_width = 0.52f * line_height * aspect;
+ float const visible_width = 1.0f - (2.0f * ui().box_lr_border() * aspect);
+ float const visible_left = (1.0f - visible_width) * 0.5f;
+ float const extra_height = 2.0f * line_height;
+ float const visible_extra_menu_height = get_customtop() + get_custombottom() + extra_height;
+
+ // determine effective positions taking into account the hilighting arrows
+ float const maximum_width = visible_width - 2.0f * gutter_width;
+
+ draw_background();
+ map_mouse();
+
+ // account for extra space at the top and bottom
+ float visible_main_menu_height = 1.0f - 2.0f * ui().box_tb_border() - visible_extra_menu_height;
+ m_visible_lines = int(std::trunc(visible_main_menu_height / line_height));
+ visible_main_menu_height = float(m_visible_lines) * line_height;
+
+ // compute top/left of inner menu area by centering, if the menu is at the bottom of the extra, adjust
+ float const visible_top = ((1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f) + get_customtop();
+
+ // lay out the text if necessary
+ if (!m_layout || (m_layout->width() != maximum_width))
+ {
+ m_layout.emplace(ui().create_layout(container(), maximum_width));
+ for (char const *const *line = copying_text; *line; ++line)
+ {
+ m_layout->add_text(*line, color);
+ m_layout->add_text("\n", color);
+ }
+ }
+ float const actual_width = m_layout->actual_width();
+
+ // compute text box size
+ float const x1 = visible_left + ((maximum_width - actual_width) * 0.5f);
+ float const y1 = visible_top - ui().box_tb_border();
+ float const x2 = visible_left + visible_width - ((maximum_width - actual_width) * 0.5f);
+ float const y2 = visible_top + visible_main_menu_height + ui().box_tb_border() + extra_height;
+ float const effective_left = x1 + gutter_width;
+ float const line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
+ float const line_x1 = x2 - 0.5f * UI_LINE_WIDTH;
+ float const separator = visible_top + float(m_visible_lines) * line_height;
- for (char const *const *line = copying_text; *line; ++line)
- item_append(*line, 0, nullptr);
+ ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color());
- item_append(menu_item_type::SEPARATOR);
+ int const visible_items = m_layout->lines();
+ m_visible_lines = (std::min)(visible_items, m_visible_lines);
+ top_line = (std::max)(0, top_line);
+ if (top_line + m_visible_lines >= visible_items)
+ top_line = visible_items - m_visible_lines;
+
+ clear_hover();
+ if (top_line)
+ {
+ // if we're on the top line, display the up arrow
+ rgb_t fgcolor = ui().colors().text_color();
+ if (mouse_in_rect(line_x0, visible_top, line_x1, visible_top + line_height))
+ {
+ fgcolor = ui().colors().mouseover_color();
+ highlight(
+ line_x0, visible_top,
+ line_x1, visible_top + line_height,
+ ui().colors().mouseover_bg_color());
+ set_hover(HOVER_ARROW_UP);
+ }
+ draw_arrow(
+ 0.5f * (x1 + x2) - 0.5f * ud_arrow_width, visible_top + 0.25f * line_height,
+ 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, visible_top + 0.75f * line_height,
+ fgcolor, ROT0);
+ }
+ if ((top_line + m_visible_lines) < visible_items)
+ {
+ // if we're on the bottom line, display the down arrow
+ float const line_y = visible_top + float(m_visible_lines - 1) * line_height;
+ rgb_t fgcolor = ui().colors().text_color();
+ if (mouse_in_rect(line_x0, line_y, line_x1, line_y + line_height))
+ {
+ fgcolor = ui().colors().mouseover_color();
+ highlight(
+ line_x0, line_y,
+ line_x1, line_y + line_height,
+ ui().colors().mouseover_bg_color());
+ set_hover(HOVER_ARROW_DOWN);
+ }
+ draw_arrow(
+ 0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height,
+ 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height,
+ fgcolor, ROT0 ^ ORIENTATION_FLIP_Y);
+ }
+
+ // return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow
+ m_visible_items = m_visible_lines - (top_line ? 1 : 0) - (top_line + m_visible_lines != visible_items);
+ m_layout->emit(
+ container(),
+ top_line ? (top_line + 1) : 0, m_visible_items,
+ effective_left, visible_top + (top_line ? line_height : 0.0f));
+
+ // add visual separator before the "return to prevous menu" item
+ container().add_line(
+ x1, separator + (0.5f * line_height),
+ x2, separator + (0.5f * line_height),
+ UI_LINE_WIDTH, ui().colors().text_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
+
+ menu_item const &pitem = item(0);
+ std::string_view const itemtext = pitem.text;
+ float const line_y0 = separator + line_height;
+ float const line_y1 = line_y0 + line_height;
+
+ if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem))
+ set_hover(0);
+
+ highlight(line_x0, line_y0, line_x1, line_y1, ui().colors().selected_bg_color());
+ ui().draw_text_full(
+ container(), itemtext,
+ effective_left, line_y0, actual_width,
+ text_layout::text_justify::CENTER, text_layout::word_wrapping::TRUNCATE,
+ mame_ui_manager::NORMAL,
+ ui().colors().selected_color(), ui().colors().selected_bg_color(),
+ nullptr, nullptr);
+
+ // if there is something special to add, do it by calling the virtual method
+ custom_render(get_selection_ref(), get_customtop(), get_custombottom(), x1, y1, x2, y2);
+}
+
+
+//-------------------------------------------------
+// populate - populates the about modal
+//-------------------------------------------------
+
+void menu_about::populate(float &customtop, float &custombottom)
+{
+ // make space for the title and revision
+ customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
+ custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
@@ -74,13 +232,35 @@ void menu_about::populate(float &customtop, float &custombottom)
void menu_about::handle()
{
- // process the menu
- const event *event = process(0);
-
- // process the event
- if (event && (event->iptkey == IPT_UI_SELECT))
+ const event *event = process(PROCESS_CUSTOM_NAV);
+ if (event)
{
- stack_pop();
+ switch (event->iptkey)
+ {
+ case IPT_UI_UP:
+ --top_line;
+ break;
+
+ case IPT_UI_DOWN:
+ ++top_line;
+ break;
+
+ case IPT_UI_PAGE_UP:
+ top_line -= m_visible_lines - 3;
+ break;
+
+ case IPT_UI_PAGE_DOWN:
+ top_line += m_visible_lines - 3;
+ break;
+
+ case IPT_UI_HOME:
+ top_line = 0;
+ break;
+
+ case IPT_UI_END:
+ top_line = m_layout->lines() - m_visible_lines;
+ break;
+ }
}
}
diff --git a/src/frontend/mame/ui/about.h b/src/frontend/mame/ui/about.h
index 2e68b7ed090..b96c7ee2055 100644
--- a/src/frontend/mame/ui/about.h
+++ b/src/frontend/mame/ui/about.h
@@ -1,10 +1,10 @@
// license:BSD-3-Clause
-// copyright-holders:Ryan Holtz
+// copyright-holders:Vas Crabb
/***************************************************************************
ui/about.h
- "About" modal
+ About box
***************************************************************************/
#ifndef MAME_FRONTEND_UI_ABOUT_H
@@ -14,7 +14,9 @@
#include "ui/menu.h"
-#include <vector>
+#include <optional>
+#include <string>
+
namespace ui {
@@ -24,9 +26,17 @@ public:
menu_about(mame_ui_manager &mui, render_container &container);
virtual ~menu_about() override;
+protected:
+ virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
+
private:
+ virtual void draw(uint32_t flags) override;
virtual void populate(float &customtop, float &custombottom) override;
virtual void handle() override;
+
+ std::string const m_title;
+ std::string const m_footer;
+ std::optional<text_layout> m_layout;
};
} // namespace ui
diff --git a/src/frontend/mame/ui/datmenu.cpp b/src/frontend/mame/ui/datmenu.cpp
index f25ece6015a..d77d3510e00 100644
--- a/src/frontend/mame/ui/datmenu.cpp
+++ b/src/frontend/mame/ui/datmenu.cpp
@@ -1,5 +1,5 @@
// license:BSD-3-Clause
-// copyright-holders:Maurizio Petrarota
+// copyright-holders:Maurizio Petrarota, Vas Crabb
/*********************************************************************
ui/datmenu.cpp
@@ -140,7 +140,7 @@ void menu_dats_view::add_info_text(text_layout &layout, std::string_view text, r
if (std::string_view::npos != split)
{
layout.add_text(line.substr(0, split), text_layout::text_justify::LEFT, color, rgb_t::transparent(), size);
- layout.add_text(" ", text_layout::text_layout::text_justify::LEFT, color, rgb_t::transparent(), size);
+ layout.add_text(" ", text_layout::text_justify::LEFT, color, rgb_t::transparent(), size);
layout.add_text(line.substr(split + 1), text_layout::text_justify::RIGHT, color, rgb_t::transparent(), size);
}
else
@@ -278,10 +278,13 @@ void menu_dats_view::draw(uint32_t flags)
if (!m_layout || (m_layout->width() != effective_width))
{
std::string buffer;
- if (m_issoft)
- get_data_sw(buffer);
- else
- get_data(buffer);
+ if (!m_items_list.empty())
+ {
+ if (m_issoft)
+ get_data_sw(buffer);
+ else
+ get_data(buffer);
+ }
m_layout.emplace(ui().create_layout(container(), effective_width));
add_info_text(*m_layout, buffer, ui().colors().text_color());
}
@@ -339,8 +342,8 @@ void menu_dats_view::draw(uint32_t flags)
// add visual separator before the "return to prevous menu" item
container().add_line(
- visible_left, separator + (0.5f * line_height),
- visible_left + visible_width, separator + (0.5f * line_height),
+ x1, separator + (0.5f * line_height),
+ x2, separator + (0.5f * line_height),
UI_LINE_WIDTH, ui().colors().text_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
menu_item const &pitem = item(0);
@@ -471,38 +474,41 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
}
// bottom
- std::string const revision(util::string_format(_("Revision: %1$s"), m_items_list[m_actual].revision));
- ui().draw_text_full(
- container(),
- revision,
- 0.0f, 0.0f, 1.0f,
- text_layout::text_justify::CENTER, text_layout::word_wrapping::TRUNCATE,
- mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(),
- &width, nullptr);
- width += 2 * lr_border;
- maxwidth = std::max(origx2 - origx1, width);
+ if (!m_items_list.empty())
+ {
+ std::string const revision(util::string_format(_("Revision: %1$s"), m_items_list[m_actual].revision));
+ ui().draw_text_full(
+ container(),
+ revision,
+ 0.0f, 0.0f, 1.0f,
+ text_layout::text_justify::CENTER, text_layout::word_wrapping::TRUNCATE,
+ mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(),
+ &width, nullptr);
+ width += 2 * lr_border;
+ maxwidth = std::max(origx2 - origx1, width);
- // compute our bounds
- x1 = 0.5f - 0.5f * maxwidth;
- x2 = x1 + maxwidth;
- y1 = origy2 + ui().box_tb_border();
- y2 = origy2 + bottom;
+ // compute our bounds
+ x1 = 0.5f - 0.5f * maxwidth;
+ x2 = x1 + maxwidth;
+ y1 = origy2 + ui().box_tb_border();
+ y2 = origy2 + bottom;
- // draw a box
- ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR);
+ // draw a box
+ ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR);
- // take off the borders
- x1 += lr_border;
- x2 -= lr_border;
- y1 += ui().box_tb_border();
+ // take off the borders
+ x1 += lr_border;
+ x2 -= lr_border;
+ y1 += ui().box_tb_border();
- // draw the text within it
- ui().draw_text_full(
- container(),
- revision,
- x1, y1, x2 - x1,
- text_layout::text_justify::CENTER, text_layout::word_wrapping::TRUNCATE,
- mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color());
+ // draw the text within it
+ ui().draw_text_full(
+ container(),
+ revision,
+ x1, y1, x2 - x1,
+ text_layout::text_justify::CENTER, text_layout::word_wrapping::TRUNCATE,
+ mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color());
+ }
}
//-------------------------------------------------
diff --git a/src/frontend/mame/ui/datmenu.h b/src/frontend/mame/ui/datmenu.h
index 33e3d160b84..ccc8bd8b2a4 100644
--- a/src/frontend/mame/ui/datmenu.h
+++ b/src/frontend/mame/ui/datmenu.h
@@ -1,5 +1,5 @@
// license:BSD-3-Clause
-// copyright-holders:Maurizio Petrarota
+// copyright-holders:Maurizio Petrarota, Vas Crabb
/***************************************************************************
ui/datmenu.h
@@ -76,4 +76,4 @@ private:
} // namespace ui
-#endif /* MAME_FRONTEND_UI_DATMENU_H */
+#endif // MAME_FRONTEND_UI_DATMENU_H
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index a66212c020b..303334de17b 100644
--- a/src/frontend/mame/ui/selmenu.cpp
+++ b/src/frontend/mame/ui/selmenu.cpp
@@ -855,18 +855,10 @@ void menu_select_launch::inkey_dats()
ui_software_info const *software;
ui_system_info const *system;
get_selection(software, system);
- if (software)
- {
- if (software->startempty && mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", software->driver->name, true))
- menu::stack_push<menu_dats_view>(ui(), container(), system);
- else if (mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", std::string(software->shortname).append(1, ',').append(software->listname).c_str()) || !software->infotext.empty())
- menu::stack_push<menu_dats_view>(ui(), container(), software);
- }
+ if (software && !software->startempty)
+ menu::stack_push<menu_dats_view>(ui(), container(), software);
else if (system)
- {
- if (mame_machine_manager::instance()->lua()->call_plugin_check<const char *>("data_list", system->driver->name, true))
- menu::stack_push<menu_dats_view>(ui(), container(), system);
- }
+ menu::stack_push<menu_dats_view>(ui(), container(), system);
}
@@ -1299,23 +1291,28 @@ void menu_select_launch::draw_toolbar(float x1, float y1, float x2, float y2)
x1 = (std::min)(backtrack_pos - (float(toolbar_count) * x_spacing), x1 + ((x2 - x1 - total_width) * 0.5f));
for (int z = 0; toolbar_count > z; ++z, x1 += x_spacing)
{
+ auto const bitmap = toolbar_bitmaps[z];
x2 = x1 + x_size;
color = rgb_t (0xffcccccc);
if (mouse_in_rect(x1, y1, x2, y2))
{
- set_hover(HOVER_B_FAV + toolbar_bitmaps[z]);
- color = rgb_t::white();
+ bool const need_selection = (TOOLBAR_BITMAP_FAVORITE == bitmap) || (TOOLBAR_BITMAP_INFO == bitmap);
+ if (!need_selection || get_selection_ptr())
+ {
+ set_hover(HOVER_B_FAV + bitmap);
+ color = rgb_t::white();
+ }
float ypos = y2 + ui().get_line_height() + 2.0f * ui().box_tb_border();
ui().draw_text_box(
container(),
- _(hover_msg[toolbar_bitmaps[z]]),
+ _(hover_msg[bitmap]),
text_layout::text_justify::CENTER, (x1 + x2) * 0.5f, ypos,
ui().colors().background_color());
}
container().add_quad(
x1, y1, x2, y2,
color,
- m_cache.toolbar_textures()[toolbar_bitmaps[z]].get(),
+ m_cache.toolbar_textures()[bitmap].get(),
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
}