diff options
Diffstat (limited to 'src/osd/modules/render/bgfx/slider.cpp')
-rw-r--r-- | src/osd/modules/render/bgfx/slider.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/osd/modules/render/bgfx/slider.cpp b/src/osd/modules/render/bgfx/slider.cpp index 94e9c26ee0c..a4424c8600f 100644 --- a/src/osd/modules/render/bgfx/slider.cpp +++ b/src/osd/modules/render/bgfx/slider.cpp @@ -11,24 +11,18 @@ #include "slider.h" #include "ui/ui.h" -bgfx_slider::bgfx_slider(running_machine &machine, std::string name, int32_t min, int32_t def, int32_t max, int32_t step, slider_type type, screen_type screen, float scale, std::string format, std::string description, std::vector<std::string>& strings) +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) , m_step(step) , m_type(type) , m_screen_type(screen) - , m_scale(scale) , m_format(format) , m_description(description) { m_min = min; m_default = def; m_max = max; - m_value = def; - if (m_type != slider_type::SLIDER_INT && m_type != slider_type::SLIDER_INT_ENUM) - { - m_value = float(def) * scale; - } for (std::string string : strings) { @@ -56,10 +50,10 @@ slider_state* bgfx_slider::create_core_slider(running_machine& machine) int size = sizeof(slider_state) + m_description.length(); slider_state *state = reinterpret_cast<slider_state *>(auto_alloc_array_clear(machine, UINT8, size)); - state->minval = m_min; - state->defval = m_default; - state->maxval = m_max; - state->incval = m_step; + 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)); state->update = update_trampoline; state->arg = this; state->id = 0; @@ -103,13 +97,13 @@ int32_t bgfx_slider::update(std::string *str, int32_t newval) float *val_ptr = reinterpret_cast<float *>(&m_value); if (newval != SLIDER_NOCHANGE) { - *val_ptr = float(newval) * m_scale; + *val_ptr = float(newval) * m_step; } if (str != nullptr) { *str = string_format(m_format, *val_ptr); } - return int32_t(floor(*val_ptr / m_scale + 0.5f)); + return int32_t(floor(*val_ptr / m_step + 0.5f)); } } return 0; |