I was fiddling around with the lua draw_text routine and saw that there's an option to call draw_text with a justification parameter like "right" or "center".
But there was no text displayed... because it doesn't have the y coordinate set properly.
Running with the apple2p driver,
emu:pause() manager:machine().screens[":screen"]:draw_text("right",25,"Hello",0xffffffff,0xffff0000)
should display some text on the screen, but it doesn't because of a missing line:
In src/mame/frontend/luaengine.cpp:
"draw_text", [this](screen_device &sdev, sol::object xobj, float y, const char *msg, sol::object color, sol::object bcolor) {
int sc_width = sdev.visible_area().width();
int sc_height = sdev.visible_area().height();
auto justify = ui::text_layout::LEFT;
float x = 0;
if(xobj.is<float>())
{
x = std::min(std::max(0.0f, xobj.as<float>()), float(sc_width-1)) / float(sc_width);
y = std::min(std::max(0.0f, y), float(sc_height-1)) / float(sc_height);
}
else if(xobj.is<const char *>())
{
std::string just_str = xobj.as<const char *>();
if(just_str == "right")
justify = ui::text_layout::RIGHT;
else if(just_str == "center")
justify = ui::text_layout::CENTER;
// need to set the y coordinate properly
y = std::min(std::max(0.0f, y), float(sc_height-1)) / float(sc_height);
}
else
{
luaL_error(m_lua_state, "Error in param 1 to draw_text");
return;
}
I'm not sure anybody uses this, it's super obscure.