summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame
diff options
context:
space:
mode:
author therealmogminer@gmail.com <therealmogminer@gmail.com>2016-05-28 15:36:50 +0200
committer therealmogminer@gmail.com <therealmogminer@gmail.com>2016-05-28 17:33:45 +0200
commit63132b3d01ee0ad797e797057687facf43f4f26d (patch)
treebd207a3454fe4f68ae9f3230a9fb57107d9a7c88 /src/frontend/mame
parent68a9dc6857e4f33be844e53d58acb8d24adcc543 (diff)
More slider cleanup, nw
Diffstat (limited to 'src/frontend/mame')
-rw-r--r--src/frontend/mame/ui/slider.h7
-rw-r--r--src/frontend/mame/ui/sliderchangednotifier.h29
-rw-r--r--src/frontend/mame/ui/sliders.cpp10
-rw-r--r--src/frontend/mame/ui/ui.cpp221
-rw-r--r--src/frontend/mame/ui/ui.h86
5 files changed, 264 insertions, 89 deletions
diff --git a/src/frontend/mame/ui/slider.h b/src/frontend/mame/ui/slider.h
index a7873db800a..7cd4b580831 100644
--- a/src/frontend/mame/ui/slider.h
+++ b/src/frontend/mame/ui/slider.h
@@ -14,16 +14,19 @@
#ifndef __UI_SLIDER__
#define __UI_SLIDER__
+#include <functional>
+
#include "emu.h"
+#include "sliderchangednotifier.h"
#define SLIDER_NOCHANGE 0x12345678
-typedef INT32(*slider_update)(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+typedef std::function<INT32(running_machine&, void*, int, std::string*, INT32)> slider_update;
struct slider_state
{
slider_state * next; /* pointer to next slider */
- slider_update update; /* callback */
+ slider_update update; /* callback */
void * arg; /* argument */
INT32 minval; /* minimum value */
INT32 defval; /* default value */
diff --git a/src/frontend/mame/ui/sliderchangednotifier.h b/src/frontend/mame/ui/sliderchangednotifier.h
new file mode 100644
index 00000000000..40e6df4b4bf
--- /dev/null
+++ b/src/frontend/mame/ui/sliderchangednotifier.h
@@ -0,0 +1,29 @@
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+//======================================================================
+//
+// sliderchangednotifier.cpp - Interface for a slider-changed callback
+//
+//======================================================================
+
+#pragma once
+
+#ifndef __SLIDER_CHANGED_NOTIFIER__
+#define __SLIDER_CHANGED_NOTIFIER__
+
+#include <cstdint>
+#include <string>
+
+using INT32 = std::int32_t;
+
+class running_machine;
+
+class slider_changed_notifier
+{
+public:
+ virtual ~slider_changed_notifier() { }
+
+ virtual INT32 slider_changed(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) = 0;
+};
+
+#endif // __SLIDER_CHANGED_NOTIFIER__
diff --git a/src/frontend/mame/ui/sliders.cpp b/src/frontend/mame/ui/sliders.cpp
index 920d2ede4b4..b94b8f00055 100644
--- a/src/frontend/mame/ui/sliders.cpp
+++ b/src/frontend/mame/ui/sliders.cpp
@@ -43,7 +43,7 @@ void menu_sliders::handle()
if (menu_event->itemref != nullptr && menu_event->type == menu_item_type::SLIDER)
{
const slider_state *slider = (const slider_state *)menu_event->itemref;
- INT32 curvalue = (*slider->update)(machine(), slider->arg, slider->id, nullptr, SLIDER_NOCHANGE);
+ INT32 curvalue = slider->update(machine(), slider->arg, slider->id, nullptr, SLIDER_NOCHANGE);
INT32 increment = 0;
bool alt_pressed = machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT);
bool ctrl_pressed = machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL);
@@ -105,7 +105,7 @@ void menu_sliders::handle()
newvalue = slider->maxval;
/* update the slider and recompute the menu */
- (*slider->update)(machine(), slider->arg, slider->id, nullptr, newvalue);
+ slider->update(machine(), slider->arg, slider->id, nullptr, newvalue);
reset(reset_options::REMEMBER_REF);
}
}
@@ -147,7 +147,7 @@ void menu_sliders::populate()
if (item.type == menu_item_type::SLIDER)
{
slider_state* slider = reinterpret_cast<slider_state *>(item.ref);
- INT32 curval = (*slider->update)(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE);
+ INT32 curval = slider->update(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE);
UINT32 flags = 0;
if (curval > slider->minval)
flags |= FLAG_LEFT_ARROW;
@@ -170,7 +170,7 @@ void menu_sliders::populate()
if (item.type == menu_item_type::SLIDER)
{
slider_state* slider = reinterpret_cast<slider_state *>(item.ref);
- INT32 curval = (*slider->update)(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE);
+ INT32 curval = slider->update(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE);
UINT32 flags = 0;
if (curval > slider->minval)
flags |= FLAG_LEFT_ARROW;
@@ -205,7 +205,7 @@ void menu_sliders::custom_render(void *selectedref, float top, float bottom, flo
INT32 curval;
/* determine the current value and text */
- curval = (*curslider->update)(machine(), curslider->arg, curslider->id, &tempstring, SLIDER_NOCHANGE);
+ curval = curslider->update(machine(), curslider->arg, curslider->id, &tempstring, SLIDER_NOCHANGE);
/* compute the current and default percentages */
percentage = (float)(curval - curslider->minval) / (float)(curslider->maxval - curslider->minval);
diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp
index 4f01102abb4..08bcfa0ceac 100644
--- a/src/frontend/mame/ui/ui.cpp
+++ b/src/frontend/mame/ui/ui.cpp
@@ -126,39 +126,6 @@ slider_state *mame_ui_manager::slider_current;
/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
-
-// slider controls
-static slider_state *slider_alloc(running_machine &machine, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, slider_update update, void *arg);
-static INT32 slider_volume(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_mixervol(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_adjuster(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_overclock(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_refresh(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_brightness(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_contrast(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_gamma(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_xscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_yscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_xoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_yoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_overxscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_overyscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_overxoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_overyoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_flicker(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_beam_width_min(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_beam_width_max(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_beam_intensity_weight(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static std::string slider_get_screen_desc(screen_device &screen);
-#ifdef MAME_DEBUG
-static INT32 slider_crossscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-static INT32 slider_crossoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
-#endif
-
-
-/***************************************************************************
INLINE FUNCTIONS
***************************************************************************/
@@ -1896,7 +1863,7 @@ std::vector<ui::menu_item>& mame_ui_manager::get_slider_list(void)
// slider_alloc - allocate a new slider entry
//-------------------------------------------------
-static slider_state *slider_alloc(running_machine &machine, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, slider_update update, void *arg)
+slider_state* mame_ui_manager::slider_alloc(running_machine &machine, int id, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, void *arg)
{
int size = sizeof(slider_state) + strlen(title);
slider_state *state = (slider_state *)auto_alloc_array_clear(machine, UINT8, size);
@@ -1905,9 +1872,12 @@ static slider_state *slider_alloc(running_machine &machine, const char *title, I
state->defval = defval;
state->maxval = maxval;
state->incval = incval;
- state->update = update;
+
+ using namespace std::placeholders;
+ state->update = std::bind(&mame_ui_manager::slider_changed, this, _1, _2, _3, _4, _5);
+
state->arg = arg;
- state->id = -1;
+ state->id = id;
strcpy(state->description, title);
return state;
@@ -1924,7 +1894,7 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
std::vector<slider_state *> sliders;
// add overall volume
- sliders.push_back(slider_alloc(machine, _("Master Volume"), -32, 0, 0, 1, slider_volume, nullptr));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_VOLUME, _("Master Volume"), -32, 0, 0, 1, nullptr));
// add per-channel volume
mixer_input info;
@@ -1934,34 +1904,37 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
INT32 defval = 1000;
std::string str = string_format(_("%1$s Volume"), info.stream->input_name(info.inputnum));
- sliders.push_back(slider_alloc(machine, str.c_str(), 0, defval, maxval, 20, slider_mixervol, (void *)(FPTR)item));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_MIXERVOL + item, str.c_str(), 0, defval, maxval, 20, (void *)(FPTR)item));
}
// add analog adjusters
+ int slider_index = 0;
for (ioport_port &port : machine.ioport().ports())
{
for (ioport_field &field : port.fields())
{
if (field.type() == IPT_ADJUSTER)
{
- sliders.push_back(slider_alloc(machine, field.name(), field.minval(), field.defvalue(), field.maxval(), 1, slider_adjuster, (void *)&field));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_ADJUSTER + slider_index++, field.name(), field.minval(), field.defvalue(), field.maxval(), 1, (void *)&field));
}
}
}
// add CPU overclocking (cheat only)
+ slider_index = 0;
if (machine.options().cheat())
{
for (device_execute_interface &exec : execute_interface_iterator(machine.root_device()))
{
void *param = (void *)&exec.device();
std::string str = string_format(_("Overclock CPU %1$s"), exec.device().tag());
- sliders.push_back(slider_alloc(machine, str.c_str(), 10, 1000, 2000, 1, slider_overclock, param));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERCLOCK + slider_index++, str.c_str(), 10, 1000, 2000, 1, param));
}
}
// add screen parameters
screen_device_iterator scriter(machine.root_device());
+ slider_index = 0;
for (screen_device &screen : scriter)
{
int defxscale = floor(screen.xscale() * 1000.0f + 0.5f);
@@ -1975,28 +1948,30 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
if (machine.options().cheat())
{
std::string str = string_format(_("%1$s Refresh Rate"), screen_desc);
- sliders.push_back(slider_alloc(machine, str.c_str(), -10000, 0, 10000, 1000, slider_refresh, param));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_REFRESH + slider_index, str.c_str(), -10000, 0, 10000, 1000, param));
}
// add standard brightness/contrast/gamma controls per-screen
std::string str = string_format(_("%1$s Brightness"), screen_desc);
- sliders.push_back(slider_alloc(machine, str.c_str(), 100, 1000, 2000, 10, slider_brightness, param));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_BRIGHTNESS + slider_index, str.c_str(), 100, 1000, 2000, 10, param));
str = string_format(_("%1$s Contrast"), screen_desc);
- sliders.push_back(slider_alloc(machine, str.c_str(), 100, 1000, 2000, 50, slider_contrast, param));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_CONTRAST + slider_index, str.c_str(), 100, 1000, 2000, 50, param));
str = string_format(_("%1$s Gamma"), screen_desc);
- sliders.push_back(slider_alloc(machine, str.c_str(), 100, 1000, 3000, 50, slider_gamma, param));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_GAMMA + slider_index, str.c_str(), 100, 1000, 3000, 50, param));
// add scale and offset controls per-screen
str = string_format(_("%1$s Horiz Stretch"), screen_desc);
- sliders.push_back(slider_alloc(machine, str.c_str(), 500, defxscale, 1500, 2, slider_xscale, param));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_XSCALE + slider_index, str.c_str(), 500, defxscale, 1500, 2, param));
str = string_format(_("%1$s Horiz Position"), screen_desc);
- sliders.push_back(slider_alloc(machine, str.c_str(), -500, defxoffset, 500, 2, slider_xoffset, param));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_XOFFSET + slider_index, str.c_str(), -500, defxoffset, 500, 2, param));
str = string_format(_("%1$s Vert Stretch"), screen_desc);
- sliders.push_back(slider_alloc(machine, str.c_str(), 500, defyscale, 1500, 2, slider_yscale, param));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_YSCALE + slider_index, str.c_str(), 500, defyscale, 1500, 2, param));
str = string_format(_("%1$s Vert Position"), screen_desc);
- sliders.push_back(slider_alloc(machine, str.c_str(), -500, defyoffset, 500, 2, slider_yoffset, param));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_YOFFSET + slider_index, str.c_str(), -500, defyoffset, 500, 2, param));
+ slider_index++;
}
+ slider_index = 0;
for (laserdisc_device &laserdisc : laserdisc_device_iterator(machine.root_device()))
{
if (laserdisc.overlay_configured())
@@ -2011,30 +1986,34 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
// add scale and offset controls per-overlay
std::string str = string_format(_("Laserdisc '%1$s' Horiz Stretch"), laserdisc.tag());
- sliders.push_back(slider_alloc(machine, str.c_str(), 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, slider_overxscale, param));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_XSCALE + slider_index, str.c_str(), 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, param));
str = string_format(_("Laserdisc '%1$s' Horiz Position"), laserdisc.tag());
- sliders.push_back(slider_alloc(machine, str.c_str(), -500, defxoffset, 500, 2, slider_overxoffset, param));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_YSCALE + slider_index, str.c_str(), -500, defxoffset, 500, 2, param));
str = string_format(_("Laserdisc '%1$s' Vert Stretch"), laserdisc.tag());
- sliders.push_back(slider_alloc(machine, str.c_str(), 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, slider_overyscale, param));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_XOFFSET + slider_index, str.c_str(), 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, param));
str = string_format(_("Laserdisc '%1$s' Vert Position"), laserdisc.tag());
- sliders.push_back(slider_alloc(machine, str.c_str(), -500, defyoffset, 500, 2, slider_overyoffset, param));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_YOFFSET + slider_index, str.c_str(), -500, defyoffset, 500, 2, param));
+ slider_index++;
}
}
+ slider_index = 0;
for (screen_device &screen : scriter)
{
if (screen.screen_type() == SCREEN_TYPE_VECTOR)
{
// add vector control
- sliders.push_back(slider_alloc(machine, _("Vector Flicker"), 0, 0, 1000, 10, slider_flicker, nullptr));
- sliders.push_back(slider_alloc(machine, _("Beam Width Minimum"), 1, 100, 1000, 1, slider_beam_width_min, nullptr));
- sliders.push_back(slider_alloc(machine, _("Beam Width Maximum"), 1, 100, 1000, 1, slider_beam_width_max, nullptr));
- sliders.push_back(slider_alloc(machine, _("Beam Intensity Weight"), -1000, 0, 1000, 10, slider_beam_intensity_weight, nullptr));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_FLICKER + slider_index, _("Vector Flicker"), 0, 0, 1000, 10, nullptr));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_BEAM_WIDTH_MIN + slider_index, _("Beam Width Minimum"), 1, 100, 1000, 1, nullptr));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_BEAM_WIDTH_MAX + slider_index, _("Beam Width Maximum"), 1, 100, 1000, 1, nullptr));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_BEAM_INTENSITY + slider_index, _("Beam Intensity Weight"), -1000, 0, 1000, 10, nullptr));
+ slider_index++;
break;
}
}
#ifdef MAME_DEBUG
+ slider_index = 0;
// add crosshair adjusters
for (ioport_port &port : machine.ioport().ports())
{
@@ -2043,9 +2022,9 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
if (field.crosshair_axis() != CROSSHAIR_AXIS_NONE && field.player() == 0)
{
std::string str = string_format(_("Crosshair Scale %1$s"), (field.crosshair_axis() == CROSSHAIR_AXIS_X) ? _("X") : _("Y"));
- sliders.push_back(slider_alloc(machine, str.c_str(), -3000, 1000, 3000, 100, slider_crossscale, (void *)&field));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_CROSSHAIR_SCALE + slider_index, str.c_str(), -3000, 1000, 3000, 100, (void *)&field));
str = string_format(_("Crosshair Offset %1$s"), (field.crosshair_axis() == CROSSHAIR_AXIS_X) ? _("X") : _("Y"));
- sliders.push_back(slider_alloc(machine, str.c_str(), -3000, 0, 3000, 100, slider_crossoffset, (void *)&field));
+ sliders.push_back(slider_alloc(machine, SLIDER_ID_CROSSHAIR_OFFSET + slider_index, str.c_str(), -3000, 0, 3000, 100, (void *)&field));
}
}
}
@@ -2066,12 +2045,92 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
return items;
}
+//----------------------------------------------------
+// slider_changed - global slider-modified callback
+//----------------------------------------------------
+
+INT32 mame_ui_manager::slider_changed(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+{
+ switch (id)
+ {
+ case SLIDER_ID_VOLUME:
+ return slider_volume(machine, arg, id, str, newval);
+
+ case SLIDER_ID_MIXERVOL ... SLIDER_ID_MIXERVOL_LAST:
+ return slider_mixervol(machine, arg, id, str, newval);
+
+ case SLIDER_ID_ADJUSTER ... SLIDER_ID_ADJUSTER_LAST:
+ return slider_adjuster(machine, arg, id, str, newval);
+
+ case SLIDER_ID_OVERCLOCK ... SLIDER_ID_OVERCLOCK_LAST:
+ return slider_overclock(machine, arg, id, str, newval);
+
+ case SLIDER_ID_REFRESH ... SLIDER_ID_REFRESH_LAST:
+ return slider_refresh(machine, arg, id, str, newval);
+
+ case SLIDER_ID_BRIGHTNESS ... SLIDER_ID_BRIGHTNESS_LAST:
+ return slider_brightness(machine, arg, id, str, newval);
+
+ case SLIDER_ID_CONTRAST ... SLIDER_ID_CONTRAST_LAST:
+ return slider_contrast(machine, arg, id, str, newval);
+
+ case SLIDER_ID_GAMMA ... SLIDER_ID_GAMMA_LAST:
+ return slider_gamma(machine, arg, id, str, newval);
+
+ case SLIDER_ID_XSCALE ... SLIDER_ID_XSCALE_LAST:
+ return slider_xscale(machine, arg, id, str, newval);
+
+ case SLIDER_ID_YSCALE ... SLIDER_ID_YSCALE_LAST:
+ return slider_yscale(machine, arg, id, str, newval);
+
+ case SLIDER_ID_XOFFSET ... SLIDER_ID_XOFFSET_LAST:
+ return slider_xoffset(machine, arg, id, str, newval);
+
+ case SLIDER_ID_YOFFSET ... SLIDER_ID_YOFFSET_LAST:
+ return slider_yoffset(machine, arg, id, str, newval);
+
+ case SLIDER_ID_OVERLAY_XSCALE ... SLIDER_ID_OVERLAY_XSCALE_LAST:
+ return slider_overxscale(machine, arg, id, str, newval);
+
+ case SLIDER_ID_OVERLAY_YSCALE ... SLIDER_ID_OVERLAY_YSCALE_LAST:
+ return slider_overyscale(machine, arg, id, str, newval);
+
+ case SLIDER_ID_OVERLAY_XOFFSET ... SLIDER_ID_OVERLAY_XOFFSET_LAST:
+ return slider_overxoffset(machine, arg, id, str, newval);
+
+ case SLIDER_ID_OVERLAY_YOFFSET ... SLIDER_ID_OVERLAY_YOFFSET_LAST:
+ return slider_overyoffset(machine, arg, id, str, newval);
+
+ case SLIDER_ID_FLICKER ... SLIDER_ID_FLICKER_LAST:
+ return slider_flicker(machine, arg, id, str, newval);
+
+ case SLIDER_ID_BEAM_WIDTH_MIN ... SLIDER_ID_BEAM_WIDTH_MIN_LAST:
+ return slider_beam_width_min(machine, arg, id, str, newval);
+
+ case SLIDER_ID_BEAM_WIDTH_MAX ... SLIDER_ID_BEAM_WIDTH_MAX_LAST:
+ return slider_beam_width_max(machine, arg, id, str, newval);
+
+ case SLIDER_ID_BEAM_INTENSITY ... SLIDER_ID_BEAM_INTENSITY_LAST:
+ return slider_beam_intensity_weight(machine, arg, id, str, newval);
+
+#ifdef MAME_DEBUG
+ case SLIDER_ID_CROSSHAIR_SCALE ... SLIDER_ID_CROSSHAIR_SCALE_LAST:
+ return slider_crossscale(machine, arg, id, str, newval);
+
+ case SLIDER_ID_CROSSHAIR_OFFSET ... SLIDER_ID_CROSSHAIR_OFFSET_LAST:
+ return slider_crossoffset(machine, arg, id, str, newval);
+#endif
+ }
+
+ return 0;
+}
+
//-------------------------------------------------
// slider_volume - global volume slider callback
//-------------------------------------------------
-static INT32 slider_volume(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_volume(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
if (newval != SLIDER_NOCHANGE)
machine.sound().set_attenuation(newval);
@@ -2086,7 +2145,7 @@ static INT32 slider_volume(running_machine &machine, void *arg, int id, std::str
// slider callback
//-------------------------------------------------
-static INT32 slider_mixervol(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_mixervol(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
mixer_input info;
if (!machine.sound().indexed_mixer_input((FPTR)arg, info))
@@ -2108,7 +2167,7 @@ static INT32 slider_mixervol(running_machine &machine, void *arg, int id, std::s
// callback
//-------------------------------------------------
-static INT32 slider_adjuster(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_adjuster(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
ioport_field *field = (ioport_field *)arg;
ioport_field::user_settings settings;
@@ -2130,7 +2189,7 @@ static INT32 slider_adjuster(running_machine &machine, void *arg, int id, std::s
// callback
//-------------------------------------------------
-static INT32 slider_overclock(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_overclock(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
device_t *cpu = (device_t *)arg;
if (newval != SLIDER_NOCHANGE)
@@ -2145,7 +2204,7 @@ static INT32 slider_overclock(running_machine &machine, void *arg, int id, std::
// slider_refresh - refresh rate slider callback
//-------------------------------------------------
-static INT32 slider_refresh(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_refresh(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
double defrefresh = ATTOSECONDS_TO_HZ(screen->refresh_attoseconds());
@@ -2170,7 +2229,7 @@ static INT32 slider_refresh(running_machine &machine, void *arg, int id, std::st
// callback
//-------------------------------------------------
-static INT32 slider_brightness(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_brightness(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings;
@@ -2192,7 +2251,7 @@ static INT32 slider_brightness(running_machine &machine, void *arg, int id, std:
// callback
//-------------------------------------------------
-static INT32 slider_contrast(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_contrast(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings;
@@ -2213,7 +2272,7 @@ static INT32 slider_contrast(running_machine &machine, void *arg, int id, std::s
// slider_gamma - screen gamma slider callback
//-------------------------------------------------
-static INT32 slider_gamma(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_gamma(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings;
@@ -2235,7 +2294,7 @@ static INT32 slider_gamma(running_machine &machine, void *arg, int id, std::stri
// callback
//-------------------------------------------------
-static INT32 slider_xscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_xscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings;
@@ -2257,7 +2316,7 @@ static INT32 slider_xscale(running_machine &machine, void *arg, int id, std::str
// callback
//-------------------------------------------------
-static INT32 slider_yscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_yscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings;
@@ -2279,7 +2338,7 @@ static INT32 slider_yscale(running_machine &machine, void *arg, int id, std::str
// slider callback
//-------------------------------------------------
-static INT32 slider_xoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_xoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings;
@@ -2301,7 +2360,7 @@ static INT32 slider_xoffset(running_machine &machine, void *arg, int id, std::st
// slider callback
//-------------------------------------------------
-static INT32 slider_yoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_yoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings;
@@ -2323,7 +2382,7 @@ static INT32 slider_yoffset(running_machine &machine, void *arg, int id, std::st
// callback
//-------------------------------------------------
-static INT32 slider_overxscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_overxscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
laserdisc_device *laserdisc = (laserdisc_device *)arg;
laserdisc_overlay_config settings;
@@ -2345,7 +2404,7 @@ static INT32 slider_overxscale(running_machine &machine, void *arg, int id, std:
// callback
//-------------------------------------------------
-static INT32 slider_overyscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_overyscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
laserdisc_device *laserdisc = (laserdisc_device *)arg;
laserdisc_overlay_config settings;
@@ -2367,7 +2426,7 @@ static INT32 slider_overyscale(running_machine &machine, void *arg, int id, std:
// slider callback
//-------------------------------------------------
-static INT32 slider_overxoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_overxoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
laserdisc_device *laserdisc = (laserdisc_device *)arg;
laserdisc_overlay_config settings;
@@ -2389,7 +2448,7 @@ static INT32 slider_overxoffset(running_machine &machine, void *arg, int id, std
// slider callback
//-------------------------------------------------
-static INT32 slider_overyoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_overyoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
laserdisc_device *laserdisc = (laserdisc_device *)arg;
laserdisc_overlay_config settings;
@@ -2411,7 +2470,7 @@ static INT32 slider_overyoffset(running_machine &machine, void *arg, int id, std
// callback
//-------------------------------------------------
-static INT32 slider_flicker(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_flicker(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
if (newval != SLIDER_NOCHANGE)
vector_options::s_flicker = (float)newval * 0.001f;
@@ -2426,7 +2485,7 @@ static INT32 slider_flicker(running_machine &machine, void *arg, int id, std::st
// callback
//-------------------------------------------------
-static INT32 slider_beam_width_min(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_beam_width_min(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
if (newval != SLIDER_NOCHANGE)
vector_options::s_beam_width_min = MIN((float)newval * 0.01f, vector_options::s_beam_width_max);
@@ -2441,7 +2500,7 @@ static INT32 slider_beam_width_min(running_machine &machine, void *arg, int id,
// callback
//-------------------------------------------------
-static INT32 slider_beam_width_max(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_beam_width_max(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
if (newval != SLIDER_NOCHANGE)
vector_options::s_beam_width_max = MAX((float)newval * 0.01f, vector_options::s_beam_width_min);
@@ -2456,7 +2515,7 @@ static INT32 slider_beam_width_max(running_machine &machine, void *arg, int id,
// callback
//-------------------------------------------------
-static INT32 slider_beam_intensity_weight(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_beam_intensity_weight(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
if (newval != SLIDER_NOCHANGE)
vector_options::s_beam_intensity_weight = (float)newval * 0.001f;
@@ -2471,7 +2530,7 @@ static INT32 slider_beam_intensity_weight(running_machine &machine, void *arg, i
// description for a given screen
//-------------------------------------------------
-static std::string slider_get_screen_desc(screen_device &screen)
+std::string mame_ui_manager::slider_get_screen_desc(screen_device &screen)
{
if (screen_device_iterator(screen.machine().root_device()).count() > 1)
return string_format(_("Screen '%1$s'"), screen.tag());
@@ -2485,7 +2544,7 @@ static std::string slider_get_screen_desc(screen_device &screen)
//-------------------------------------------------
#ifdef MAME_DEBUG
-static INT32 slider_crossscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_crossscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
ioport_field *field = (ioport_field *)arg;
@@ -2504,7 +2563,7 @@ static INT32 slider_crossscale(running_machine &machine, void *arg, int id, std:
//-------------------------------------------------
#ifdef MAME_DEBUG
-static INT32 slider_crossoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
+INT32 mame_ui_manager::slider_crossoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
ioport_field *field = (ioport_field *)arg;
diff --git a/src/frontend/mame/ui/ui.h b/src/frontend/mame/ui/ui.h
index b81114c939c..299465e2d67 100644
--- a/src/frontend/mame/ui/ui.h
+++ b/src/frontend/mame/ui/ui.h
@@ -93,6 +93,59 @@ enum
DRAW_OPAQUE
};
+#define SLIDER_DEVICE_SPACING 0x0ff
+#define SLIDER_SCREEN_SPACING 0x0f
+#define SLIDER_INPUT_SPACING 0x0f
+
+enum
+{
+ SLIDER_ID_VOLUME = 0,
+ SLIDER_ID_MIXERVOL,
+ SLIDER_ID_MIXERVOL_LAST = SLIDER_ID_MIXERVOL + SLIDER_DEVICE_SPACING,
+ SLIDER_ID_ADJUSTER,
+ SLIDER_ID_ADJUSTER_LAST = SLIDER_ID_ADJUSTER + SLIDER_DEVICE_SPACING,
+ SLIDER_ID_OVERCLOCK,
+ SLIDER_ID_OVERCLOCK_LAST = SLIDER_ID_OVERCLOCK + SLIDER_DEVICE_SPACING,
+ SLIDER_ID_REFRESH,
+ SLIDER_ID_REFRESH_LAST = SLIDER_ID_REFRESH + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_BRIGHTNESS,
+ SLIDER_ID_BRIGHTNESS_LAST = SLIDER_ID_BRIGHTNESS + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_CONTRAST,
+ SLIDER_ID_CONTRAST_LAST = SLIDER_ID_CONTRAST + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_GAMMA,
+ SLIDER_ID_GAMMA_LAST = SLIDER_ID_GAMMA + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_XSCALE,
+ SLIDER_ID_XSCALE_LAST = SLIDER_ID_XSCALE + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_YSCALE,
+ SLIDER_ID_YSCALE_LAST = SLIDER_ID_YSCALE + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_XOFFSET,
+ SLIDER_ID_XOFFSET_LAST = SLIDER_ID_XOFFSET + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_YOFFSET,
+ SLIDER_ID_YOFFSET_LAST = SLIDER_ID_YOFFSET + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_OVERLAY_XSCALE,
+ SLIDER_ID_OVERLAY_XSCALE_LAST = SLIDER_ID_OVERLAY_XSCALE + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_OVERLAY_YSCALE,
+ SLIDER_ID_OVERLAY_YSCALE_LAST = SLIDER_ID_OVERLAY_YSCALE + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_OVERLAY_XOFFSET,
+ SLIDER_ID_OVERLAY_XOFFSET_LAST = SLIDER_ID_OVERLAY_XOFFSET + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_OVERLAY_YOFFSET,
+ SLIDER_ID_OVERLAY_YOFFSET_LAST = SLIDER_ID_OVERLAY_YOFFSET + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_FLICKER,
+ SLIDER_ID_FLICKER_LAST = SLIDER_ID_FLICKER + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_BEAM_WIDTH_MIN,
+ SLIDER_ID_BEAM_WIDTH_MIN_LAST = SLIDER_ID_BEAM_WIDTH_MIN + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_BEAM_WIDTH_MAX,
+ SLIDER_ID_BEAM_WIDTH_MAX_LAST = SLIDER_ID_BEAM_WIDTH_MAX + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_BEAM_INTENSITY,
+ SLIDER_ID_BEAM_INTENSITY_LAST = SLIDER_ID_BEAM_INTENSITY + SLIDER_SCREEN_SPACING,
+ SLIDER_ID_CROSSHAIR_SCALE,
+ SLIDER_ID_CROSSHAIR_SCALE_LAST = SLIDER_ID_CROSSHAIR_SCALE + SLIDER_INPUT_SPACING,
+ SLIDER_ID_CROSSHAIR_OFFSET,
+ SLIDER_ID_CROSSHAIR_OFFSET_LAST = SLIDER_ID_CROSSHAIR_OFFSET + SLIDER_INPUT_SPACING,
+
+ SLIDER_ID_CORE_LAST = SLIDER_ID_CROSSHAIR_OFFSET,
+ SLIDER_ID_CORE_COUNT
+};
/***************************************************************************
TYPE DEFINITIONS
@@ -103,7 +156,7 @@ typedef UINT32 (*ui_callback)(mame_ui_manager &, render_container *, UINT32);
// ======================> mame_ui_manager
-class mame_ui_manager : public ui_manager
+class mame_ui_manager : public ui_manager, public slider_changed_notifier
{
public:
// construction/destruction
@@ -179,6 +232,7 @@ public:
virtual void image_display(const device_type &type, device_image_interface *image) override;
virtual void menu_reset() override;
+
private:
// instance variables
render_font * m_font;
@@ -215,6 +269,36 @@ private:
// private methods
void exit();
+ slider_state* slider_alloc(running_machine &machine, int id, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, void *arg);
+
+ // slider controls
+ virtual INT32 slider_changed(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) override;
+
+ INT32 slider_volume(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_mixervol(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_adjuster(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_overclock(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_refresh(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_brightness(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_contrast(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_gamma(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_xscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_yscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_xoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_yoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_overxscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_overyscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_overxoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_overyoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_flicker(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_beam_width_min(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_beam_width_max(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_beam_intensity_weight(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ std::string slider_get_screen_desc(screen_device &screen);
+ #ifdef MAME_DEBUG
+ INT32 slider_crossscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ INT32 slider_crossoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval);
+ #endif
};