2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2001-12-11 11:25:37 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
2002-08-13 23:26:46 +00:00
|
|
|
Class: TextBanner
|
2001-12-11 11:25:37 +00:00
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
Desc: See header.
|
2001-12-11 11:25:37 +00:00
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
2002-08-13 23:26:46 +00:00
|
|
|
Chris Danford
|
2001-12-11 11:25:37 +00:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "TextBanner.h"
|
2002-08-13 23:26:46 +00:00
|
|
|
#include "RageUtil.h"
|
2003-02-16 04:28:17 +00:00
|
|
|
#include "song.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
#include "PrefsManager.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "ThemeManager.h"
|
2003-02-10 05:30:12 +00:00
|
|
|
#include "SongManager.h"
|
2003-06-05 22:18:42 +00:00
|
|
|
#include "RageTextureManager.h"
|
2003-02-10 05:30:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#define WIDTH THEME->GetMetricF("TextBanner","Width")
|
|
|
|
|
#define HEIGHT THEME->GetMetricF("TextBanner","Height")
|
|
|
|
|
#define HORIZ_ALIGN THEME->GetMetricI("TextBanner","HorizAlign")
|
|
|
|
|
#define ARTIST_PREPEND_STRING THEME->GetMetric( "TextBanner","ArtistPrependString")
|
|
|
|
|
#define TWO_LINES_TITLE_ZOOM THEME->GetMetricF("TextBanner","TwoLinesTitleZoom")
|
|
|
|
|
#define TWO_LINES_ARTIST_ZOOM THEME->GetMetricF("TextBanner","TwoLinesArtistZoom")
|
|
|
|
|
#define THREE_LINES_TITLE_ZOOM THEME->GetMetricF("TextBanner","ThreeLinesTitleZoom")
|
|
|
|
|
#define THREE_LINES_SUB_TITLE_ZOOM THEME->GetMetricF("TextBanner","ThreeLinesSubTitleZoom")
|
|
|
|
|
#define THREE_LINES_ARTIST_ZOOM THEME->GetMetricF("TextBanner","ThreeLinesArtistZoom")
|
|
|
|
|
#define TWO_LINES_TITLE_Y THEME->GetMetricF("TextBanner","TwoLinesTitleY")
|
|
|
|
|
#define TWO_LINES_ARTIST_Y THEME->GetMetricF("TextBanner","TwoLinesArtistY")
|
|
|
|
|
#define THREE_LINES_TITLE_Y THEME->GetMetricF("TextBanner","ThreeLinesTitleY")
|
|
|
|
|
#define THREE_LINES_SUB_TITLE_Y THEME->GetMetricF("TextBanner","ThreeLinesSubTitleY")
|
|
|
|
|
#define THREE_LINES_ARTIST_Y THEME->GetMetricF("TextBanner","ThreeLinesArtistY")
|
|
|
|
|
|
|
|
|
|
// metrics cache
|
|
|
|
|
float g_fWidth;
|
|
|
|
|
float g_fHeight;
|
|
|
|
|
int g_iHorizAlign;
|
|
|
|
|
CString g_sArtistPrependString;
|
|
|
|
|
float g_fTwoLinesTitleZoom;
|
|
|
|
|
float g_fTwoLinesArtistZoom;
|
|
|
|
|
float g_fThreeLinesTitleZoom;
|
|
|
|
|
float g_fThreeLinesSubTitleZoom;
|
|
|
|
|
float g_fThreeLinesArtistZoom;
|
|
|
|
|
float g_fTwoLinesTitleY;
|
|
|
|
|
float g_fTwoLinesArtistY;
|
|
|
|
|
float g_fThreeLinesTitleY;
|
|
|
|
|
float g_fThreeLinesSubTitleY;
|
|
|
|
|
float g_fThreeLinesArtistY;
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2001-12-11 11:25:37 +00:00
|
|
|
|
|
|
|
|
TextBanner::TextBanner()
|
|
|
|
|
{
|
2003-02-10 05:30:12 +00:00
|
|
|
g_fWidth = WIDTH;
|
|
|
|
|
g_fHeight = HEIGHT;
|
|
|
|
|
g_iHorizAlign = HORIZ_ALIGN;
|
|
|
|
|
g_sArtistPrependString = ARTIST_PREPEND_STRING;
|
|
|
|
|
g_fTwoLinesTitleZoom = TWO_LINES_TITLE_ZOOM;
|
|
|
|
|
g_fTwoLinesArtistZoom = TWO_LINES_ARTIST_ZOOM;
|
|
|
|
|
g_fThreeLinesTitleZoom = THREE_LINES_TITLE_ZOOM;
|
|
|
|
|
g_fThreeLinesSubTitleZoom = THREE_LINES_SUB_TITLE_ZOOM;
|
|
|
|
|
g_fThreeLinesArtistZoom = THREE_LINES_ARTIST_ZOOM;
|
|
|
|
|
g_fTwoLinesTitleY = TWO_LINES_TITLE_Y;
|
|
|
|
|
g_fTwoLinesArtistY = TWO_LINES_ARTIST_Y;
|
|
|
|
|
g_fThreeLinesTitleY = THREE_LINES_TITLE_Y;
|
|
|
|
|
g_fThreeLinesSubTitleY = THREE_LINES_SUB_TITLE_Y;
|
|
|
|
|
g_fThreeLinesArtistY = THREE_LINES_ARTIST_Y;
|
|
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
m_textTitle.LoadFromFont( THEME->GetPathToF("TextBanner") );
|
|
|
|
|
m_textSubTitle.LoadFromFont( THEME->GetPathToF("TextBanner") );
|
|
|
|
|
m_textArtist.LoadFromFont( THEME->GetPathToF("TextBanner") );
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2003-02-10 05:30:12 +00:00
|
|
|
m_textTitle.SetX( -g_fWidth/2 );
|
|
|
|
|
m_textSubTitle.SetX( -g_fWidth/2 );
|
|
|
|
|
m_textArtist.SetX( -g_fWidth/2 );
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2003-02-10 05:30:12 +00:00
|
|
|
m_textTitle.SetHorizAlign( (Actor::HorizAlign)g_iHorizAlign );
|
|
|
|
|
m_textSubTitle.SetHorizAlign( (Actor::HorizAlign)g_iHorizAlign );
|
|
|
|
|
m_textArtist.SetHorizAlign( (Actor::HorizAlign)g_iHorizAlign );
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2003-03-02 01:43:33 +00:00
|
|
|
m_textTitle.EnableShadow( false );
|
|
|
|
|
m_textSubTitle.EnableShadow( false );
|
|
|
|
|
m_textArtist.EnableShadow( false );
|
2002-05-01 19:14:55 +00:00
|
|
|
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_textTitle );
|
|
|
|
|
this->AddChild( &m_textSubTitle );
|
|
|
|
|
this->AddChild( &m_textArtist );
|
2001-12-11 11:25:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-16 10:12:03 +00:00
|
|
|
void TextBanner::LoadFromString(
|
|
|
|
|
CString sDisplayTitle, CString sTranslitTitle,
|
|
|
|
|
CString sDisplaySubTitle, CString sTranslitSubTitle,
|
|
|
|
|
CString sDisplayArtist, CString sTranslitArtist )
|
2001-12-11 11:25:37 +00:00
|
|
|
{
|
2003-05-20 04:14:53 +00:00
|
|
|
bool bTwoLines = sDisplaySubTitle.size() == 0;
|
2001-12-11 11:25:37 +00:00
|
|
|
|
2003-05-20 04:14:53 +00:00
|
|
|
const float fTitleZoom = bTwoLines ? g_fTwoLinesTitleZoom : g_fThreeLinesTitleZoom;
|
|
|
|
|
const float fSubTitleZoom = bTwoLines ? 0 : g_fThreeLinesSubTitleZoom;
|
|
|
|
|
const float fArtistZoom = bTwoLines ? g_fTwoLinesArtistZoom : g_fThreeLinesArtistZoom;
|
2001-12-11 11:25:37 +00:00
|
|
|
|
2003-05-20 04:14:53 +00:00
|
|
|
m_textTitle.SetZoom( fTitleZoom );
|
|
|
|
|
m_textSubTitle.SetZoom( fSubTitleZoom );
|
|
|
|
|
m_textArtist.SetZoom( fArtistZoom );
|
|
|
|
|
|
|
|
|
|
m_textTitle.SetTextMaxWidth( g_fWidth, sDisplayTitle, sTranslitTitle );
|
|
|
|
|
m_textSubTitle.SetTextMaxWidth( g_fWidth, sDisplaySubTitle, sTranslitSubTitle );
|
|
|
|
|
m_textArtist.SetTextMaxWidth( g_fWidth, sDisplayArtist, sTranslitArtist );
|
|
|
|
|
|
|
|
|
|
const float fTitleY = bTwoLines ? g_fTwoLinesTitleY : g_fThreeLinesTitleY;
|
|
|
|
|
const float fSubTitleY = bTwoLines ? 0 : g_fThreeLinesSubTitleY;
|
|
|
|
|
const float fArtistY = bTwoLines ? g_fTwoLinesArtistY : g_fThreeLinesArtistY;
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2003-02-10 05:30:12 +00:00
|
|
|
m_textTitle.SetY( fTitleY );
|
|
|
|
|
m_textSubTitle.SetY( fSubTitleY );
|
|
|
|
|
m_textArtist.SetY( fArtistY );
|
2003-02-16 10:12:03 +00:00
|
|
|
}
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2003-02-16 10:12:03 +00:00
|
|
|
void TextBanner::LoadFromSong( const Song* pSong )
|
|
|
|
|
{
|
|
|
|
|
CString sDisplayTitle = pSong ? pSong->GetDisplayMainTitle() : "";
|
|
|
|
|
CString sTranslitTitle = pSong ? pSong->GetTranslitMainTitle() : "";
|
|
|
|
|
CString sDisplaySubTitle = pSong ? pSong->GetDisplaySubTitle() : "";
|
|
|
|
|
CString sTranslitSubTitle = pSong ? pSong->GetTranslitSubTitle() : "";
|
|
|
|
|
CString sDisplayArtist = pSong ? g_sArtistPrependString + pSong->GetDisplayArtist() : "";
|
|
|
|
|
CString sTranslitArtist = pSong ? g_sArtistPrependString + pSong->GetTranslitArtist() : "";
|
|
|
|
|
|
|
|
|
|
LoadFromString(
|
|
|
|
|
sDisplayTitle, sTranslitTitle,
|
|
|
|
|
sDisplaySubTitle, sTranslitSubTitle,
|
|
|
|
|
sDisplayArtist, sTranslitArtist );
|
2001-12-11 11:25:37 +00:00
|
|
|
}
|
2003-02-16 10:12:03 +00:00
|
|
|
|