ui: Clean up slider callbacks

This commit is contained in:
AJR 2021-01-27 19:13:27 -05:00
parent cdde43b7a7
commit 1ef9d6991b
15 changed files with 184 additions and 371 deletions

View File

@ -14,23 +14,30 @@
#pragma once
#include "sliderchangednotifier.h"
#include <functional>
#include <string>
#define SLIDER_NOCHANGE 0x12345678
typedef std::function<std::int32_t (running_machine &, void *, int, std::string *, std::int32_t)> slider_update;
typedef std::function<std::int32_t (std::string *, std::int32_t)> slider_update;
struct slider_state
{
slider_state(const std::string &title, std::int32_t min, std::int32_t def, std::int32_t max, std::int32_t inc, slider_update func)
: update(func), minval(min), defval(def), maxval(max), incval(inc), description(title)
{
}
slider_state(std::string &&title, std::int32_t min, std::int32_t def, std::int32_t max, std::int32_t inc, slider_update func)
: update(func), minval(min), defval(def), maxval(max), incval(inc), description(std::move(title))
{
}
slider_update update; // callback
void * arg = nullptr; // argument
std::int32_t minval = 0; // minimum value
std::int32_t defval = 0; // default value
std::int32_t maxval = 0; // maximum value
std::int32_t incval = 0; // increment value
int id = 0;
std::int32_t minval; // minimum value
std::int32_t defval; // default value
std::int32_t maxval; // maximum value
std::int32_t incval; // increment value
std::string description; // textual description
};

View File

@ -1,27 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
//======================================================================
//
// sliderchangednotifier.cpp - Interface for a slider-changed callback
//
//======================================================================
#ifndef MAME_FRONTEND_MAME_UI_SLIDERCHANGEDNOTIFIER_H
#define MAME_FRONTEND_MAME_UI_SLIDERCHANGEDNOTIFIER_H
#pragma once
#include <cstdint>
#include <string>
class running_machine;
class slider_changed_notifier
{
public:
virtual ~slider_changed_notifier() { }
virtual std::int32_t slider_changed(running_machine &machine, void *arg, int id, std::string *str, std::int32_t newval) = 0;
};
#endif // MAME_FRONTEND_MAME_UI_SLIDERCHANGEDNOTIFIER_H

View File

