示例#1
0
void CChatSession::SetupWidget(CWidgetPrivateMessage *pWg)
{
	m_pWidget = pWg;

	connect(this, SIGNAL(guidChanged(QUuid)), m_pWidget, SLOT(OnGUIDChanged(QUuid)));
	connect(this, SIGNAL(nickChanged(QString)), m_pWidget, SLOT(OnNickChanged(QString)));
	connect(this, SIGNAL(incomingMessage(QString,bool)), m_pWidget, SLOT(OnIncomingMessage(QString,bool)));
	connect(this, SIGNAL(systemMessage(QString)), m_pWidget, SLOT(OnSystemMessage(QString)));
	connect(m_pWidget, SIGNAL(SendMessageS(QString,bool)), this, SLOT(SendMessage(QString,bool)));
	connect(m_pWidget, SIGNAL(SendMessageS(QTextDocument*,bool)), this, SLOT(SendMessage(QTextDocument*,bool)));
	connect(m_pWidget, SIGNAL(destroyed()), this, SLOT(deleteLater()));
}
//////////////////////////////////////////////////////////////////////
// fe_MultiplayerSetup::OnUpdate() //              \author Logan Jones
////////////////////////////////////                    \date 9/5/2002
//               
//====================================================================
//
void fe_MultiplayerSetup::OnUpdate()
{
	bool			bQueried;
	UINT32			Msg;
	gadget_ListBox*	pBox = (gadget_ListBox*)GetGadget("Output");

	net.SendRecv( &bQueried );

	if( bQueried )
		pBox->AddListBoxItem( "Something pinged at me" );

	while( net.Read().BytesToRead() )
		if( net.Read().Marker()==net_SystemMarker ) OnSystemMessage();
		else { net.Read() >> Msg; theApp.Console.Comment( CT_LOAD, "fe_MultiplayerSetup::OnUpdate(): Handling message, %d", Msg );switch(Msg){
			case fems_ClientLogin: OnClientLogin(); break;
			case fems_Resync: OnResync(); break;
			case fems_NewPlayer: OnNewPlayer(); break;
			case fems_RemovePlayer: DestroyPlayer(net.Read().GetUInt32()); break;
			case fems_Go: sound.PlaySound( guiResources.Sounds.BigButton ); SaveSettings(); theApp.SetStartMenu( "SelectGame" ); theApp.StartGame(); break;
			default:theApp.Console.Comment( CT_LOAD, "fe_MultiplayerSetup::OnUpdate(): Unknown message, %d", Msg );
		}}
}