Reworked m_roomInfo's datatype into its own class RoomInfoDisplay. I will add more functionality tonight.

This commit is contained in:
Josh Allen
2006-01-20 20:34:36 +00:00
parent 3bf20452b9
commit 642c5270dc
2 changed files with 78 additions and 46 deletions
+48 -30
View File
@@ -23,16 +23,10 @@ void RoomWheel::Load( CString sType )
for( int i=0; i<NUM_WHEEL_ITEMS; i++ ) for( int i=0; i<NUM_WHEEL_ITEMS; i++ )
m_WheelBaseItems.push_back( new RoomWheelItem ); m_WheelBaseItems.push_back( new RoomWheelItem );
m_roomInfo.SetName("InfoBox"); m_roomInfo.Load("RoomInfoDisplay");
m_roomInfo.SetWidth( THEME->GetMetricF(m_sName,"InfoBoxWidth") );
m_roomInfo.SetHeight( THEME->GetMetricF(m_sName,"InfoBoxHeight") );
SET_XY( m_roomInfo );
m_roomInfo.SetHidden( true );
OFF_COMMAND( m_roomInfo );
this->AddChild(&m_roomInfo); this->AddChild(&m_roomInfo);
m_WheelState = STATE_SELECTING; m_WheelState = STATE_SELECTING;
m_RoomInfoState = LOCKED;
AddPerminateItem( new RoomWheelData(TYPE_GENERIC, "Create Room", "Create a new game room", THEME->GetMetricC( m_sName, "CreateRoomColor")) ); AddPerminateItem( new RoomWheelData(TYPE_GENERIC, "Create Room", "Create a new game room", THEME->GetMetricC( m_sName, "CreateRoomColor")) );
@@ -91,12 +85,12 @@ void RoomWheel::AddPerminateItem(RoomWheelData* itemdata)
static LocalizedString ENTER_ROOM_NAME( "RoomWheel", "Enter room name" ); static LocalizedString ENTER_ROOM_NAME( "RoomWheel", "Enter room name" );
bool RoomWheel::Select() bool RoomWheel::Select()
{ {
RetractInfoBox(); m_roomInfo.RetractInfoBox();
if( m_iSelection > 0 ) if( m_iSelection > 0 )
return WheelBase::Select(); return WheelBase::Select();
else if( m_iSelection == 0 ) else if( m_iSelection == 0 )
{ {
// Since this is not actually an option outside of this wheel NULL is a good idea. // Since this is not actually an option outside of this wheel, NULL is a good idea.
m_LastSelection = NULL; m_LastSelection = NULL;
ScreenTextEntry::TextEntry( SM_BackFromRoomName, ENTER_ROOM_NAME, "", 255 ); ScreenTextEntry::TextEntry( SM_BackFromRoomName, ENTER_ROOM_NAME, "", 255 );
} }
@@ -115,25 +109,14 @@ void RoomWheelItem::LoadFromWheelItemBaseData( WheelItemBaseData* pWID )
void RoomWheel::Update( float fDeltaTime ) void RoomWheel::Update( float fDeltaTime )
{ {
WheelBase::Update(fDeltaTime); WheelBase::Update(fDeltaTime);
if ((m_deployDelay.PeekDeltaTime() >= 1.5) && (m_deployDelay.PeekDeltaTime() < (1.5 + 5)))
DeployInfoBox();
else if (m_deployDelay.PeekDeltaTime() >= 1.5 + 5)
RetractInfoBox();
} }
void RoomWheel::Move(int n) void RoomWheel::Move(int n)
{ {
if ((n == 0) && (m_iSelection >= m_offset)) if ((n == 0) && (m_iSelection >= m_offset))
{ m_roomInfo.SetRoom( GetItem(m_iSelection) );
m_RoomInfoState = CLOSED;
m_deployDelay.Touch();
if (m_roomInfo.GetHidden())
m_roomInfo.SetHidden(false);
}
else else
RetractInfoBox(); m_roomInfo.RetractInfoBox();
WheelBase::Move(n); WheelBase::Move(n);
} }
@@ -148,21 +131,56 @@ void RoomWheel::RemoveItem( int index )
WheelBase::RemoveItem(index + m_offset); WheelBase::RemoveItem(index + m_offset);
} }
void RoomWheel::DeployInfoBox() void RoomInfoDisplay::DeployInfoBox()
{ {
if (m_RoomInfoState == CLOSED) if (m_state == CLOSED)
{ {
SET_XY_AND_ON_COMMAND( m_roomInfo ); LOG->Info("OPEN");
m_RoomInfoState = OPEN; SET_XY_AND_ON_COMMAND( this );
m_state = OPEN;
} }
} }
void RoomWheel::RetractInfoBox() void RoomInfoDisplay::RetractInfoBox()
{ {
if (m_RoomInfoState == OPEN) if (m_state == OPEN)
OFF_COMMAND( m_roomInfo ); OFF_COMMAND( this );
m_RoomInfoState = LOCKED; m_state = LOCKED;
}
void RoomInfoDisplay::Load( CString sType )
{
SetName(sType);
DEPLOY_DELAY.Load(sType, "DeployDelay");
RETRACT_DELAY.Load(sType, "RetractDelay");
m_state = LOCKED;
m_bg.SetName("Background");
m_bg.SetWidth( THEME->GetMetricF(sType,"BackgroundWidth") );
m_bg.SetHeight( THEME->GetMetricF(sType,"BackgroundHeight") );
this->AddChild(&m_bg);
SET_XY_AND_ON_COMMAND( this );
OFF_COMMAND(this);
StopTweening();
}
void RoomInfoDisplay::SetRoom( const RoomWheelData* roomData )
{
m_state = CLOSED;
m_deployDelay.Touch();
}
void RoomInfoDisplay::Update( float fDeltaTime )
{
if ((m_deployDelay.PeekDeltaTime() >= DEPLOY_DELAY) && (m_deployDelay.PeekDeltaTime() < (DEPLOY_DELAY + RETRACT_DELAY)))
DeployInfoBox();
else if (m_deployDelay.PeekDeltaTime() >= DEPLOY_DELAY + RETRACT_DELAY)
RetractInfoBox();
ActorFrame::Update(fDeltaTime);
} }
/* /*
+30 -16
View File
@@ -34,6 +34,35 @@ private:
ThemeMetric<apActorCommands> DESC_ON_COMMAND; ThemeMetric<apActorCommands> DESC_ON_COMMAND;
}; };
class RoomInfoDisplay : public ActorFrame
{
public:
virtual void Load( CString sType );
virtual void Update( float fDeltaTime );
void SetRoom( const RoomWheelData* roomData );
void DeployInfoBox();
void RetractInfoBox();
private:
enum RoomInfoDisplayState
{
OPEN = 0,
CLOSED,
LOCKED
};
RoomInfoDisplayState m_state;
Quad m_bg;
BitmapText m_sTitle;
BitmapText m_sDesc;
RageTimer m_deployDelay;
ThemeMetric<float> X;
ThemeMetric<float> Y;
ThemeMetric<float> DEPLOY_DELAY;
ThemeMetric<float> RETRACT_DELAY;
};
class RoomWheel : public WheelBase { class RoomWheel : public WheelBase {
public: public:
virtual void Load( CString sType ); virtual void Load( CString sType );
@@ -50,22 +79,7 @@ public:
private: private:
int m_offset; int m_offset;
enum RoomInfoState RoomInfoDisplay m_roomInfo;
{
OPEN = 0,
CLOSED,
LOCKED
};
Quad m_roomInfo;
RageTimer m_deployDelay;
// RageTimer m_retractDelay;
RoomInfoState m_RoomInfoState;
void DeployInfoBox();
void RetractInfoBox();
}; };
#endif #endif