From 9f40c6d0441908b51817737b9e7252014d1c34b8 Mon Sep 17 00:00:00 2001 From: Kyzentun Keeslala Date: Sun, 18 Oct 2015 14:09:08 -0600 Subject: [PATCH] Added mult_attrs_with_diffuse to BitmapText. Added some convenience macros to LuaBinding for generic get/set functions. Updated changelog. --- Docs/Changelog_sm5.txt | 19 +++++++++++++ Docs/Luadoc/Lua.xml | 2 ++ Docs/Luadoc/LuaDocumentation.xml | 6 ++++ src/BitmapText.cpp | 42 ++++++++++++++++++---------- src/BitmapText.h | 3 ++ src/LuaBinding.h | 48 ++++++++++++++++++++++++++++++++ 6 files changed, 106 insertions(+), 14 deletions(-) diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index fdbd497cdc..5fe50f27b9 100644 --- a/Docs/Changelog_sm5.txt +++ b/Docs/Changelog_sm5.txt @@ -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 diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml index 82734011d7..9f3e1e415e 100644 --- a/Docs/Luadoc/Lua.xml +++ b/Docs/Luadoc/Lua.xml @@ -628,11 +628,13 @@ + + diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index 8e945e6852..f4c435805f 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -1970,6 +1970,12 @@ save yourself some time, copy this for undocumented things: Turns off distortion. + + Returns whether the diffuse colors in the attributes are multiplied by the general diffuse colors of the BitmapText. + + + 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. + If bJitter is true, move each character of the string around by a small random amount. diff --git a/src/BitmapText.cpp b/src/BitmapText.cpp index 1c6e2b9687..1cf3a8419b 100644 --- a/src/BitmapText.cpp +++ b/src/BitmapText.cpp @@ -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 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 ); diff --git a/src/BitmapText.h b/src/BitmapText.h index b64f98eef5..802f4594fe 100644 --- a/src/BitmapText.h +++ b/src/BitmapText.h @@ -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; diff --git a/src/LuaBinding.h b/src/LuaBinding.h index 985ece38d4..d5b170df57 100644 --- a/src/LuaBinding.h +++ b/src/LuaBinding.h @@ -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) \