Using latest android branch of LÖVE (6d14516b05c9) that now syncs with default (woooo!)

This commit is contained in:
fysx
2015-07-03 19:09:18 +02:00
parent 1924bbdeeb
commit 357a7237a4
304 changed files with 28694 additions and 23064 deletions
@@ -19,8 +19,12 @@
**/
// LOVE
#include "common/config.h"
#include "wrap_Font.h"
// C++
#include <algorithm>
namespace love
{
namespace graphics
@@ -30,7 +34,7 @@ namespace opengl
Font *luax_checkfont(lua_State *L, int idx)
{
return luax_checktype<Font>(L, idx, "Font", GRAPHICS_FONT_T);
return luax_checktype<Font>(L, idx, GRAPHICS_FONT_ID);
}
int w_Font_getHeight(lua_State *L)
@@ -54,15 +58,24 @@ int w_Font_getWrap(lua_State *L)
Font *t = luax_checkfont(L, 1);
const char *str = luaL_checkstring(L, 2);
float wrap = (float) luaL_checknumber(L, 3);
int max_width = 0, numlines = 0;
int max_width = 0;
std::vector<std::string> lines;
std::vector<int> widths;
luax_catchexcept(L, [&]() {
std::vector<std::string> lines = t->getWrap(str, wrap, &max_width);
numlines = lines.size();
});
luax_catchexcept(L, [&]() { t->getWrap(str, wrap, lines, &widths); });
for (int width : widths)
max_width = std::max(max_width, width);
lua_pushinteger(L, max_width);
lua_pushinteger(L, numlines);
lua_createtable(L, (int) lines.size(), 0);
for (int i = 0; i < (int) lines.size(); i++)
{
lua_pushstring(L, lines[i].c_str());
lua_rawseti(L, -2, i + 1);
}
return 2;
}
@@ -140,8 +153,7 @@ int w_Font_hasGlyphs(lua_State *L)
Font *t = luax_checkfont(L, 1);
bool hasglyph = false;
int count = lua_gettop(L) - 1;
count = count < 1 ? 1 : count;
int count = std::max(lua_gettop(L) - 1, 1);
luax_catchexcept(L, [&]() {
for (int i = 2; i < count + 2; i++)
@@ -160,6 +172,18 @@ int w_Font_hasGlyphs(lua_State *L)
return 1;
}
int w_Font_setFallbacks(lua_State *L)
{
Font *t = luax_checkfont(L, 1);
std::vector<Font *> fallbacks;
for (int i = 2; i <= lua_gettop(L); i++)
fallbacks.push_back(luax_checkfont(L, i));
luax_catchexcept(L, [&](){ t->setFallbacks(fallbacks); });
return 0;
}
static const luaL_Reg functions[] =
{
{ "getHeight", w_Font_getHeight },
@@ -173,12 +197,13 @@ static const luaL_Reg functions[] =
{ "getDescent", w_Font_getDescent },
{ "getBaseline", w_Font_getBaseline },
{ "hasGlyphs", w_Font_hasGlyphs },
{ "setFallbacks", w_Font_setFallbacks },
{ 0, 0 }
};
extern "C" int luaopen_font(lua_State *L)
{
return luax_register_type(L, "Font", functions);
return luax_register_type(L, GRAPHICS_FONT_ID, functions);
}
} // opengl