void ScreenNetRoom::HandleScreenMessage( const ScreenMessage SM )
{
	if( SM == SM_GoToPrevScreen )
	{
		SCREENMAN->SetNewScreen( THEME->GetMetric (m_sName, "PrevScreen") );
	}
	else if( SM == SM_GoToNextScreen )
	{
		SCREENMAN->SetNewScreen( THEME->GetMetric (m_sName, "NextScreen") );
	}
	else if( SM == SM_BackFromReqPass )
	{
		if ( !ScreenTextEntry::s_bCancelledLast )
		{
			NSMAN->m_SMOnlinePacket.ClearPacket();
			NSMAN->m_SMOnlinePacket.Write1( 1 );
			NSMAN->m_SMOnlinePacket.Write1( 1 ); //Type (enter a room)
			NSMAN->m_SMOnlinePacket.WriteNT( m_sLastPickedRoom );
			NSMAN->m_SMOnlinePacket.WriteNT( ScreenTextEntry::s_sLastAnswer );
			NSMAN->SendSMOnline( );
		}
	}
	else if( SM == SM_SMOnlinePack )
	{
		switch( NSMAN->m_SMOnlinePacket.Read1() )
		{
		case 1:
			switch ( NSMAN->m_SMOnlinePacket.Read1() )
			{
				case 0: //Room title Change
				{
					RString title, subtitle;
					title = NSMAN->m_SMOnlinePacket.ReadNT();
					subtitle = NSMAN->m_SMOnlinePacket.ReadNT();

					Message msg( MessageIDToString(Message_UpdateScreenHeader) );
					msg.SetParam( "Header", title );
					msg.SetParam( "Subheader", subtitle );
					MESSAGEMAN->Broadcast( msg );

					if ( NSMAN->m_SMOnlinePacket.Read1() != 0 )
					{
						RString SMOnlineSelectScreen = THEME->GetMetric( m_sName, "MusicSelectScreen" );
						SCREENMAN->SetNewScreen( SMOnlineSelectScreen );
					}
				}
				case 1: //Rooms list change
				{
					int numRooms = NSMAN->m_SMOnlinePacket.Read1();
					m_Rooms.clear();
					for( int i=0; i<numRooms; ++i )
					{
						RoomData tmpRoomData;
						tmpRoomData.SetName( NSMAN->m_SMOnlinePacket.ReadNT() );
						tmpRoomData.SetDescription( NSMAN->m_SMOnlinePacket.ReadNT() );
						m_Rooms.push_back( tmpRoomData );
					}
					//Abide by protocol and read room status
					for( int i=0; i<numRooms; ++i )
						m_Rooms[i].SetState( NSMAN->m_SMOnlinePacket.Read1() );

					for( int i=0; i<numRooms; ++i )
						m_Rooms[i].SetFlags( NSMAN->m_SMOnlinePacket.Read1() );

					if( m_iRoomPlace<0 )
						m_iRoomPlace=0;
					if( m_iRoomPlace >= (int) m_Rooms.size() )
						m_iRoomPlace=m_Rooms.size()-1;
					UpdateRoomsList();
				}
			}
			break;
		case 3:
			RoomInfo info;
			info.songTitle = NSMAN->m_SMOnlinePacket.ReadNT();
			info.songSubTitle = NSMAN->m_SMOnlinePacket.ReadNT();
			info.songArtist = NSMAN->m_SMOnlinePacket.ReadNT();
			info.numPlayers = NSMAN->m_SMOnlinePacket.Read1();
			info.maxPlayers = NSMAN->m_SMOnlinePacket.Read1();
			info.players.resize( info.numPlayers );
			for( int i = 0; i < info.numPlayers; ++i )
				info.players[i] = NSMAN->m_SMOnlinePacket.ReadNT();

			m_roomInfo.SetRoomInfo( info );
			break;
		}
	}
	else if ( SM == SM_BackFromRoomName )
	{
		if ( !ScreenTextEntry::s_bCancelledLast )
		{
			m_newRoomName = ScreenTextEntry::s_sLastAnswer;
			ScreenTextEntry::TextEntry( SM_BackFromRoomDesc, ENTER_ROOM_DESCRIPTION, "", 255 );
		}
	}
	else if( SM == SM_BackFromRoomDesc )
	{
		if ( !ScreenTextEntry::s_bCancelledLast )
		{
			m_newRoomDesc = ScreenTextEntry::s_sLastAnswer;
			ScreenTextEntry::TextEntry( SM_BackFromRoomPass, ENTER_ROOM_PASSWORD, "", 255 );
		}
	}
	else if( SM == SM_BackFromRoomPass )
	{
		if ( !ScreenTextEntry::s_bCancelledLast )
		{
			m_newRoomPass = ScreenTextEntry::s_sLastAnswer;
			CreateNewRoom( m_newRoomName, m_newRoomDesc, m_newRoomPass);
		}
	}
	else if ( SM == SM_RoomInfoRetract )
	{
		m_roomInfo.RetractInfoBox();
	}
	else if ( SM == SM_RoomInfoDeploy )
	{
		int i = m_RoomWheel.GetCurrentIndex() - m_RoomWheel.GetPerminateOffset();
		const RoomWheelItemData* data = m_RoomWheel.GetItem(i);
		if( data != NULL )
			m_roomInfo.SetRoom( data );
	}

	ScreenNetSelectBase::HandleScreenMessage( SM );
}
示例#2
0
void ScreenNetRoom::HandleScreenMessage( const ScreenMessage SM )
{
	if( SM == SM_GoToPrevScreen )
	{
		SCREENMAN->SetNewScreen( THEME->GetMetric (m_sName, "PrevScreen") );
	}
	else if( SM == SM_GoToNextScreen )
	{
		SCREENMAN->SetNewScreen( THEME->GetMetric (m_sName, "NextScreen") );
	}
	else if( SM == SM_SMOnlinePack )
	{
		if ( NSMAN->m_SMOnlinePacket.Read1() == 1 )
		{
			switch ( NSMAN->m_SMOnlinePacket.Read1() )
			{
			case 0: //Room title Change
				{
					CString titleSub;
					titleSub = NSMAN->m_SMOnlinePacket.ReadNT() + "\n";
					titleSub += NSMAN->m_SMOnlinePacket.ReadNT();
					m_textTitle.SetText( titleSub );
					if ( NSMAN->m_SMOnlinePacket.Read1() != 0 )
					{
						CString SMOnlineSelectScreen;
						THEME->GetMetric( m_sName, "MusicSelectScreen", SMOnlineSelectScreen );
						SCREENMAN->SetNewScreen( SMOnlineSelectScreen );
					}
				}
			case 1: //Rooms list change
				{
					int numRooms = NSMAN->m_SMOnlinePacket.Read1();
					m_Rooms.clear();
					for (int i=0;i<numRooms;i++)
					{
						RoomData tmpRoomData;
						tmpRoomData.SetName(NSMAN->m_SMOnlinePacket.ReadNT());
						tmpRoomData.SetDescription(NSMAN->m_SMOnlinePacket.ReadNT());
						m_Rooms.push_back( tmpRoomData );
					}
					//Abide by protocol and read room status
					for (int i=0;i<numRooms;i++)
						m_Rooms[i].SetState(NSMAN->m_SMOnlinePacket.Read1());

					if (m_iRoomPlace<0)
						m_iRoomPlace=0;
					if( m_iRoomPlace >= (int) m_Rooms.size() )
						m_iRoomPlace=m_Rooms.size()-1;
					UpdateRoomsList();
				}
			}
		}
	}
	else if ( SM == SM_BackFromRoomName )
	{
		if ( !ScreenTextEntry::s_bCancelledLast )
		{
			m_newRoomName = ScreenTextEntry::s_sLastAnswer;
			SCREENMAN->TextEntry( SM_BackFromRoomDesc, "Enter Room Description:", "", 255 );
		}
	}
	else if( SM == SM_BackFromRoomDesc )
	{
		if ( !ScreenTextEntry::s_bCancelledLast )
		{
			m_newRoomDesc = ScreenTextEntry::s_sLastAnswer;
			CreateNewRoom( m_newRoomName, m_newRoomDesc);
		}
	}
	ScreenNetSelectBase::HandleScreenMessage( SM );
}