Added mult_attrs_with_diffuse to BitmapText. Added some convenience macros to LuaBinding for generic get/set functions. Updated changelog.

This commit is contained in:
Kyzentun Keeslala
2015-10-18 14:09:08 -06:00
parent 3d6ef83a88
commit 9f40c6d044
6 changed files with 106 additions and 14 deletions
+19
View File
@@ -4,6 +4,25 @@ The StepMania 5 Changelog covers all post-sm-ssc changes. For a list of changes
from StepMania 4 alpha 5 to sm-ssc v1.2.5, see Changelog_sm-ssc.txt.
________________________________________________________________________________
2015/10/18
----------
* [BitmapText] Added set_mult_attrs_with_diffuse lua function. [kyzentun]
2015/10/17
----------
* [Course] Fixed loading of courses that use WORST entries. [wolfman2000]
* [SextetStream] SextetStream stuff is now in all platforms. [wolfman2000]
2015/10/15
----------
* [BMS] Changed bms loading so that iidx bms files aren't loaded as kb7.
[zardoru]
2015/10/12
----------
* [ActorMultiVertex] Fixed bug that *sometimes* caused diffuse to be applied
to verts wrong. [kyzentun]
2015/10/11
----------
* [Song] Changed song loading to allow a song to have a blank MusicFile field
+2
View File
@@ -628,11 +628,13 @@
<Function name='PixelFont'/>
<Function name='Stroke'/>
<Function name='distort'/>
<Function name='get_mult_attrs_with_diffuse'/>
<Function name='jitter'/>
<Function name='max_dimension_use_zoom'/>
<Function name='maxheight'/>
<Function name='maxwidth'/>
<Function name='rainbowscroll'/>
<Function name='set_mult_attrs_with_diffuse'/>
<Function name='settext'/>
<Function name='settextf'/>
<Function name='strokecolor'/>
+6
View File
@@ -1970,6 +1970,12 @@ save yourself some time, copy this for undocumented things:
<Function name='undistort' return='void' arguments=''>
Turns off distortion.
</Function>
<Function name='get_mult_attrs_with_diffuse' return='bool' arguments=''>
Returns whether the diffuse colors in the attributes are multiplied by the general diffuse colors of the BitmapText.
</Function>
<Function name='set_mult_attrs_with_diffuse' return='' arguments='bool mult'>
If mult_attrs_with_diffuse is set to true, then the diffuse colors in the attributes are multiplied by the general diffuse colors of the BitmapText.
</Function>
<Function name='jitter' return='void' arguments='bool bJitter'>
If <code>bJitter</code> is <code>true</code>, move each character of the string around by a small random amount.
</Function>
+28 -14
View File
@@ -49,6 +49,7 @@ BitmapText::BitmapText()
m_bJitter = false;
m_fDistortion= 0.0f;
m_bUsingDistortion= false;
m_mult_attrs_with_diffuse= false;
m_iWrapWidthPixels = -1;
m_fMaxWidth = 0;
@@ -86,6 +87,7 @@ BitmapText & BitmapText::operator=(const BitmapText &cpy)
CPY( m_bJitter );
CPY( m_fDistortion );
CPY( m_bUsingDistortion );
CPY( m_mult_attrs_with_diffuse );
CPY( m_iVertSpacing );
CPY( m_MaxDimensionUsesZoom );
CPY( m_aVertices );
@@ -573,6 +575,17 @@ void BitmapText::UnSetDistortion()
BuildChars();
}
void BitmapText::set_mult_attrs_with_diffuse(bool m)
{
m_mult_attrs_with_diffuse= m;
BuildChars();
}
bool BitmapText::get_mult_attrs_with_diffuse()
{
return m_mult_attrs_with_diffuse;
}
void BitmapText::UpdateBaseZoom()
{
// don't divide by 0
@@ -724,22 +737,21 @@ void BitmapText::DrawPrimitives()
else
iEnd = i + attr.length*4;
iEnd = min( iEnd, m_aVertices.size() );
vector<RageColor> temp_attr_diffuse(NUM_DIFFUSE_COLORS, m_internalDiffuse);
for(size_t c= 0; c < NUM_DIFFUSE_COLORS; ++c)
{
temp_attr_diffuse[c]*= attr.diffuse[c];
if(m_mult_attrs_with_diffuse)
{
temp_attr_diffuse[c]*= m_pTempState->diffuse[c];
}
}
for( ; i < iEnd; i += 4 )
{
if( m_internalDiffuse != RageColor(1, 1, 1, 1) )
{
m_aVertices[i+0].c = attr.diffuse[0] * m_internalDiffuse;
m_aVertices[i+1].c = attr.diffuse[2] * m_internalDiffuse;
m_aVertices[i+2].c = attr.diffuse[3] * m_internalDiffuse;
m_aVertices[i+3].c = attr.diffuse[1] * m_internalDiffuse;
}
else
{
m_aVertices[i+0].c = attr.diffuse[0]; // top left
m_aVertices[i+1].c = attr.diffuse[2]; // bottom left
m_aVertices[i+2].c = attr.diffuse[3]; // bottom right
m_aVertices[i+3].c = attr.diffuse[1]; // top right
}
m_aVertices[i+0].c = temp_attr_diffuse[0]; // top left
m_aVertices[i+1].c = temp_attr_diffuse[2]; // bottom left
m_aVertices[i+2].c = temp_attr_diffuse[3]; // bottom right
m_aVertices[i+3].c = temp_attr_diffuse[1]; // top right
}
}
}
@@ -965,6 +977,7 @@ public:
static int jitter( T* p, lua_State *L ) { p->SetJitter( BArg(1) ); COMMON_RETURN_SELF; }
static int distort( T* p, lua_State *L) { p->SetDistortion( FArg(1) ); COMMON_RETURN_SELF; }
static int undistort( T* p, lua_State *L) { p->UnSetDistortion(); COMMON_RETURN_SELF; }
GETTER_SETTER_BOOL_METHOD(mult_attrs_with_diffuse);
static int GetText( T* p, lua_State *L ) { lua_pushstring( L, p->GetText() ); return 1; }
static int AddAttribute( T* p, lua_State *L )
{
@@ -993,6 +1006,7 @@ public:
ADD_METHOD( jitter );
ADD_METHOD( distort );
ADD_METHOD( undistort );
ADD_GET_SET_METHODS(mult_attrs_with_diffuse);
ADD_METHOD( GetText );
ADD_METHOD( AddAttribute );
ADD_METHOD( ClearAttributes );
+3
View File
@@ -73,6 +73,8 @@ public:
void SetJitter( bool b ) { m_bJitter = b; }
void SetDistortion( float f );
void UnSetDistortion();
void set_mult_attrs_with_diffuse(bool m);
bool get_mult_attrs_with_diffuse();
void SetHorizAlign( float f );
@@ -120,6 +122,7 @@ protected:
bool m_bRainbowScroll;
bool m_bJitter;
bool m_bUsingDistortion;
bool m_mult_attrs_with_diffuse;
float m_fDistortion;
int m_iVertSpacing;
+48
View File
@@ -163,6 +163,54 @@ public:
#define COMMON_RETURN_SELF p->PushSelf(L); return 1;
#define GET_SET_BOOL_METHOD(method_name, bool_name) \
static int get_##method_name(T* p, lua_State* L) \
{ \
lua_pushboolean(L, p->bool_name); \
return 1; \
} \
static int set_##method_name(T* p, lua_State* L) \
{ \
p->bool_name= lua_toboolean(L, 1); \
COMMON_RETURN_SELF; \
}
#define GETTER_SETTER_BOOL_METHOD(bool_name) \
static int get_##bool_name(T* p, lua_State* L) \
{ \
lua_pushboolean(L, p->get_##bool_name()); \
return 1; \
} \
static int set_##bool_name(T* p, lua_State* L) \
{ \
p->set_##bool_name(lua_toboolean(L, 1)); \
COMMON_RETURN_SELF; \
}
#define GET_SET_FLOAT_METHOD(method_name, float_name) \
static int get_##method_name(T* p, lua_State* L) \
{ \
lua_pushnumber(L, p->float_name); \
return 1; \
} \
static int set_##method_name(T* p, lua_State* L) \
{ \
p->float_name= FArg(1); \
COMMON_RETURN_SELF; \
}
#define GETTER_SETTER_FLOAT_METHOD(float_name) \
static int get_##float_name(T* p, lua_State* L) \
{ \
lua_pushnumber(L, p->get_##float_name()); \
return 1; \
} \
static int set_##float_name(T* p, lua_State* L) \
{ \
p->set_##float_name(FArg(1)); \
COMMON_RETURN_SELF; \
}
#define ADD_METHOD( method_name ) \
AddMethod( #method_name, method_name )
#define ADD_GET_SET_METHODS(method_name) \