Add love.system.getPreferredLocales()

This commit is contained in:
Miku AuahDark
2022-03-17 23:38:25 +08:00
parent 9c75f816fe
commit c2104f896a
4 changed files with 57 additions and 0 deletions
+17
View File
@@ -101,6 +101,22 @@ int w_hasBackgroundMusic(lua_State *L)
return 1;
}
int w_getPreferredLocales(lua_State* L)
{
int i = 1;
std::vector<std::string> locales = instance()->getPreferredLocales();
lua_createtable(L, locales.size(), 0);
for (const std::string& str: locales)
{
luax_pushstring(L, str);
lua_rawseti(L, -2, i++);
}
return 1;
}
static const luaL_Reg functions[] =
{
{ "getOS", w_getOS },
@@ -111,6 +127,7 @@ static const luaL_Reg functions[] =
{ "openURL", w_openURL },
{ "vibrate", w_vibrate },
{ "hasBackgroundMusic", w_hasBackgroundMusic },
{ "getPreferredLocales", w_getPreferredLocales },
{ 0, 0 }
};