int CPlayerToolBar::GetVolume() { int volume = m_volctrl.GetPos(), type = 0; if (volume < 1 && !iMute) { if (!IsMuted()) { type++; } iMute = 1; } else if (IsMuted() && volume > 0 && iMute) { type++; iMute = 0; } /* if (type) { OnVolumeMute(0); SendMessage(WM_COMMAND, ID_VOLUME_MUTE); } */ if (IsMuted() || volume < 1) { volume = -10000; } else { volume = min((int)(4000 * log10(volume / 100.0f)), 0); } return volume; }
void CPlayerToolBar::ArrangeControls() { CRect rc; GetWindowRect(&rc); long iWidth = rc.Width(); CMainFrame* pFrame = ((CMainFrame*)AfxGetMainWnd()); double skinsRate = 1.0; BOOL isaudio = (pFrame && pFrame->IsSomethingLoaded() && pFrame->m_fAudioOnly)?TRUE:FALSE; m_btnList.SetCurrentHideState(rc.Width(),skinsRate,m_nLogDPIY); if(IsMuted()) m_btnList.SetHideStat(L"VOLUME.BMP", TRUE); else //m_btnList.SetHideStat(L"VOLUME.BMP", FALSE|hideT1); m_btnList.SetHideStat(L"MUTED.BMP", TRUE); if(pFrame && pFrame->IsSomethingLoaded() ) { if (pFrame->m_fAudioOnly) { m_btnList.SetHideStat(ID_NAVIGATE_SKIPBACK , 0); m_btnList.SetHideStat(ID_NAVIGATE_SKIPFORWARD , 0); m_btnList.SetHideStat(ID_MOVIESHARE, 1); } } m_btnList.OnSize(rc); if(!::IsWindow(m_volctrl.m_hWnd)) return; }
void Client::PlayerHitBlockWithSpade(spades::client::Player *p, Vector3 hitPos, IntVector3 blockPos, IntVector3 normal) { SPADES_MARK_FUNCTION(); uint32_t col = map->GetColor(blockPos.x, blockPos.y, blockPos.z); IntVector3 colV = {(uint8_t)col, (uint8_t)(col >> 8), (uint8_t)(col >> 16)}; Vector3 shiftedHitPos = hitPos; shiftedHitPos.x += normal.x * .05f; shiftedHitPos.y += normal.y * .05f; shiftedHitPos.z += normal.z * .05f; EmitBlockFragments(shiftedHitPos, colV); if (p == world->GetLocalPlayer()) { localFireVibrationTime = time; } if (!IsMuted()) { bool isLocal = p == world->GetLocalPlayer(); Handle<IAudioChunk> c = audioDevice->RegisterSound("Sounds/Weapons/Spade/HitBlock.opus"); if (isLocal) audioDevice->PlayLocal(c, MakeVector3(.1f, -.1f, 1.2f), AudioParam()); else audioDevice->Play(c, p->GetOrigin() + p->GetFront() * 0.5f - p->GetUp() * .2f, AudioParam()); } }
void Output::saveVolume () { SaveVolumeScheduled_ = false; XmlSettingsManager::Instance ().setProperty ("AudioVolume", GetVolume ()); XmlSettingsManager::Instance ().setProperty ("AudioMuted", IsMuted ()); }
void Client::PlayerCapturedIntel(spades::client::Player *p){ std::string msg; { std::string holderName = chatWindow->TeamColorMessage(p->GetName(), p->GetTeamId()); std::string otherTeamName = chatWindow->TeamColorMessage(world->GetTeam(1 - p->GetTeamId()).name, 1 - p->GetTeamId()); msg = _Tr("Client", "{0} captured {1}'s intel", holderName, otherTeamName); chatWindow->AddMessage(msg); } if ((int)cg_centerMessage != 0){ std::string holderName = p->GetName(); std::string otherTeamName = world->GetTeam(1 - p->GetTeamId()).name; msg = _Tr("Client", "{0} captured {1}'s Intel.", holderName, otherTeamName); NetLog("%s", msg.c_str()); centerMessageView->AddMessage(msg); } if(world->GetLocalPlayer() && !IsMuted()){ if(p->GetTeamId() == world->GetLocalPlayer()->GetTeamId()){ Handle<IAudioChunk> chunk = audioDevice->RegisterSound("Sounds/Feedback/CTF/YourTeamCaptured.wav"); audioDevice->PlayLocal(chunk, AudioParam()); }else{ Handle<IAudioChunk> chunk = audioDevice->RegisterSound("Sounds/Feedback/CTF/EnemyCaptured.wav"); audioDevice->PlayLocal(chunk, AudioParam()); } } }
void AudioSystem::PlaySound(SoundHandle sound, float volume, float x, float y, Time_t currentTime) { if (IsMuted()) return; if (sound == InvalidSound) return; uint32_t timeMillis = currentTime / 1000ull; size_t_32 longestPlayIndex = 0; uint32_t longestPlayTime = 0; for (size_t_32 i = 0; i < MAX_CHANNELS; i++) { if (m_channels[i]->IsFree()) { Sound *s = m_sounds.Get(sound); m_channels[i]->PlaySound(s, volume, x, y, timeMillis); return; } uint32_t playTime = m_channels[i]->TimePlayed(timeMillis); if (playTime > longestPlayTime) { longestPlayIndex = i; longestPlayTime = playTime; } } Sound *s = m_sounds.Get(sound); m_channels[longestPlayIndex]->Stop(); m_channels[longestPlayIndex]->PlaySound(s, volume, x, y, timeMillis); }
void TransportControlGroup::_UpdateVolume() { if (IsMuted()) SetMuted(false); VolumeChanged(Volume()); }
void Client::PlayerMadeFootstep(spades::client::Player *p) { SPADES_MARK_FUNCTION(); if (!IsMuted()) { std::array<const char *, 8> snds = {"Sounds/Player/Footstep1.opus", "Sounds/Player/Footstep2.opus", "Sounds/Player/Footstep3.opus", "Sounds/Player/Footstep4.opus", "Sounds/Player/Footstep5.opus", "Sounds/Player/Footstep6.opus", "Sounds/Player/Footstep7.opus", "Sounds/Player/Footstep8.opus"}; std::array<const char *, 12> rsnds = { "Sounds/Player/Run1.opus", "Sounds/Player/Run2.opus", "Sounds/Player/Run3.opus", "Sounds/Player/Run4.opus", "Sounds/Player/Run5.opus", "Sounds/Player/Run6.opus", "Sounds/Player/Run7.opus", "Sounds/Player/Run8.opus", "Sounds/Player/Run9.opus", "Sounds/Player/Run10.opus", "Sounds/Player/Run11.opus", "Sounds/Player/Run12.opus", }; std::array<const char *, 8> wsnds = {"Sounds/Player/Wade1.opus", "Sounds/Player/Wade2.opus", "Sounds/Player/Wade3.opus", "Sounds/Player/Wade4.opus", "Sounds/Player/Wade5.opus", "Sounds/Player/Wade6.opus", "Sounds/Player/Wade7.opus", "Sounds/Player/Wade8.opus"}; bool sprinting = clientPlayers[p->GetId()] ? clientPlayers[p->GetId()]->GetSprintState() > 0.5f : false; Handle<IAudioChunk> c = p->GetWade() ? audioDevice->RegisterSound(SampleRandomElement(wsnds)) : audioDevice->RegisterSound(SampleRandomElement(snds)); audioDevice->Play(c, p->GetOrigin(), AudioParam()); if (sprinting && !p->GetWade()) { AudioParam param; param.volume *= clientPlayers[p->GetId()]->GetSprintState(); c = audioDevice->RegisterSound(SampleRandomElement(rsnds)); audioDevice->Play(c, p->GetOrigin(), param); } } }
void Client::LocalPlayerPulledGrenadePin() { SPADES_MARK_FUNCTION(); if (!IsMuted()) { Handle<IAudioChunk> c = audioDevice->RegisterSound("Sounds/Weapons/Grenade/Fire.opus"); audioDevice->PlayLocal(c, MakeVector3(.4f, -.3f, .5f), AudioParam()); } }
void Client::GrenadeDroppedIntoWater(spades::client::Grenade *g) { SPADES_MARK_FUNCTION(); if (!IsMuted()) { Handle<IAudioChunk> c = audioDevice->RegisterSound("Sounds/Weapons/Grenade/DropWater.opus"); audioDevice->Play(c, g->GetPosition(), AudioParam()); } }
int CPlayerToolBar::GetVolume() { int volume = min( m_volctrl.GetPos() , 100); volume = (int)((log10(1.0*volume)-2)*5000); volume = ((int)(volume/100)*100); //SVP_LogMsg3(("Vol %d") , volume); volume = max(min(volume, 0), -10000); return(IsMuted() ? -10000 : volume); }
void Client::PlayerCreatedBlock(spades::client::Player *p){ SPADES_MARK_FUNCTION(); if(!IsMuted()) { Handle<IAudioChunk> c = audioDevice->RegisterSound("Sounds/Weapons/Block/Build.wav"); audioDevice->Play(c, p->GetEye() + p->GetFront(), AudioParam()); } }
BOOL CPlayerToolBar::OnVolumeMute(UINT nID) { SetMute(!IsMuted()); if (::IsWindow(m_volctrl.GetSafeHwnd())) { m_volctrl.Invalidate(); } return FALSE; }
void Client::GrenadeBounced(spades::client::Grenade *g) { SPADES_MARK_FUNCTION(); if (g->GetPosition().z < 63.f) { if (!IsMuted()) { Handle<IAudioChunk> c = audioDevice->RegisterSound("Sounds/Weapons/Grenade/Bounce.opus"); audioDevice->Play(c, g->GetPosition(), AudioParam()); } } }
void Client::PlayerJumped(spades::client::Player *p) { SPADES_MARK_FUNCTION(); if (!IsMuted()) { Handle<IAudioChunk> c = p->GetWade() ? audioDevice->RegisterSound("Sounds/Player/WaterJump.opus") : audioDevice->RegisterSound("Sounds/Player/Jump.opus"); audioDevice->Play(c, p->GetOrigin(), AudioParam()); } }
int CPlayerToolBar::GetVolume() const { int volume = m_volctrl.GetPos(); // [0..100] if (IsMuted() || volume <= 0) { volume = -10000; } else { volume = min((int)(4000 * log10(volume / 100.0f)), 0); // 4000=2.0*100*20, where 2.0 is a special factor } return volume; }
void Client::PlayerMissedSpade(spades::client::Player *p) { SPADES_MARK_FUNCTION(); if (!IsMuted()) { bool isLocal = p == world->GetLocalPlayer(); Handle<IAudioChunk> c = audioDevice->RegisterSound("Sounds/Weapons/Spade/Miss.opus"); if (isLocal) audioDevice->PlayLocal(c, MakeVector3(.2f, -.1f, 0.7f), AudioParam()); else audioDevice->Play(c, p->GetOrigin() + p->GetFront() * 0.8f - p->GetUp() * .2f, AudioParam()); } }
void Client::PlayerRestocked(spades::client::Player *p) { if (!IsMuted()) { bool isLocal = p == world->GetLocalPlayer(); Handle<IAudioChunk> c = isLocal ? audioDevice->RegisterSound("Sounds/Weapons/RestockLocal.opus") : audioDevice->RegisterSound("Sounds/Weapons/Restock.opus"); if (isLocal) audioDevice->PlayLocal(c, MakeVector3(.4f, -.3f, .5f), AudioParam()); else audioDevice->Play(c, p->GetEye() + p->GetFront() * 0.5f - p->GetUp() * .3f + p->GetRight() * .4f, AudioParam()); } }
void Client::PlayerLanded(spades::client::Player *p, bool hurt) { SPADES_MARK_FUNCTION(); if (!IsMuted()) { Handle<IAudioChunk> c; if (hurt) c = audioDevice->RegisterSound("Sounds/Player/FallHurt.opus"); else if (p->GetWade()) c = audioDevice->RegisterSound("Sounds/Player/WaterLand.opus"); else c = audioDevice->RegisterSound("Sounds/Player/Land.opus"); audioDevice->Play(c, p->GetOrigin(), AudioParam()); } }
void Client::PlayerDryFiredWeapon(spades::client::Player *p) { SPADES_MARK_FUNCTION(); if (!IsMuted()) { bool isLocal = p == world->GetLocalPlayer(); Handle<IAudioChunk> c = audioDevice->RegisterSound("Sounds/Weapons/DryFire.opus"); if (isLocal) audioDevice->PlayLocal(c, MakeVector3(.4f, -.3f, .5f), AudioParam()); else audioDevice->Play(c, p->GetEye() + p->GetFront() * 0.5f - p->GetUp() * .3f + p->GetRight() * .4f, AudioParam()); } }
void Client::PlayerSentChatMessage(spades::client::Player *p, bool global, const std::string &msg){ { std::string s; if(global) /// prefix added to global chat messages. s = _Tr("Client", "[Global] "); s += ChatWindow::TeamColorMessage(p->GetName(), p->GetTeamId()); s += ": "; s += msg; chatWindow->AddMessage(s); } { std::string s; if(global) s = "[Global] "; s += p->GetName(); s += ": "; s += msg; auto col = p->GetTeamId() < 2 ? world->GetTeam(p->GetTeamId()).color : IntVector3::Make(255, 255, 255); scriptedUI->RecordChatLog(s, MakeVector4(col.x / 255.f, col.y / 255.f, col.z / 255.f, 0.8f)); } if(global) NetLog("[Global] %s (%s): %s", p->GetName().c_str(), world->GetTeam(p->GetTeamId()).name.c_str(), msg.c_str()); else NetLog("[Team] %s (%s): %s", p->GetName().c_str(), world->GetTeam(p->GetTeamId()).name.c_str(), msg.c_str()); if((!IsMuted()) && (int)cg_chatBeep) { Handle<IAudioChunk> chunk = audioDevice->RegisterSound("Sounds/Feedback/Chat.wav"); audioDevice->PlayLocal(chunk, AudioParam()); } }
bool FOnlineVoiceSteam::UnmuteRemoteTalker(uint8 LocalUserNum, const FUniqueNetId& PlayerId, bool bIsSystemWide) { uint32 Return = E_FAIL; if (LocalUserNum >= 0 && LocalUserNum < MAX_LOCAL_PLAYERS) { if (bIsSystemWide) { // Remove them from the mute list SystemMuteList.RemoveSingleSwap((const FUniqueNetIdSteam&)PlayerId); ProcessMuteChangeNotification(); } else { // Skip this if the session isn't active if (SessionInt && SessionInt->GetNumSessions() > 0 && // Or if voice is disabled VoiceEngine.IsValid()) { // Find the specified talker FRemoteTalker* Talker = FindRemoteTalker(PlayerId); if (Talker != NULL) { // Make sure there isn't a system mute bool bIsMuted = IsMuted(LocalUserNum, PlayerId); if (!bIsMuted) { // Remove them from the mute list MuteList.RemoveSingleSwap((const FUniqueNetIdSteam&)PlayerId); UE_LOG(LogVoice, Log, TEXT("Unmuting remote talker (%s)"), *PlayerId.ToDebugString()); } } else { UE_LOG(LogVoice, Verbose, TEXT("Unknown remote talker (%s) specified to UnmuteRemoteTalker()"), *PlayerId.ToDebugString()); } } } } else { UE_LOG(LogVoice, Warning, TEXT("Invalid user specified in UnmuteRemoteTalker(%d)"), LocalUserNum); } return Return == S_OK; }
void Client::PlayerDestroyedBlockWithWeaponOrTool(spades::IntVector3 blk){ Vector3 origin = {blk.x + .5f, blk.y + .5f, blk.z + .5f}; if(!map->IsSolid(blk.x, blk.y, blk.z)) return;; Handle<IAudioChunk> c = audioDevice->RegisterSound("Sounds/Misc/BlockDestroy.wav"); if(!IsMuted()){ audioDevice->Play(c, origin, AudioParam()); } uint32_t col = map->GetColor(blk.x, blk.y, blk.z); IntVector3 colV = {(uint8_t)col, (uint8_t)(col >> 8), (uint8_t)(col >> 16)}; EmitBlockDestroyFragments(blk, colV); }
void Client::PlayerChangedTool(spades::client::Player *p) { SPADES_MARK_FUNCTION(); if (!IsMuted()) { bool isLocal = p == world->GetLocalPlayer(); Handle<IAudioChunk> c; if (isLocal) { // played by ClientPlayer::Update return; } else { c = audioDevice->RegisterSound("Sounds/Weapons/Switch.opus"); } if (isLocal) audioDevice->PlayLocal(c, MakeVector3(.4f, -.3f, .5f), AudioParam()); else audioDevice->Play(c, p->GetEye() + p->GetFront() * 0.5f - p->GetUp() * .3f + p->GetRight() * .4f, AudioParam()); } }
void Client::PlayerThrownGrenade(spades::client::Player *p, Grenade *g) { SPADES_MARK_FUNCTION(); if (!IsMuted()) { bool isLocal = p == world->GetLocalPlayer(); Handle<IAudioChunk> c = audioDevice->RegisterSound("Sounds/Weapons/Grenade/Throw.opus"); if (g && isLocal) { net->SendGrenade(g); } if (isLocal) audioDevice->PlayLocal(c, MakeVector3(.4f, 0.1f, .3f), AudioParam()); else audioDevice->Play(c, p->GetEye() + p->GetFront() * 0.5f - p->GetUp() * .2f + p->GetRight() * .3f, AudioParam()); } }
void Client::PlayerDiggedBlock(spades::IntVector3 blk){ Vector3 origin = {blk.x + .5f, blk.y + .5f, blk.z + .5f}; Handle<IAudioChunk> c = audioDevice->RegisterSound("Sounds/Misc/BlockDestroy.wav"); if(!IsMuted()){ audioDevice->Play(c, origin, AudioParam()); } for(int z = blk.z - 1 ; z <= blk.z + 1; z++){ if(z < 0 || z > 61) continue; if(!map->IsSolid(blk.x, blk.y, z)) continue; uint32_t col = map->GetColor(blk.x, blk.y, z); IntVector3 colV = {(uint8_t)col, (uint8_t)(col >> 8), (uint8_t)(col >> 16)}; EmitBlockDestroyFragments(IntVector3::Make(blk.x, blk.y, z), colV); } }
void Client::BlocksFell(std::vector<IntVector3> blocks) { SPADES_MARK_FUNCTION(); if (blocks.empty()) return; FallingBlock *b = new FallingBlock(this, blocks); AddLocalEntity(b); if (!IsMuted()) { IntVector3 v = blocks[0]; Vector3 o; o.x = v.x; o.y = v.y; o.z = v.z; o += .5f; Handle<IAudioChunk> c = audioDevice->RegisterSound("Sounds/Misc/BlockFall.opus"); audioDevice->Play(c, o, AudioParam()); } }
void Client::TeamCapturedTerritory(int teamId, int terId) { TCGameMode::Territory *ter = static_cast<TCGameMode *>(world->GetMode())->GetTerritory(terId); int old = ter->ownerTeamId; std::string msg; std::string teamName = chatWindow->TeamColorMessage(world->GetTeam(teamId).name, teamId); if(old < 2){ std::string otherTeam = chatWindow->TeamColorMessage(world->GetTeam(old).name, old); msg = _Tr("Client", "{0} captured {1}'s territory", teamName, otherTeam); }else{ msg = _Tr("Client", "{0} captured an neutral territory", teamName); } chatWindow->AddMessage(msg); if ((int)cg_centerMessage != 0){ teamName = world->GetTeam(teamId).name; if (old < 2){ std::string otherTeam = world->GetTeam(old).name; msg = _Tr("Client", "{0} captured {1}'s Territory", teamName, otherTeam); } else{ msg = _Tr("Client", "{0} captured an Neutral Territory", teamName); } NetLog("%s", msg.c_str()); centerMessageView->AddMessage(msg); } if(world->GetLocalPlayer() && !IsMuted()){ if(teamId == world->GetLocalPlayer()->GetTeamId()){ Handle<IAudioChunk> chunk = audioDevice->RegisterSound("Sounds/Feedback/TC/YourTeamCaptured.wav"); audioDevice->PlayLocal(chunk, AudioParam()); }else{ Handle<IAudioChunk> chunk = audioDevice->RegisterSound("Sounds/Feedback/TC/EnemyCaptured.wav"); audioDevice->PlayLocal(chunk, AudioParam()); } } }
void CPlayerToolBar::OnUpdateVolumeMute(CCmdUI* pCmdUI) { pCmdUI->Enable(true); pCmdUI->SetCheck(IsMuted()); }
BOOL CPlayerToolBar::OnVolumeMute(UINT nID) { AfxGetAppSettings().fMute = !IsMuted(); ArrangeControls(); return FALSE; }