Skip to content

Commit

Permalink
Experimental getGlyphRect(idx) in preparation for chat hyperlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Nov 27, 2018
1 parent c512d3a commit 005753b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/BitmapText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,23 @@ ColorBitmapText::SetMaxLines(int iNumLines, int iDirection)
class LunaBitmapText : public Luna<BitmapText>
{
public:
static int getGlyphRect(T* p, lua_State* L)
{
int idx = (IArg(1) - 1) * 4; // lua idx start at 1 and 4 verts per glyph
if (idx < 0 || idx >= p->m_aVertices.size()) {
lua_pushnil(L);
return 1;
}
for (int i = 0; i < 4; i++) {
lua_newtable(L);
auto& v = p->m_aVertices[idx + i].p;
lua_pushnumber(L, v.x);
lua_rawseti(L, -2, 1);
lua_pushnumber(L, v.y);
lua_rawseti(L, -2, 2);
}
return 4;
}
static int wrapwidthpixels(T* p, lua_State* L)
{
p->SetWrapWidthPixels(IArg(1));
Expand Down Expand Up @@ -1541,6 +1558,7 @@ class LunaBitmapText : public Luna<BitmapText>

LunaBitmapText()
{
ADD_METHOD(getGlyphRect);
ADD_METHOD(wrapwidthpixels);
ADD_METHOD(maxwidth);
ADD_METHOD(maxheight);
Expand Down
4 changes: 2 additions & 2 deletions src/BitmapText.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class BitmapText : public Actor
// Commands
void PushSelf(lua_State* L) override;

vector<RageSpriteVertex> m_aVertices;

protected:
Font* m_pFont;
bool m_bUppercase;
Expand All @@ -163,8 +165,6 @@ class BitmapText : public Actor
float m_fDistortion;
int m_iVertSpacing;

vector<RageSpriteVertex> m_aVertices;

vector<FontPageTextures*> m_vpFontPageTextures;
map<size_t, Attribute> m_mAttributes;
bool m_bHasGlowAttribute;
Expand Down

0 comments on commit 005753b

Please sign in to comment.