aboutsummaryrefslogtreecommitdiff
path: root/src/aosfxplayer.h
blob: 7669f0de9d7baa59abfdb50a3720fe8a4c215f2d (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
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include "aoapplication.h"

#include <bass.h>
#include <bassopus.h>

#include <QDebug>
#include <QWidget>

class AOSfxPlayer
{
public:
  static constexpr int STREAM_COUNT = 5;

  AOSfxPlayer(AOApplication *ao_app);

  int volume();
  void setVolume(int value);

  void play(QString path);
  void stop(int streamId = -1);
  void stopAll();
  void stopAllLoopingStream();

  void findAndPlaySfx(QString sfx);
  void findAndPlayCharacterSfx(QString sfx, QString character);
  void findAndPlayCharacterShout(QString shout, QString character, QString group);

  void setMuted(bool toggle);
  void setLooping(bool toggle, int streamId = -1);

private:
  AOApplication *ao_app;

  int m_volume = 0;
  bool m_muted = false;
  bool m_looping = true;
  HSTREAM m_stream[STREAM_COUNT]{};
  int m_current_stream_id = 0;

  int maybeFetchCurrentStreamId(int streamId);
  bool ensureValidStreamId(int streamId);
  void updateInternalVolume();
};