add XML loading

This commit is contained in:
Chris Danford
2005-12-05 19:09:22 +00:00
parent 7c5f8ceace
commit 8a68930a2a
2 changed files with 35 additions and 13 deletions
+31 -12
View File
@@ -14,9 +14,10 @@
#include "Foreach.h"
#include "PercentageDisplay.h"
#include "LuaManager.h"
#include "XmlFile.h"
#define SHIFT_X(p) THEME->GetMetricF(sType, ssprintf("ShiftP%iX", p+1))
#define SHIFT_Y(p) THEME->GetMetricF(sType, ssprintf("ShiftP%iY", p+1))
#define SHIFT_X(p) THEME->GetMetricF(sMetricsGroup, ssprintf("ShiftP%iX", p+1))
#define SHIFT_Y(p) THEME->GetMetricF(sMetricsGroup, ssprintf("ShiftP%iY", p+1))
enum { NEED_NOTES=1, NEED_COURSE=2, NEED_PROFILE=4 };
struct Content_t
@@ -55,17 +56,17 @@ PaneDisplay::PaneDisplay()
m_CurPane = PANE_INVALID;
}
void PaneDisplay::Load( const CString &sType, PlayerNumber pn )
void PaneDisplay::Load( const CString &sMetricsGroup, PlayerNumber pn )
{
m_PlayerNumber = pn;
m_sprPaneUnder.Load( THEME->GetPathG(sType,ssprintf("under p%i",pn+1)) );
m_sprPaneUnder.Load( THEME->GetPathG(sMetricsGroup,ssprintf("under p%i",pn+1)) );
m_sprPaneUnder->SetName( "Under" );
ActorUtil::OnCommand( m_sprPaneUnder, sType );
ActorUtil::OnCommand( m_sprPaneUnder, sMetricsGroup );
this->AddChild( m_sprPaneUnder );
EMPTY_MACHINE_HIGH_SCORE_NAME.Load( sType, "EmptyMachineHighScoreName" );
NOT_AVAILABLE.Load( sType, "NotAvailable" );
EMPTY_MACHINE_HIGH_SCORE_NAME.Load( sMetricsGroup, "EmptyMachineHighScoreName" );
NOT_AVAILABLE.Load( sMetricsGroup, "NotAvailable" );
for( int p = 0; p < NUM_PANE_CONTENTS; ++p )
@@ -73,17 +74,17 @@ void PaneDisplay::Load( const CString &sType, PlayerNumber pn )
if( g_Contents[p].type == NUM_PANES )
continue; /* skip, disabled */
m_textContents[p].LoadFromFont( THEME->GetPathF(sType,"text") );
m_textContents[p].LoadFromFont( THEME->GetPathF(sMetricsGroup,"text") );
m_textContents[p].SetName( ssprintf("%sText", g_Contents[p].name) );
ActorUtil::SetXYAndOnCommand( m_textContents[p], sType, this );
ActorUtil::SetXYAndOnCommand( m_textContents[p], sMetricsGroup, this );
m_ContentsFrame.AddChild( &m_textContents[p] );
m_Labels[p].Load( THEME->GetPathG(sType,CString(g_Contents[p].name)+" label") );
m_Labels[p].Load( THEME->GetPathG(sMetricsGroup,CString(g_Contents[p].name)+" label") );
m_Labels[p]->SetName( ssprintf("%sLabel", g_Contents[p].name) );
ActorUtil::SetXYAndOnCommand( m_Labels[p], sType, this );
ActorUtil::SetXYAndOnCommand( m_Labels[p], sMetricsGroup, this );
m_ContentsFrame.AddChild( m_Labels[p] );
ActorUtil::LoadAllCommandsFromName( m_textContents[p], sType, g_Contents[p].name );
ActorUtil::LoadAllCommandsFromName( m_textContents[p], sMetricsGroup, g_Contents[p].name );
}
m_ContentsFrame.SetXY( SHIFT_X(m_PlayerNumber), SHIFT_Y(m_PlayerNumber) );
@@ -100,6 +101,24 @@ void PaneDisplay::Load( const CString &sType, PlayerNumber pn )
m_CurPane = PANE_INVALID;
}
void PaneDisplay::LoadFromNode( const CString &sDir, const XNode *pNode )
{
ActorFrame::LoadFromNode( sDir, pNode );
bool b;
CString sMetricsGroup;
b = pNode->GetAttrValue( "MetricsGroup", sMetricsGroup );
ASSERT( b );
CString sPlayerNumber;
b = pNode->GetAttrValue( "PlayerNumber", sPlayerNumber );
ASSERT( b );
PlayerNumber pn = (PlayerNumber) LuaHelpers::RunExpressionI(sPlayerNumber);
Load( sMetricsGroup, pn );
}
void PaneDisplay::SetContent( PaneContents c )
{
CString str = "?"; // fill this in
+4 -1
View File
@@ -10,6 +10,7 @@
#include "AutoActor.h"
#include "GameConstantsAndTypes.h"
#include "ThemeMetric.h"
struct XNode;
enum PaneTypes
{
@@ -51,9 +52,11 @@ public:
PaneDisplay();
virtual Actor *Copy() const;
void Load( const CString &sClass, PlayerNumber pn );
void Load( const CString &sMetricsGroup, PlayerNumber pn );
void SetFromGameState( SortOrder so );
void LoadFromNode( const CString &sDir, const XNode *pNode );
// Lua
void PushSelf( lua_State *L );