Have OptionRows subscribe to a Message in order to refresh

This commit is contained in:
Chris Danford
2005-02-24 15:40:05 +00:00
parent 017dd5d048
commit 182db1222f
10 changed files with 148 additions and 168 deletions
+44
View File
@@ -3,6 +3,8 @@
#include "RageUtil.h"
#include "RageLog.h"
#include "Font.h"
#include "Foreach.h"
#include "OptionRowHandler.h"
static const CString SelectTypeNames[NUM_SELECT_TYPES] = {
"SelectOne",
@@ -52,6 +54,12 @@ void OptionRow::Clear()
m_Underline[p].clear();
}
if( m_pHand )
{
FOREACH_CONST( CString, m_pHand->m_vsReloadRowMessages, m )
MESSAGEMAN->Unsubscribe( this, *m );
}
m_pHand = NULL;
}
@@ -61,6 +69,12 @@ void OptionRow::LoadNormal( const OptionRowDefinition &def, OptionRowHandler *pH
m_RowType = OptionRow::ROW_NORMAL;
m_pHand = pHand;
if( m_pHand )
{
FOREACH_CONST( CString, m_pHand->m_vsReloadRowMessages, m )
MESSAGEMAN->Subscribe( this, *m );
}
if( !def.choices.size() )
RageException::Throw( "Screen %s menu entry \"%s\" has no choices",
m_sName.c_str(), def.name.c_str() );
@@ -565,6 +579,36 @@ void OptionRow::SetExitText( CString sExitText )
bt->SetText( sExitText );
}
void OptionRow::Reload()
{
if( m_pHand == NULL )
return;
OptionRowDefinition def;
m_pHand->Reload( def );
switch( GetRowType() )
{
case OptionRow::ROW_NORMAL:
{
ASSERT( m_RowDef.layoutType == LAYOUT_SHOW_ONE_IN_ROW );
m_RowDef = def;
UpdateText( true );
}
break;
case OptionRow::ROW_EXIT:
// nothing to do
break;
default:
ASSERT(0);
}
}
void OptionRow::HandleMessage( const CString& sMessage )
{
Reload();
}
/*
* (c) 2001-2004 Chris Danford