void SoundEffectListDialog::AddSoundEffect(const SoundEffect &sfx)
{
    _sfx.append(sfx);
    auto startFrame = sfx.getStartFrame();
    auto filename = sfx.getFilename();
    auto inPoint = sfx.getInPoint();
    auto outPoint = sfx.getOutPoint();
    auto duration = outPoint - inPoint;
    auto linearVolume = sfx.getVolume() / 100.0;
    qreal logVolume = QAudio::convertVolume(linearVolume,
                                            QAudio::LinearVolumeScale,
                                            QAudio::LogarithmicVolumeScale);

    QTableWidgetItem *newItemFrame  = new QTableWidgetItem(QString::number(startFrame)); // Frame
    QTableWidgetItem *newItemFilename   = new QTableWidgetItem(filename); // Filename
    QTableWidgetItem *newItemStart   = new QTableWidgetItem(QString::number(inPoint)); // Start
    QTableWidgetItem *newItemEnd   = new QTableWidgetItem(QString::number(outPoint)); // End
    QTableWidgetItem *newItemDuration   = new QTableWidgetItem(QString::number(duration)); // Duration
    QTableWidgetItem *newItemVolume   = new QTableWidgetItem(QString::number(ceil(logVolume*100))); // Volume

    auto row = ui->tableWidget->rowCount();
    ui->tableWidget->insertRow(ui->tableWidget->rowCount());
    ui->tableWidget->setItem(row, 0, newItemFrame);
    ui->tableWidget->setItem(row, 1, newItemStart);
    ui->tableWidget->setItem(row, 2, newItemEnd);
    ui->tableWidget->setItem(row, 3, newItemDuration);
    ui->tableWidget->setItem(row, 4, newItemVolume);
    ui->tableWidget->setItem(row, 5, newItemFilename);
}
Ejemplo n.º 2
0
void Sound::playSfx(const std::string &path, int x, int y)
{
    if (!mInstalled || path.empty() || !mPlayBattle)
        return;

    std::string tmpPath;
    if (!path.compare(0, 4, "sfx/"))
        tmpPath = path;
    else
        tmpPath = paths.getValue("sfx", "sfx/") + path;
    ResourceManager *resman = ResourceManager::getInstance();
    SoundEffect *sample = resman->getSoundEffect(tmpPath);
    if (sample)
    {
        logger->log("Sound::playSfx() Playing: %s", path.c_str());
        int vol = 120;
        if (player_node && (x > 0 || y > 0))
        {
            int dx = player_node->getTileX() - x;
            int dy = player_node->getTileY() - y;
            if (dx < 0)
                dx = -dx;
            if (dy < 0)
                dy = -dy;
            int dist = dx > dy ? dx : dy;
            if (dist * 8 > vol)
                return;

            vol -= dist * 8;
        }
        sample->play(0, vol);
    }
}
void GameState_BasePlayable::OnGameFinished (bool successful) {
	finished = true;

	SoundEffect* finishSFX;
	finishSFX = successful ? new SoundEffect("Content/Audio/congrats.wav")
							: new SoundEffect("Content/Audio/caught.wav");
	finishSFX->oneShot = true;
	Sounds->RefreshVol_Effect_Of(finishSFX);
	finishSFX->Play();
}
Ejemplo n.º 4
0
void Sound::playSfx(const std::string &path)
{
    if (!mInstalled || path.empty())
        return;

    ResourceManager *resman = ResourceManager::getInstance();
    SoundEffect *sample = resman->getSoundEffect(
                                            paths.getStringValue("sfx") + path);
    if (sample)
    {
        logger->log("Sound::playSfx() Playing: %s", path.c_str());
        sample->play(0, 120);
    }
}
Ejemplo n.º 5
0
void Coin::OnIntersect (ColliderBase* other) {
	GameState_BasePlayable* playableState = dynamic_cast<GameState_BasePlayable*>(Game->GetGameStateMachine()->Top());

	if (playableState && other->entityType == ID_PLAYER) {
		playableState->PickedUpGold(MyMagicNumbers::goldValue_coin, this);

		GameObjects->Delete(this);

		SoundEffect* coinJingle = new SoundEffect("Content/Audio/coin.wav");
		coinJingle->oneShot = true;
		Sounds->RefreshVol_Effect_Of(coinJingle);
		coinJingle->Play();
	}
}
Ejemplo n.º 6
0
	void AudioManager::LoadEffect(
		const tstring& path,
		const tstring& name,
		float32 volume,
		uint8 channel
		)
	{
		Logger::GetInstance()->Log(mSoundService != nullptr,
			_T("Sound Service is invalid."),STARENGINE_LOG_TAG);

		if(mEffectsList.find(name) != mEffectsList.end())
		{
			star::Logger::GetInstance()->Log(LogLevel::Warning,
				_T("Sound Service: The effect '") + name +
				_T("' already exists."), STARENGINE_LOG_TAG);
			return;
		}

		auto pathit = mSoundEffectPathList.find(path);
		if(pathit != mSoundEffectPathList.end())
		{
			star::Logger::GetInstance()->Log(LogLevel::Warning,
				_T("Sound Service: Sound Effect Path Already Exists"),
				STARENGINE_LOG_TAG);
			tstring nameold = pathit->second;
			auto nameit = mMusicList.find(nameold);
			if(nameit!= mMusicList.end())
			{
				star::Logger::GetInstance()->
					Log(LogLevel::Warning,
					_T("Sound Service: Found Sound Effect of old path, making copy for new name"));
				mMusicList[name] = nameit->second;
			}
			mSoundEffectPathList.erase(pathit);
		}

		SoundEffect* effect = new SoundEffect(path, channel);
		effect->SetCompleteVolume(
			volume,
			GetChannelVolume(channel),
			GetVolume()
			);
		mEffectsList[name] = effect;
		mSoundEffectPathList[path] = name;
		return;
	}
