aboutsummaryrefslogtreecommitdiff
path: root/src/aosfxplayer.h
blob: b86e00b846505bdcc85f6a77103a324e71c26f81 (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
#pragma once

#include "aoapplication.h"

#include <QDebug>
#include <QWidget>

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

  AOSfxPlayer(AOApplication *ao_app);
  ~AOSfxPlayer();

  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;

  float m_volume = 0.0f;
  bool m_muted = false;
  ma_sound m_stream[STREAM_COUNT]{};
  int m_current_stream_id = 0;

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