Example #1
0
void CRaceDemo::OnRender()
{
	if(!g_Config.m_ClAutoRaceRecord || !m_pClient->m_Snap.m_pGameobj || m_pClient->m_Snap.m_Spectate || Client()->State() != IClient::STATE_ONLINE)
		return;
	
	// start the demo
	if(m_DemoStartTick < Client()->GameTick())
	{
		bool start = false;
		std::list < int > Indices = m_pClient->Collision()->GetMapIndices(m_pClient->m_PredictedPrevChar.m_Pos, m_pClient->m_LocalCharacterPos);
		if(!Indices.empty())
			for(std::list < int >::iterator i = Indices.begin(); i != Indices.end(); i++)
				if(m_pClient->Collision()->GetTileIndex(*i) == TILE_BEGIN) start = true;
		else
			start = m_pClient->Collision()->GetTileIndex(m_pClient->Collision()->GetPureMapIndex(m_pClient->m_LocalCharacterPos)) == TILE_BEGIN;
		
		if(start)
		{
			OnReset();
			m_pMap = Client()->RaceRecordStart("tmp");
			m_DemoStartTick = Client()->GameTick() + Client()->GameTickSpeed();
			m_RaceState = RACE_STARTED;
		}
	}
	
	// stop the demo
	if(m_RaceState == RACE_FINISHED && m_RecordStopTime < Client()->GameTick() && m_Time > 0)
	{
		CheckDemo();
		OnReset();
	}
	
}
Example #2
0
void CRaceDemo::OnMessage(int MsgType, void *pRawMsg)
{
	if(!g_Config.m_ClAutoRaceRecord || Client()->State() != IClient::STATE_ONLINE || m_pClient->m_Snap.m_Spectate)
		return;
		
	// check for messages from server
	if(MsgType == NETMSGTYPE_SV_KILLMSG)
	{
		CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)pRawMsg;
		if(pMsg->m_Victim == m_pClient->m_Snap.m_LocalClientID && m_RaceState == RACE_FINISHED)
		{
			// check for new record
			CheckDemo();
			OnReset();
		}
	}
	else if(MsgType == NETMSGTYPE_SV_CHAT)
	{
		CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)pRawMsg;
		if(pMsg->m_ClientID == -1 && m_RaceState == RACE_STARTED)
		{
			const char* pMessage = pMsg->m_pMessage;
			
			int Num = 0;
			while(str_comp_num(pMessage, " finished in: ", 14))
			{
				pMessage++;
				Num++;
				if(!pMessage[0])
					return;
			}
			
			// store the name
			char aName[64];
			str_copy(aName, pMsg->m_pMessage, Num+1);
			
			// prepare values and state for saving
			int Minutes;
			float Seconds;
			if(!str_comp(aName, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName) && sscanf(pMessage, " finished in: %d minute(s) %f", &Minutes, &Seconds) == 2)
			{
				m_RaceState = RACE_FINISHED;
				m_RecordStopTime = Client()->GameTick() + Client()->GameTickSpeed();
				m_Time = Minutes*60 + Seconds;
			}
		}
	}
}
// ----------------------------------------------------
// CMobileOfficeAppUi::HandleCommandL(TInt aCommand)
// takes care of command handling
// ----------------------------------------------------
//
void CMobileOfficeAppUi::HandleCommandL(TInt aCommand)
{
		CheckDemo();
	
		switch ( aCommand )
        {
		case EAknSoftkeyExit:
		case EEikCmdExit:	
            {
				if (iDoorObserver)
					iDoorObserver->NotifyExit( MApaEmbeddedDocObserver::ENoChanges );
				#ifndef FREEVERSION
					licMan.End();
				#endif
				Exit();
				break;
            }
        case EMobileOfficeCmdAppAbout:
            {
			
				HBufC* messageText = StringLoader::LoadLC( R_MOBILESEARCH_ABOUT );
				
				/*
				TBuf<500> nein;
				nein.Copy(*messageText);
				nein.Append(_L("\r\n"));
				nein.Append(_L("\r\n"));
				nein.Append(_L("Application: 1.1"));
				nein.Append(_L("\r\n"));
				*/
				CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *messageText );
				dlg->PrepareLC(R_MESSAGE_QUERY);
				HBufC* aboutTitleText = StringLoader::LoadLC( R_MOBILESEARCH_ABOUTTITLE );	
				dlg->QueryHeading()->SetTextL( *aboutTitleText );
				CleanupStack::PopAndDestroy( aboutTitleText );
				dlg->RunLD();
				CleanupStack::PopAndDestroy( messageText );
				break;
            }
		case EMobileOfficeCmdOpen:
            {
				TUid viewID = KEditorViewViewId;	
				ActivateLocalViewL(viewID);
				//SendFileL(iOpenDocument->Filename());

				
				break;
			
			}
	
		case EMobileOfficeCmdList:
            {
				TUid viewID = KViewId;
				ActivateLocalViewL(viewID);
				break;
			
			}
	
		case EMobileOfficeCmdProp:
            {
				TUid viewID = KView2Id;
				ActivateLocalViewL(viewID);
				break;
			
			}
	#ifndef FREEVERSION
		case EMobileOfficeCmdRegister:
			{
				Register();	
				break;		
			}
	#endif
		case EMobileOfficeCmdPicture:
            {
				TUid viewID = KViewImageViewId;
				ActivateLocalViewL(viewID);
				break;
			
			}
		case EMobileOfficeCmdNewText:
			{
				TUid viewID = KEditorViewViewId;	
				OpenDocument()->SetNextViewID(viewID);
				OpenDocument()->SetEditable(ETrue);
				ActivateLocalViewL(viewID);
				break;
			}
		case EMobileOfficeCmdBack:
            {
			
				ActivateLocalViewL(OpenDocument()->NextViewID());
				break;
			
			}
		case EMobileOfficeCmdHelp:
			{
				CArrayFix<TCoeHelpContext>* buf = AppHelpContextL();
				HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf);
			}
        default:
            break;      
        }
    }
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CMobileOfficeAppUi::ConstructL()
// 
// ----------------------------------------------------------
//
void CMobileOfficeAppUi::ConstructL()
{
	BaseConstructL(EAknEnableSkin);

	iOpenDocument = COpenDocument::NewL();
	
	#ifndef FREEVERSION
		TBuf<50> nein;
		#ifndef __WINSCW__
			CIMEIRetriever::GetIMEIL(nein);	
		#endif

		licMan.SetIMEI(nein);
		licMan.Start(this);
	#endif	

	//SetOrientationL(EAppUiOrientationLandscape);

    // Show tabs for main views from resources
    CEikStatusPane* sp = StatusPane();

    // Fetch pointer to the default navi pane control
    iNaviPane = (CAknNavigationControlContainer*)sp->ControlL( 
        TUid::Uid(EEikStatusPaneUidNavi));

    // Tabgroup has been read from resource and it were pushed to the navi pane. 
    // Get pointer to the navigation decorator with the ResourceDecorator() function. 
    // Application owns the decorator and it has responsibility to delete the object.
    iDecoratedTabGroup = iNaviPane->ResourceDecorator();
    if (iDecoratedTabGroup)
        {
        iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl();
		iTabGroup->SetObserver( this );
		}

		
    CMobileOfficeView* view1 = new (ELeave) CMobileOfficeView;

    CleanupStack::PushL( view1 );
    view1->ConstructL();
    AddViewL( view1 );      // transfer ownership to CAknViewAppUi
    CleanupStack::Pop();    // view1

    CMobileOfficeView2* view2 = new (ELeave) CMobileOfficeView2;

    CleanupStack::PushL( view2 );
    view2->ConstructL();
    AddViewL( view2 );      // transfer ownership to CAknViewAppUi
    CleanupStack::Pop();    // view2

	
	CEditorViewView* view3 = new (ELeave) CEditorViewView;

    CleanupStack::PushL( view3 );
    view3->ConstructL();
    AddViewL( view3 );      // transfer ownership to CAknViewAppUi
    CleanupStack::Pop();    // view2

	
	CViewImageView* view4 = new (ELeave) CViewImageView;

    CleanupStack::PushL( view4 );
    view4->ConstructL();
    AddViewL( view4 );      // transfer ownership to CAknViewAppUi
    CleanupStack::Pop();    // view2

    SetDefaultViewL(*view1);
	CheckDemo();
}