diff options
Diffstat (limited to 'src/osd/modules/render/bgfx/slider.cpp')
-rw-r--r-- | src/osd/modules/render/bgfx/slider.cpp | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/src/osd/modules/render/bgfx/slider.cpp b/src/osd/modules/render/bgfx/slider.cpp index 0cc97275497..dcd64c0c865 100644 --- a/src/osd/modules/render/bgfx/slider.cpp +++ b/src/osd/modules/render/bgfx/slider.cpp @@ -6,13 +6,15 @@ // //============================================================ -#include "emu.h" - #include "slider.h" #include "../frontend/mame/ui/slider.h" -bgfx_slider::bgfx_slider(running_machine &machine, std::string name, float min, float def, float max, float step, slider_type type, screen_type screen, std::string format, std::string description, std::vector<std::string>& strings) - : m_name(name) +#include "strformat.h" + +#include <utility> + +bgfx_slider::bgfx_slider(running_machine &machine, std::string &&name, float min, float def, float max, float step, slider_type type, screen_type screen, std::string format, std::string description, std::vector<std::string>& strings) + : m_name(std::move(name)) , m_step(step) , m_type(type) , m_screen_type(screen) @@ -25,7 +27,7 @@ bgfx_slider::bgfx_slider(running_machine &machine, std::string name, float min, m_max = max; m_value = def; - for (std::string string : strings) + for (const std::string &string : strings) { m_strings.push_back(string); } @@ -37,38 +39,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 = make_unique_clear<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) @@ -83,7 +68,7 @@ int32_t bgfx_slider::update(std::string *str, int32_t newval) } if (str != nullptr) { - *str = string_format(m_format, m_strings[as_int()]); + *str = util::string_format(m_format, m_strings[as_int()]); } return as_int(); } @@ -96,21 +81,21 @@ int32_t bgfx_slider::update(std::string *str, int32_t newval) } if (str != nullptr) { - *str = string_format(m_format, as_int()); + *str = util::string_format(m_format, as_int()); } return as_int(); } default: { - float *val_ptr = reinterpret_cast<float *>(&m_value); + auto *val_ptr = reinterpret_cast<float *>(&m_value); if (newval != SLIDER_NOCHANGE) { *val_ptr = float(newval) * m_step; } if (str != nullptr) { - *str = string_format(m_format, *val_ptr); + *str = util::string_format(m_format, *val_ptr); } return int32_t(floor(*val_ptr / m_step + 0.5f)); } |