@ -42,7 +42,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_t curvalue = slider->update(machine(), slider->arg, slider->id, nullptr, SLIDER_NOCHANGE);
int32_t curvalue = slider->update(nullptr, SLIDER_NOCHANGE);
int32_t 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);
@ -104,7 +104,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(nullptr, newvalue);
reset(reset_options::REMEMBER_REF);
}
}
@ -157,11 +157,14 @@ void menu_sliders::populate(float &customtop, float &custombottom)
{
slider_state* slider = reinterpret_cast<slider_state *>(item.ref);
bool display(true);
#if 0
// FIXME: this test should be reimplemented in a dedicated menu
if (slider->id >= SLIDER_ID_ADJUSTER && slider->id <= SLIDER_ID_ADJUSTER_LAST)
display = reinterpret_cast<ioport_field *>(slider->arg)->enabled();
#endif
if (display)
{
int32_t curval = slider->update(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE);
int32_t curval = slider->update(&tempstring, SLIDER_NOCHANGE);
uint32_t flags = 0;
if (curval > slider->minval)
flags |= FLAG_LEFT_ARROW;
@ -185,7 +188,7 @@ void menu_sliders::populate(float &customtop, float &custombottom)
if (item.type == menu_item_type::SLIDER)
{
slider_state* slider = reinterpret_cast<slider_state *>(item.ref);
int32_t curval = slider->update(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE);
int32_t curval = slider->update(&tempstring, SLIDER_NOCHANGE);
uint32_t flags = 0;
if (curval > slider->minval)
flags |= FLAG_LEFT_ARROW;
@ -220,7 +223,7 @@ void menu_sliders::custom_render(void *selectedref, float top, float bottom, flo
int32_t curval;
// determine the current value and text
curval = curslider->update(machine(), curslider->arg, curslider->id, &tempstring, SLIDER_NOCHANGE);
curval = curslider->update(&tempstring, SLIDER_NOCHANGE);
// compute the current and default percentages
percentage = (float)(curval - curslider->minval) / (float)(curslider->maxval - curslider->minval);

View File

@ -14,6 +14,12 @@
#include "ui/utils.h"
#include "ui/menuitem.h"
#if defined(UI_WINDOWS) && !defined(UI_SDL)
#include "../osd/windows/winmain.h"
#else
#include "../osd/modules/lib/osdobj_common.h"
#endif
#include <limits>

View File

@ -15,12 +15,6 @@
#include "emuopts.h"
#include "ui/menu.h"
#if defined(UI_WINDOWS) && !defined(UI_SDL)
#include "../osd/windows/winmain.h"
#else
#include "../osd/modules/lib/osdobj_common.h"
#endif
#include <string>
#include <vector>

View File

@ -1464,30 +1464,6 @@ std::vector<ui::menu_item>& mame_ui_manager::get_slider_list(void)
}
//-------------------------------------------------
// slider_alloc - allocate a new slider entry
//-------------------------------------------------
std::unique_ptr<slider_state> mame_ui_manager::slider_alloc(int id, const char *title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, void *arg)
{
auto state = std::make_unique<slider_state>();
state->minval = minval;
state->defval = defval;
state->maxval = maxval;
state->incval = incval;
using namespace std::placeholders;
state->update = std::bind(&mame_ui_manager::slider_changed, this, _1, _2, _3, _4, _5);
state->arg = arg;
state->id = id;
state->description = title;
return state;
}
//----------------------------------------------------------
// mame_ui_manager::slider_init - initialize the list of slider
// controls
@ -1495,10 +1471,12 @@ std::unique_ptr<slider_state> mame_ui_manager::slider_alloc(int id, const char *
std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine)
{
using namespace std::placeholders;
m_sliders.clear();
// add overall volume
m_sliders.push_back(slider_alloc(SLIDER_ID_VOLUME, _("Master Volume"), -32, 0, 0, 1, nullptr));
slider_alloc(_("Master Volume"), -32, 0, 0, 1, std::bind(&mame_ui_manager::slider_volume, this, _1, _2));
// add per-channel volume
mixer_input info;
@ -1508,84 +1486,77 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
int32_t defval = 1000;
std::string str = string_format(_("%1$s Volume"), info.stream->input(info.inputnum).name());
m_sliders.push_back(slider_alloc(SLIDER_ID_MIXERVOL + item, str.c_str(), 0, defval, maxval, 20, (void *)(uintptr_t)item));
slider_alloc(std::move(str), 0, defval, maxval, 20, std::bind(&mame_ui_manager::slider_mixervol, this, item, _1, _2));
}
// add analog adjusters
int slider_index = 0;
for (auto &port : machine.ioport().ports())
{
for (ioport_field &field : port.second->fields())
{
if (field.type() == IPT_ADJUSTER)
{
m_sliders.push_back(slider_alloc(SLIDER_ID_ADJUSTER + slider_index++, field.name(), field.minval(), field.defvalue(), field.maxval(), 1, (void *)&field));
slider_alloc(field.name(), field.minval(), field.defvalue(), field.maxval(), 1,
std::bind(&mame_ui_manager::slider_adjuster, this, std::ref(field), _1, _2));
}
}
}
// add CPU overclocking (cheat only)
slider_index = 0;
if (machine.options().cheat())
{
for (device_execute_interface &exec : execute_interface_enumerator(machine.root_device()))
{
void *param = (void *)&exec.device();
std::string str = string_format(_("Overclock CPU %1$s"), exec.device().tag());
m_sliders.push_back(slider_alloc(SLIDER_ID_OVERCLOCK + slider_index++, str.c_str(), 100, 1000, 4000, 10, param));
slider_alloc(std::move(str), 100, 1000, 4000, 10, std::bind(&mame_ui_manager::slider_overclock, this, std::ref(exec.device()), _1, _2));
}
for (device_sound_interface &snd : sound_interface_enumerator(machine.root_device()))
{
device_execute_interface *exec;
if (!snd.device().interface(exec) && snd.device().unscaled_clock() != 0)
{
void *param = (void *)&snd.device();
std::string str = string_format(_("Overclock %1$s sound"), snd.device().tag());
m_sliders.push_back(slider_alloc(SLIDER_ID_OVERCLOCK + slider_index++, str.c_str(), 100, 1000, 4000, 10, param));
slider_alloc(std::move(str), 100, 1000, 4000, 10, std::bind(&mame_ui_manager::slider_overclock, this, std::ref(snd.device()), _1, _2));
}
}
}
// add screen parameters
screen_device_enumerator scriter(machine.root_device());
slider_index = 0;
for (screen_device &screen : scriter)
{
int defxscale = floor(screen.xscale() * 1000.0f + 0.5f);
int defyscale = floor(screen.yscale() * 1000.0f + 0.5f);
int defxoffset = floor(screen.xoffset() * 1000.0f + 0.5f);
int defyoffset = floor(screen.yoffset() * 1000.0f + 0.5f);
void *param = (void *)&screen;
std::string screen_desc = machine_info().get_screen_desc(screen);
// add refresh rate tweaker
if (machine.options().cheat())
{
std::string str = string_format(_("%1$s Refresh Rate"), screen_desc);
m_sliders.push_back(slider_alloc(SLIDER_ID_REFRESH + slider_index, str.c_str(), -10000, 0, 10000, 1000, param));
slider_alloc(std::move(str), -10000, 0, 10000, 1000, std::bind(&mame_ui_manager::slider_refresh, this, std::ref(screen), _1, _2));
}
// add standard brightness/contrast/gamma controls per-screen
std::string str = string_format(_("%1$s Brightness"), screen_desc);
m_sliders.push_back(slider_alloc(SLIDER_ID_BRIGHTNESS + slider_index, str.c_str(), 100, 1000, 2000, 10, param));
slider_alloc(std::move(str), 100, 1000, 2000, 10, std::bind(&mame_ui_manager::slider_brightness, this, std::ref(screen), _1, _2));
str = string_format(_("%1$s Contrast"), screen_desc);
m_sliders.push_back(slider_alloc(SLIDER_ID_CONTRAST + slider_index, str.c_str(), 100, 1000, 2000, 50, param));
slider_alloc(std::move(str), 100, 1000, 2000, 50, std::bind(&mame_ui_manager::slider_contrast, this, std::ref(screen), _1, _2));
str = string_format(_("%1$s Gamma"), screen_desc);
m_sliders.push_back(slider_alloc(SLIDER_ID_GAMMA + slider_index, str.c_str(), 100, 1000, 3000, 50, param));
slider_alloc(std::move(str), 100, 1000, 3000, 50, std::bind(&mame_ui_manager::slider_gamma, this, std::ref(screen), _1, _2));
// add scale and offset controls per-screen
str = string_format(_("%1$s Horiz Stretch"), screen_desc);
m_sliders.push_back(slider_alloc(SLIDER_ID_XSCALE + slider_index, str.c_str(), 500, defxscale, 1500, 2, param));
slider_alloc(std::move(str), 500, defxscale, 1500, 2, std::bind(&mame_ui_manager::slider_xscale, this, std::ref(screen), _1, _2));
str = string_format(_("%1$s Horiz Position"), screen_desc);
m_sliders.push_back(slider_alloc(SLIDER_ID_XOFFSET + slider_index, str.c_str(), -500, defxoffset, 500, 2, param));
slider_alloc(std::move(str), -500, defxoffset, 500, 2, std::bind(&mame_ui_manager::slider_xoffset, this, std::ref(screen), _1, _2));
str = string_format(_("%1$s Vert Stretch"), screen_desc);
m_sliders.push_back(slider_alloc(SLIDER_ID_YSCALE + slider_index, str.c_str(), 500, defyscale, 1500, 2, param));
slider_alloc(std::move(str), 500, defyscale, 1500, 2, std::bind(&mame_ui_manager::slider_yscale, this, std::ref(screen), _1, _2));
str = string_format(_("%1$s Vert Position"), screen_desc);
m_sliders.push_back(slider_alloc(SLIDER_ID_YOFFSET + slider_index, str.c_str(), -500, defyoffset, 500, 2, param));
slider_index++;
slider_alloc(std::move(str), -500, defyoffset, 500, 2, std::bind(&mame_ui_manager::slider_yoffset, this, std::ref(screen), _1, _2));
}
slider_index = 0;
for (laserdisc_device &laserdisc : laserdisc_device_enumerator(machine.root_device()))
{
if (laserdisc.overlay_configured())
@ -1596,39 +1567,36 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
int defyscale = floor(config.m_overscaley * 1000.0f + 0.5f);
int defxoffset = floor(config.m_overposx * 1000.0f + 0.5f);
int defyoffset = floor(config.m_overposy * 1000.0f + 0.5f);
void *param = (void *)&laserdisc;
// add scale and offset controls per-overlay
std::string str = string_format(_("Laserdisc '%1$s' Horiz Stretch"), laserdisc.tag());
m_sliders.push_back(slider_alloc(SLIDER_ID_OVERLAY_XSCALE + slider_index, str.c_str(), 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, param));
slider_alloc(std::move(str), 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2,
std::bind(&mame_ui_manager::slider_overxscale, this, std::ref(laserdisc), _1, _2));
str = string_format(_("Laserdisc '%1$s' Horiz Position"), laserdisc.tag());
m_sliders.push_back(slider_alloc(SLIDER_ID_OVERLAY_YSCALE + slider_index, str.c_str(), -500, defxoffset, 500, 2, param));
slider_alloc(std::move(str), -500, defxoffset, 500, 2, std::bind(&mame_ui_manager::slider_overxoffset, this, std::ref(laserdisc), _1, _2));
str = string_format(_("Laserdisc '%1$s' Vert Stretch"), laserdisc.tag());
m_sliders.push_back(slider_alloc(SLIDER_ID_OVERLAY_XOFFSET + slider_index, str.c_str(), 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, param));
slider_alloc(std::move(str), 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2,
std::bind(&mame_ui_manager::slider_overyscale, this, std::ref(laserdisc), _1, _2));
str = string_format(_("Laserdisc '%1$s' Vert Position"), laserdisc.tag());
m_sliders.push_back(slider_alloc(SLIDER_ID_OVERLAY_YOFFSET + slider_index, str.c_str(), -500, defyoffset, 500, 2, param));
slider_index++;
slider_alloc(std::move(str), -500, defyoffset, 500, 2, std::bind(&mame_ui_manager::slider_overyoffset, this, std::ref(laserdisc), _1, _2));
}
}
slider_index = 0;
for (screen_device &screen : scriter)
{
if (screen.screen_type() == SCREEN_TYPE_VECTOR)
{
// add vector control
m_sliders.push_back(slider_alloc(SLIDER_ID_FLICKER + slider_index, _("Vector Flicker"), 0, 0, 1000, 10, nullptr));
m_sliders.push_back(slider_alloc(SLIDER_ID_BEAM_WIDTH_MIN + slider_index, _("Beam Width Minimum"), 100, 100, 1000, 1, nullptr));
m_sliders.push_back(slider_alloc(SLIDER_ID_BEAM_WIDTH_MAX + slider_index, _("Beam Width Maximum"), 100, 100, 1000, 1, nullptr));
m_sliders.push_back(slider_alloc(SLIDER_ID_BEAM_DOT_SIZE + slider_index, _("Beam Dot Size"), 100, 100, 1000, 1, nullptr));
m_sliders.push_back(slider_alloc(SLIDER_ID_BEAM_INTENSITY + slider_index, _("Beam Intensity Weight"), -1000, 0, 1000, 10, nullptr));
slider_index++;
// add vector control (FIXME: these should all be per-screen rather than global)
slider_alloc(_("Vector Flicker"), 0, 0, 1000, 10, std::bind(&mame_ui_manager::slider_flicker, this, std::ref(screen), _1, _2));
slider_alloc(_("Beam Width Minimum"), 100, 100, 1000, 1, std::bind(&mame_ui_manager::slider_beam_width_min, this, std::ref(screen), _1, _2));
slider_alloc(_("Beam Width Maximum"), 100, 100, 1000, 1, std::bind(&mame_ui_manager::slider_beam_width_max, this, std::ref(screen), _1, _2));
slider_alloc(_("Beam Dot Size"), 100, 100, 1000, 1, std::bind(&mame_ui_manager::slider_beam_dot_size, this, std::ref(screen), _1, _2));
slider_alloc(_("Beam Intensity Weight"), -1000, 0, 1000, 10, std::bind(&mame_ui_manager::slider_beam_intensity_weight, this, std::ref(screen), _1, _2));
break;
}
}
#ifdef MAME_DEBUG
slider_index = 0;
// add crosshair adjusters
for (auto &port : machine.ioport().ports())
{
@ -1637,9 +1605,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"));
m_sliders.push_back(slider_alloc(SLIDER_ID_CROSSHAIR_SCALE + slider_index, str.c_str(), -3000, 1000, 3000, 100, (void *)&field));
slider_alloc(std::move(str), -3000, 1000, 3000, 100, std::bind(&mame_ui_manager::slider_crossscale, this, std::ref(field), _1, _2));
str = string_format(_("Crosshair Offset %1$s"), (field.crosshair_axis() == CROSSHAIR_AXIS_X) ? _("X") : _("Y"));
m_sliders.push_back(slider_alloc(SLIDER_ID_CROSSHAIR_OFFSET + slider_index, str.c_str(), -3000, 0, 3000, 100, (void *)&field));
slider_alloc(std::move(str), -3000, 0, 3000, 100, std::bind(&mame_ui_manager::slider_crossoffset, this, std::ref(field), _1, _2));
}
}
}
@ -1660,76 +1628,18 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
return items;
}
//----------------------------------------------------
// slider_changed - global slider-modified callback
//----------------------------------------------------
int32_t mame_ui_manager::slider_changed(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
{
if (id == SLIDER_ID_VOLUME)
return slider_volume(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_MIXERVOL && id <= SLIDER_ID_MIXERVOL_LAST)
return slider_mixervol(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_ADJUSTER && id <= SLIDER_ID_ADJUSTER_LAST)
return slider_adjuster(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_OVERCLOCK && id <= SLIDER_ID_OVERCLOCK_LAST)
return slider_overclock(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_REFRESH && id <= SLIDER_ID_REFRESH_LAST)
return slider_refresh(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_BRIGHTNESS && id <= SLIDER_ID_BRIGHTNESS_LAST)
return slider_brightness(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_CONTRAST && id <= SLIDER_ID_CONTRAST_LAST)
return slider_contrast(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_GAMMA && id <= SLIDER_ID_GAMMA_LAST)
return slider_gamma(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_XSCALE && id <= SLIDER_ID_XSCALE_LAST)
return slider_xscale(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_YSCALE && id <= SLIDER_ID_YSCALE_LAST)
return slider_yscale(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_XOFFSET && id <= SLIDER_ID_XOFFSET_LAST)
return slider_xoffset(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_YOFFSET && id <= SLIDER_ID_YOFFSET_LAST)
return slider_yoffset(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_OVERLAY_XSCALE && id <= SLIDER_ID_OVERLAY_XSCALE_LAST)
return slider_overxscale(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_OVERLAY_YSCALE && id <= SLIDER_ID_OVERLAY_YSCALE_LAST)
return slider_overyscale(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_OVERLAY_XOFFSET && id <= SLIDER_ID_OVERLAY_XOFFSET_LAST)
return slider_overxoffset(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_OVERLAY_YOFFSET && id <= SLIDER_ID_OVERLAY_YOFFSET_LAST)
return slider_overyoffset(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_FLICKER && id <= SLIDER_ID_FLICKER_LAST)
return slider_flicker(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_BEAM_WIDTH_MIN && id <= SLIDER_ID_BEAM_WIDTH_MIN_LAST)
return slider_beam_width_min(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_BEAM_WIDTH_MAX && id <= SLIDER_ID_BEAM_WIDTH_MAX_LAST)
return slider_beam_width_max(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_BEAM_DOT_SIZE && id <= SLIDER_ID_BEAM_DOT_SIZE_LAST)
return slider_beam_dot_size(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_BEAM_INTENSITY && id <= SLIDER_ID_BEAM_INTENSITY_LAST)
return slider_beam_intensity_weight(machine, arg, id, str, newval);
#ifdef MAME_DEBUG
else if (id >= SLIDER_ID_CROSSHAIR_SCALE && id <= SLIDER_ID_CROSSHAIR_SCALE_LAST)
return slider_crossscale(machine, arg, id, str, newval);
else if (id >= SLIDER_ID_CROSSHAIR_OFFSET && id <= SLIDER_ID_CROSSHAIR_OFFSET_LAST)
return slider_crossoffset(machine, arg, id, str, newval);
#endif
return 0;
}
//-------------------------------------------------
// slider_volume - global volume slider callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_volume(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_volume(std::string *str, int32_t newval)
{
if (newval != SLIDER_NOCHANGE)
machine.sound().set_attenuation(newval);
machine().sound().set_attenuation(newval);
if (str)
*str = string_format(_("%1$3ddB"), machine.sound().attenuation());
return machine.sound().attenuation();
*str = string_format(_("%1$3ddB"), machine().sound().attenuation());
return machine().sound().attenuation();
}
@ -1738,10 +1648,10 @@ int32_t mame_ui_manager::slider_volume(running_machine &machine, void *arg, int
// slider callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_mixervol(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_mixervol(int item, std::string *str, int32_t newval)
{
mixer_input info;
if (!machine.sound().indexed_mixer_input((uintptr_t)arg, info))
if (!machine().sound().indexed_mixer_input(item, info))
return 0;
if (newval != SLIDER_NOCHANGE)
{
@ -1760,16 +1670,15 @@ int32_t mame_ui_manager::slider_mixervol(running_machine &machine, void *arg, in
// callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_adjuster(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_adjuster(ioport_field &field, std::string *str, int32_t newval)
{
ioport_field *field = (ioport_field *)arg;
ioport_field::user_settings settings;
field->get_user_settings(settings);
field.get_user_settings(settings);
if (newval != SLIDER_NOCHANGE)
{
settings.value = newval;
field->set_user_settings(settings);
field.set_user_settings(settings);
}
if (str)
*str = string_format(_("%1$d%%"), settings.value);
@ -1782,14 +1691,13 @@ int32_t mame_ui_manager::slider_adjuster(running_machine &machine, void *arg, in
// callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_overclock(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_overclock(device_t &device, std::string *str, int32_t newval)
{
device_t *cpu = (device_t *)arg;
if (newval != SLIDER_NOCHANGE)
cpu->set_clock_scale((float)newval * 0.001f);
device.set_clock_scale((float)newval * 0.001f);
if (str)
*str = string_format(_("%1$3.0f%%"), floor(cpu->clock_scale() * 100.0 + 0.5));
return floor(cpu->clock_scale() * 1000.0 + 0.5);
*str = string_format(_("%1$3.0f%%"), floor(device.clock_scale() * 100.0 + 0.5));
return floor(device.clock_scale() * 1000.0 + 0.5);
}
@ -1797,23 +1705,22 @@ int32_t mame_ui_manager::slider_overclock(running_machine &machine, void *arg, i
// slider_refresh - refresh rate slider callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_refresh(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_refresh(screen_device &screen, std::string *str, int32_t newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
double defrefresh = ATTOSECONDS_TO_HZ(screen->refresh_attoseconds());
double defrefresh = ATTOSECONDS_TO_HZ(screen.refresh_attoseconds());
double refresh;
if (newval != SLIDER_NOCHANGE)
{
int width = screen->width();
int height = screen->height();
const rectangle &visarea = screen->visible_area();
screen->configure(width, height, visarea, HZ_TO_ATTOSECONDS(defrefresh + (double)newval * 0.001));
int width = screen.width();
int height = screen.height();
const rectangle &visarea = screen.visible_area();
screen.configure(width, height, visarea, HZ_TO_ATTOSECONDS(defrefresh + (double)newval * 0.001));
}
if (str)
*str = string_format(_("%1$.3f" UTF8_NBSP "Hz"), screen->frame_period().as_hz());
refresh = screen->frame_period().as_hz();
*str = string_format(_("%1$.3f" UTF8_NBSP "Hz"), screen.frame_period().as_hz());
refresh = screen.frame_period().as_hz();
return floor((refresh - defrefresh) * 1000.0 + 0.5);
}
@ -1823,15 +1730,13 @@ int32_t mame_ui_manager::slider_refresh(running_machine &machine, void *arg, int
// callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_brightness(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_brightness(screen_device &screen, std::string *str, int32_t newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings = screen->container().get_user_settings();
render_container::user_settings settings = screen.container().get_user_settings();
if (newval != SLIDER_NOCHANGE)
{
settings.m_brightness = (float)newval * 0.001f;
screen->container().set_user_settings(settings);
screen.container().set_user_settings(settings);
}
if (str)
*str = string_format(_("%1$.3f"), settings.m_brightness);
@ -1844,15 +1749,13 @@ int32_t mame_ui_manager::slider_brightness(running_machine &machine, void *arg,
// callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_contrast(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_contrast(screen_device &screen, std::string *str, int32_t newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings = screen->container().get_user_settings();
render_container::user_settings settings = screen.container().get_user_settings();
if (newval != SLIDER_NOCHANGE)
{
settings.m_contrast = (float)newval * 0.001f;
screen->container().set_user_settings(settings);
screen.container().set_user_settings(settings);
}
if (str)
*str = string_format(_("%1$.3f"), settings.m_contrast);
@ -1864,15 +1767,13 @@ int32_t mame_ui_manager::slider_contrast(running_machine &machine, void *arg, in
// slider_gamma - screen gamma slider callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_gamma(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_gamma(screen_device &screen, std::string *str, int32_t newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings = screen->container().get_user_settings();
render_container::user_settings settings = screen.container().get_user_settings();
if (newval != SLIDER_NOCHANGE)
{
settings.m_gamma = (float)newval * 0.001f;
screen->container().set_user_settings(settings);
screen.container().set_user_settings(settings);
}
if (str)
*str = string_format(_("%1$.3f"), settings.m_gamma);
@ -1885,15 +1786,13 @@ int32_t mame_ui_manager::slider_gamma(running_machine &machine, void *arg, int i
// callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_xscale(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_xscale(screen_device &screen, std::string *str, int32_t newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings = screen->container().get_user_settings();
render_container::user_settings settings = screen.container().get_user_settings();
if (newval != SLIDER_NOCHANGE)
{
settings.m_xscale = (float)newval * 0.001f;
screen->container().set_user_settings(settings);
screen.container().set_user_settings(settings);
}
if (str)
*str = string_format(_("%1$.3f"), settings.m_xscale);
@ -1906,15 +1805,13 @@ int32_t mame_ui_manager::slider_xscale(running_machine &machine, void *arg, int
// callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_yscale(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_yscale(screen_device &screen, std::string *str, int32_t newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings = screen->container().get_user_settings();
render_container::user_settings settings = screen.container().get_user_settings();
if (newval != SLIDER_NOCHANGE)
{
settings.m_yscale = (float)newval * 0.001f;
screen->container().set_user_settings(settings);
screen.container().set_user_settings(settings);
}
if (str)
*str = string_format(_("%1$.3f"), settings.m_yscale);
@ -1927,15 +1824,13 @@ int32_t mame_ui_manager::slider_yscale(running_machine &machine, void *arg, int
// slider callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_xoffset(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_xoffset(screen_device &screen, std::string *str, int32_t newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings = screen->container().get_user_settings();
render_container::user_settings settings = screen.container().get_user_settings();
if (newval != SLIDER_NOCHANGE)
{
settings.m_xoffset = (float)newval * 0.001f;
screen->container().set_user_settings(settings);
screen.container().set_user_settings(settings);
}
if (str)
*str = string_format(_("%1$.3f"), settings.m_xoffset);
@ -1948,15 +1843,13 @@ int32_t mame_ui_manager::slider_xoffset(running_machine &machine, void *arg, int
// slider callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_yoffset(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_yoffset(screen_device &screen, std::string *str, int32_t newval)
{
screen_device *screen = reinterpret_cast<screen_device *>(arg);
render_container::user_settings settings = screen->container().get_user_settings();
render_container::user_settings settings = screen.container().get_user_settings();
if (newval != SLIDER_NOCHANGE)
{
settings.m_yoffset = (float)newval * 0.001f;
screen->container().set_user_settings(settings);
screen.container().set_user_settings(settings);
}
if (str)
*str = string_format(_("%1$.3f"), settings.m_yoffset);
@ -1969,16 +1862,15 @@ int32_t mame_ui_manager::slider_yoffset(running_machine &machine, void *arg, int
// callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_overxscale(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_overxscale(laserdisc_device &laserdisc, std::string *str, int32_t newval)
{
laserdisc_device *laserdisc = (laserdisc_device *)arg;
laserdisc_overlay_config settings;
laserdisc->get_overlay_config(settings);
laserdisc.get_overlay_config(settings);
if (newval != SLIDER_NOCHANGE)
{
settings.m_overscalex = (float)newval * 0.001f;
laserdisc->set_overlay_config(settings);
laserdisc.set_overlay_config(settings);
}
if (str)
*str = string_format(_("%1$.3f"), settings.m_overscalex);
@ -1991,16 +1883,15 @@ int32_t mame_ui_manager::slider_overxscale(running_machine &machine, void *arg,
// callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_overyscale(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_overyscale(laserdisc_device &laserdisc, std::string *str, int32_t newval)
{
laserdisc_device *laserdisc = (laserdisc_device *)arg;
laserdisc_overlay_config settings;
laserdisc->get_overlay_config(settings);
laserdisc.get_overlay_config(settings);
if (newval != SLIDER_NOCHANGE)
{
settings.m_overscaley = (float)newval * 0.001f;
laserdisc->set_overlay_config(settings);
laserdisc.set_overlay_config(settings);
}
if (str)
*str = string_format(_("%1$.3f"), settings.m_overscaley);
@ -2013,16 +1904,15 @@ int32_t mame_ui_manager::slider_overyscale(running_machine &machine, void *arg,
// slider callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_overxoffset(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_overxoffset(laserdisc_device &laserdisc, std::string *str, int32_t newval)
{
laserdisc_device *laserdisc = (laserdisc_device *)arg;
laserdisc_overlay_config settings;
laserdisc->get_overlay_config(settings);
laserdisc.get_overlay_config(settings);
if (newval != SLIDER_NOCHANGE)
{
settings.m_overposx = (float)newval * 0.001f;
laserdisc->set_overlay_config(settings);
laserdisc.set_overlay_config(settings);
}
if (str)
*str = string_format(_("%1$.3f"), settings.m_overposx);
@ -2035,16 +1925,15 @@ int32_t mame_ui_manager::slider_overxoffset(running_machine &machine, void *arg,
// slider callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_overyoffset(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_overyoffset(laserdisc_device &laserdisc, std::string *str, int32_t newval)
{
laserdisc_device *laserdisc = (laserdisc_device *)arg;
laserdisc_overlay_config settings;
laserdisc->get_overlay_config(settings);
laserdisc.get_overlay_config(settings);
if (newval != SLIDER_NOCHANGE)
{
settings.m_overposy = (float)newval * 0.001f;
laserdisc->set_overlay_config(settings);
laserdisc.set_overlay_config(settings);
}
if (str)
*str = string_format(_("%1$.3f"), settings.m_overposy);
@ -2057,7 +1946,7 @@ int32_t mame_ui_manager::slider_overyoffset(running_machine &machine, void *arg,
// callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_flicker(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_flicker([[maybe_unused]] screen_device &screen, std::string *str, int32_t newval)
{
if (newval != SLIDER_NOCHANGE)
vector_options::s_flicker = (float)newval * 0.001f;
@ -2072,7 +1961,7 @@ int32_t mame_ui_manager::slider_flicker(running_machine &machine, void *arg, int
// callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_beam_width_min(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_beam_width_min([[maybe_unused]] screen_device &screen, std::string *str, int32_t newval)
{
if (newval != SLIDER_NOCHANGE)
vector_options::s_beam_width_min = std::min((float)newval * 0.01f, vector_options::s_beam_width_max);
@ -2087,7 +1976,7 @@ int32_t mame_ui_manager::slider_beam_width_min(running_machine &machine, void *a
// callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_beam_width_max(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_beam_width_max([[maybe_unused]] screen_device &screen, std::string *str, int32_t newval)
{
if (newval != SLIDER_NOCHANGE)
vector_options::s_beam_width_max = std::max((float)newval * 0.01f, vector_options::s_beam_width_min);
@ -2102,7 +1991,7 @@ int32_t mame_ui_manager::slider_beam_width_max(running_machine &machine, void *a
// callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_beam_dot_size(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_beam_dot_size([[maybe_unused]] screen_device &screen, std::string *str, int32_t newval)
{
if (newval != SLIDER_NOCHANGE)
vector_options::s_beam_dot_size = std::max((float)newval * 0.01f, 0.1f);
@ -2117,7 +2006,7 @@ int32_t mame_ui_manager::slider_beam_dot_size(running_machine &machine, void *ar
// callback
//-------------------------------------------------
int32_t mame_ui_manager::slider_beam_intensity_weight(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_beam_intensity_weight([[maybe_unused]] screen_device &screen, std::string *str, int32_t newval)
{
if (newval != SLIDER_NOCHANGE)
vector_options::s_beam_intensity_weight = (float)newval * 0.001f;
@ -2133,15 +2022,13 @@ int32_t mame_ui_manager::slider_beam_intensity_weight(running_machine &machine,
//-------------------------------------------------
#ifdef MAME_DEBUG
int32_t mame_ui_manager::slider_crossscale(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_crossscale(ioport_field &field, std::string *str, int32_t newval)
{
ioport_field *field = (ioport_field *)arg;
if (newval != SLIDER_NOCHANGE)
field->set_crosshair_scale(float(newval) * 0.001);
field.set_crosshair_scale(float(newval) * 0.001);
if (str)
*str = string_format((field->crosshair_axis() == CROSSHAIR_AXIS_X) ? _("Crosshair Scale X %1$1.3f") : _("Crosshair Scale Y %1$1.3f"), float(newval) * 0.001f);
return floor(field->crosshair_scale() * 1000.0f + 0.5f);
*str = string_format((field.crosshair_axis() == CROSSHAIR_AXIS_X) ? _("Crosshair Scale X %1$1.3f") : _("Crosshair Scale Y %1$1.3f"), float(newval) * 0.001f);
return floor(field.crosshair_scale() * 1000.0f + 0.5f);
}
#endif
@ -2152,15 +2039,13 @@ int32_t mame_ui_manager::slider_crossscale(running_machine &machine, void *arg,
//-------------------------------------------------
#ifdef MAME_DEBUG
int32_t mame_ui_manager::slider_crossoffset(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t mame_ui_manager::slider_crossoffset(ioport_field &field, std::string *str, int32_t newval)
{
ioport_field *field = (ioport_field *)arg;
if (newval != SLIDER_NOCHANGE)
field->set_crosshair_offset(float(newval) * 0.001f);
field.set_crosshair_offset(float(newval) * 0.001f);
if (str)
*str = string_format((field->crosshair_axis() == CROSSHAIR_AXIS_X) ? _("Crosshair Offset X %1$1.3f") : _("Crosshair Offset Y %1$1.3f"), float(newval) * 0.001f);
return field->crosshair_offset();
*str = string_format((field.crosshair_axis() == CROSSHAIR_AXIS_X) ? _("Crosshair Offset X %1$1.3f") : _("Crosshair Offset Y %1$1.3f"), float(newval) * 0.001f);
return field.crosshair_offset();
}
#endif

View File

@ -36,6 +36,8 @@ class machine_info;
} // namespace ui
class laserdisc_device;
/***************************************************************************
CONSTANTS
@ -170,7 +172,7 @@ private:
// ======================> mame_ui_manager
class mame_ui_manager : public ui_manager, public slider_changed_notifier
class mame_ui_manager : public ui_manager
{
public:
enum draw_mode
@ -312,36 +314,34 @@ private:
void exit();
void config_load(config_type cfg_type, util::xml::data_node const *parentnode);
void config_save(config_type cfg_type, util::xml::data_node *parentnode);
std::unique_ptr<slider_state> slider_alloc(int id, const char *title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, void *arg);
template <typename... Params> void slider_alloc(Params &&...args) { m_sliders.push_back(std::make_unique<slider_state>(std::forward<Params>(args)...)); }
// slider controls
virtual int32_t slider_changed(running_machine &machine, void *arg, int id, std::string *str, int32_t newval) override;
int32_t slider_volume(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_mixervol(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_adjuster(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_overclock(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_refresh(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_brightness(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_contrast(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_gamma(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_xscale(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_yscale(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_xoffset(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_yoffset(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_overxscale(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_overyscale(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_overxoffset(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_overyoffset(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_flicker(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_beam_width_min(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_beam_width_max(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_beam_dot_size(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_beam_intensity_weight(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_volume(std::string *str, int32_t newval);
int32_t slider_mixervol(int item, std::string *str, int32_t newval);
int32_t slider_adjuster(ioport_field &field, std::string *str, int32_t newval);
int32_t slider_overclock(device_t &device, std::string *str, int32_t newval);
int32_t slider_refresh(screen_device &screen, std::string *str, int32_t newval);
int32_t slider_brightness(screen_device &screen, std::string *str, int32_t newval);
int32_t slider_contrast(screen_device &screen, std::string *str, int32_t newval);
int32_t slider_gamma(screen_device &screen, std::string *str, int32_t newval);
int32_t slider_xscale(screen_device &screen, std::string *str, int32_t newval);
int32_t slider_yscale(screen_device &screen, std::string *str, int32_t newval);
int32_t slider_xoffset(screen_device &screen, std::string *str, int32_t newval);
int32_t slider_yoffset(screen_device &screen, std::string *str, int32_t newval);
int32_t slider_overxscale(laserdisc_device &laserdisc, std::string *str, int32_t newval);
int32_t slider_overyscale(laserdisc_device &laserdisc, std::string *str, int32_t newval);
int32_t slider_overxoffset(laserdisc_device &laserdisc, std::string *str, int32_t newval);
int32_t slider_overyoffset(laserdisc_device &laserdisc, std::string *str, int32_t newval);
int32_t slider_flicker(screen_device &screen, std::string *str, int32_t newval);
int32_t slider_beam_width_min(screen_device &screen, std::string *str, int32_t newval);
int32_t slider_beam_width_max(screen_device &screen, std::string *str, int32_t newval);
int32_t slider_beam_dot_size(screen_device &screen, std::string *str, int32_t newval);
int32_t slider_beam_intensity_weight(screen_device &screen, std::string *str, int32_t newval);
std::string slider_get_screen_desc(screen_device &screen);
#ifdef MAME_DEBUG
int32_t slider_crossscale(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_crossoffset(running_machine &machine, void *arg, int id, std::string *str, int32_t newval);
int32_t slider_crossscale(ioport_field &field, std::string *str, int32_t newval);
int32_t slider_crossoffset(ioport_field &field, std::string *str, int32_t newval);
#endif
std::vector<std::unique_ptr<slider_state>> m_sliders;

View File

@ -377,7 +377,7 @@ void chain_manager::update_screen_count(uint32_t screen_count)
}
}
int32_t chain_manager::slider_changed(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
int32_t chain_manager::slider_changed(int id, std::string *str, int32_t newval)
{
if (newval != SLIDER_NOCHANGE)
{
@ -405,18 +405,16 @@ void chain_manager::create_selection_slider(uint32_t screen_index)
return;
}
std::unique_ptr<slider_state> state = std::make_unique<slider_state>();
int32_t minval = 0;
int32_t defval = m_current_chain[screen_index];
int32_t maxval = m_available_chains.size() - 1;
int32_t incval = 1;
state->minval = 0;
state->defval = m_current_chain[screen_index];
state->maxval = m_available_chains.size() - 1;
state->incval = 1;
std::string description = "Window " + std::to_string(m_window_index) + ", Screen " + std::to_string(screen_index) + " Effect:";
using namespace std::placeholders;
state->update = std::bind(&chain_manager::slider_changed, this, _1, _2, _3, _4, _5);
state->arg = this;
state->id = screen_index;
state->description = "Window " + std::to_string(m_window_index) + ", Screen " + std::to_string(screen_index) + " Effect:";
auto state = std::make_unique<slider_state>(std::move(description), minval, defval, maxval, incval,
std::bind(&chain_manager::slider_changed, this, screen_index, _1, _2));
ui::menu_item item;
item.text = state->description;

View File

@ -22,7 +22,6 @@
#include "targetmanager.h"
#include "effectmanager.h"
#include "../frontend/mame/ui/menuitem.h"
#include "../frontend/mame/ui/sliderchangednotifier.h"
#include "render.h"
class running_machine;
@ -47,7 +46,7 @@ public:
const std::string m_path;
};
class chain_manager : public slider_changed_notifier
class chain_manager
{
public:
chain_manager(running_machine& machine, osd_options& options, texture_manager& textures, target_manager& targets, effect_manager& effects, uint32_t window_index, slider_dirty_notifier& slider_notifier);
@ -123,7 +122,7 @@ private:
void update_screen_count(uint32_t screen_count);
virtual int32_t slider_changed(running_machine &machine, void *arg, int id, std::string *str, int32_t newval) override;
int32_t slider_changed(int id, std::string *str, int32_t newval);
void create_selection_slider(uint32_t screen_index);
bool needs_sliders();

View File

@ -72,11 +72,6 @@ void bgfx_input_pair::bind(bgfx_effect *effect, const int32_t screen) const
bgfx::setTexture(m_index, effect->uniform(m_sampler)->handle(), chains().textures().handle(name));
}
int32_t bgfx_input_pair::slider_changed(running_machine &machine, void *arg, int id, std::string *str, int32_t newval)
{
return texture_changed(id, str, newval);
}
int32_t bgfx_input_pair::texture_changed(int32_t id, std::string *str, int32_t newval)
{
if (newval != SLIDER_NOCHANGE)
@ -111,18 +106,16 @@ int32_t bgfx_input_pair::texture_changed(int32_t id, std::string *str, int32_t n
void bgfx_input_pair::create_selection_slider(uint32_t screen_index)
{
m_slider_state = std::make_unique<slider_state>();
int32_t minval = 0;
int32_t defval = m_current_texture;
int32_t maxval = m_available_textures.size() - 1;
int32_t incval = 1;
m_slider_state->minval = 0;
m_slider_state->defval = m_current_texture;
m_slider_state->maxval = m_available_textures.size() - 1;
m_slider_state->incval = 1;
std::string description = "Window " + std::to_string(chains().window_index()) + ", Screen " + std::to_string(screen_index) + " " + m_selection + ":";
using namespace std::placeholders;
m_slider_state->update = std::bind(&bgfx_input_pair::slider_changed, this, _1, _2, _3, _4, _5);
m_slider_state->arg = this;
m_slider_state->id = screen_index;
m_slider_state->description = "Window " + std::to_string(chains().window_index()) + ", Screen " + std::to_string(screen_index) + " " + m_selection + ":";
m_slider_state = std::make_unique<slider_state>(std::move(description), minval, defval, maxval, incval,
std::bind(&bgfx_input_pair::texture_changed, this, screen_index, _1, _2));
ui::menu_item item;
item.text = m_slider_state->description;

View File

@ -17,13 +17,12 @@
#include <string>
#include "../frontend/mame/ui/menuitem.h"
#include "../frontend/mame/ui/sliderchangednotifier.h"
struct slider_state;
class bgfx_effect;
class chain_manager;
class bgfx_input_pair : public slider_changed_notifier
class bgfx_input_pair
{
public:
bgfx_input_pair(int index, std::string sampler, std::string texture, std::vector<std::string> available_textures, std::string selection, chain_manager& chains, uint32_t screen_index);
@ -39,7 +38,6 @@ public:
std::vector<ui::menu_item> get_slider_list();
private:
virtual int32_t slider_changed(running_machine &machine, void *arg, int /*id*/, std::string *str, int32_t newval) override;
void create_selection_slider(uint32_t screen_index);
bool needs_sliders();

View File

@ -37,38 +37,21 @@ bgfx_slider::~bgfx_slider()
{
}
int32_t bgfx_slider::slider_changed(running_machine& /*machine*/, void *arg, int /*id*/, std::string *str, int32_t newval)
{
if (arg != nullptr)
{
return reinterpret_cast<bgfx_slider*>(arg)->update(str, newval);
}
return 0;
}
void bgfx_slider::import(float val)
{
m_value = val;
slider_changed(m_machine, this, m_slider_state->id, nullptr, int32_t(floor(m_value / m_step + 0.5f)));
update(nullptr, int32_t(floor(m_value / m_step + 0.5f)));
}
std::unique_ptr<slider_state> bgfx_slider::create_core_slider()
{
auto state = std::make_unique<slider_state>();
state->minval = int32_t(floor(m_min / m_step + 0.5f));
state->defval = int32_t(floor(m_default / m_step + 0.5f));
state->maxval = int32_t(floor(m_max / m_step + 0.5f));
state->incval = int32_t(floor(m_step / m_step + 0.5f));
int32_t minval = int32_t(floor(m_min / m_step + 0.5f));
int32_t defval = int32_t(floor(m_default / m_step + 0.5f));
int32_t maxval = int32_t(floor(m_max / m_step + 0.5f));
int32_t incval = int32_t(floor(m_step / m_step + 0.5f));
using namespace std::placeholders;
state->update = std::bind(&bgfx_slider::slider_changed, this, _1, _2, _3, _4, _5);
state->arg = this;
state->id = 0;
state->description = m_description;
return state;
return std::make_unique<slider_state>(m_description, minval, defval, maxval, incval, std::bind(&bgfx_slider::update, this, _1, _2));
}
int32_t bgfx_slider::update(std::string *str, int32_t newval)

View File

@ -16,11 +16,9 @@
#include <string>
#include <vector>
#include "../frontend/mame/ui/sliderchangednotifier.h"
struct slider_state;
class bgfx_slider : public slider_changed_notifier
class bgfx_slider
{
public:
enum slider_type
@ -62,7 +60,6 @@ public:
void import(float val);
protected:
virtual int32_t slider_changed(running_machine &machine, void *arg, int /*id*/, std::string *str, int32_t newval) override;
std::unique_ptr<slider_state> create_core_slider();
int32_t as_int() const { return int32_t(floor(m_value / m_step + 0.5f)); }

View File

@ -1987,23 +1987,10 @@ static void get_vector(const char *data, int count, float *out, bool report_erro
// be done in a more ideal way.
//============================================================
std::unique_ptr<slider_state> shaders::slider_alloc(int id, const char *title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, void *arg)
std::unique_ptr<slider_state> shaders::slider_alloc(std::string &&title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, slider *arg)
{
auto state = std::make_unique<slider_state>();
state->minval = minval;
state->defval = defval;
state->maxval = maxval;
state->incval = incval;
using namespace std::placeholders;
state->update = std::bind(&shaders::slider_changed, this, _1, _2, _3, _4, _5);
state->arg = arg;
state->id = id;
state->description = title;
return state;
return std::make_unique<slider_state>(std::move(title), minval, defval, maxval, incval, std::bind(&slider::update, arg, _1, _2));
}
@ -2069,15 +2056,6 @@ int32_t slider::update(std::string *str, int32_t newval)
return 0;
}
int32_t shaders::slider_changed(running_machine& /*machine*/, void *arg, int /*id*/, std::string *str, int32_t newval)
{
if (arg != nullptr)
{
return reinterpret_cast<slider *>(arg)->update(str, newval);
}
return 0;
}
char shaders::last_system_name[16];
hlsl_options shaders::last_options = { false };
@ -2388,7 +2366,7 @@ void shaders::init_slider_list()
break;
}
std::unique_ptr<slider_state> core_slider = slider_alloc(desc->id, name.c_str(), desc->minval, desc->defval, desc->maxval, desc->step, slider_arg);
std::unique_ptr<slider_state> core_slider = slider_alloc(std::move(name), desc->minval, desc->defval, desc->maxval, desc->step, slider_arg);
ui::menu_item item;
item.text = core_slider->description;

View File

@ -290,7 +290,7 @@ private:
void * m_value;
};
class shaders : public slider_changed_notifier
class shaders
{
friend class effect;
friend class uniform;
@ -330,8 +330,7 @@ public:
void delete_resources();
// slider-related functions
virtual int32_t slider_changed(running_machine &machine, void *arg, int /*id*/, std::string *str, int32_t newval) override;
std::unique_ptr<slider_state> slider_alloc(int id, const char *title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, void *arg);
std::unique_ptr<slider_state> slider_alloc(std::string &&title, int32_t minval, int32_t defval, int32_t maxval, int32_t incval, slider *arg);
void init_slider_list();
std::vector<ui::menu_item> get_slider_list() { return m_sliders; }
void *get_slider_option(int id, int index = 0);