bool CTournamentRace::OnEvent (const SEvent &event) { bool bRet=false; if (event.EventType==EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown) { if (event.KeyInput.Key==KEY_ESCAPE && !event.KeyInput.PressedDown) { if (m_pSndEngine) m_pSndEngine->play2D("data/sounds/menuback.ogg"); m_iSelect=m_iReturnState; if (m_pNetAdapter) { CEventServerMessage cMsg(eNetBackToStart); m_pNetAdapter->sendPacket(&cMsg); } bRet=true; } if (event.KeyInput.Key==KEY_RETURN && (!m_pNetAdapter || m_pNetAdapter->isServer())) bRet=startRace(); } if (event.EventType==EET_GUI_EVENT) { if (event.GUIEvent.EventType==EGET_TAB_CHANGED && m_pSndEngine) m_pSndEngine->play2D("data/sounds/menuchange.ogg"); if (event.GUIEvent.EventType==EGET_BUTTON_CLICKED) { u32 id=event.GUIEvent.Caller->getID(); if (id==1 && (!m_pNetAdapter || m_pNetAdapter->isServer())) bRet=startRace(); if (id==2) { m_pSndEngine->play2D("data/sounds/menuback.ogg"); m_iSelect=m_iReturnState; if (m_pNetAdapter) { CEventServerMessage cMsg(eNetBackToStart); m_pNetAdapter->sendPacket(&cMsg); } bRet=true; } if (id==3) { m_pSndEngine->play2D("data/sounds/menuchange.ogg"); m_iSelect=1; bRet=true; } } } return bRet; }
void SelectWin::HandleMessage( os::Message* pcMessage ) { switch( pcMessage->GetCode() ) { case CF_GUI_PLAYLIST_OPEN: { os::Message cMsg( CF_GUI_LIST_SELECTED ); cMsg.AddString( "file/path", m_pcFileInput->GetBuffer()[0] ); os::Application::GetInstance()->PostMessage( &cMsg, os::Application::GetInstance() ); PostMessage( os::M_QUIT ); } break; case CF_GUI_PLAYLIST_SELECTOR: if( !m_pcFileDialog->IsVisible() ) m_pcFileDialog->Show(); m_pcFileDialog->MakeFocus( true ); break; case os::M_LOAD_REQUESTED: { os::String zFile; if( pcMessage->FindString( "file/path", &zFile.str() ) == 0 ) { m_pcFileInput->Clear(); m_pcFileInput->Insert( zFile.c_str() ); } } default: os::Window::HandleMessage( pcMessage ); } }
/** \brief Notify the gui that a given transfer's status has changed. * This is used to send a message to the main window signifying that some of the * downloads/uploads have been updated. * * If called from a GUI thread, the server lock must be held. * * \param pcJob: The job that has been updated. */ void Server::JobUpdated( Job* pcJob ) { Message cMsg( M_JOB_UPDATED ); bool bSend = pcJob->GetJobInfo( &cMsg ); if( bSend ) m_pcTarget->PostMessage( &cMsg, m_pcTarget ); }
/** \brief Notify the GUI that an error occurred during a transfer. * This is used to notify the GUI that an error occurred during a transfer, * and the transfer did not complete successfully. It sends a message to the GUI * which will then display a notification with the error message. * * \param pcJob: The job that has experienced an error. * \param zErrorMessage: A message describing the error that should be displayed to the user. */ void Server::SendFailureNotification( Job* pcJob, String& zErrorMessage ) { Message cMsg( M_JOB_ERROR ); pcJob->GetJobInfo( &cMsg ); cMsg.AddString( "message", zErrorMessage ); m_pcTarget->PostMessage( &cMsg, m_pcTarget ); }
/** \brief Notify the GUI that a destination file exists and ask the user whether to overwrite. * This is used to notify the GUI that a destinattion file exists, * and ask the user whether to overwrite it. It sends a message to the GUI * which will then display a overwrite notification. * * \param pcJob The job sending the overwrite notification * \param bMultiJob True if the job is part of a recursive job and the * 'Do this for all remaining files' checkbox should be shown; false if not. */ void Server::SendOverwriteNotification( Job* pcJob, bool bMultiJob ) { Message cMsg( M_JOB_OVERWRITE_QUERY ); pcJob->GetJobInfo( &cMsg ); cMsg.AddBool( "multi", bMultiJob ); m_pcTarget->PostMessage( &cMsg, m_pcTarget ); }
void CheatFn(int argc, char **argv) { if (argc < 1 || !g_pCheatMgr) return; CParsedMsg cMsg( argc, argv ); if (g_pCheatMgr->Check( cMsg )) { g_pClientSoundMgr->PlayInterfaceSound("Interface\\Menu\\Snd\\Cheat.wav"); } }
void CTournamentRace::onPeerDisconnect(u16 iPlayerId) { u32 iDisconnectPos=m_pNetAdapter->getIndexOfPeer(iPlayerId); CNetPlayer *pData=(CNetPlayer *)m_pNetAdapter->getPeerData(iPlayerId); if (pData) delete pData; printf("player %i disconnected\n",iPlayerId); if (m_pNetAdapter->isServer()) { CEventServerMessage cMsg(eMessagePlayerDisconnected); cMsg.setData1(iDisconnectPos); m_pNetAdapter->sendPacket(&cMsg); } }
void GUIDirListJob::HandleDirListData( std::vector< RemoteNode >* pacList ) { Message cMsg( M_REMOTE_DIRLISTING ); cMsg.AddString( "path", m_zRemotePath ); cMsg.AddPointer( "list", pacList ); if( m_bInitial ) cMsg.AddBool( "initial", true ); /* TODO: fix up initial, final flags. Maybe remove them. */ // cMsg.AddBool( "final", true ); Messenger cMessenger( m_pcTarget ); cMessenger.SendMessage( &cMsg ); }
uint32 LightDirectional::OnObjectCreated(const GenericPropList* pProps, float fCreationReason) { //let our base class handle the message first uint32 nResult = LightBase::OnObjectCreated(pProps, fCreationReason); if (nResult == 0) return nResult; EEngineLOD eLOD = CEngineLODPropUtil::StringToLOD(pProps->GetString("VolumetricLOD", ""), eEngineLOD_Never); //we don't need to continue if we're not going to have a volumetric lighting object if (eLOD == eEngineLOD_Never) return LT_OK; //read in the volumetric lighting options VOLUMETRICLIGHTCREATESTRUCT vlcs; vlcs.m_eLOD = eLOD; vlcs.m_fNoiseIntensity = pProps->GetReal("VolumetricNoiseIntensity", vlcs.m_fNoiseIntensity); vlcs.m_fNoiseScale = pProps->GetReal("VolumetricNoiseScale", vlcs.m_fNoiseScale); vlcs.m_vColor = pProps->GetColor("VolumetricColor", vlcs.m_vColor * 255.0f) / 255.0f; vlcs.m_sTexture = pProps->GetString("VolumetricTexture", vlcs.m_sTexture.c_str()); // Use the light's texture if they don't specify a texture if (vlcs.m_sTexture.empty()) vlcs.m_sTexture = m_sLightTexture; vlcs.m_fAttenuation = pProps->GetReal("VolumetricAttenuation", vlcs.m_fAttenuation); vlcs.m_bAdditive = pProps->GetBool("VolumetricAdditive", vlcs.m_bAdditive); vlcs.m_fDepth = pProps->GetReal("VolumetricDepth", vlcs.m_fDepth); vlcs.m_bShadow = pProps->GetBool("VolumetricShadow", vlcs.m_bShadow); //update the sfx message CAutoMessage cMsg((uint8)SFX_VOLUMETRICLIGHT_ID); vlcs.Write(cMsg); g_pLTServer->SetObjectSFXMessage(m_hObject, cMsg.Read()); //don't create/destroy the object based on visibility g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_FORCECLIENTUPDATE, FLAG_FORCECLIENTUPDATE); return LT_OK; }
void Core::sendGroupMessageWithType(int groupId, const QString& message, TOX_MESSAGE_TYPE type) { QStringList cMessages = splitMessage(message, MAX_GROUP_MESSAGE_LEN); for (auto& part : cMessages) { ToxString cMsg(part); TOX_ERR_CONFERENCE_SEND_MESSAGE error; bool ok = tox_conference_send_message(tox, groupId, type, cMsg.data(), cMsg.size(), &error); if (ok && error == TOX_ERR_CONFERENCE_SEND_MESSAGE_OK) { return; } qCritical() << "Fail of tox_conference_send_message"; switch (error) { case TOX_ERR_CONFERENCE_SEND_MESSAGE_CONFERENCE_NOT_FOUND: qCritical() << "Conference not found"; return; case TOX_ERR_CONFERENCE_SEND_MESSAGE_FAIL_SEND: qCritical() << "Conference message failed to send"; return; case TOX_ERR_CONFERENCE_SEND_MESSAGE_NO_CONNECTION: qCritical() << "No connection"; return; case TOX_ERR_CONFERENCE_SEND_MESSAGE_TOO_LONG: qCritical() << "Meesage too long"; return; default: break; } emit groupSentResult(groupId, message, -1); } }
/** \brief DragSelection callback. * Handles the results of a drag selection. */ void RemoteIconView::DragSelection( Point cStartPoint ) { /* Most of this is adapted from IconDirectoryView::DragSelection */ if( m_pcServer == NULL ) { DEBUG( "DragSelection with m_pcServer== NULL\n" ); return; } String zBase = m_pcServer->GetServerAddress(); Message cMsg( 1234 ); /* Message code isn't important */ /* Add all selected icons to the message, and find the icon under the mouse. */ int nCount = 0; int nLastSelected = -1; Point cIconPos = Point( 0,0 ); for( uint i = 0; i < GetIconCount(); i++ ) { if( GetIconSelected( i ) ) { RemoteIconData* pcData = (RemoteIconData*)GetIconData( i ); // DEBUG( " %s\n", pcData->m_cNode.m_zPath.c_str() ); cMsg.AddString( "remote-file/path", pcData->m_cNode.m_zPath ); cMsg.AddString( "server", zBase ); cMsg.AddBool( "is_dir", pcData->m_cNode.m_bIsDir ); if( Rect( GetIconPosition( i ), GetIconPosition( i ) + GetIconSize() ).DoIntersect( cStartPoint ) ) { cIconPos = GetIconPosition( i ); } nLastSelected = i; nCount++; } } if( nCount == 0 ) return; /* Create a drag&drop icon */ Bitmap cBitmap( (int)GetIconSize().x + 1, (int)GetIconSize().y + 1, CS_RGB32, Bitmap::ACCEPT_VIEWS | Bitmap::SHARE_FRAMEBUFFER ); View* pcView = new View( Rect( Point(0,0), GetIconSize() ), "temp" ); cBitmap.AddChild( pcView ); Image* pcIcon = NULL; String zLabel; if( nCount == 1 ) { /* Only one file selected; use its icon */ zLabel = GetIconString( nLastSelected, 0 ); pcIcon = GetIconImage( nLastSelected ); } else { /* Multiple files selected; use dir icon */ zLabel.Format( "%i items", nCount ); /* TODO: localise the string */ /* TODO: Fall back to resource if file isn't present */ File* pcFile = new File( "/system/icons/folder.png" ); BitmapImage* pcBitmapImage = new BitmapImage( pcFile ); Point cSize = (GetView() == VIEW_LIST || GetView() == VIEW_DETAILS ? Point( 24,24 ) : Point( 48,48 )); if( pcBitmapImage->GetSize() != cSize ) pcBitmapImage->SetSize( cSize ); pcIcon = pcBitmapImage; } if( pcIcon ) { RenderIcon( zLabel, pcIcon, pcView, Point(0,0) ); } cBitmap.Sync(); if( nCount != 1 ) delete( pcIcon ); BeginDrag( &cMsg, cStartPoint - cIconPos, &cBitmap ); }
void CIrrOdeNetController::addTorque(CIrrOdeBody *pBody, vector3df vTorque) { CEventControlMessage cMsg(eNetAddTorque); cMsg.setBodyId(pBody->getID()); cMsg.setVector(vTorque); m_pNetAdapter->sendPacket(&cMsg); }
void CIrrOdeNetController::setAngularVeclocity(CIrrOdeBody *pBody, vector3df vVel) { CEventControlMessage cMsg(eNetSetAngularVelocity); cMsg.setBodyId(pBody->getID()); cMsg.setVector(vVel); m_pNetAdapter->sendPacket(&cMsg); }
void CIrrOdeNetController::setPosition(CIrrOdeBody *pBody, vector3df vPos) { CEventControlMessage cMsg(eNetSetPosition); cMsg.setBodyId(pBody->getID()); cMsg.setVector(vPos); m_pNetAdapter->sendPacket(&cMsg); }
void CIrrOdeNetController::setAngularDamping(CIrrOdeBody *pBody, f32 fDamping) { CEventControlMessage cMsg(eNetSetAngularDamping); cMsg.setBodyId(pBody->getID()); cMsg.setFloat(fDamping); m_pNetAdapter->sendPacket(&cMsg); }
void CTournamentRace::activate(IState *pPrevious) { printf("CTournamentRace::activate start\n"); irr::ode::CIrrOdeManager::getSharedInstance()->getQueue()->addEventListener(this); if (m_pRace!=NULL && pPrevious!=m_pRace) { m_iReturnState=pPrevious->getNum()+1; printf("m_iReturnState: %i\n",m_iReturnState); } m_pDevice->getCursorControl()->setVisible(true); m_pTimer=m_pDevice->getTimer(); m_pSmgr->loadScene("data/setup_scene.xml"); m_iSelect=0; m_pSndEngine=m_pStateMachine->getSoundEngine(); dimension2du screenSize=m_pDriver->getScreenSize(); s32 iLeftX=screenSize.Width/2-400,iRightX=screenSize.Width/2+400; m_pTab=m_pGuienv->addTab(rect<s32>(iLeftX,0,iRightX,600)); m_pPages=m_pGuienv->addTabControl(rect<s32>(10,50,790,590),m_pTab,true,true); m_pRaces =m_pPages->addTab(L"Tournament Races"); m_pStandings=m_pPages->addTab(L"Tournament Standings"); m_pTable=m_pGuienv->addTable(rect<s32>(10,10,770,530),m_pStandings,-1,true); m_pTable->addColumn(L""); for (u32 j=0; j<m_pTrnInfo->getPlayerNo(); j++) { m_pTable->addColumn(m_pTrnInfo->getPlayerName(j)); m_pTable->setColumnWidth(j+1,400/m_pTrnInfo->getPlayerNo()); } m_pTable->addColumn(L"Fastest Lap"); m_pTable->setColumnWidth(0,160); m_pTable->setColumnWidth(m_pTable->getColumnCount()-1,200); printf("%i races\n",m_pTrnInfo->getRaceCount()); u32 iPoints[4]={0,0,0,0}, iVictories[4]={0,0,0,0}, iFastestLaps[4]={0,0,0,0}; for (u32 i=0; i<m_pTrnInfo->getRaceCount(); i++) { CTournamentRaceInfo *pInfo=m_pTrnInfo->getRace(i); CRaceInfoGUI *pGui=new CRaceInfoGUI(m_pDevice,i,pInfo,m_pRaces); if (i<=m_iNextRace) pGui->setState(m_iNextRace==i?1:2); m_aRaces.push_back(pGui); printf("Race %i: %s, %i Laps\n",i+1,stringc(stringw(pInfo->getTrack())).c_str(),pInfo->getLaps()); u32 iRow=m_pTable->addRow(m_pTable->getRowCount()); stringw sTrackName=stringw(pInfo->getTrack()); if (sTrackName.findFirst(L':')!=-1) sTrackName=sTrackName.subString(sTrackName.findFirst(L':')+1,sTrackName.size()); sTrackName=sTrackName.trim(); m_pTable->setCellText(iRow,0,sTrackName); if (m_iNextRace>0) { printf("race num: %i\n",m_iNextRace-1); CRaceInfo *pInfo=m_pTrnInfo->getRaceInfo(i); if (pInfo && pInfo->raceFinished()) { for (u32 j=0; j<m_pTrnInfo->getPlayerNo(); j++) { wchar_t s[0xFF]; u32 iPos=pInfo->getPlayerFinishedPosition(j); swprintf(s,L"%s",iPos==0?L"1st":iPos==1?L"2nd":iPos==2?L"3rd":iPos==3?L"4th":L"D.N.F."); m_pTable->setCellText(iRow,j+1,s); m_pTable->setCellColor(iRow,j+1,SColor(255,64,64,64)); if (iPos==0) { iPoints[j]+=m_pTrnInfo->getPlayerNo(); iVictories[j]++; } else { iPoints[j]+=m_pTrnInfo->getPlayerNo()-1-iPos; } if (pInfo->getFastestLap()->getPlayerNo()==j) iPoints[j]++; } m_pTable->setCellText(iRow,m_pTable->getColumnCount()-1,m_pTrnInfo->getPlayerName(pInfo->getFastestLap()->getPlayerNo())); iFastestLaps[pInfo->getFastestLap()->getPlayerNo()]++; } else if (i<m_iNextRace) for (u32 j=0; j<m_pTrnInfo->getPlayerNo(); j++) { m_pTable->setCellText(iRow,j+1,L"Cancelled"); m_pTable->setCellText(iRow,m_pTable->getColumnCount()-1,L"Cancelled"); } } } u32 iRow=m_pTable->addRow(m_pTable->getRowCount()); m_pTable->setCellText(iRow,0,L"Points"); for (u32 i=0; i<m_pTrnInfo->getPlayerNo(); i++) { wchar_t s[0xFF]; swprintf(s,L"%i",iPoints[i]); m_pTable->setCellText(iRow,i+1,s); } IGUIFont *pBigFont=m_pGuienv->getFont("data/font2.xml"); IGUIStaticText *pHeadline=m_pGuienv->addStaticText(L"Kinect Marble Racers - Tournament",rect<s32>(10,10,790,40),false,true,m_pTab); pHeadline->setTextAlignment(EGUIA_CENTER,EGUIA_CENTER); pHeadline->setOverrideFont(pBigFont); pHeadline->setBackgroundColor(SColor(128,16,16,16)); pHeadline->setOverrideColor(SColor(255,255,118,70)); if (m_iNextRace<m_aRaces.size() || m_iState==1) { if (m_pNetAdapter==NULL || m_pNetAdapter->isServer()) m_pGuienv->addButton(rect<s32>(10,445,210,465),m_pRaces,1,L"Start next Race"); m_pGuienv->addButton(rect<s32>(10,470,210,490),m_pRaces,2,L"Cancel Tournament"); m_iState=0; } else { array<CResult *> aResult; bool b=false; for (u32 i=0; i<m_pTrnInfo->getPlayerNo(); i++) { CResult *p=new CResult(); p->iPoints=iPoints[i]; p->iVictories=iVictories[i]; p->iFastestLaps=iFastestLaps[i]; p->iIdx=i; b=false; for (u32 j=0; j<aResult.size() && !b; j++) if (p->iPoints>aResult[j]->iPoints) { aResult.insert(p,j); b=true; } if (!b) aResult.push_back(p); } m_pGuienv->addButton(rect<s32>(10,470,210,490),m_pRaces,3,L"Back to Main Menu"); m_pTab->setVisible(false); u32 x=screenSize.Width/2-350,y=50; m_pGuienv->addImage(m_pDriver->getTexture("data/overall.png"),position2di(x,y),true); y+=150; x+=50; printf("\n\t\taResult.size: %i\n\n",aResult.size()); for (u32 i=0; i<aResult.size(); i++) { wchar_t s[0xFF]; IGUITab *pTab=m_pGuienv->addTab(rect<s32>(x,y,x+600,y+75)); pTab->setDrawBackground(true); pTab->setBackgroundColor(SColor(128,16,16,16)); swprintf(s,L"%i: %s",i+1,m_pTrnInfo->getPlayerName(aResult[i]->iIdx)); IGUIStaticText *text=m_pGuienv->addStaticText(s,rect<s32>(10,10,590,45),false,true,pTab); text->setOverrideFont(pBigFont); text->setOverrideColor(SColor(255,255,82,33)); swprintf(s,L"%i points, %i victories, %i fastest laps",aResult[i]->iPoints,aResult[i]->iVictories,aResult[i]->iFastestLaps); text=m_pGuienv->addStaticText(s,rect<s32>(50,50,590,65),false,true,pTab); text->setOverrideColor(SColor(255,255,82,33)); y+=80; } m_iState=1; } if (m_pLogic) delete m_pLogic; if (m_pNetAdapter==NULL || m_pNetAdapter->isServer()) m_pLogic=new CGameLogic(); else m_pLogic=new CGameLogicClient(); m_pLogic->setDevice(m_pDevice); m_pLogic->setGame(m_pRace); m_pDevice->setEventReceiver(this); if (m_pNetAdapter) { m_pNetAdapter->addConnectionHandler(this); m_pLogic->setNetAdapter(m_pNetAdapter); if (m_pNetAdapter->isServer()) { CEventServerMessage cMsg(eMessageQuitState); m_pNetAdapter->sendPacket(&cMsg); m_pNetAdapter->update(); } } m_pLogic->resetPlayerObject(); printf("CTournamentRace::activate end\n"); }
void CTournamentRace::onPeerConnect(u16 iPlayerId) { CEventServerMessage cMsg(eNetGameRunning); m_pNetAdapter->sendPacket(&cMsg,iPlayerId); m_pNetAdapter->update(); }