diff options
author | 2021-02-03 17:45:21 -0500 | |
---|---|---|
committer | 2021-02-03 17:45:21 -0500 | |
commit | bcf647342a9643fedfba6d9ebc3be56bcc4c1cf1 (patch) | |
tree | fb2c32cc05cc43803f19ba8b0a2fc661ef0d5cd0 /src/frontend/mame/luaengine.cpp | |
parent | 0c57408ed81194046b56318dd6fd8583f8de44b3 (diff) |
Use std::clamp in various core functions
Diffstat (limited to 'src/frontend/mame/luaengine.cpp')
-rw-r--r-- | src/frontend/mame/luaengine.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index d8ec8c746db..c7800f70829 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -63,10 +63,10 @@ void do_draw_box(screen_device &sdev, float x1, float y1, float x2, float y2, ui { float const sc_width(sdev.visible_area().width()); float const sc_height(sdev.visible_area().height()); - x1 = std::min(std::max(0.0f, x1), sc_width) / sc_width; - y1 = std::min(std::max(0.0f, y1), sc_height) / sc_height; - x2 = std::min(std::max(0.0f, x2), sc_width) / sc_width; - y2 = std::min(std::max(0.0f, y2), sc_height) / sc_height; + x1 = std::clamp(x1, 0.0f, sc_width) / sc_width; + y1 = std::clamp(y1, 0.0f, sc_height) / sc_height; + x2 = std::clamp(x2, 0.0f, sc_width) / sc_width; + y2 = std::clamp(y2, 0.0f, sc_height) / sc_height; mame_machine_manager::instance()->ui().draw_outlined_box(sdev.container(), x1, y1, x2, y2, fgcolor, bgcolor); } @@ -74,10 +74,10 @@ void do_draw_line(screen_device &sdev, float x1, float y1, float x2, float y2, u { float const sc_width(sdev.visible_area().width()); float const sc_height(sdev.visible_area().height()); - x1 = std::min(std::max(0.0f, x1), sc_width) / sc_width; - y1 = std::min(std::max(0.0f, y1), sc_height) / sc_height; - x2 = std::min(std::max(0.0f, x2), sc_width) / sc_width; - y2 = std::min(std::max(0.0f, y2), sc_height) / sc_height; + x1 = std::clamp(x1, 0.0f, sc_width) / sc_width; + y1 = std::clamp(y1, 0.0f, sc_height) / sc_height; + x2 = std::clamp(x2, 0.0f, sc_width) / sc_width; + y2 = std::clamp(y2, 0.0f, sc_height) / sc_height; sdev.container().add_line(x1, y1, x2, y2, UI_LINE_WIDTH, rgb_t(color), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } @@ -89,7 +89,7 @@ void do_draw_text(lua_State *L, screen_device &sdev, sol::object &xobj, float y, float x = 0; if (xobj.is<float>()) { - x = std::min(std::max(0.0f, xobj.as<float>()), sc_width) / sc_width; + x = std::clamp(xobj.as<float>(), 0.0f, sc_width) / sc_width; } else if (xobj.is<char const *>()) { @@ -106,7 +106,7 @@ void do_draw_text(lua_State *L, screen_device &sdev, sol::object &xobj, float y, luaL_error(L, "Error in param 1 to draw_text"); return; } - y = std::min(std::max(0.0f, y), sc_height) / sc_height; + y = std::clamp(y, 0.0f, sc_height) / sc_height; mame_machine_manager::instance()->ui().draw_text_full( sdev.container(), msg, |