summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/ui/videoopt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/mame/ui/videoopt.cpp')
-rw-r--r--src/frontend/mame/ui/videoopt.cpp205
1 files changed, 116 insertions, 89 deletions
diff --git a/src/frontend/mame/ui/videoopt.cpp b/src/frontend/mame/ui/videoopt.cpp
index baa0a265cb6..58818328d41 100644
--- a/src/frontend/mame/ui/videoopt.cpp
+++ b/src/frontend/mame/ui/videoopt.cpp
@@ -9,12 +9,52 @@
*********************************************************************/
#include "emu.h"
-
#include "ui/videoopt.h"
#include "rendutil.h"
+
namespace ui {
+
+namespace {
+
+constexpr uintptr_t ITEM_ROTATE = 0x00000100;
+constexpr uintptr_t ITEM_ZOOM = 0x00000101;
+constexpr uintptr_t ITEM_TOGGLE_FIRST = 0x00000200;
+constexpr uintptr_t ITEM_VIEW_FIRST = 0x00000300;
+
+} // anonymous namespace
+
+
+/*-------------------------------------------------
+ menu_video_targets_populate - populate the
+ video targets menu
+-------------------------------------------------*/
+
+menu_video_targets::menu_video_targets(mame_ui_manager &mui, render_container &container)
+ : menu(mui, container)
+{
+}
+
+menu_video_targets::~menu_video_targets()
+{
+}
+
+void menu_video_targets::populate(float &customtop, float &custombottom)
+{
+ // find the targets
+ for (unsigned targetnum = 0; ; targetnum++)
+ {
+ // stop when we run out
+ render_target *const target = machine().render().target_by_index(targetnum);
+ if (!target)
+ break;
+
+ // add a menu item
+ item_append(util::string_format(_("Screen #%d"), targetnum), "", 0, target);
+ }
+}
+
/*-------------------------------------------------
menu_video_targets - handle the video targets
menu
@@ -22,46 +62,74 @@ namespace ui {
void menu_video_targets::handle()
{
- /* process the menu */
- const event *menu_event = process(0);
- if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT)
- menu::stack_push<menu_video_options>(ui(), container(), static_cast<render_target *>(menu_event->itemref));
+ event const *const menu_event = process(0);
+ if (menu_event && (menu_event->iptkey == IPT_UI_SELECT))
+ menu::stack_push<menu_video_options>(ui(), container(), *reinterpret_cast<render_target *>(menu_event->itemref));
}
/*-------------------------------------------------
- menu_video_targets_populate - populate the
- video targets menu
+ menu_video_options_populate - populate the
+ video options menu
-------------------------------------------------*/
-menu_video_targets::menu_video_targets(mame_ui_manager &mui, render_container &container) : menu(mui, container)
+menu_video_options::menu_video_options(mame_ui_manager &mui, render_container &container, render_target &target)
+ : menu(mui, container)
+ , m_target(target)
{
}
-void menu_video_targets::populate(float &customtop, float &custombottom)
+menu_video_options::~menu_video_options()
{
- int targetnum;
+}
+
+void menu_video_options::populate(float &customtop, float &custombottom)
+{
+ uintptr_t ref;
- /* find the targets */
- for (targetnum = 0; ; targetnum++)
+ // add items for each view
+ for (char const *name = m_target.view_name(ref = 0); name; name = m_target.view_name(++ref))
+ item_append(name, "", 0, reinterpret_cast<void *>(ITEM_VIEW_FIRST + ref));
+ item_append(menu_item_type::SEPARATOR);
+
+ // add items for visibility toggles
+ auto const &toggles = m_target.visibility_toggles();
+ if (!toggles.empty())
{
- render_target *target = machine().render().target_by_index(targetnum);
- char buffer[40];
+ ref = 0U;
+ auto const current_mask(m_target.visibility_mask());
+ for (auto toggle = toggles.begin(); toggles.end() != toggle; ++toggle, ++ref)
+ {
+ auto const toggle_mask(toggle->mask());
+ bool const enabled(BIT(current_mask, ref));
+ bool eclipsed(false);
+ for (auto it = toggles.begin(); !eclipsed && (toggle != it); ++it)
+ eclipsed = ((current_mask & it->mask()) != it->mask()) && ((toggle_mask & it->mask()) == it->mask());
+ u32 const flags((enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW) | (eclipsed ? (FLAG_INVERT | FLAG_DISABLE) : 0U));
+ item_append(toggle->name(), enabled ? _("On") : _("Off"), flags, reinterpret_cast<void *>(ITEM_TOGGLE_FIRST + ref));
+ }
+ item_append(menu_item_type::SEPARATOR);
+ }
- /* stop when we run out */
- if (target == nullptr)
- break;
+ const char *subtext = "";
- /* add a menu item */
- sprintf(buffer, _("Screen #%d"), targetnum);
- item_append(buffer, "", 0, target);
+ // add a rotate item
+ switch (m_target.orientation())
+ {
+ case ROT0: subtext = "None"; break;
+ case ROT90: subtext = "CW 90" UTF8_DEGREES; break;
+ case ROT180: subtext = "180" UTF8_DEGREES; break;
+ case ROT270: subtext = "CCW 90" UTF8_DEGREES; break;
}
-}
+ item_append(_("Rotate"), subtext, FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, reinterpret_cast<void *>(ITEM_ROTATE));
-menu_video_targets::~menu_video_targets()
-{
+ // cropping
+ int enabled;
+ enabled = m_target.zoom_to_screen();
+ item_append(_("Zoom to Screen Area"), enabled ? _("On") : _("Off"), enabled ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, reinterpret_cast<void *>(ITEM_ZOOM));
}
+
/*-------------------------------------------------
menu_video_options - handle the video options
menu
@@ -69,21 +137,21 @@ menu_video_targets::~menu_video_targets()
void menu_video_options::handle()
{
- bool changed = false;
+ bool changed(false);
// process the menu
- const event *menu_event = process(0);
- if (menu_event != nullptr && menu_event->itemref != nullptr)
+ event const *const menu_event(process(0));
+ if (menu_event && menu_event->itemref)
{
- switch ((uintptr_t)menu_event->itemref)
+ switch (reinterpret_cast<uintptr_t>(menu_event->itemref))
{
// rotate adds rotation depending on the direction
- case VIDEO_ITEM_ROTATE:
+ case ITEM_ROTATE:
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
{
- int delta = (menu_event->iptkey == IPT_UI_LEFT) ? ROT270 : ROT90;
- target->set_orientation(orientation_add(delta, target->orientation()));
- if (target->is_ui_target())
+ int const delta((menu_event->iptkey == IPT_UI_LEFT) ? ROT270 : ROT90);
+ m_target.set_orientation(orientation_add(delta, m_target.orientation()));
+ if (m_target.is_ui_target())
{
render_container::user_settings settings;
container().get_user_settings(settings);
@@ -95,20 +163,31 @@ void menu_video_options::handle()
break;
// layer config bitmasks handle left/right keys the same (toggle)
- case VIDEO_ITEM_ZOOM:
- if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
+ case ITEM_ZOOM:
+ if ((menu_event->iptkey == IPT_UI_LEFT) || (menu_event->iptkey == IPT_UI_RIGHT))
{
- target->set_zoom_to_screen(!target->zoom_to_screen());
+ m_target.set_zoom_to_screen(menu_event->iptkey == IPT_UI_RIGHT);
changed = true;
}
break;
// anything else is a view item
default:
- if (menu_event->iptkey == IPT_UI_SELECT && (int)(uintptr_t)menu_event->itemref >= VIDEO_ITEM_VIEW)
+ if (reinterpret_cast<uintptr_t>(menu_event->itemref) >= ITEM_VIEW_FIRST)
{
- target->set_view((uintptr_t)menu_event->itemref - VIDEO_ITEM_VIEW);
- changed = true;
+ if (menu_event->iptkey == IPT_UI_SELECT)
+ {
+ m_target.set_view(reinterpret_cast<uintptr_t>(menu_event->itemref) - ITEM_VIEW_FIRST);
+ changed = true;
+ }
+ }
+ else if (reinterpret_cast<uintptr_t>(menu_event->itemref) >= ITEM_TOGGLE_FIRST)
+ {
+ if ((menu_event->iptkey == IPT_UI_LEFT) || (menu_event->iptkey == IPT_UI_RIGHT))
+ {
+ m_target.set_visibility_toggle(reinterpret_cast<uintptr_t>(menu_event->itemref) - ITEM_TOGGLE_FIRST, menu_event->iptkey == IPT_UI_RIGHT);
+ changed = true;
+ }
}
break;
}
@@ -119,56 +198,4 @@ void menu_video_options::handle()
reset(reset_options::REMEMBER_REF);
}
-
-/*-------------------------------------------------
- menu_video_options_populate - populate the
- video options menu
--------------------------------------------------*/
-
-menu_video_options::menu_video_options(mame_ui_manager &mui, render_container &container, render_target *_target) : menu(mui, container)
-{
- target = _target;
-}
-
-void menu_video_options::populate(float &customtop, float &custombottom)
-{
- const char *subtext = "";
- std::string tempstring;
- int enabled;
-
- // add items for each view
- for (int viewnum = 0; ; viewnum++)
- {
- const char *name = target->view_name(viewnum);
- if (name == nullptr)
- break;
-
- // create a string for the item, replacing underscores with spaces
- tempstring.assign(name);
- strreplace(tempstring, "_", " ");
- item_append(tempstring, "", 0, (void *)(uintptr_t)(VIDEO_ITEM_VIEW + viewnum));
- }
-
- // add a separator
- item_append(menu_item_type::SEPARATOR);
-
- // add a rotate item
- switch (target->orientation())
- {
- case ROT0: subtext = "None"; break;
- case ROT90: subtext = "CW 90" UTF8_DEGREES; break;
- case ROT180: subtext = "180" UTF8_DEGREES; break;
- case ROT270: subtext = "CCW 90" UTF8_DEGREES; break;
- }
- item_append(_("Rotate"), subtext, FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_ROTATE);
-
- // cropping
- enabled = target->zoom_to_screen();
- item_append(_("View"), enabled ? _("Cropped") : _("Full"), enabled ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW, (void *)VIDEO_ITEM_ZOOM);
-}
-
-menu_video_options::~menu_video_options()
-{
-}
-
} // namespace ui