mirror of
https://github.com/holub/mame
synced 2025-10-07 09:25:34 +03:00
Merge pull request #718 from motoschifo/master
Added Lua function screen.orientation()
This commit is contained in:
commit
df00bf568f
@ -838,6 +838,54 @@ int lua_engine::lua_screen::l_width(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// screen_orientation - return screen orientation
|
||||||
|
// -> manager:machine().screens[":screen"]:orientation()
|
||||||
|
// -> rotation_angle (0, 90, 180, 270)
|
||||||
|
// -> flipx (true, false)
|
||||||
|
// -> flipy (true, false)
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
int lua_engine::lua_screen::l_orientation(lua_State *L)
|
||||||
|
{
|
||||||
|
UINT32 flags = (luaThis->machine().system().flags & ORIENTATION_MASK);
|
||||||
|
|
||||||
|
int rotation_angle = 0;
|
||||||
|
switch (flags)
|
||||||
|
{
|
||||||
|
case ORIENTATION_FLIP_X:
|
||||||
|
rotation_angle = 0;
|
||||||
|
break;
|
||||||
|
case ORIENTATION_SWAP_XY:
|
||||||
|
case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_X:
|
||||||
|
rotation_angle = 90;
|
||||||
|
break;
|
||||||
|
case ORIENTATION_FLIP_Y:
|
||||||
|
case ORIENTATION_FLIP_X|ORIENTATION_FLIP_Y:
|
||||||
|
rotation_angle = 180;
|
||||||
|
break;
|
||||||
|
case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_Y:
|
||||||
|
case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_X|ORIENTATION_FLIP_Y:
|
||||||
|
rotation_angle = 270;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_createtable(L, 2, 2);
|
||||||
|
lua_pushliteral(L, "rotation_angle");
|
||||||
|
lua_pushinteger(L, rotation_angle);
|
||||||
|
|
||||||
|
lua_settable(L, -3);
|
||||||
|
lua_pushliteral(L, "flipx");
|
||||||
|
lua_pushboolean(L, (flags & ORIENTATION_FLIP_X));
|
||||||
|
|
||||||
|
lua_settable(L, -3);
|
||||||
|
lua_pushliteral(L, "flipy");
|
||||||
|
lua_pushboolean(L, (flags & ORIENTATION_FLIP_Y));
|
||||||
|
lua_settable(L, -3);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// screen_refresh - return screen refresh rate
|
// screen_refresh - return screen refresh rate
|
||||||
// -> manager:machine().screens[":screen"]:refresh()
|
// -> manager:machine().screens[":screen"]:refresh()
|
||||||
@ -1579,6 +1627,7 @@ void lua_engine::initialize()
|
|||||||
.addCFunction ("draw_text", &lua_screen::l_draw_text)
|
.addCFunction ("draw_text", &lua_screen::l_draw_text)
|
||||||
.addCFunction ("height", &lua_screen::l_height)
|
.addCFunction ("height", &lua_screen::l_height)
|
||||||
.addCFunction ("width", &lua_screen::l_width)
|
.addCFunction ("width", &lua_screen::l_width)
|
||||||
|
.addCFunction ("orientation", &lua_screen::l_orientation)
|
||||||
.addCFunction ("refresh", &lua_screen::l_refresh)
|
.addCFunction ("refresh", &lua_screen::l_refresh)
|
||||||
.addCFunction ("snapshot", &lua_screen::l_snapshot)
|
.addCFunction ("snapshot", &lua_screen::l_snapshot)
|
||||||
.addCFunction ("type", &lua_screen::l_type)
|
.addCFunction ("type", &lua_screen::l_type)
|
||||||
|
@ -138,6 +138,7 @@ private:
|
|||||||
struct lua_screen {
|
struct lua_screen {
|
||||||
int l_height(lua_State *L);
|
int l_height(lua_State *L);
|
||||||
int l_width(lua_State *L);
|
int l_width(lua_State *L);
|
||||||
|
int l_orientation(lua_State *L);
|
||||||
int l_refresh(lua_State *L);
|
int l_refresh(lua_State *L);
|
||||||
int l_type(lua_State *L);
|
int l_type(lua_State *L);
|
||||||
int l_snapshot(lua_State *L);
|
int l_snapshot(lua_State *L);
|
||||||
|
Loading…
Reference in New Issue
Block a user