Ejemplo n.º 7
0
SoundEffect * SoundSystem::RequestSoundEffect()
{
    SoundEffect* request = nullptr;
    if (!mFreeSoundEffect)
        return request;
    if (mFreeSoundEffect->mNext == mFreeSoundEffect)
    {
        request = mFreeSoundEffect;
        mFreeSoundEffect = nullptr;
    }
    else
    {
        request = mFreeSoundEffect->mNext;
        mFreeSoundEffect->mNext = request->mNext;
    }
    request->Reset();
    return request;
}
Ejemplo n.º 8
0
void Sound::playGuiSfx(const std::string &path)
{
    if (!mInstalled || path.empty() || !mPlayGui)
        return;

    std::string tmpPath;
    if (!path.compare(0, 4, "sfx/"))
        tmpPath = path;
    else
        tmpPath = paths.getValue("sfx", "sfx/") + path;
    ResourceManager *resman = ResourceManager::getInstance();
    SoundEffect *sample = resman->getSoundEffect(tmpPath);
    if (sample)
    {
        logger->log("Sound::playGuiSfx() Playing: %s", path.c_str());
        int ret = sample->play(0, 120, mGuiChannel);
        if (ret != -1)
            mGuiChannel = ret;
    }
}
Ejemplo n.º 9
0
SoundEffect SoundEffect::fromFile(const char* completePath) noexcept
{
	SoundEffect tmp = SoundEffect::fromFileNoLoad(completePath);
	tmp.load();
	return std::move(tmp);
}
Ejemplo n.º 10
0
void InterfaceSounds::PlaySelect()
{
   static SoundEffect selectSound(LocateResource("sounds/select.wav"));

   selectSound.Play();
}
Ejemplo n.º 11
0
void InterfaceSounds::PlayBleep()
{
   static SoundEffect bleepSound(LocateResource("sounds/bleep.wav"));

   bleepSound.Play();
}
void GameState_BasePlayable::HandleSFEvents(std::list<sf::Event>& sfEvents) {
	mMenuStateMachine->RefreshStack();

	if (inoutFader != 0) {
		if (cancelNavMapGenBtn)
			cancelNavMapGenBtn->HandleSFEvents(sfEvents);

		std::list<sf::Event>::iterator itSfEvent = sfEvents.begin();
		while (itSfEvent != sfEvents.end()) {
			switch (itSfEvent->Type) {
				case sf::Event::Closed:
					Game->GetRenderWindow()->Close();
				break;
				default:
				break;
			}

			++itSfEvent;
		}

		return;
	}

	if (!mMenuStateMachine->IsEmpty())
		mMenuStateMachine->HandleSFEvents(sfEvents);

	std::list<sf::Event>::iterator itSfEvent = sfEvents.begin();
	while (itSfEvent != sfEvents.end()) {
		switch (itSfEvent->Type) {
			case sf::Event::Closed:
				Game->GetRenderWindow()->Close();
			break;
			case sf::Event::KeyPressed:
				switch (itSfEvent->Key.Code) {
					case sf::Key::Escape:
						if (!finished) {
							if (!mMenuStateMachine->IsEmpty())
								OnPause(false);
							else
								OnPause(true);
						}
					break;
					case sf::Key::Space:
						if (HUD) {
							GameObject* interactee = HUD->GetInteractee();
							if (interactee) {
								if (interactee == chest && chest) {
									goldPickedUp += MyMagicNumbers::goldValue_chest;

									for (unsigned int i = 0; i != 2; ++i) {
										if (objectives[i] == chest) {
											OnObjectiveCompleted(i);
											objectives[i] = 0;
										}
									}
									PopWorldSpace(chest);
									delete chest;
									chest = 0;

									SoundEffect* coinJingle = new SoundEffect("Content/Audio/coin.wav");
									coinJingle->oneShot = true;
									Sounds->RefreshVol_Effect_Of(coinJingle);
									coinJingle->Play();

									HUD->SetAmountGold(goldPickedUp);

									HUD->SetInteractContextNote(0);
								}
								else if (/*interactee == princess && */princess) {
									princess->StartFollowing(princess->IsFollowingAnyone() ?
																0 : player);

									HUD->SetInteractContextNote(0);


									// if following than it's considered completed..
									if (princess->IsFollowingAnyone()) {
										for (unsigned int i = 0; i != 2; ++i) {
											// if it was the active objective
											if (objectives[i] == princess
													&& objectives[i]->objectiveState == ACTIVE) {
												OnObjectiveCompleted(i);
											}
										}
									}
									else {
										// However..
										for (unsigned int i = 0; i != 2; ++i) {
											// if the active objective is a goal
											if (objectives[i]
													&& objectives[i]->objectiveState == ACTIVE
													&& objectives[i]->entityType == ID_GOAL) {

												// looking backwards
												for (int j = i - 1; j >= 0; --j) {
													// j represents the last objective

													// if it was this princess
													if (objectives[j] == princess) {
														// then that princess should have been brought here

														// so we set the current goal state to inactive, and hide it
														objectives[i]->objectiveState = INACTIVE;
														PopWorldSpace(dynamic_cast<Goal*>(objectives[i]));

														// and reactivate the former princess objective
														objectives[j]->objectiveState = ACTIVE;
														HUD->SetObjective("Content/Textures/princess_thumbnail.png");
													}
												}

											}
										}
									}

								}
							}
						}
					break;
					default:
					break;
				}
			break;
			default:
			break;
		}

		++itSfEvent;
	}

	if (finished) {
		if (player) player->PauseAudio();
		if (princess) princess->PauseAudio();

		const EntityMap& guards = (*GameObjects)[ID_GUARD];
		for (EntityMap::const_iterator itG = guards.begin(); itG != guards.end(); itG++) {
			dynamic_cast<Guard*>(itG->second)->PauseAudio();
		}
	}
}