void CLocalPlayer::HandleSpawn( bool bRespawn ) { // Are we respawning and not dead? if( bRespawn && !IsDead() ) return; // Have we already just spawned? if( (SharedUtility::GetTime() - m_ulSpawnTime) < 500 ) return; // Set the spawn time m_ulSpawnTime = SharedUtility::GetTime(); // Reset the death time m_ulDeathTime = 0; // Set the state SetState( ePlayerState::PLAYERSTATE_ONFOOT ); // Mark as not dead SetDead( false ); // Mark as spawned SetSpawned( true ); // Are we in a vehicle? if( IsInVehicle() ) { // Handle this enter with the network vehicle m_pVehicle->HandlePlayerExit( this, m_seat, false ); // Reset the vehicle SetVehicle( NULL ); // Reset the seat SetSeat( INVALID_ENTITY_ID ); } // Reset the player position and rotation Teleport ( CVector3() ); SetRotation ( CVector3() ); // Send RPC to server pCore->GetNetworkModule()->Call( RPC_PLAYER_SPAWN, NULL, HIGH_PRIORITY, RELIABLE, true ); // Restore the camera (TODO: Use real game function to reset camera behind player!) pCore->GetCamera()->LockControl ( false ); LockControls ( false ); // Restore the camera control pCore->GetCamera()->LockControl ( bOldCameraState ); // Restore the control state LockControls ( bOldCTRLState ); }
void GlassWidget::startEncodingData() { QStringList args; gw_process=new QProcess(this); gw_process->setReadChannel(QProcess::StandardOutput); connect(gw_process,SIGNAL(readyRead()), this,SLOT(processReadyReadStandardOutputData())); connect(gw_process,SIGNAL(error(QProcess::ProcessError)), this,SLOT(processErrorData(QProcess::ProcessError))); connect(gw_process,SIGNAL(finished(int,QProcess::ExitStatus)), this,SLOT(processFinishedData(int,QProcess::ExitStatus))); gw_server_dialog->makeArgs(&args,false); gw_codec_dialog->makeArgs(&args); gw_stream_dialog->makeArgs(&args,false); gw_source_dialog->makeArgs(&args,false); args.push_back("--meter-data"); args.push_back("--errors-to=STDOUT"); args.push_back("--errors-string="+gw_name_label->text()); gw_process->start("glasscoder",args); gw_start_button->disconnect(); connect(gw_start_button,SIGNAL(clicked()),this,SLOT(stopEncodingData())); gw_start_button->setText(tr("Stop")); LockControls(true); }
void CLocalPlayer::OnDeath( CNetworkPlayer * pKiller ) { // Are we not marked as dead? if( !IsDead() ) { // Get the old camera lock state bOldCameraState = pCore->GetCamera()->IsLocked (); // Get the old control state bOldCTRLState = AreControlsLocked (); // Mark as dead SetDead( true ); // Set the death time m_ulDeathTime = SharedUtility::GetTime(); // Mark as not spawned SetSpawned( false ); // Mark as not aiming SetAiming( false ); // Mark as not shooting SetShooting( false ); // Set the death time SetDeathTime( SharedUtility::GetTime() ); // Remove all the weapons m_pPlayerPed->RemoveAllWeapons (); // Construct a new bitstream RakNet::BitStream pBitStream; // Write the killerid pBitStream.WriteCompressed( (pKiller ? pKiller->GetId() : INVALID_ENTITY_ID) ); // Send RPC to server pCore->GetNetworkModule()->Call( RPC_PLAYER_DEATH, &pBitStream, HIGH_PRIORITY, RELIABLE, true ); // Fade out the screen pCore->GetHud()->FadeOut ( 3000 ); // Fade out the sound pCore->GetGame()->FadeSound ( true, 3 ); // Lock the camera control pCore->GetCamera()->LockControl ( true ); // Lock the player controls LockControls ( true ); } }
void CLocalPlayer::HandlePassengerKey( void ) { // Are we spawned and not dead and not already in a vehicle? if( IsSpawned() && !IsDead() && !m_pVehicle ) { // CNetworkVehicle * pVehicle = NULL; EntityId seat = 0; // Get the closest vehicle in range GetClosestVehicle( &pVehicle, &seat ); CLogFile::Printf( "CLocalPlayer::HandlePassengerKey() - Vehicle: 0x%p, Seat: %d", pVehicle, seat ); // Did we get a closest vehicle and a seat? if( pVehicle && seat ) { // Get the old control state bOldControlState = AreControlsLocked(); // Get the old camera lock state bOldCameraState = pCore->GetCamera()->IsLocked(); CLogFile::Printf( "CLocalPlayer::HandlePassengerKey() - bOldControlState: %s, bOldCameraState: %s", (bOldControlState ? "true" : "false"), (bOldCameraState ? "true" : "false") ); // Lock the player controls LockControls( true ); // Set the player state SetState( PLAYERSTATE_PASSENGER ); CLogFile::Printf( "CLocalPlayer::HandlePassengerKey() - Putting player in passenger seat..." ); // Get in the vehicle PutInVehicle( pVehicle, seat ); CLogFile::Printf( "CLocalPlayer::HandlePassengerKey() - Done!" ); // Unlock camera control if( !bOldCameraState ) // checking this because after we put in vehicle, it locks control :( pCore->GetCamera()->LockControl( false ); // Reset the controls //*(DWORD *)(m_pPlayerPed->GetPed() + 0x310) = 6; //LockControls( bState ); } } }
void GlassWidget::processFinishedData(int exit_code, QProcess::ExitStatus exit_status) { if(exit_code==0) { gw_meters[0]->setPeakBar(-10000); gw_meters[1]->setPeakBar(-10000); gw_start_button->disconnect(); connect(gw_start_button,SIGNAL(clicked()),this,SLOT(startEncodingData())); gw_start_button->setText(tr("Start")); LockControls(false); } else { ProcessError(exit_code,exit_status); } gw_kill_timer->stop(); gw_status_widget->setStatus(CONNECTION_IDLE); gw_process->deleteLater(); gw_process=NULL; emit stopped(); }
BOOL CCtrlPatterns::OnInitDialog() //-------------------------------- { CWnd::EnableToolTips(true); CRect rect, rcOrderList; CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); CModControlDlg::OnInitDialog(); if ((!m_pModDoc) || (!m_pSndFile) || (!pMainFrm)) return TRUE; LockControls(); // Order List m_BtnNext.GetWindowRect(&rect); ScreenToClient(&rect); rcOrderList.left = rect.right + 4; rcOrderList.top = rect.top; rcOrderList.bottom = rect.bottom + GetSystemMetrics(SM_CYHSCROLL); GetClientRect(&rect); rcOrderList.right = rect.right - 4; m_OrderList.Init(rcOrderList, this, m_pModDoc, pMainFrm->GetGUIFont()); // Toolbar buttons m_ToolBar.Init(); m_ToolBar.AddButton(IDC_PATTERN_NEW, TIMAGE_PATTERN_NEW); m_ToolBar.AddButton(IDC_PATTERN_PLAY, TIMAGE_PATTERN_PLAY); m_ToolBar.AddButton(IDC_PATTERN_PLAYFROMSTART, TIMAGE_PATTERN_RESTART); m_ToolBar.AddButton(IDC_PATTERN_STOP, TIMAGE_PATTERN_STOP); m_ToolBar.AddButton(ID_PATTERN_PLAYROW, TIMAGE_PATTERN_PLAYROW); m_ToolBar.AddButton(IDC_PATTERN_RECORD, TIMAGE_PATTERN_RECORD, TBSTYLE_CHECK, ((m_bRecord) ? TBSTATE_CHECKED : 0)|TBSTATE_ENABLED); m_ToolBar.AddButton(ID_SEPARATOR, 0, TBSTYLE_SEP); m_ToolBar.AddButton(ID_PATTERN_VUMETERS, TIMAGE_PATTERN_VUMETERS, TBSTYLE_CHECK, ((m_bVUMeters) ? TBSTATE_CHECKED : 0)|TBSTATE_ENABLED); m_ToolBar.AddButton(ID_VIEWPLUGNAMES, TIMAGE_PATTERN_PLUGINS, TBSTYLE_CHECK, ((m_bPluginNames) ? TBSTATE_CHECKED : 0)|TBSTATE_ENABLED); //rewbs.patPlugNames m_ToolBar.AddButton(ID_PATTERN_CHANNELMANAGER, TIMAGE_CHANNELMANAGER); m_ToolBar.AddButton(ID_SEPARATOR, 0, TBSTYLE_SEP); m_ToolBar.AddButton(ID_PATTERN_MIDIMACRO, TIMAGE_MACROEDITOR); m_ToolBar.AddButton(ID_PATTERN_CHORDEDIT, TIMAGE_CHORDEDITOR); m_ToolBar.AddButton(ID_SEPARATOR, 0, TBSTYLE_SEP); m_ToolBar.AddButton(ID_EDIT_UNDO, TIMAGE_UNDO); m_ToolBar.AddButton(ID_PATTERN_PROPERTIES, TIMAGE_PATTERN_PROPERTIES); m_ToolBar.AddButton(ID_PATTERN_EXPAND, TIMAGE_PATTERN_EXPAND); m_ToolBar.AddButton(ID_PATTERN_SHRINK, TIMAGE_PATTERN_SHRINK); // m_ToolBar.AddButton(ID_PATTERN_AMPLIFY, TIMAGE_SAMPLE_AMPLIFY); m_ToolBar.AddButton(ID_SEPARATOR, 0, TBSTYLE_SEP); m_ToolBar.AddButton(ID_PATTERNDETAIL_LO, TIMAGE_PATTERN_DETAIL_LO, TBSTYLE_CHECK, TBSTATE_ENABLED); m_ToolBar.AddButton(ID_PATTERNDETAIL_MED, TIMAGE_PATTERN_DETAIL_MED, TBSTYLE_CHECK, TBSTATE_ENABLED); m_ToolBar.AddButton(ID_PATTERNDETAIL_HI, TIMAGE_PATTERN_DETAIL_HI, TBSTYLE_CHECK, TBSTATE_ENABLED|TBSTATE_CHECKED); m_ToolBar.AddButton(ID_SEPARATOR, 0, TBSTYLE_SEP); m_ToolBar.AddButton(ID_OVERFLOWPASTE, TIMAGE_PATTERN_OVERFLOWPASTE, TBSTYLE_CHECK, ((CMainFrame::m_dwPatternSetup & PATTERN_OVERFLOWPASTE) ? TBSTATE_CHECKED : 0) | TBSTATE_ENABLED); // Special edit controls -> tab switch to view m_EditSequence.SetParent(this); m_EditSpacing.SetParent(this); m_EditPatName.SetParent(this); m_EditPatName.SetLimitText(MAX_PATTERNNAME - 1); m_EditOrderListMargins.SetParent(this); m_EditOrderListMargins.SetLimitText(3); // Spin controls m_SpinSpacing.SetRange(0, MAX_SPACING); m_SpinSpacing.SetPos(CMainFrame::gnPatternSpacing); m_SpinInstrument.SetRange(-1, 1); m_SpinInstrument.SetPos(0); if(CMainFrame::gbShowHackControls == true) { m_SpinOrderListMargins.ShowWindow(SW_SHOW); m_EditOrderListMargins.ShowWindow(SW_SHOW); m_SpinOrderListMargins.SetRange(0, m_OrderList.GetMarginsMax()); m_SpinOrderListMargins.SetPos(m_OrderList.GetMargins()); } else { m_SpinOrderListMargins.ShowWindow(SW_HIDE); m_EditOrderListMargins.ShowWindow(SW_HIDE); } SetDlgItemInt(IDC_EDIT_SPACING, CMainFrame::gnPatternSpacing); SetDlgItemInt(IDC_EDIT_ORDERLIST_MARGINS, m_OrderList.GetMargins()); CheckDlgButton(IDC_PATTERN_FOLLOWSONG, !(CMainFrame::m_dwPatternSetup & PATTERN_FOLLOWSONGOFF)); //rewbs.noFollow - set to unchecked m_SpinSequence.SetRange(0, m_pSndFile->Order.GetNumSequences() - 1); m_SpinSequence.SetPos(m_pSndFile->Order.GetCurrentSequenceIndex()); SetDlgItemText(IDC_EDIT_SEQUENCE_NAME, m_pSndFile->Order.m_sName.c_str()); m_OrderList.SetFocus(); UpdateView(HINT_MODTYPE|HINT_PATNAMES, NULL); RecalcLayout(); m_bInitialized = TRUE; UnlockControls(); return FALSE; }
void CCtrlPatterns::UpdateView(uint32_t dwHintMask, CObject *pObj) //------------------------------------------------------------- { CHAR s[256]; m_OrderList.UpdateView(dwHintMask, pObj); if (!m_pSndFile) return; if (dwHintMask & HINT_MODSEQUENCE) { SetDlgItemText(IDC_EDIT_SEQUENCE_NAME, m_pSndFile->Order.m_sName.c_str()); } if (dwHintMask & (HINT_MODSEQUENCE|HINT_MODTYPE)) { m_SpinSequence.SetRange(0, m_pSndFile->Order.GetNumSequences() - 1); m_SpinSequence.SetPos(m_pSndFile->Order.GetCurrentSequenceIndex()); } //rewbs.instroVST if (dwHintMask & (HINT_MIXPLUGINS|HINT_MODTYPE)) { if (HasValidPlug(m_nInstrument)) ::EnableWindow(::GetDlgItem(m_hWnd, IDC_PATINSTROPLUGGUI), true); else ::EnableWindow(::GetDlgItem(m_hWnd, IDC_PATINSTROPLUGGUI), false); // Enable/disable multisequence controls according the current modtype. BOOL isMultiSeqAvail = (m_pSndFile->GetType() == MOD_TYPE_MPT) ? TRUE : FALSE; GetDlgItem(IDC_STATIC_SEQUENCE_NAME)->EnableWindow(isMultiSeqAvail); GetDlgItem(IDC_EDIT_SEQUENCE_NAME)->EnableWindow(isMultiSeqAvail); GetDlgItem(IDC_EDIT_SEQNUM)->EnableWindow(isMultiSeqAvail); GetDlgItem(IDC_SPIN_SEQNUM)->EnableWindow(isMultiSeqAvail); // Enable/disable pattern names BOOL isPatNameAvail = (m_pSndFile->GetType() & (MOD_TYPE_MPT|MOD_TYPE_IT|MOD_TYPE_XM)) ? TRUE : FALSE; GetDlgItem(IDC_STATIC_PATTERNNAME)->EnableWindow(isPatNameAvail); GetDlgItem(IDC_EDIT_PATTERNNAME)->EnableWindow(isPatNameAvail); } //end rewbs.instroVST if (dwHintMask & HINT_MPTOPTIONS) { m_ToolBar.UpdateStyle(); // -> CODE#0007 // -> DESC="uncheck follow song checkbox by default" //CheckDlgButton(IDC_PATTERN_FOLLOWSONG, (CMainFrame::m_dwPatternSetup & PATTERN_FOLLOWSONGOFF) ? MF_UNCHECKED : MF_CHECKED); m_ToolBar.SetState(ID_OVERFLOWPASTE, ((CMainFrame::m_dwPatternSetup & PATTERN_OVERFLOWPASTE) ? TBSTATE_CHECKED : 0) | TBSTATE_ENABLED); // -! BEHAVIOUR_CHANGE#0007 } if (dwHintMask & (HINT_MODTYPE|HINT_INSNAMES|HINT_SMPNAMES|HINT_PATNAMES)) { LockControls(); if (dwHintMask & (HINT_MODTYPE|HINT_INSNAMES|HINT_SMPNAMES)) { static const TCHAR szSplitFormat[] = TEXT("%02u %s %02u: %s/%s"); UINT nPos = 0; m_CbnInstrument.SetRedraw(FALSE); m_CbnInstrument.ResetContent(); m_CbnInstrument.SetItemData(m_CbnInstrument.AddString(" No Instrument"), 0); const modplug::tracker::instrumentindex_t nSplitIns = m_pModDoc->GetSplitKeyboardSettings()->splitInstrument; const modplug::tracker::note_t noteSplit = 1 + m_pModDoc->GetSplitKeyboardSettings()->splitNote; const CString sSplitInsName = m_pModDoc->GetPatternViewInstrumentName(nSplitIns, true, false); if (m_pSndFile->m_nInstruments) { for (UINT i=1; i<=m_pSndFile->m_nInstruments; i++) { if (m_pSndFile->Instruments[i] == nullptr) continue; CString sDisplayName; if (m_pModDoc->GetSplitKeyboardSettings()->IsSplitActive()) { wsprintf(s, szSplitFormat, nSplitIns, GetNoteStr(noteSplit), i, (LPCTSTR)sSplitInsName, (LPCTSTR)m_pModDoc->GetPatternViewInstrumentName(i, true, false)); sDisplayName = s; } else sDisplayName = m_pModDoc->GetPatternViewInstrumentName(i); UINT n = m_CbnInstrument.AddString(sDisplayName); if (n == m_nInstrument) nPos = n; m_CbnInstrument.SetItemData(n, i); } } else { UINT nmax = m_pSndFile->m_nSamples; while ((nmax > 1) && (m_pSndFile->Samples[nmax].sample_data == NULL) && (!m_pSndFile->m_szNames[nmax][0])) nmax--; for (UINT i=1; i<=nmax; i++) if ((m_pSndFile->m_szNames[i][0]) || (m_pSndFile->Samples[i].sample_data)) { if (m_pModDoc->GetSplitKeyboardSettings()->IsSplitActive() && nSplitIns < CountOf(m_pSndFile->m_szNames)) wsprintf(s, szSplitFormat, nSplitIns, GetNoteStr(noteSplit), i, m_pSndFile->m_szNames[nSplitIns], m_pSndFile->m_szNames[i]); else wsprintf(s, "%02u: %s", i, m_pSndFile->m_szNames[i]); UINT n = m_CbnInstrument.AddString(s); if (n == m_nInstrument) nPos = n; m_CbnInstrument.SetItemData(n, i); } } m_CbnInstrument.SetCurSel(nPos); m_CbnInstrument.SetRedraw(TRUE); } if (dwHintMask & (HINT_MODTYPE|HINT_PATNAMES)) { modplug::tracker::patternindex_t nPat; if (dwHintMask & HINT_PATNAMES) nPat = (modplug::tracker::patternindex_t)(dwHintMask >> HINT_SHIFT_PAT); else
void CCtrlGeneral::OnVScroll(UINT code, UINT pos, CScrollBar *pscroll) //-------------------------------------------------------------------- { CDialog::OnVScroll(code, pos, pscroll); if (m_bInitialized) { CSliderCtrl* pSlider = (CSliderCtrl*) pscroll; if (pSlider == &m_SliderTempo) { const TEMPO tempo = tempoMax - TEMPO(m_SliderTempo.GetPos(), 0); if ((tempo >= m_sndFile.GetModSpecifications().GetTempoMin()) && (tempo <= m_sndFile.GetModSpecifications().GetTempoMax()) && (tempo != m_sndFile.m_nDefaultTempo)) { m_sndFile.m_nDefaultTempo = m_sndFile.m_PlayState.m_nMusicTempo = tempo; m_modDoc.SetModified(); m_modDoc.UpdateAllViews(nullptr, GeneralHint().General(), this); } } else if (pSlider == &m_SliderGlobalVol) { const UINT gv = MAX_SLIDER_GLOBAL_VOL - m_SliderGlobalVol.GetPos(); if ((gv >= 0) && (gv <= MAX_SLIDER_GLOBAL_VOL) && (gv != m_sndFile.m_nDefaultGlobalVolume)) { m_sndFile.m_PlayState.m_nGlobalVolume = gv; m_sndFile.m_nDefaultGlobalVolume = gv; m_modDoc.SetModified(); m_modDoc.UpdateAllViews(nullptr, GeneralHint().General(), this); } } else if (pSlider == &m_SliderSamplePreAmp) { const UINT spa = MAX_SLIDER_SAMPLE_VOL - m_SliderSamplePreAmp.GetPos(); if ((spa >= 0) && (spa <= MAX_SLIDER_SAMPLE_VOL) && (spa != m_sndFile.m_nSamplePreAmp)) { m_sndFile.m_nSamplePreAmp = spa; if(m_sndFile.GetType() != MOD_TYPE_MOD) m_modDoc.SetModified(); m_modDoc.UpdateAllViews(nullptr, GeneralHint().General(), this); } } else if (pSlider == &m_SliderVSTiVol) { const UINT vv = MAX_SLIDER_VSTI_VOL - m_SliderVSTiVol.GetPos(); if ((vv >= 0) && (vv <= MAX_SLIDER_VSTI_VOL) && (vv != m_sndFile.m_nVSTiVolume)) { m_sndFile.m_nVSTiVolume = vv; m_sndFile.RecalculateGainForAllPlugs(); m_modDoc.SetModified(); m_modDoc.UpdateAllViews(nullptr, GeneralHint().General(), this); } } else if(pSlider == (CSliderCtrl*)&m_SpinTempo) { int pos32 = m_SpinTempo.GetPos32(); if(pos32 != 0) { TEMPO newTempo; if(m_sndFile.GetModSpecifications().hasFractionalTempo) { pos32 *= TEMPO::fractFact; if(CMainFrame::GetMainFrame()->GetInputHandler()->CtrlPressed()) pos32 /= 100; else pos32 /= 10; newTempo.SetRaw(pos32); } else { newTempo = TEMPO(pos32, 0); } newTempo += m_sndFile.m_nDefaultTempo; Limit(newTempo, tempoMin, tempoMax); m_sndFile.m_nDefaultTempo = m_sndFile.m_PlayState.m_nMusicTempo = newTempo; m_modDoc.SetModified(); LockControls(); m_modDoc.UpdateAllViews(nullptr, GeneralHint().General(), this); UnlockControls(); } m_SpinTempo.SetPos(0); } UpdateView(GeneralHint().General()); } }
void CLocalPlayer::OnLeaveVehicle( void ) { // Set the player state SetState( PLAYERSTATE_ONFOOT ); // Is the vehicle instance valid? if( m_pVehicle ) { // Get the seat of this player EntityId seat = m_seat; // Construct a new bitstream RakNet::BitStream pBitStream; // Write the vehicle id pBitStream.WriteCompressed( m_pVehicle->GetId() ); // Write the seat pBitStream.WriteCompressed( seat ); // Write if we're exiting quickly! m_bFastExitVehicle ? pBitStream.Write1() : pBitStream.Write0(); // Send to the server pCore->GetNetworkModule()->Call( RPC_EXIT_VEHICLE, &pBitStream, HIGH_PRIORITY, RELIABLE_ORDERED, true ); #ifdef DEBUG pCore->GetChat()->AddDebugMessage( "CLocalPlayer::OnExitVehicle( %d, %d ) - Forcefully: %s", m_pVehicle->GetId(), seat, (IsBeingRemovedForcefully () ? "Yes" : "No") ); #endif // Are we not being removed forcefully? if ( !IsBeingRemovedForcefully () ) { // Handle this enter with the network vehicle m_pVehicle->HandlePlayerExit( this, seat, false ); // Do we need to respawn this vehicle? (Set to true when vehicle enters water) if( bRespawnVehicle && m_seat == 0 ) { // Respawn the vehicle m_pVehicle->Respawn(); // bRespawnVehicle = false; } // Are we a passenger? if( m_seat > 0 ) { // Restore the player controls LockControls( bOldControlState ); // Restore the camera lock state pCore->GetCamera()->LockControl( bOldCameraState ); // *(DWORD *)(m_pPlayerPed->GetPed() + 0x310) = 6; } } // Reset the vehicle SetVehicle( NULL ); // Reset the seat SetSeat( INVALID_ENTITY_ID ); // Reset the target data SetEnteringVehicle( NULL, INVALID_ENTITY_ID ); // Reset the fast vehicle exit flag FlagForFastExitVehicle ( false ); // Reset the forceful exit flag SetRemoveForcefully ( false ); } }