From 758381eecd57fa287d2c1e44499b422deecd565d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 16 Nov 2003 21:44:42 +0000 Subject: [PATCH] metric lookup update better abstraction --- stepmania/src/CourseContentsList.cpp | 10 ++++-- stepmania/src/CourseContentsList.h | 2 +- stepmania/src/CourseEntryDisplay.cpp | 48 ++++++++++------------------ stepmania/src/CourseEntryDisplay.h | 3 +- 4 files changed, 27 insertions(+), 36 deletions(-) diff --git a/stepmania/src/CourseContentsList.cpp b/stepmania/src/CourseContentsList.cpp index edf139e226..a1b543bf8d 100644 --- a/stepmania/src/CourseContentsList.cpp +++ b/stepmania/src/CourseContentsList.cpp @@ -37,11 +37,15 @@ CourseContentsList::CourseContentsList() m_quad.SetUseZBuffer( true ); for( int i = 0; i < MAX_TOTAL_CONTENTS; ++i ) + { + m_CourseContentDisplays[i].SetName( "CourseEntryDisplay" ); + m_CourseContentDisplays[i].Load(); m_CourseContentDisplays[i].SetUseZBuffer( true ); + } /* These are all the same; grab the dimensions. */ - ContentsBarHeight = m_CourseContentDisplays[0].m_sprFrame.GetTexture()->GetSourceFrameHeight(); - ContentsBarWidth = m_CourseContentDisplays[0].m_sprFrame.GetTexture()->GetSourceFrameWidth(); + ContentsBarHeight = m_CourseContentDisplays[0].GetUnzoomedHeight(); + ContentsBarWidth = m_CourseContentDisplays[0].GetUnzoomedWidth(); } @@ -102,7 +106,7 @@ void CourseContentsList::DrawPrimitives() // write to z buffer so that top and bottom are clipped m_quad.SetZ( 1 ); - RectI rectBarSize(-ContentsBarWidth/2, -ContentsBarHeight/2, + RectF rectBarSize(-ContentsBarWidth/2, -ContentsBarHeight/2, ContentsBarWidth/2, ContentsBarHeight/2); m_quad.StretchTo( rectBarSize ); diff --git a/stepmania/src/CourseContentsList.h b/stepmania/src/CourseContentsList.h index 397c6d4bfd..70306d26a0 100644 --- a/stepmania/src/CourseContentsList.h +++ b/stepmania/src/CourseContentsList.h @@ -43,7 +43,7 @@ protected: int m_iNumContents; CourseEntryDisplay m_CourseContentDisplays[MAX_TOTAL_CONTENTS]; - int ContentsBarHeight, ContentsBarWidth; + float ContentsBarHeight, ContentsBarWidth; float m_fTimeUntilScroll; float m_fItemAtTopOfList; // between 0 and m_iNumContents diff --git a/stepmania/src/CourseEntryDisplay.cpp b/stepmania/src/CourseEntryDisplay.cpp index 18ce4ce613..3721b13c63 100644 --- a/stepmania/src/CourseEntryDisplay.cpp +++ b/stepmania/src/CourseEntryDisplay.cpp @@ -23,55 +23,41 @@ #include "Steps.h" #include "GameState.h" #include "StyleDef.h" +#include "ActorUtil.h" -#define TEXT_BANNER_X THEME->GetMetricF("CourseEntryDisplay","TextBannerX") -#define TEXT_BANNER_Y THEME->GetMetricF("CourseEntryDisplay","TextBannerY") -#define TEXT_BANNER_ZOOM THEME->GetMetricF("CourseEntryDisplay","TextBannerZoom") -#define NUMBER_X THEME->GetMetricF("CourseEntryDisplay","NumberX") -#define NUMBER_Y THEME->GetMetricF("CourseEntryDisplay","NumberY") -#define NUMBER_ZOOM THEME->GetMetricF("CourseEntryDisplay","NumberZoom") -#define FOOT_X THEME->GetMetricF("CourseEntryDisplay","FootX") -#define FOOT_Y THEME->GetMetricF("CourseEntryDisplay","FootY") -#define FOOT_ZOOM THEME->GetMetricF("CourseEntryDisplay","FootZoom") -#define DIFFICULTY_X THEME->GetMetricF("CourseEntryDisplay","DifficultyX") -#define DIFFICULTY_Y THEME->GetMetricF("CourseEntryDisplay","DifficultyY") -#define DIFFICULTY_ZOOM THEME->GetMetricF("CourseEntryDisplay","DifficultyZoom") -#define MODIFIERS_X THEME->GetMetricF("CourseEntryDisplay","ModifiersX") -#define MODIFIERS_Y THEME->GetMetricF("CourseEntryDisplay","ModifiersY") -#define MODIFIERS_ZOOM THEME->GetMetricF("CourseEntryDisplay","ModifiersZoom") -#define MODIFIERS_HORIZ_ALIGN THEME->GetMetricI("CourseEntryDisplay","ModifiersHorizAlign") - - -CourseEntryDisplay::CourseEntryDisplay() +void CourseEntryDisplay::Load() { + m_sprFrame.SetName( "Bar" ); m_sprFrame.Load( THEME->GetPathToG("CourseEntryDisplay bar") ); + SET_XY_AND_ON_COMMAND( &m_sprFrame ); this->AddChild( &m_sprFrame ); + this->m_size.x = (float) m_sprFrame.GetTexture()->GetSourceFrameWidth(); + this->m_size.y = (float) m_sprFrame.GetTexture()->GetSourceFrameHeight(); + + m_textNumber.SetName( "Number" ); m_textNumber.LoadFromFont( THEME->GetPathToF("CourseEntryDisplay number") ); - m_textNumber.SetXY( NUMBER_X, NUMBER_Y ); - m_textNumber.EnableShadow( false ); + SET_XY_AND_ON_COMMAND( &m_textNumber ); this->AddChild( &m_textNumber ); - m_TextBanner.SetXY( TEXT_BANNER_X, TEXT_BANNER_Y ); + m_TextBanner.SetName( "TextBanner" ); + SET_XY_AND_ON_COMMAND( &m_TextBanner ); this->AddChild( &m_TextBanner ); + m_textFoot.SetName( "Foot" ); m_textFoot.LoadFromTextureAndChars( THEME->GetPathToG("CourseEntryDisplay difficulty 2x1"),"10" ); - m_textFoot.SetXY( FOOT_X, FOOT_Y ); - m_textFoot.EnableShadow( false ); + SET_XY_AND_ON_COMMAND( &m_textFoot ); this->AddChild( &m_textFoot ); + m_textDifficultyNumber.SetName( "Difficulty" ); m_textDifficultyNumber.LoadFromFont( THEME->GetPathToF("Common normal") ); - m_textDifficultyNumber.SetXY( DIFFICULTY_X, DIFFICULTY_Y ); - m_textDifficultyNumber.SetZoom( DIFFICULTY_ZOOM ); - m_textDifficultyNumber.EnableShadow( false ); + SET_XY_AND_ON_COMMAND( &m_textDifficultyNumber ); this->AddChild( &m_textDifficultyNumber ); + m_textModifiers.SetName( "Modifiers" ); m_textModifiers.LoadFromFont( THEME->GetPathToF("Common normal") ); - m_textModifiers.SetXY( MODIFIERS_X, MODIFIERS_Y ); - m_textModifiers.SetZoom( MODIFIERS_ZOOM ); - m_textModifiers.SetHorizAlign( (Actor::HorizAlign)MODIFIERS_HORIZ_ALIGN ); - m_textModifiers.EnableShadow( false ); + SET_XY_AND_ON_COMMAND( &m_textModifiers ); this->AddChild( &m_textModifiers ); } diff --git a/stepmania/src/CourseEntryDisplay.h b/stepmania/src/CourseEntryDisplay.h index 615f0a526a..ab6a00ea2b 100644 --- a/stepmania/src/CourseEntryDisplay.h +++ b/stepmania/src/CourseEntryDisplay.h @@ -25,12 +25,13 @@ class Steps; class CourseEntryDisplay : public ActorFrame { public: - CourseEntryDisplay(); + void Load(); void LoadFromSongAndNotes( int iNum, Song* pSong, Steps* pNotes, CString sModifiers ); void LoadFromDifficulty( int iNum, Difficulty dc, CString sModifiers ); void LoadFromMeterRange( int iNum, int iLow, int iHigh, CString sModifiers ); +private: Sprite m_sprFrame; BitmapText m_textNumber; TextBanner m_TextBanner;