From 2430b2e9981a56a4c407dc835ee74e7862e785f3 Mon Sep 17 00:00:00 2001 From: Craig Robbins Date: Sat, 28 Mar 2015 11:05:39 +1000 Subject: Add Lua function get_video_modes() for main menu Also updates and uses porting::getSupportedVideoModes() --- src/script/lua_api/l_mainmenu.cpp | 23 +++++++++++++++++++++++ src/script/lua_api/l_mainmenu.h | 2 ++ 2 files changed, 25 insertions(+) (limited to 'src/script/lua_api') diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index f90508012..22fc176bf 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -1056,6 +1056,28 @@ int ModApiMainMenu::l_get_video_drivers(lua_State *L) return 1; } +/******************************************************************************/ +int ModApiMainMenu::l_get_video_modes(lua_State *L) +{ + std::vector > videomodes + = porting::getSupportedVideoModes(); + + lua_newtable(L); + for (u32 i = 0; i != videomodes.size(); i++) { + lua_newtable(L); + lua_pushnumber(L, videomodes[i].X); + lua_setfield(L, -2, "w"); + lua_pushnumber(L, videomodes[i].Y); + lua_setfield(L, -2, "h"); + lua_pushnumber(L, videomodes[i].Z); + lua_setfield(L, -2, "depth"); + + lua_rawseti(L, -2, i + 1); + } + + return 1; +} + /******************************************************************************/ int ModApiMainMenu::l_gettext(lua_State *L) { @@ -1164,6 +1186,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top) API_FCT(sound_stop); API_FCT(gettext); API_FCT(get_video_drivers); + API_FCT(get_video_modes); API_FCT(get_screen_info); API_FCT(get_min_supp_proto); API_FCT(get_max_supp_proto); diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h index 8b21a93aa..9c1fed272 100644 --- a/src/script/lua_api/l_mainmenu.h +++ b/src/script/lua_api/l_mainmenu.h @@ -137,6 +137,8 @@ private: static int l_get_video_drivers(lua_State *L); + static int l_get_video_modes(lua_State *L); + //version compatibility static int l_get_min_supp_proto(lua_State *L); -- cgit v1.2.3