aboutsummaryrefslogtreecommitdiff
path: root/aoblipplayer.cpp
blob: 5e3929e266a539df67dd36ecbe03c24c0f31c22e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "aoblipplayer.h"

AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
{
  m_sfxplayer = new QSoundEffect;
  m_parent = parent;
  ao_app = p_ao_app;
}

AOBlipPlayer::~AOBlipPlayer()
{
  m_sfxplayer->stop();
  m_sfxplayer->deleteLater();
}

void AOBlipPlayer::set_blips(QString p_sfx)
{
  m_sfxplayer->stop();
  QString f_path = ao_app->get_sounds_path() + p_sfx.toLower();
  m_sfxplayer->setSource(QUrl::fromLocalFile(f_path));
  set_volume(m_volume);
}

void AOBlipPlayer::blip_tick()
{
  m_sfxplayer->play();
}

void AOBlipPlayer::set_volume(int p_value)
{
  m_volume = p_value;
  m_sfxplayer->setVolume(p_value / 100.0);
}