From 1d186c481d3b0b38c7e4d55802ecbebffe9c46c5 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 15 Jan 2006 07:12:05 +0000 Subject: [PATCH] const fix --- stepmania/src/Actor.h | 17 +++++++++-------- stepmania/src/OptionRow.cpp | 6 +++--- stepmania/src/OptionRow.h | 6 +++--- stepmania/src/ScreenOptionsMaster.cpp | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index 3a854203c4..a15c1b867b 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -104,9 +104,9 @@ public: float GetX() const { return m_current.pos.x; }; float GetY() const { return m_current.pos.y; }; float GetZ() const { return m_current.pos.z; }; - float GetDestX() { return DestTweenState().pos.x; }; - float GetDestY() { return DestTweenState().pos.y; }; - float GetDestZ() { return DestTweenState().pos.z; }; + float GetDestX() const { return DestTweenState().pos.x; }; + float GetDestY() const { return DestTweenState().pos.y; }; + float GetDestZ() const { return DestTweenState().pos.z; }; void SetX( float x ) { DestTweenState().pos.x = x; }; void SetY( float y ) { DestTweenState().pos.y = y; }; void SetZ( float z ) { DestTweenState().pos.z = z; }; @@ -116,10 +116,10 @@ public: void AddZ( float z ) { SetZ( GetDestZ()+z ); } // height and width vary depending on zoom - float GetUnzoomedWidth() { return m_size.x; } - float GetUnzoomedHeight() { return m_size.y; } - float GetZoomedWidth() { return m_size.x * m_baseScale.x * DestTweenState().scale.x; } - float GetZoomedHeight() { return m_size.y * m_baseScale.y * DestTweenState().scale.y; } + float GetUnzoomedWidth() const { return m_size.x; } + float GetUnzoomedHeight() const { return m_size.y; } + float GetZoomedWidth() const { return m_size.x * m_baseScale.x * DestTweenState().scale.x; } + float GetZoomedHeight() const { return m_size.y * m_baseScale.y * DestTweenState().scale.y; } void SetWidth( float width ) { m_size.x = width; } void SetHeight( float height ) { m_size.y = height; } @@ -208,7 +208,7 @@ public: virtual void HurryTweening( float factor ); // Let ActorFrame and BGAnimation override virtual float GetTweenTimeLeft() const; // Amount of time until all tweens have stopped - TweenState& DestTweenState() // where Actor will end when its tween finish + TweenState& DestTweenState() // where Actor will end when its tween finish { if( m_pTempState != NULL ) // effect_lua running return *m_pTempState; @@ -217,6 +217,7 @@ public: else return m_Tweens.back()->state; } + const TweenState& DestTweenState() const { return const_cast(this)->DestTweenState(); } enum StretchType { fit_inside, cover }; diff --git a/stepmania/src/OptionRow.cpp b/stepmania/src/OptionRow.cpp index ba41353ba6..3161d4d779 100644 --- a/stepmania/src/OptionRow.cpp +++ b/stepmania/src/OptionRow.cpp @@ -740,7 +740,7 @@ void OptionRow::SetOptionIcon( PlayerNumber pn, const CString &sText, GameComman LUA->UnsetGlobal( "ThisGameCommand" ); } -BitmapText &OptionRow::GetTextItemForRow( PlayerNumber pn, int iChoiceOnRow ) +const BitmapText &OptionRow::GetTextItemForRow( PlayerNumber pn, int iChoiceOnRow ) const { bool bOneChoice = m_RowDef.m_bOneChoiceForAllPlayers; int index = -1; @@ -763,9 +763,9 @@ BitmapText &OptionRow::GetTextItemForRow( PlayerNumber pn, int iChoiceOnRow ) return *m_textItems[index]; } -void OptionRow::GetWidthXY( PlayerNumber pn, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut ) +void OptionRow::GetWidthXY( PlayerNumber pn, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut ) const { - BitmapText &text = GetTextItemForRow( pn, iChoiceOnRow ); + const BitmapText &text = GetTextItemForRow( pn, iChoiceOnRow ); iWidthOut = int(roundf( text.GetZoomedWidth() )); iXOut = int(roundf( text.GetDestX() )); diff --git a/stepmania/src/OptionRow.h b/stepmania/src/OptionRow.h index c0da5f07c1..a173b1133e 100644 --- a/stepmania/src/OptionRow.h +++ b/stepmania/src/OptionRow.h @@ -188,12 +188,12 @@ public: RowType GetRowType() const { return m_RowType; } OptionRowHandler *GetHandler() { return m_pHand; } - BitmapText &GetTextItemForRow( PlayerNumber pn, int iChoiceOnRow ); - void GetWidthXY( PlayerNumber pn, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut ); + const BitmapText &GetTextItemForRow( PlayerNumber pn, int iChoiceOnRow ) const; + void GetWidthXY( PlayerNumber pn, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut ) const; // ScreenOptions calls positions m_FrameDestination, then m_Frame tween to that same TweenState. void SetRowHidden( bool bRowHidden ) { m_bHidden = bRowHidden; } - bool GetRowHidden() { return m_bHidden; } + bool GetRowHidden() const { return m_bHidden; } unsigned GetTextItemsSize() const { return m_textItems.size(); } bool GetFirstItemGoesDown() const { return m_bFirstItemGoesDown; } diff --git a/stepmania/src/ScreenOptionsMaster.cpp b/stepmania/src/ScreenOptionsMaster.cpp index d395edccc5..1a0839fa56 100644 --- a/stepmania/src/ScreenOptionsMaster.cpp +++ b/stepmania/src/ScreenOptionsMaster.cpp @@ -134,7 +134,7 @@ void ScreenOptionsMaster::BeginFadingOut() int iCurRow = this->GetCurrentRow(); ASSERT( iCurRow >= 0 && iCurRow < (int)m_pRows.size() ); - OptionRow &row = *m_pRows[iCurRow]; + const OptionRow &row = *m_pRows[iCurRow]; { int iChoice = row.GetChoiceInRowWithFocus( GAMESTATE->m_MasterPlayerNumber ); @@ -143,7 +143,7 @@ void ScreenOptionsMaster::BeginFadingOut() // not the "goes down" item if( iChoice != -1 && iCurRow < (int) m_OptionRowHandlers.size() ) { - OptionRowHandler *pHand = m_OptionRowHandlers[iCurRow]; + const OptionRowHandler *pHand = m_OptionRowHandlers[iCurRow]; if( pHand != NULL ) m_bExportWillSetANewScreen = pHand->HasScreen( iChoice ); }